Skip to main content

Modify secret state

Change the state of a secret

A secret can be in an enabled or disabled state.

Disabling a secret

Disabling a secret prevents all versions of a secret from being used. When a secret is in the disabled state, only the following actions can be performed:

  • Update/Retrieve metadata
  • Deleting the secret

import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Vault
from pangea.services.vault.models.common import ItemState


def disable_secret(secret_id):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
vault.update(secret_id, item_state=ItemState.DISABLED)

except pe.PangeaAPIException as e:
print(f"Vault Request Error: {e.response.summary}")
for err in e.errors:
print(f"\t{err.detail} \n")

return

Enabling a secret

Enabling a secret restores all previous functionality to a secret, and its versions.


import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Vault
from pangea.services.vault.models.common import ItemState


def enable_secret(secret_id):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
vault.update(secret_id, item_state=ItemState.ENABLED)

except pe.PangeaAPIException as e:
print(f"Vault Request Error: {e.response.summary}")
for err in e.errors:
print(f"\t{err.detail} \n")

return

Was this article helpful?

Contact us