Fetching workloads

A list of workloads that are present in Acronis Cyber Protect Cloud may be obtained by sending a GET request to the /api/workload_management/v5/workloads endpoint.

Query parameters

Parameter

Type

Description

tenant_id

string

Filter by one or more tenant IDs. Maximum 100 items.

To filter by one tenant ID, specify a tenant ID: 2f4b84d8-6aad-487b-b0b1-40845bf72737.

To filter by multiple tenant IDs, specify tenants in the following format: or(2f4b84d8-6aad-487b-b0b1-40845bf72737,c70134c4-a244-4b22-99ad-e081301f7530).

type

string

Filter by one or more workload types. Maximum 10 items.

To filter by one workload type, specify the workload type identifier: cti.a.p.wm.workload_aspect.v1.0~a.p.machine.v1.0.

To filter by multiple workload types, specify the workload type identifiers in the following format: or(cti.a.p.wm.workload_aspect.v1.0~a.p.machine.v1.0,cti.a.p.wm.workload_aspect.v1.0~a.p.mobile.v1.0).

workload_id

string

Filter by one or more workload IDs. Maximum 100 items.

To filter by one workload ID, specify a workload ID: 2f4b84d8-6aad-487b-b0b1-40845bf72737.

To filter by multiple workload IDs, specify workloads in the following format: or(2f4b84d8-6aad-487b-b0b1-40845bf72737,c70134c4-a244-4b22-99ad-e081301f7530).

search

string

Search for workloads by type and tags using an SQL-like syntax.

For more information, refer to https://www.acronis.com/en-us/support/documentation/CyberProtectionService/index.html#operators-dynamic-groups.html.

updated_at

string

Filter by the date and time when the workload was updated in RFC3339 format.

Supports the following formats:

To filter by the specific date and time, specify the exact date and time: 2009-11-10T23:00:00Z.

To filter by specific conditions, use one of the following operators:

  • ge() - returns the workloads whose dates are greater than or equal (>=) to the specified date. For example, ge(2009-11-10T23:00:00Z).

  • gt() - returns the workloads whose dates are greater than (>) the specified date. For example, gt(2009-11-10T23:00:00Z).

  • le() - returns the workloads whose dates are less than or equal (<=) the specified date. For example, le(2009-11-10T23:00:00Z).

  • lt() - returns the workloads whose dates are less than (<>) the specified date. For example, lt(2009-11-10T23:00:00Z).

  • range() - returns the workloads whose dates are within the specified range including the specified dates. For example, range(2009-11-10T23:00:00Z,2009-11-11T23:00:00Z).

  • xrange() - returns the workloads whose dates are within the specified range excluding the specified dates. For example, xrange(2009-11-10T23:00:00Z,2009-11-11T23:00:00Z).

include_status

boolean

If true, includes workload statuses in the response. Does not include workload statuses otherwise.

include_all_attributes

boolean

If true, includes all workload attributes in the response. Does not include workload attributes otherwise. Mutually exclusive with the include_attributes.

include_attributes

array of string

Includes the specified workload attributes (if present) by their names in the response. Mutually exclusive with the include_attributes.

include_allowed_actions

boolean

If true, includes allowed actions for the workload in the response. Does not include workload actions otherwise.

include_aggregated_aspects

boolean

If true, includes aspects that were aggregated into the workload.

order

string

Sorts workloads by orderable fields. Only one field can be specified in the request.

Fields that can be used for ordering:

  • is_group

  • updated_at

To sort by a specific field, specify the field: updated_at. The results will be ordered in ascending order.

To specify the order, use one of the following operators:

  • asc() - returns the workloads ordered by the field in ascending order. For example, asc(updated_at).

  • desc() - returns the workloads ordered by the field in ascending order. For example, desc(updated_at).

limit

integer

Number of the results returned in the response.

before

string

Cursor to the previous results page.

after

string

Cursor to the next results page.

Response structure

If the workloads were fetched successfully, the response returns status 200 with the payload in the following structure:

Name

Value type

Description

items

array of object

A list of workloads.

items[*].id

string

The UUID of the workload.

items[*].type

string

The identifier of the workload type.

items[*].name

string

A name of the workload.

