diff --git a/internal/cli/get.go b/internal/cli/get.go index 4ef8bf0..b9e0758 100644 --- a/internal/cli/get.go +++ b/internal/cli/get.go @@ -29,11 +29,7 @@ func getSubnetID(client api_client.Authenticator, cfg *config_reader.Config, sub return subnet_id, err } - subnet_id, err = strconv.Atoi(subnets.Subnets[0].Id) - if err != nil { - log.Printf("Error converting subnet id to int: %s", err.Error()) - return subnet_id, err - } + subnet_id = subnets.Subnets[0].Id return subnet_id, nil } @@ -82,7 +78,7 @@ func getPiHoleCustomOutput(addresses IPAddresses, cfg *config_reader.Config) str for _, address := range addresses.IPAddresses { switch address.Tag { - case "2": // In Use + case 2: // In Use if address.Hostname == "" { log.Printf("WARNING: Skipping %s because hostname is empty", address.IP) } else if address.IP == "" { @@ -90,10 +86,10 @@ func getPiHoleCustomOutput(addresses IPAddresses, cfg *config_reader.Config) str } else { output += address.IP + " " + address.Hostname + "." + cfg.Domain + "\n" } - case "3": // Reserved - case "4": // DHCP pool + case 3: // Reserved + case 4: // DHCP pool default: - log.Printf("WARNING: Skipping %s because tag is %s", address.IP, address.Tag) + log.Printf("WARNING: Skipping %s because tag is %v", address.IP, address.Tag) } } @@ -170,7 +166,7 @@ func getCiscoDHCPOutputBySubnet(addresses IPAddresses, subnet string) (string, e for _, address := range addresses.IPAddresses { switch address.Tag { - case "2": // In Use + case 2: // In Use if address.Hostname == "" { log.Printf("WARNING: Skipping %s because hostname is empty", address.IP) } else if address.IP == "" { @@ -187,10 +183,10 @@ func getCiscoDHCPOutputBySubnet(addresses IPAddresses, subnet string) (string, e output += " default-router " + gw + "\n" output += "!\n" } - case "3": // Reserved - case "4": // DHCP pool + case 3: // Reserved + case 4: // DHCP pool default: - log.Printf("WARNING: Skipping %s because tag is %s", address.IP, address.Tag) + log.Printf("WARNING: Skipping %s because tag is %v", address.IP, address.Tag) } } diff --git a/internal/cli/get_types.go b/internal/cli/get_types.go index bfdb8c1..4b162e7 100644 --- a/internal/cli/get_types.go +++ b/internal/cli/get_types.go @@ -6,7 +6,7 @@ type IpamSubnet_list struct { } type Ipam_subnet_data struct { - Id string `json:"id"` + Id int `json:"id"` } type IPAddresses struct { @@ -14,22 +14,22 @@ type IPAddresses struct { } type IPAddress struct { - ID string `json:"id"` - SubnetID string `json:"subnetId"` + ID int `json:"id"` + SubnetID int `json:"subnetId"` IP string `json:"ip"` - IsGateway string `json:"is_gateway"` + IsGateway int `json:"is_gateway"` Description string `json:"description"` Hostname string `json:"hostname"` Mac string `json:"mac"` Owner string `json:"owner"` - Tag string `json:"tag"` - DeviceID string `json:"deviceId"` + Tag int `json:"tag"` + DeviceID int `json:"deviceId"` Location string `json:"location"` Port string `json:"port"` Note string `json:"note"` LastSeen string `json:"lastSeen"` - ExcludePing string `json:"excludePing"` - PTRignore string `json:"PTRignore"` + ExcludePing int `json:"excludePing"` + PTRignore int `json:"PTRignore"` Ptr string `json:"PTR"` FirewallAddressObject string `json:"firewallAddressObject"` EditDate string `json:"editDate"`