Secrets Manager

Use dataikuapi.DSSClient.get_secrets_manager() to obtain a Secrets Manager handle. Secrets are identified by their identifier. A returned dataikuapi.secretsmanager.secretsmanager.DSSSecret exposes its metadata as properties and persists editable properties with dataikuapi.secretsmanager.secretsmanager.DSSSecret.save().

For example, to create and share a local secret:

secrets_manager = client.get_secrets_manager()

secret = secrets_manager.create_local_secret(
    identifier="snowflake-password",
    secret_value="initial-value",
    description="Password used by the Snowflake connection",
)
secret.share_with_user(
    "alice",
    can_use=True,
    can_read=False,
    can_write=True,
).save()

The capability attributes are properties. They indicate what the current authentication context can do with the secret:

secret = secrets_manager.get_secret("snowflake-password")
print(secret.can_use)
print(secret.can_read)
print(secret.can_write)
print(secret.can_admin)

To update metadata, modify the corresponding properties on the secret handle and save it. There is no separate metadata object.

secret.description = "Rotated Snowflake password"
secret.save()

Reading a secret value

Use dataikuapi.secretsmanager.secretsmanager.DSSSecret.get_value() on the generic secret handle to read a value. This is the expected way to access a secret value: it works for both local and vault-backed secrets, and remains valid if the secret has a different backing type on another DSS instance. The caller needs Reveal permission. The optional context is included in the audit event.

secret = secrets_manager.get_secret("snowflake-password")
value = secret.get_value(context={"operation": "connection-test"})

Typed handles are only needed for operations specific to a secret type. For example, use a local-secret handle to rotate a locally stored value:

local_secret = secret.get_as_local_secret()
local_secret.update_value(
    "rotated-value",
    context={"operation": "credential-rotation"},
)

Use a vault-secret handle only when you need to inspect or edit its vault ID, remote secret identifier, or pinned version. Calling a typed-handle method for the wrong backing type raises an error.

If saving metadata or sharing changes would remove the current caller’s effective Admin permission, pass confirm_losing_admin_access=True to dataikuapi.secretsmanager.secretsmanager.DSSSecret.save().

Manager and secret handles

class dataikuapi.secretsmanager.secretsmanager.DSSSecretsManager(client)

Collection-level handle for DSS Secrets Manager operations.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_secrets_manager() instead

list_secrets()

List secrets usable by the current authentication context.

Returns:

secret handles

Return type:

list of DSSSecret

get_secret(identifier)

Get a handle to a specific secret identifier.

Parameters:

identifier (str) – identifier of the secret

Returns:

handle to the secret

Return type:

DSSSecret

create_local_secret(identifier, secret_value, permission_items=None, description=None)

Create a new local secret definition with its initial value.

Parameters:
  • identifier (str) – identifier of the secret

  • secret_value (str) – initial decrypted value to store for the local secret

  • permission_items (list) – optional list of permission item dicts

  • description (str) – optional description of the secret

Returns:

typed handle to the created local secret

Return type:

DSSLocalSecret

create_vault_secret(identifier, vault_id, remote_secret_identifier, remote_secret_version=None, permission_items=None, description=None)

Create a new secret definition whose value is resolved from a vault.

Parameters:
  • identifier (str) – identifier of the secret

  • vault_id (str) – identifier of the configured vault provider to use

  • remote_secret_identifier (str) – identifier of the secret in the remote vault

  • remote_secret_version (str) – optional version of the remote secret to pin

  • permission_items (list) – optional list of permission item dicts

  • description (str) – optional description of the secret

Returns:

typed handle to the created vault secret

Return type:

DSSVaultSecret

class dataikuapi.secretsmanager.secretsmanager.DSSSecret(client, identifier, metadata=None, capabilities=None)

Handle for a specific DSS secret.

Important

Do not instantiate directly, use DSSSecretsManager.list_secrets() or DSSSecretsManager.get_secret() instead

refresh()

Refresh this secret’s metadata and capabilities from DSS.

