---
title: Charmhub | Deploy Vault using Charmhub - The Open Operator Collection
description: Deploy the latest version of Vault as a Kubernetes Operator on any cloud.
url: https://charmhub.io/vault-k8s/libraries/juju_facade
---

# Vault

[Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

* [Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

Platform:

2.0/stable 590

```
juju deploy vault-k8s --channel 2.0/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/vault-k8s/libraries/juju_facade#drawer)

## charms.vault\_k8s.v0.juju\_facade

* [*Docstrings*Docstrings](https://charmhub.io/vault-k8s/libraries/juju_facade)
  [*Code*Source code](https://charmhub.io/vault-k8s/libraries/juju_facade/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.vault_k8s.v0.juju_facade
    ```

    [Download juju\_facade.py](https://charmhub.io/vault-k8s/libraries/juju_facade/download)
  + *Last updated* 17 Jan 2025
  + *Revision* Library version 0.7

This library provides a wrapper of the Juju API.

---

Index

* [class FacadeError](https://charmhub.io/vault-k8s/libraries/juju_facade#facadeerror)
* [class TransientJujuError](https://charmhub.io/vault-k8s/libraries/juju_facade#transientjujuerror)
* [class SecretValidationError](https://charmhub.io/vault-k8s/libraries/juju_facade#secretvalidationerror)
* [class NoSuchSecretError](https://charmhub.io/vault-k8s/libraries/juju_facade#nosuchsecreterror)
* [class SecretRemovedError](https://charmhub.io/vault-k8s/libraries/juju_facade#secretremovederror)
* [class NoSuchRelationError](https://charmhub.io/vault-k8s/libraries/juju_facade#nosuchrelationerror)
* [class InvalidRelationDataError](https://charmhub.io/vault-k8s/libraries/juju_facade#invalidrelationdataerror)
* [class NotLeaderError](https://charmhub.io/vault-k8s/libraries/juju_facade#notleadererror)
* [class NoSuchStorageError](https://charmhub.io/vault-k8s/libraries/juju_facade#nosuchstorageerror)
* [class SecretAccessDeniedError](https://charmhub.io/vault-k8s/libraries/juju_facade#secretaccessdeniederror)
* [class NoRemoteAppError](https://charmhub.io/vault-k8s/libraries/juju_facade#noremoteapperror)
* [class MultipleRelationsFoundError](https://charmhub.io/vault-k8s/libraries/juju_facade#multiplerelationsfounderror)
* [class JujuFacade](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade)
* + [def \_\_init\_\_(
    self,
    charm)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-__init__)
* + [def get\_secret(
    self,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_secret)
* + [def secret\_exists(
    self,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-secret_exists)
* + [def secret\_exists\_with\_fields(
    self,
    fields,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-secret_exists_with_fields)
* + [def get\_current\_secret\_content(
    self,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_current_secret_content)
* + [def get\_latest\_secret\_content(
    self,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_latest_secret_content)
* + [def get\_secret\_content\_values(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_secret_content_values)
* + [def set\_app\_secret\_content(
    self,
    content,
    label,
    id,
    description)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_app_secret_content)
* + [def set\_unit\_secret\_content(
    self,
    content,
    label,
    id,
    description)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_unit_secret_content)
* + [def set\_secret\_label(
    self,
    new\_label,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_secret_label)
* + [def set\_secret\_expiry(
    self,
    expiry,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_secret_expiry)
* + [def grant\_secret(
    self,
    relation,
    secret,
    secret\_id,
    secret\_label)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-grant_secret)
* + [def remove\_secret(
    self,
    label,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-remove_secret)
* + [def get\_relation(
    self,
    name,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_relation)
* + [def get\_relation\_by\_name(
    self,
    name)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_relation_by_name)
* + [def get\_relations(
    self,
    name)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_relations)
* + [def get\_active\_relation(
    self,
    name,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_active_relation)
* + [def get\_active\_relations(
    self,
    name,
    id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_active_relations)
* + [def relation\_exists(
    self,
    name)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-relation_exists)
* + [def get\_app\_relation\_data(
    self,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_app_relation_data)
* + [def get\_remote\_app\_relation\_data(
    self,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_remote_app_relation_data)
* + [def get\_unit\_relation\_data(
    self,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_unit_relation_data)
* + [def get\_remote\_unit\_relation\_data(
    self,
    unit,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_remote_unit_relation_data)
* + [def get\_remote\_units\_relation\_data(
    self,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_remote_units_relation_data)
* + [def set\_app\_relation\_data(
    self,
    data,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_app_relation_data)
* + [def set\_unit\_relation\_data(
    self,
    data,
    name,
    id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-set_unit_relation_data)
* + [def get\_string\_config(
    self,
    key)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_string_config)
* + [def get\_int\_config(
    self,
    key)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_int_config)
* + [def get\_bool\_config(
    self,
    key)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_bool_config)
* + [def get\_storage\_location(
    self,
    storage\_name)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_storage_location)
* + [def get\_binding(
    self,
    relation\_name,
    relation,
    relation\_id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_binding)
* + [def get\_egress\_subnets(
    self,
    relation\_name,
    relation\_id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_egress_subnets)
* + [def get\_ingress\_address(
    self,
    relation\_name,
    relation,
    relation\_id)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_ingress_address)
* + [def get\_bind\_address(
    self,
    relation\_name,
    relation\_id,
    relation)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-get_bind_address)
* + [def model\_name(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-model_name)
* + [def app\_name(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-app_name)
* + [def unit\_name(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-unit_name)
* + [def model\_storage\_names(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-model_storage_names)
* + [def is\_leader(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-is_leader)
* + [def planned\_units\_for\_app(
    self)](https://charmhub.io/vault-k8s/libraries/juju_facade#jujufacade-planned_units_for_app)

#### class FacadeError

Description

Base class for custom errors raised by this library. None

#### class TransientJujuError

Description

Exception raised for transient Juju errors like ModelError. None

#### class SecretValidationError

Description

Exception raised for secret validation errors. None

#### class NoSuchSecretError

Description

Exception raised when a secret does not exist. None

#### class SecretRemovedError

Description

Exception raised when a secret does not exist anymore. None

#### class NoSuchRelationError

Description

Exception raised when a relation does not exist. None

#### class InvalidRelationDataError

Description

Exception raised when relation data is invalid. None

#### class NotLeaderError

Description

Exception raised when the unit is not leader. None

#### class NoSuchStorageError

Description

Exception raised when a storage does not exist. None

#### class SecretAccessDeniedError

Description

Exception raised if the charm does not have permission to access the secret. None

#### class NoRemoteAppError

Description

Exception raised when a relation has no remote application. None

#### class MultipleRelationsFoundError

Description

Exception raised when multiple relations are found. None

#### class JujuFacade

Description

Juju API wrapper class. None

Methods

JujuFacade.
\_\_init\_\_(

*self*

,
charm: CharmBase
)

JujuFacade.
get\_secret(

*self*

,
label

,
id
)

Retrieve a secret and handles error.

JujuFacade.
secret\_exists(

*self*

,
label

,
id
)

Check if the secret exists.

Description

Raises:
TransientJujuError

JujuFacade.
secret\_exists\_with\_fields(

*self*

,
fields

,
label

,
id
)

Check if the secret exists and has the required fields.

Description

Args:
fields: The requested fields
label: The secret label
id: The secret id

Returns:
True if the secret exists and has the required fields, False otherwise

Raises:
TransientJujuError

JujuFacade.
get\_current\_secret\_content(

*self*

,
label

,
id
)

Get secret content if the secret exists and return currently tracked revision.

Description

Raises:
TransientJujuError
NoSuchSecretError
SecretRemovedError

JujuFacade.
get\_latest\_secret\_content(

*self*

,
label

,
id
)

Get secret content if the secret exists and return latest revision.

Description

Raises:
TransientJujuError
NoSuchSecretError
SecretRemovedError

JujuFacade.
get\_secret\_content\_values(

*self*
)

Get secret content values by keys.

Description

Args:
keys: Keys of the requested values
label: The secret label
id: The secret id

Returns:
tuple[str | None, ...]: The secret content values,
if a key is not found, None is returned for its value

Raises:
TransientJujuError
NoSuchSecretError
SecretRemovedError

JujuFacade.
set\_app\_secret\_content(

*self*

,
content

,
label

,
id

,
description
)

Set the secret content if the secret exists.

Description

Creates new secret revision if secret exists, otherwise creates a new secret.

Raises:
TransientJujuError
SecretValidationError

JujuFacade.
set\_unit\_secret\_content(

*self*

,
content

,
label: str

,
id

,
description
)

Set the secret content if the secret exists.

Description

Creates new secret revision if secret exists, otherwise creates a new secret.

Raises:
TransientJujuError
SecretValidationError

JujuFacade.
set\_secret\_label(

*self*

,
new\_label: str

,
label: str

,
id
)

Set a new label for the secret if the secret exists.

Description

Raises:
TransientJujuError

JujuFacade.
set\_secret\_expiry(

*self*

,
expiry: datetime

,
label: str

,
id
)

Set a new expiry date for the secret if the secret exists.

Description

Raises:
TransientJujuError

JujuFacade.
grant\_secret(

*self*

,
relation: Relation

,
secret

,
secret\_id

,
secret\_label
)

Grant read access to the secret to the application related.

Description

If secret ID or label is provided, it retrieves the secret and grants it to the relation.

Raises:
NoSuchSecretError
SecretRemovedError

JujuFacade.
remove\_secret(

*self*

,
label: str

,
id
)

Description

Remove the secret if it exists. None

JujuFacade.
get\_relation(

*self*

,
name: str

,
id: int
)

Get the relation object by name and id.

Returns

The relation object

JujuFacade.
get\_relation\_by\_name(

*self*

,
name: str
)

Get the relation object by name.

Description

Raises:
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
get\_relations(

*self*

,
name: str
)

Get all relation objects with the given name.

Returns

A list of relation objects, the list is empty if no relations are found

JujuFacade.
get\_active\_relation(

*self*

,
name: str

,
id: int
)

Description

Get the active relation object by name and id. None

JujuFacade.
get\_active\_relations(

*self*

,
name: str

,
id
)

Description

Get all relations with the given name that are active. None

JujuFacade.
relation\_exists(

*self*

,
name: str
)

Description

Check if there are any relations with the given name. None

JujuFacade.
get\_app\_relation\_data(

*self*

,
name

,
id

,
relation
)

Get relation data from the caller's application databag.

Description

Either relation or relation\_name must be provided.

Returns:
The relation data as a dict

Raises:
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
get\_remote\_app\_relation\_data(

*self*

,
name

,
id

,
relation
)

Get relation data from the remote application databag.

Description

Either relation or relation\_name must be provided.

Returns:
The relation data as a dict

Raises:
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
get\_unit\_relation\_data(

*self*

,
name

,
id

,
relation
)

Get relation data from the caller's unit databag.

Description

Raises:
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
get\_remote\_unit\_relation\_data(

*self*

,
unit: Unit

,
name

,
id

,
relation
)

Description

Get relation data from the remote unit databag. None

JujuFacade.
get\_remote\_units\_relation\_data(

*self*

,
name

,
id

,
relation
)

Get relation data from the remote units databags.

Description

Raises:
NoSuchRelationError
MultipleRelationsFoundError
ValueError

JujuFacade.
set\_app\_relation\_data(

*self*

,
data

,
name

,
id

,
relation
)

Set relation data in the caller's application databag.

Description

Raises:
NotLeaderError
InvalidRelationDataError
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
set\_unit\_relation\_data(

*self*

,
data

,
name

,
id

,
relation
)

Set relation data in the caller's unit databag.

Description

Raises:
InvalidRelationDataError
NoSuchRelationError
MultipleRelationsFoundError

JujuFacade.
get\_string\_config(

*self*

,
key: str
)

Description

Get a string config value. None

JujuFacade.
get\_int\_config(

*self*

,
key: str
)

Description

Get an integer config value. None

JujuFacade.
get\_bool\_config(

*self*

,
key: str
)

Description

Get a boolean config value. None

JujuFacade.
get\_storage\_location(

*self*

,
storage\_name: str
)

Description

Get the storage location. None

JujuFacade.
get\_binding(

*self*

,
relation\_name

,
relation

,
relation\_id
)

Description

Get the binding for the given relation. None

JujuFacade.
get\_egress\_subnets(

*self*

,
relation\_name: str

,
relation\_id

,
relation
)

Get the list of egress subnets for the given relation.

Description

This returns how units on the relation will see the charm connecting from.
For example ['10.0.0.1/32', '10.1.1.1/32']

JujuFacade.
get\_ingress\_address(

*self*

,
relation\_name

,
relation

,
relation\_id
)

Description

Get the ingress address for the given relation. None

JujuFacade.
get\_bind\_address(

*self*

,
relation\_name: str

,
relation\_id

,
relation
)

Description

Get the bind address for the given relation. None

JujuFacade.
model\_name(

*self*
)

Description

Get the model name. None

JujuFacade.
app\_name(

*self*
)

Description

Get the application name. None

JujuFacade.
unit\_name(

*self*
)

Description

Get the unit name. None

JujuFacade.
model\_storage\_names(

*self*
)

Description

Get the model storage names. None

JujuFacade.
is\_leader(

*self*
)

Description

Check if the unit is leader. None

JujuFacade.
planned\_units\_for\_app(

*self*
)

Description

Return the number of planned units for the application. None
