Skip to main content

Modify token state

Change the status of a token

A token can be in an enabled or disabled state.

Disabling a token

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

  • Update/Retrieve metadata
  • Deleting the token

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_token(token_id):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
vault.update(token_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 token

Enabling a token restores all previous functionality to a token 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_token(token_id):
token = os.getenv("PANGEA_VAULT_TOKEN")
domain = os.getenv("PANGEA_DOMAIN")
config = PangeaConfig(domain=domain)
vault = Vault(token, config=config)

try:
vault.update(token_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