diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 528e531d42a..5a96a021585 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -44866,6 +44866,66 @@ components: type: $ref: "#/components/schemas/HistoricalJobDataType" type: object + HistoricalMetricsConfigurationAttributes: + description: Attributes of a historical metrics configuration. + properties: + created_at: + description: Timestamp when historical metrics ingestion was enabled for the metric. + example: "2024-01-15T12:00:00.000Z" + format: date-time + readOnly: true + type: string + type: object + HistoricalMetricsConfigurationCreateData: + description: Data object for enabling historical metrics ingestion for a metric. + properties: + id: + description: The metric name, used as the resource ID. + example: dd.test.metric + type: string + type: + $ref: "#/components/schemas/HistoricalMetricsConfigurationType" + required: + - id + - type + type: object + HistoricalMetricsConfigurationCreateRequest: + description: Request body for enabling historical metrics ingestion for a metric. + properties: + data: + $ref: "#/components/schemas/HistoricalMetricsConfigurationCreateData" + required: + - data + type: object + HistoricalMetricsConfigurationData: + description: >- + A historical metrics configuration resource object. Existence of this resource means historical metrics ingestion is enabled for the metric; there is no separate enabled attribute. + properties: + attributes: + $ref: "#/components/schemas/HistoricalMetricsConfigurationAttributes" + id: + description: The metric name, used as the resource ID. + example: dd.test.metric + type: string + type: + $ref: "#/components/schemas/HistoricalMetricsConfigurationType" + type: object + HistoricalMetricsConfigurationResponse: + description: Response containing a historical metrics configuration. + properties: + data: + $ref: "#/components/schemas/HistoricalMetricsConfigurationData" + readOnly: true + type: object + HistoricalMetricsConfigurationType: + default: historical_metrics_configurations + description: The historical metrics configuration resource type. + enum: + - historical_metrics_configurations + example: historical_metrics_configurations + type: string + x-enum-varnames: + - HISTORICAL_METRICS_CONFIGURATIONS HourlyUsage: description: Hourly usage for a product family for an org. properties: @@ -159552,6 +159612,178 @@ paths: permissions: - metric_tags_write x-sunset: "2027-01-01" + /api/v2/metrics/historical-metrics-configurations: + post: + description: |- + Enable historical metrics ingestion (late data ingestion) for a metric. Idempotent: + enabling an already-enabled metric returns 200 instead of 201. Not supported for + distribution metrics, metrics with an existing tag configuration, or most standard + (non-custom) metrics. + operationId: CreateHistoricalMetricsConfiguration + requestBody: + content: + application/json: + examples: + default: + value: + data: + id: dd.test.metric + type: historical_metrics_configurations + schema: + $ref: "#/components/schemas/HistoricalMetricsConfigurationCreateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-15T12:00:00.000Z" + id: dd.test.metric + type: historical_metrics_configurations + schema: + $ref: "#/components/schemas/HistoricalMetricsConfigurationResponse" + description: OK + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-15T12:00:00.000Z" + id: dd.test.metric + type: historical_metrics_configurations + schema: + $ref: "#/components/schemas/HistoricalMetricsConfigurationResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "422": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unprocessable Entity + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - late_metrics_config_write + summary: Enable historical metrics ingestion + tags: + - Metrics + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - late_metrics_config_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/metrics/historical-metrics-configurations/{metric_name}: + delete: + description: |- + Disable historical metrics ingestion for a metric. Idempotent: always returns 204, + whether or not the configuration existed or the metric itself still exists, so that + Terraform destroy succeeds for a metric removed out-of-band. + operationId: DeleteHistoricalMetricsConfiguration + parameters: + - $ref: "#/components/parameters/MetricName" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - late_metrics_config_write + summary: Delete a historical metrics configuration + tags: + - Metrics + "x-permission": + operator: OR + permissions: + - late_metrics_config_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: |- + Get the historical metrics ingestion configuration for a metric. Existence of the + resource means historical metrics ingestion is enabled; returns 404 when it is not + enabled for the metric. + operationId: GetHistoricalMetricsConfiguration + parameters: + - $ref: "#/components/parameters/MetricName" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-15T12:00:00.000Z" + id: dd.test.metric + type: historical_metrics_configurations + schema: + $ref: "#/components/schemas/HistoricalMetricsConfigurationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - metrics_read + summary: Get a historical metrics configuration + tags: + - Metrics + "x-permission": + operator: OR + permissions: + - metrics_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/metrics/tag-indexing-rules: get: description: List tag indexing rules for an org, sorted by `rule_order`, with offset/limit pagination. diff --git a/examples/v2/metrics/CreateHistoricalMetricsConfiguration.java b/examples/v2/metrics/CreateHistoricalMetricsConfiguration.java new file mode 100644 index 00000000000..9a95bee2a1a --- /dev/null +++ b/examples/v2/metrics/CreateHistoricalMetricsConfiguration.java @@ -0,0 +1,36 @@ +// Enable historical metrics ingestion returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.MetricsApi; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationCreateData; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationCreateRequest; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationResponse; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationType; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createHistoricalMetricsConfiguration", true); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + HistoricalMetricsConfigurationCreateRequest body = + new HistoricalMetricsConfigurationCreateRequest() + .data( + new HistoricalMetricsConfigurationCreateData() + .id("dd.test.metric") + .type(HistoricalMetricsConfigurationType.HISTORICAL_METRICS_CONFIGURATIONS)); + + try { + HistoricalMetricsConfigurationResponse result = + apiInstance.createHistoricalMetricsConfiguration(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#createHistoricalMetricsConfiguration"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/metrics/DeleteHistoricalMetricsConfiguration.java b/examples/v2/metrics/DeleteHistoricalMetricsConfiguration.java new file mode 100644 index 00000000000..e2a95c25a19 --- /dev/null +++ b/examples/v2/metrics/DeleteHistoricalMetricsConfiguration.java @@ -0,0 +1,23 @@ +// Delete a historical metrics configuration returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.MetricsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.deleteHistoricalMetricsConfiguration", true); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + try { + apiInstance.deleteHistoricalMetricsConfiguration("dist.http.endpoint.request"); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#deleteHistoricalMetricsConfiguration"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/metrics/GetHistoricalMetricsConfiguration.java b/examples/v2/metrics/GetHistoricalMetricsConfiguration.java new file mode 100644 index 00000000000..06c1ffd87ff --- /dev/null +++ b/examples/v2/metrics/GetHistoricalMetricsConfiguration.java @@ -0,0 +1,26 @@ +// Get a historical metrics configuration returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.MetricsApi; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getHistoricalMetricsConfiguration", true); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + try { + HistoricalMetricsConfigurationResponse result = + apiInstance.getHistoricalMetricsConfiguration("dist.http.endpoint.request"); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#getHistoricalMetricsConfiguration"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 2c00c9b0dcb..2ddba8395e3 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1124,10 +1124,13 @@ public class ApiClient { put("v2.removeRoleFromRestrictionQuery", false); put("v2.replaceRestrictionQuery", false); put("v2.updateRestrictionQuery", false); + put("v2.createHistoricalMetricsConfiguration", false); put("v2.createTagIndexingRule", false); put("v2.createTagIndexingRuleExemption", false); + put("v2.deleteHistoricalMetricsConfiguration", false); put("v2.deleteTagIndexingRule", false); put("v2.deleteTagIndexingRuleExemption", false); + put("v2.getHistoricalMetricsConfiguration", false); put("v2.getTagIndexingRule", false); put("v2.getTagIndexingRuleExemption", false); put("v2.listTagIndexingRules", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/MetricsApi.java b/src/main/java/com/datadog/api/client/v2/api/MetricsApi.java index 296fb862b49..76b3b5d8d5f 100644 --- a/src/main/java/com/datadog/api/client/v2/api/MetricsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/MetricsApi.java @@ -5,6 +5,8 @@ import com.datadog.api.client.ApiResponse; import com.datadog.api.client.PaginationIterable; import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationCreateRequest; +import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationResponse; import com.datadog.api.client.v2.model.IntakePayloadAccepted; import com.datadog.api.client.v2.model.MetricAllTagsResponse; import com.datadog.api.client.v2.model.MetricAssetsResponse; @@ -234,6 +236,169 @@ public ApiResponse createBulkTagsMetricsConfigurati new GenericType() {}); } + /** + * Enable historical metrics ingestion. + * + *

