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-11-04 17:58:13.167732",
"spec_repo_commit": "6ffe013b"
"regenerated": "2024-11-04 18:34:33.238993",
"spec_repo_commit": "aeb956c4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-11-04 17:58:13.187613",
"spec_repo_commit": "6ffe013b"
"regenerated": "2024-11-04 18:34:33.257596",
"spec_repo_commit": "aeb956c4"
}
}
}
4 changes: 4 additions & 0 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ module {{ module_name }}::{{ version|upper }}
:return_type => return_type,
:api_version => "{{ version|upper }}"
)
{%- set query_multi_params = operation|parameters | map(attribute=1) | selectattr("in", "equalto", "query")| map("collection_format")| select("eq", "multi") | first-%}
{%- if query_multi_params %}
new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER
{%- endif %}

data, status_code, headers = @api_client.call_api(Net::HTTP::{{ httpMethod|camel_case }}, local_var_path, new_options)
if @api_client.config.debugging
Expand Down
1 change: 1 addition & 0 deletions .generator/src/generator/templates/api_client.j2
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ module {{ module_name }}

req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file
req_opts[:pem_password] = File.read(@config.key_file) if @config.key_file
req_opts[:query_string_normalizer] = opts[:query_string_normalizer] if opts[:query_string_normalizer]

opts[:stream_body] = true if opts[:return_type] == 'File'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-10-21T20:05:58.636Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions examples/v2/security-monitoring/ListFindings_1668290866.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# List findings with detection_type query param returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.list_findings".to_sym] = true
end
api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new
opts = {
filter_vulnerability_type: [
FindingVulnerabilityType::MISCONFIGURATION,
FindingVulnerabilityType::ATTACK_PATH,
],
}
p api_instance.list_findings(opts)
5 changes: 3 additions & 2 deletions features/step_definitions/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require_relative '../scenarios_model_mapping'

SLEEP_AFTER_REQUEST = ENV.has_key?("SLEEP_AFTER_REQUEST") ? ENV["SLEEP_AFTER_REQUEST"].to_i : 0
WebMock::Config.instance.query_values_notation = :flat_array

module APIWorld
def api
Expand Down Expand Up @@ -100,7 +101,7 @@ def relative_time(iso)
return ret.rfc3339(3) if iso
return ret.to_i
end
return nil
nil
}
end

Expand Down Expand Up @@ -221,7 +222,7 @@ def build_given(api_version, operation)
def model_builder(param, obj)
model = ScenariosModelMappings["v#{@api_version}.#{@operation_id}"][param]
if model == 'File'
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
end
@api_client.convert_to_type(obj, model, "V#{@api_version}")
end
Expand Down
9 changes: 8 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ def use_real_time?
c.register_request_matcher :safe_headers do |r1, r2|
r1.headers.slice(*filtered_headers) == r2.headers.slice(*filtered_headers)
end
c.register_request_matcher :ignore_query_param_ordering do |r1, r2|
uri1 = URI(r1.uri)
uri2 = URI(r2.uri)
query1 = CGI.parse(uri1.query || '').transform_values(&:sort)
query2 = CGI.parse(uri2.query || '').transform_values(&:sort)
query1 == query2
end
c.default_cassette_options = {
:record_on_error => false,
:match_requests_on => [:method, :host, :safe_path, :query, :body_as_json, :safe_headers],
:match_requests_on => [:method, :host, :safe_path, :ignore_query_param_ordering, :body_as_json, :safe_headers],

Choose a reason for hiding this comment

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

Code Quality Violation

Suggested change
:match_requests_on => [:method, :host, :safe_path, :ignore_query_param_ordering, :body_as_json, :safe_headers],
:match_requests_on => %i[method host safe_path ignore_query_param_ordering body_as_json safe_headers],
Consider using the %i syntax instead (...read more)

The rule "Prefer %i to the literal array syntax" is a guideline that encourages the use of the %i syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.

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 %i syntax can make your code cleaner and easier to read.

To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz], use the %i syntax like %i[foo bar baz]. It's a good practice to consistently use %i for arrays of symbols as it enhances code readability and maintainability.

View in Datadog  Leave us feedback  Documentation

}
c.allow_http_connections_when_no_cassette = true
RecordMode.send(ENV["RECORD"] || "false", c)
Expand Down
8 changes: 8 additions & 0 deletions features/v2/security_monitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ Feature: Security Monitoring
When the request with pagination is sent
Then the response status is 200 OK

@skip-terraform-config @team:DataDog/cloud-security-posture-management
Scenario: List findings with detection_type query param returns "OK" response
Given operation "ListFindings" enabled
And new "ListFindings" request
And request contains "filter[vulnerability_type]" parameter with value ["misconfiguration", "attack_path"]
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/k9-cloud-security-platform
Scenario: List rules returns "Bad Request" response
Given new "ListSecurityMonitoringRules" request
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def build_request(http_method, path, opts = {})

req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file
req_opts[:pem_password] = File.read(@config.key_file) if @config.key_file
req_opts[:query_string_normalizer] = opts[:query_string_normalizer] if opts[:query_string_normalizer]

opts[:stream_body] = true if opts[:return_type] == 'File'

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/v1/api/synthetics_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ def get_api_test_latest_results_with_http_info(public_id, opts = {})
:return_type => return_type,
:api_version => "V1"
)
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
Expand Down Expand Up @@ -1030,6 +1031,7 @@ def get_browser_test_latest_results_with_http_info(public_id, opts = {})
:return_type => return_type,
:api_version => "V1"
)
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
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/v1/api/usage_metering_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,7 @@ def get_usage_logs_by_index_with_http_info(start_hr, opts = {})
:return_type => return_type,
:api_version => "V1"
)
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
Expand Down Expand Up @@ -2759,6 +2760,7 @@ def get_usage_top_avg_metrics_with_http_info(opts = {})
:return_type => return_type,
:api_version => "V1"
)
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
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v2/api/security_monitoring_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ def list_findings_with_http_info(opts = {})
: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
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v2/api/teams_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ def list_teams_with_http_info(opts = {})
: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
Expand Down
Loading