Returns:

self

Return type:

DSSSecret

property type

The secret type, such as DSSSecretType.LOCAL.

property description

The secret description.

property permission_items

The permission items visible to the current caller.

property created_by

The user that created the secret.

property created_on

The date and time when the secret was created.

property last_updated_by

The user who last updated the secret metadata.

property last_updated_on

The date and time of the latest secret metadata update.

save(confirm_losing_admin_access=False)

Persist updates made to this secret handle and refresh it from DSS.

Parameters:

confirm_losing_admin_access (bool) – allow this update to remove the caller’s ability to administer the secret. Defaults to False.

Returns:

self

Return type:

DSSSecret

property can_use

Return whether the current caller can use this secret indirectly.

property can_read

Return whether the current caller can read this secret value or metadata.

property can_write

Return whether the current caller can rotate this secret value.

property can_admin

Return whether the current caller can administer this secret metadata and ACLs.

delete()

Delete this secret.

Returns:

self

Return type:

DSSSecret

share_with_user(user, can_use=True, can_read=False, can_write=False, is_admin=False)

Add or replace a user permission on this secret handle.

Call save() to persist the change.

Parameters:
  • user (str) – DSS login to share with

  • can_use (bool) – grant use permission

  • can_read (bool) – grant read permission

  • can_write (bool) – grant write permission

  • is_admin (bool) – grant admin permission

Returns:

self

Return type:

DSSSecret

revoke_share_with_user(user)

Remove a user permission from this secret handle.

Call save() to persist the change.

Caution

If the user still gets access through one of their groups, they will keep that access.

Parameters:

user (str) – DSS login to revoke

Returns:

self

Return type:

DSSSecret

share_with_group(group, can_use=True, can_read=True, can_write=False, is_admin=False)

Add or replace a group permission on this secret handle.

Call save() to persist the change.

Parameters:
  • group (str) – DSS group name to share with

  • can_use (bool) – grant use permission

  • can_read (bool) – grant read permission

  • can_write (bool) – grant write permission

  • is_admin (bool) – grant admin permission

Returns:

self

Return type:

DSSSecret

revoke_share_with_group(group)

Remove a group permission from this secret handle.

Call save() to persist the change.

Direct user permissions are unaffected.

Parameters:

group (str) – DSS group name to revoke

Returns:

self

Return type:

DSSSecret

get_as_local_secret()

Get a typed local-secret handle for this secret.

Returns:

a local secret handle

Return type:

DSSLocalSecret

get_as_vault_secret()

Get a typed vault-secret handle for this secret.

Returns:

a vault secret handle

Return type:

DSSVaultSecret

get_value(context=None)

Read the current value of this secret through DSS.

Parameters:

context (dict) – optional caller-provided context attached to audit usage

Returns:

decrypted or resolved secret value

Return type:

str

class dataikuapi.secretsmanager.secretsmanager.DSSLocalSecret(client, identifier, metadata=None, capabilities=None)

Typed handle for a local DSS secret.

Important

Do not instantiate directly, use DSSSecret.get_as_local_secret() instead

update_value(value, context=None)

Update the value of this local secret.

Parameters:
  • value (str) – new decrypted secret value

  • context (dict) – optional caller-provided context attached to audit usage

Returns:

self

Return type:

DSSLocalSecret

class dataikuapi.secretsmanager.secretsmanager.DSSVaultSecret(client, identifier, metadata=None, capabilities=None)

Typed handle for a DSS secret whose value is resolved from a vault.

Important

Do not instantiate directly, use DSSSecret.get_as_vault_secret() instead

property vault_id

The identifier of the vault backing this secret.

property remote_secret_identifier

The identifier of the secret in the remote vault.

property remote_secret_version

The optional version of the remote secret pinned by this secret.

Secret types

class dataikuapi.secretsmanager.secretsmanager.DSSSecretType(*values)

Enumeration of DSS secret types.

LOCAL = 'LOCAL'
VAULT = 'VAULT'