items[*].attributes

object

A key-value map of workload attributes. Allowed values are defined by the attributes schema specified in the Vendor Portal.

items[*].client_id

string

An identifier of the API client that created the workload. Must be the client ID of your application.

items[*].allowed_actions

array of string

A list of workload action identifiers that are allowed for this workload.

items[*].tenant_id

string

The identifier of the tenant where the workload was created.

items[*].external_id

string

The identifier that is used in the external system where the workload is originated from. Equal to the id field in case it was not specified.

items[*].agent_id

string

UUID of the agent that manages the workload. Only applicable to Acronis workloads.

items[*].created_at

string

RFC3339 date and time in UTC timezone when the workload was created.

items[*].updated_at

string

RFC3339 date and time in UTC timezone when the workload was updated.

items[*].aggregates_detection_query

object

Parameters of any use cases when workload group is automatically created.

items[*].parent_child_relationship_query

array of objects

Parameters of any use cases when the parent-child relationship is set automatically.

items[*].is_auto_created

boolean

True if the workload was created due to merge and cluster-like use case. False otherwise.

items[*].aggregation_status

string

Status of the workload aggregation. Can be one of the following:

  • NOT_AGGREGATED - workload was not aggregated.

  • MERGED_AUTOMATICALLY - workload was merged automatically.

  • MERGED_MANUALLY - workload was merged manually.

  • SPLIT_MANUALLY - workload was split manually.

items[*].enabled

boolean

Status of the workload. True if enabled, false otherwise.

paging

object

An object containing the information about the pagination.

paging.cursors

object

An object containing the information about the cursors to the pages.

paging.cursors.before

string

Cursor to the next page.

paging.cursors.after

string

Cursor to the previous page.

_links

array of object

A list of links related to the requested resource.

Step-by-step procedure

  1. Authenticate to the cloud platform via the Python shell.

    The following variables should be available now:

    >>> base_url  # the base URL
    'https://eu8-cloud.acronis.com'
    >>> auth  # the 'Authorization' header value with the access token
    {'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImMwMD...'}
    
  2. Define a variable named params, and then assign an object with the include_all_attributes parameter to include all workload attributes to this variable:

    >>> params = {
    ...     # Include workload attributes in the response
    ...     "include_all_attributes": True
    ... }
    
  3. Send a GET request to the /api/workload_management/v5/workloads endpoint:

    >>> response = requests.get(
    ...     f'{base_url}/api/workload_management/v5/workloads',
    ...     headers=auth,
    ...     params=params,
    ... )
    
  4. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the request was successful.

    Also, the response body contains the list of workloads including all their attributes in the attributes field formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {
        "items": [
            {
                "type_alias": "resource.machine",
                "aggregates_detection_query": {},
                "parent_child_relationship_query": [
                    {
                        "parent_type": "cti.a.p.wm.workload.v1.0~a.p.wm.group.v1.0~a.p.computers.v1.0"
                    }
                ],
                "id": "2faf3f5c-0d7a-455f-bcf1-6fb7b8ec1bf2",
                "created_at": "2023-11-07T14:40:01.976227998Z",
                "updated_at": "2023-11-07T14:40:01.976227998Z",
                "type": "cti.a.p.wm.workload.v1.0~a.p.wm.aspect.v1.0~vendor.application.mongodb.v1.0",
                "is_auto_created": false,
                "external_id": "2faf3f5c-0d7a-455f-bcf1-6fb7b8ec1bf2@286",
                "tenant_id": "286",
                "name": "MongoDB Server",
                "user_defined_name": "MongoDB Server",
                "attributes": {
                    "host_name": "DESKTOP-ABC321SDF",
                    "mac_address": "00:00:00:00:00",
                    "status": "OK",
                    "db_version": "v3.4.9"
                },
                "client_id": "696fcfe0-1272-454c-99cc-24ec2e037613",
                "aggregation_status": "NOT_AGGREGATED"
            },
            ...
        ],
        "paging": {
            "cursors": {
                "total": 3
            }
        },
        "dynamic_group_creation_forbidden": false,
        "_links": [
            {
                "rel": "self",
                "href": "/api/workload_management/v5/workloads"
            }
        ]
    }