범위별로 하나 이상의 사용량 쿼터를 생성하거나 업데이트합니다. 제공된 범위에 대해 쿼터가 이미 존재하는 경우 업데이트되며, 그렇지 않으면 새 쿼터가 생성됩니다. user_access_manage, billing_edit 및 org_management 권한이 필요합니다.
This endpoint requires the billing_edit permission.
OAuth apps require the billing_edit authorization scope to access this endpoint.
인수
경로 파라미터
이름
유형
설명
quota_namespace [required]
string
The product-specific namespace whose usage quotas are being managed.
쿼리 문자열
이름
유형
설명
include_descendants
boolean
Whether to write every item in the request to the caller’s organization and all of its descendant organizations, instead of only the caller’s organization. Only descendants in the same datacenter are supported. For a user-handle scope, the quota is applied only to the caller’s organization and to descendant organizations where that user handle exists; the item fails only if the handle exists in none of them.
A bulk list of usage quota resources to create or update by scope.
attributes [required]
object
Attributes for creating or updating a usage quota by scope.
enforced [required]
boolean
Whether to actively block usage above the limit instead of only tracking or alerting on it.
scope
object
A namespace-specific key and value identifying what the quota applies to within an organization. The object must contain exactly one entry. Use "*" as the value for the default quota applied to entities without a specific quota, or omit the scope for an organization-wide quota. A specific value must identify an existing user handle in the caller's organization when include_descendants is false. When include_descendants is true, the handle must exist in the caller's organization or in at least one targeted descendant organization; the quota is then applied only to the organizations where that handle exists, and the request fails only if the handle exists in none of them.
<any-key>
string
usage_limit [required]
int64
The quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than the usage already recorded in the current period.
type [required]
enum
The JSON:API resource type for a usage quota.
Allowed enum values: quotas
Response containing the result of a bulk usage quota create-or-update request. Returned with a 200 status regardless of whether individual items succeeded or failed; check each item’s error attribute to determine its outcome.
Expand All
항목
유형
설명
data [required]
[object]
The results of writing each usage quota in a bulk create-or-update request, in the same order as the request.
attributes [required]
object
Attributes of a usage quota bulk write result. On success, all fields except error are present. On failure, only error is present and the other fields are omitted.
enforced
boolean
Whether usage above the limit is actively blocked instead of only tracked or alerted on. Omitted if this item failed to write.
error
string
An error message describing why this item failed to write. Omitted if this item was written successfully.
org_public_id
string
The public ID of the organization that owns the quota. Omitted if this item failed to write.
scope
object
A namespace-specific key and value identifying what the quota applies to within an organization. The object contains exactly one entry. A value of "*" identifies the default quota applied to entities without a specific quota. This field is omitted for an organization-wide quota.
<any-key>
string
usage_limit
double
The quota limit in the usage units defined by the quota namespace. May be fractional for quotas configured before public writes required whole units. Omitted if this item failed to write.
id [required]
string
An opaque usage quota identifier. Clients must pass this value back verbatim in update and delete requests and must not infer any structure from it.
type [required]
enum
The JSON:API resource type for a usage quota.
Allowed enum values: quotas
{"data":[{"attributes":{"enforced":true,"error":"usage_limit is out of range","org_public_id":"abcdef12345","scope":{"<any-key>":"jane@example.com"},"usage_limit":100000},"id":"MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f","type":"quotas"}]}
## Create or update quotas for the caller's organization.
#
# Path parameters exportquota_namespace="ai_credits" # Use a Personal Access Token or Service Access Token exportDD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
"""
Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
for any that failed to write." response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.usage_metering_apiimportUsageMeteringApifromdatadog_api_client.v2.model.usage_quota_create_attributesimportUsageQuotaCreateAttributesfromdatadog_api_client.v2.model.usage_quota_create_dataimportUsageQuotaCreateDatafromdatadog_api_client.v2.model.usage_quota_request_scopeimportUsageQuotaRequestScopefromdatadog_api_client.v2.model.usage_quota_typeimportUsageQuotaTypefromdatadog_api_client.v2.model.usage_quotas_create_requestimportUsageQuotasCreateRequestbody=UsageQuotasCreateRequest(data=[UsageQuotaCreateData(attributes=UsageQuotaCreateAttributes(enforced=True,scope=UsageQuotaRequestScope(user_handle="jane@example.com",),usage_limit=100000,),type=UsageQuotaType.QUOTAS,),],)configuration=Configuration()configuration.access_token=environ["DD_BEARER_TOKEN"]configuration.unstable_operations["create_quotas"]=TruewithApiClient(configuration)asapi_client:api_instance=UsageMeteringApi(api_client)response=api_instance.create_quotas(quota_namespace="ai_credits",body=body)print(response)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"python3"example.py"
# Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute# for any that failed to write." responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.access_token=ENV["DD_BEARER_TOKEN"]config.unstable_operations["v2.create_quotas".to_sym]=trueendapi_instance=DatadogAPIClient::V2::UsageMeteringAPI.newbody=DatadogAPIClient::V2::UsageQuotasCreateRequest.new({data:[DatadogAPIClient::V2::UsageQuotaCreateData.new({attributes:DatadogAPIClient::V2::UsageQuotaCreateAttributes.new({enforced:true,scope:{user_handle:"jane@example.com",},usage_limit:100000,}),type:DatadogAPIClient::V2::UsageQuotaType::QUOTAS,}),],})papi_instance.create_quotas("ai_credits",body)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"rb"example.rb"
// Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute// for any that failed to write." responsepackagemainimport("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")funcmain(){body:=datadogV2.UsageQuotasCreateRequest{Data:[]datadogV2.UsageQuotaCreateData{{Attributes:datadogV2.UsageQuotaCreateAttributes{Enforced:true,Scope:map[string]string{"user_handle":"jane@example.com",},UsageLimit:100000,},Type:datadogV2.USAGEQUOTATYPE_QUOTAS,},},}ctx:=datadog.NewDefaultContext(context.Background())ctx=context.WithValue(ctx,datadog.ContextAccessToken,os.Getenv("DD_BEARER_TOKEN"))configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.CreateQuotas",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewUsageMeteringApi(apiClient)resp,r,err:=api.CreateQuotas(ctx,"ai_credits",body,*datadogV2.NewCreateQuotasOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `UsageMeteringApi.CreateQuotas`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `UsageMeteringApi.CreateQuotas`:\n%s\n",responseContent)}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"go run"main.go"
// Create or update usage quotas returns "OK. The response includes each item's result; see each// item's `error` attribute// for any that failed to write." responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.UsageMeteringApi;importcom.datadog.api.client.v2.model.UsageQuotaCreateAttributes;importcom.datadog.api.client.v2.model.UsageQuotaCreateData;importcom.datadog.api.client.v2.model.UsageQuotaType;importcom.datadog.api.client.v2.model.UsageQuotasBulkResponse;importcom.datadog.api.client.v2.model.UsageQuotasCreateRequest;importjava.util.Collections;importjava.util.Map;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));defaultClient.setUnstableOperationEnabled("v2.createQuotas",true);UsageMeteringApiapiInstance=newUsageMeteringApi(defaultClient);UsageQuotasCreateRequestbody=newUsageQuotasCreateRequest().data(Collections.singletonList(newUsageQuotaCreateData().attributes(newUsageQuotaCreateAttributes().enforced(true).scope(Map.ofEntries(Map.entry("user_handle","jane@example.com"))).usageLimit(100000L)).type(UsageQuotaType.QUOTAS)));try{UsageQuotasBulkResponseresult=apiInstance.createQuotas("ai_credits",body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling UsageMeteringApi#createQuotas");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"java"Example.java"
// Create or update usage quotas returns "OK. The response includes each item's
// result; see each item's `error` attribute for any that failed to write."
// response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_usage_metering::CreateQuotasOptionalParams;usedatadog_api_client::datadogV2::api_usage_metering::UsageMeteringAPI;usedatadog_api_client::datadogV2::model::UsageQuotaCreateAttributes;usedatadog_api_client::datadogV2::model::UsageQuotaCreateData;usedatadog_api_client::datadogV2::model::UsageQuotaType;usedatadog_api_client::datadogV2::model::UsageQuotasCreateRequest;usestd::collections::BTreeMap;#[tokio::main]asyncfnmain(){letbody=UsageQuotasCreateRequest::new(vec![UsageQuotaCreateData::new(UsageQuotaCreateAttributes::new(true,100000).scope(BTreeMap::from([("user_handle".to_string(),"jane@example.com".to_string(),)])),UsageQuotaType::QUOTAS,)]);letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.CreateQuotas",true);letapi=UsageMeteringAPI::with_config(configuration);letresp=api.create_quotas("ai_credits".to_string(),body,CreateQuotasOptionalParams::default(),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute
* for any that failed to write." response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});configuration.unstableOperations["v2.createQuotas"]=true;constapiInstance=newv2.UsageMeteringApi(configuration);constparams: v2.UsageMeteringApiCreateQuotasRequest={body:{data:[{attributes:{enforced: true,scope:{user_handle:"jane@example.com",},usageLimit: 100000,},type:"quotas",},],},quotaNamespace:"ai_credits",};apiInstance.createQuotas(params).then((data: v2.UsageQuotasBulkResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"tsc"example.ts"
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.