mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-21 02:58:43 -06:00
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CI / build (20.x, 3.14) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
* Enable specifying mask length when creating IP addresses via available-ips endpoint Fixes #21144 Allow clients to specify an arbitrary mask length when creating IP addresses from a parent prefix or range using the 'next available' 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 to reflect PrefixLengthSerializer usage This enables use cases like creating loopback IP addresses with /32 mask length from a parent prefix with a shorter mask length. * Refine available-ips prefix length handling Keep PrefixLengthSerializer strict for available-prefixes and introduce AvailableIPRequestSerializer for the available-ips endpoint, where prefix_length is optional and validated against the parent prefix/range. * Revert PrefixLengthSerializer to original strict state PrefixLengthSerializer should remain required and strict for the available-prefixes endpoint. The optional prefix_length functionality for available-ips is handled by AvailableIPRequestSerializer. * Add API test; misc cleanup --------- Co-authored-by: adionit7 <adionit7@users.noreply.github.com> Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>