# Workloads

## List Workloads

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

Provides the list of all workloads for the given tenant/project id

#### Path Parameters

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                         |
| tenant\_id   | string | ID of the Tenant/Project to fetch the workloads from |

#### Query Parameters

| Name           | Type    | Description                                                        |
| -------------- | ------- | ------------------------------------------------------------------ |
| nfs\_share     | string  | lists workloads located on a specific nfs-share                    |
| all\_workloads | boolean | admin role required - True lists workloads of all tenants/projects |

#### Headers

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

{% tabs %}
{% tab title="200 This response shows workloads existing in the admin project including important information like status, name, description, or workload type." %}

```
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Thu, 29 Oct 2020 14:55:40 GMT
Content-Type: application/json
Content-Length: 3480
Connection: keep-alive
X-Compute-Request-Id: req-a2e49b7e-ce0f-4dcb-9e61-c5a4756d9948

{
   "workloads":[
      {
         "project_id":"4dfe98a43bfa404785a812020066b4d6",
         "user_id":"adfa32d7746a4341b27377d6f7c61adb",
         "id":"8ee7a61d-a051-44a7-b633-b495e6f8fc1d",
         "name":"worklaod1",
         "snapshots_info":"",
         "description":"no-description",
         "workload_type_id":"f82ce76f-17fe-438b-aa37-7a023058e50d",
         "status":"available",
         "created_at":"2020-10-26T12:07:01.000000",
         "updated_at":"2020-10-29T12:22:26.000000",
         "scheduler_trust":null,
         "links":[
            {
               "rel":"self",
               "href":"http://wlm_backend/v1/4dfe98a43bfa404785a812020066b4d6/workloads/8ee7a61d-a051-44a7-b633-b495e6f8fc1d"
            },
            {
               "rel":"bookmark",
               "href":"http://wlm_backend/4dfe98a43bfa404785a812020066b4d6/workloads/8ee7a61d-a051-44a7-b633-b495e6f8fc1d"
            }
         ]
      },
      {
         "project_id":"4dfe98a43bfa404785a812020066b4d6",
         "user_id":"adfa32d7746a4341b27377d6f7c61adb",
         "id":"a90d002a-85e4-44d1-96ac-7ffc5d0a5a84",
         "name":"workload2",
         "snapshots_info":"",
         "description":"no-description",
         "workload_type_id":"f82ce76f-17fe-438b-aa37-7a023058e50d",
         "status":"available",
         "created_at":"2020-10-20T09:51:15.000000",
         "updated_at":"2020-10-29T10:03:33.000000",
         "scheduler_trust":null,
         "links":[
            {
               "rel":"self",
               "href":"http://wlm_backend/v1/4dfe98a43bfa404785a812020066b4d6/workloads/a90d002a-85e4-44d1-96ac-7ffc5d0a5a84"
            },
            {
               "rel":"bookmark",
               "href":"http://wlm_backend/4dfe98a43bfa404785a812020066b4d6/workloads/a90d002a-85e4-44d1-96ac-7ffc5d0a5a84"
            }
         ]
      }
   ]
}
```

{% endtab %}
{% endtabs %}

## Create Workload

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

Creates a workload in the provided Tenant/Project with the given details.

#### Path Parameters

| Name         | Type   | Description                                        |
| ------------ | ------ | -------------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                       |
| tenant\_id   | string | ID of the Tenant/Project to create the workload in |

#### Headers

| Name              | Type   | Description                               |
| ----------------- | ------ | ----------------------------------------- |
| X-Auth-Project-Id | string | Project to run the authentication 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 Response upon successfully starting the workload creation process." %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Thu, 29 Oct 2020 15:42:02 GMT
Content-Type: application/json
Content-Length: 703
Connection: keep-alive
X-Compute-Request-Id: req-443b9dea-36e6-4721-a11b-4dce3c651ede

