nautobot.apps.secrets - Nautobot Documentation

Skip to content

# `nautobot.apps.secrets`

Integrations with Nautobot's secrets feature.

## `nautobot.apps.secrets.SecretsProvider`

Bases: `ABC`

Abstract base class for concrete providers of secret retrieval features.

Source code in `nautobot/extras/secrets/__init__.py`

     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    class SecretsProvider(ABC):
        """Abstract base class for concrete providers of secret retrieval features."""

        def __repr__(self):
            return f"<{self.name}>"

        @property
        @abstractmethod
        def slug(self):
            """String uniquely identifying this class; will be used as a key to look up the class owning a given Secret."""

        @property
        def name(self):
            """Human-friendly name for this class, falling back to the slug if not overridden."""
            return self.slug

        @property
        @abstractmethod
        def ParametersForm(self):
            """Django Form class with inputs for describing the parameter(s) required for a Secret to use this Provider.

            The clean() method may be implemented to provide additional input validation.
            """

        @classmethod
        @abstractmethod
        def get_value_for_secret(cls, secret, obj=None, **kwargs):
            """Retrieve the stored value described by the given Secret record.

            May raise a SecretError or one of its subclasses if an error occurs.

            Args:
                secret (nautobot.extras.models.Secret): DB entry describing the secret or family of secrets in question.
                obj (object): Django model instance or similar providing additional context for retrieving the secret.
            """

### `ParametersForm` `abstractmethod` `property`

Django Form class with inputs for describing the parameter(s) required for a Secret to use this Provider.

The clean() method may be implemented to provide additional input validation.

### `name` `property`

Human-friendly name for this class, falling back to the slug if not overridden.

### `slug` `abstractmethod` `property`

String uniquely identifying this class; will be used as a key to look up the class owning a given Secret.

### `get_value_for_secret(secret, obj=None, **kwargs)` `abstractmethod` `classmethod`

Retrieve the stored value described by the given Secret record.

May raise a SecretError or one of its subclasses if an error occurs.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`secret` | `nautobot.extras.models.Secret` | DB entry describing the secret or family of secrets in question. | required
`obj` | `object` | Django model instance or similar providing additional context for retrieving the secret. | `None`

Source code in `nautobot/extras/secrets/__init__.py`

    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    @classmethod
    @abstractmethod
    def get_value_for_secret(cls, secret, obj=None, **kwargs):
        """Retrieve the stored value described by the given Secret record.

        May raise a SecretError or one of its subclasses if an error occurs.

        Args:
            secret (nautobot.extras.models.Secret): DB entry describing the secret or family of secrets in question.
            obj (object): Django model instance or similar providing additional context for retrieving the secret.
        """