hopsworks.core.secret_api #
SecretsApi #
API for managing secrets in Hopsworks.
You can get an instance of this class with hopsworks.get_secrets_api.
Returned by
get_secrets #
Get all secrets.
| RETURNS | DESCRIPTION |
|---|---|
list[secret.Secret] | List of all accessible secrets. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request |
get_secret #
Get a secret.
| PARAMETER | DESCRIPTION |
|---|---|
name | Name of the secret. TYPE: |
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: |
| RETURNS | DESCRIPTION |
|---|---|
secret.Secret | None | The Secret object or |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
get #
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: |
owner | Email of the owner for a secret shared with the current project. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
str | The secret value. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
create_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: |
value | The secret value. TYPE: |
project | Name of the project to share the secret with. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
secret.Secret | The Secret object. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
create_secret_from_file #
Create a new secret from the contents of a local file.
The file is base64-encoded in memory and stored as the secret value. Reads return the same base64 string and the caller is responsible for decoding it back to the original bytes.
import base64
import hopsworks
project = hopsworks.login()
secrets_api = hopsworks.get_secrets_api()
secret = secrets_api.create_secret_from_file("my_key", "~/.ssh/id_ed25519")
raw_bytes = base64.b64decode(secrets_api.get("my_key"))
| PARAMETER | DESCRIPTION |
|---|---|
name | Name of the secret. TYPE: |
local_path | Path to the file whose contents become the secret value. TYPE: |
project | Name of the project to share the secret with. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
secret.Secret | The Secret object. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If the base64-encoded length exceeds the server-side ceiling. |
FileNotFoundError | If |
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |