github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/website/source/api/quotas.html.md (about) 1 --- 2 layout: api 3 page_title: Quotas - HTTP API 4 sidebar_current: api-quotas 5 description: |- 6 The /quota endpoints are used to query for and interact with quotas. 7 --- 8 9 # Quota HTTP API 10 11 The `/quota` endpoints are used to query for and interact with quotas. 12 13 ~> **Enterprise Only!** This API endpoint and functionality only exists in 14 Nomad Enterprise. This is not present in the open source version of Nomad. 15 16 ## List Quota Specifications 17 18 This endpoint lists all quota specifications. 19 20 | Method | Path | Produces | 21 | ------ | ----------------- | ------------------ | 22 | `GET` | `/v1/quotas` | `application/json` | 23 24 The table below shows this endpoint's support for 25 [blocking queries](/api/index.html#blocking-queries) and 26 [required ACLs](/api/index.html#acls). 27 28 | Blocking Queries | ACL Required | 29 | ---------------- | ------------- | 30 | `YES` | `quota:read`<br>`namespace:*` if namespace has quota attached| 31 32 ### Parameters 33 34 - `prefix` `(string: "")`- Specifies a string to filter quota specifications on 35 based on an index prefix. This is specified as a query string parameter. 36 37 ### Sample Request 38 39 ```text 40 $ curl \ 41 https://localhost:4646/v1/quotas 42 ``` 43 44 ```text 45 $ curl \ 46 https://localhost:4646/v1/quotas?prefix=sha 47 ``` 48 49 ### Sample Response 50 51 ```json 52 [ 53 { 54 "CreateIndex": 8, 55 "Description": "Limit the shared default namespace", 56 "Hash": "SgDCH7L5ZDqNSi2NmJlqdvczt/Q6mjyVwVJC0XjWglQ=", 57 "Limits": [ 58 { 59 "Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=", 60 "Region": "global", 61 "RegionLimit": { 62 "CPU": 2500, 63 "DiskMB": 0, 64 "MemoryMB": 2000, 65 "Networks": null 66 } 67 } 68 ], 69 "ModifyIndex": 56, 70 "Name": "shared-quota" 71 } 72 ] 73 ``` 74 75 ## Read Quota Specification 76 77 This endpoint reads information about a specific quota specification. 78 79 | Method | Path | Produces | 80 | ------ | ------------------- | -------------------------- | 81 | `GET` | `/v1/quota/:quota` | `application/json` | 82 83 The table below shows this endpoint's support for 84 [blocking queries](/api/index.html#blocking-queries) and 85 [required ACLs](/api/index.html#acls). 86 87 | Blocking Queries | ACL Required | 88 | ---------------- | -------------------- | 89 | `YES` | `quota:read`<br>`namespace:*` if namespace has quota attached| 90 91 ### Parameters 92 93 - `:quota` `(string: <required>)`- Specifies the quota specification to query 94 where the identifier is the quota's name. 95 96 ### Sample Request 97 98 ```text 99 $ curl \ 100 https://localhost:4646/v1/quota/shared-quota 101 ``` 102 103 ### Sample Response 104 105 ```json 106 { 107 "CreateIndex": 8, 108 "Description": "Limit the shared default namespace", 109 "Hash": "SgDCH7L5ZDqNSi2NmJlqdvczt/Q6mjyVwVJC0XjWglQ=", 110 "Limits": [ 111 { 112 "Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=", 113 "Region": "global", 114 "RegionLimit": { 115 "CPU": 2500, 116 "DiskMB": 0, 117 "MemoryMB": 2000, 118 "Networks": null 119 } 120 } 121 ], 122 "ModifyIndex": 56, 123 "Name": "shared-quota" 124 } 125 ``` 126 127 ## Create or Update Quota Specification 128 129 This endpoint is used to create or update a quota specification. 130 131 | Method | Path | Produces | 132 | ------- | ----------------------------------- | -------------------------- | 133 | `POST` | `/v1/quota/:quota` <br> `/v1/quota` | `application/json` | 134 135 The table below shows this endpoint's support for 136 [blocking queries](/api/index.html#blocking-queries) and 137 [required ACLs](/api/index.html#acls). 138 139 | Blocking Queries | ACL Required | 140 | ---------------- | ------------ | 141 | `NO` | `quota:write` | 142 143 ### Body 144 145 The request body contains a valid, JSON quota specification. View the api 146 package to see the definition of a [`QuotaSpec` 147 object](https://github.com/hashicorp/nomad/blob/master/api/quota.go#L100-L131). 148 149 ### Sample Payload 150 151 ```javascript 152 { 153 "Name": "shared-quota", 154 "Description": "Limit the shared default namespace", 155 "Limits": [ 156 { 157 "Region": "global", 158 "RegionLimit": { 159 "CPU": 2500, 160 "MemoryMB": 1000 161 } 162 } 163 ] 164 } 165 ``` 166 167 ### Sample Request 168 169 ```text 170 $ curl \ 171 --request POST \ 172 --data @spec.json \ 173 https://localhost:4646/v1/quota/shared-quota 174 ``` 175 176 ```text 177 $ curl \ 178 --request POST \ 179 --data @spec.json \ 180 https://localhost:4646/v1/quota 181 ``` 182 183 ## Delete Quota Specification 184 185 This endpoint is used to delete a quota specification. 186 187 | Method | Path | Produces | 188 | ------- | -------------------------- | -------------------------- | 189 | `DELETE` | `/v1/quota/:quota` | `application/json` | 190 191 The table below shows this endpoint's support for 192 [blocking queries](/api/index.html#blocking-queries) and 193 [required ACLs](/api/index.html#acls). 194 195 | Blocking Queries | ACL Required | 196 | ---------------- | ------------ | 197 | `NO` | `quota:write` | 198 199 ### Parameters 200 201 - `:quota` `(string: <required>)`- Specifies the quota specification to delete 202 where the identifier is the quota's name. 203 204 ### Sample Request 205 206 ```text 207 $ curl \ 208 --request DELETE \ 209 https://localhost:4646/v1/quota/shared-quota 210 ``` 211 212 ## List Quota Usages 213 214 This endpoint lists all quota usages. 215 216 | Method | Path | Produces | 217 | ------ | ----------------- | ------------------ | 218 | `GET` | `/v1/quota-usages` | `application/json` | 219 220 The table below shows this endpoint's support for 221 [blocking queries](/api/index.html#blocking-queries) and 222 [required ACLs](/api/index.html#acls). 223 224 | Blocking Queries | ACL Required | 225 | ---------------- | ------------- | 226 | `YES` | `quota:read`<br>`namespace:*` if namespace has quota attached| 227 228 ### Parameters 229 230 - `prefix` `(string: "")`- Specifies a string to filter quota specifications on 231 based on an index prefix. This is specified as a query string parameter. 232 233 ### Sample Request 234 235 ```text 236 $ curl \ 237 https://localhost:4646/v1/quota-usages 238 ``` 239 240 ```text 241 $ curl \ 242 https://localhost:4646/v1/quota-usages?prefix=sha 243 ``` 244 245 ### Sample Response 246 247 ```json 248 [ 249 { 250 "Used": { 251 "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=": { 252 "Region": "global", 253 "RegionLimit": { 254 "CPU": 500, 255 "MemoryMB": 256, 256 "DiskMB": 0, 257 "Networks": null 258 }, 259 "Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=" 260 } 261 }, 262 "Name": "default", 263 "CreateIndex": 8, 264 "ModifyIndex": 56 265 } 266 ] 267 ``` 268 269 ## Read Quota Usage 270 271 This endpoint reads information about a specific quota usage. 272 273 | Method | Path | Produces | 274 | ------ | ------------------- | -------------------------- | 275 | `GET` | `/v1/quota/usage/:quota` | `application/json` | 276 277 The table below shows this endpoint's support for 278 [blocking queries](/api/index.html#blocking-queries) and 279 [required ACLs](/api/index.html#acls). 280 281 | Blocking Queries | ACL Required | 282 | ---------------- | -------------------- | 283 | `YES` | `quota:read`<br>`namespace:*` if namespace has quota attached| 284 285 ### Parameters 286 287 - `:quota` `(string: <required>)`- Specifies the quota specification to query 288 where the identifier is the quota's name. 289 290 ### Sample Request 291 292 ```text 293 $ curl \ 294 https://localhost:4646/v1/quota/shared-quota 295 ``` 296 297 ### Sample Response 298 299 ```json 300 { 301 "Used": { 302 "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=": { 303 "Region": "global", 304 "RegionLimit": { 305 "CPU": 500, 306 "MemoryMB": 256, 307 "DiskMB": 0, 308 "Networks": null 309 }, 310 "Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=" 311 } 312 }, 313 "Name": "default", 314 "CreateIndex": 8, 315 "ModifyIndex": 56 316 } 317 ```