Skip to content

Latest commit

 

History

History
197 lines (144 loc) · 7.5 KB

BillingUsageMetricsApi.md

File metadata and controls

197 lines (144 loc) · 7.5 KB

fastly.BillingUsageMetricsApi

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
get_service_level_usage GET /billing/v3/service-usage-metrics Retrieve service-level usage metrics for a product.
get_usage_metrics GET /billing/v3/usage-metrics Get monthly usage metrics

get_service_level_usage

Serviceusagemetrics get_service_level_usage(product_id, usage_type_name)

Retrieve service-level usage metrics for a product.

Returns product usage, broken down by service.

Example

  • Api Key Authentication (token):
import time
import fastly
from fastly.api import billing_usage_metrics_api
from fastly.model.serviceusagemetrics import Serviceusagemetrics
from fastly.model.error import Error
from pprint import pprint
# Defining the host is optional and defaults to https://api.fastly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = fastly.Configuration(
    host = "https://api.fastly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: token
configuration.api_key['token'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['token'] = 'Bearer'

# Enter a context with an instance of the API client
with fastly.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = billing_usage_metrics_api.BillingUsageMetricsApi(api_client)
    product_id = "product_id_example" # str | The product identifier for the metrics returned (e.g., `cdn_usage`). This field is not required for CSV requests.
    usage_type_name = "usage_type_name_example" # str | The usage type name for the metrics returned (e.g., `North America Requests`). This field is not required for CSV requests.
    start_month = "2023-01" # str |  (optional)
    end_month = "2023-03" # str |  (optional)
    limit = "5" # str | Number of results per page. The maximum is 100. (optional) if omitted the server will use the default value of "5"
    cursor = "cursor_example" # str | Cursor value from the `next_cursor` field of a previous response, used to retrieve the next page. To request the first page, this should be empty. (optional)

    # example passing only required values which don't have defaults set
    try:
        # Retrieve service-level usage metrics for a product.
        api_response = api_instance.get_service_level_usage(product_id, usage_type_name)
        pprint(api_response)
    except fastly.ApiException as e:
        print("Exception when calling BillingUsageMetricsApi->get_service_level_usage: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Retrieve service-level usage metrics for a product.
        api_response = api_instance.get_service_level_usage(product_id, usage_type_name, start_month=start_month, end_month=end_month, limit=limit, cursor=cursor)
        pprint(api_response)
    except fastly.ApiException as e:
        print("Exception when calling BillingUsageMetricsApi->get_service_level_usage: %s\n" % e)

Parameters

Name Type Description Notes
product_id str The product identifier for the metrics returned (e.g., cdn_usage). This field is not required for CSV requests.
usage_type_name str The usage type name for the metrics returned (e.g., North America Requests). This field is not required for CSV requests.
start_month str [optional]
end_month str [optional]
limit str Number of results per page. The maximum is 100. [optional] if omitted the server will use the default value of "5"
cursor str Cursor value from the next_cursor field of a previous response, used to retrieve the next page. To request the first page, this should be empty. [optional]

Return type

Serviceusagemetrics

Authorization

token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A response containing usage elements. -
400 Bad Request -
401 Unauthorized -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_usage_metrics

Usagemetric get_usage_metrics()

Get monthly usage metrics

Returns monthly usage metrics for customer by product.

Example

  • Api Key Authentication (token):
import time
import fastly
from fastly.api import billing_usage_metrics_api
from fastly.model.error import Error
from fastly.model.usagemetric import Usagemetric
from pprint import pprint
# Defining the host is optional and defaults to https://api.fastly.com
# See configuration.py for a list of all supported configuration parameters.
configuration = fastly.Configuration(
    host = "https://api.fastly.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: token
configuration.api_key['token'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['token'] = 'Bearer'

# Enter a context with an instance of the API client
with fastly.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = billing_usage_metrics_api.BillingUsageMetricsApi(api_client)
    start_month = "2023-01" # str |  (optional)
    end_month = "2023-03" # str |  (optional)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get monthly usage metrics
        api_response = api_instance.get_usage_metrics(start_month=start_month, end_month=end_month)
        pprint(api_response)
    except fastly.ApiException as e:
        print("Exception when calling BillingUsageMetricsApi->get_usage_metrics: %s\n" % e)

Parameters

Name Type Description Notes
start_month str [optional]
end_month str [optional]

Return type

Usagemetric

Authorization

token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A response containing usage metric elements. -
400 Bad Request -
401 Unauthorized -
500 Internal Server Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]