Changing quotas

Quotas enable you to limit the ability to use the service. The quota is managed through the offering items which represent the set of services and service features.

The user account quotas are controlled via user account personal tenants.

There are two types of quotas: “soft” and “hard”:

The quota is considered “soft” when you do not set a quota overage. This means that restrictions on using the backup service are not applied.

The quota is considered “hard” when you set a quota overage. An overage allows to exceed the quota by the specified value. When the overage is exceeded, restrictions on using the service are applied.

Warning

When changing storage quotas of partner or folder sub-tenants with multiple storages, some offering items may have the same name. Refer to “Changing storage quotas of partner sub-tenants”.

In this procedure, the vms and workstations offering items of the advanced edition will be used as an example.

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 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 tenant which offering items and/or offering item quotas you want to modify:

    1. To modify the quotas of a user account, use a personal tenant of the user account created via the API or find the user account and use its UUID to fetch the user account information and store its personal tenant UUID:

      >>> tenant_id = created_user_personal_tenant_id
      >>> tenant_id
      'e18a5b6f-5ba4-44b0-8b41-033148877aee'
      
    2. To enable/disable or modify quotas of a sub-tenant, use the sub-tenant created via the API or find the sub-tenant and store its UUID:

      >>> tenant_id = created_tenant_id
      >>> tenant_id
      '95303d96-628c-4265-9afa-07bee3fccf39'
      
  3. Fetch the list of all offering items of the advanced for the tenant as described in “Fetching available offering items”. As the result, you must have a variable assigned with the list of all offering items available for the tenant:

    >>> offering_items = fetched_offering_items['items']
    >>> pprint.pprint(offering_items)
    [{'application_id': '6e6d758d-8e74-3ae3-ac84-50eb0dff12eb',
      'edition': 'advanced',
      'locked': False,
      'measurement_unit': 'quantity',
      'name': 'adv_workstations',
      'quota': {'overage': None, 'value': None, 'version': 0},
      'status': 1,
      'type': 'count',
      'usage_name': 'workstations'},
      ...
     {'application_id': '6e6d758d-8e74-3ae3-ac84-50eb0dff12eb',
      'edition': 'advanced',
      'locked': False,
      'measurement_unit': 'quantity',
      'name': 'adv_vms',
      'quota': {'overage': None, 'value': None, 'version': 0},
      'status': 1,
      'type': 'count',
      'usage_name': 'vms'},
      ...]
    

    Important

    • The quota limits are removed by setting the value (soft quota) and/or overage (hard quota) attributes to None.

    • Setting the value (soft quota) to 0 will set it to zero. This means that the offering item will not be available to the tenant since the quota will be already exceeded.

    • Setting the value (soft quota) limit to None will reset the version to 0 and the overage to None.

    • Disabled offering items do not have the quota object.

  4. Iterate over the list of the offering items and set the soft quota for the vms to 15 virtual machines and for the workstations to 10 workstations.

    >>> for offering_item in offering_items:
    ...     # Check if the offering item is enabled
    ...     if offering_item['status']:
    ...         if offering_item['usage_name'] == 'workstations':
    ...             offering_item['quota']['value'] = 10  #  measurement_unit - quantity
    ...         elif offering_item['usage_name'] == 'vms':
    ...             offering_item['quota']['value'] = 15  #  measurement_unit - quantity
    
  5. Define a variable named updated_offering_items, and then assign an object with the offering_items key with the list of offering items to this variable:

    >>> updated_offering_items = {
    ...     'offering_items': offering_items
    ... }
    
  6. Convert the updated_offering_items object to a JSON text:

    >>> updated_offering_items = json.dumps(updated_offering_items, indent=4)
    
  7. Send a PUT request with the JSON text to the /tenants/{tenant_id}/offering_items endpoint:

    >>> response = requests.put(
    ...     f'{base_url}/tenants/{tenant_id}/offering_items',
    ...     headers={'Content-Type': 'application/json', **auth},
    ...     data=updated_offering_items,
    ... )
    
  8. Check the status code of the response:

    >>> response.status_code
    200
    

    Status code 200 means that the quotas of the offering items has been changed.

    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 items array with the updated offering item quotas formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'items': [{'application_id': '6e6d758d-8e74-3ae3-ac84-50eb0dff12eb',
                'edition': 'advanced',
                'locked': False,
                'measurement_unit': 'quantity',
                'name': 'adv_workstations',
                'quota': {'overage': None,
                          'value': 10,
                          'version': 1565794018233},
                'status': 1,
                'type': 'count',
                'usage_name': 'workstations'},
                ...
               {'application_id': '6e6d758d-8e74-3ae3-ac84-50eb0dff12eb',
                'edition': 'advanced',
                'locked': False,
                'measurement_unit': 'quantity',
                'name': 'adv_vms',
                'quota': {'overage': None, 'value': 15, 'version': 1565794018233},
                'status': 1,
                'type': 'count',
                'usage_name': 'vms'},
                ...]}