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 workload_id, and then assign ID of the workload obtained from the list of fetched workloads to this variable:

    >>> workload_id = 'b369335d-fc8a-4c7f-b5bb-896448c854bd'
    
  3. Define a variable named workload_data, and then assign the updated information about the workload to this variable:

    >>> workload_data = {
    ...     "name": "New virtual machine name",
    ...     "attributes": {
    ...         "hostname": "CORP-123456",
    ...         "mac_address": "0a:df:7e:25:36:7e"
    ...     }
    ... }
    
  4. Convert the workload_data object to a JSON text:

    >>> workload_data = json.dumps(workload_data, indent=4)
    >>> print(workload_data)
    {
        "name": "New virtual machine name",
        "attributes": {
            "hostname": "CORP-123456",
            "mac_address": "0a:df:7e:25:36:7e"
        }
    }
    
  5. Send a PATCH request with the JSON text to the /api/workload_management/v5/workloads/{workload_id} endpoint:

    >>> response = requests.patch(
    ...     f'{base_url}/api/workload_management/v5/workloads/{workload_id}',
    ...     headers={'Content-Type': 'application/json', **auth},
    ...     data=workload_data,
    ... )
    
  6. Check the status code of the response:

    >>> response.status_code
    204
    

    Status code 200 means that the workload was updated successfully.