Secret

A class for working with Secret manifests and the Secret Django ORM.

class smarter.apps.account.manifest.transformers.secret.SecretSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

Secret serializer for Smarter api.

class smarter.apps.account.manifest.transformers.secret.SecretTransformer(*args, user_profile, name=None, api_version=None, manifest=None, secret_id=None, secret=None, data=None, **kwargs)[source]

Bases: SmarterHelperMixin

A class for working with secrets.

__init__(*args, user_profile, name=None, api_version=None, manifest=None, secret_id=None, secret=None, data=None, **kwargs)[source]

Options for initialization are: - name: name of the secret, for initializing the Django ORM model. - Pydantic model created by a manifest broker (preferred method). - django model secret id. - yaml manifest or json representation of a yaml manifest see ./tests/data/secret-good.yaml for an example.

property annotations: list[dict[str, Any]]

Return the secret annotations.

property api_version: str

Return the api version of the secret.

create()[source]

Create a secret from either yaml or a dictionary.

Return type:

bool

property created_at: str | None

Return the created date.

property data: dict | None

Return the secret as a dictionary.

delete()[source]

Delete a secret.

Return type:

bool

property description: str | None

Return the secret description.

property encrypted_value: bytes | None

Return the encrypted secret value.

classmethod example_manifest(kwargs=None)[source]
Return type:

dict

property expires_at: datetime | None

Return the expiration date in the format, YYYY-MM-DD

property id: int | None

Return the id of the secret.

is_valid_yaml(data)[source]

Validate a yaml string.

Return type:

bool

property kind: str

Return the kind of manifest.

property last_accessed: str | None

Return the last accessed date.

property manifest: SAMSecret | None

Return the Pydandic model of the secret.

manifest_to_django_orm()[source]

Return a dict for loading the secret Django ORM model.

Return type:

Optional[dict[str, Any]]

property name: str | None

Return the name of the secret. The manifest takes precedence over the secret ORM

property ready: bool

Return whether SecretTransformer is ready.

refresh()[source]

Refresh the secret.

Return type:

bool

save()[source]

Save a secret.

Return type:

bool

property secret: Secret | None

Return the secret meta.

property secret_serializer: SecretSerializer | None

Return the secret meta serializer.

property tags: set[str]

Return the secret tags.

to_json(version='v1')[source]

Serialize a secret in JSON format that is importable by Pydantic.

Return type:

Optional[dict[str, Any]]

update()[source]

Update a secret.

Return type:

bool

property updated_at: str | None

Return the updated date.

property user_profile: UserProfile | None

Return the user profile.

property value: str | None

Return the secret value.

property version: str

Return the secret version.

property yaml: str | None

Return the secret as a yaml string.

yaml_to_json(yaml_string)[source]

Convert a yaml string to a dictionary.

Return type:

dict

exception smarter.apps.account.manifest.transformers.secret.SmarterSecretTransformerError(message='')[source]

Bases: SmarterException

Base exception for Smarter API Secret handling.

smarter.apps.account.manifest.transformers.secret.should_log(level)[source]

Check if logging should be done based on the waffle switch.