netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

Add `AsnRanges.available_asns` (for NetBox 3.5+) #542

Closed markkuleinio closed 1 year ago

markkuleinio commented 1 year ago

Example:

>>> asn_range = nb.ipam.asn_ranges.get(1)
>>> asn_range
TestRange (65510-65512)
>>> pprint.pprint(dict(asn_range))
{'created': '2023-04-16T10:59:57.566139+03:00',
 'custom_fields': {},
 'description': '',
 'display': 'TestRange (65510-65512)',
 'end': 65512,
 'id': 1,
 'last_updated': '2023-04-16T11:13:15.835726+03:00',
 'name': 'TestRange',
 'rir': {'display': 'RFC1918',
         'id': 1,
         'name': 'RFC1918',
         'slug': 'rfc1918',
         'url': 'http://netbox-future.lein.io/api/ipam/rirs/1/'},
 'slug': 'testrange',
 'start': 65510,
 'tags': [],
 'tenant': None,
 'url': 'http://netbox-future.lein.io/api/ipam/asn-ranges/1/'}
>>> asn_range.available_asns
<pynetbox.core.endpoint.DetailEndpoint object at 0x7f0224cc9a58>
>>> asn_range.available_asns.list()
[65510, 65511, 65512]
>>>
abhi1693 commented 1 year ago

This will be superseded by #564 once that's merged.