Skip to content

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

@jeremystretch

Description

@jeremystretch

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

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions