diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8e540e2cff55..10cbce5a5e5a 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.rb b/examples/v2/metrics/CreateDerivedMetric.rb new file mode 100644 index 000000000000..04a388d9d749 --- /dev/null +++ b/examples/v2/metrics/CreateDerivedMetric.rb @@ -0,0 +1,27 @@ +# Create a derived metric returns "Created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::MetricsAPI.new + +body = DatadogAPIClient::V2::DerivedMetricCreateRequest.new({ + data: DatadogAPIClient::V2::DerivedMetricCreateData.new({ + attributes: DatadogAPIClient::V2::DerivedMetricAttributes.new({ + definition: DatadogAPIClient::V2::DerivedMetricDefinition.new({ + formula: "a", + queries: [ + DatadogAPIClient::V2::DerivedMetricQuery.new({ + data_source: "metrics", + name: "a", + query: "avg:system.cpu.user{*}", + }), + ], + }), + }), + id: "test.derived.examplemetric", + type: DatadogAPIClient::V2::DerivedMetricsType::DERIVED_METRICS, + }), +}) +p api_instance.create_derived_metric(body) diff --git a/examples/v2/metrics/DeleteDerivedMetric.rb b/examples/v2/metrics/DeleteDerivedMetric.rb new file mode 100644 index 000000000000..77613df8471d --- /dev/null +++ b/examples/v2/metrics/DeleteDerivedMetric.rb @@ -0,0 +1,11 @@ +# Delete a derived metric returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::MetricsAPI.new + +# there is a valid "derived_metric" in the system +DERIVED_METRIC_DATA_ID = ENV["DERIVED_METRIC_DATA_ID"] +api_instance.delete_derived_metric(DERIVED_METRIC_DATA_ID) diff --git a/examples/v2/metrics/GetDerivedMetric.rb b/examples/v2/metrics/GetDerivedMetric.rb new file mode 100644 index 000000000000..c47af156be53 --- /dev/null +++ b/examples/v2/metrics/GetDerivedMetric.rb @@ -0,0 +1,11 @@ +# Get a derived metric returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::MetricsAPI.new + +# there is a valid "derived_metric" in the system +DERIVED_METRIC_DATA_ID = ENV["DERIVED_METRIC_DATA_ID"] +p api_instance.get_derived_metric(DERIVED_METRIC_DATA_ID) diff --git a/examples/v2/metrics/UpdateDerivedMetric.rb b/examples/v2/metrics/UpdateDerivedMetric.rb new file mode 100644 index 000000000000..bad12a68b6fb --- /dev/null +++ b/examples/v2/metrics/UpdateDerivedMetric.rb @@ -0,0 +1,30 @@ +# Update a derived metric returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::MetricsAPI.new + +# there is a valid "derived_metric" in the system +DERIVED_METRIC_DATA_ID = ENV["DERIVED_METRIC_DATA_ID"] + +body = DatadogAPIClient::V2::DerivedMetricCreateRequest.new({ + data: DatadogAPIClient::V2::DerivedMetricCreateData.new({ + attributes: DatadogAPIClient::V2::DerivedMetricAttributes.new({ + definition: DatadogAPIClient::V2::DerivedMetricDefinition.new({ + formula: "a * 2", + queries: [ + DatadogAPIClient::V2::DerivedMetricQuery.new({ + data_source: "metrics", + name: "a", + query: "avg:system.cpu.user{*}", + }), + ], + }), + }), + id: DERIVED_METRIC_DATA_ID, + type: DatadogAPIClient::V2::DerivedMetricsType::DERIVED_METRICS, + }), +}) +p api_instance.update_derived_metric(DERIVED_METRIC_DATA_ID, body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 1377d926590b..adc41071f962 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -4948,6 +4948,19 @@ "v2.CreateBulkTagsMetricsConfiguration" => { "body" => "MetricBulkTagConfigCreateRequest", }, + "v2.CreateDerivedMetric" => { + "body" => "DerivedMetricCreateRequest", + }, + "v2.DeleteDerivedMetric" => { + "metric_name" => "String", + }, + "v2.GetDerivedMetric" => { + "metric_name" => "String", + }, + "v2.UpdateDerivedMetric" => { + "metric_name" => "String", + "body" => "DerivedMetricCreateRequest", + }, "v2.CreateHistoricalMetricsConfiguration" => { "body" => "HistoricalMetricsConfigurationCreateRequest", }, diff --git a/features/v2/given.json b/features/v2/given.json index b307445fc2cc..5cef0618e18a 100644 --- a/features/v2/given.json +++ b/features/v2/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/features/v2/metrics.feature b/features/v2/metrics.feature index 2d187a673ecc..1b228ebeae8f 100644 --- a/features/v2/metrics.feature +++ b/features/v2/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/features/v2/undo.json b/features/v2/undo.json index 8b44c9415758..96457f3ccc4c 100644 --- a/features/v2/undo.json +++ b/features/v2/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/generated-test/test-runner-data/manifest.json b/generated-test/test-runner-data/manifest.json index b761a83eefcc..f8e9565cbc3e 100644 --- a/generated-test/test-runner-data/manifest.json +++ b/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/metrics.feature", @@ -7336,6 +7371,27 @@ "scenario": "Delete a tag indexing rule returns \"No Content\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/metrics.feature", @@ -7756,6 +7812,27 @@ "scenario": "Timeseries cross product query with spans data source returns \"OK\" response", "version": "v2" }, + { + "feature": "Metrics", + "feature_file": "../../features/v2/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": "../../features/v2/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": "../../features/v2/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": "../../features/v2/metrics.feature", diff --git a/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-bad-request-response.json b/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 000000000000..34328a1a83da --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-conflict-response.json b/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-conflict-response.json new file mode 100644 index 000000000000..4c025dbe1e34 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-created-response.json b/generated-test/test-runner-data/v2/metrics/create-a-derived-metric-returns-created-response.json new file mode 100644 index 000000000000..cd8103cfcd9a --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-bad-request-response.json b/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 000000000000..5be957f740e1 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-no-content-response.json b/generated-test/test-runner-data/v2/metrics/delete-a-derived-metric-returns-no-content-response.json new file mode 100644 index 000000000000..11042c6cf940 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-bad-request-response.json b/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 000000000000..8db0a25188a9 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-not-found-response.json b/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-not-found-response.json new file mode 100644 index 000000000000..f7f4ee1c2b30 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-ok-response.json b/generated-test/test-runner-data/v2/metrics/get-a-derived-metric-returns-ok-response.json new file mode 100644 index 000000000000..8236b77d57d9 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-bad-request-response.json b/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-bad-request-response.json new file mode 100644 index 000000000000..c4fd70b8ae50 --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-not-found-response.json b/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-not-found-response.json new file mode 100644 index 000000000000..915ea92f144b --- /dev/null +++ b/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/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-ok-response.json b/generated-test/test-runner-data/v2/metrics/update-a-derived-metric-returns-ok-response.json new file mode 100644 index 000000000000..c68ad50f0d41 --- /dev/null +++ b/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/generated-test/test-server-data/v2/metrics.json b/generated-test/test-server-data/v2/metrics.json index d7e161a016bd..255cdd7eea95 100644 --- a/generated-test/test-server-data/v2/metrics.json +++ b/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", diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index b6deb90e82d8..4869c55661d3 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3205,6 +3205,14 @@ def overrides "v2.deployment_rule_response_data_attributes_type" => "DeploymentRuleResponseDataAttributesType", "v2.deployment_rule_response_data_attributes_updated_by" => "DeploymentRuleResponseDataAttributesUpdatedBy", "v2.deployment_rules_options" => "DeploymentRulesOptions", + "v2.derived_metric_attributes" => "DerivedMetricAttributes", + "v2.derived_metric_create_data" => "DerivedMetricCreateData", + "v2.derived_metric_create_request" => "DerivedMetricCreateRequest", + "v2.derived_metric_data" => "DerivedMetricData", + "v2.derived_metric_definition" => "DerivedMetricDefinition", + "v2.derived_metric_query" => "DerivedMetricQuery", + "v2.derived_metric_response" => "DerivedMetricResponse", + "v2.derived_metrics_type" => "DerivedMetricsType", "v2.detach_case_request" => "DetachCaseRequest", "v2.detach_case_request_data" => "DetachCaseRequestData", "v2.detach_case_request_data_relationships" => "DetachCaseRequestDataRelationships", diff --git a/lib/datadog_api_client/v2/api/metrics_api.rb b/lib/datadog_api_client/v2/api/metrics_api.rb index 1f1d936538b8..bf290a94a38c 100644 --- a/lib/datadog_api_client/v2/api/metrics_api.rb +++ b/lib/datadog_api_client/v2/api/metrics_api.rb @@ -101,6 +101,75 @@ def create_bulk_tags_metrics_configuration_with_http_info(body, opts = {}) return data, status_code, headers end + # Create a derived metric. + # + # @see #create_derived_metric_with_http_info + def create_derived_metric(body, opts = {}) + data, _status_code, _headers = create_derived_metric_with_http_info(body, opts) + data + end + + # Create a derived metric. + # + # 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 [DerivedMetricCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(DerivedMetricResponse, Integer, Hash)>] DerivedMetricResponse data, response status code and response headers + def create_derived_metric_with_http_info(body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MetricsAPI.create_derived_metric ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling MetricsAPI.create_derived_metric" + end + # resource path + local_var_path = '/api/v2/metrics/derived-metrics' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'DerivedMetricResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :create_derived_metric, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MetricsAPI#create_derived_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Enable historical metrics ingestion. # # @see #create_historical_metrics_configuration_with_http_info @@ -482,6 +551,72 @@ def delete_bulk_tags_metrics_configuration_with_http_info(body, opts = {}) return data, status_code, headers end + # Delete a derived metric. + # + # @see #delete_derived_metric_with_http_info + def delete_derived_metric(metric_name, opts = {}) + delete_derived_metric_with_http_info(metric_name, opts) + nil + end + + # Delete a derived metric. + # + # Delete a derived metric by name. Idempotent: returns 204 regardless of whether the derived + # metric existed. Requires the `Manage Tags for Metrics` permission. + # + # @param metric_name [String] The name of the metric. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_derived_metric_with_http_info(metric_name, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MetricsAPI.delete_derived_metric ...' + end + # verify the required parameter 'metric_name' is set + if @api_client.config.client_side_validation && metric_name.nil? + fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.delete_derived_metric" + end + # resource path + local_var_path = '/api/v2/metrics/derived-metrics/{metric_name}'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :delete_derived_metric, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MetricsAPI#delete_derived_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a historical metrics configuration. # # @see #delete_historical_metrics_configuration_with_http_info @@ -857,6 +992,71 @@ def estimate_metrics_output_series_with_http_info(metric_name, opts = {}) return data, status_code, headers end + # Get a derived metric. + # + # @see #get_derived_metric_with_http_info + def get_derived_metric(metric_name, opts = {}) + data, _status_code, _headers = get_derived_metric_with_http_info(metric_name, opts) + data + end + + # Get a derived metric. + # + # Get the definition of a derived metric by name. + # + # @param metric_name [String] The name of the metric. + # @param opts [Hash] the optional parameters + # @return [Array<(DerivedMetricResponse, Integer, Hash)>] DerivedMetricResponse data, response status code and response headers + def get_derived_metric_with_http_info(metric_name, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MetricsAPI.get_derived_metric ...' + end + # verify the required parameter 'metric_name' is set + if @api_client.config.client_side_validation && metric_name.nil? + fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.get_derived_metric" + end + # resource path + local_var_path = '/api/v2/metrics/derived-metrics/{metric_name}'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DerivedMetricResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_derived_metric, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MetricsAPI#get_derived_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get a historical metrics configuration. # # @see #get_historical_metrics_configuration_with_http_info @@ -2070,6 +2270,79 @@ def submit_metrics_with_http_info(body, opts = {}) return data, status_code, headers end + # Update a derived metric. + # + # @see #update_derived_metric_with_http_info + def update_derived_metric(metric_name, body, opts = {}) + data, _status_code, _headers = update_derived_metric_with_http_info(metric_name, body, opts) + data + end + + # Update a derived metric. + # + # 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 metric_name [String] The name of the metric. + # @param body [DerivedMetricCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(DerivedMetricResponse, Integer, Hash)>] DerivedMetricResponse data, response status code and response headers + def update_derived_metric_with_http_info(metric_name, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MetricsAPI.update_derived_metric ...' + end + # verify the required parameter 'metric_name' is set + if @api_client.config.client_side_validation && metric_name.nil? + fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.update_derived_metric" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling MetricsAPI.update_derived_metric" + end + # resource path + local_var_path = '/api/v2/metrics/derived-metrics/{metric_name}'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'DerivedMetricResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_derived_metric, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MetricsAPI#update_derived_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update a tag configuration. # # @see #update_tag_configuration_with_http_info diff --git a/lib/datadog_api_client/v2/models/derived_metric_attributes.rb b/lib/datadog_api_client/v2/models/derived_metric_attributes.rb new file mode 100644 index 000000000000..154697f70c25 --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_attributes.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes of a derived metric. + class DerivedMetricAttributes + include BaseGenericModel + + # The definition of a derived metric as a formula over one or more queries. + attr_reader :definition + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'definition' => :'definition' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'definition' => :'DerivedMetricDefinition' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'definition') + self.definition = attributes[:'definition'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @definition.nil? + true + end + + # Custom attribute writer method with validation + # @param definition [Object] Object to be assigned + # @!visibility private + def definition=(definition) + if definition.nil? + fail ArgumentError, 'invalid value for "definition", definition cannot be nil.' + end + @definition = definition + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + definition == o.definition && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [definition, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_create_data.rb b/lib/datadog_api_client/v2/models/derived_metric_create_data.rb new file mode 100644 index 000000000000..878afc674096 --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_create_data.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data object for creating or updating a derived metric. + class DerivedMetricCreateData + include BaseGenericModel + + # Attributes of a derived metric. + attr_reader :attributes + + # The derived metric name used as the resource ID. + attr_reader :id + + # The derived metric resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'DerivedMetricAttributes', + :'id' => :'String', + :'type' => :'DerivedMetricsType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricCreateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_create_request.rb b/lib/datadog_api_client/v2/models/derived_metric_create_request.rb new file mode 100644 index 000000000000..9aed51ba86c3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_create_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request body for creating or updating a derived metric. + class DerivedMetricCreateRequest + include BaseGenericModel + + # Data object for creating or updating a derived metric. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'DerivedMetricCreateData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricCreateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_data.rb b/lib/datadog_api_client/v2/models/derived_metric_data.rb new file mode 100644 index 000000000000..8eb7ad14c3b0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_data.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A derived metric resource object. + class DerivedMetricData + include BaseGenericModel + + # Attributes of a derived metric. + attr_reader :attributes + + # The derived metric name used as the resource ID. + attr_reader :id + + # The derived metric resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'DerivedMetricAttributes', + :'id' => :'String', + :'type' => :'DerivedMetricsType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_definition.rb b/lib/datadog_api_client/v2/models/derived_metric_definition.rb new file mode 100644 index 000000000000..f23bb3f202ab --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_definition.rb @@ -0,0 +1,150 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The definition of a derived metric as a formula over one or more queries. + class DerivedMetricDefinition + include BaseGenericModel + + # The formula that combines the queries into the value of the derived metric. + attr_reader :formula + + # The list of queries referenced by the formula. + attr_reader :queries + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'formula' => :'formula', + :'queries' => :'queries' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'formula' => :'String', + :'queries' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricDefinition` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'formula') + self.formula = attributes[:'formula'] + end + + if attributes.key?(:'queries') + if (value = attributes[:'queries']).is_a?(Array) + self.queries = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @formula.nil? + return false if @queries.nil? + return false if @queries.length < 1 + true + end + + # Custom attribute writer method with validation + # @param formula [Object] Object to be assigned + # @!visibility private + def formula=(formula) + if formula.nil? + fail ArgumentError, 'invalid value for "formula", formula cannot be nil.' + end + @formula = formula + end + + # Custom attribute writer method with validation + # @param queries [Object] Object to be assigned + # @!visibility private + def queries=(queries) + if queries.nil? + fail ArgumentError, 'invalid value for "queries", queries cannot be nil.' + end + if queries.length < 1 + fail ArgumentError, 'invalid value for "queries", number of items must be greater than or equal to 1.' + end + @queries = queries + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + formula == o.formula && + queries == o.queries && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [formula, queries, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_query.rb b/lib/datadog_api_client/v2/models/derived_metric_query.rb new file mode 100644 index 000000000000..3e349182210b --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_query.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A single query used in the definition of a derived metric. + class DerivedMetricQuery + include BaseGenericModel + + # The data source that the query is run against. + attr_reader :data_source + + # The name used to reference this query from the formula. + attr_reader :name + + # The query string executed against the data source. + attr_reader :query + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data_source' => :'data_source', + :'name' => :'name', + :'query' => :'query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data_source' => :'String', + :'name' => :'String', + :'query' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricQuery` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data_source') + self.data_source = attributes[:'data_source'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'query') + self.query = attributes[:'query'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data_source.nil? + return false if @name.nil? + return false if @query.nil? + true + end + + # Custom attribute writer method with validation + # @param data_source [Object] Object to be assigned + # @!visibility private + def data_source=(data_source) + if data_source.nil? + fail ArgumentError, 'invalid value for "data_source", data_source cannot be nil.' + end + @data_source = data_source + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param query [Object] Object to be assigned + # @!visibility private + def query=(query) + if query.nil? + fail ArgumentError, 'invalid value for "query", query cannot be nil.' + end + @query = query + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data_source == o.data_source && + name == o.name && + query == o.query && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data_source, name, query, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metric_response.rb b/lib/datadog_api_client/v2/models/derived_metric_response.rb new file mode 100644 index 000000000000..f2b4cb2ebb8f --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metric_response.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response containing a single derived metric. + class DerivedMetricResponse + include BaseGenericModel + + # A derived metric resource object. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'DerivedMetricData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DerivedMetricResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/derived_metrics_type.rb b/lib/datadog_api_client/v2/models/derived_metrics_type.rb new file mode 100644 index 000000000000..eda70b84a1bf --- /dev/null +++ b/lib/datadog_api_client/v2/models/derived_metrics_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The derived metric resource type. + class DerivedMetricsType + include BaseEnumModel + + DERIVED_METRICS = "derived_metrics".freeze + end +end