Skip to content
Open
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.

5 changes: 2 additions & 3 deletions examples/v2/usage-metering/CreateQuotas.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.datadog.api.client.v2.model.UsageQuotasBulkResponse;
import com.datadog.api.client.v2.model.UsageQuotasCreateRequest;
import java.util.Collections;
import java.util.Map;

public class Example {
public static void main(String[] args) {
Expand All @@ -28,8 +27,8 @@ public static void main(String[] args) {
.attributes(
new UsageQuotaCreateAttributes()
.enforced(true)
.scope(Map.ofEntries(Map.entry("user_handle", "jane@example.com")))
.usageLimit(100000L))
.pendingUsageLimit(100000L)
.usageLimit(600000L))
.type(UsageQuotaType.QUOTAS)));

try {
Expand Down
25 changes: 25 additions & 0 deletions examples/v2/usage-metering/DeletePendingQuota.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Cancel a scheduled usage quota limit returns "No Content" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.UsageMeteringApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.deletePendingQuota", true);
UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

try {
apiInstance.deletePendingQuota(
"ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18");
} catch (ApiException e) {
System.err.println("Exception when calling UsageMeteringApi#deletePendingQuota");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion examples/v2/usage-metering/DeleteQuota.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] args) {
UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);

try {
apiInstance.deleteQuota("ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f");
apiInstance.deleteQuota("ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18");
} catch (ApiException e) {
System.err.println("Exception when calling UsageMeteringApi#deleteQuota");
System.err.println("Status code: " + e.getCode());
Expand Down
9 changes: 6 additions & 3 deletions examples/v2/usage-metering/UpdateQuota.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ public static void main(String[] args) {
.data(
new UsageQuotaUpdateData()
.attributes(
new UsageQuotaUpdateAttributes().enforced(false).usageLimit(120000L))
.id("MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f")
new UsageQuotaUpdateAttributes()
.enforced(false)
.pendingUsageLimit(50000L)
.usageLimit(120000L))
.id("MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18")
.type(UsageQuotaType.QUOTAS));

try {
UsageQuotaResponse result =
apiInstance.updateQuota(
"ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", body);
"ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsageMeteringApi#updateQuota");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/datadog/api/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ public class ApiClient {
put("v2.searchCostRecommendations", false);
put("v2.updateUnitCost", false);
put("v2.createQuotas", false);
put("v2.deletePendingQuota", false);
put("v2.deleteQuota", false);
put("v2.listQuotas", false);
put("v2.updateQuota", false);
Expand Down
211 changes: 203 additions & 8 deletions src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ public CompletableFuture<UsageQuotasBulkResponse> createQuotasAsync(

/**
* 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 <code>billing_edit</code>
* permission.
* scope, it is updated. Otherwise, a quota is created only when <code>usage_limit</code> and
* <code>enforced</code> are provided. For the organization-wide quota, <code>pending_usage_limit
* </code> schedules a limit for the next usage period and can accompany an immediate limit or
* update an existing quota by itself. Scheduled changes follow <code>include_descendants</code>
* like the other fields. Requires the <code>billing_edit</code> permission.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
Expand All @@ -180,7 +183,7 @@ public CompletableFuture<UsageQuotasBulkResponse> createQuotasAsync(
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK. The response includes each item&#39;s result; see each item&#39;s &#x60;error&#x60; attribute for any that failed to write. </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request. Returned if the request is malformed, including when an item sets &#x60;pending_usage_limit&#x60; on a scoped quota, provides &#x60;enforced&#x60; without &#x60;usage_limit&#x60;, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item&#39;s &#x60;error&#x60;; when only the caller&#39;s organization is targeted, this failure returns &#x60;400&#x60;. </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* <tr><td> 500 </td><td> Internal Server Error. Every item in the batch failed to write. </td><td> - </td></tr>
Expand Down Expand Up @@ -329,6 +332,197 @@ public CompletableFuture<ApiResponse<UsageQuotasBulkResponse>> createQuotasWithH
new GenericType<UsageQuotasBulkResponse>() {});
}

/**
* Cancel a scheduled usage quota limit.
*
* <p>See {@link #deletePendingQuotaWithHttpInfo}.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
* @param id The opaque quota identifier returned by a previous list or create request. Clients
* must pass this value verbatim. (required)
* @throws ApiException if fails to make API call
*/
public void deletePendingQuota(String quotaNamespace, String id) throws ApiException {
deletePendingQuotaWithHttpInfo(quotaNamespace, id);
}

/**
* Cancel a scheduled usage quota limit.
*
* <p>See {@link #deletePendingQuotaWithHttpInfoAsync}.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
* @param id The opaque quota identifier returned by a previous list or create request. Clients
* must pass this value verbatim. (required)
* @return CompletableFuture
*/
public CompletableFuture<Void> deletePendingQuotaAsync(String quotaNamespace, String id) {
return deletePendingQuotaWithHttpInfoAsync(quotaNamespace, id)
.thenApply(
response -> {
return response.getData();
});
}

/**
* 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 <code>404</code> 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 <code>billing_edit</code> permission.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
* @param id The opaque quota identifier returned by a previous list or create request. Clients
* must pass this value verbatim. (required)
* @return ApiResponse&lt;Void&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 204 </td><td> No Content </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request. Returned if the &#x60;id&#x60; is malformed or does not belong to the requested quota namespace. </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<Void> deletePendingQuotaWithHttpInfo(String quotaNamespace, String id)
throws ApiException {
// Check if unstable operation is enabled
String operationId = "deletePendingQuota";
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
} else {
throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
}
Object localVarPostBody = null;

// verify the required parameter 'quotaNamespace' is set
if (quotaNamespace == null) {
throw new ApiException(
400, "Missing the required parameter 'quotaNamespace' when calling deletePendingQuota");
}

// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException(
400, "Missing the required parameter 'id' when calling deletePendingQuota");
}
// create path and map variables
String localVarPath =
"/api/v2/usage/quotas/{quota_namespace}/{id}/pending"
.replaceAll(
"\\{" + "quota_namespace" + "\\}",
apiClient.escapeString(quotaNamespace.toString()))
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.UsageMeteringApi.deletePendingQuota",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"*/*"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
return apiClient.invokeAPI(
"DELETE",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
null);
}

/**
* Cancel a scheduled usage quota limit.
*
* <p>See {@link #deletePendingQuotaWithHttpInfo}.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
* @param id The opaque quota identifier returned by a previous list or create request. Clients
* must pass this value verbatim. (required)
* @return CompletableFuture&lt;ApiResponse&lt;Void&gt;&gt;
*/
public CompletableFuture<ApiResponse<Void>> deletePendingQuotaWithHttpInfoAsync(
String quotaNamespace, String id) {
// Check if unstable operation is enabled
String operationId = "deletePendingQuota";
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
} else {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
return result;
}
Object localVarPostBody = null;

// verify the required parameter 'quotaNamespace' is set
if (quotaNamespace == null) {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(
400,
"Missing the required parameter 'quotaNamespace' when calling deletePendingQuota"));
return result;
}

// verify the required parameter 'id' is set
if (id == null) {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(
400, "Missing the required parameter 'id' when calling deletePendingQuota"));
return result;
}
// create path and map variables
String localVarPath =
"/api/v2/usage/quotas/{quota_namespace}/{id}/pending"
.replaceAll(
"\\{" + "quota_namespace" + "\\}",
apiClient.escapeString(quotaNamespace.toString()))
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.UsageMeteringApi.deletePendingQuota",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"*/*"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"DELETE",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
null);
}

/**
* Delete a usage quota.
*
Expand Down Expand Up @@ -3980,10 +4174,11 @@ public CompletableFuture<UsageQuotaResponse> updateQuotaAsync(
}

/**
* 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 <code>billing_edit</code>
* permission.
* Updates the supplied fields on a usage quota and leaves omitted fields unchanged. For an
* organization-wide quota, <code>pending_usage_limit</code> 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 <code>billing_edit
* </code> permission.
*
* @param quotaNamespace The product-specific namespace whose usage quotas are being managed.
* (required)
Expand All @@ -3998,7 +4193,7 @@ public CompletableFuture<UsageQuotaResponse> updateQuotaAsync(
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request. Returned if the request is malformed, or if the &#x60;id&#x60; in the request body does not match the &#x60;id&#x60; in the request path. </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request. Returned if the request is malformed, if the &#x60;id&#x60; in the request body does not match the &#x60;id&#x60; in the request path, if none of &#x60;usage_limit&#x60;, &#x60;enforced&#x60;, or &#x60;pending_usage_limit&#x60; is provided, or if &#x60;pending_usage_limit&#x60; is set on a scoped quota. </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
Expand Down
Loading
Loading