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