Skip to main content

Vault | Python SDK | General Endpoints

General Endpoints

Delete

Vault.delete(item_id, recursive)

Delete a secret or key

required parameters

str

The item ID.

optional parameters

bool

Whether to delete the item and all its children recursively. Only applicable to folders.

Response Object

A PangeaResponse where the id of the deleted secret or key is returned in the response.result field. Available response fields can be found in our API documentation.

vault.delete(id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5")

Retrieve

Vault.get(item_id, version)

Retrieve a secret, key or folder, and any associated information.

required parameters

str

The item ID

optional parameters

Union[Literal['all'], int, None]

The key version(s).

  • all for all versions
  • num for a specific version
  • -num for the num latest versions

Response Object

A PangeaResponse where the secret or key is returned in the response.result field. Available response fields can be found in our API documentation.

response = vault.get(
    id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
    version=1,
)

Get bulk

Vault.get_bulk(filter, size, order, order_by, last)

Retrieve details for multiple Vault items, including keys, secrets, tokens, or folders, that match a given filter specification.

optional parameters

Filters to customize your search.

int | None

Maximum number of items in the response.

ItemOrder | None

Direction for ordering the results.

ItemOrderBy | None

Property by which to order the results.

str | None

Internal ID returned in the previous look up response. Used for pagination.

response = vault.get_bulk({"id": "pvi_..."})

List

Vault.list(filter, size, order, order_by, last)

Retrieve a list of secrets, keys and folders, and their associated information.

optional parameters

Optional[Mapping[str, str]]

A set of filters to help you customize your search. Examples:

  • "folder": "/tmp"
  • "tags": "personal"
  • "name__contains": "xxx"
  • "created_at__gt": "2020-02-05T10:00:00Z"

For metadata, use: "metadata_{key}": "{value}"

int

Maximum number of items in the response. Default is 50.

Optional[ItemOrder]

Ordering direction: asc or desc

ItemOrderBy | None

Property used to order the results. Supported properties: id, type, created_at, algorithm, purpose, expiration, last_rotated, next_rotation, name, folder, item_state.

str | None

Internal ID returned in the previous look up response. Used for pagination.

Response Object

A PangeaResponse where a list of secrets or keys is returned in the response.result field. Available response fields can be found in our API documentation.

response = vault.list(
    filter={
        "folder": "/",
        "type": "asymmetric_key",
        "name__contains": "test",
        "metadata_key1": "value1",
        "created_at__lt": "2023-12-12T00:00:00Z"
    },
    last="WyIvdGVzdF8yMDdfc3ltbWV0cmljLyJd",
    order=ItemOrder.ASC,
    order_by=ItemOrderBy.NAME,
    size=20,
)

State change

Vault.state_change(item_id, state, version, destroy_period)

Change the state of a specific version of a secret or key.

required parameters

str

The item ID.

ItemVersionState

The new state of the item version.

optional parameters

int | None

The item version.

str | None

Period of time for the destruction of a compromised key. Only valid if state=compromised.

Response Object

A PangeaResponse where the state change object is returned in the response.result field. Available response fields can be found in our API documentation.

response = vault.state_change(
    id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
    state=ItemVersionState.DEACTIVATED,
)

Update

Vault.update(item_id, name, folder, metadata, tags, disabled_at, enabled, rotation_frequency, rotation_state, rotation_grace_period)

Update information associated with a secret, key or folder.

required parameters

str

The item ID.

optional parameters

str | None

The name of this item

str | None

The folder where this item is stored.

Metadata | None

User-provided metadata.

Tags | None

A list of user-defined tags.

str | None

Timestamp indicating when the item will be disabled.

bool | None

True if the item is enabled.

str | None

Period of time between item rotations.

RequestRotationState

State to which the previous version should transition upon rotation.

str | None

Grace period for the previous version of the Pangea Token.

Response Object

A PangeaResponse where the item ID is returned in the response.result field. Available response fields can be found in our API documentation.

response = vault.update(
    id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
    name="my-very-secret-secret",
    folder="/personal",
    metadata={
        "created_by": "John Doe",
        "used_in": "Google products"
    },
    tags=[
        "irs_2023",
        "personal"
    ],
    rotation_frequency="10d",
    rotation_state=ItemVersionState.DEACTIVATED,
)