# Workload Quotas

## List Quota Types

<mark style="color:blue;">`GET`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/projects_quota_types`

Lists all available Quota Types

#### Path Parameters

| Name         | Type   | Description                  |
| ------------ | ------ | ---------------------------- |
| tvm\_address | string | IP or FQDN of Trilio service |
| tenant\_id   | string | ID of Tenant/Project         |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="200 Provides the list of available Quota Types" %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 15:40:56 GMT
Content-Type: application/json
Content-Length: 1625
Connection: keep-alive
X-Compute-Request-Id: req-2ad95c02-54c6-4908-887b-c16c5e2f20fe

{
   "quota_types":[
      {
         "created_at":"2020-10-19T10:05:52.000000",
         "updated_at":"2020-10-19T10:07:32.000000",
         "deleted_at":null,
         "deleted":false,
         "version":"4.0.115",
         "id":"1c5d4290-2e08-11ea-889c-7440bb00b67d",
         "display_name":"Workloads",
         "display_description":"Total number of workload creation allowed per project",
         "status":"available"
      },
      {
         "created_at":"2020-10-19T10:05:52.000000",
         "updated_at":"2020-10-19T10:07:32.000000",
         "deleted_at":null,
         "deleted":false,
         "version":"4.0.115",
         "id":"b7273a06-2e08-11ea-889c-7440bb00b67d",
         "display_name":"Snapshots",
         "display_description":"Total number of snapshot creation allowed per project",
         "status":"available"
      },
      {
         "created_at":"2020-10-19T10:05:52.000000",
         "updated_at":"2020-10-19T10:07:32.000000",
         "deleted_at":null,
         "deleted":false,
         "version":"4.0.115",
         "id":"be323f58-2e08-11ea-889c-7440bb00b67d",
         "display_name":"VMs",
         "display_description":"Total number of VMs allowed per project",
         "status":"available"
      },
      {
         "created_at":"2020-10-19T10:05:52.000000",
         "updated_at":"2020-10-19T10:07:32.000000",
         "deleted_at":null,
         "deleted":false,
         "version":"4.0.115",
         "id":"c61324d0-2e08-11ea-889c-7440bb00b67d",
         "display_name":"Volumes",
         "display_description":"Total number of volume attachments allowed per project",
         "status":"available"
      },
      {
         "created_at":"2020-10-19T10:05:52.000000",
         "updated_at":"2020-10-19T10:07:32.000000",
         "deleted_at":null,
         "deleted":false,
         "version":"4.0.115",
         "id":"f02dd7a6-2e08-11ea-889c-7440bb00b67d",
         "display_name":"Storage",
         "display_description":"Total storage (in Bytes) allowed per project",
         "status":"available"
      }
   ]
}
```

{% endtab %}
{% endtabs %}

## Show Quota Type

<mark style="color:blue;">`GET`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/projects_quota_types/<quota_type_id>`

Requests the details of a Quota Type

#### Path Parameters

| Name            | Type   | Description                     |
| --------------- | ------ | ------------------------------- |
| tvm\_address    | string | IP or FQDN of Trilio service    |
| tenant\_id      | string | ID of Tenant/Project to work in |
| quota\_type\_id | string | ID of the Quota Type to show    |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="200 Returns details for the Quota Type" %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 15:44:43 GMT
Content-Type: application/json
Content-Length: 342
Connection: keep-alive
X-Compute-Request-Id: req-5bf629fe-ffa2-4c90-b704-5178ba2ab09b

{
   "quota_type":{
      "created_at":"2020-10-19T10:05:52.000000",
      "updated_at":"2020-10-19T10:07:32.000000",
      "deleted_at":null,
      "deleted":false,
      "version":"4.0.115",
      "id":"1c5d4290-2e08-11ea-889c-7440bb00b67d",
      "display_name":"Workloads",
      "display_description":"Total number of workload creation allowed per project",
      "status":"available"
   }
}
```

{% endtab %}
{% endtabs %}

## Create allowed Quota

<mark style="color:green;">`POST`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/project_allowed_quotas/<project_id>`

Creates an allowed Quota with the given parameters

#### Path Parameters

| Name         | Type   | Description                                             |
| ------------ | ------ | ------------------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio service                            |
| tenant\_id   | string | ID of the Tenant/Project to work in                     |
| project\_id  | string | ID of the Tenant/Project to create the allowed Quota in |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Content-Type      | string | application/json                |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="200 Allowed Quota has been created" %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 15:51:51 GMT
Content-Type: application/json
Content-Length: 24
Connection: keep-alive
X-Compute-Request-Id: req-08c8cdb6-b249-4650-91fb-79a6f7497927

{
   "allowed_quotas":[
      {
         
      }
   ]
}
```

{% endtab %}
{% endtabs %}

### Body Format

```
{
   "allowed_quotas":[
      {
         "project_id":"<project_id>",
         "quota_type_id":"<quota_type_id>",
         "allowed_value":"<integer>",
         "high_watermark":"<Integer>"
      }
   ]
}
```

## List allowed Quota

