diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8e540e2cff5..10cbce5a5e5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -36727,6 +36727,109 @@ components: - $ref: "#/components/schemas/DeploymentRuleOptionsFaultyDeploymentDetection" - $ref: "#/components/schemas/DeploymentRuleOptionsMonitor" - $ref: "#/components/schemas/DeploymentRuleOptionsMonitorIds" + DerivedMetricAttributes: + description: Attributes of a derived metric. + properties: + definition: + $ref: "#/components/schemas/DerivedMetricDefinition" + required: + - definition + type: object + DerivedMetricCreateData: + description: Data object for creating or updating a derived metric. + properties: + attributes: + $ref: "#/components/schemas/DerivedMetricAttributes" + id: + description: The derived metric name used as the resource ID. + example: my.derived.metric + type: string + type: + $ref: "#/components/schemas/DerivedMetricsType" + required: + - id + - type + - attributes + type: object + DerivedMetricCreateRequest: + description: Request body for creating or updating a derived metric. + properties: + data: + $ref: "#/components/schemas/DerivedMetricCreateData" + required: + - data + type: object + DerivedMetricData: + description: A derived metric resource object. + properties: + attributes: + $ref: "#/components/schemas/DerivedMetricAttributes" + id: + description: The derived metric name used as the resource ID. + example: my.derived.metric + type: string + type: + $ref: "#/components/schemas/DerivedMetricsType" + required: + - id + - type + - attributes + type: object + DerivedMetricDefinition: + description: The definition of a derived metric as a formula over one or more queries. + properties: + formula: + description: The formula that combines the queries into the value of the derived metric. + example: a + type: string + queries: + description: The list of queries referenced by the formula. + items: + $ref: "#/components/schemas/DerivedMetricQuery" + minItems: 1 + type: array + required: + - formula + - queries + type: object + DerivedMetricQuery: + description: A single query used in the definition of a derived metric. + properties: + data_source: + description: The data source that the query is run against. + example: metrics + type: string + name: + description: The name used to reference this query from the formula. + example: a + type: string + query: + description: The query string executed against the data source. + example: avg:system.cpu.user{*} + type: string + required: + - data_source + - name + - query + type: object + DerivedMetricResponse: + description: Response containing a single derived metric. + properties: + data: + $ref: "#/components/schemas/DerivedMetricData" + readOnly: true + required: + - data + type: object + DerivedMetricsType: + default: derived_metrics + description: The derived metric resource type. + enum: + - derived_metrics + example: derived_metrics + type: string + x-enum-varnames: + - DERIVED_METRICS DetachCaseRequest: description: Request for detaching security findings from their case. properties: @@ -198072,6 +198175,245 @@ paths: permissions: - metric_tags_write x-sunset: "2027-01-01" + /api/v2/metrics/derived-metrics: + post: + description: |- + Create a derived metric for the org. The metric name is supplied as the resource `id`, + and the `definition` sets the formula and the queries the formula is computed from. + Requires the `Manage Tags for Metrics` permission. + operationId: CreateDerivedMetric + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + definition: + formula: a + queries: + - data_source: metrics + name: a + query: avg:system.cpu.user{*} + id: my.derived.metric + type: derived_metrics + schema: + $ref: "#/components/schemas/DerivedMetricCreateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + definition: + formula: a + queries: + - data_source: metrics + name: a + query: avg:system.cpu.user{*} + id: my.derived.metric + type: derived_metrics + schema: + $ref: "#/components/schemas/DerivedMetricResponse" + description: Created + headers: + Location: + description: The URL of the newly created derived metric. + schema: + type: string + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - metric_tags_write + summary: Create a derived metric + tags: + - Metrics + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - metric_tags_write + /api/v2/metrics/derived-metrics/{metric_name}: + delete: + description: |- + Delete a derived metric by name. Idempotent: returns 204 regardless of whether the derived + metric existed. Requires the `Manage Tags for Metrics` permission. + operationId: DeleteDerivedMetric + parameters: + - $ref: "#/components/parameters/MetricName" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - metric_tags_write + summary: Delete a derived metric + tags: + - Metrics + "x-permission": + operator: OR + permissions: + - metric_tags_write + get: + description: Get the definition of a derived metric by name. + operationId: GetDerivedMetric + parameters: + - $ref: "#/components/parameters/MetricName" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + definition: + formula: a + queries: + - data_source: metrics + name: a + query: avg:system.cpu.user{*} + id: my.derived.metric + type: derived_metrics + schema: + $ref: "#/components/schemas/DerivedMetricResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - metrics_read + summary: Get a derived metric + tags: + - Metrics + "x-permission": + operator: OR + permissions: + - metrics_read + put: + description: |- + Update the definition of an existing derived metric. The `id` in the request body + must match the `metric_name` path parameter. Requires the `Manage Tags for Metrics` permission. + operationId: UpdateDerivedMetric + parameters: + - $ref: "#/components/parameters/MetricName" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + definition: + formula: a + queries: + - data_source: metrics + name: a + query: avg:system.cpu.user{*} + id: my.derived.metric + type: derived_metrics + schema: + $ref: "#/components/schemas/DerivedMetricCreateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + definition: + formula: a + queries: + - data_source: metrics + name: a + query: avg:system.cpu.user{*} + id: my.derived.metric + type: derived_metrics + schema: + $ref: "#/components/schemas/DerivedMetricResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - metric_tags_write + summary: Update a derived metric + tags: + - Metrics + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - metric_tags_write /api/v2/metrics/historical-metrics-configurations: post: description: |- diff --git a/examples/v2/metrics/CreateDerivedMetric.java b/examples/v2/metrics/CreateDerivedMetric.java new file mode 100644 index 00000000000..57427111221 --- /dev/null +++ b/examples/v2/metrics/CreateDerivedMetric.java @@ -0,0 +1,50 @@ +// Create a derived metric returns "Created" 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.DerivedMetricAttributes; +import com.datadog.api.client.v2.model.DerivedMetricCreateData; +import com.datadog.api.client.v2.model.DerivedMetricCreateRequest; +import com.datadog.api.client.v2.model.DerivedMetricDefinition; +import com.datadog.api.client.v2.model.DerivedMetricQuery; +import com.datadog.api.client.v2.model.DerivedMetricResponse; +import com.datadog.api.client.v2.model.DerivedMetricsType; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + DerivedMetricCreateRequest body = + new DerivedMetricCreateRequest() + .data( + new DerivedMetricCreateData() + .attributes( + new DerivedMetricAttributes() + .definition( + new DerivedMetricDefinition() + .formula("a") + .queries( + Collections.singletonList( + new DerivedMetricQuery() + .dataSource("metrics") + .name("a") + .query("avg:system.cpu.user{*}"))))) + .id("test.derived.examplemetric") + .type(DerivedMetricsType.DERIVED_METRICS)); + + try { + DerivedMetricResponse result = apiInstance.createDerivedMetric(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#createDerivedMetric"); + 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/DeleteDerivedMetric.java b/examples/v2/metrics/DeleteDerivedMetric.java new file mode 100644 index 00000000000..5d870802790 --- /dev/null +++ b/examples/v2/metrics/DeleteDerivedMetric.java @@ -0,0 +1,26 @@ +// Delete a derived metric 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.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + // there is a valid "derived_metric" in the system + String DERIVED_METRIC_DATA_ID = System.getenv("DERIVED_METRIC_DATA_ID"); + + try { + apiInstance.deleteDerivedMetric(DERIVED_METRIC_DATA_ID); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#deleteDerivedMetric"); + 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/GetDerivedMetric.java b/examples/v2/metrics/GetDerivedMetric.java new file mode 100644 index 00000000000..78535f80507 --- /dev/null +++ b/examples/v2/metrics/GetDerivedMetric.java @@ -0,0 +1,28 @@ +// Get a derived metric 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.DerivedMetricResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + // there is a valid "derived_metric" in the system + String DERIVED_METRIC_DATA_ID = System.getenv("DERIVED_METRIC_DATA_ID"); + + try { + DerivedMetricResponse result = apiInstance.getDerivedMetric(DERIVED_METRIC_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#getDerivedMetric"); + 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/UpdateDerivedMetric.java b/examples/v2/metrics/UpdateDerivedMetric.java new file mode 100644 index 00000000000..5c3d9183f08 --- /dev/null +++ b/examples/v2/metrics/UpdateDerivedMetric.java @@ -0,0 +1,53 @@ +// Update a derived metric 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.DerivedMetricAttributes; +import com.datadog.api.client.v2.model.DerivedMetricCreateData; +import com.datadog.api.client.v2.model.DerivedMetricCreateRequest; +import com.datadog.api.client.v2.model.DerivedMetricDefinition; +import com.datadog.api.client.v2.model.DerivedMetricQuery; +import com.datadog.api.client.v2.model.DerivedMetricResponse; +import com.datadog.api.client.v2.model.DerivedMetricsType; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + MetricsApi apiInstance = new MetricsApi(defaultClient); + + // there is a valid "derived_metric" in the system + String DERIVED_METRIC_DATA_ID = System.getenv("DERIVED_METRIC_DATA_ID"); + + DerivedMetricCreateRequest body = + new DerivedMetricCreateRequest() + .data( + new DerivedMetricCreateData() + .attributes( + new DerivedMetricAttributes() + .definition( + new DerivedMetricDefinition() + .formula("a * 2") + .queries( + Collections.singletonList( + new DerivedMetricQuery() + .dataSource("metrics") + .name("a") + .query("avg:system.cpu.user{*}"))))) + .id(DERIVED_METRIC_DATA_ID) + .type(DerivedMetricsType.DERIVED_METRICS)); + + try { + DerivedMetricResponse result = apiInstance.updateDerivedMetric(DERIVED_METRIC_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MetricsApi#updateDerivedMetric"); + 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/v2/api/MetricsApi.java b/src/main/java/com/datadog/api/client/v2/api/MetricsApi.java index 439868ed291..ddfe59d71bd 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.DerivedMetricCreateRequest; +import com.datadog.api.client.v2.model.DerivedMetricResponse; import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationCreateRequest; import com.datadog.api.client.v2.model.HistoricalMetricsConfigurationResponse; import com.datadog.api.client.v2.model.IntakePayloadAccepted; @@ -236,6 +238,142 @@ public ApiResponse createBulkTagsMetricsConfigurati new GenericType() {}); } + /** + * Create a derived metric. + * + *

