Namespace๏ƒ

Create Namespace๏ƒ

Namespace.create_namespace(path)[source]

Create a namespace at the given path.

Supported methods:

POST: /sys/namespaces/{path}. Produces: 200 application/json

Returns:

The response of the request.

Return type:

requests.Response

Examples๏ƒ

import hvac
client = hvac.Client(url='https://127.0.0.1:8200')

# Create namespace team1 where team1 is a child of root
client.sys.create_namespace(path="team1")

# Create namespace team1/app1 where app1 is a child of team1
client2 = hvac.Client(url='https://127.0.0.1:8200', namespace="team1")
client2.sys.create_namespace(path="app1")

Example output:

print(client.sys.create_namespace(path=โ€team1โ€)) {โ€œrequest_idโ€:โ€<redacted>โ€,โ€lease_idโ€:โ€โ€,โ€renewableโ€:false,โ€lease_durationโ€:0,โ€dataโ€:{โ€œidโ€:โ€nf28fโ€,โ€pathโ€:โ€team1/โ€},โ€wrap_infoโ€:null,โ€warningsโ€:null,โ€authโ€:null}

print(client2.sys.create_namespace(path=โ€app1โ€)) {โ€œrequest_idโ€:โ€<redacted>โ€,โ€lease_idโ€:โ€โ€,โ€renewableโ€:false,โ€lease_durationโ€:0,โ€dataโ€:{โ€œidโ€:โ€EGqRJโ€,โ€pathโ€:โ€team1/app1/โ€},โ€wrap_infoโ€:null,โ€warningsโ€:null,โ€authโ€:null}

List Namespaces๏ƒ

Namespace.list_namespaces()[source]

Lists all the namespaces.

Supported methods:

LIST: /sys/namespaces. Produces: 200 application/json

Returns:

The JSON response of the request.

Return type:

dict

Examples๏ƒ

import hvac
client = hvac.Client(url='https://127.0.0.1:8200')
client.sys.create_namespace(path='testns')

client.sys.list_namespaces()

Example output:

print(client.sys.list_namespaces()) {โ€œrequest_idโ€:โ€<redacted>โ€,โ€lease_idโ€:โ€โ€,โ€renewableโ€:false,โ€lease_durationโ€:0,โ€dataโ€:{โ€œkey_infoโ€:{โ€œtestns/โ€:{โ€œidโ€:โ€ekiUnโ€,โ€pathโ€:โ€testns/โ€}},โ€keysโ€:[โ€œtestns/โ€]},โ€wrap_infoโ€:null,โ€warningsโ€:null,โ€authโ€:null}

Delete Namespace๏ƒ

Namespace.delete_namespace(path)[source]

Delete a namespaces. You cannot delete a namespace with existing child namespaces.

Supported methods:

DELETE: /sys/namespaces. Produces: 204 (empty body)

Returns:

The response of the request.

Return type:

requests.Response

Examples๏ƒ

import hvac

# Delete namespace app1 where app1 is a child of team1
client2 = hvac.Client(url='https://127.0.0.1:8200', namespace="team1")
client2.sys.delete_namespace(path="app1")

# Delete namespace team1
client = hvac.Client(url='https://127.0.0.1:8200')
client.sys.delete_namespace(path="team1")