Skip to content

Commit 1b7a2d9

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit f2f1df9 of spec repo
1 parent c94cf3d commit 1b7a2d9

16 files changed

Lines changed: 344 additions & 57 deletions

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

Lines changed: 138 additions & 24 deletions
Large diffs are not rendered by default.

‎examples/v2/usage-metering/CreateQuotas.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
99
from datadog_api_client.v2.model.usage_quota_create_attributes import UsageQuotaCreateAttributes
1010
from datadog_api_client.v2.model.usage_quota_create_data import UsageQuotaCreateData
11-
from datadog_api_client.v2.model.usage_quota_request_scope import UsageQuotaRequestScope
1211
from datadog_api_client.v2.model.usage_quota_type import UsageQuotaType
1312
from datadog_api_client.v2.model.usage_quotas_create_request import UsageQuotasCreateRequest
1413

@@ -17,10 +16,8 @@
1716
UsageQuotaCreateData(
1817
attributes=UsageQuotaCreateAttributes(
1918
enforced=True,
20-
scope=UsageQuotaRequestScope(
21-
user_handle="jane@example.com",
22-
),
23-
usage_limit=100000,
19+
pending_usage_limit=100000,
20+
usage_limit=600000,
2421
),
2522
type=UsageQuotaType.QUOTAS,
2623
),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Cancel a scheduled usage quota limit returns "No Content" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
8+
9+
configuration = Configuration()
10+
configuration.access_token = environ["DD_BEARER_TOKEN"]
11+
configuration.unstable_operations["delete_pending_quota"] = True
12+
with ApiClient(configuration) as api_client:
13+
api_instance = UsageMeteringApi(api_client)
14+
api_instance.delete_pending_quota(
15+
quota_namespace="ai_credits",
16+
id="MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
17+
)

‎examples/v2/usage-metering/DeleteQuota.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
api_instance = UsageMeteringApi(api_client)
1414
api_instance.delete_quota(
1515
quota_namespace="ai_credits",
16-
id="MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f",
16+
id="MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
1717
)

‎examples/v2/usage-metering/UpdateQuota.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
data=UsageQuotaUpdateData(
1515
attributes=UsageQuotaUpdateAttributes(
1616
enforced=False,
17+
pending_usage_limit=50000,
1718
usage_limit=120000,
1819
),
19-
id="MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f",
20+
id="MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18",
2021
type=UsageQuotaType.QUOTAS,
2122
),
2223
)
@@ -27,7 +28,7 @@
2728
with ApiClient(configuration) as api_client:
2829
api_instance = UsageMeteringApi(api_client)
2930
response = api_instance.update_quota(
30-
quota_namespace="ai_credits", id="MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", body=body
31+
quota_namespace="ai_credits", id="MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", body=body
3132
)
3233

3334
print(response)

‎src/datadog_api_client/configuration.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def __init__(
487487
"v2.search_cost_recommendations": False,
488488
"v2.update_unit_cost": False,
489489
"v2.create_quotas": False,
490+
"v2.delete_pending_quota": False,
490491
"v2.delete_quota": False,
491492
"v2.list_quotas": False,
492493
"v2.update_quota": False,

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

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@ def __init__(self, api_client=None):
8989
api_client=api_client,
9090
)
9191

