Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
403 changes: 403 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions examples/v2/cloud-cost-management/GetCostAnomaly.rb
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 8 additions & 0 deletions examples/v2/cloud-cost-management/ListCostAnomalies.rb
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 16 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>",
},
"v2.GetCostAnomaly" => {
"anomaly_id" => "String",
},
"v2.CreateCustomAllocationRule" => {
"body" => "ArbitraryCostUpsertRequest",
},
Expand Down
38 changes: 38 additions & 0 deletions features/v2/cloud_cost_management.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
160 changes: 160 additions & 0 deletions lib/datadog_api_client/v2/api/cloud_cost_management_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>] :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
Expand Down
Loading
Loading