<mark style="color:blue;">`GET`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/project_allowed_quotas/<project_id>`

Lists all allowed Quotas for a given project.

#### Path Parameters

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio service                         |
| tenant\_id   | string | ID of the Tenant/Project to work in                  |
| project\_id  | string | ID of the Tenant/Project to list allowed Quotas from |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="200 Returns list of allowed quotas for a given project" %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 16:01:39 GMT
Content-Type: application/json
Content-Length: 766
Connection: keep-alive
X-Compute-Request-Id: req-e570ce15-de0d-48ac-a9e8-60af429aebc0

{
   "allowed_quotas":[
      {
         "id":"262b117d-e406-4209-8964-004b19a8d422",
         "project_id":"c76b3355a164498aa95ddbc960adc238",
         "quota_type_id":"1c5d4290-2e08-11ea-889c-7440bb00b67d",
         "allowed_value":5,
         "high_watermark":4,
         "version":"4.0.115",
         "quota_type_name":"Workloads"
      },
      {
         "id":"68e7203d-8a38-4776-ba58-051e6d289ee0",
         "project_id":"c76b3355a164498aa95ddbc960adc238",
         "quota_type_id":"f02dd7a6-2e08-11ea-889c-7440bb00b67d",
         "allowed_value":-1,
         "high_watermark":-1,
         "version":"4.0.115",
         "quota_type_name":"Storage"
      },
      {
         "id":"ed67765b-aea8-4898-bb1c-7c01ecb897d2",
         "project_id":"c76b3355a164498aa95ddbc960adc238",
         "quota_type_id":"be323f58-2e08-11ea-889c-7440bb00b67d",
         "allowed_value":50,
         "high_watermark":25,
         "version":"4.0.115",
         "quota_type_name":"VMs"
      }
   ]
}
```

{% endtab %}
{% endtabs %}

## Show allowed Quota

<mark style="color:blue;">`GET`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/project_allowed_quota/<allowed_quota_id>`

Shows details for a given allowed Quota

#### Path Parameters

| Name                  | Type   | Description                         |
| --------------------- | ------ | ----------------------------------- |
| tvm\_address          | string | IP or FQDN of Trilio service        |
| tenant\_id            | string | ID of the Tenant/Project to work in |
| \<allowed\_quota\_id> | string | ID of the allowed Quota to show     |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="200 " %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 16:15:07 GMT
Content-Type: application/json
Content-Length: 268
Connection: keep-alive
X-Compute-Request-Id: req-d87a57cd-c14c-44dd-931e-363158376cb7

{
   "allowed_quotas":{
      "id":"262b117d-e406-4209-8964-004b19a8d422",
      "project_id":"c76b3355a164498aa95ddbc960adc238",
      "quota_type_id":"1c5d4290-2e08-11ea-889c-7440bb00b67d",
      "allowed_value":5,
      "high_watermark":4,
      "version":"4.0.115",
      "quota_type_name":"Workloads"
   }
}
```

{% endtab %}
{% endtabs %}

## Update allowed Quota

<mark style="color:orange;">`PUT`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/update_allowed_quota/<allowed_quota_id>`

Updates an allowed Quota with the given parameters

#### Path Parameters

| Name                  | Type   | Description                         |
| --------------------- | ------ | ----------------------------------- |
| tvm\_address          | string | IP or FQDN of Trilio service        |
| tenant\_id            | string | ID of the Tenant/Project to work in |
| \<allowed\_quota\_id> | string | ID of the allowed Quota to update   |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Content-Type      | string | application/json                |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="202 Quota Update has been done" %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 16:24:04 GMT
Content-Type: application/json
Content-Length: 24
Connection: keep-alive
X-Compute-Request-Id: req-a4c02ee5-b86e-4808-92ba-c363b287f1a2

{"allowed_quotas": [{}]}
```

{% endtab %}
{% endtabs %}

### Body Format

```
{
   "allowed_quotas":{
      "project_id":"c76b3355a164498aa95ddbc960adc238",
      "allowed_value":"20000",
      "high_watermark":"18000"
   }
}
```

## Delete allowed Quota

<mark style="color:red;">`DELETE`</mark> `https://$(tvm_address):8780/v1/$(tenant_id)/project_allowed_quotas/<allowed_quota_id>`

Deletes a given allowed Quota

#### Path Parameters

| Name                  | Type   | Description                         |
| --------------------- | ------ | ----------------------------------- |
| tvm\_address          | string | IP or FQDN of Trilio service        |
| tenant\_id            | string | ID of the Tenant/Project to work in |
| \<allowed\_quota\_id> | string | ID of the allowed Quota to delete   |

#### Headers

| Name              | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| X-Auth-Project-Id | string | Project to authenticate against |
| X-Auth-Token      | string | Authentication token to use     |
| Accept            | string | application/json                |
| User-Agent        | string | python-workloadmgrclient        |

{% tabs %}
{% tab title="202 Allowed quota gots deleted" %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Wed, 18 Nov 2020 16:33:09 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
```

{% endtab %}
{% endtabs %}