92+
self._delete_pending_quota_endpoint = _Endpoint(
93+
settings={
94+
"response_type": None,
95+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
96+
"endpoint_path": "/api/v2/usage/quotas/{quota_namespace}/{id}/pending",
97+
"operation_id": "delete_pending_quota",
98+
"http_method": "DELETE",
99+
"version": "v2",
100+
},
101+
params_map={
102+
"quota_namespace": {
103+
"required": True,
104+
"openapi_types": (str,),
105+
"attribute": "quota_namespace",
106+
"location": "path",
107+
},
108+
"id": {
109+
"required": True,
110+
"openapi_types": (str,),
111+
"attribute": "id",
112+
"location": "path",
113+
},
114+
},
115+
headers_map={
116+
"accept": ["*/*"],
117+
},
118+
api_client=api_client,
119+
)
120+
92121
self._delete_quota_endpoint = _Endpoint(
93122
settings={
94123
"response_type": None,
@@ -632,7 +661,11 @@ def create_quotas(
632661
) -> UsageQuotasBulkResponse:
633662
"""Create or update usage quotas.
634663
635-
Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated; otherwise, a new quota is created. Requires the ``billing_edit`` permission.
664+
Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated.
665+
Otherwise, a quota is created only when ``usage_limit`` and ``enforced`` are provided.
666+
For the organization-wide quota, ``pending_usage_limit`` schedules a limit for the next usage period and can
667+
accompany an immediate limit or update an existing quota by itself.
668+
Scheduled changes follow ``include_descendants`` like the other fields. Requires the ``billing_edit`` permission.
636669
637670
:param quota_namespace: The product-specific namespace whose usage quotas are being managed.
638671
:type quota_namespace: str
@@ -652,6 +685,28 @@ def create_quotas(
652685

653686
return self._create_quotas_endpoint.call_with_http_info(**kwargs)
654687

688+
def delete_pending_quota(
689+
self,
690+
quota_namespace: str,
691+
id: str,
692+
) -> None:
693+
"""Cancel a scheduled usage quota limit.
694+
695+
Cancels the limit change scheduled to take effect at the start of the next usage period, leaving the usage quota and its current limit unchanged. Returns ``404`` when the quota does not exist, has no scheduled change, or its scheduled change has already taken effect; in every case the quota is left unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the ``billing_edit`` permission.
696+
697+
:param quota_namespace: The product-specific namespace whose usage quotas are being managed.
698+
:type quota_namespace: str
699+
:param id: The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim.
700+
:type id: str
701+
:rtype: None
702+
"""
703+
kwargs: Dict[str, Any] = {}
704+
kwargs["quota_namespace"] = quota_namespace
705+
706+
kwargs["id"] = id
707+
708+
return self._delete_pending_quota_endpoint.call_with_http_info(**kwargs)
709+
655710
def delete_quota(
656711
self,
657712
quota_namespace: str,
@@ -1266,7 +1321,7 @@ def update_quota(
12661321
) -> UsageQuotaResponse:
12671322
"""Update a usage quota.
12681323
1269-
Updates the supplied fields on a usage quota and leaves omitted fields unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the ``billing_edit`` permission.
1324+
Updates the supplied fields on a usage quota and leaves omitted fields unchanged. For an organization-wide quota, ``pending_usage_limit`` schedules a limit for the next usage period. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the ``billing_edit`` permission.
12701325
12711326
:param quota_namespace: The product-specific namespace whose usage quotas are being managed.
12721327
:type quota_namespace: str

‎src/datadog_api_client/v2/model/usage_quota_bulk_result_attributes.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919

2020
class UsageQuotaBulkResultAttributes(ModelNormal):
21+
validations = {
22+
"pending_effective_from": {},
23+
}
24+
2125
@cached_property
2226
def openapi_types(_):
2327
from datadog_api_client.v2.model.usage_quota_response_scope import UsageQuotaResponseScope
@@ -26,6 +30,8 @@ def openapi_types(_):
2630
"enforced": (bool,),
2731
"error": (str,),
2832
"org_public_id": (str,),
33+
"pending_effective_from": (str,),
34+
"pending_usage_limit": (float,),
2935
"scope": (UsageQuotaResponseScope,),
3036
"usage_limit": (float,),
3137
}
@@ -34,6 +40,8 @@ def openapi_types(_):
3440
"enforced": "enforced",
3541
"error": "error",
3642
"org_public_id": "org_public_id",
43+
"pending_effective_from": "pending_effective_from",
44+
"pending_usage_limit": "pending_usage_limit",
3745
"scope": "scope",
3846
"usage_limit": "usage_limit",
3947
}
@@ -43,12 +51,14 @@ def __init__(
4351
enforced: Union[bool, UnsetType] = unset,
4452
error: Union[str, UnsetType] = unset,
4553
org_public_id: Union[str, UnsetType] = unset,
54+
pending_effective_from: Union[str, UnsetType] = unset,
55+
pending_usage_limit: Union[float, UnsetType] = unset,
4656
scope: Union[UsageQuotaResponseScope, UnsetType] = unset,
4757
usage_limit: Union[float, UnsetType] = unset,
4858
**kwargs,
4959
):
5060
"""
51-
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.
61+
Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only ``error`` is present and the other fields are omitted.
5262
5363
:param enforced: Whether usage above the limit is actively blocked instead of only tracked or alerted on. Omitted if this item failed to write.
5464
:type enforced: bool, optional
@@ -59,6 +69,12 @@ def __init__(
5969
:param org_public_id: The public ID of the organization that owns the quota. Omitted if this item failed to write.
6070
:type org_public_id: str, optional
6171
72+
:param pending_effective_from: The future UTC month when the scheduled limit takes effect, formatted as ``YYYY-MM`` , starting at 00:00 UTC on its first day. Present only together with ``pending_usage_limit`` and omitted when no change is scheduled or this item failed to write.
73+
:type pending_effective_from: str, optional
74+
75+
:param pending_usage_limit: The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. A value of ``0`` is valid. At the start of the effective month, this value becomes ``usage_limit`` and both pending fields are omitted. Omitted when no change is scheduled or this item failed to write.
76+
:type pending_usage_limit: float, optional
77+
6278
:param scope: 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.
6379
:type scope: UsageQuotaResponseScope, optional
6480
@@ -71,6 +87,10 @@ def __init__(
7187
kwargs["error"] = error
7288
if org_public_id is not unset:
7389
kwargs["org_public_id"] = org_public_id
90+
if pending_effective_from is not unset:
91+
kwargs["pending_effective_from"] = pending_effective_from
92+
if pending_usage_limit is not unset:
93+
kwargs["pending_usage_limit"] = pending_usage_limit
7494
if scope is not unset:
7595
kwargs["scope"] = scope
7696
if usage_limit is not unset:

‎src/datadog_api_client/v2/model/usage_quota_bulk_result_data.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self_, attributes: UsageQuotaBulkResultAttributes, id: str, type: U
3838
"""
3939
The result of writing one usage quota in a bulk create-or-update request.
4040
41-
:param attributes: 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.
41+
:param attributes: Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only ``error`` is present and the other fields are omitted.
4242
:type attributes: UsageQuotaBulkResultAttributes
4343
4444
:param id: 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.

