Skip to content

Latest commit

 

History

History
142 lines (91 loc) · 4.93 KB

BillingUsageMetricsAPI.md

File metadata and controls

142 lines (91 loc) · 4.93 KB

BillingUsageMetricsAPI

Note

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

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

GetServiceLevelUsage

Retrieve service-level usage metrics for a product.

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    productID := "productId_example" // string | The product identifier for the metrics returned (e.g., `cdn_usage`). This field is not required for CSV requests.
    usageTypeName := "usageTypeName_example" // string | The usage type name for the metrics returned (e.g., `North America Requests`). This field is not required for CSV requests.
    startMonth := "2023-01" // string |  (optional)
    endMonth := "2023-03" // string |  (optional)
    limit := "limit_example" // string | Number of results per page. The maximum is 100. (optional) (default to "5")
    cursor := "cursor_example" // string | 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)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.BillingUsageMetricsAPI.GetServiceLevelUsage(ctx).ProductID(productID).UsageTypeName(usageTypeName).StartMonth(startMonth).EndMonth(endMonth).Limit(limit).Cursor(cursor).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `BillingUsageMetricsAPI.GetServiceLevelUsage`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetServiceLevelUsage`: Serviceusagemetrics
    fmt.Fprintf(os.Stdout, "Response from `BillingUsageMetricsAPI.GetServiceLevelUsage`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiGetServiceLevelUsageRequest struct via the builder pattern

Name Type Description Notes
productID string The product identifier for the metrics returned (e.g., cdn_usage). This field is not required for CSV requests. usageTypeName

Return type

Serviceusagemetrics

Authorization

API Token

HTTP request headers

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

Back to top | Back to API list | Back to README

GetUsageMetrics

Get monthly usage metrics

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    startMonth := "2023-01" // string |  (optional)
    endMonth := "2023-03" // string |  (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.BillingUsageMetricsAPI.GetUsageMetrics(ctx).StartMonth(startMonth).EndMonth(endMonth).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `BillingUsageMetricsAPI.GetUsageMetrics`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetUsageMetrics`: Usagemetric
    fmt.Fprintf(os.Stdout, "Response from `BillingUsageMetricsAPI.GetUsageMetrics`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiGetUsageMetricsRequest struct via the builder pattern

Name Type Description Notes
startMonth string endMonth

Return type

Usagemetric

Authorization

API Token

HTTP request headers

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

Back to top | Back to API list | Back to README