Quota

Read Quota

Quota.read_quota(name)[source]

Read quota. Only works when calling on the root namespace.

Supported methods:

GET: /sys/quotas/rate-limit/:name. Produces: 200 application/json

Parameters:

name (str | unicode) – the name of the quota to look up.

Returns:

JSON response from API request.

Return type:

requests.Response

Examples

import hvac
client = hvac.Client(url='https://127.0.0.1:8200')
client.sys.create_or_update_quota(name="quota1", rate=100.0)

Create or Update Quota

Quota.create_or_update_quota(name, rate, path=None, interval=None, block_interval=None, role=None, rate_limit_type=None, inheritable=None)[source]

Create quota if it doesn’t exist or update if already created. Only works when calling on the root namespace.

Supported methods:

POST: /sys/quotas/rate-limit. Produces: 204 (empty body)

Parameters:
  • name (str | unicode) – The name of the quota to create or update.

  • path (str | unicode) – Path of the mount or namespace to apply the quota.

  • rate (float) – The maximum number of requests in a given interval to be allowed. Must be positive.

  • interval (str | unicode) – The duration to enforce rate limit. Default is β€œ1s”.

  • block_interval (str | unicode) – If rate limit is reached, how long before client can send requests again.

  • role (str | unicode) – If quota is set on an auth mount path, restrict login requests that are made with a specified role.

  • rate_limit_type (str | unicode) – Type of rate limit quota. Can be lease-count or rate-limit.

  • inheritable (bool) – If set to true on a path that is a namespace, quota will be applied to all child namespaces

Returns:

API status code from request.

Return type:

requests.Response

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

# Create file quota
client.sys.create_or_update_quota(name="quota1", rate=100.0)

# Update quota that already exists
client.sys.create_or_update_quota(name="quota1", rate=101.0)

List Quotas

Quota.list_quotas()[source]

Retrieve a list of quotas by name. Only works when calling on the root namespace.

Supported methods:

LIST: /sys/quotas/rate-limit. Produces: 200 application/json

Returns:

JSON response from API request.

Return type:

requests.Response

Examples

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

client.sys.create_or_update_quota(name="quota1", rate=1000.0, interval="10m")
client.sys.create_or_update_quota(name="quota2", rate=1000.0, path="/kv")

Delete Quota

Quota.delete_quota(name)[source]

Delete a given quota. Only works when calling on the root namespace.

Supported methods:

DELETE: /sys/quotas/rate-limit. Produces: 204 (empty body)

Parameters:

name (str | unicode) – Name of the quota to delete

Returns:

API status code from request.

Return type:

requests.Response

Examples

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

client.sys.delete_quota(name="quota1")