‎src/datadog_api_client/v2/model/usage_quota_create_attributes.py‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
class UsageQuotaCreateAttributes(ModelNormal):
2121
validations = {
22+
"pending_usage_limit": {
23+
"inclusive_minimum": 0,
24+
},
2225
"usage_limit": {
2326
"inclusive_minimum": 0,
2427
},
@@ -30,34 +33,47 @@ def openapi_types(_):
3033

3134
return {
3235
"enforced": (bool,),
36+
"pending_usage_limit": (int,),
3337
"scope": (UsageQuotaRequestScope,),
3438
"usage_limit": (int,),
3539
}
3640

3741
attribute_map = {
3842
"enforced": "enforced",
43+
"pending_usage_limit": "pending_usage_limit",
3944
"scope": "scope",
4045
"usage_limit": "usage_limit",
4146
}
4247

4348
def __init__(
44-
self_, enforced: bool, usage_limit: int, scope: Union[UsageQuotaRequestScope, UnsetType] = unset, **kwargs
49+
self_,
50+
enforced: Union[bool, UnsetType] = unset,
51+
pending_usage_limit: Union[int, UnsetType] = unset,
52+
scope: Union[UsageQuotaRequestScope, UnsetType] = unset,
53+
usage_limit: Union[int, UnsetType] = unset,
54+
**kwargs,
4555
):
4656
"""
47-
Attributes for creating or updating a usage quota by scope.
57+
Attributes for creating or updating a usage quota by scope. Each item must provide ``usage_limit`` , ``pending_usage_limit`` , or both. Providing only ``pending_usage_limit`` updates an existing organization-wide quota, never creates one, requires ``enforced`` to be omitted, and fails if the quota does not exist.
4858
49-
:param enforced: Whether to actively block usage above the limit instead of only tracking or alerting on it.
50-
:type enforced: bool
59+
:param enforced: Whether to actively block usage above ``usage_limit`` instead of only tracking or alerting on it. Required when ``usage_limit`` is provided and must be omitted when only ``pending_usage_limit`` is provided.
60+
:type enforced: bool, optional
61+
62+
:param pending_usage_limit: The non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes ``pending_effective_from``. Omit this field to leave any scheduled change unchanged, including when raising ``usage_limit``. Cancel a scheduled change only by deleting the quota's ``/pending`` sub-resource.
63+
:type pending_usage_limit: int, optional
5164
5265
:param scope: 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.
5366
:type scope: UsageQuotaRequestScope, optional
5467
55-
:param usage_limit: 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.
56-
:type usage_limit: int
68+
:param usage_limit: The non-negative, whole-number 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 usage already recorded in the current period. When this field is provided, ``enforced`` is required.
69+
:type usage_limit: int, optional
5770
"""
71+
if enforced is not unset:
72+
kwargs["enforced"] = enforced
73+
if pending_usage_limit is not unset:
74+
kwargs["pending_usage_limit"] = pending_usage_limit
5875
if scope is not unset:
5976
kwargs["scope"] = scope
77+
if usage_limit is not unset:
78+
kwargs["usage_limit"] = usage_limit
6079
super().__init__(kwargs)
61-
62-
self_.enforced = enforced
63-
self_.usage_limit = usage_limit

0 commit comments

Comments
 (0)