{
   "workload":{
      "project_id":"c76b3355a164498aa95ddbc960adc238",
      "user_id":"ccddc7e7a015487fa02920f4d4979779",
      "id":"c4e3aeeb-7d87-4c49-99ed-677e51ba715e",
      "name":"API created",
      "snapshots_info":"",
      "description":"API description",
      "workload_type_id":"f82ce76f-17fe-438b-aa37-7a023058e50d",
      "status":"creating",
      "created_at":"2020-10-29T15:42:01.000000",
      "updated_at":"2020-10-29T15:42:01.000000",
      "scheduler_trust":null,
      "links":[
         {
            "rel":"self",
            "href":"http://wlm_backend/v1/c76b3355a164498aa95ddbc960adc238/workloads/c4e3aeeb-7d87-4c49-99ed-677e51ba715e"
         },
         {
            "rel":"bookmark",
            "href":"http://wlm_backend/c76b3355a164498aa95ddbc960adc238/workloads/c4e3aeeb-7d87-4c49-99ed-677e51ba715e"
         }
      ]
   }
}
```

{% endtab %}
{% endtabs %}

### Body format

Workload create requires a Body in json format, to provide the requested information.

{% hint style="warning" %}
Using a policy-id will pull the following information from the policy. Values provided in the Body will be overwritten with the values from the Policy.

```
retention_policy_type
retention_policy_value
interval
```

{% endhint %}

```
{
   "workload":{
      "name":"<name of the Workload>",
      "description":"<description of workload>",
      "workload_type_id":"<ID of the chosen Workload Type",
      "source_platform":"openstack",
      "instances":[
         {
            "instance-id":"<Instance ID>"
         },
         {
            "instance-id":"<Instance ID>"
         }
      ],
      "jobschedule":{
         "retention_policy_type":"<'Number of Snapshots to Keep'/'Number of days to retain Snapshots'>",
         "retention_policy_value":"<Integer>"
         "timezone":"<timezone>",
         "start_date":"<Date format: MM/DD/YYYY>"
         "end_date":"<Date format MM/DD/YYYY>",
         "start_time":"<Time format: HH:MM AM/PM>",
         "interval":"<Format: Integer hr",
         "enabled":"<True/False>"
      },
      "metadata":{
         <key>:<value>,
         "policy_id":"<policy_id>"
      }
   }
}
```

## Show Workload

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

Shows all details of a specified workload

#### Path Parameters

| Name         | Type   | Description                                         |
| ------------ | ------ | --------------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                        |
| tenant\_id   | string | ID of the Project/Tenant where to find the Workload |
| workload\_id | string | ID of the Workload to show                          |

#### Headers

| Name              | Type   | Description                               |
| ----------------- | ------ | ----------------------------------------- |
| X-Auth-Project-Id | string | Project to run the authentication 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: Mon, 02 Nov 2020 12:08:42 GMT
Content-Type: application/json
Content-Length: 1536
Connection: keep-alive
X-Compute-Request-Id: req-afb76abb-aa33-427e-8219-04fc2b91bce0

{
   "workload":{
      "created_at":"2020-10-29T15:42:01.000000",
      "updated_at":"2020-10-29T15:42:18.000000",
      "id":"c4e3aeeb-7d87-4c49-99ed-677e51ba715e",
      "user_id":"ccddc7e7a015487fa02920f4d4979779",
      "project_id":"c76b3355a164498aa95ddbc960adc238",
      "availability_zone":"nova",
      "workload_type_id":"f82ce76f-17fe-438b-aa37-7a023058e50d",
      "name":"API created",
      "description":"API description",
      "interval":null,
      "storage_usage":{
         "usage":0,
         "full":{
            "snap_count":0,
            "usage":0
         },
         "incremental":{
            "snap_count":0,
            "usage":0
         }
      },
      "instances":[
         {
            "id":"08dab61c-6efd-44d3-a9ed-8e789d338c1b",
            "name":"cirros-4",
            "metadata":{
               
            }
         },
         {
            "id":"7c1bb5d2-aa5a-44f7-abcd-2d76b819b4c8",
            "name":"cirros-3",
            "metadata":{
               
            }
         }
      ],
      "metadata":{
         "hostnames":"[]",
         "meta":"data",
         "policy_id":"b79aa5f3-405b-4da4-96e2-893abf7cb5fd",
         "preferredgroup":"[]",
         "workload_approx_backup_size":"6"
      },
      "jobschedule":{
         "retention_policy_type":"Number of Snapshots to Keep",
         "end_date":"15/27/2020",
         "start_time":"3:00 PM",
         "interval":"5",
         "enabled":false,
         "retention_policy_value":"10",
         "timezone":"UTC+2",
         "start_date":"10/27/2020",
         "fullbackup_interval":"-1",
         "appliance_timezone":"UTC",
         "global_jobscheduler":true
      },
      "status":"available",
      "error_msg":null,
      "links":[
         {
            "rel":"self",
            "href":"http://wlm_backend/v1/c76b3355a164498aa95ddbc960adc238/workloads/c4e3aeeb-7d87-4c49-99ed-677e51ba715e"
         },
         {
            "rel":"bookmark",
            "href":"http://wlm_backend/c76b3355a164498aa95ddbc960adc238/workloads/c4e3aeeb-7d87-4c49-99ed-677e51ba715e"
         }
      ],
      "scheduler_trust":null
   }
}
```

