Skip to content

hook

hook

__all__ = ['GoogleSecretManagerHook'] module-attribute

GoogleSecretManagerHook

Bases: SecretManagerHook

Hook for interacting with Google Secret Manager.

__init__() -> None

Initializes the GoogleSecretManagerHook.

add_secret_version(project: str, id: str, value: Any) -> Any

Adds a new version to a secret.

Parameters:

Name Type Description Default
project str

The project ID.

required
id str

The secret ID.

required
value Any

The value to store in the secret.

required

Returns:

Name Type Description
Any Any

The response from the secret manager.

destroy_secret_version(secret_name: str, version: str) -> str

Destroys a specific version of a secret.

Parameters:

Name Type Description Default
secret_name str

The name of the secret.

required
version str

The version of the secret to destroy.

required

Returns:

Name Type Description
str str

The name of the destroyed version.

get_secret(project: str, id: str, parse_json: bool = False) -> Any

Retrieves the latest version of a secret.

Parameters:

Name Type Description Default
project str

The project ID.

required
id str

The secret ID.

required
parse_json bool

Whether to parse the secret as JSON. Defaults to False.

False

Returns:

Name Type Description
Any Any

The secret value, parsed if requested.

list_secret_versions(secret_name: str, filter: str = 'state:(ENABLED OR DISABLED)') -> List[str]

Lists all versions of a specified secret.

Parameters:

Name Type Description Default
secret_name str

The name of the secret.

required
filter str

The filter for the versions. Defaults to 'state:(ENABLED OR DISABLED)'.

'state:(ENABLED OR DISABLED)'

Returns:

Type Description
List[str]

List[str]: A list of secret version names.

list_secrets() -> List[str]

Lists all secrets in the project.

Returns:

Type Description
List[str]

List[str]: A list of secret names.