Add support for "limit" query parameter to available VLANs endpoint #6828

Closed
opened 2025-12-29 19:45:49 +01:00 by adam · 2 comments
Owner

Originally created by @RobinGeuze on GitHub (Aug 17, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2.9

Python version

3.10

Steps to Reproduce

  1. Create a new VlanGroup with minvid set to 1 and maxvid set to 4094
  2. Call the available-vlans endpoint with ?limit=1

Expected Behavior

Get back one available-vlan object

Observed Behavior

Get back 4094 available-vlan objects, which in my case causes partial responses to be send which leads to invalid JSON with all associated issues. This only seems to happen with the Guzzle PHP HTTP client, works "fine" in the browser, except for the fact that the request obviously takes ages.

Available-prefix works a bit different and available-ips does seem to support the limit parameter.

Originally created by @RobinGeuze on GitHub (Aug 17, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2.9 ### Python version 3.10 ### Steps to Reproduce 1. Create a new VlanGroup with minvid set to 1 and maxvid set to 4094 2. Call the available-vlans endpoint with ?limit=1 ### Expected Behavior Get back one available-vlan object ### Observed Behavior Get back 4094 available-vlan objects, which in my case causes partial responses to be send which leads to invalid JSON with all associated issues. This only seems to happen with the Guzzle PHP HTTP client, works "fine" in the browser, except for the fact that the request obviously takes ages. Available-prefix works a bit different and available-ips does seem to support the limit parameter.
adam added the status: acceptedtype: feature labels 2025-12-29 19:45:49 +01:00
adam closed this issue 2025-12-29 19:45:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 22, 2022):

Pagination is not currently supported for available VLANs because they do not equate to records in the database. The same is true for e.g. available IP addresses. (The available-ips/ endpoints do support the limit query parameter, but not pagination of results.)

We could add support for the limit parameter pretty easily, however it would involve abstracting the logic currently in place under AvailableIPAddressesView's get() method into a reusable function. It should probably also be replicated to AvailablePrefixesView.

@jeremystretch commented on GitHub (Aug 22, 2022): Pagination is not currently supported for available VLANs because they do not equate to records in the database. The same is true for e.g. available IP addresses. (The `available-ips/` endpoints do support the `limit` query parameter, but not pagination of results.) We could add support for the `limit` parameter pretty easily, however it would involve abstracting the logic currently in place under AvailableIPAddressesView's `get()` method into a reusable function. It should probably also be replicated to AvailablePrefixesView.
Author
Owner

@RobinGeuze commented on GitHub (Aug 23, 2022):

Ye I noticed the lack of pagination after submitting this. Isolating the limit code in a separate function would be nice, although I would need a bit of guidance as to where I could put that function best.

As for available-prefix, I think that is a bit of an exception. Rather than returning all available prefixes it only returns the set of the biggest possible prefixes. Also the write variant works different because you just request a prefix of a certain size without specifying the actual prefix unlike available-ips/vlans.

@RobinGeuze commented on GitHub (Aug 23, 2022): Ye I noticed the lack of pagination after submitting this. Isolating the limit code in a separate function would be nice, although I would need a bit of guidance as to where I could put that function best. As for available-prefix, I think that is a bit of an exception. Rather than returning all available prefixes it only returns the set of the biggest possible prefixes. Also the write variant works different because you just request a prefix of a certain size without specifying the actual prefix unlike available-ips/vlans.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6828