Expose depth and child count on prefix REST API serializer #4948

Closed
opened 2025-12-29 19:22:34 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (May 28, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.4

Feature type

Change to existing functionality

Proposed functionality

Add two read-only fields to the REST API serializer for the ipam.Prefix model:

  • _depth: Depth in the prefix hierarchy (e.g. a root-level prefix will have a depth of zero)
  • children: The number of child prefixes contained within this prefix

The leading underscore in the name of the depth field is consistent with models which employ MPTT to maintain a hierarchy, such as dcim.Region.

Use case

Following the work implemented under #6087, it is now possible to include this data with no performance impact.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (May 28, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.4 ### Feature type Change to existing functionality ### Proposed functionality Add two read-only fields to the REST API serializer for the ipam.Prefix model: - `_depth`: Depth in the prefix hierarchy (e.g. a root-level prefix will have a depth of zero) - `children`: The number of child prefixes contained within this prefix The leading underscore in the name of the depth field is consistent with models which employ MPTT to maintain a hierarchy, such as dcim.Region. ### Use case Following the work implemented under #6087, it is now possible to include this data with no performance impact. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:22:34 +01:00
adam closed this issue 2025-12-29 19:22:34 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4948