Skip to content

App

pynautobot.core.app

This module defines the App and PluginsApp classes for interacting with Nautobot applications and plugins.

pynautobot.core.app.App

Represents apps in Nautobot.

Calls to attributes are returned as Endpoint objects.

Returns:

Type Description
Endpoint

Matching requested attribute.

Raises:

Type Description
RequestError

If requested endpoint doesn't exist.

__dir__()

Get the directory of the App object.

__getattr__(name)

Get an attribute from the App object.

__getstate__()

Get the state of the App object.

__init__(api, name)

Initialize the App object.

__setstate__(d)

Set the state of the App object.

choices()

Returns _choices response from App.

Returns:

Type Description
List[Response]

Raw response from Nautobot's _choices endpoint.

config()

Returns config response from app.

Returns:

Type Description
dict

Raw response from Nautobot's config endpoint.

Raises:

Type Description
RequestError

If called for an invalid endpoint.

Example

pprint.pprint(nb.users.config()) {'tables': {'DeviceTable': {'columns': ['name', 'status', 'tenant', 'device_role', 'site', 'primary_ip', 'tags']}}}

get_custom_field_choices()

Returns custom-field-choices response from app.

Returns:

Type Description
List[Response]

Raw response from Nautobot's custom-field-choices endpoint.

Raises:

Type Description
RequestError

If called for an invalid endpoint.

Examples:

>>> nb.extras.get_custom_field_choices()
[
    {
        "id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c",
        "display": "First option",
        "url": "http://localhost:8000/api/extras/custom-field-choices/5b39ba88-e5ab-4be2-89f5-5a016473b53c/",
        "field": {
            "display": "Test custom field 2",
            "id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c",
            "url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/",
            "name": "test_custom_field_2"
        },
        "value": "First option",
        "weight": 100,
        "created": "2023-04-15",
        "last_updated": "2023-04-15T18:11:57.163237Z"
    },
]

get_custom_fields()

Returns custom-fields response from app.

Returns:

Type Description
List[Response]

Raw response from Nautobot's custom-fields endpoint.

Raises:

Type Description
RequestError

If called for an invalid endpoint.

Examples:

>>> nb.extras.get_custom_fields()
[
    {
        "id": "5b39ba88-e5ab-4be2-89f5-5a016473b53c",
        "display": "Test custom field",
        "url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/",
        "content_types": ["dcim.rack"],
        "type": {"value": "integer", "label": "Integer"},
        "label": "Test custom field",
        "name": "test_custom_field",
        "slug": "test_custom_field",
        "description": "",
        "required": False,
        "filter_logic": {"value": "loose", "label": "Loose"},
        "default": None,
        "weight": 100,
        "validation_minimum": None,
        "validation_maximum": None,
        "validation_regex": "",
        "created": "2023-04-15",
        "last_updated": "2023-04-15T17:45:11.839431Z",
        "notes_url": "http://localhost:8000/api/extras/custom-fields/5b39ba88-e5ab-4be2-89f5-5a016473b53c/notes/",
    },
]

pynautobot.core.app.PluginsApp

Add plugins to the URL path.

Basically, valid plugins API could be handled by the same App class, but you need to add "plugins" to the request URL path.

Returns:

Type Description
App

With "plugins" added to the path.

__dir__()

Get the directory of the PluginsApp object.

__getattr__(name)

Get an attribute from the PluginsApp object.

__init__(api)

Initialize the PluginsApp object.

installed_plugins()

Returns raw response with installed plugins.

Returns:

Type Description
List[Response]

Raw response from Nautobot's installed plugins.

Examples:

>>> nb.plugins.installed_plugins()
[{
    'name': 'test_plugin',
    'package': 'test_plugin',
    'author': 'Dmitry',
    'description': 'Nautobot test plugin',
    'verison': '0.10'
}]