package com.suse.salt.netapi.calls.modules;

import com.suse.salt.netapi.calls.LocalCall;

import com.google.gson.reflect.TypeToken;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * salt.modules.network
 */
public class Network {

    private Network() { }

    /**
     * Network interface as returned by "network.interfaces".
     */
    public static class Interface {

        private String hwaddr;
        private boolean up;
        private List<INet> inet;
        private List<INet6> inet6;

        /**
         * @return the hwaddr
         */
        public String getHWAddr() {
            return hwaddr;
        }

        /**
         * @return the up
         */
        public boolean isUp() {
            return up;
        }

        /**
         * @return the inet
         */
        public List<INet> getInet() {
            return inet;
        }

        /**
         * @return the inet6
         */
        public List<INet6> getInet6() {
            return inet6;
        }
    }

    /**
     * Network interface as returned by "network.interfaces".
     */
    public static class INet {

        private String broadcast;
        private String netmask;
        private String label;
        private String address;

        /**
         * @return the broadcast
         */
        public String getBroadcast() {
            return broadcast;
        }

        /**
         * @return the netmask
         */
        public String getNetmask() {
            return netmask;
        }

        /**
         * @return the label
         */
        public String getLabel() {
            return label;
        }

        /**
         * @return the address
         */
        public String getAddress() {
            return address;
        }
    }

    /**
     * Network interface (IPv6) as returned by "network.interfaces".
     */
    public static class INet6 {

        private String prefixlen;
        private String address;
        private String scope;

        /**
         * @return the prefixlen
         */
        public String getPrefixlen() {
            return prefixlen;
        }

        /**
         * @return the address
         */
        public String getAddress() {
            return address;
        }

        /**
         * @return the scope
         */
        public String getScope() {
            return scope;
        }
    }

    public static LocalCall<Map<String, Interface>> interfaces() {
        return new LocalCall<>("network.interfaces", Optional.empty(), Optional.empty(),
                new TypeToken<Map<String, Interface>>(){});
    }
}

@@ -1158,22 +1158,32 @@
 private 
+Optional%3C
 String
+%3E
  broadca
@@ -1202,22 +1202,32 @@
 private 
+Optional%3C
 String
+%3E
  netmask
@@ -1244,22 +1244,32 @@
 private 
+Optional%3C
 String
+%3E
  label;%0A
@@ -1276,38 +1276,48 @@
         private 
+Optional%3C
 String
+%3E
  address;%0A%0A     
@@ -1379,30 +1379,40 @@
      public 
+Optional%3C
 String
+%3E
  getBroadcas
@@ -1524,30 +1524,40 @@
      public 
+Optional%3C
 String
+%3E
  getNetmask(
@@ -1663,30 +1663,40 @@
      public 
+Optional%3C
 String
+%3E
  getLabel() 
@@ -1796,38 +1796,48 @@
 %0A        public 
+Optional%3C
 String
+%3E
  getAddress() %7B%0A

make inet fields optional