Skip to content

Commit

Permalink
Merge pull request #13 from IvanKuchin/development
Browse files Browse the repository at this point in the history
Bugfix: json-scheme changed after phpipam 1.6.0
  • Loading branch information
IvanKuchin authored Jan 30, 2024
2 parents 091d12b + 1cec496 commit e61604b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
22 changes: 9 additions & 13 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,18 +78,18 @@ 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)
log.Printf("WARNING: Skipping %s because tag is %v", address.IP, address.Tag)
}
}

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,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)
}
}

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 e61604b

Please sign in to comment.