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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-10 19:46:04.854996",
"spec_repo_commit": "049920eb"
"regenerated": "2024-10-16 20:07:14.122500",
"spec_repo_commit": "86072741"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-10 19:46:04.873453",
"spec_repo_commit": "049920eb"
"regenerated": "2024-10-16 20:07:14.140655",
"spec_repo_commit": "86072741"
}
}
}
2 changes: 1 addition & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28730,7 +28730,7 @@ paths:
for cost ending this month.'
in: query
name: end_month
required: true
required: false
schema:
format: date-time
type: string
Expand Down
5 changes: 4 additions & 1 deletion examples/v2/usage-metering/GetMonthlyCostAttribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
config.unstable_operations["v2.get_monthly_cost_attribution".to_sym] = true
end
api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new
p api_instance.get_monthly_cost_attribution((Time.now + -5 * 86400), (Time.now + -3 * 86400), "infra_host_total_cost")
opts = {
end_month: (Time.now + -3 * 86400),
}
p api_instance.get_monthly_cost_attribution((Time.now + -5 * 86400), "infra_host_total_cost", opts)
4 changes: 2 additions & 2 deletions features/v2/usage_metering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Feature: Usage Metering
Given operation "GetMonthlyCostAttribution" enabled
And new "GetMonthlyCostAttribution" request
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "fields" parameter with value "not_a_product"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 400 Bad Request

Expand All @@ -29,8 +29,8 @@ Feature: Usage Metering
Given operation "GetMonthlyCostAttribution" enabled
And new "GetMonthlyCostAttribution" request
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "fields" parameter with value "infra_host_total_cost"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 200 OK

Expand Down
14 changes: 5 additions & 9 deletions lib/datadog_api_client/v2/api/usage_metering_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ def get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_famil
# Get Monthly Cost Attribution.
#
# @see #get_monthly_cost_attribution_with_http_info
def get_monthly_cost_attribution(start_month, end_month, fields, opts = {})
data, _status_code, _headers = get_monthly_cost_attribution_with_http_info(start_month, end_month, fields, opts)
def get_monthly_cost_attribution(start_month, fields, opts = {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Avoid 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 options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation

data, _status_code, _headers = get_monthly_cost_attribution_with_http_info(start_month, fields, opts)
data
end

Expand All @@ -438,16 +438,16 @@ def get_monthly_cost_attribution(start_month, end_month, fields, opts = {})
# This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/).
#
# @param start_month [Time] Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost beginning in this month.
# @param end_month [Time] Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost ending this month.
# @param fields [String] Comma-separated list specifying cost types (e.g., `<billing_dimension>_on_demand_cost`, `<billing_dimension>_committed_cost`, `<billing_dimension>_total_cost`) and the proportions (`<billing_dimension>_percentage_in_org`, `<billing_dimension>_percentage_in_account`). Use `*` to retrieve all fields. Example: `infra_host_on_demand_cost,infra_host_percentage_in_account` To obtain the complete list of active billing dimensions that can be used to replace `<billing_dimension>` in the field names, make a request to the [Get active billing dimensions API](https://docs.datadoghq.com/api/latest/usage-metering/#get-active-billing-dimensions-for-cost-attribution).
# @param opts [Hash] the optional parameters
# @option opts [Time] :end_month Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost ending this month.
# @option opts [SortDirection] :sort_direction The direction to sort by: `[desc, asc]`.
# @option opts [String] :sort_name The billing dimension to sort by. Always sorted by total cost. Example: `infra_host`.
# @option opts [String] :tag_breakdown_keys Comma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags. To see which tags are available, look for the value of `tag_config_source` in the API response.
# @option opts [String] :next_record_id List following results with a next_record_id provided in the previous query.
# @option opts [Boolean] :include_descendants Include child org cost in the response. Defaults to `true`.
# @return [Array<(MonthlyCostAttributionResponse, Integer, Hash)>] MonthlyCostAttributionResponse data, response status code and response headers
def get_monthly_cost_attribution_with_http_info(start_month, end_month, fields, opts = {})
def get_monthly_cost_attribution_with_http_info(start_month, fields, opts = {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Avoid 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 options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation

unstable_enabled = @api_client.config.unstable_operations["v2.get_monthly_cost_attribution".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_monthly_cost_attribution")
Expand All @@ -462,10 +462,6 @@ def get_monthly_cost_attribution_with_http_info(start_month, end_month, fields,
if @api_client.config.client_side_validation && start_month.nil?
fail ArgumentError, "Missing the required parameter 'start_month' when calling UsageMeteringAPI.get_monthly_cost_attribution"
end
# verify the required parameter 'end_month' is set
if @api_client.config.client_side_validation && end_month.nil?
fail ArgumentError, "Missing the required parameter 'end_month' when calling UsageMeteringAPI.get_monthly_cost_attribution"
end
# verify the required parameter 'fields' is set
if @api_client.config.client_side_validation && fields.nil?
fail ArgumentError, "Missing the required parameter 'fields' when calling UsageMeteringAPI.get_monthly_cost_attribution"
Expand All @@ -480,8 +476,8 @@ def get_monthly_cost_attribution_with_http_info(start_month, end_month, fields,
# query parameters
query_params = opts[:query_params] || {}
query_params[:'start_month'] = start_month
query_params[:'end_month'] = end_month
query_params[:'fields'] = fields
query_params[:'end_month'] = opts[:'end_month'] if !opts[:'end_month'].nil?
query_params[:'sort_direction'] = opts[:'sort_direction'] if !opts[:'sort_direction'].nil?
query_params[:'sort_name'] = opts[:'sort_name'] if !opts[:'sort_name'].nil?
query_params[:'tag_breakdown_keys'] = opts[:'tag_breakdown_keys'] if !opts[:'tag_breakdown_keys'].nil?
Expand Down
Loading