Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes docs of what it should be. #195

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions development/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3"

x-common: &common
image: "${IMAGE_NAME}:${IMAGE_VER}"
volumes:
Expand Down
77 changes: 44 additions & 33 deletions pynautobot/models/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,62 +31,73 @@ def __str__(self):

@property
def available_ips(self):
"""Represents the ``available-ips`` detail endpoint.
"""
Represents the ``available-ips`` detail endpoint.

Returns a DetailEndpoint object that is the interface for
viewing and creating IP addresses inside a prefix.

:returns: :py:class:`.DetailEndpoint`

:Examples:
Returns:
DetailEndpoint: The detail endpoint interface for available IPs.

>>> prefix = nb.ipam.prefixes.get(24)
>>> prefix.available_ips.list()
[{u'vrf': None, u'family': 4, u'address': u'10.1.1.49/30'}...]
Examples:
List available IPs:

To create a single IP:
>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> prefix.available_ips.list()
[
<pynautobot.models.ipam.IpAddresses ('10.0.192.1/18') at 0x103cb59d0>,
<pynautobot.models.ipam.IpAddresses ('10.0.192.2/18') at 0x103cefb90>,
...
]

>>> prefix = nb.ipam.prefixes.get(24)
>>> prefix.available_ips.create()
{u'status': 1, u'description': u'', u'nat_inside': None...}
To create a single IP:

>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> ip_address = prefix.available_ips.create({"status": "Active"})
>>> ip_address
<pynautobot.models.ipam.IpAddresses ('10.0.192.1/18') at 0x7f7b595e6160>

To create multiple IPs:
To create multiple IPs:

>>> prefix = nb.ipam.prefixes.get(24)
>>> create = prefix.available_ips.create([{} for i in range(2)])
>>> len(create)
2
>>> prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
>>> ip_addresses = prefix.available_ips.create([{"status": "Active"} for i in range(2)])
>>> len(create)
2
"""

return DetailEndpoint(self, "available-ips", custom_return=IpAddresses)

@property
def available_prefixes(self):
"""Represents the ``available-prefixes`` detail endpoint.
"""
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 :py:meth:`~pynautobot.ipam.Prefixes.available_ips`
, except that dict (or list of dicts) passed to ``.create()``
needs to have a ``prefix_length`` key/value specifed.

:returns: :py:class:`.DetailEndpoint`

:Examples:
Very similar to :py:meth:`~pynautobot.ipam.Prefixes.available_ips`,
except that the dict (or list of dicts) passed to ``.create()``
needs to have a ``prefix_length`` key/value specified.

>>> prefix.available_prefixes.list()
[{u'prefix': u'10.1.1.44/30', u'vrf': None, u'family': 4}]
Returns:
DetailEndpoint: The detail endpoint interface for available prefixes.

Examples:
List available prefixes:

Creating a single child prefix:
>>> prefix = nb.ipam.prefixes.get(prefix="10.0.0.0/16")
>>> prefix.available_prefixes.list()
[<pynautobot.models.ipam.Prefixes ('10.1.0.0/16') at 0x7f7b595f0b80>]

>>> prefix = nb.ipam.prefixes.get(1)
>>> new_prefix = prefix.available_prefixes.create(
... {'prefix_length': 29}
...)
>>> new_prefix['prefix']
u'10.1.1.56/29'
Creating a single child prefix:

>>> new_prefix = prefix.available_prefixes.create({
'prefix_length': 24,
'status': 'Active',
'type': 'network',
})
>>> new_prefix
<pynautobot.models.ipam.Prefixes ('10.0.0.0/24') at 0x7f7b595e6c70>
"""
return DetailEndpoint(self, "available-prefixes", custom_return=Prefixes)
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def down(context, remove=False):
}
)
def logs(context, service="", follow=False, tail=None):
"""View the logs of a docker-compose service."""
"""View the logs of a docker compose service."""
command = [
"docker compose logs",
"--follow" if follow else "",
Expand Down Expand Up @@ -319,7 +319,7 @@ def wait(context):
@task
def export(context):
"""Export compose configuration to `compose.yaml` file."""
context.run("docker-compose convert > compose.yaml", env=_DOCKER_COMPOSE_ENV, pty=True)
context.run("docker compose convert > compose.yaml", env=_DOCKER_COMPOSE_ENV, pty=True)


@task
Expand Down
Loading