Get commitments list
https://api.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.us3.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.us5.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.datadoghq.eu/api/v2/cost/commitments/commitment-listhttps://api.ap1.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.ap2.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.uk1.datadoghq.com/api/v2/cost/commitments/commitment-listhttps://api.ddog-gov.com/api/v2/cost/commitments/commitment-listhttps://api.us2.ddog-gov.com/api/v2/cost/commitments/commitment-listOverview
Get a list of individual cloud commitments (Reserved Instances or Savings Plans) with their utilization details. The response schema varies based on the provider, product, and commitment type.
OAuth apps require the cloud_cost_management_read authorization scope to access this endpoint.
Arguments
Query Strings
provider [required]Cloud provider for commitment programs (aws or azure).
aws, azureproduct [required]Cloud product identifier (for example, ec2, rds, virtualmachines).
start [required]Start of the query time range in Unix milliseconds.
end [required]End of the query time range in Unix milliseconds.
filterByOptional filter expression to narrow down results.
commitmentTypeType of commitment to query. ri for Reserved Instances, sp for Savings Plans. Defaults to ri.
ri, spResponse
OK
Response containing a list of cloud commitment details.
commitments [required]Array of commitment items.
Object 1AWS EC2 Reserved Instance commitment details.
availability_zoneThe availability zone of the reservation.
commitment_id [required]The unique identifier of the Reserved Instance.
expiration_dateThe expiration date of the commitment.
instance_type [required]The EC2 instance type.
number_of_nfusThe number of Normalized Capacity Units.
number_of_reservationsThe number of reserved instances.
offering_class [required]The offering class of the Reserved Instance.
operating_system [required]The operating system of the Reserved Instance.
purchase_option [required]The payment option for the Reserved Instance.
region [required]The AWS region of the Reserved Instance.
start_dateThe start date of the commitment.
term_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
Object 2AWS RDS Reserved Instance commitment details.
commitment_id [required]The unique identifier of the Reserved Instance.
database_engine [required]The database engine of the Reserved Instance.
expiration_dateThe expiration date of the commitment.
instance_type [required]The RDS instance type.
is_multi_azWhether the Reserved Instance is Multi-AZ.
number_of_nfusThe number of Normalized Capacity Units.
number_of_reservationsThe number of reserved instances.
purchase_option [required]The payment option for the Reserved Instance.
region [required]The AWS region of the Reserved Instance.
start_dateThe start date of the commitment.
term_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
Object 3AWS ElastiCache Reserved Instance commitment details.
cache_engine [required]The cache engine type of the Reserved Instance.
commitment_id [required]The unique identifier of the Reserved Instance.
expiration_dateThe expiration date of the commitment.
instance_type [required]The ElastiCache instance type.
number_of_nfusThe number of Normalized Capacity Units.
number_of_reservationsThe number of reserved instances.
purchase_option [required]The payment option for the Reserved Instance.
region [required]The AWS region of the Reserved Instance.
start_dateThe start date of the commitment.
term_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
Object 4AWS Savings Plan commitment details.
commitment_id [required]The unique identifier of the Savings Plan.
committed_spend_per_hourThe hourly committed spend for the Savings Plan.
expiration_dateThe expiration date of the commitment.
purchase_option [required]The payment option for the Savings Plan.
savings_plan_type [required]The Savings Plan type.
start_dateThe start date of the commitment.
term_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
Object 5Azure Virtual Machine Reserved Instance commitment details.
benefit_name [required]The display name of the Azure reservation.
commitment_id [required]The unique identifier of the Reserved Instance.
expiration_dateThe expiration date of the commitment.
instance_type [required]The Azure VM instance type.
meter_sub_category [required]The Azure meter sub-category for the reservation.
region [required]The Azure region of the Reserved Instance.
start_dateThe start date of the commitment.
status [required]Status of an Azure VM Reserved Instance.
running, expired, cancelledterm_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
Object 6Azure Compute Savings Plan commitment details.
benefit_name [required]The display name of the Azure Savings Plan.
commitment_id [required]The unique identifier of the Savings Plan.
committed_spend_per_hourThe hourly committed spend for the Savings Plan.
expiration_dateThe expiration date of the commitment.
start_dateThe start date of the commitment.
term_lengthThe term length in years.
utilizationThe utilization percentage of the commitment.
metaMetadata for a commitments list response.
committed_spend_unitUnit metadata for a numeric metric.
family [required]The unit family (for example, percentage or money).
id [required]The unit identifier.
name [required]The unit name (for example, percent or dollar).
plural [required]The plural form of the unit name.
scale_factor [required]The scale factor for the unit.
short_name [required]The abbreviated unit name (for example, % or $).
{
"commitments": [
{
"availability_zone": "us-east-1a",
"commitment_id": "ri-0123456789abcdef0",
"expiration_date": "2025-12-31T00:00:00Z",
"instance_type": "m5.xlarge",
"number_of_nfus": 8,
"number_of_reservations": 2,
"offering_class": "standard",
"operating_system": "Linux",
"purchase_option": "All Upfront",
"region": "us-east-1",
"start_date": "2023-01-01T00:00:00Z",
"term_length": 1,
"utilization": 0.85
}
],
"meta": {
"committed_spend_unit": {
"family": "percentage",
"id": 17,
"name": "percent",
"plural": "percent",
"scale_factor": 1,
"short_name": "%"
}
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Required query arguments
export provider="aws"
export product="ec2"
export start="1693526400000"
export end="1696118400000"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/cost/commitments/commitment-list?provider=${provider}&product=${product}&start=${start}&end=${end}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"// Get commitments list returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.GetCommitmentsCommitmentList", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCloudCostManagementApi(apiClient)
resp, r, err := api.GetCommitmentsCommitmentList(ctx, datadogV2.COMMITMENTSPROVIDER_AWS, "product", 9223372036854775807, 9223372036854775807, *datadogV2.NewGetCommitmentsCommitmentListOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.GetCommitmentsCommitmentList`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CloudCostManagementApi.GetCommitmentsCommitmentList`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Get commitments list returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CloudCostManagementApi;
import com.datadog.api.client.v2.model.CommitmentsListResponse;
import com.datadog.api.client.v2.model.CommitmentsProvider;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.getCommitmentsCommitmentList", true);
CloudCostManagementApi apiInstance = new CloudCostManagementApi(defaultClient);
try {
CommitmentsListResponse result =
apiInstance.getCommitmentsCommitmentList(
CommitmentsProvider.AWS, "ec2", 1693526400000L, 1696118400000L);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling CloudCostManagementApi#getCommitmentsCommitmentList");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Get commitments list returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
from datadog_api_client.v2.model.commitments_provider import CommitmentsProvider
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["get_commitments_commitment_list"] = True
with ApiClient(configuration) as api_client:
api_instance = CloudCostManagementApi(api_client)
response = api_instance.get_commitments_commitment_list(
provider=CommitmentsProvider.AWS,
product="product",
start=9223372036854775807,
end=9223372036854775807,
)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Get commitments list returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.get_commitments_commitment_list".to_sym] = true
end
api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new
p api_instance.get_commitments_commitment_list(CommitmentsProvider::AWS, "product", 9223372036854775807, 9223372036854775807)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Get commitments list returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
use datadog_api_client::datadogV2::api_cloud_cost_management::GetCommitmentsCommitmentListOptionalParams;
use datadog_api_client::datadogV2::model::CommitmentsProvider;
#[tokio::main]
async fn main() {
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.get_commitments_commitment_list", true);
let api = CloudCostManagementAPI::with_config(configuration);
let resp = api
.get_commitments_commitment_list(
CommitmentsProvider::AWS,
"product".to_string(),
9223372036854775807,
9223372036854775807,
GetCommitmentsCommitmentListOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Get commitments list returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.getCommitmentsCommitmentList"] = true;
const apiInstance = new v2.CloudCostManagementApi(configuration);
const params: v2.CloudCostManagementApiGetCommitmentsCommitmentListRequest = {
provider: "aws",
product: "product",
start: 9223372036854775807,
end: 9223372036854775807,
};
apiInstance
.getCommitmentsCommitmentList(params)
.then((data: v2.CommitmentsListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"