{% endtab %}
{% endtabs %}

## Modify Workload

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

Modifies a workload in the provided Tenant/Project with the given details.

#### Path Parameters

| Name         | Type   | Description                                            |
| ------------ | ------ | ------------------------------------------------------ |
| tvm\_address | string | IP or FQDN of Trilio Service                           |
| tenant\_id   | string | ID of the Tenant/Project where to find the workload in |
| workload\_id | string | ID of the Workload to modify                           |

#### Headers

| Name              | Type   | Description                               |
| ----------------- | ------ | ----------------------------------------- |
| X-Auth-Project-Id | string | Project to run the authentication 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 Workload modify request has been received and accepted by the API" %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Mon, 02 Nov 2020 12:31:42 GMT
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
X-Compute-Request-Id: req-674a5d71-4aeb-4f99-90ce-7e8d3158d137
```

{% endtab %}
{% endtabs %}

### Body format

Workload modify requires a Body in json format, to provide the information about the values to modify.

{% hint style="info" %}
All values in the body are optional.
{% endhint %}

{% hint style="warning" %}
Using a policy-id will pull the following information from the policy. Values provided in the Body will be overwritten with the values from the Policy.

```
retention_policy_type
retention_policy_value
interval
```

{% endhint %}

```
{
   "workload":{
      "name":"<name>",
      "description":"<description>"
      "instances":[
         {
            "instance-id":"<instance_id>"
         },
         {
            "instance-id":"<instance_id>"
         }
      ],
      "jobschedule":{
         "retention_policy_type":"<'Number of Snapshots to Keep'/'Number of days to retain Snapshots'>",
         "retention_policy_value":"<Integer>",
         "timezone":"<timezone>",
         "start_time":"<HH:MM AM/PM>",
         "end_date":"<MM/DD/YYYY>",
         "interval":"<Integer hr>",
         "enabled":"<True/False>"
      },
      "metadata":{
         "meta":"data",
         "policy_id":"<policy_id>"
      },
   }
}
```

## Delete Workload

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

Deletes the specified Workload.

#### Path Parameters

| Name         | Type   | Description                                    |
| ------------ | ------ | ---------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                   |
| tenant\_id   | string | ID of the Tenant where to find the Workload in |
| workload\_id | string | ID of the Workload to delete                   |

#### Query Parameters

| Name           | Type    | Description                                        |
| -------------- | ------- | -------------------------------------------------- |
| database\_only | boolean | True leaves the Workload data on the Backup Target |

#### Headers

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

{% tabs %}
{% tab title="202 Workload delete has been received and accepted." %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Mon, 02 Nov 2020 13:31:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
```

{% endtab %}
{% endtabs %}

## Unlock Workload

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

Unlocks the specified Workload

#### Path Parameters

| Name         | Type   | Description                                    |
| ------------ | ------ | ---------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                   |
| tenant\_id   | string | ID of the Tenant where to find the Workload in |
| workload\_id | string | ID of the Workload to unlock                   |

#### Headers

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

{% tabs %}
{% tab title="202 Request to unlock the Workload has been received and accepted" %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Mon, 02 Nov 2020 13:41:55 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
```

{% endtab %}
{% endtabs %}

## Reset Workload

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

Resets the defined workload

#### Path Parameters

| Name         | Type   | Description                                    |
| ------------ | ------ | ---------------------------------------------- |
| tvm\_address | string | IP or FQDN of Trilio Service                   |
| tenant\_id   | string | ID of the Tenant where to find the Workload in |
| workload\_id | string | ID of the Workload to reset                    |

#### Headers

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

{% tabs %}
{% tab title="202 Reset request has been received and accepted" %}

```
HTTP/1.1 202 Accepted
Server: nginx/1.16.1
Date: Mon, 02 Nov 2020 13:52:30 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.trilio.io/openstack/t4o-5.x/api-guide/workloads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
