Disabling/enabling a usage report

Important

Only scheduled reports can be enabled or disabled.

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

    The following variables should be available now:

    >>> base_url  # the base URL of the API
    'https://eu2-cloud.acronis.com/api/2'
    >>> auth  # the 'Authorization' header value with the access token
    {'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImMwMD...'}
    >>> tenant_id  # the UUID of the tenant to which the token provides access
    'ede9f834-70b3-476c-83d9-736f9f8c7dae'
    
  2. Fetch the UUID of the report that you want to update as described in “Fetching a usage report”. As the result, the following variable with the report UUID should be available:

    >>> report_id
    '20dffb36-d77b-45c6-b2fa-39276e98d5fc'
    
  3. Define a variable named report_data, and then assign the report data to update to this variable:

    >>> report_data = {
    ...     'schedule': {
    ...         'enabled': False
    ...     }
    ... }
    

    Name

    Value type

    Required

    Description

    schedule

    report schedule object

    No

    An object that allows to configure scheduling of the report. The enabled parameter is optional.

  4. Convert the report_data object to a JSON text:

    >>> report_data = json.dumps(report_data, indent=4)
    >>> print(report_data)
    {
        "schedule": {
            "enabled": false
        }
    }
    
  5. Send a PUT request with the JSON text to the /reports/{report_id} endpoint:

    >>> response = requests.put(
    ...     f'{base_url}/reports/{report_id}',
    ...     headers={'Content-Type': 'application/json', **auth},
    ...     data=report_data,
    ... )
    
  6. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the report has been disabled.

    A different status code means that an error has occurred. For the details, refer to “Status and error codes”.

    Also, the response body contains the report data formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'generation_date': '2017-05-08',
     'id': '20dffb36-d77b-45c6-b2fa-39276e98d5fc',
     'parameters': {'formats': ['csv'],
                     'kind': 'usage_current',
                     'level': 'direct_partners',
                     'period': {'end': '2017-05-07', 'start': '2017-05-01'},
                     'tenant_id': 'ede9f834-70b3-476c-83d9-736f9f8c7dae'},
     'recipients': ['ca451758-b48a-45d9-9ae6-8f1059f67619'],
     'result_action': 'send',
     'schedule': {'enabled': False, 'type': 'once'},
     'version': 1}