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
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) classmethod abstractmethod

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
@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.
    """