Fetching the pricing information for a tenant

  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
    >>> 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
  2. Assign either of the following values to the tenant_id variable – the UUID of a tenant created via the API or a tenant found by its name:

    >>> tenant_id = created_tenant_id
    >>> tenant_id
  3. Obtain the list of services enabled for the tenant, which UUID is specified in the tenant_id variable, as described in steps 3-6 of “Fetching information about services enabled for a tenant”. As the result, you should have a tenant_applications variable with the list of service objects.

  4. In this list, find the platform service (the value of a service object’s type key) and store its UUID (the value of a service object’s id key) in a variable named application_id:

    >>> application_id = None
    >>> for application in tenant_applications:
    ...     if application['type'] == 'platform':
    ...         application_id = application['id']
    ...         break
    >>> application_id
  5. Define a variable named setting_name, and then assign a name of the price list setting to this variable:

    >>> setting_name = 'pricing_info'
  6. Send a GET request to the /applications/{application_id}/settings/tenants/{tenant_id}/{setting_name} endpoint:

    >>> response = requests.get(
    ...     f'{base_url}/applications/{application_id}/settings/tenants/{tenant_id}/{setting_name}',
    ...     headers=auth,
    ... )
  7. Check the status code of the response:

    >>> response.status_code

    Status code 200 means that the platform has assigned the tenant with the licensing mode.

    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 price list setting object formatted as a JSON text. When converted to an object, it will look as follows:

    >>> pprint.pprint(response.json())
    {'effective': None,
    'name': 'pricing_info',
    'own': {'exclusive': False,
            'lock': False,
            'value': {'currency': 'USD',
                    'licensing_mode': 'per_gb',
                    'pricing': [{'description': 'Cloud Storage',
                                    'price': 0.09,
                                    'sku': 'ACRCLST'},
                                {'description': 'Google Hosted Storage',
                                    'price': 0.12,
                                    'sku': 'ACRGLST'},
                                {'description': 'Local Storage',
                                    'price': 0.05,
                                    'sku': 'PRTLCST'}],
                    'tier_level': 'Minimal monthly payment 100 USD'}}}