Skip to content

Commit be661a7

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit c2c362c of spec repo
1 parent e573b5f commit be661a7

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎.generator/schemas/v2/openapi.yaml‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267100,6 +267100,10 @@ paths:
267100267100
description: |-
267101267101
Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated.
267102267102
Otherwise, a quota is created only when `usage_limit` and `enforced` are provided.
267103+
Set `create_only=true` to atomically create exactly one quota in the caller's organization and reject an
267104+
existing quota with `409` instead of updating it. This mode does not support pending limits or descendant writes.
267105+
Repeated create-only requests do not replay the original response. If a response is lost, a retry can return `409`
267106+
even if the first request succeeded; reconcile the outcome before retrying or importing the quota.
267103267107
For the organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period and can
267104267108
accompany an immediate limit or update an existing quota by itself.
267105267109
Scheduled changes follow `include_descendants` like the other fields. Requires the `billing_edit` permission.
@@ -267147,6 +267151,13 @@ paths:
267147267151
schema:
267148267152
default: false
267149267153
type: boolean
267154+
- description: Create one quota without updating an existing quota. Requires exactly one item that specifies `usage_limit` and `enforced`, omits `pending_usage_limit`, and sets `include_descendants=false`. The quota belongs to the caller's organization. An existing quota returns `409` without being modified.
267155+
in: query
267156+
name: create_only
267157+
required: false
267158+
schema:
267159+
default: false
267160+
type: boolean
267150267161
requestBody:
267151267162
content:
267152267163
application/json:
@@ -267208,13 +267219,29 @@ paths:
267208267219
application/json:
267209267220
schema:
267210267221
$ref: "#/components/schemas/JSONAPIErrorResponse"
267211-
description: 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`.
267222+
description: Bad Request. Returned when `create_only=true` is combined with multiple items, `pending_usage_limit`, or `include_descendants=true`, or 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 nonexistent quota reports an error in the item's `error` field. If only the caller's organization is targeted, this failure returns `400`.
267212267223
"403":
267213267224
content:
267214267225
application/json:
267215267226
schema:
267216267227
$ref: "#/components/schemas/JSONAPIErrorResponse"
267217267228
description: Forbidden
267229+
"409":
267230+
content:
267231+
application/json:
267232+
examples:
267233+
already_exists:
267234+
value:
267235+
errors:
267236+
- detail: A quota already exists for this namespace and scope. Import it before managing it with Terraform.
267237+
meta:
267238+
error_code: already_exists
267239+
quota_id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOmphbmVAZXhhbXBsZS5jb20"
267240+
status: "409"
267241+
title: Conflict
267242+
schema:
267243+
$ref: "#/components/schemas/JSONAPIErrorResponse"
267244+
description: Conflict. With `create_only=true`, a quota already exists for this namespace and scope in the caller's organization. The existing quota is unchanged. The error's `meta` contains `error_code` set to `already_exists` and `quota_id` set to the existing quota's opaque ID. Import the existing quota before managing it with Terraform.
267218267245
"429":
267219267246
$ref: "#/components/responses/TooManyRequestsResponse"
267220267247
"500":

‎src/datadog_api_client/v2/api/usage_metering_api.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ def __init__(self, api_client=None):
8686
"attribute": "include_descendants",
8787
"location": "query",
8888
},
89+
"create_only": {
90+
"openapi_types": (bool,),
91+
"attribute": "create_only",
92+
"location": "query",
93+
},
8994
"body": {
9095
"required": True,
9196
"openapi_types": (UsageQuotasCreateRequest,),
@@ -929,11 +934,16 @@ def create_quotas(
929934
body: UsageQuotasCreateRequest,
930935
*,
931936
include_descendants: Union[bool, UnsetType] = unset,
937+
create_only: Union[bool, UnsetType] = unset,
932938
) -> UsageQuotasBulkResponse:
933939
"""Create or update usage quotas.
934940
935941
Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated.
936942
Otherwise, a quota is created only when ``usage_limit`` and ``enforced`` are provided.
943+
Set ``create_only=true`` to atomically create exactly one quota in the caller's organization and reject an
944+
existing quota with ``409`` instead of updating it. This mode does not support pending limits or descendant writes.
945+
Repeated create-only requests do not replay the original response. If a response is lost, a retry can return ``409``
946+
even if the first request succeeded; reconcile the outcome before retrying or importing the quota.
937947
For the organization-wide quota, ``pending_usage_limit`` schedules a limit for the next usage period and can
938948
accompany an immediate limit or update an existing quota by itself.
939949
Scheduled changes follow ``include_descendants`` like the other fields. Requires the ``billing_edit`` permission.
@@ -972,6 +982,8 @@ def create_quotas(
972982
:type body: UsageQuotasCreateRequest
973983
:param include_descendants: 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 data center 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.
974984
:type include_descendants: bool, optional
985+
:param create_only: Create one quota without updating an existing quota. Requires exactly one item that specifies ``usage_limit`` and ``enforced`` , omits ``pending_usage_limit`` , and sets ``include_descendants=false``. The quota belongs to the caller's organization. An existing quota returns ``409`` without being modified.
986+
:type create_only: bool, optional
975987
:rtype: UsageQuotasBulkResponse
976988
"""
977989
kwargs: Dict[str, Any] = {}
@@ -980,6 +992,9 @@ def create_quotas(
980992
if include_descendants is not unset:
981993
kwargs["include_descendants"] = include_descendants
982994

995+
if create_only is not unset:
996+
kwargs["create_only"] = create_only
997+
983998
kwargs["body"] = body
984999

9851000
return self._create_quotas_endpoint.call_with_http_info(**kwargs)

‎tests/v2/features/usage_metering.feature‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,22 @@ Feature: Usage Metering
106106
Then the response status is 404 Not Found
107107

108108
@generated @skip @team:ddoghq/billing-hub
109-
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
109+
Scenario: Create or update usage quotas returns "Bad Request. Returned when `create_only=true` is combined with multiple items, `pending_usage_limit`, or `include_descendants=true`, or 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 nonexistent quota reports an error in the item's `error` field. If only the caller's organization is targeted, this failure returns `400`." response
110110
Given operation "CreateQuotas" enabled
111111
And new "CreateQuotas" request
112112
And request contains "quota_namespace" parameter from "REPLACE.ME"
113113
And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]}
114114
When the request is sent
115-
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`.
115+
Then the response status is 400 Bad Request. Returned when `create_only=true` is combined with multiple items, `pending_usage_limit`, or `include_descendants=true`, or 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 nonexistent quota reports an error in the item's `error` field. If only the caller's organization is targeted, this failure returns `400`.
116+
117+
@generated @skip @team:ddoghq/billing-hub
118+
Scenario: Create or update usage quotas returns "Conflict. With `create_only=true`, a quota already exists for this namespace and scope in the caller's organization. The existing quota is unchanged. The error's `meta` contains `error_code` set to `already_exists` and `quota_id` set to the existing quota's opaque ID. Import the existing quota before managing it with Terraform." response
119+
Given operation "CreateQuotas" enabled
120+
And new "CreateQuotas" request
121+
And request contains "quota_namespace" parameter from "REPLACE.ME"
122+
And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]}
123+
When the request is sent
124+
Then the response status is 409 Conflict. With `create_only=true`, a quota already exists for this namespace and scope in the caller's organization. The existing quota is unchanged. The error's `meta` contains `error_code` set to `already_exists` and `quota_id` set to the existing quota's opaque ID. Import the existing quota before managing it with Terraform.
116125

117126
@generated @skip @team:ddoghq/billing-hub
118127
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

0 commit comments

Comments
 (0)