Enable specifying mask length when creating IP addresses via available-ips endpoint #553

Closed
opened 2026-04-05 16:43:23 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @adionit7 on 1/16/2026

Fixes: #21144

Summary

Enable specifying a mask length when creating IP addresses via the available-ips REST API endpoint.

Changes

  • Updated AvailableIPAddressesView to use PrefixLengthSerializer as write_serializer_class
  • Enhanced PrefixLengthSerializer to support both 'prefix' and 'parent' context keys
  • Added validation to ensure requested prefix_length >= parent.mask_length
  • Updated prep_object_data to use requested prefix_length if provided, otherwise fall back to parent.mask_length for backwards compatibility
  • Updated API schema documentation

Example Usage

curl -X POST
-H "Authorization: Bearer "
-H "Content-Type: application/json"
http://netbox/api/ipam/prefixes/123/available-ips/
--data '{"prefix_length": 32}'

*Originally created by @adionit7 on 1/16/2026* ### Fixes: #21144 ## Summary Enable specifying a mask length when creating IP addresses via the available-ips REST API endpoint. ## Changes - Updated `AvailableIPAddressesView` to use `PrefixLengthSerializer` as `write_serializer_class` - Enhanced `PrefixLengthSerializer` to support both 'prefix' and 'parent' context keys - Added validation to ensure requested `prefix_length >= parent.mask_length` - Updated `prep_object_data` to use requested `prefix_length` if provided, otherwise fall back to `parent.mask_length` for backwards compatibility - Updated API schema documentation ## Example Usage curl -X POST \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ http://netbox/api/ipam/prefixes/123/available-ips/ \ --data '{"prefix_length": 32}'
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#553