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": "2025-02-20 13:35:00.547017",
"spec_repo_commit": "c64543d0"
"regenerated": "2025-02-20 18:33:33.220649",
"spec_repo_commit": "d3fcdb89"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-20 13:35:00.565048",
"spec_repo_commit": "c64543d0"
"regenerated": "2025-02-20 18:33:33.236028",
"spec_repo_commit": "d3fcdb89"
}
}
}
38 changes: 35 additions & 3 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,33 @@ components:
xray_services:
$ref: '#/components/schemas/XRayServicesList'
type: object
AccountFilteringConfig:
description: The account filtering configuration.
properties:
excluded_accounts:
description: The AWS account IDs to be excluded from your billing dataset.
This field is used when `include_new_accounts` is `true`.
example:
- '123456789123'
- '123456789143'
items:
type: string
type: array
include_new_accounts:
description: Whether or not to automatically include new member accounts
by default in your billing dataset.
example: true
type: boolean
included_accounts:
description: The AWS account IDs to be included in your billing dataset.
This field is used when `include_new_accounts` is `false`.
example:
- '123456789123'
- '123456789143'
items:
type: string
type: array
type: object
ActionConnectionAttributes:
description: The definition of `ActionConnectionAttributes` object.
properties:
Expand Down Expand Up @@ -2870,6 +2897,8 @@ components:
AwsCURConfigAttributes:
description: Attributes for An AWS CUR config.
properties:
account_filters:
$ref: '#/components/schemas/AccountFilteringConfig'
account_id:
description: The AWS account ID.
example: '123456789123'
Expand Down Expand Up @@ -2947,12 +2976,12 @@ components:
AwsCURConfigPatchRequestAttributes:
description: Attributes for AWS CUR config Patch Request.
properties:
account_filters:
$ref: '#/components/schemas/AccountFilteringConfig'
is_enabled:
description: Whether or not the Cloud Cost Management account is enabled.
example: true
type: boolean
required:
- is_enabled
type: object
AwsCURConfigPatchRequestType:
default: aws_cur_config_patch_request
Expand Down Expand Up @@ -2985,6 +3014,8 @@ components:
AwsCURConfigPostRequestAttributes:
description: Attributes for AWS CUR config Post Request.
properties:
account_filters:
$ref: '#/components/schemas/AccountFilteringConfig'
account_id:
description: The AWS account ID.
example: '123456789123'
Expand Down Expand Up @@ -35630,7 +35661,8 @@ paths:
permissions:
- cloud_cost_management_write
patch:
description: Update the status of an AWS CUR config (active/archived).
description: Update the status (active/archived) and/or account filtering configuration
of an AWS CUR config.
operationId: UpdateCostAWSCURConfig
parameters:
- $ref: '#/components/parameters/CloudAccountID'
Expand Down
2 changes: 1 addition & 1 deletion features/v2/cloud_cost_management.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Cloud Cost Management
@generated @skip @team:Datadog/cloud-cost-management
Scenario: Create Cloud Cost Management AWS CUR config returns "Bad Request" response
Given new "CreateCostAWSCURConfig" request
And body with value {"data": {"attributes": {"account_id": "123456789123", "bucket_name": "dd-cost-bucket", "bucket_region": "us-east-1", "report_name": "dd-report-name", "report_prefix": "dd-report-prefix"}, "type": "aws_cur_config_post_request"}}
And body with value {"data": {"attributes": {"account_filters": {"excluded_accounts": ["123456789123", "123456789143"], "include_new_accounts": true, "included_accounts": ["123456789123", "123456789143"]}, "account_id": "123456789123", "bucket_name": "dd-cost-bucket", "bucket_region": "us-east-1", "report_name": "dd-report-name", "report_prefix": "dd-report-prefix"}, "type": "aws_cur_config_post_request"}}
When the request is sent
Then the response status is 400 Bad Request

Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ def overrides
"v1.widget_vertical_align" => "WidgetVerticalAlign",
"v1.widget_view_mode" => "WidgetViewMode",
"v1.widget_viz_type" => "WidgetVizType",
"v2.account_filtering_config" => "AccountFilteringConfig",
"v2.action_connection_attributes" => "ActionConnectionAttributes",
"v2.action_connection_attributes_update" => "ActionConnectionAttributesUpdate",
"v2.action_connection_data" => "ActionConnectionData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def update_cost_awscur_config(cloud_account_id, body, opts = {})

# Update Cloud Cost Management AWS CUR config.
#
# Update the status of an AWS CUR config (active/archived).
# Update the status (active/archived) and/or account filtering configuration of an AWS CUR config.
#
# @param cloud_account_id [String] Cloud Account id.
# @param body [AwsCURConfigPatchRequest]
Expand Down
129 changes: 129 additions & 0 deletions lib/datadog_api_client/v2/models/account_filtering_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
=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
# The account filtering configuration.
class AccountFilteringConfig
include BaseGenericModel

# The AWS account IDs to be excluded from your billing dataset. This field is used when `include_new_accounts` is `true`.
attr_accessor :excluded_accounts

# Whether or not to automatically include new member accounts by default in your billing dataset.
attr_accessor :include_new_accounts

# The AWS account IDs to be included in your billing dataset. This field is used when `include_new_accounts` is `false`.
attr_accessor :included_accounts

attr_accessor :additional_properties

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'excluded_accounts' => :'excluded_accounts',
:'include_new_accounts' => :'include_new_accounts',
:'included_accounts' => :'included_accounts'
}
end

