Getting & Setting a storage quota via cURL in gateway

The easiest way to set and get quotas per domain or tenants is via the content portal as detailed here.

https://perifery.atlassian.net/wiki/spaces/public/pages/2443818631

However if you have a batch of domains that you need to set a quota on or if you have a regular check that you want to report the management api is there to give you a hand.

https://perifery.atlassian.net/wiki/spaces/public/pages/2443822511

 

How to get the status of Quotas

In the docs this is what is written to check wether the feature is enabled at all , do this first with the user that you are attempting to perform quota checks with.

The permission rquired is ListDomain ,

GET /_admin/manage/quota/status

translated to cURL

curl -iL -u <user>:<password> 'http://<gateway-ip>:<gateway-port>/_admin/manage/quota/status'

the expected output for that would be

HTTP/1.1 200 OK Date: Mon, 24 Apr 2023 15:36:44 GMT Content-Type: application/json Server: Cloud Gateway SCSP/7.10.4 Gateway-Request-Id: 34A21DA7ADAAFB8E Gateway-Manage-API-Version: 2.0 Content-Length: 47 {"queueSize":1,"stateChanges":1,"enabled":true}

How to check on a single domain

 

The permission required at a userlevel on the domain / bucket or tenant that you are querying here is GetQuota

The api spec is like this

HEAD /_admin/manage/tenants/{T}/ quota/check domains/{D}/quota/check domains/{D}/buckets/{B}/quota/check

What we would do in a query would be like the below.

In this scenario the 10.42.0.63 address is my gateway and the 8084 port is my SCSP endpoint.

cURL -IL is a head request.

if we just wanted to check the tenant quota the request for a tenant named tenant1 would look like this.

 

for a domain in tenant1 called domain1 the request would look like this

The output for a quota check looks like this.

note the header output

x-caringo-meta-quota-state: ok


Quota Metric Check

response

note the headers in the response.

The storage-limit and action here are the value to pay attention to.

The action on hitting the limit is nowrite and the size is 10GB the value is reported in Bytes 10737418240 = 10GB

 

Setting a storage limit

The api for a storage limit looks like this

translated to cURL →

Note that the email field is a separate request.

System Tenant

In many scenarios multi tenancy may not be required for a cluster and often the System Tenant is what is used. In this case you can still use quotas but requests like this

or this

will fail

That is because the system tenant has a special path in the management api.

_system

So if your domain is in the system tenant and not in a named tenant you can use this kind of cURL call.

 

© DataCore Software Corporation. · https://www.datacore.com · All rights reserved.