From 5f3ee85e9863dbcfb162223e7ebac307636d049b Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 17:27:19 +0000 Subject: [PATCH 1/4] Add OpenAPI for Cloud Cost Management anomalies endpoints (#3320) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 403 ++++++++++++++++++ .../cloud-cost-management/GetCostAnomaly.rb | 8 + .../ListCostAnomalies.rb | 8 + features/scenarios_model_mapping.rb | 16 + features/v2/cloud_cost_management.feature | 38 ++ features/v2/undo.json | 12 + lib/datadog_api_client/configuration.rb | 2 + lib/datadog_api_client/inflector.rb | 8 + .../v2/api/cloud_cost_management_api.rb | 160 +++++++ .../v2/models/cost_anomalies_response.rb | 105 +++++ .../v2/models/cost_anomalies_response_data.rb | 165 +++++++ ...cost_anomalies_response_data_attributes.rb | 209 +++++++++ .../cost_anomalies_response_data_type.rb | 26 ++ .../v2/models/cost_anomaly.rb | 319 ++++++++++++++ .../v2/models/cost_anomaly_dismissal.rb | 207 +++++++++ .../v2/models/cost_anomaly_response.rb | 105 +++++ .../v2/models/cost_anomaly_response_data.rb | 165 +++++++ 17 files changed, 1956 insertions(+) create mode 100644 examples/v2/cloud-cost-management/GetCostAnomaly.rb create mode 100644 examples/v2/cloud-cost-management/ListCostAnomalies.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomalies_response.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomalies_response_data.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomalies_response_data_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomalies_response_data_type.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomaly.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomaly_dismissal.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomaly_response.rb create mode 100644 lib/datadog_api_client/v2/models/cost_anomaly_response_data.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5808b5f79644..4cefb983dbae 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -93,6 +93,13 @@ components: required: true schema: type: string + AnomalyID: + description: The UUID of the cost anomaly. + in: path + name: anomaly_id + required: true + schema: + type: string ApplicationKeyFilterCreatedAtEndParameter: description: Only include application keys created on or before the specified date. in: query @@ -15490,6 +15497,204 @@ components: type: string x-enum-varnames: - CUMULATIVE + CostAnomaliesResponse: + description: Response object containing a list of detected Cloud Cost Management anomalies and aggregated totals. + properties: + data: + $ref: "#/components/schemas/CostAnomaliesResponseData" + type: object + CostAnomaliesResponseData: + description: Resource wrapper for the list of cost anomalies and aggregated totals. + properties: + attributes: + $ref: "#/components/schemas/CostAnomaliesResponseDataAttributes" + id: + description: Static identifier of the cost anomalies collection resource. + example: anomalies + type: string + type: + $ref: "#/components/schemas/CostAnomaliesResponseDataType" + required: + - id + - type + - attributes + type: object + CostAnomaliesResponseDataAttributes: + description: Cost anomaly results and aggregated totals for the queried window. + properties: + anomalies: + description: The list of cost anomalies that match the request. + items: + $ref: "#/components/schemas/CostAnomaly" + type: array + avg_daily_anomalous_cost: + description: Average daily anomalous cost change across the queried window. + example: 625.375 + format: double + type: number + total_actual_cost: + description: Total actual cost spent across the queried window for the matching providers. + example: 3001.24 + format: double + type: number + total_anomalous_cost: + description: Sum of the anomalous cost change across all returned anomalies. + example: 1250.75 + format: double + type: number + total_count: + description: Total number of anomalies that match the request. + example: 1 + format: int64 + type: integer + required: + - anomalies + - total_count + - total_anomalous_cost + - total_actual_cost + - avg_daily_anomalous_cost + type: object + CostAnomaliesResponseDataType: + default: anomalies + description: Type of the cost anomalies collection resource. Must be `anomalies`. + enum: + - anomalies + example: anomalies + type: string + x-enum-varnames: + - ANOMALIES + CostAnomaly: + description: A single detected Cloud Cost Management anomaly. + properties: + actual_cost: + description: Actual cost incurred during the anomaly window. + example: 3001.24 + format: double + type: number + anomalous_cost_change: + description: Anomalous cost change relative to the expected baseline. + example: 1250.75 + format: double + type: number + anomaly_end: + description: Anomaly end timestamp in Unix milliseconds. + example: 1730429150000 + format: int64 + type: integer + anomaly_start: + description: Anomaly start timestamp in Unix milliseconds. + example: 1730259950000 + format: int64 + type: integer + correlated_tags: + $ref: "#/components/schemas/CostAnomalyCorrelatedTags" + dimensions: + $ref: "#/components/schemas/CostAnomalyDimensions" + dismissal: + $ref: "#/components/schemas/CostAnomalyDismissal" + max_cost: + description: Maximum cost observed during the anomaly window. + example: 5000.5 + format: double + type: number + provider: + description: Cloud or SaaS provider associated with the anomaly (for example `aws`, `gcp`, `azure`). + example: aws + type: string + query: + description: The metrics query that detected the anomaly. + example: sum:aws.cost.net.amortized{aws_cost_type IN (Usage,DiscountedUsage,SavingsPlanCoveredUsage) AND aws_product NOT IN (supportenterprise) AND service:"ec2"}.rollup(sum, daily) + type: string + uuid: + description: The unique identifier of the anomaly. + example: b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09 + type: string + required: + - uuid + - anomaly_start + - anomaly_end + - query + - dimensions + - correlated_tags + - anomalous_cost_change + - actual_cost + - max_cost + - provider + type: object + CostAnomalyCorrelatedTags: + additionalProperties: + description: The list of correlated values for the tag key. + items: + type: string + type: array + description: Map of correlated tag keys to the list of correlated tag values. + example: + region: + - us-east-1 + - us-west-2 + nullable: true + type: object + CostAnomalyDimensions: + additionalProperties: + description: The dimension value. + type: string + description: Map of cost dimension keys to their values for the anomaly grouping. + example: + service: ec2 + type: object + CostAnomalyDismissal: + description: Resolution metadata for an anomaly that has been dismissed. + properties: + cause: + description: Reason the anomaly was dismissed. + example: false_positive + type: string + dismissal_id: + description: Unique identifier of the dismissal record. + example: 12345678-1234-1234-1234-123456789abc + type: string + message: + description: Optional message explaining the dismissal. + example: This was expected due to planned infrastructure changes. + type: string + updated_at: + description: Timestamp of the last dismissal update in Unix milliseconds. + example: 1730344150000 + format: int64 + type: integer + updated_by: + description: Identifier of the user that last updated the dismissal. + example: user@example.com + type: string + required: + - dismissal_id + - cause + - message + - updated_at + - updated_by + type: object + CostAnomalyResponse: + description: Response object containing a single Cloud Cost Management anomaly. + properties: + data: + $ref: "#/components/schemas/CostAnomalyResponseData" + type: object + CostAnomalyResponseData: + description: Resource wrapper for a single cost anomaly. + properties: + attributes: + $ref: "#/components/schemas/CostAnomaly" + id: + description: The unique identifier of the anomaly. + example: b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09 + type: string + type: + $ref: "#/components/schemas/CostAnomaliesResponseDataType" + required: + - id + - type + - attributes + type: object CostAttributionAggregates: description: An array of available aggregates. items: @@ -95324,6 +95529,204 @@ paths: "x-permission": operator: OPEN permissions: [] + /api/v2/cost/anomalies: + get: + description: List detected Cloud Cost Management anomalies for the organization. + operationId: ListCostAnomalies + parameters: + - description: Start time as Unix milliseconds. Defaults to the start of the latest stable seven-day window. + in: query + name: start + required: false + schema: + example: 1730259950000 + format: int64 + type: integer + - description: End time as Unix milliseconds. Defaults to the end of the latest stable seven-day window. + in: query + name: end + required: false + schema: + example: 1730429150000 + format: int64 + type: integer + - description: 'Optional JSON object mapping cost tag keys to allowed values, for example `{"team":["payments"],"env":["prod"]}`. Filters match anomaly dimensions or correlated tags.' + in: query + name: filter + required: false + schema: + example: '{"team":["payments"]}' + type: string + - description: Minimum absolute anomalous cost change to include. Numeric value; defaults to `1`. + in: query + name: min_anomalous_threshold + required: false + schema: + example: "1.0" + type: string + - description: Minimum absolute actual cost to include. Numeric value; defaults to `0`. + in: query + name: min_cost_threshold + required: false + schema: + example: "0.0" + type: string + - description: Filter by resolution state. Use `none` for unresolved anomalies, `all` or `*` for resolved anomalies, or a comma-separated list of causes. + in: query + name: dismissal_cause + required: false + schema: + example: none + type: string + - description: Sort field. One of `start_date`, `end_date`, `duration`, `max_cost`, `anomalous_cost`, or `dismissal_date`. Defaults to `anomalous_cost`. + in: query + name: order_by + required: false + schema: + example: anomalous_cost + type: string + - description: Sort direction. One of `asc` or `desc`. Defaults to `desc`. + in: query + name: order + required: false + schema: + example: desc + type: string + - description: Maximum number of anomalies to return. Defaults to `200`. + in: query + name: limit + required: false + schema: + example: 200 + type: integer + - description: Pagination offset. Defaults to `0`. + in: query + name: offset + required: false + schema: + example: 0 + type: integer + - description: Optional repeated cloud or SaaS provider filters, such as `aws`, `gcp`, `azure`, `Oracle`, `datadog`, `OpenAI`, or `Anthropic`. + explode: true + in: query + name: provider_ids + required: false + schema: + items: + example: aws + type: string + type: array + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + anomalies: + - actual_cost: 3001.24 + anomalous_cost_change: 1250.75 + anomaly_end: 1730429150000 + anomaly_start: 1730259950000 + correlated_tags: + region: + - us-east-1 + - us-west-2 + dimensions: + service: ec2 + max_cost: 5000.5 + provider: aws + query: 'sum:aws.cost.net.amortized{aws_cost_type IN (Usage,DiscountedUsage,SavingsPlanCoveredUsage) AND aws_product NOT IN (supportenterprise) AND service:"ec2"}.rollup(sum, daily)' + uuid: b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09 + avg_daily_anomalous_cost: 625.375 + total_actual_cost: 3001.24 + total_anomalous_cost: 1250.75 + total_count: 1 + id: anomalies + type: anomalies + schema: + $ref: "#/components/schemas/CostAnomaliesResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: List cost anomalies + tags: + - Cloud Cost Management + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/cost/anomalies/{anomaly_id}: + get: + description: Get a detected Cloud Cost Management anomaly by UUID. + operationId: GetCostAnomaly + parameters: + - $ref: "#/components/parameters/AnomalyID" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + actual_cost: 3001.24 + anomalous_cost_change: 1250.75 + anomaly_end: 1730429150000 + anomaly_start: 1730259950000 + correlated_tags: + region: + - us-east-1 + - us-west-2 + dimensions: + service: ec2 + max_cost: 5000.5 + provider: aws + query: 'sum:aws.cost.net.amortized{aws_cost_type IN (Usage,DiscountedUsage,SavingsPlanCoveredUsage) AND aws_product NOT IN (supportenterprise) AND service:"ec2"}.rollup(sum, daily)' + uuid: b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09 + id: b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09 + type: anomalies + schema: + $ref: "#/components/schemas/CostAnomalyResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Get cost anomaly + tags: + - Cloud Cost Management + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/cost/arbitrary_rule: get: description: List all custom allocation rules - Retrieve a list of all custom allocation rules for the organization diff --git a/examples/v2/cloud-cost-management/GetCostAnomaly.rb b/examples/v2/cloud-cost-management/GetCostAnomaly.rb new file mode 100644 index 000000000000..37682284ff52 --- /dev/null +++ b/examples/v2/cloud-cost-management/GetCostAnomaly.rb @@ -0,0 +1,8 @@ +# Get cost anomaly returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_cost_anomaly".to_sym] = true +end +api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new +p api_instance.get_cost_anomaly("anomaly_id") diff --git a/examples/v2/cloud-cost-management/ListCostAnomalies.rb b/examples/v2/cloud-cost-management/ListCostAnomalies.rb new file mode 100644 index 000000000000..fbe626f3369a --- /dev/null +++ b/examples/v2/cloud-cost-management/ListCostAnomalies.rb @@ -0,0 +1,8 @@ +# List cost anomalies returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_cost_anomalies".to_sym] = true +end +api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new +p api_instance.list_cost_anomalies() diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 31b4961848f6..4f6619e89ece 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2101,6 +2101,22 @@ "page_size" => "Integer", "page_cursor" => "String", }, + "v2.ListCostAnomalies" => { + "start" => "Integer", + "_end" => "Integer", + "filter" => "String", + "min_anomalous_threshold" => "String", + "min_cost_threshold" => "String", + "dismissal_cause" => "String", + "order_by" => "String", + "order" => "String", + "limit" => "Integer", + "offset" => "Integer", + "provider_ids" => "Array", + }, + "v2.GetCostAnomaly" => { + "anomaly_id" => "String", + }, "v2.CreateCustomAllocationRule" => { "body" => "ArbitraryCostUpsertRequest", }, diff --git a/features/v2/cloud_cost_management.feature b/features/v2/cloud_cost_management.feature index bf9f695d40eb..9bab51741ef3 100644 --- a/features/v2/cloud_cost_management.feature +++ b/features/v2/cloud_cost_management.feature @@ -292,6 +292,30 @@ Feature: Cloud Cost Management And the response "data.attributes.configs[0].dataset_type" is equal to "amortized" And the response "data.attributes.configs[1].dataset_type" is equal to "actual" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get cost anomaly returns "Bad Request" response + Given operation "GetCostAnomaly" enabled + And new "GetCostAnomaly" request + And request contains "anomaly_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get cost anomaly returns "Not Found" response + Given operation "GetCostAnomaly" enabled + And new "GetCostAnomaly" request + And request contains "anomaly_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get cost anomaly returns "OK" response + Given operation "GetCostAnomaly" enabled + And new "GetCostAnomaly" request + And request contains "anomaly_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: Get custom allocation rule returns "OK" response Given new "GetCustomAllocationRule" request @@ -357,6 +381,20 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List cost anomalies returns "Bad Request" response + Given operation "ListCostAnomalies" enabled + And new "ListCostAnomalies" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List cost anomalies returns "OK" response + Given operation "ListCostAnomalies" enabled + And new "ListCostAnomalies" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: List custom allocation rule statuses returns "OK" response Given new "ListCustomAllocationRulesStatus" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 1ca1c2309ae4..b9805518e9df 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1265,6 +1265,18 @@ "type": "safe" } }, + "ListCostAnomalies": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "GetCostAnomaly": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "ListCustomAllocationRules": { "tag": "Cloud Cost Management", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index d12e66a43601..5f9e199c1b69 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -293,6 +293,8 @@ def initialize "v2.search_security_monitoring_histsignals": false, "v2.get_code_coverage_branch_summary": false, "v2.get_code_coverage_commit_summary": false, + "v2.get_cost_anomaly": false, + "v2.list_cost_anomalies": false, "v2.create_dashboard_secure_embed": false, "v2.delete_dashboard_secure_embed": false, "v2.get_dashboard_secure_embed": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index c8a70ed3c2fc..af1b2864eca4 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1982,6 +1982,14 @@ def overrides "v2.convert_job_results_to_signals_data_type" => "ConvertJobResultsToSignalsDataType", "v2.convert_job_results_to_signals_request" => "ConvertJobResultsToSignalsRequest", "v2.cost_aggregation_type" => "CostAggregationType", + "v2.cost_anomalies_response" => "CostAnomaliesResponse", + "v2.cost_anomalies_response_data" => "CostAnomaliesResponseData", + "v2.cost_anomalies_response_data_attributes" => "CostAnomaliesResponseDataAttributes", + "v2.cost_anomalies_response_data_type" => "CostAnomaliesResponseDataType", + "v2.cost_anomaly" => "CostAnomaly", + "v2.cost_anomaly_dismissal" => "CostAnomalyDismissal", + "v2.cost_anomaly_response" => "CostAnomalyResponse", + "v2.cost_anomaly_response_data" => "CostAnomalyResponseData", "v2.cost_attribution_aggregates_body" => "CostAttributionAggregatesBody", "v2.cost_attribution_type" => "CostAttributionType", "v2.cost_by_org" => "CostByOrg", diff --git a/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb b/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb index 02ae0914469b..8d28019cff2e 100644 --- a/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb +++ b/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb @@ -890,6 +890,77 @@ def get_budget_with_http_info(budget_id, opts = {}) return data, status_code, headers end + # Get cost anomaly. + # + # @see #get_cost_anomaly_with_http_info + def get_cost_anomaly(anomaly_id, opts = {}) + data, _status_code, _headers = get_cost_anomaly_with_http_info(anomaly_id, opts) + data + end + + # Get cost anomaly. + # + # Get a detected Cloud Cost Management anomaly by UUID. + # + # @param anomaly_id [String] The UUID of the cost anomaly. + # @param opts [Hash] the optional parameters + # @return [Array<(CostAnomalyResponse, Integer, Hash)>] CostAnomalyResponse data, response status code and response headers + def get_cost_anomaly_with_http_info(anomaly_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_cost_anomaly".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_cost_anomaly") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_cost_anomaly")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CloudCostManagementAPI.get_cost_anomaly ...' + end + # verify the required parameter 'anomaly_id' is set + if @api_client.config.client_side_validation && anomaly_id.nil? + fail ArgumentError, "Missing the required parameter 'anomaly_id' when calling CloudCostManagementAPI.get_cost_anomaly" + end + # resource path + local_var_path = '/api/v2/cost/anomalies/{anomaly_id}'.sub('{anomaly_id}', CGI.escape(anomaly_id.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] || 'CostAnomalyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_cost_anomaly, + :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: CloudCostManagementAPI#get_cost_anomaly\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get cost AWS CUR config. # # @see #get_cost_awscur_config_with_http_info @@ -1340,6 +1411,95 @@ def list_budgets_with_http_info(opts = {}) return data, status_code, headers end + # List cost anomalies. + # + # @see #list_cost_anomalies_with_http_info + def list_cost_anomalies(opts = {}) + data, _status_code, _headers = list_cost_anomalies_with_http_info(opts) + data + end + + # List cost anomalies. + # + # List detected Cloud Cost Management anomalies for the organization. + # + # @param opts [Hash] the optional parameters + # @option opts [Integer] :start Start time as Unix milliseconds. Defaults to the start of the latest stable seven-day window. + # @option opts [Integer] :_end End time as Unix milliseconds. Defaults to the end of the latest stable seven-day window. + # @option opts [String] :filter Optional JSON object mapping cost tag keys to allowed values, for example `{"team":["payments"],"env":["prod"]}`. Filters match anomaly dimensions or correlated tags. + # @option opts [String] :min_anomalous_threshold Minimum absolute anomalous cost change to include. Numeric value; defaults to `1`. + # @option opts [String] :min_cost_threshold Minimum absolute actual cost to include. Numeric value; defaults to `0`. + # @option opts [String] :dismissal_cause Filter by resolution state. Use `none` for unresolved anomalies, `all` or `*` for resolved anomalies, or a comma-separated list of causes. + # @option opts [String] :order_by Sort field. One of `start_date`, `end_date`, `duration`, `max_cost`, `anomalous_cost`, or `dismissal_date`. Defaults to `anomalous_cost`. + # @option opts [String] :order Sort direction. One of `asc` or `desc`. Defaults to `desc`. + # @option opts [Integer] :limit Maximum number of anomalies to return. Defaults to `200`. + # @option opts [Integer] :offset Pagination offset. Defaults to `0`. + # @option opts [Array] :provider_ids Optional repeated cloud or SaaS provider filters, such as `aws`, `gcp`, `azure`, `Oracle`, `datadog`, `OpenAI`, or `Anthropic`. + # @return [Array<(CostAnomaliesResponse, Integer, Hash)>] CostAnomaliesResponse data, response status code and response headers + def list_cost_anomalies_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_cost_anomalies".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_cost_anomalies") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_cost_anomalies")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CloudCostManagementAPI.list_cost_anomalies ...' + end + # resource path + local_var_path = '/api/v2/cost/anomalies' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil? + query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil? + query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil? + query_params[:'min_anomalous_threshold'] = opts[:'min_anomalous_threshold'] if !opts[:'min_anomalous_threshold'].nil? + query_params[:'min_cost_threshold'] = opts[:'min_cost_threshold'] if !opts[:'min_cost_threshold'].nil? + query_params[:'dismissal_cause'] = opts[:'dismissal_cause'] if !opts[:'dismissal_cause'].nil? + query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? + query_params[:'provider_ids'] = @api_client.build_collection_param(opts[:'provider_ids'], :multi) if !opts[:'provider_ids'].nil? + + # 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] || 'CostAnomaliesResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_cost_anomalies, + :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" + ) + new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER + + 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: CloudCostManagementAPI#list_cost_anomalies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List Cloud Cost Management AWS CUR configs. # # @see #list_cost_awscur_configs_with_http_info diff --git a/lib/datadog_api_client/v2/models/cost_anomalies_response.rb b/lib/datadog_api_client/v2/models/cost_anomalies_response.rb new file mode 100644 index 000000000000..dfee3d16e4de --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomalies_response.rb @@ -0,0 +1,105 @@ +=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 object containing a list of detected Cloud Cost Management anomalies and aggregated totals. + class CostAnomaliesResponse + include BaseGenericModel + + # Resource wrapper for the list of cost anomalies and aggregated totals. + attr_accessor :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' => :'CostAnomaliesResponseData' + } + 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::CostAnomaliesResponse` 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 + + # 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/cost_anomalies_response_data.rb b/lib/datadog_api_client/v2/models/cost_anomalies_response_data.rb new file mode 100644 index 000000000000..a77e1c88bc29 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomalies_response_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 + # Resource wrapper for the list of cost anomalies and aggregated totals. + class CostAnomaliesResponseData + include BaseGenericModel + + # Cost anomaly results and aggregated totals for the queried window. + attr_reader :attributes + + # Static identifier of the cost anomalies collection resource. + attr_reader :id + + # Type of the cost anomalies collection resource. Must be `anomalies`. + 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' => :'CostAnomaliesResponseDataAttributes', + :'id' => :'String', + :'type' => :'CostAnomaliesResponseDataType' + } + 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::CostAnomaliesResponseData` 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/cost_anomalies_response_data_attributes.rb b/lib/datadog_api_client/v2/models/cost_anomalies_response_data_attributes.rb new file mode 100644 index 000000000000..b1a60a6cae37 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomalies_response_data_attributes.rb @@ -0,0 +1,209 @@ +=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 + # Cost anomaly results and aggregated totals for the queried window. + class CostAnomaliesResponseDataAttributes + include BaseGenericModel + + # The list of cost anomalies that match the request. + attr_reader :anomalies + + # Average daily anomalous cost change across the queried window. + attr_reader :avg_daily_anomalous_cost + + # Total actual cost spent across the queried window for the matching providers. + attr_reader :total_actual_cost + + # Sum of the anomalous cost change across all returned anomalies. + attr_reader :total_anomalous_cost + + # Total number of anomalies that match the request. + attr_reader :total_count + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'anomalies' => :'anomalies', + :'avg_daily_anomalous_cost' => :'avg_daily_anomalous_cost', + :'total_actual_cost' => :'total_actual_cost', + :'total_anomalous_cost' => :'total_anomalous_cost', + :'total_count' => :'total_count' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'anomalies' => :'Array', + :'avg_daily_anomalous_cost' => :'Float', + :'total_actual_cost' => :'Float', + :'total_anomalous_cost' => :'Float', + :'total_count' => :'Integer' + } + 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::CostAnomaliesResponseDataAttributes` 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?(:'anomalies') + if (value = attributes[:'anomalies']).is_a?(Array) + self.anomalies = value + end + end + + if attributes.key?(:'avg_daily_anomalous_cost') + self.avg_daily_anomalous_cost = attributes[:'avg_daily_anomalous_cost'] + end + + if attributes.key?(:'total_actual_cost') + self.total_actual_cost = attributes[:'total_actual_cost'] + end + + if attributes.key?(:'total_anomalous_cost') + self.total_anomalous_cost = attributes[:'total_anomalous_cost'] + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + 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 @anomalies.nil? + return false if @avg_daily_anomalous_cost.nil? + return false if @total_actual_cost.nil? + return false if @total_anomalous_cost.nil? + return false if @total_count.nil? + true + end + + # Custom attribute writer method with validation + # @param anomalies [Object] Object to be assigned + # @!visibility private + def anomalies=(anomalies) + if anomalies.nil? + fail ArgumentError, 'invalid value for "anomalies", anomalies cannot be nil.' + end + @anomalies = anomalies + end + + # Custom attribute writer method with validation + # @param avg_daily_anomalous_cost [Object] Object to be assigned + # @!visibility private + def avg_daily_anomalous_cost=(avg_daily_anomalous_cost) + if avg_daily_anomalous_cost.nil? + fail ArgumentError, 'invalid value for "avg_daily_anomalous_cost", avg_daily_anomalous_cost cannot be nil.' + end + @avg_daily_anomalous_cost = avg_daily_anomalous_cost + end + + # Custom attribute writer method with validation + # @param total_actual_cost [Object] Object to be assigned + # @!visibility private + def total_actual_cost=(total_actual_cost) + if total_actual_cost.nil? + fail ArgumentError, 'invalid value for "total_actual_cost", total_actual_cost cannot be nil.' + end + @total_actual_cost = total_actual_cost + end + + # Custom attribute writer method with validation + # @param total_anomalous_cost [Object] Object to be assigned + # @!visibility private + def total_anomalous_cost=(total_anomalous_cost) + if total_anomalous_cost.nil? + fail ArgumentError, 'invalid value for "total_anomalous_cost", total_anomalous_cost cannot be nil.' + end + @total_anomalous_cost = total_anomalous_cost + end + + # Custom attribute writer method with validation + # @param total_count [Object] Object to be assigned + # @!visibility private + def total_count=(total_count) + if total_count.nil? + fail ArgumentError, 'invalid value for "total_count", total_count cannot be nil.' + end + @total_count = total_count + 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 && + anomalies == o.anomalies && + avg_daily_anomalous_cost == o.avg_daily_anomalous_cost && + total_actual_cost == o.total_actual_cost && + total_anomalous_cost == o.total_anomalous_cost && + total_count == o.total_count && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [anomalies, avg_daily_anomalous_cost, total_actual_cost, total_anomalous_cost, total_count, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_anomalies_response_data_type.rb b/lib/datadog_api_client/v2/models/cost_anomalies_response_data_type.rb new file mode 100644 index 000000000000..4ac34d9118f6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomalies_response_data_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 + # Type of the cost anomalies collection resource. Must be `anomalies`. + class CostAnomaliesResponseDataType + include BaseEnumModel + + ANOMALIES = "anomalies".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/cost_anomaly.rb b/lib/datadog_api_client/v2/models/cost_anomaly.rb new file mode 100644 index 000000000000..7874adc0c327 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomaly.rb @@ -0,0 +1,319 @@ +=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 detected Cloud Cost Management anomaly. + class CostAnomaly + include BaseGenericModel + + # Actual cost incurred during the anomaly window. + attr_reader :actual_cost + + # Anomalous cost change relative to the expected baseline. + attr_reader :anomalous_cost_change + + # Anomaly end timestamp in Unix milliseconds. + attr_reader :anomaly_end + + # Anomaly start timestamp in Unix milliseconds. + attr_reader :anomaly_start + + # Map of correlated tag keys to the list of correlated tag values. + attr_accessor :correlated_tags + + # Map of cost dimension keys to their values for the anomaly grouping. + attr_reader :dimensions + + # Resolution metadata for an anomaly that has been dismissed. + attr_accessor :dismissal + + # Maximum cost observed during the anomaly window. + attr_reader :max_cost + + # Cloud or SaaS provider associated with the anomaly (for example `aws`, `gcp`, `azure`). + attr_reader :provider + + # The metrics query that detected the anomaly. + attr_reader :query + + # The unique identifier of the anomaly. + attr_reader :uuid + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'actual_cost' => :'actual_cost', + :'anomalous_cost_change' => :'anomalous_cost_change', + :'anomaly_end' => :'anomaly_end', + :'anomaly_start' => :'anomaly_start', + :'correlated_tags' => :'correlated_tags', + :'dimensions' => :'dimensions', + :'dismissal' => :'dismissal', + :'max_cost' => :'max_cost', + :'provider' => :'provider', + :'query' => :'query', + :'uuid' => :'uuid' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'actual_cost' => :'Float', + :'anomalous_cost_change' => :'Float', + :'anomaly_end' => :'Integer', + :'anomaly_start' => :'Integer', + :'correlated_tags' => :'Hash>', + :'dimensions' => :'Hash', + :'dismissal' => :'CostAnomalyDismissal', + :'max_cost' => :'Float', + :'provider' => :'String', + :'query' => :'String', + :'uuid' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'correlated_tags', + ]) + 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::CostAnomaly` 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?(:'actual_cost') + self.actual_cost = attributes[:'actual_cost'] + end + + if attributes.key?(:'anomalous_cost_change') + self.anomalous_cost_change = attributes[:'anomalous_cost_change'] + end + + if attributes.key?(:'anomaly_end') + self.anomaly_end = attributes[:'anomaly_end'] + end + + if attributes.key?(:'anomaly_start') + self.anomaly_start = attributes[:'anomaly_start'] + end + + if attributes.key?(:'correlated_tags') + self.correlated_tags = attributes[:'correlated_tags'] + end + + if attributes.key?(:'dimensions') + self.dimensions = attributes[:'dimensions'] + end + + if attributes.key?(:'dismissal') + self.dismissal = attributes[:'dismissal'] + end + + if attributes.key?(:'max_cost') + self.max_cost = attributes[:'max_cost'] + end + + if attributes.key?(:'provider') + self.provider = attributes[:'provider'] + end + + if attributes.key?(:'query') + self.query = attributes[:'query'] + end + + if attributes.key?(:'uuid') + self.uuid = attributes[:'uuid'] + 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 @actual_cost.nil? + return false if @anomalous_cost_change.nil? + return false if @anomaly_end.nil? + return false if @anomaly_start.nil? + return false if @dimensions.nil? + return false if @max_cost.nil? + return false if @provider.nil? + return false if @query.nil? + return false if @uuid.nil? + true + end + + # Custom attribute writer method with validation + # @param actual_cost [Object] Object to be assigned + # @!visibility private + def actual_cost=(actual_cost) + if actual_cost.nil? + fail ArgumentError, 'invalid value for "actual_cost", actual_cost cannot be nil.' + end + @actual_cost = actual_cost + end + + # Custom attribute writer method with validation + # @param anomalous_cost_change [Object] Object to be assigned + # @!visibility private + def anomalous_cost_change=(anomalous_cost_change) + if anomalous_cost_change.nil? + fail ArgumentError, 'invalid value for "anomalous_cost_change", anomalous_cost_change cannot be nil.' + end + @anomalous_cost_change = anomalous_cost_change + end + + # Custom attribute writer method with validation + # @param anomaly_end [Object] Object to be assigned + # @!visibility private + def anomaly_end=(anomaly_end) + if anomaly_end.nil? + fail ArgumentError, 'invalid value for "anomaly_end", anomaly_end cannot be nil.' + end + @anomaly_end = anomaly_end + end + + # Custom attribute writer method with validation + # @param anomaly_start [Object] Object to be assigned + # @!visibility private + def anomaly_start=(anomaly_start) + if anomaly_start.nil? + fail ArgumentError, 'invalid value for "anomaly_start", anomaly_start cannot be nil.' + end + @anomaly_start = anomaly_start + end + + # Custom attribute writer method with validation + # @param dimensions [Object] Object to be assigned + # @!visibility private + def dimensions=(dimensions) + if dimensions.nil? + fail ArgumentError, 'invalid value for "dimensions", dimensions cannot be nil.' + end + @dimensions = dimensions + end + + # Custom attribute writer method with validation + # @param max_cost [Object] Object to be assigned + # @!visibility private + def max_cost=(max_cost) + if max_cost.nil? + fail ArgumentError, 'invalid value for "max_cost", max_cost cannot be nil.' + end + @max_cost = max_cost + end + + # Custom attribute writer method with validation + # @param provider [Object] Object to be assigned + # @!visibility private + def provider=(provider) + if provider.nil? + fail ArgumentError, 'invalid value for "provider", provider cannot be nil.' + end + @provider = provider + 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 + + # Custom attribute writer method with validation + # @param uuid [Object] Object to be assigned + # @!visibility private + def uuid=(uuid) + if uuid.nil? + fail ArgumentError, 'invalid value for "uuid", uuid cannot be nil.' + end + @uuid = uuid + 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 && + actual_cost == o.actual_cost && + anomalous_cost_change == o.anomalous_cost_change && + anomaly_end == o.anomaly_end && + anomaly_start == o.anomaly_start && + correlated_tags == o.correlated_tags && + dimensions == o.dimensions && + dismissal == o.dismissal && + max_cost == o.max_cost && + provider == o.provider && + query == o.query && + uuid == o.uuid && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [actual_cost, anomalous_cost_change, anomaly_end, anomaly_start, correlated_tags, dimensions, dismissal, max_cost, provider, query, uuid, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_anomaly_dismissal.rb b/lib/datadog_api_client/v2/models/cost_anomaly_dismissal.rb new file mode 100644 index 000000000000..f53e33bc00b6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomaly_dismissal.rb @@ -0,0 +1,207 @@ +=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 + # Resolution metadata for an anomaly that has been dismissed. + class CostAnomalyDismissal + include BaseGenericModel + + # Reason the anomaly was dismissed. + attr_reader :cause + + # Unique identifier of the dismissal record. + attr_reader :dismissal_id + + # Optional message explaining the dismissal. + attr_reader :message + + # Timestamp of the last dismissal update in Unix milliseconds. + attr_reader :updated_at + + # Identifier of the user that last updated the dismissal. + attr_reader :updated_by + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'cause' => :'cause', + :'dismissal_id' => :'dismissal_id', + :'message' => :'message', + :'updated_at' => :'updated_at', + :'updated_by' => :'updated_by' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'cause' => :'String', + :'dismissal_id' => :'String', + :'message' => :'String', + :'updated_at' => :'Integer', + :'updated_by' => :'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::CostAnomalyDismissal` 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?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'dismissal_id') + self.dismissal_id = attributes[:'dismissal_id'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'updated_by') + self.updated_by = attributes[:'updated_by'] + 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 @cause.nil? + return false if @dismissal_id.nil? + return false if @message.nil? + return false if @updated_at.nil? + return false if @updated_by.nil? + true + end + + # Custom attribute writer method with validation + # @param cause [Object] Object to be assigned + # @!visibility private + def cause=(cause) + if cause.nil? + fail ArgumentError, 'invalid value for "cause", cause cannot be nil.' + end + @cause = cause + end + + # Custom attribute writer method with validation + # @param dismissal_id [Object] Object to be assigned + # @!visibility private + def dismissal_id=(dismissal_id) + if dismissal_id.nil? + fail ArgumentError, 'invalid value for "dismissal_id", dismissal_id cannot be nil.' + end + @dismissal_id = dismissal_id + end + + # Custom attribute writer method with validation + # @param message [Object] Object to be assigned + # @!visibility private + def message=(message) + if message.nil? + fail ArgumentError, 'invalid value for "message", message cannot be nil.' + end + @message = message + end + + # Custom attribute writer method with validation + # @param updated_at [Object] Object to be assigned + # @!visibility private + def updated_at=(updated_at) + if updated_at.nil? + fail ArgumentError, 'invalid value for "updated_at", updated_at cannot be nil.' + end + @updated_at = updated_at + end + + # Custom attribute writer method with validation + # @param updated_by [Object] Object to be assigned + # @!visibility private + def updated_by=(updated_by) + if updated_by.nil? + fail ArgumentError, 'invalid value for "updated_by", updated_by cannot be nil.' + end + @updated_by = updated_by + 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 && + cause == o.cause && + dismissal_id == o.dismissal_id && + message == o.message && + updated_at == o.updated_at && + updated_by == o.updated_by && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [cause, dismissal_id, message, updated_at, updated_by, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_anomaly_response.rb b/lib/datadog_api_client/v2/models/cost_anomaly_response.rb new file mode 100644 index 000000000000..b62abd84c5a6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomaly_response.rb @@ -0,0 +1,105 @@ +=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 object containing a single Cloud Cost Management anomaly. + class CostAnomalyResponse + include BaseGenericModel + + # Resource wrapper for a single cost anomaly. + attr_accessor :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' => :'CostAnomalyResponseData' + } + 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::CostAnomalyResponse` 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 + + # 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/cost_anomaly_response_data.rb b/lib/datadog_api_client/v2/models/cost_anomaly_response_data.rb new file mode 100644 index 000000000000..4882bfa438ef --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_anomaly_response_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 + # Resource wrapper for a single cost anomaly. + class CostAnomalyResponseData + include BaseGenericModel + + # A single detected Cloud Cost Management anomaly. + attr_reader :attributes + + # The unique identifier of the anomaly. + attr_reader :id + + # Type of the cost anomalies collection resource. Must be `anomalies`. + 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' => :'CostAnomaly', + :'id' => :'String', + :'type' => :'CostAnomaliesResponseDataType' + } + 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::CostAnomalyResponseData` 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 From bb1264b3baf5665471b6a7663eb2aa6be8e76bda Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 18:00:35 +0000 Subject: [PATCH 2/4] Add regression fields to Error Tracking API responses (#3323) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 23 +++ lib/datadog_api_client/inflector.rb | 1 + .../v2/models/issue_attributes.rb | 12 +- .../v2/models/issue_regression.rb | 154 ++++++++++++++++++ 4 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 lib/datadog_api_client/v2/models/issue_regression.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4cefb983dbae..db3332717dac 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -37295,6 +37295,8 @@ components: type: string platform: $ref: "#/components/schemas/IssuePlatform" + regression: + $ref: "#/components/schemas/IssueRegression" service: description: Service name. example: "email-api-py" @@ -37565,6 +37567,27 @@ components: - id - type type: object + IssueRegression: + description: Regression information for an issue that was previously resolved and then reopened. + properties: + regressed_at: + description: Timestamp when the issue was reopened (regressed). + example: "2024-01-03T08:00:00Z" + format: date-time + type: string + regressed_at_version: + description: Application version where the regression was observed. + example: "v2.5.2" + type: string + resolved_at: + description: Timestamp when the issue was resolved before the regression. + example: "2024-01-01T10:00:00Z" + format: date-time + type: string + required: + - resolved_at + - regressed_at + type: object IssueRelationships: description: Relationship between the issue and an assignee, case and/or teams. properties: diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index af1b2864eca4..a15a42597c0e 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3339,6 +3339,7 @@ def overrides "v2.issue_language" => "IssueLanguage", "v2.issue_platform" => "IssuePlatform", "v2.issue_reference" => "IssueReference", + "v2.issue_regression" => "IssueRegression", "v2.issue_relationships" => "IssueRelationships", "v2.issue_response" => "IssueResponse", "v2.issues_search_request" => "IssuesSearchRequest", diff --git a/lib/datadog_api_client/v2/models/issue_attributes.rb b/lib/datadog_api_client/v2/models/issue_attributes.rb index 55e5661930fb..1732a0c9edbe 100644 --- a/lib/datadog_api_client/v2/models/issue_attributes.rb +++ b/lib/datadog_api_client/v2/models/issue_attributes.rb @@ -54,6 +54,9 @@ class IssueAttributes # Platform associated with the issue. attr_accessor :platform + # Regression information for an issue that was previously resolved and then reopened. + attr_accessor :regression + # Service name. attr_accessor :service @@ -77,6 +80,7 @@ def self.attribute_map :'last_seen' => :'last_seen', :'last_seen_version' => :'last_seen_version', :'platform' => :'platform', + :'regression' => :'regression', :'service' => :'service', :'state' => :'state' } @@ -97,6 +101,7 @@ def self.openapi_types :'last_seen' => :'Integer', :'last_seen_version' => :'String', :'platform' => :'IssuePlatform', + :'regression' => :'IssueRegression', :'service' => :'String', :'state' => :'IssueState' } @@ -166,6 +171,10 @@ def initialize(attributes = {}) self.platform = attributes[:'platform'] end + if attributes.key?(:'regression') + self.regression = attributes[:'regression'] + end + if attributes.key?(:'service') self.service = attributes[:'service'] end @@ -212,6 +221,7 @@ def ==(o) last_seen == o.last_seen && last_seen_version == o.last_seen_version && platform == o.platform && + regression == o.regression && service == o.service && state == o.state && additional_properties == o.additional_properties @@ -221,7 +231,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [error_message, error_type, file_path, first_seen, first_seen_version, function_name, is_crash, languages, last_seen, last_seen_version, platform, service, state, additional_properties].hash + [error_message, error_type, file_path, first_seen, first_seen_version, function_name, is_crash, languages, last_seen, last_seen_version, platform, regression, service, state, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/issue_regression.rb b/lib/datadog_api_client/v2/models/issue_regression.rb new file mode 100644 index 000000000000..76028cc36483 --- /dev/null +++ b/lib/datadog_api_client/v2/models/issue_regression.rb @@ -0,0 +1,154 @@ +=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 + # Regression information for an issue that was previously resolved and then reopened. + class IssueRegression + include BaseGenericModel + + # Timestamp when the issue was reopened (regressed). + attr_reader :regressed_at + + # Application version where the regression was observed. + attr_accessor :regressed_at_version + + # Timestamp when the issue was resolved before the regression. + attr_reader :resolved_at + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'regressed_at' => :'regressed_at', + :'regressed_at_version' => :'regressed_at_version', + :'resolved_at' => :'resolved_at' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'regressed_at' => :'Time', + :'regressed_at_version' => :'String', + :'resolved_at' => :'Time' + } + 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::IssueRegression` 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?(:'regressed_at') + self.regressed_at = attributes[:'regressed_at'] + end + + if attributes.key?(:'regressed_at_version') + self.regressed_at_version = attributes[:'regressed_at_version'] + end + + if attributes.key?(:'resolved_at') + self.resolved_at = attributes[:'resolved_at'] + 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 @regressed_at.nil? + return false if @resolved_at.nil? + true + end + + # Custom attribute writer method with validation + # @param regressed_at [Object] Object to be assigned + # @!visibility private + def regressed_at=(regressed_at) + if regressed_at.nil? + fail ArgumentError, 'invalid value for "regressed_at", regressed_at cannot be nil.' + end + @regressed_at = regressed_at + end + + # Custom attribute writer method with validation + # @param resolved_at [Object] Object to be assigned + # @!visibility private + def resolved_at=(resolved_at) + if resolved_at.nil? + fail ArgumentError, 'invalid value for "resolved_at", resolved_at cannot be nil.' + end + @resolved_at = resolved_at + 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 && + regressed_at == o.regressed_at && + regressed_at_version == o.regressed_at_version && + resolved_at == o.resolved_at && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [regressed_at, regressed_at_version, resolved_at, additional_properties].hash + end + end +end From 571a174737e94d0c0d9b8b8eb92f998290ab8d43 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 16:32:50 -0400 Subject: [PATCH 3/4] Regenerate client from commit 3d6d3ae of spec repo (#3313) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 418 ++++++++++++++++++ .../v2/cloud-cost-management/GetCostTagKey.rb | 5 + .../cloud-cost-management/ListCostTagKeys.rb | 5 + .../v2/cloud-cost-management/ListCostTags.rb | 5 + features/scenarios_model_mapping.rb | 16 + features/v2/cloud_cost_management.feature | 45 ++ features/v2/undo.json | 18 + lib/datadog_api_client/inflector.rb | 10 + .../v2/api/cloud_cost_management_api.rb | 211 +++++++++ lib/datadog_api_client/v2/models/cost_tag.rb | 165 +++++++ .../v2/models/cost_tag_attributes.rb | 146 ++++++ .../v2/models/cost_tag_key.rb | 165 +++++++ .../v2/models/cost_tag_key_attributes.rb | 156 +++++++ .../v2/models/cost_tag_key_details.rb | 146 ++++++ .../v2/models/cost_tag_key_response.rb | 123 ++++++ .../v2/models/cost_tag_key_type.rb | 26 ++ .../v2/models/cost_tag_keys_response.rb | 125 ++++++ .../v2/models/cost_tag_type.rb | 26 ++ .../v2/models/cost_tags_response.rb | 125 ++++++ 19 files changed, 1936 insertions(+) create mode 100644 examples/v2/cloud-cost-management/GetCostTagKey.rb create mode 100644 examples/v2/cloud-cost-management/ListCostTagKeys.rb create mode 100644 examples/v2/cloud-cost-management/ListCostTags.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_key.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_key_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_key_details.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_key_response.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_key_type.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_keys_response.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tag_type.rb create mode 100644 lib/datadog_api_client/v2/models/cost_tags_response.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index db3332717dac..faa94f948b80 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1468,6 +1468,13 @@ components: required: true schema: type: string + TagKey: + description: The Cloud Cost Management tag key. Tag keys can contain forward slashes (for example, `kubernetes/instance`). + in: path + name: tag_key + required: true + schema: + type: string ToTimestamp: description: The ending timestamp for the SLO status query in epoch seconds. in: query @@ -15805,6 +15812,41 @@ components: type: string x-enum-varnames: - COST_BY_ORG + CostTag: + description: A Cloud Cost Management tag. + properties: + attributes: + $ref: "#/components/schemas/CostTagAttributes" + id: + description: The tag identifier, equal to its `key:value` representation. + example: providername:aws + type: string + type: + $ref: "#/components/schemas/CostTagType" + required: + - attributes + - id + - type + type: object + CostTagAttributes: + description: Attributes of a Cloud Cost Management tag. + properties: + sources: + description: List of sources that define this tag. + example: + - focus + items: + description: A tag source. + type: string + type: array + value: + description: The tag value in `key:value` format. + example: providername:aws + type: string + required: + - sources + - value + type: object CostTagDescription: description: A Cloud Cost Management tag key description, either cross-cloud or scoped to a single cloud provider. properties: @@ -15897,6 +15939,153 @@ components: required: - data type: object + CostTagKey: + description: A Cloud Cost Management tag key. + properties: + attributes: + $ref: "#/components/schemas/CostTagKeyAttributes" + id: + description: The tag key identifier. + example: providername + type: string + type: + $ref: "#/components/schemas/CostTagKeyType" + required: + - attributes + - id + - type + type: object + CostTagKeyAttributes: + description: Attributes of a Cloud Cost Management tag key. + properties: + details: + $ref: "#/components/schemas/CostTagKeyDetails" + sources: + description: List of sources that define this tag key. + example: + - focus + items: + description: A tag key source. + type: string + type: array + value: + description: The tag key name. + example: providername + type: string + required: + - sources + - value + type: object + CostTagKeyDetails: + description: Additional details for a Cloud Cost Management tag key, including its description and example tag values. + properties: + description: + description: Description of the tag key. + example: The cloud provider name reported for the cost line item. + type: string + tag_values: + description: Example tag values observed for this tag key. + example: + - aws + - gcp + - azure + items: + description: A tag value observed for this tag key. + type: string + type: array + required: + - description + - tag_values + type: object + CostTagKeyResponse: + description: A single Cloud Cost Management tag key. + example: + data: + attributes: + details: + description: The cloud provider name reported for the cost line item. + tag_values: + - aws + - gcp + - azure + sources: + - focus + value: providername + id: providername + type: cost_tag_key + properties: + data: + $ref: "#/components/schemas/CostTagKey" + required: + - data + type: object + CostTagKeyType: + default: cost_tag_key + description: Type of the Cloud Cost Management tag key resource. + enum: + - cost_tag_key + example: cost_tag_key + type: string + x-enum-varnames: + - COST_TAG_KEY + CostTagKeysResponse: + description: A list of Cloud Cost Management tag keys. + example: + data: + - attributes: + sources: + - focus + value: providername + id: providername + type: cost_tag_key + - attributes: + sources: [] + value: service + id: service + type: cost_tag_key + properties: + data: + description: The list of Cloud Cost Management tag keys. + items: + $ref: "#/components/schemas/CostTagKey" + type: array + required: + - data + type: object + CostTagType: + default: cost_tag + description: Type of the Cloud Cost Management tag resource. + enum: + - cost_tag + example: cost_tag + type: string + x-enum-varnames: + - COST_TAG + CostTagsResponse: + description: A list of Cloud Cost Management tags. + example: + data: + - attributes: + sources: + - focus + value: providername:aws + id: providername:aws + type: cost_tag + - attributes: + sources: + - focus + value: providername:gcp + id: providername:gcp + type: cost_tag + properties: + data: + description: The list of Cloud Cost Management tags. + items: + $ref: "#/components/schemas/CostTag" + type: array + required: + - data + type: object CoverageSummaryAttributes: description: Attributes object for code coverage summary response. properties: @@ -97646,6 +97835,235 @@ paths: operator: OR permissions: - cloud_cost_management_read + /api/v2/cost/tag_keys: + get: + description: List Cloud Cost Management tag keys. + operationId: ListCostTagKeys + parameters: + - description: The Cloud Cost Management metric to scope the tag keys to. When omitted, returns tag keys across all metrics. + in: query + name: filter[metric] + schema: + type: string + - description: |- + Filter to return only tag keys that appear with the given `key:value` tag values. For example, `filter[tags]=providername:aws` returns tag keys found on the same cost data, such as `is_aws_ec2_compute` and `aws_instance_type`. + in: query + name: filter[tags] + schema: + items: + type: string + type: array + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + sources: + - focus + value: providername + id: providername + type: cost_tag_key + - attributes: + sources: [] + value: service + id: service + type: cost_tag_key + schema: + $ref: "#/components/schemas/CostTagKeysResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: List Cloud Cost Management tag keys + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + /api/v2/cost/tag_keys/{tag_key}: + get: + description: Get details for a specific Cloud Cost Management tag key, including example tag values and description. + operationId: GetCostTagKey + parameters: + - $ref: "#/components/parameters/TagKey" + - description: The Cloud Cost Management metric to scope the tag key details to. When omitted, returns details across all metrics. + in: query + name: filter[metric] + schema: + type: string + - description: |- + Controls the size of the internal tag value search scope. This does **not** restrict the number of example tag values returned in the response. Defaults to 50, maximum 10000. + in: query + name: page[size] + schema: + default: 50 + format: int32 + maximum: 10000 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + details: + description: The cloud provider name reported for the cost line item. + tag_values: + - aws + - gcp + - azure + sources: + - focus + value: providername + id: providername + type: cost_tag_key + schema: + $ref: "#/components/schemas/CostTagKeyResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Get a Cloud Cost Management tag key + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + /api/v2/cost/tags: + get: + description: List Cloud Cost Management tags for a given metric. + operationId: ListCostTags + parameters: + - description: The Cloud Cost Management metric to scope the tags to. When omitted, returns tags across all metrics. + in: query + name: filter[metric] + schema: + type: string + - description: A substring used to filter the returned tags by name. + in: query + name: filter[match] + schema: + type: string + - description: |- + Filter to return only tags that appear with the given `key:value` tag values. For example, `filter[tags]=providername:aws` returns tags found on the same cost data, such as `aws_instance_type:t3.micro` and `aws_instance_type:m5.large`. + in: query + name: filter[tags] + schema: + items: + type: string + type: array + - description: Restrict the returned tags to those whose key matches one of the given tag keys. + in: query + name: filter[tag_keys] + schema: + items: + type: string + type: array + - description: |- + Controls the size of the internal tag search scope. This does **not** restrict the number of tags returned in the response. Defaults to 50, maximum 10000. + in: query + name: page[size] + schema: + default: 50 + format: int32 + maximum: 10000 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + sources: + - focus + value: providername:aws + id: providername:aws + type: cost_tag + - attributes: + sources: + - focus + value: providername:gcp + id: providername:gcp + type: cost_tag + schema: + $ref: "#/components/schemas/CostTagsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: List Cloud Cost Management tags + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read /api/v2/cost_by_tag/active_billing_dimensions: get: description: |- diff --git a/examples/v2/cloud-cost-management/GetCostTagKey.rb b/examples/v2/cloud-cost-management/GetCostTagKey.rb new file mode 100644 index 000000000000..bf2551882b4b --- /dev/null +++ b/examples/v2/cloud-cost-management/GetCostTagKey.rb @@ -0,0 +1,5 @@ +# Get a Cloud Cost Management tag key returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new +p api_instance.get_cost_tag_key("tag_key") diff --git a/examples/v2/cloud-cost-management/ListCostTagKeys.rb b/examples/v2/cloud-cost-management/ListCostTagKeys.rb new file mode 100644 index 000000000000..932e35eb64ca --- /dev/null +++ b/examples/v2/cloud-cost-management/ListCostTagKeys.rb @@ -0,0 +1,5 @@ +# List Cloud Cost Management tag keys returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new +p api_instance.list_cost_tag_keys() diff --git a/examples/v2/cloud-cost-management/ListCostTags.rb b/examples/v2/cloud-cost-management/ListCostTags.rb new file mode 100644 index 000000000000..8e476a8ab5b5 --- /dev/null +++ b/examples/v2/cloud-cost-management/ListCostTags.rb @@ -0,0 +1,5 @@ +# List Cloud Cost Management tags returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new +p api_instance.list_cost_tags() diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 4f6619e89ece..55709e0a558b 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2204,6 +2204,22 @@ "v2.ListCostTagDescriptions" => { "filter_cloud" => "String", }, + "v2.ListCostTagKeys" => { + "filter_metric" => "String", + "filter_tags" => "Array", + }, + "v2.GetCostTagKey" => { + "tag_key" => "String", + "filter_metric" => "String", + "page_size" => "Integer", + }, + "v2.ListCostTags" => { + "filter_metric" => "String", + "filter_match" => "String", + "filter_tags" => "Array", + "filter_tag_keys" => "Array", + "page_size" => "Integer", + }, "v2.CreateTagPipelinesRuleset" => { "body" => "CreateRulesetRequest", }, diff --git a/features/v2/cloud_cost_management.feature b/features/v2/cloud_cost_management.feature index 9bab51741ef3..d06acba8d826 100644 --- a/features/v2/cloud_cost_management.feature +++ b/features/v2/cloud_cost_management.feature @@ -250,6 +250,27 @@ Feature: Cloud Cost Management And the response "data.type" is equal to "gcp_uc_config" And the response "data.attributes.account_id" is equal to "123456_ABCDEF_123ABC" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag key returns "Bad Request" response + Given new "GetCostTagKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag key returns "Not Found" response + Given new "GetCostTagKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag key returns "OK" response + Given new "GetCostTagKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/cloud-cost-management Scenario: Get a budget returns "Not Found" response Given new "GetBudget" request @@ -349,6 +370,30 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List Cloud Cost Management tag keys returns "Bad Request" response + Given new "ListCostTagKeys" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List Cloud Cost Management tag keys returns "OK" response + Given new "ListCostTagKeys" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List Cloud Cost Management tags returns "Bad Request" response + Given new "ListCostTags" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List Cloud Cost Management tags returns "OK" response + Given new "ListCostTags" request + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: List Custom Costs Files returns "OK" response Given new "ListCustomCostsFiles" request diff --git a/features/v2/undo.json b/features/v2/undo.json index b9805518e9df..dc1a8b2fbbde 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1488,6 +1488,24 @@ "type": "safe" } }, + "ListCostTagKeys": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "GetCostTagKey": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "ListCostTags": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "GetActiveBillingDimensions": { "tag": "Usage Metering", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index a15a42597c0e..9f5558e0d1ac 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1996,11 +1996,21 @@ def overrides "v2.cost_by_org_attributes" => "CostByOrgAttributes", "v2.cost_by_org_response" => "CostByOrgResponse", "v2.cost_by_org_type" => "CostByOrgType", + "v2.cost_tag" => "CostTag", + "v2.cost_tag_attributes" => "CostTagAttributes", "v2.cost_tag_description" => "CostTagDescription", "v2.cost_tag_description_attributes" => "CostTagDescriptionAttributes", "v2.cost_tag_description_source" => "CostTagDescriptionSource", "v2.cost_tag_descriptions_response" => "CostTagDescriptionsResponse", "v2.cost_tag_description_type" => "CostTagDescriptionType", + "v2.cost_tag_key" => "CostTagKey", + "v2.cost_tag_key_attributes" => "CostTagKeyAttributes", + "v2.cost_tag_key_details" => "CostTagKeyDetails", + "v2.cost_tag_key_response" => "CostTagKeyResponse", + "v2.cost_tag_keys_response" => "CostTagKeysResponse", + "v2.cost_tag_key_type" => "CostTagKeyType", + "v2.cost_tags_response" => "CostTagsResponse", + "v2.cost_tag_type" => "CostTagType", "v2.coverage_summary_attributes" => "CoverageSummaryAttributes", "v2.coverage_summary_codeowner_stats" => "CoverageSummaryCodeownerStats", "v2.coverage_summary_data" => "CoverageSummaryData", diff --git a/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb b/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb index 8d28019cff2e..2a8f0b28274e 100644 --- a/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb +++ b/lib/datadog_api_client/v2/api/cloud_cost_management_api.rb @@ -1156,6 +1156,78 @@ def get_cost_gcp_usage_cost_config_with_http_info(cloud_account_id, opts = {}) return data, status_code, headers end + # Get a Cloud Cost Management tag key. + # + # @see #get_cost_tag_key_with_http_info + def get_cost_tag_key(tag_key, opts = {}) + data, _status_code, _headers = get_cost_tag_key_with_http_info(tag_key, opts) + data + end + + # Get a Cloud Cost Management tag key. + # + # Get details for a specific Cloud Cost Management tag key, including example tag values and description. + # + # @param tag_key [String] The Cloud Cost Management tag key. Tag keys can contain forward slashes (for example, `kubernetes/instance`). + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_metric The Cloud Cost Management metric to scope the tag key details to. When omitted, returns details across all metrics. + # @option opts [Integer] :page_size Controls the size of the internal tag value search scope. This does **not** restrict the number of example tag values returned in the response. Defaults to 50, maximum 10000. + # @return [Array<(CostTagKeyResponse, Integer, Hash)>] CostTagKeyResponse data, response status code and response headers + def get_cost_tag_key_with_http_info(tag_key, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CloudCostManagementAPI.get_cost_tag_key ...' + end + # verify the required parameter 'tag_key' is set + if @api_client.config.client_side_validation && tag_key.nil? + fail ArgumentError, "Missing the required parameter 'tag_key' when calling CloudCostManagementAPI.get_cost_tag_key" + end + if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 10000 + fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CloudCostManagementAPI.get_cost_tag_key, must be smaller than or equal to 10000.' + end + # resource path + local_var_path = '/api/v2/cost/tag_keys/{tag_key}'.sub('{tag_key}', CGI.escape(tag_key.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[metric]'] = opts[:'filter_metric'] if !opts[:'filter_metric'].nil? + query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil? + + # 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] || 'CostTagKeyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_cost_tag_key, + :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: CloudCostManagementAPI#get_cost_tag_key\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get custom allocation rule. # # @see #get_custom_allocation_rule_with_http_info @@ -1802,6 +1874,145 @@ def list_cost_tag_descriptions_with_http_info(opts = {}) return data, status_code, headers end + # List Cloud Cost Management tag keys. + # + # @see #list_cost_tag_keys_with_http_info + def list_cost_tag_keys(opts = {}) + data, _status_code, _headers = list_cost_tag_keys_with_http_info(opts) + data + end + + # List Cloud Cost Management tag keys. + # + # List Cloud Cost Management tag keys. + # + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_metric The Cloud Cost Management metric to scope the tag keys to. When omitted, returns tag keys across all metrics. + # @option opts [Array] :filter_tags Filter to return only tag keys that appear with the given `key:value` tag values. For example, `filter[tags]=providername:aws` returns tag keys found on the same cost data, such as `is_aws_ec2_compute` and `aws_instance_type`. + # @return [Array<(CostTagKeysResponse, Integer, Hash)>] CostTagKeysResponse data, response status code and response headers + def list_cost_tag_keys_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CloudCostManagementAPI.list_cost_tag_keys ...' + end + # resource path + local_var_path = '/api/v2/cost/tag_keys' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[metric]'] = opts[:'filter_metric'] if !opts[:'filter_metric'].nil? + query_params[:'filter[tags]'] = @api_client.build_collection_param(opts[:'filter_tags'], :multi) if !opts[:'filter_tags'].nil? + + # 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] || 'CostTagKeysResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_cost_tag_keys, + :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" + ) + new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER + + 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: CloudCostManagementAPI#list_cost_tag_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Cloud Cost Management tags. + # + # @see #list_cost_tags_with_http_info + def list_cost_tags(opts = {}) + data, _status_code, _headers = list_cost_tags_with_http_info(opts) + data + end + + # List Cloud Cost Management tags. + # + # List Cloud Cost Management tags for a given metric. + # + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_metric The Cloud Cost Management metric to scope the tags to. When omitted, returns tags across all metrics. + # @option opts [String] :filter_match A substring used to filter the returned tags by name. + # @option opts [Array] :filter_tags Filter to return only tags that appear with the given `key:value` tag values. For example, `filter[tags]=providername:aws` returns tags found on the same cost data, such as `aws_instance_type:t3.micro` and `aws_instance_type:m5.large`. + # @option opts [Array] :filter_tag_keys Restrict the returned tags to those whose key matches one of the given tag keys. + # @option opts [Integer] :page_size Controls the size of the internal tag search scope. This does **not** restrict the number of tags returned in the response. Defaults to 50, maximum 10000. + # @return [Array<(CostTagsResponse, Integer, Hash)>] CostTagsResponse data, response status code and response headers + def list_cost_tags_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CloudCostManagementAPI.list_cost_tags ...' + end + if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 10000 + fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CloudCostManagementAPI.list_cost_tags, must be smaller than or equal to 10000.' + end + # resource path + local_var_path = '/api/v2/cost/tags' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[metric]'] = opts[:'filter_metric'] if !opts[:'filter_metric'].nil? + query_params[:'filter[match]'] = opts[:'filter_match'] if !opts[:'filter_match'].nil? + query_params[:'filter[tags]'] = @api_client.build_collection_param(opts[:'filter_tags'], :multi) if !opts[:'filter_tags'].nil? + query_params[:'filter[tag_keys]'] = @api_client.build_collection_param(opts[:'filter_tag_keys'], :multi) if !opts[:'filter_tag_keys'].nil? + query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil? + + # 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] || 'CostTagsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_cost_tags, + :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" + ) + new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER + + 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: CloudCostManagementAPI#list_cost_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List custom allocation rules. # # @see #list_custom_allocation_rules_with_http_info diff --git a/lib/datadog_api_client/v2/models/cost_tag.rb b/lib/datadog_api_client/v2/models/cost_tag.rb new file mode 100644 index 000000000000..73161f537c05 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag.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 Cloud Cost Management tag. + class CostTag + include BaseGenericModel + + # Attributes of a Cloud Cost Management tag. + attr_reader :attributes + + # The tag identifier, equal to its `key:value` representation. + attr_reader :id + + # Type of the Cloud Cost Management tag resource. + 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' => :'CostTagAttributes', + :'id' => :'String', + :'type' => :'CostTagType' + } + 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::CostTag` 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/cost_tag_attributes.rb b/lib/datadog_api_client/v2/models/cost_tag_attributes.rb new file mode 100644 index 000000000000..8767d6920856 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_attributes.rb @@ -0,0 +1,146 @@ +=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 Cloud Cost Management tag. + class CostTagAttributes + include BaseGenericModel + + # List of sources that define this tag. + attr_reader :sources + + # The tag value in `key:value` format. + attr_reader :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'sources' => :'sources', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'sources' => :'Array', + :'value' => :'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::CostTagAttributes` 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?(:'sources') + if (value = attributes[:'sources']).is_a?(Array) + self.sources = value + end + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + 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 @sources.nil? + return false if @value.nil? + true + end + + # Custom attribute writer method with validation + # @param sources [Object] Object to be assigned + # @!visibility private + def sources=(sources) + if sources.nil? + fail ArgumentError, 'invalid value for "sources", sources cannot be nil.' + end + @sources = sources + end + + # Custom attribute writer method with validation + # @param value [Object] Object to be assigned + # @!visibility private + def value=(value) + if value.nil? + fail ArgumentError, 'invalid value for "value", value cannot be nil.' + end + @value = value + 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 && + sources == o.sources && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [sources, value, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_tag_key.rb b/lib/datadog_api_client/v2/models/cost_tag_key.rb new file mode 100644 index 000000000000..255aa24b72e9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_key.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 Cloud Cost Management tag key. + class CostTagKey + include BaseGenericModel + + # Attributes of a Cloud Cost Management tag key. + attr_reader :attributes + + # The tag key identifier. + attr_reader :id + + # Type of the Cloud Cost Management tag key resource. + 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' => :'CostTagKeyAttributes', + :'id' => :'String', + :'type' => :'CostTagKeyType' + } + 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::CostTagKey` 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/cost_tag_key_attributes.rb b/lib/datadog_api_client/v2/models/cost_tag_key_attributes.rb new file mode 100644 index 000000000000..789e7be45e62 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_key_attributes.rb @@ -0,0 +1,156 @@ +=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 Cloud Cost Management tag key. + class CostTagKeyAttributes + include BaseGenericModel + + # Additional details for a Cloud Cost Management tag key, including its description and example tag values. + attr_accessor :details + + # List of sources that define this tag key. + attr_reader :sources + + # The tag key name. + attr_reader :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'details' => :'details', + :'sources' => :'sources', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'details' => :'CostTagKeyDetails', + :'sources' => :'Array', + :'value' => :'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::CostTagKeyAttributes` 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?(:'details') + self.details = attributes[:'details'] + end + + if attributes.key?(:'sources') + if (value = attributes[:'sources']).is_a?(Array) + self.sources = value + end + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + 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 @sources.nil? + return false if @value.nil? + true + end + + # Custom attribute writer method with validation + # @param sources [Object] Object to be assigned + # @!visibility private + def sources=(sources) + if sources.nil? + fail ArgumentError, 'invalid value for "sources", sources cannot be nil.' + end + @sources = sources + end + + # Custom attribute writer method with validation + # @param value [Object] Object to be assigned + # @!visibility private + def value=(value) + if value.nil? + fail ArgumentError, 'invalid value for "value", value cannot be nil.' + end + @value = value + 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 && + details == o.details && + sources == o.sources && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [details, sources, value, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_tag_key_details.rb b/lib/datadog_api_client/v2/models/cost_tag_key_details.rb new file mode 100644 index 000000000000..2af7b499866d --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_key_details.rb @@ -0,0 +1,146 @@ +=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 + # Additional details for a Cloud Cost Management tag key, including its description and example tag values. + class CostTagKeyDetails + include BaseGenericModel + + # Description of the tag key. + attr_reader :description + + # Example tag values observed for this tag key. + attr_reader :tag_values + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'tag_values' => :'tag_values' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'tag_values' => :'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::CostTagKeyDetails` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'tag_values') + if (value = attributes[:'tag_values']).is_a?(Array) + self.tag_values = 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 @description.nil? + return false if @tag_values.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param tag_values [Object] Object to be assigned + # @!visibility private + def tag_values=(tag_values) + if tag_values.nil? + fail ArgumentError, 'invalid value for "tag_values", tag_values cannot be nil.' + end + @tag_values = tag_values + 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 && + description == o.description && + tag_values == o.tag_values && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, tag_values, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cost_tag_key_response.rb b/lib/datadog_api_client/v2/models/cost_tag_key_response.rb new file mode 100644 index 000000000000..bb2c573c0de2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_key_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 + # A single Cloud Cost Management tag key. + class CostTagKeyResponse + include BaseGenericModel + + # A Cloud Cost Management tag key. + 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' => :'CostTagKey' + } + 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::CostTagKeyResponse` 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/cost_tag_key_type.rb b/lib/datadog_api_client/v2/models/cost_tag_key_type.rb new file mode 100644 index 000000000000..469c9cc76132 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_key_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 + # Type of the Cloud Cost Management tag key resource. + class CostTagKeyType + include BaseEnumModel + + COST_TAG_KEY = "cost_tag_key".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/cost_tag_keys_response.rb b/lib/datadog_api_client/v2/models/cost_tag_keys_response.rb new file mode 100644 index 000000000000..a3d73d7a0b31 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_keys_response.rb @@ -0,0 +1,125 @@ +=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 list of Cloud Cost Management tag keys. + class CostTagKeysResponse + include BaseGenericModel + + # The list of Cloud Cost Management tag keys. + 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' => :'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::CostTagKeysResponse` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = 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 @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/cost_tag_type.rb b/lib/datadog_api_client/v2/models/cost_tag_type.rb new file mode 100644 index 000000000000..9aae770573be --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tag_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 + # Type of the Cloud Cost Management tag resource. + class CostTagType + include BaseEnumModel + + COST_TAG = "cost_tag".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/cost_tags_response.rb b/lib/datadog_api_client/v2/models/cost_tags_response.rb new file mode 100644 index 000000000000..9c89ab354ef3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cost_tags_response.rb @@ -0,0 +1,125 @@ +=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 list of Cloud Cost Management tags. + class CostTagsResponse + include BaseGenericModel + + # The list of Cloud Cost Management tags. + 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' => :'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::CostTagsResponse` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = 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 @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 From 243ca14f91e791b72ae2b51294c694b1f2ba29da Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 16:39:39 -0400 Subject: [PATCH 4/4] Regenerate client from commit 8c9b068 of spec repo (#3327) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 12 +++++++++++- features/scenarios_model_mapping.rb | 1 + lib/datadog_api_client/v2/api/metrics_api.rb | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index faa94f948b80..73163c4c177d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -116514,12 +116514,22 @@ paths: /api/v2/metrics/{metric_name}/volumes: get: description: |- - View distinct metrics volumes for the given metric name. + View hourly average metric volumes for the given metric name over the look back period. Custom metrics generated in-app from other products will return `null` for ingested volumes. operationId: ListVolumesByMetricName parameters: - $ref: "#/components/parameters/MetricName" + - description: |- + The number of seconds of look back (from now). + Default value is 3,600 (1 hour), maximum value is 2,592,000 (1 month). + example: 7200 + in: query + name: window[seconds] + required: false + schema: + format: int64 + type: integer responses: "200": content: diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 55709e0a558b..ec3f4f8a915c 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3247,6 +3247,7 @@ }, "v2.ListVolumesByMetricName" => { "metric_name" => "String", + "window_seconds" => "Integer", }, "v2.QueryScalarData" => { "body" => "ScalarFormulaQueryRequest", diff --git a/lib/datadog_api_client/v2/api/metrics_api.rb b/lib/datadog_api_client/v2/api/metrics_api.rb index f77368485a7d..d9cda9def75a 100644 --- a/lib/datadog_api_client/v2/api/metrics_api.rb +++ b/lib/datadog_api_client/v2/api/metrics_api.rb @@ -879,12 +879,13 @@ def list_volumes_by_metric_name(metric_name, opts = {}) # List distinct metric volumes by metric name. # - # View distinct metrics volumes for the given metric name. + # View hourly average metric volumes for the given metric name over the look back period. # # Custom metrics generated in-app from other products will return `null` for ingested volumes. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters + # @option opts [Integer] :window_seconds The number of seconds of look back (from now). Default value is 3,600 (1 hour), maximum value is 2,592,000 (1 month). # @return [Array<(MetricVolumesResponse, Integer, Hash)>] MetricVolumesResponse data, response status code and response headers def list_volumes_by_metric_name_with_http_info(metric_name, opts = {}) @@ -900,6 +901,7 @@ def list_volumes_by_metric_name_with_http_info(metric_name, opts = {}) # query parameters query_params = opts[:query_params] || {} + query_params[:'window[seconds]'] = opts[:'window_seconds'] if !opts[:'window_seconds'].nil? # header parameters header_params = opts[:header_params] || {}