See {@link #createDerivedMetricWithHttpInfo}. + * + * @param body (required) + * @return DerivedMetricResponse + * @throws ApiException if fails to make API call + */ + public DerivedMetricResponse createDerivedMetric(DerivedMetricCreateRequest body) + throws ApiException { + return createDerivedMetricWithHttpInfo(body).getData(); + } + + /** + * Create a derived metric. + * + *

See {@link #createDerivedMetricWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<DerivedMetricResponse> + */ + public CompletableFuture createDerivedMetricAsync( + DerivedMetricCreateRequest body) { + return createDerivedMetricWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a derived metric for the org. The metric name is supplied as the resource id + * , and the definition sets the formula and the queries the formula is + * computed from. Requires the Manage Tags for Metrics permission. + * + * @param body (required) + * @return ApiResponse<DerivedMetricResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
409 Conflict -
429 Too many requests -
+ */ + public ApiResponse createDerivedMetricWithHttpInfo( + DerivedMetricCreateRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createDerivedMetric"); + } + // create path and map variables + String localVarPath = "/api/v2/metrics/derived-metrics"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.createDerivedMetric", + 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() {}); + } + + /** + * Create a derived metric. + * + *

See {@link #createDerivedMetricWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<DerivedMetricResponse>> + */ + public CompletableFuture> createDerivedMetricWithHttpInfoAsync( + DerivedMetricCreateRequest body) { + 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 createDerivedMetric")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/metrics/derived-metrics"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.createDerivedMetric", + 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() {}); + } + /** * Enable historical metrics ingestion. * @@ -1061,6 +1199,141 @@ public ApiResponse deleteBulkTagsMetricsConfigurati new GenericType() {}); } + /** + * Delete a derived metric. + * + *

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

See {@link #deleteDerivedMetricWithHttpInfoAsync}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteDerivedMetricAsync(String metricName) { + return deleteDerivedMetricWithHttpInfoAsync(metricName) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete a derived metric by name. Idempotent: returns 204 regardless of whether the derived + * metric existed. Requires the Manage Tags for Metrics permission. + * + * @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 deleteDerivedMetricWithHttpInfo(String metricName) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'metricName' is set + if (metricName == null) { + throw new ApiException( + 400, "Missing the required parameter 'metricName' when calling deleteDerivedMetric"); + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.deleteDerivedMetric", + 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 derived metric. + * + *

See {@link #deleteDerivedMetricWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteDerivedMetricWithHttpInfoAsync( + String metricName) { + 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 deleteDerivedMetric")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.deleteDerivedMetric", + 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 historical metrics configuration. * @@ -1969,6 +2242,143 @@ public ApiResponse estimateMetricsOutputSeriesWithHttpIn new GenericType() {}); } + /** + * Get a derived metric. + * + *

See {@link #getDerivedMetricWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return DerivedMetricResponse + * @throws ApiException if fails to make API call + */ + public DerivedMetricResponse getDerivedMetric(String metricName) throws ApiException { + return getDerivedMetricWithHttpInfo(metricName).getData(); + } + + /** + * Get a derived metric. + * + *

See {@link #getDerivedMetricWithHttpInfoAsync}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<DerivedMetricResponse> + */ + public CompletableFuture getDerivedMetricAsync(String metricName) { + return getDerivedMetricWithHttpInfoAsync(metricName) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get the definition of a derived metric by name. + * + * @param metricName The name of the metric. (required) + * @return ApiResponse<DerivedMetricResponse> + * @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 getDerivedMetricWithHttpInfo(String metricName) + throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'metricName' is set + if (metricName == null) { + throw new ApiException( + 400, "Missing the required parameter 'metricName' when calling getDerivedMetric"); + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.getDerivedMetric", + 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 derived metric. + * + *

See {@link #getDerivedMetricWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @return CompletableFuture<ApiResponse<DerivedMetricResponse>> + */ + public CompletableFuture> getDerivedMetricWithHttpInfoAsync( + String metricName) { + 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 getDerivedMetric")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.getDerivedMetric", + 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 a historical metrics configuration. * @@ -5106,6 +5516,166 @@ public CompletableFuture> submitMetricsWithHt new GenericType() {}); } + /** + * Update a derived metric. + * + *

See {@link #updateDerivedMetricWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @param body (required) + * @return DerivedMetricResponse + * @throws ApiException if fails to make API call + */ + public DerivedMetricResponse updateDerivedMetric( + String metricName, DerivedMetricCreateRequest body) throws ApiException { + return updateDerivedMetricWithHttpInfo(metricName, body).getData(); + } + + /** + * Update a derived metric. + * + *

See {@link #updateDerivedMetricWithHttpInfoAsync}. + * + * @param metricName The name of the metric. (required) + * @param body (required) + * @return CompletableFuture<DerivedMetricResponse> + */ + public CompletableFuture updateDerivedMetricAsync( + String metricName, DerivedMetricCreateRequest body) { + return updateDerivedMetricWithHttpInfoAsync(metricName, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update the definition of an existing derived metric. The id in the request body + * must match the metric_name path parameter. Requires the + * Manage Tags for Metrics permission. + * + * @param metricName The name of the metric. (required) + * @param body (required) + * @return ApiResponse<DerivedMetricResponse> + * @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 updateDerivedMetricWithHttpInfo( + String metricName, DerivedMetricCreateRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'metricName' is set + if (metricName == null) { + throw new ApiException( + 400, "Missing the required parameter 'metricName' when calling updateDerivedMetric"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateDerivedMetric"); + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.MetricsApi.updateDerivedMetric", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update a derived metric. + * + *

See {@link #updateDerivedMetricWithHttpInfo}. + * + * @param metricName The name of the metric. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<DerivedMetricResponse>> + */ + public CompletableFuture> updateDerivedMetricWithHttpInfoAsync( + String metricName, DerivedMetricCreateRequest body) { + Object localVarPostBody = body; + + // 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 updateDerivedMetric")); + return result; + } + + // 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 updateDerivedMetric")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/metrics/derived-metrics/{metric_name}" + .replaceAll( + "\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.MetricsApi.updateDerivedMetric", + 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( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Update a tag configuration. * diff --git a/src/main/java/com/datadog/api/client/v2/model/DerivedMetricAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricAttributes.java new file mode 100644 index 00000000000..b232f1a400c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricAttributes.java @@ -0,0 +1,149 @@ +/* + * 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; + +/** Attributes of a derived metric. */ +@JsonPropertyOrder({DerivedMetricAttributes.JSON_PROPERTY_DEFINITION}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DEFINITION = "definition"; + private DerivedMetricDefinition definition; + + public DerivedMetricAttributes() {} + + @JsonCreator + public DerivedMetricAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_DEFINITION) + DerivedMetricDefinition definition) { + this.definition = definition; + this.unparsed |= definition.unparsed; + } + + public DerivedMetricAttributes definition(DerivedMetricDefinition definition) { + this.definition = definition; + this.unparsed |= definition.unparsed; + return this; + } + + /** + * The definition of a derived metric as a formula over one or more queries. + * + * @return definition + */ + @JsonProperty(JSON_PROPERTY_DEFINITION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricDefinition getDefinition() { + return definition; + } + + public void setDefinition(DerivedMetricDefinition definition) { + this.definition = definition; + if (definition != null) { + this.unparsed |= definition.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 DerivedMetricAttributes + */ + @JsonAnySetter + public DerivedMetricAttributes 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 DerivedMetricAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricAttributes derivedMetricAttributes = (DerivedMetricAttributes) o; + return Objects.equals(this.definition, derivedMetricAttributes.definition) + && Objects.equals(this.additionalProperties, derivedMetricAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(definition, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricAttributes {\n"); + sb.append(" definition: ").append(toIndentedString(definition)).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/DerivedMetricCreateData.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricCreateData.java new file mode 100644 index 00000000000..9248a8bde8a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricCreateData.java @@ -0,0 +1,212 @@ +/* + * 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 creating or updating a derived metric. */ +@JsonPropertyOrder({ + DerivedMetricCreateData.JSON_PROPERTY_ATTRIBUTES, + DerivedMetricCreateData.JSON_PROPERTY_ID, + DerivedMetricCreateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricCreateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DerivedMetricAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DerivedMetricsType type = DerivedMetricsType.DERIVED_METRICS; + + public DerivedMetricCreateData() {} + + @JsonCreator + public DerivedMetricCreateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DerivedMetricAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DerivedMetricsType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DerivedMetricCreateData attributes(DerivedMetricAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a derived metric. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DerivedMetricAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public DerivedMetricCreateData id(String id) { + this.id = id; + return this; + } + + /** + * The derived 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 DerivedMetricCreateData type(DerivedMetricsType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The derived metric resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricsType getType() { + return type; + } + + public void setType(DerivedMetricsType 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 DerivedMetricCreateData + */ + @JsonAnySetter + public DerivedMetricCreateData 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 DerivedMetricCreateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricCreateData derivedMetricCreateData = (DerivedMetricCreateData) o; + return Objects.equals(this.attributes, derivedMetricCreateData.attributes) + && Objects.equals(this.id, derivedMetricCreateData.id) + && Objects.equals(this.type, derivedMetricCreateData.type) + && Objects.equals(this.additionalProperties, derivedMetricCreateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricCreateData {\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/DerivedMetricCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricCreateRequest.java new file mode 100644 index 00000000000..0532235bddf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricCreateRequest.java @@ -0,0 +1,149 @@ +/* + * 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 creating or updating a derived metric. */ +@JsonPropertyOrder({DerivedMetricCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DerivedMetricCreateData data; + + public DerivedMetricCreateRequest() {} + + @JsonCreator + public DerivedMetricCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) DerivedMetricCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DerivedMetricCreateRequest data(DerivedMetricCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data object for creating or updating a derived metric. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricCreateData getData() { + return data; + } + + public void setData(DerivedMetricCreateData 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 DerivedMetricCreateRequest + */ + @JsonAnySetter + public DerivedMetricCreateRequest 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 DerivedMetricCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricCreateRequest derivedMetricCreateRequest = (DerivedMetricCreateRequest) o; + return Objects.equals(this.data, derivedMetricCreateRequest.data) + && Objects.equals( + this.additionalProperties, derivedMetricCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricCreateRequest {\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/DerivedMetricData.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricData.java new file mode 100644 index 00000000000..e388a8ad3d3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricData.java @@ -0,0 +1,212 @@ +/* + * 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; + +/** A derived metric resource object. */ +@JsonPropertyOrder({ + DerivedMetricData.JSON_PROPERTY_ATTRIBUTES, + DerivedMetricData.JSON_PROPERTY_ID, + DerivedMetricData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DerivedMetricAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DerivedMetricsType type = DerivedMetricsType.DERIVED_METRICS; + + public DerivedMetricData() {} + + @JsonCreator + public DerivedMetricData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DerivedMetricAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DerivedMetricsType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DerivedMetricData attributes(DerivedMetricAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a derived metric. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DerivedMetricAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public DerivedMetricData id(String id) { + this.id = id; + return this; + } + + /** + * The derived 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 DerivedMetricData type(DerivedMetricsType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The derived metric resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricsType getType() { + return type; + } + + public void setType(DerivedMetricsType 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 DerivedMetricData + */ + @JsonAnySetter + public DerivedMetricData 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 DerivedMetricData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricData derivedMetricData = (DerivedMetricData) o; + return Objects.equals(this.attributes, derivedMetricData.attributes) + && Objects.equals(this.id, derivedMetricData.id) + && Objects.equals(this.type, derivedMetricData.type) + && Objects.equals(this.additionalProperties, derivedMetricData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricData {\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/DerivedMetricDefinition.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricDefinition.java new file mode 100644 index 00000000000..30a25dd3463 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricDefinition.java @@ -0,0 +1,193 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The definition of a derived metric as a formula over one or more queries. */ +@JsonPropertyOrder({ + DerivedMetricDefinition.JSON_PROPERTY_FORMULA, + DerivedMetricDefinition.JSON_PROPERTY_QUERIES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricDefinition { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FORMULA = "formula"; + private String formula; + + public static final String JSON_PROPERTY_QUERIES = "queries"; + private List queries = new ArrayList<>(); + + public DerivedMetricDefinition() {} + + @JsonCreator + public DerivedMetricDefinition( + @JsonProperty(required = true, value = JSON_PROPERTY_FORMULA) String formula, + @JsonProperty(required = true, value = JSON_PROPERTY_QUERIES) + List queries) { + this.formula = formula; + this.queries = queries; + for (DerivedMetricQuery item : queries) { + this.unparsed |= item.unparsed; + } + } + + public DerivedMetricDefinition formula(String formula) { + this.formula = formula; + return this; + } + + /** + * The formula that combines the queries into the value of the derived metric. + * + * @return formula + */ + @JsonProperty(JSON_PROPERTY_FORMULA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFormula() { + return formula; + } + + public void setFormula(String formula) { + this.formula = formula; + } + + public DerivedMetricDefinition queries(List queries) { + this.queries = queries; + for (DerivedMetricQuery item : queries) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DerivedMetricDefinition addQueriesItem(DerivedMetricQuery queriesItem) { + this.queries.add(queriesItem); + this.unparsed |= queriesItem.unparsed; + return this; + } + + /** + * The list of queries referenced by the formula. + * + * @return queries + */ + @JsonProperty(JSON_PROPERTY_QUERIES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getQueries() { + return queries; + } + + public void setQueries(List queries) { + this.queries = queries; + if (queries != null) { + for (DerivedMetricQuery item : queries) { + this.unparsed |= item.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 DerivedMetricDefinition + */ + @JsonAnySetter + public DerivedMetricDefinition 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 DerivedMetricDefinition object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricDefinition derivedMetricDefinition = (DerivedMetricDefinition) o; + return Objects.equals(this.formula, derivedMetricDefinition.formula) + && Objects.equals(this.queries, derivedMetricDefinition.queries) + && Objects.equals(this.additionalProperties, derivedMetricDefinition.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(formula, queries, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricDefinition {\n"); + sb.append(" formula: ").append(toIndentedString(formula)).append("\n"); + sb.append(" queries: ").append(toIndentedString(queries)).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/DerivedMetricQuery.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricQuery.java new file mode 100644 index 00000000000..1bf13b4100d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricQuery.java @@ -0,0 +1,201 @@ +/* + * 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; + +/** A single query used in the definition of a derived metric. */ +@JsonPropertyOrder({ + DerivedMetricQuery.JSON_PROPERTY_DATA_SOURCE, + DerivedMetricQuery.JSON_PROPERTY_NAME, + DerivedMetricQuery.JSON_PROPERTY_QUERY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricQuery { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA_SOURCE = "data_source"; + private String dataSource; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public DerivedMetricQuery() {} + + @JsonCreator + public DerivedMetricQuery( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA_SOURCE) String dataSource, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) { + this.dataSource = dataSource; + this.name = name; + this.query = query; + } + + public DerivedMetricQuery dataSource(String dataSource) { + this.dataSource = dataSource; + return this; + } + + /** + * The data source that the query is run against. + * + * @return dataSource + */ + @JsonProperty(JSON_PROPERTY_DATA_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getDataSource() { + return dataSource; + } + + public void setDataSource(String dataSource) { + this.dataSource = dataSource; + } + + public DerivedMetricQuery name(String name) { + this.name = name; + return this; + } + + /** + * The name used to reference this query from the formula. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DerivedMetricQuery query(String query) { + this.query = query; + return this; + } + + /** + * The query string executed against the data source. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** + * 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 DerivedMetricQuery + */ + @JsonAnySetter + public DerivedMetricQuery 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 DerivedMetricQuery object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricQuery derivedMetricQuery = (DerivedMetricQuery) o; + return Objects.equals(this.dataSource, derivedMetricQuery.dataSource) + && Objects.equals(this.name, derivedMetricQuery.name) + && Objects.equals(this.query, derivedMetricQuery.query) + && Objects.equals(this.additionalProperties, derivedMetricQuery.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dataSource, name, query, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricQuery {\n"); + sb.append(" dataSource: ").append(toIndentedString(dataSource)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" query: ").append(toIndentedString(query)).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/DerivedMetricResponse.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricResponse.java new file mode 100644 index 00000000000..bb990c6c28b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricResponse.java @@ -0,0 +1,148 @@ +/* + * 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; + +/** Response containing a single derived metric. */ +@JsonPropertyOrder({DerivedMetricResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DerivedMetricResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DerivedMetricData data; + + public DerivedMetricResponse() {} + + @JsonCreator + public DerivedMetricResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) DerivedMetricData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DerivedMetricResponse data(DerivedMetricData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * A derived metric resource object. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DerivedMetricData getData() { + return data; + } + + public void setData(DerivedMetricData 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 DerivedMetricResponse + */ + @JsonAnySetter + public DerivedMetricResponse 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 DerivedMetricResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DerivedMetricResponse derivedMetricResponse = (DerivedMetricResponse) o; + return Objects.equals(this.data, derivedMetricResponse.data) + && Objects.equals(this.additionalProperties, derivedMetricResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DerivedMetricResponse {\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/DerivedMetricsType.java b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricsType.java new file mode 100644 index 00000000000..d371051942c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DerivedMetricsType.java @@ -0,0 +1,55 @@ +/* + * 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 derived metric resource type. */ +@JsonSerialize(using = DerivedMetricsType.DerivedMetricsTypeSerializer.class) +public class DerivedMetricsType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("derived_metrics")); + + public static final DerivedMetricsType DERIVED_METRICS = + new DerivedMetricsType("derived_metrics"); + + DerivedMetricsType(String value) { + super(value, allowedValues); + } + + public static class DerivedMetricsTypeSerializer extends StdSerializer { + public DerivedMetricsTypeSerializer(Class t) { + super(t); + } + + public DerivedMetricsTypeSerializer() { + this(null); + } + + @Override + public void serialize(DerivedMetricsType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DerivedMetricsType fromValue(String value) { + return new DerivedMetricsType(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index b307445fc2c..5cef0618e18 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -1134,6 +1134,18 @@ "tag": "Logs Restriction Queries", "operationId": "CreateRestrictionQuery" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"id\": \"test.derived.{{ unique_lower_alnum }}\",\n \"type\": \"derived_metrics\",\n \"attributes\": {\n \"definition\": {\n \"formula\": \"a\",\n \"queries\": [{\"data_source\": \"metrics\", \"name\": \"a\", \"query\": \"avg:system.cpu.user{*}\"}]\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"derived_metric\" in the system", + "key": "derived_metric", + "tag": "Metrics", + "operationId": "CreateDerivedMetric" + }, { "parameters": [ { 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 2d187a673ec..1b228ebeae8 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 @@ -40,6 +40,36 @@ Feature: Metrics When the request is sent Then the response status is 404 Not Found + @team:ddoghq/metrics-experience + Scenario: Create a derived metric returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "CreateDerivedMetric" request + And body with value {"data": {"attributes": {"definition": {"formula": "a", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "1invalid.metric", "type": "derived_metrics"}} + When the request is sent + Then the response status is 400 Bad Request + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Create a derived metric returns "Conflict" response + Given a valid "appKeyAuth" key in the system + And there is a valid "derived_metric" in the system + And new "CreateDerivedMetric" request + And body with value {"data": {"attributes": {"definition": {"formula": "a", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "{{ derived_metric.data.id }}", "type": "derived_metrics"}} + When the request is sent + Then the response status is 409 Conflict + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Create a derived metric returns "Created" response + Given a valid "appKeyAuth" key in the system + And new "CreateDerivedMetric" request + And body with value {"data": {"attributes": {"definition": {"formula": "a", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "test.derived.{{ unique_lower_alnum }}", "type": "derived_metrics"}} + When the request is sent + Then the response status is 201 Created + And the response "data.id" is equal to "test.derived.{{ unique_lower_alnum }}" + And the response "data.type" is equal to "derived_metrics" + And the response "data.attributes.definition.formula" is equal to "a" + @generated @skip @team:ddoghq/metrics-experience Scenario: Create a tag configuration returns "Bad Request" response Given a valid "appKeyAuth" key in the system @@ -142,6 +172,24 @@ Feature: Metrics When the request is sent Then the response status is 400 Bad Request + @team:ddoghq/metrics-experience + Scenario: Delete a derived metric returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "DeleteDerivedMetric" request + And request contains "metric_name" parameter with value "1invalid.metric" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Delete a derived metric returns "No Content" response + Given a valid "appKeyAuth" key in the system + And there is a valid "derived_metric" in the system + And new "DeleteDerivedMetric" request + And request contains "metric_name" parameter from "derived_metric.data.id" + When the request is sent + Then the response status is 204 No Content + @generated @skip @team:ddoghq/metrics-experience Scenario: Delete a historical metrics configuration returns "Bad Request" response Given a valid "appKeyAuth" key in the system @@ -284,6 +332,36 @@ Feature: Metrics When the request is sent Then the response status is 422 Unprocessable Entity + @team:ddoghq/metrics-experience + Scenario: Get a derived metric returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "GetDerivedMetric" request + And request contains "metric_name" parameter with value "1invalid.metric" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Get a derived metric returns "Not Found" response + Given a valid "appKeyAuth" key in the system + And new "GetDerivedMetric" request + And request contains "metric_name" parameter with value "test.derived.missing.{{ unique_lower_alnum }}" + When the request is sent + Then the response status is 404 Not Found + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Get a derived metric returns "OK" response + Given a valid "appKeyAuth" key in the system + And there is a valid "derived_metric" in the system + And new "GetDerivedMetric" request + And request contains "metric_name" parameter from "derived_metric.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "derived_metric.data.id" + And the response "data.type" is equal to "derived_metrics" + And the response "data.attributes.definition.formula" is equal to "a" + @generated @skip @team:ddoghq/metrics-experience Scenario: Get a historical metrics configuration returns "Bad Request" response Given a valid "appKeyAuth" key in the system @@ -1075,6 +1153,39 @@ Feature: Metrics Then the response status is 200 OK And the response "data.type" is equal to "timeseries_response" + @team:ddoghq/metrics-experience + Scenario: Update a derived metric returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "UpdateDerivedMetric" request + And request contains "metric_name" parameter with value "test.derived.{{ unique_lower_alnum }}" + And body with value {"data": {"attributes": {"definition": {"formula": "a", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "test.derived.mismatch.{{ unique_lower_alnum }}", "type": "derived_metrics"}} + When the request is sent + Then the response status is 400 Bad Request + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Update a derived metric returns "Not Found" response + Given a valid "appKeyAuth" key in the system + And new "UpdateDerivedMetric" request + And request contains "metric_name" parameter with value "test.derived.missing.{{ unique_lower_alnum }}" + And body with value {"data": {"attributes": {"definition": {"formula": "a", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "test.derived.missing.{{ unique_lower_alnum }}", "type": "derived_metrics"}} + When the request is sent + Then the response status is 404 Not Found + And the response "errors" has length 1 + + @team:ddoghq/metrics-experience + Scenario: Update a derived metric returns "OK" response + Given a valid "appKeyAuth" key in the system + And there is a valid "derived_metric" in the system + And new "UpdateDerivedMetric" request + And request contains "metric_name" parameter from "derived_metric.data.id" + And body with value {"data": {"attributes": {"definition": {"formula": "a * 2", "queries": [{"data_source": "metrics", "name": "a", "query": "avg:system.cpu.user{*}"}]}}, "id": "{{ derived_metric.data.id }}", "type": "derived_metrics"}} + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "derived_metric.data.id" + And the response "data.type" is equal to "derived_metrics" + And the response "data.attributes.definition.formula" is equal to "a * 2" + @generated @skip @team:ddoghq/metrics-experience Scenario: Update a tag configuration 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 8b44c941575..96457f3ccc4 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 @@ -6085,6 +6085,37 @@ "type": "unsafe" } }, + "CreateDerivedMetric": { + "tag": "Metrics", + "undo": { + "operationId": "DeleteDerivedMetric", + "parameters": [ + { + "name": "metric_name", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteDerivedMetric": { + "tag": "Metrics", + "undo": { + "type": "idempotent" + } + }, + "GetDerivedMetric": { + "tag": "Metrics", + "undo": { + "type": "safe" + } + }, + "UpdateDerivedMetric": { + "tag": "Metrics", + "undo": { + "type": "idempotent" + } + }, "CreateHistoricalMetricsConfiguration": { "tag": "Metrics", "undo": { diff --git a/src/test/resources/generated-test/test-runner-data/manifest.json b/src/test/resources/generated-test/test-runner-data/manifest.json index b9b66fc3b14..00fd50eb2cc 100644 --- a/src/test/resources/generated-test/test-runner-data/manifest.json +++ b/src/test/resources/generated-test/test-runner-data/manifest.json @@ -7273,6 +7273,27 @@ "scenario": "Configure tags for multiple metrics returns \"Accepted\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/create-a-derived-metric-returns-bad-request-response.json", + "scenario": "Create a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/create-a-derived-metric-returns-conflict-response.json", + "scenario": "Create a derived metric returns \"Conflict\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/create-a-derived-metric-returns-created-response.json", + "scenario": "Create a derived metric returns \"Created\" response", + "version": "v2" + }, { "feature": "Metrics", "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", @@ -7315,6 +7336,20 @@ "scenario": "Create a tag indexing rule with exclude_not_used_in_assets and exclude_tags_mode false returns \"Bad Request\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/delete-a-derived-metric-returns-bad-request-response.json", + "scenario": "Delete a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/delete-a-derived-metric-returns-no-content-response.json", + "scenario": "Delete a derived metric returns \"No Content\" response", + "version": "v2" + }, { "feature": "Metrics", "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", @@ -7336,6 +7371,27 @@ "scenario": "Delete a tag indexing rule returns \"No Content\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/get-a-derived-metric-returns-bad-request-response.json", + "scenario": "Get a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/get-a-derived-metric-returns-not-found-response.json", + "scenario": "Get a derived metric returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/get-a-derived-metric-returns-ok-response.json", + "scenario": "Get a derived metric returns \"OK\" response", + "version": "v2" + }, { "feature": "Metrics", "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", @@ -7756,6 +7812,27 @@ "scenario": "Timeseries cross product query with spans data source returns \"OK\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/update-a-derived-metric-returns-bad-request-response.json", + "scenario": "Update a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/update-a-derived-metric-returns-not-found-response.json", + "scenario": "Update a derived metric returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", + "file": "v2/metrics/update-a-derived-metric-returns-ok-response.json", + "scenario": "Update a derived metric returns \"OK\" response", + "version": "v2" + }, { "feature": "Metrics", "feature_file": "../../com/datadog/api/client/v2/api/metrics.feature", diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-bad-request-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 00000000000..34328a1a83d --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-bad-request-response.json @@ -0,0 +1,43 @@ +{ + "api": "Metrics", + "expected_status": 400, + "feature": "Metrics", + "id": "v2/Metrics/Create a derived metric returns \"Bad Request\" response", + "operation_id": "CreateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "1invalid.metric", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/metrics/derived-metrics" + }, + "scenario": "Create a derived metric returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-conflict-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-conflict-response.json new file mode 100644 index 00000000000..4c025dbe1e3 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-conflict-response.json @@ -0,0 +1,43 @@ +{ + "api": "Metrics", + "expected_status": 409, + "feature": "Metrics", + "id": "v2/Metrics/Create a derived metric returns \"Conflict\" response", + "operation_id": "CreateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "{{ derived_metric.data.id }}", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/metrics/derived-metrics" + }, + "scenario": "Create a derived metric returns \"Conflict\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-created-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-created-response.json new file mode 100644 index 00000000000..cd8103cfcd9 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-created-response.json @@ -0,0 +1,43 @@ +{ + "api": "Metrics", + "expected_status": 201, + "feature": "Metrics", + "id": "v2/Metrics/Create a derived metric returns \"Created\" response", + "operation_id": "CreateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.{{ unique_lower_alnum }}", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/metrics/derived-metrics" + }, + "scenario": "Create a derived metric returns \"Created\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-bad-request-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 00000000000..5be957f740e --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-bad-request-response.json @@ -0,0 +1,35 @@ +{ + "api": "Metrics", + "expected_status": 400, + "feature": "Metrics", + "id": "v2/Metrics/Delete a derived metric returns \"Bad Request\" response", + "operation_id": "DeleteDerivedMetric", + "request": { + "body": null, + "content_type": null, + "method": "DELETE", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "1invalid.metric" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Delete a derived metric returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-no-content-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-no-content-response.json new file mode 100644 index 00000000000..11042c6cf94 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-no-content-response.json @@ -0,0 +1,35 @@ +{ + "api": "Metrics", + "expected_status": 204, + "feature": "Metrics", + "id": "v2/Metrics/Delete a derived metric returns \"No Content\" response", + "operation_id": "DeleteDerivedMetric", + "request": { + "body": null, + "content_type": null, + "method": "DELETE", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "derived_metric.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Delete a derived metric returns \"No Content\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-bad-request-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 00000000000..8db0a25188a --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-bad-request-response.json @@ -0,0 +1,35 @@ +{ + "api": "Metrics", + "expected_status": 400, + "feature": "Metrics", + "id": "v2/Metrics/Get a derived metric returns \"Bad Request\" response", + "operation_id": "GetDerivedMetric", + "request": { + "body": null, + "content_type": null, + "method": "GET", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "1invalid.metric" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Get a derived metric returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-not-found-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-not-found-response.json new file mode 100644 index 00000000000..f7f4ee1c2b3 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-not-found-response.json @@ -0,0 +1,35 @@ +{ + "api": "Metrics", + "expected_status": 404, + "feature": "Metrics", + "id": "v2/Metrics/Get a derived metric returns \"Not Found\" response", + "operation_id": "GetDerivedMetric", + "request": { + "body": null, + "content_type": null, + "method": "GET", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "test.derived.missing.{{ unique_lower_alnum }}" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Get a derived metric returns \"Not Found\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-ok-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-ok-response.json new file mode 100644 index 00000000000..8236b77d57d --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-ok-response.json @@ -0,0 +1,35 @@ +{ + "api": "Metrics", + "expected_status": 200, + "feature": "Metrics", + "id": "v2/Metrics/Get a derived metric returns \"OK\" response", + "operation_id": "GetDerivedMetric", + "request": { + "body": null, + "content_type": null, + "method": "GET", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "derived_metric.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Get a derived metric returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-bad-request-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 00000000000..c4fd70b8ae5 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-bad-request-response.json @@ -0,0 +1,60 @@ +{ + "api": "Metrics", + "expected_status": 400, + "feature": "Metrics", + "id": "v2/Metrics/Update a derived metric returns \"Bad Request\" response", + "operation_id": "UpdateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.mismatch.{{ unique_lower_alnum }}", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "test.derived.{{ unique_lower_alnum }}" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Update a derived metric returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-not-found-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-not-found-response.json new file mode 100644 index 00000000000..915ea92f144 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-not-found-response.json @@ -0,0 +1,60 @@ +{ + "api": "Metrics", + "expected_status": 404, + "feature": "Metrics", + "id": "v2/Metrics/Update a derived metric returns \"Not Found\" response", + "operation_id": "UpdateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.missing.{{ unique_lower_alnum }}", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "test.derived.missing.{{ unique_lower_alnum }}" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Update a derived metric returns \"Not Found\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-ok-response.json b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-ok-response.json new file mode 100644 index 00000000000..c68ad50f0d4 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-ok-response.json @@ -0,0 +1,60 @@ +{ + "api": "Metrics", + "expected_status": 200, + "feature": "Metrics", + "id": "v2/Metrics/Update a derived metric returns \"OK\" response", + "operation_id": "UpdateDerivedMetric", + "request": { + "body": { + "schema": { + "format": null, + "ref": "DerivedMetricCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a * 2", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "{{ derived_metric.data.id }}", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "metric_name", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "derived_metric.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/metrics/derived-metrics/{metric_name}" + }, + "scenario": "Update a derived metric returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-server-data/v2/metrics.json b/src/test/resources/generated-test/test-server-data/v2/metrics.json index d7e161a016b..255cdd7eea9 100644 --- a/src/test/resources/generated-test/test-server-data/v2/metrics.json +++ b/src/test/resources/generated-test/test-server-data/v2/metrics.json @@ -131,6 +131,232 @@ "scenario": "Configure tags for multiple metrics returns \"Accepted\" response", "version": "v2" }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:42.783Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "1invalid.metric", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"metric name must start with a letter and only contain letters, numbers, dots, and underscores\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Create a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:45.093Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testcreateaderivedmetricreturnsconflictresponse1791920325", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"test.derived.testcreateaderivedmetricreturnsconflictresponse1791920325\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testcreateaderivedmetricreturnsconflictresponse1791920325", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"A generated metric named \\\"test.derived.testcreateaderivedmetricreturnsconflictresponse1791920325\\\" already exists in this organization. Delete it or choose a different name.\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Conflict", + "status": 409 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/test.derived.testcreateaderivedmetricreturnsconflictresponse1791920325", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a derived metric returns \"Conflict\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:45.914Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testcreateaderivedmetricreturnscreatedresponse1791920325", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"test.derived.testcreateaderivedmetricreturnscreatedresponse1791920325\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/test.derived.testcreateaderivedmetricreturnscreatedresponse1791920325", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a derived metric returns \"Created\" response", + "version": "v2" + }, { "feature": "Metrics", "frozen_at": "2022-05-12T11:27:30.563Z", @@ -611,6 +837,127 @@ "scenario": "Create a tag indexing rule with exclude_not_used_in_assets and exclude_tags_mode false returns \"Bad Request\" response", "version": "v2" }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:46.452Z", + "interactions": [ + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/1invalid.metric", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"metric name must start with a letter and only contain letters, numbers, dots, and underscores\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Delete a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:46.687Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testdeleteaderivedmetricreturnsnocontentresponse1791920326", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"test.derived.testdeleteaderivedmetricreturnsnocontentresponse1791920326\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/test.derived.testdeleteaderivedmetricreturnsnocontentresponse1791920326", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/test.derived.testdeleteaderivedmetricreturnsnocontentresponse1791920326", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Delete a derived metric returns \"No Content\" response", + "version": "v2" + }, { "feature": "Metrics", "frozen_at": "2022-05-12T11:26:28.844Z", @@ -661,30 +1008,150 @@ "value": { "data": { "attributes": { - "metric_type": "gauge", + "metric_type": "gauge", + "tags": [ + "app", + "datacenter", + "TestDeleteatagconfigurationreturnsNoContentresponse1652354788" + ] + }, + "id": "TestDeleteatagconfigurationreturnsNoContentresponse1652354788", + "type": "manage_tags" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"type\":\"manage_tags\",\"id\":\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788\",\"attributes\":{\"tags\":[\"datacenter\",\"app\",\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788\"],\"created_at\":\"2022-05-12T11:26:33.849417+00:00\",\"modified_at\":\"2022-05-12T11:26:33.849417+00:00\",\"metric_type\":\"gauge\",\"aggregations\":[{\"space\":\"avg\",\"time\":\"avg\"}]}}}" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\": [\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788 not found\"]}" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "Not Found", + "status": 404 + } + } + ], + "scenario": "Delete a tag configuration returns \"No Content\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-06-04T16:39:36.667Z", + "interactions": [ + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/tag-indexing-rules/not-a-valid-uuid", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"Invalid tag indexing rule ID format\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Delete a tag indexing rule returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-06-04T16:39:36.727Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "metric_name_matches": [ + "dd.TestDeleteatagindexingrulereturnsNoContentresponse1780591176.*" + ], + "name": "TestDeleteatagindexingrulereturnsNoContentresponse1780591176", "tags": [ - "app", - "datacenter", - "TestDeleteatagconfigurationreturnsNoContentresponse1652354788" + "env", + "service" ] }, - "id": "TestDeleteatagconfigurationreturnsNoContentresponse1652354788", - "type": "manage_tags" + "type": "tag_indexing_rules" } } }, "content_type": "application/json", "method": "POST", - "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "path": "/api/v2/metrics/tag-indexing-rules", "query": [] }, "response": { "body": { "encoding": "text", - "value": "{\"data\":{\"type\":\"manage_tags\",\"id\":\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788\",\"attributes\":{\"tags\":[\"datacenter\",\"app\",\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788\"],\"created_at\":\"2022-05-12T11:26:33.849417+00:00\",\"modified_at\":\"2022-05-12T11:26:33.849417+00:00\",\"metric_type\":\"gauge\",\"aggregations\":[{\"space\":\"avg\",\"time\":\"avg\"}]}}}" + "value": "{\"data\":{\"id\":\"223d99dd-9c0a-4181-82b7-53d234bf5b26\",\"type\":\"tag_indexing_rules\",\"attributes\":{\"created_at\":\"2026-06-04T16:39:36.77795Z\",\"created_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"exclude_tags_mode\":false,\"metric_name_matches\":[\"dd.TestDeleteatagindexingrulereturnsNoContentresponse1780591176.*\"],\"modified_at\":\"2026-06-04T16:39:36.77795Z\",\"modified_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"TestDeleteatagindexingrulereturnsNoContentresponse1780591176\",\"options\":{\"version\":1,\"data\":{\"override_previous_rules\":false,\"manage_preexisting_metrics\":true}},\"rule_order\":1,\"tags\":[\"env\",\"service\"]}}}" }, "headers": { - "content-type": "application/json" + "content-type": "application/vnd.api+json" }, "reason": "Created", "status": 201 @@ -698,7 +1165,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "path": "/api/v2/metrics/tag-indexing-rules/223d99dd-9c0a-4181-82b7-53d234bf5b26", "query": [] }, "response": { @@ -719,28 +1186,26 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/metrics/TestDeleteatagconfigurationreturnsNoContentresponse1652354788/tags", + "path": "/api/v2/metrics/tag-indexing-rules/223d99dd-9c0a-4181-82b7-53d234bf5b26", "query": [] }, "response": { "body": { "encoding": "text", - "value": "{\"errors\": [\"TestDeleteatagconfigurationreturnsNoContentresponse1652354788 not found\"]}" - }, - "headers": { - "content-type": "application/json" + "value": "" }, - "reason": "Not Found", - "status": 404 + "headers": {}, + "reason": "No Content", + "status": 204 } } ], - "scenario": "Delete a tag configuration returns \"No Content\" response", + "scenario": "Delete a tag indexing rule returns \"No Content\" response", "version": "v2" }, { "feature": "Metrics", - "frozen_at": "2026-06-04T16:39:36.667Z", + "frozen_at": "2026-10-13T19:38:47.504Z", "interactions": [ { "request": { @@ -749,14 +1214,14 @@ "value": null }, "content_type": "", - "method": "DELETE", - "path": "/api/v2/metrics/tag-indexing-rules/not-a-valid-uuid", + "method": "GET", + "path": "/api/v2/metrics/derived-metrics/1invalid.metric", "query": [] }, "response": { "body": { "encoding": "text", - "value": "{\"errors\":[\"Invalid tag indexing rule ID format\"]}" + "value": "{\"errors\":[\"metric name must start with a letter and only contain letters, numbers, dots, and underscores\"]}" }, "headers": { "content-type": "application/vnd.api+json" @@ -766,12 +1231,43 @@ } } ], - "scenario": "Delete a tag indexing rule returns \"Bad Request\" response", + "scenario": "Get a derived metric returns \"Bad Request\" response", "version": "v2" }, { "feature": "Metrics", - "frozen_at": "2026-06-04T16:39:36.727Z", + "frozen_at": "2026-10-13T19:38:47.745Z", + "interactions": [ + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "GET", + "path": "/api/v2/metrics/derived-metrics/test.derived.missing.testgetaderivedmetricreturnsnotfoundresponse1791920327", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"Not Found\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Not Found", + "status": 404 + } + } + ], + "scenario": "Get a derived metric returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:47.979Z", "interactions": [ { "request": { @@ -780,28 +1276,31 @@ "value": { "data": { "attributes": { - "metric_name_matches": [ - "dd.TestDeleteatagindexingrulereturnsNoContentresponse1780591176.*" - ], - "name": "TestDeleteatagindexingrulereturnsNoContentresponse1780591176", - "tags": [ - "env", - "service" - ] + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } }, - "type": "tag_indexing_rules" + "id": "test.derived.testgetaderivedmetricreturnsokresponse1791920327", + "type": "derived_metrics" } } }, "content_type": "application/json", "method": "POST", - "path": "/api/v2/metrics/tag-indexing-rules", + "path": "/api/v2/metrics/derived-metrics", "query": [] }, "response": { "body": { "encoding": "text", - "value": "{\"data\":{\"id\":\"223d99dd-9c0a-4181-82b7-53d234bf5b26\",\"type\":\"tag_indexing_rules\",\"attributes\":{\"created_at\":\"2026-06-04T16:39:36.77795Z\",\"created_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"exclude_tags_mode\":false,\"metric_name_matches\":[\"dd.TestDeleteatagindexingrulereturnsNoContentresponse1780591176.*\"],\"modified_at\":\"2026-06-04T16:39:36.77795Z\",\"modified_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"TestDeleteatagindexingrulereturnsNoContentresponse1780591176\",\"options\":{\"version\":1,\"data\":{\"override_previous_rules\":false,\"manage_preexisting_metrics\":true}},\"rule_order\":1,\"tags\":[\"env\",\"service\"]}}}" + "value": "{\"data\":{\"id\":\"test.derived.testgetaderivedmetricreturnsokresponse1791920327\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" }, "headers": { "content-type": "application/vnd.api+json" @@ -817,18 +1316,20 @@ "value": null }, "content_type": "", - "method": "DELETE", - "path": "/api/v2/metrics/tag-indexing-rules/223d99dd-9c0a-4181-82b7-53d234bf5b26", + "method": "GET", + "path": "/api/v2/metrics/derived-metrics/test.derived.testgetaderivedmetricreturnsokresponse1791920327", "query": [] }, "response": { "body": { "encoding": "text", - "value": "" + "value": "{\"data\":{\"id\":\"test.derived.testgetaderivedmetricreturnsokresponse1791920327\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" }, - "headers": {}, - "reason": "No Content", - "status": 204 + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 } }, { @@ -839,7 +1340,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/metrics/tag-indexing-rules/223d99dd-9c0a-4181-82b7-53d234bf5b26", + "path": "/api/v2/metrics/derived-metrics/test.derived.testgetaderivedmetricreturnsokresponse1791920327", "query": [] }, "response": { @@ -853,7 +1354,7 @@ } } ], - "scenario": "Delete a tag indexing rule returns \"No Content\" response", + "scenario": "Get a derived metric returns \"OK\" response", "version": "v2" }, { @@ -4562,6 +5063,211 @@ "scenario": "Timeseries cross product query with spans data source returns \"OK\" response", "version": "v2" }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:48.794Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.mismatch.testupdateaderivedmetricreturnsbadrequestresponse1791920328", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "path": "/api/v2/metrics/derived-metrics/test.derived.testupdateaderivedmetricreturnsbadrequestresponse1791920328", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"invalid derived metric request body\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Update a derived metric returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:49.048Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.missing.testupdateaderivedmetricreturnsnotfoundresponse1791920329", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "path": "/api/v2/metrics/derived-metrics/test.derived.missing.testupdateaderivedmetricreturnsnotfoundresponse1791920329", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[\"Not Found\"]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Not Found", + "status": 404 + } + } + ], + "scenario": "Update a derived metric returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Metrics", + "frozen_at": "2026-10-13T19:38:49.305Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testupdateaderivedmetricreturnsokresponse1791920329", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/metrics/derived-metrics", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"test.derived.testupdateaderivedmetricreturnsokresponse1791920329\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "definition": { + "formula": "a * 2", + "queries": [ + { + "data_source": "metrics", + "name": "a", + "query": "avg:system.cpu.user{*}" + } + ] + } + }, + "id": "test.derived.testupdateaderivedmetricreturnsokresponse1791920329", + "type": "derived_metrics" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "path": "/api/v2/metrics/derived-metrics/test.derived.testupdateaderivedmetricreturnsokresponse1791920329", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"test.derived.testupdateaderivedmetricreturnsokresponse1791920329\",\"type\":\"derived_metrics\",\"attributes\":{\"definition\":{\"formula\":\"a * 2\",\"queries\":[{\"data_source\":\"metrics\",\"name\":\"a\",\"query\":\"avg:system.cpu.user{*}\"}]}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/metrics/derived-metrics/test.derived.testupdateaderivedmetricreturnsokresponse1791920329", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Update a derived metric returns \"OK\" response", + "version": "v2" + }, { "feature": "Metrics", "frozen_at": "2022-05-12T11:19:32.360Z",