Skip to content

hopsworks.core.secret_api #

[source] SecretsApi #

API for managing secrets in Hopsworks.

You can get an instance of this class with hopsworks.get_secrets_api.

[source] get_secrets #

get_secrets() -> list[secret.Secret]

Get all secrets.

RETURNS DESCRIPTION
list[secret.Secret]

List[Secret]: List of all accessible secrets

Raises: hopsworks.client.exceptions.RestAPIError: If the backend encounters an error when handling the request

[source] get_secret #

get_secret(
    name: str, owner: str = None
) -> secret.Secret | None

Get a secret.

PARAMETER DESCRIPTION
name

Name of the secret.

TYPE: str

owner

Username of the owner for a secret shared with the current project. Users can find their username in the Account Settings > Profile section.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
secret.Secret | None

The Secret object or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] get #

get(name: str, owner: str = None) -> str

Get the secret's value.

If the secret does not exist, it prompts the user to create the secret if the application is running interactively.

PARAMETER DESCRIPTION
name

Name of the secret.

TYPE: str

owner

Email of the owner for a secret shared with the current project.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
str

The secret value.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] create_secret #

create_secret(
    name: str, value: str, project: str = None
) -> secret.Secret

Create a new secret.

import hopsworks

project = hopsworks.login()

secrets_api = hopsworks.get_secrets_api()

secret = secrets_api.create_secret("my_secret", "Fk3MoPlQXCQvPo")
PARAMETER DESCRIPTION
name

Name of the secret.

TYPE: str

value

The secret value.

TYPE: str

project

Name of the project to share the secret with.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
secret.Secret

The Secret object.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.