Skip to content

Commit

Permalink
Bugfix: json-scheme changed after phpipam 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKuchin committed Jan 30, 2024
1 parent 091d12b commit d01bd48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
18 changes: 7 additions & 11 deletions internal/cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -82,16 +78,16 @@ 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 == "" {
log.Printf("WARNING: Skipping %s because IP is empty", address.Hostname)
} 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)

Check failure on line 92 in internal/cli/get.go

View workflow job for this annotation

GitHub Actions / build

log.Printf format %s has arg address.Tag of wrong type int
}
Expand Down Expand Up @@ -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 == "" {
Expand All @@ -187,8 +183,8 @@ 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)

Check failure on line 189 in internal/cli/get.go

View workflow job for this annotation

GitHub Actions / build

log.Printf format %s has arg address.Tag of wrong type int
}
Expand Down
16 changes: 8 additions & 8 deletions internal/cli/get_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ type IpamSubnet_list struct {
}

type Ipam_subnet_data struct {
Id string `json:"id"`
Id int `json:"id"`
}

type IPAddresses struct {
IPAddresses []IPAddress `json:"data"`
}

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"`
Expand Down

0 comments on commit d01bd48

Please sign in to comment.