go-netbox
go-netbox copied to clipboard
Unexpected error return from IpamPrefixesList
trafficstars
When running the following function:
package main
import (
"context"
"log"
"os"
"github.com/netbox-community/go-netbox/v4"
)
func main() {
ctx := context.Background()
client := netbox.NewAPIClientFor("https://netbox.zro.gcp.tempus.cloud", os.Getenv("NETBOX_API_TOKEN"))
prefixList, resp, err := client.IpamAPI.IpamPrefixesList(ctx).Execute()
if err != nil {
log.Printf("Num returned: %d", len(prefixList.Results))
log.Printf("HTTP RESP: %v", resp)
log.Fatalf("Failed to get prefixes: %v", err)
}
}
I'm seeing results where:
preflxListhas no results- RESP is a
200return with the expected prefix outputs in the JSON body - The value of the
errreturned is: no value given for required property prefix_count
Netbox version being run: v4.0.3
Based on the value of the response, I gather this is an issue with the parsing of this request, rather than an actual API issue.
I have the same problem with IpamIpRangesList and no value given for required property prefix_count.
I think the error in on the response parsing, role.prefix_count in my case (vrf.prefix_count in your's) is marked as required in OpenAPI spec but are not returned by the API:
GET /api/ipam/ip-ranges/?status=active
HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"url": "https://demo.netbox.dev/api/ipam/ip-ranges/1/",
"display_url": "https://demo.netbox.dev/ipam/ip-ranges/1/",
"display": "192.168.1.0-49/22",
"family": {
"value": 4,
"label": "IPv4"
},
"start_address": "192.168.1.0/22",
"end_address": "192.168.1.49/22",
"size": 50,
"vrf": null,
"tenant": null,
"status": {
"value": "active",
"label": "Actif"
},
"role": {
"id": 5,
"url": "https://demo.netbox.dev/api/ipam/roles/5/",
"display": "Testing",
"name": "Testing",
"slug": "testing",
"description": ""
},
"description": "Future use",
"comments": "",
"tags": [],
"custom_fields": {},
"created": "2021-12-30T00:00:00Z",
"last_updated": "2024-10-25T11:11:26.071302Z",
"mark_utilized": false
}
]
}
Fixed in #194