-
Notifications
You must be signed in to change notification settings - Fork 22
Documentation for beta /v2/usage/billing_dimension_mapping #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-10-28T16:04:40.774Z |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Get billing dimension mapping for usage endpoints returns "OK" response | ||
|
||
require "datadog_api_client" | ||
DatadogAPIClient.configure do |config| | ||
config.unstable_operations["v2.get_billing_dimension_mapping".to_sym] = true | ||
end | ||
api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new | ||
p api_instance.get_billing_dimension_mapping() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1129,6 +1129,10 @@ | |
"start_hr" => "Time", | ||
"end_hr" => "Time", | ||
}, | ||
"v2.GetBillingDimensionMapping" => { | ||
"filter_month" => "Time", | ||
"filter_view" => "String", | ||
}, | ||
Comment on lines
+1132
to
+1135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationConsider using symbols instead of string hash keys (...read more)In Ruby, it is a best practice to use symbols instead of strings as hash keys. This rule emphasizes that it's more efficient and idiomatic to use symbols for this purpose. Symbols are immutable and unique, which makes them ideal for identifying things, whereas strings are mutable and can create multiple objects for the same sequence of characters. The importance of this rule lies in the performance and memory usage of your Ruby application. Using symbols as hash keys reduces memory usage because they are stored in memory only once during a Ruby process. This can make a significant difference in the efficiency of your application, especially when dealing with large data sets. To ensure you're following good coding practices, always use symbols for hash keys unless there's a specific reason to use a string. A simple refactoring from |
||
"v2.GetCostByOrg" => { | ||
"start_month" => "Time", | ||
"end_month" => "Time", | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -89,6 +89,79 @@ def get_active_billing_dimensions_with_http_info(opts = {}) | |||||
return data, status_code, headers | ||||||
end | ||||||
|
||||||
# Get billing dimension mapping for usage endpoints. | ||||||
# | ||||||
# @see #get_billing_dimension_mapping_with_http_info | ||||||
def get_billing_dimension_mapping(opts = {}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationAvoid using a hash as an optional parameter (...read more)The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect. This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand. To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using |
||||||
data, _status_code, _headers = get_billing_dimension_mapping_with_http_info(opts) | ||||||
data | ||||||
end | ||||||
|
||||||
# Get billing dimension mapping for usage endpoints. | ||||||
# | ||||||
# Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints. | ||||||
# Mapping data is updated on a monthly cadence. | ||||||
# | ||||||
# This endpoint is only accessible to [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). | ||||||
# | ||||||
# @param opts [Hash] the optional parameters | ||||||
# @option opts [Time] :filter_month Datetime in ISO-8601 format, UTC, and for mappings beginning this month. Defaults to the current month. | ||||||
# @option opts [String] :filter_view String to specify whether to retrieve active billing dimension mappings for the contract or for all available mappings. Allowed views have the string `active` or `all`. Defaults to `active`. | ||||||
# @return [Array<(BillingDimensionsMappingResponse, Integer, Hash)>] BillingDimensionsMappingResponse data, response status code and response headers | ||||||
def get_billing_dimension_mapping_with_http_info(opts = {}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationAvoid using a hash as an optional parameter (...read more)The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect. This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand. To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using |
||||||
unstable_enabled = @api_client.config.unstable_operations["v2.get_billing_dimension_mapping".to_sym] | ||||||
if unstable_enabled | ||||||
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_billing_dimension_mapping") | ||||||
else | ||||||
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_billing_dimension_mapping")) | ||||||
end | ||||||
|
||||||
if @api_client.config.debugging | ||||||
@api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_billing_dimension_mapping ...' | ||||||
end | ||||||
# resource path | ||||||
local_var_path = '/api/v2/usage/billing_dimension_mapping' | ||||||
|
||||||
# query parameters | ||||||
query_params = opts[:query_params] || {} | ||||||
query_params[:'filter[month]'] = opts[:'filter_month'] if !opts[:'filter_month'].nil? | ||||||
query_params[:'filter[view]'] = opts[:'filter_view'] if !opts[:'filter_view'].nil? | ||||||
|
||||||
# header parameters | ||||||
header_params = opts[:header_params] || {} | ||||||
# HTTP header 'Accept' (if needed) | ||||||
header_params['Accept'] = @api_client.select_header_accept(['application/json;datetime-format=rfc3339']) | ||||||
|
||||||
# form parameters | ||||||
form_params = opts[:form_params] || {} | ||||||
|
||||||
# http body (model) | ||||||
post_body = opts[:debug_body] | ||||||
|
||||||
# return_type | ||||||
return_type = opts[:debug_return_type] || 'BillingDimensionsMappingResponse' | ||||||
|
||||||
# auth_names | ||||||
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality Violation
Suggested change
Consider using the %i syntax instead (...read more)The rule "Prefer Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like |
||||||
|
||||||
new_options = opts.merge( | ||||||
:operation => :get_billing_dimension_mapping, | ||||||
: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: UsageMeteringAPI#get_billing_dimension_mapping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" | ||||||
end | ||||||
return data, status_code, headers | ||||||
end | ||||||
|
||||||
# Get cost across multi-org account. | ||||||
# | ||||||
# @see #get_cost_by_org_with_http_info | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
Do not use parentheses with methods that take no arguments (...read more)
The rule "Avoid parentheses when methods take no arguments" is part of the Ruby style guide. It suggests that when a method takes no arguments, you should not use parentheses. This is because the use of parentheses in such a case is redundant and unnecessary, and it can make your code more difficult to read and understand.
This rule is important because it promotes cleaner, more readable code. In Ruby, clean and readable code is highly valued. By following this rule, you can ensure your code is easier to understand and maintain, which is crucial for long-term project success.
To adhere to this rule, remove the parentheses when calling a method that does not require any arguments. For example, instead of writing
'test'.upcase()
, you should write'test'.upcase
. Similarly, instead ofKernel.exit!()
, writeKernel.exit!
. However, note that there is an exception forsuper
-super
by itself is different fromsuper()
, so in this case, parentheses may be necessary.