See {@link #createHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param body (required) + * @return HistoricalMetricsConfigurationResponse + * @throws ApiException if fails to make API call + */ + public HistoricalMetricsConfigurationResponse createHistoricalMetricsConfiguration( + HistoricalMetricsConfigurationCreateRequest body) throws ApiException { + return createHistoricalMetricsConfigurationWithHttpInfo(body).getData(); + } + + /** + * Enable historical metrics ingestion. + * + *

See {@link #createHistoricalMetricsConfigurationWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<HistoricalMetricsConfigurationResponse> + */ + public CompletableFuture + createHistoricalMetricsConfigurationAsync(HistoricalMetricsConfigurationCreateRequest body) { + return createHistoricalMetricsConfigurationWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Enable historical metrics ingestion (late data ingestion) for a metric. Idempotent: enabling an + * already-enabled metric returns 200 instead of 201. Not supported for distribution metrics, + * metrics with an existing tag configuration, or most standard (non-custom) metrics. + * + * @param body (required) + * @return ApiResponse<HistoricalMetricsConfigurationResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
201 Created -
400 Bad Request -
404 Not Found -
422 Unprocessable Entity -
429 Too many requests -
+ */ + public ApiResponse + createHistoricalMetricsConfigurationWithHttpInfo( + HistoricalMetricsConfigurationCreateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "createHistoricalMetricsConfiguration"; + 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 = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " createHistoricalMetricsConfiguration"); + } + // create path and map variables + String localVarPath = "/api/v2/metrics/historical-metrics-configurations"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.createHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Enable historical metrics ingestion. + * + *

See {@link #createHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<HistoricalMetricsConfigurationResponse>> + */ + public CompletableFuture> + createHistoricalMetricsConfigurationWithHttpInfoAsync( + HistoricalMetricsConfigurationCreateRequest body) { + // Check if unstable operation is enabled + String operationId = "createHistoricalMetricsConfiguration"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " createHistoricalMetricsConfiguration")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/metrics/historical-metrics-configurations"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.createHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Create a tag configuration. * @@ -896,6 +1061,164 @@ public ApiResponse deleteBulkTagsMetricsConfigurati new GenericType() {}); } + /** + * Delete a historical metrics configuration. + * + *

See {@link #deleteHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @throws ApiException if fails to make API call + */ + public void deleteHistoricalMetricsConfiguration(String metricName) throws ApiException { + deleteHistoricalMetricsConfigurationWithHttpInfo(metricName); + } + + /** + * Delete a historical metrics configuration. + * + *

See {@link #deleteHistoricalMetricsConfigurationWithHttpInfoAsync}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteHistoricalMetricsConfigurationAsync(String metricName) { + return deleteHistoricalMetricsConfigurationWithHttpInfoAsync(metricName) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Disable historical metrics ingestion for a metric. Idempotent: always returns 204, whether or + * not the configuration existed or the metric itself still exists, so that Terraform destroy + * succeeds for a metric removed out-of-band. + * + * @param metricName The name of the metric. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
429 Too many requests -
+ */ + public ApiResponse deleteHistoricalMetricsConfigurationWithHttpInfo(String metricName) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "deleteHistoricalMetricsConfiguration"; + 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 'metricName' is set + if (metricName == null) { + throw new ApiException( + 400, + "Missing the required parameter 'metricName' when calling" + + " deleteHistoricalMetricsConfiguration"); + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/historical-metrics-configurations/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.deleteHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a historical metrics configuration. + * + *

See {@link #deleteHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteHistoricalMetricsConfigurationWithHttpInfoAsync( + String metricName) { + // Check if unstable operation is enabled + String operationId = "deleteHistoricalMetricsConfiguration"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> 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 'metricName' is set + if (metricName == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'metricName' when calling" + + " deleteHistoricalMetricsConfiguration")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/historical-metrics-configurations/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.deleteHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** * Delete a tag configuration. * @@ -1627,6 +1950,171 @@ public ApiResponse estimateMetricsOutputSeriesWithHttpIn new GenericType() {}); } + /** + * Get a historical metrics configuration. + * + *

See {@link #getHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return HistoricalMetricsConfigurationResponse + * @throws ApiException if fails to make API call + */ + public HistoricalMetricsConfigurationResponse getHistoricalMetricsConfiguration(String metricName) + throws ApiException { + return getHistoricalMetricsConfigurationWithHttpInfo(metricName).getData(); + } + + /** + * Get a historical metrics configuration. + * + *

See {@link #getHistoricalMetricsConfigurationWithHttpInfoAsync}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<HistoricalMetricsConfigurationResponse> + */ + public CompletableFuture + getHistoricalMetricsConfigurationAsync(String metricName) { + return getHistoricalMetricsConfigurationWithHttpInfoAsync(metricName) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get the historical metrics ingestion configuration for a metric. Existence of the resource + * means historical metrics ingestion is enabled; returns 404 when it is not enabled for the + * metric. + * + * @param metricName The name of the metric. (required) + * @return ApiResponse<HistoricalMetricsConfigurationResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse + getHistoricalMetricsConfigurationWithHttpInfo(String metricName) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getHistoricalMetricsConfiguration"; + 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 'metricName' is set + if (metricName == null) { + throw new ApiException( + 400, + "Missing the required parameter 'metricName' when calling" + + " getHistoricalMetricsConfiguration"); + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/historical-metrics-configurations/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.getHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get a historical metrics configuration. + * + *

See {@link #getHistoricalMetricsConfigurationWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<ApiResponse<HistoricalMetricsConfigurationResponse>> + */ + public CompletableFuture> + getHistoricalMetricsConfigurationWithHttpInfoAsync(String metricName) { + // Check if unstable operation is enabled + String operationId = "getHistoricalMetricsConfiguration"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> 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 'metricName' is set + if (metricName == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'metricName' when calling" + + " getHistoricalMetricsConfiguration")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/historical-metrics-configurations/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.getHistoricalMetricsConfiguration", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Get tag key cardinality details. * diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationAttributes.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationAttributes.java new file mode 100644 index 00000000000..22b8930844b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationAttributes.java @@ -0,0 +1,130 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes of a historical metrics configuration. */ +@JsonPropertyOrder({HistoricalMetricsConfigurationAttributes.JSON_PROPERTY_CREATED_AT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HistoricalMetricsConfigurationAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + /** + * Timestamp when historical metrics ingestion was enabled for the metric. + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return HistoricalMetricsConfigurationAttributes + */ + @JsonAnySetter + public HistoricalMetricsConfigurationAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this HistoricalMetricsConfigurationAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HistoricalMetricsConfigurationAttributes historicalMetricsConfigurationAttributes = + (HistoricalMetricsConfigurationAttributes) o; + return Objects.equals(this.createdAt, historicalMetricsConfigurationAttributes.createdAt) + && Objects.equals( + this.additionalProperties, + historicalMetricsConfigurationAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HistoricalMetricsConfigurationAttributes {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateData.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateData.java new file mode 100644 index 00000000000..0f933c2eda6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateData.java @@ -0,0 +1,183 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Data object for enabling historical metrics ingestion for a metric. */ +@JsonPropertyOrder({ + HistoricalMetricsConfigurationCreateData.JSON_PROPERTY_ID, + HistoricalMetricsConfigurationCreateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HistoricalMetricsConfigurationCreateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private HistoricalMetricsConfigurationType type = + HistoricalMetricsConfigurationType.HISTORICAL_METRICS_CONFIGURATIONS; + + public HistoricalMetricsConfigurationCreateData() {} + + @JsonCreator + public HistoricalMetricsConfigurationCreateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + HistoricalMetricsConfigurationType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public HistoricalMetricsConfigurationCreateData id(String id) { + this.id = id; + return this; + } + + /** + * The metric name, used as the resource ID. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public HistoricalMetricsConfigurationCreateData type(HistoricalMetricsConfigurationType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The historical metrics configuration resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public HistoricalMetricsConfigurationType getType() { + return type; + } + + public void setType(HistoricalMetricsConfigurationType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return HistoricalMetricsConfigurationCreateData + */ + @JsonAnySetter + public HistoricalMetricsConfigurationCreateData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this HistoricalMetricsConfigurationCreateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HistoricalMetricsConfigurationCreateData historicalMetricsConfigurationCreateData = + (HistoricalMetricsConfigurationCreateData) o; + return Objects.equals(this.id, historicalMetricsConfigurationCreateData.id) + && Objects.equals(this.type, historicalMetricsConfigurationCreateData.type) + && Objects.equals( + this.additionalProperties, + historicalMetricsConfigurationCreateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HistoricalMetricsConfigurationCreateData {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateRequest.java new file mode 100644 index 00000000000..ede5fcb9d1f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationCreateRequest.java @@ -0,0 +1,154 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request body for enabling historical metrics ingestion for a metric. */ +@JsonPropertyOrder({HistoricalMetricsConfigurationCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HistoricalMetricsConfigurationCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private HistoricalMetricsConfigurationCreateData data; + + public HistoricalMetricsConfigurationCreateRequest() {} + + @JsonCreator + public HistoricalMetricsConfigurationCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + HistoricalMetricsConfigurationCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public HistoricalMetricsConfigurationCreateRequest data( + HistoricalMetricsConfigurationCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data object for enabling historical metrics ingestion for a metric. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public HistoricalMetricsConfigurationCreateData getData() { + return data; + } + + public void setData(HistoricalMetricsConfigurationCreateData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return HistoricalMetricsConfigurationCreateRequest + */ + @JsonAnySetter + public HistoricalMetricsConfigurationCreateRequest putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this HistoricalMetricsConfigurationCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HistoricalMetricsConfigurationCreateRequest historicalMetricsConfigurationCreateRequest = + (HistoricalMetricsConfigurationCreateRequest) o; + return Objects.equals(this.data, historicalMetricsConfigurationCreateRequest.data) + && Objects.equals( + this.additionalProperties, + historicalMetricsConfigurationCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HistoricalMetricsConfigurationCreateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationData.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationData.java new file mode 100644 index 00000000000..33d67c26c06 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationData.java @@ -0,0 +1,206 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * A historical metrics configuration resource object. Existence of this resource means historical + * metrics ingestion is enabled for the metric; there is no separate enabled attribute. + */ +@JsonPropertyOrder({ + HistoricalMetricsConfigurationData.JSON_PROPERTY_ATTRIBUTES, + HistoricalMetricsConfigurationData.JSON_PROPERTY_ID, + HistoricalMetricsConfigurationData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HistoricalMetricsConfigurationData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private HistoricalMetricsConfigurationAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private HistoricalMetricsConfigurationType type = + HistoricalMetricsConfigurationType.HISTORICAL_METRICS_CONFIGURATIONS; + + public HistoricalMetricsConfigurationData attributes( + HistoricalMetricsConfigurationAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a historical metrics configuration. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public HistoricalMetricsConfigurationAttributes getAttributes() { + return attributes; + } + + public void setAttributes(HistoricalMetricsConfigurationAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public HistoricalMetricsConfigurationData id(String id) { + this.id = id; + return this; + } + + /** + * The metric name, used as the resource ID. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public HistoricalMetricsConfigurationData type(HistoricalMetricsConfigurationType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The historical metrics configuration resource type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public HistoricalMetricsConfigurationType getType() { + return type; + } + + public void setType(HistoricalMetricsConfigurationType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return HistoricalMetricsConfigurationData + */ + @JsonAnySetter + public HistoricalMetricsConfigurationData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this HistoricalMetricsConfigurationData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HistoricalMetricsConfigurationData historicalMetricsConfigurationData = + (HistoricalMetricsConfigurationData) o; + return Objects.equals(this.attributes, historicalMetricsConfigurationData.attributes) + && Objects.equals(this.id, historicalMetricsConfigurationData.id) + && Objects.equals(this.type, historicalMetricsConfigurationData.type) + && Objects.equals( + this.additionalProperties, historicalMetricsConfigurationData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HistoricalMetricsConfigurationData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationResponse.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationResponse.java new file mode 100644 index 00000000000..cbd1a845668 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationResponse.java @@ -0,0 +1,142 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response containing a historical metrics configuration. */ +@JsonPropertyOrder({HistoricalMetricsConfigurationResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HistoricalMetricsConfigurationResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private HistoricalMetricsConfigurationData data; + + public HistoricalMetricsConfigurationResponse data(HistoricalMetricsConfigurationData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * A historical metrics configuration resource object. Existence of this resource means historical + * metrics ingestion is enabled for the metric; there is no separate enabled attribute. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public HistoricalMetricsConfigurationData getData() { + return data; + } + + public void setData(HistoricalMetricsConfigurationData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return HistoricalMetricsConfigurationResponse + */ + @JsonAnySetter + public HistoricalMetricsConfigurationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this HistoricalMetricsConfigurationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HistoricalMetricsConfigurationResponse historicalMetricsConfigurationResponse = + (HistoricalMetricsConfigurationResponse) o; + return Objects.equals(this.data, historicalMetricsConfigurationResponse.data) + && Objects.equals( + this.additionalProperties, historicalMetricsConfigurationResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HistoricalMetricsConfigurationResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationType.java b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationType.java new file mode 100644 index 00000000000..7695ca9a882 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HistoricalMetricsConfigurationType.java @@ -0,0 +1,59 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The historical metrics configuration resource type. */ +@JsonSerialize( + using = HistoricalMetricsConfigurationType.HistoricalMetricsConfigurationTypeSerializer.class) +public class HistoricalMetricsConfigurationType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("historical_metrics_configurations")); + + public static final HistoricalMetricsConfigurationType HISTORICAL_METRICS_CONFIGURATIONS = + new HistoricalMetricsConfigurationType("historical_metrics_configurations"); + + HistoricalMetricsConfigurationType(String value) { + super(value, allowedValues); + } + + public static class HistoricalMetricsConfigurationTypeSerializer + extends StdSerializer { + public HistoricalMetricsConfigurationTypeSerializer( + Class t) { + super(t); + } + + public HistoricalMetricsConfigurationTypeSerializer() { + this(null); + } + + @Override + public void serialize( + HistoricalMetricsConfigurationType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static HistoricalMetricsConfigurationType fromValue(String value) { + return new HistoricalMetricsConfigurationType(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/metrics.feature b/src/test/resources/com/datadog/api/client/v2/api/metrics.feature index d463aa4250b..30517072c69 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/metrics.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/metrics.feature @@ -142,6 +142,24 @@ Feature: Metrics When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/metrics-experience + Scenario: Delete a historical metrics configuration returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "DeleteHistoricalMetricsConfiguration" enabled + And new "DeleteHistoricalMetricsConfiguration" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/metrics-experience + Scenario: Delete a historical metrics configuration returns "No Content" response + Given a valid "appKeyAuth" key in the system + And operation "DeleteHistoricalMetricsConfiguration" enabled + And new "DeleteHistoricalMetricsConfiguration" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + @replay-only @skip-validation @team:DataDog/metrics-experience Scenario: Delete a tag configuration returns "No Content" response Given there is a valid "metric" in the system @@ -221,6 +239,78 @@ Feature: Metrics When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/metrics-experience + Scenario: Enable historical metrics ingestion returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "CreateHistoricalMetricsConfiguration" enabled + And new "CreateHistoricalMetricsConfiguration" request + And body with value {"data": {"id": "dd.test.metric", "type": "historical_metrics_configurations"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/metrics-experience + Scenario: Enable historical metrics ingestion returns "Created" response + Given a valid "appKeyAuth" key in the system + And operation "CreateHistoricalMetricsConfiguration" enabled + And new "CreateHistoricalMetricsConfiguration" request + And body with value {"data": {"id": "dd.test.metric", "type": "historical_metrics_configurations"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/metrics-experience + Scenario: Enable historical metrics ingestion returns "Not Found" response + Given a valid "appKeyAuth" key in the system + And operation "CreateHistoricalMetricsConfiguration" enabled + And new "CreateHistoricalMetricsConfiguration" request + And body with value {"data": {"id": "dd.test.metric", "type": "historical_metrics_configurations"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/metrics-experience + Scenario: Enable historical metrics ingestion returns "OK" response + Given a valid "appKeyAuth" key in the system + And operation "CreateHistoricalMetricsConfiguration" enabled + And new "CreateHistoricalMetricsConfiguration" request + And body with value {"data": {"id": "dd.test.metric", "type": "historical_metrics_configurations"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/metrics-experience + Scenario: Enable historical metrics ingestion returns "Unprocessable Entity" response + Given a valid "appKeyAuth" key in the system + And operation "CreateHistoricalMetricsConfiguration" enabled + And new "CreateHistoricalMetricsConfiguration" request + And body with value {"data": {"id": "dd.test.metric", "type": "historical_metrics_configurations"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + + @generated @skip @team:DataDog/metrics-experience + Scenario: Get a historical metrics configuration returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "GetHistoricalMetricsConfiguration" enabled + And new "GetHistoricalMetricsConfiguration" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/metrics-experience + Scenario: Get a historical metrics configuration returns "Not Found" response + Given a valid "appKeyAuth" key in the system + And operation "GetHistoricalMetricsConfiguration" enabled + And new "GetHistoricalMetricsConfiguration" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/metrics-experience + Scenario: Get a historical metrics configuration returns "OK" response + Given a valid "appKeyAuth" key in the system + And operation "GetHistoricalMetricsConfiguration" enabled + And new "GetHistoricalMetricsConfiguration" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/metrics-experience Scenario: Get a list of metrics returns "Bad Request" response Given a valid "appKeyAuth" key in the system diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 2a7fb64a0a9..f6d33436a51 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -5154,6 +5154,31 @@ "type": "unsafe" } }, + "CreateHistoricalMetricsConfiguration": { + "tag": "Metrics", + "undo": { + "operationId": "DeleteHistoricalMetricsConfiguration", + "parameters": [ + { + "name": "metric_name", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteHistoricalMetricsConfiguration": { + "tag": "Metrics", + "undo": { + "type": "idempotent" + } + }, + "GetHistoricalMetricsConfiguration": { + "tag": "Metrics", + "undo": { + "type": "safe" + } + }, "ListTagIndexingRules": { "tag": "Metrics", "undo": {