Updating a usage report
Important
Only scheduled reports can be updated.
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'
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'
Define a variable named
report_data
, and then assign the report data to update to this variable:>>> report_data = { ... "recipients": [ ... "ca451758-b48a-45d9-9ae6-8f1059f67619" ... ], ... "parameters": { ... "kind": "usage_current", ... "level": "direct_partners" ... } ... }
Name
Value type
Required
Description
recipients
array of UUID strings
No
An array of UUIDs of the users who should receive the report by email. Must be used only when
result_action
is set tosend
parameters
report parameters object
Yes
An object of report parameters which allow to configure the report. Only
kind
andlevel
parameters can be changed.Convert the
report_data
object to a JSON text:>>> report_data = json.dumps(report_data, indent=4) >>> print(report_data) { "recipients": [ "ca451758-b48a-45d9-9ae6-8f1059f67619" ], "parameters": { "kind": "usage_current", "level": "direct_partners" } }
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, ... )
Check the status code of the response:
>>> response.status_code 200
Status code 200 means that the report has been successfully updated.
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', 'html'], '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': True, 'type': 'once'}, 'version': 1}