IPAM
pynetbox.models.ipam.Prefixes (Record)
Source code in pynetbox/models/ipam.py
class Prefixes(Record):
def __str__(self):
return str(self.prefix)
@property
def available_ips(self):
"""Represents the ``available-ips`` detail endpoint.
Returns a DetailEndpoint object that is the interface for
viewing and creating IP addresses inside a prefix.
## Returns
DetailEndpoint object.
## Examples
```python
prefix = nb.ipam.prefixes.get(24)
prefix.available_ips.list()
# [10.0.0.1/24, 10.0.0.2/24, 10.0.0.3/24, 10.0.0.4/24, 10.0.0.5/24, ...]
```
To create a single IP:
```python
prefix = nb.ipam.prefixes.get(24)
prefix.available_ips.create()
# 10.0.0.1/24
```
To create multiple IPs:
```python
prefix = nb.ipam.prefixes.get(24)
create = prefix.available_ips.create([{} for i in range(2)])
# [10.0.0.2/24, 10.0.0.3/24]
```
"""
return DetailEndpoint(self, "available-ips", custom_return=IpAddresses)
@property
def available_prefixes(self):
"""Represents the ``available-prefixes`` detail endpoint.
Returns a DetailEndpoint object that is the interface for
viewing and creating prefixes inside a parent prefix.
Very similar to `available_ips`, except that dict (or list of dicts) passed to `.create()`
needs to have a `prefix_length` key/value specified.
## Returns
DetailEndpoint object.
## Examples
```python
prefix = nb.ipam.prefixes.get(3)
prefix
# 10.0.0.0/16
prefix.available_prefixes.list()
# [10.0.1.0/24, 10.0.2.0/23, 10.0.4.0/22, 10.0.8.0/21, 10.0.16.0/20, 10.0.32.0/19, 10.0.64.0/18, 10.0.128.0/17]
```
Creating a single child prefix:
```python
prefix = nb.ipam.prefixes.get(1)
prefix
# 10.0.0.0/24
new_prefix = prefix.available_prefixes.create(
{"prefix_length": 29}
)
# 10.0.0.16/29
```
"""
return DetailEndpoint(self, "available-prefixes", custom_return=Prefixes)
available_ips
property
readonly
Represents the available-ips
detail endpoint.
Returns a DetailEndpoint object that is the interface for viewing and creating IP addresses inside a prefix.
Returns
DetailEndpoint object.
Examples
prefix = nb.ipam.prefixes.get(24)
prefix.available_ips.list()
# [10.0.0.1/24, 10.0.0.2/24, 10.0.0.3/24, 10.0.0.4/24, 10.0.0.5/24, ...]
To create a single IP:
To create multiple IPs:
available_prefixes
property
readonly
Represents the available-prefixes
detail endpoint.
Returns a DetailEndpoint object that is the interface for viewing and creating prefixes inside a parent prefix.
Very similar to available_ips
, except that dict (or list of dicts) passed to .create()
needs to have a prefix_length
key/value specified.
Returns
DetailEndpoint object.
Examples
prefix = nb.ipam.prefixes.get(3)
prefix
# 10.0.0.0/16
prefix.available_prefixes.list()
# [10.0.1.0/24, 10.0.2.0/23, 10.0.4.0/22, 10.0.8.0/21, 10.0.16.0/20, 10.0.32.0/19, 10.0.64.0/18, 10.0.128.0/17]
Creating a single child prefix:
pynetbox.models.ipam.VlanGroups (Record)
Source code in pynetbox/models/ipam.py
class VlanGroups(Record):
@property
def available_vlans(self):
"""Represents the ``available-vlans`` detail endpoint.
Returns a DetailEndpoint object that is the interface for
viewing and creating VLANs inside a VLAN group.
## Returns
DetailEndpoint object.
## Examples
```python
vlan_group = nb.ipam.vlan_groups.get(1)
vlan_group.available_vlans.list()
# [10, 11, 12]
```
To create a new VLAN:
```python
vlan_group.available_vlans.create({"name": "NewVLAN"})
# NewVLAN (10)
```
"""
return DetailEndpoint(self, "available-vlans", custom_return=Vlans)
available_vlans
property
readonly
Represents the available-vlans
detail endpoint.
Returns a DetailEndpoint object that is the interface for viewing and creating VLANs inside a VLAN group.
Returns
DetailEndpoint object.
Examples
To create a new VLAN: