Add Prefix utilization to API #6619

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

Originally created by @empusas on GitHub (Jul 2, 2022).

NetBox version

v3.2.6

Feature type

New functionality

Proposed functionality

Add the prefix utilization to the API. The utilization is a useful information for people who use the Netbox API for their own automation.
The code to add is simple as the models.py for IPAM has already the required function used by the Web UI.

Code to add to the prefix serializer:

utilization = serializers.SerializerMethodField('get_utilization')

def get_utilization(self, obj):
    utilization = obj.get_utilization()
    return utilization

I am happy to make the changes and create a pull request if the feature is accepted.

Use case

API users get the utilization of a prefix in a percentage value. That would be helpful to create reports or get an overview about IP usage.

Database changes

NA

External dependencies

NA

Originally created by @empusas on GitHub (Jul 2, 2022). ### NetBox version v3.2.6 ### Feature type New functionality ### Proposed functionality Add the prefix utilization to the API. The utilization is a useful information for people who use the Netbox API for their own automation. The code to add is simple as the models.py for IPAM has already the required function used by the Web UI. Code to add to the prefix serializer: ``` utilization = serializers.SerializerMethodField('get_utilization') def get_utilization(self, obj): utilization = obj.get_utilization() return utilization ``` I am happy to make the changes and create a pull request if the feature is accepted. ### Use case API users get the utilization of a prefix in a percentage value. That would be helpful to create reports or get an overview about IP usage. ### Database changes NA ### External dependencies NA
adam added the type: featurestatus: duplicatenetbox labels 2025-12-29 19:43:13 +01:00
adam closed this issue 2025-12-29 19:43:13 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 5, 2022):

The manner in which prefix utilization is currently calculated is too inefficient to include by default in REST API responses. Marking this as blocked by #7845, which, if implemented, should make this feasible.

@jeremystretch commented on GitHub (Jul 5, 2022): The manner in which prefix utilization is currently calculated is too inefficient to include by default in REST API responses. Marking this as blocked by #7845, which, if implemented, should make this feasible.
Author
Owner

@jeremystretch commented on GitHub (Mar 14, 2025):

I think this is covered by #7292, so I'll mark it as a duplicate.

@jeremystretch commented on GitHub (Mar 14, 2025): I think this is covered by #7292, so I'll mark it as a duplicate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6619