Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 138 additions & 24 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions examples/v2/usage-metering/CreateQuotas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ const params: v2.UsageMeteringApiCreateQuotasRequest = {
{
attributes: {
enforced: true,
scope: {
user_handle: "jane@example.com",
},
usageLimit: 100000,
pendingUsageLimit: 100000,
usageLimit: 600000,
},
type: "quotas",
},
Expand Down
29 changes: 29 additions & 0 deletions examples/v2/usage-metering/DeletePendingQuota.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Cancel a scheduled usage quota limit returns "No Content" 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.deletePendingQuota"] = true;
const apiInstance = new v2.UsageMeteringApi(configuration);

const params: v2.UsageMeteringApiDeletePendingQuotaRequest = {
quotaNamespace: "ai_credits",
id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
};

apiInstance
.deletePendingQuota(params)
.then((data: any) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
2 changes: 1 addition & 1 deletion examples/v2/usage-metering/DeleteQuota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const apiInstance = new v2.UsageMeteringApi(configuration);

const params: v2.UsageMeteringApiDeleteQuotaRequest = {
quotaNamespace: "ai_credits",
id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f",
id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
};

apiInstance
Expand Down
5 changes: 3 additions & 2 deletions examples/v2/usage-metering/UpdateQuota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ const params: v2.UsageMeteringApiUpdateQuotaRequest = {
data: {
attributes: {
enforced: false,
pendingUsageLimit: 50000,
usageLimit: 120000,
},
id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f",
id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
type: "quotas",
},
},
quotaNamespace: "ai_credits",
id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f",
id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
};

apiInstance
Expand Down
11 changes: 11 additions & 0 deletions features/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9125,6 +9125,17 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
},
"operationResponseType": "UsageQuotaResponse",
},
"v2.DeletePendingQuota": {
"quotaNamespace": {
"type": "string",
"format": "",
},
"id": {
"type": "string",
"format": "",
},
"operationResponseType": "{}",
},
"v2.GetUsageSummaryAvailableFields": {
"operationResponseType": "UsageSummaryAvailableFieldsResponse",
},
Expand Down
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -11046,6 +11046,12 @@
"type": "idempotent"
}
},
"DeletePendingQuota": {
"tag": "Usage Metering",
"undo": {
"type": "idempotent"
}
},
"GetUsageSummaryAvailableFields": {
"tag": "Usage Metering",
"undo": {
Expand Down
45 changes: 36 additions & 9 deletions features/v2/usage_metering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,47 @@ Feature: Usage Metering
And an instance of "UsageMetering" API

@generated @skip @team:ddoghq/billing-hub
Scenario: Create or update usage quotas returns "Bad Request" response
Scenario: Cancel a scheduled usage quota limit returns "Bad Request. Returned if the `id` is malformed or does not belong to the requested quota namespace." response
Given operation "DeletePendingQuota" enabled
And new "DeletePendingQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request. Returned if the `id` is malformed or does not belong to the requested quota namespace.

@generated @skip @team:ddoghq/billing-hub
Scenario: Cancel a scheduled usage quota limit returns "No Content" response
Given operation "DeletePendingQuota" enabled
And new "DeletePendingQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 204 No Content

@generated @skip @team:ddoghq/billing-hub
Scenario: Cancel a scheduled usage quota limit returns "Not Found" response
Given operation "DeletePendingQuota" enabled
And new "DeletePendingQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 404 Not Found

@generated @skip @team:ddoghq/billing-hub
Scenario: Create or update usage quotas returns "Bad Request. Returned if the request is malformed, including when an item sets `pending_usage_limit` on a scoped quota, provides `enforced` without `usage_limit`, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item's `error`; when only the caller's organization is targeted, this failure returns `400`." response
Given operation "CreateQuotas" enabled
And new "CreateQuotas" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And body with value {"data": [{"attributes": {"enforced": true, "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quotas"}]}
And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]}
When the request is sent
Then the response status is 400 Bad Request
Then the response status is 400 Bad Request. Returned if the request is malformed, including when an item sets `pending_usage_limit` on a scoped quota, provides `enforced` without `usage_limit`, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item's `error`; when only the caller's organization is targeted, this failure returns `400`.

@generated @skip @team:ddoghq/billing-hub
Scenario: 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
Given operation "CreateQuotas" enabled
And new "CreateQuotas" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And body with value {"data": [{"attributes": {"enforced": true, "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quotas"}]}
And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]}
When the request is sent
Then the response status is 200 OK. The response includes each item's result; see each item's `error` attribute for any that failed to write.

Expand Down Expand Up @@ -304,22 +331,22 @@ Feature: Usage Metering
Then the response status is 200 OK

@generated @skip @team:ddoghq/billing-hub
Scenario: Update a usage quota returns "Bad Request. Returned if the request is malformed, or if the `id` in the request body does not match the `id` in the request path." response
Scenario: Update a usage quota returns "Bad Request. Returned if the request is malformed, if the `id` in the request body does not match the `id` in the request path, if none of `usage_limit`, `enforced`, or `pending_usage_limit` is provided, or if `pending_usage_limit` is set on a scoped quota." response
Given operation "UpdateQuota" enabled
And new "UpdateQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"enforced": false, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}}
And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}}
When the request is sent
Then the response status is 400 Bad Request. Returned if the request is malformed, or if the `id` in the request body does not match the `id` in the request path.
Then the response status is 400 Bad Request. Returned if the request is malformed, if the `id` in the request body does not match the `id` in the request path, if none of `usage_limit`, `enforced`, or `pending_usage_limit` is provided, or if `pending_usage_limit` is set on a scoped quota.

@generated @skip @team:ddoghq/billing-hub
Scenario: Update a usage quota returns "Not Found" response
Given operation "UpdateQuota" enabled
And new "UpdateQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"enforced": false, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}}
And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}}
When the request is sent
Then the response status is 404 Not Found

Expand All @@ -329,6 +356,6 @@ Feature: Usage Metering
And new "UpdateQuota" request
And request contains "quota_namespace" parameter from "REPLACE.ME"
And request contains "id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"enforced": false, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}}
And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}}
When the request is sent
Then the response status is 200 OK
1 change: 1 addition & 0 deletions packages/datadog-api-client-common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ export function createConfiguration(
"v2.searchCostRecommendations": false,
"v2.updateUnitCost": false,
"v2.createQuotas": false,
"v2.deletePendingQuota": false,
"v2.deleteQuota": false,
"v2.listQuotas": false,
"v2.updateQuota": false,
Expand Down
Loading
Loading