# Attribute type mapping.
# @!visibility private
def self.openapi_types
{
:'excluded_accounts' => :'Array<String>',
:'include_new_accounts' => :'Boolean',
:'included_accounts' => :'Array<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::AccountFilteringConfig` 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?(:'excluded_accounts')
if (value = attributes[:'excluded_accounts']).is_a?(Array)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Quality Violation

Consider using Array() to ensure the type is that of an array (...read more)

The rule "Use Array() to ensure your variable is an array" is important for ensuring your code behaves as expected, regardless of the type of data it receives. It is common in Ruby to need to iterate through an array of items. However, if the variable is not an array, this can lead to unexpected behavior or errors.

The Array() method in Ruby is a Kernel method that converts its argument to an Array. If the argument is already an Array, it returns the argument. If the argument is nil, it returns an empty Array. This can be used to ensure that a variable is an array before trying to iterate over it, preventing potential errors or unexpected behavior.

By using Array(foos), you can ensure that foos is an array before you try to iterate over it with each. This prevents the need to check if foos is an array with foos.is_a?(Array) and makes your code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation

self.excluded_accounts = value
end
end

if attributes.key?(:'include_new_accounts')
self.include_new_accounts = attributes[:'include_new_accounts']
end

if attributes.key?(:'included_accounts')
if (value = attributes[:'included_accounts']).is_a?(Array)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Quality Violation

Consider using Array() to ensure the type is that of an array (...read more)

The rule "Use Array() to ensure your variable is an array" is important for ensuring your code behaves as expected, regardless of the type of data it receives. It is common in Ruby to need to iterate through an array of items. However, if the variable is not an array, this can lead to unexpected behavior or errors.

The Array() method in Ruby is a Kernel method that converts its argument to an Array. If the argument is already an Array, it returns the argument. If the argument is nil, it returns an empty Array. This can be used to ensure that a variable is an array before trying to iterate over it, preventing potential errors or unexpected behavior.

By using Array(foos), you can ensure that foos is an array before you try to iterate over it with each. This prevents the need to check if foos is an array with foos.is_a?(Array) and makes your code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation

self.included_accounts = value
end
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 &&
excluded_accounts == o.excluded_accounts &&
include_new_accounts == o.include_new_accounts &&
included_accounts == o.included_accounts &&
additional_properties == o.additional_properties
end

# Calculates hash code according to all attributes.
# @return [Integer] Hash code
# @!visibility private
def hash
[excluded_accounts, include_new_accounts, included_accounts, additional_properties].hash
end
end
end
12 changes: 11 additions & 1 deletion lib/datadog_api_client/v2/models/aws_cur_config_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module DatadogAPIClient::V2
class AwsCURConfigAttributes
include BaseGenericModel

# The account filtering configuration.
attr_accessor :account_filters

# The AWS account ID.
attr_reader :account_id

Expand Down Expand Up @@ -60,6 +63,7 @@ class AwsCURConfigAttributes
# @!visibility private
def self.attribute_map
{
:'account_filters' => :'account_filters',
:'account_id' => :'account_id',
:'bucket_name' => :'bucket_name',
:'bucket_region' => :'bucket_region',
Expand All @@ -78,6 +82,7 @@ def self.attribute_map
# @!visibility private
def self.openapi_types
{
:'account_filters' => :'AccountFilteringConfig',
:'account_id' => :'String',
:'bucket_name' => :'String',
:'bucket_region' => :'String',
Expand Down Expand Up @@ -110,6 +115,10 @@ def initialize(attributes = {})
end
}

if attributes.key?(:'account_filters')
self.account_filters = attributes[:'account_filters']
end

if attributes.key?(:'account_id')
self.account_id = attributes[:'account_id']
end
Expand Down Expand Up @@ -306,6 +315,7 @@ def to_hash
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
account_filters == o.account_filters &&
account_id == o.account_id &&
bucket_name == o.bucket_name &&
bucket_region == o.bucket_region &&
Expand All @@ -324,7 +334,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[account_id, bucket_name, bucket_region, created_at, error_messages, months, report_name, report_prefix, status, status_updated_at, updated_at, additional_properties].hash
[account_filters, account_id, bucket_name, bucket_region, created_at, error_messages, months, report_name, report_prefix, status, status_updated_at, updated_at, additional_properties].hash
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ module DatadogAPIClient::V2
class AwsCURConfigPatchRequestAttributes
include BaseGenericModel

# The account filtering configuration.
attr_accessor :account_filters

# Whether or not the Cloud Cost Management account is enabled.
attr_reader :is_enabled
attr_accessor :is_enabled

attr_accessor :additional_properties

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'account_filters' => :'account_filters',
:'is_enabled' => :'is_enabled'
}
end
Expand All @@ -38,6 +42,7 @@ def self.attribute_map
# @!visibility private
def self.openapi_types
{
:'account_filters' => :'AccountFilteringConfig',
:'is_enabled' => :'Boolean'
}
end
Expand All @@ -60,27 +65,13 @@ def initialize(attributes = {})
end
}

if attributes.key?(:'is_enabled')
self.is_enabled = attributes[:'is_enabled']
if attributes.key?(:'account_filters')
self.account_filters = attributes[:'account_filters']
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 @is_enabled.nil?
true
end

# Custom attribute writer method with validation
# @param is_enabled [Object] Object to be assigned
# @!visibility private
def is_enabled=(is_enabled)
if is_enabled.nil?
fail ArgumentError, 'invalid value for "is_enabled", is_enabled cannot be nil.'
if attributes.key?(:'is_enabled')
self.is_enabled = attributes[:'is_enabled']
end
@is_enabled = is_enabled
end

# Returns the object in the form of hash, with additionalProperties support.
Expand Down Expand Up @@ -109,6 +100,7 @@ def to_hash
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
account_filters == o.account_filters &&
is_enabled == o.is_enabled &&
additional_properties == o.additional_properties
end
Expand All @@ -117,7 +109,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[is_enabled, additional_properties].hash
[account_filters, is_enabled, additional_properties].hash
end
end
end
Loading