Skip to content

Commit cfd2eff

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 90ca7ea of spec repo
1 parent c18c050 commit cfd2eff

27 files changed

+2567
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 419 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Search flaky tests returns "OK" response
2+
3+
require "datadog_api_client"
4+
DatadogAPIClient.configure do |config|
5+
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
6+
end
7+
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new
8+
9+
body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({
10+
data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({
11+
attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({
12+
filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({
13+
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
14+
}),
15+
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
16+
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
17+
limit: 25,
18+
}),
19+
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FAILURE_RATE_ASCENDING,
20+
}),
21+
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
22+
}),
23+
})
24+
opts = {
25+
body: body,
26+
}
27+
p api_instance.search_flaky_tests(opts)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Search flaky tests returns "OK" response with pagination
2+
3+
require "datadog_api_client"
4+
DatadogAPIClient.configure do |config|
5+
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
6+
end
7+
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new
8+
9+
body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({
10+
data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({
11+
attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({
12+
filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({
13+
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"',
14+
}),
15+
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
16+
cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==",
17+
limit: 25,
18+
}),
19+
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FAILURE_RATE_ASCENDING,
20+
}),
21+
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
22+
}),
23+
})
24+
opts = {
25+
body: body,
26+
}
27+
api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Search flaky tests returns "OK" response with filtered query
2+
3+
require "datadog_api_client"
4+
DatadogAPIClient.configure do |config|
5+
config.unstable_operations["v2.search_flaky_tests".to_sym] = true
6+
end
7+
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new
8+
9+
body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({
10+
data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({
11+
attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({
12+
filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({
13+
query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/cart-tracking"',
14+
}),
15+
page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({
16+
limit: 10,
17+
}),
18+
sort: DatadogAPIClient::V2::FlakyTestsSearchSort::LAST_FLAKED_DESCENDING,
19+
}),
20+
type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST,
21+
}),
22+
})
23+
opts = {
24+
body: body,
25+
}
26+
api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item }

features/scenarios_model_mapping.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,6 +2911,9 @@
29112911
"team_id" => "String",
29122912
"body" => "IncidentTeamUpdateRequest",
29132913
},
2914+
"v2.SearchFlakyTests" => {
2915+
"body" => "FlakyTestsSearchRequest",
2916+
},
29142917
"v2.SendInvitations" => {
29152918
"body" => "UserInvitationsRequest",
29162919
},
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@endpoint(test-optimization) @endpoint(test-optimization-v2)
2+
Feature: Test Optimization
3+
Search and manage flaky tests through Test Optimization. See the [Test
4+
Optimization page](https://docs.datadoghq.com/tests/) for more
5+
information.
6+
7+
Background:
8+
Given a valid "apiKeyAuth" key in the system
9+
And a valid "appKeyAuth" key in the system
10+
And an instance of "TestOptimization" API
11+
And operation "SearchFlakyTests" enabled
12+
And new "SearchFlakyTests" request
13+
14+
@generated @skip @team:DataDog/ci-app-backend
15+
Scenario: Search flaky tests returns "Bad Request" response
16+
Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
17+
When the request is sent
18+
Then the response status is 400 Bad Request
19+
20+
@skip @team:DataDog/ci-app-backend
21+
Scenario: Search flaky tests returns "Bad Request" response with invalid limit
22+
Given body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}}
23+
When the request is sent
24+
Then the response status is 400 Bad Request
25+
26+
@generated @skip @team:DataDog/ci-app-backend
27+
Scenario: Search flaky tests returns "OK" response
28+
Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
29+
When the request is sent
30+
Then the response status is 200 OK
31+
32+
@replay-only @skip @skip-validation @team:DataDog/ci-app-backend @with-pagination
33+
Scenario: Search flaky tests returns "OK" response with filtered query
34+
Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/cart-tracking\""}, "page": {"limit": 10}, "sort": "-last_flaked"}, "type": "search_flaky_tests_request"}}
35+
When the request with pagination is sent
36+
Then the response status is 200 OK
37+
38+
@generated @skip @team:DataDog/ci-app-backend @with-pagination
39+
Scenario: Search flaky tests returns "OK" response with pagination
40+
Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}}
41+
When the request with pagination is sent
42+
Then the response status is 200 OK

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,6 +3829,12 @@
38293829
"type": "idempotent"
38303830
}
38313831
},
3832+
"SearchFlakyTests": {
3833+
"tag": "Test Optimization",
3834+
"undo": {
3835+
"type": "safe"
3836+
}
3837+
},
38323838
"GetUsageApplicationSecurityMonitoring": {
38333839
"tag": "Usage Metering",
38343840
"undo": {

lib/datadog_api_client/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def initialize
291291
"v2.get_incident_team": false,
292292
"v2.list_incident_teams": false,
293293
"v2.update_incident_team": false,
294+
"v2.search_flaky_tests": false,
294295
}
295296
@server_variables[:site] = ENV['DD_SITE'] if ENV.key? 'DD_SITE'
296297
@api_key['apiKeyAuth'] = ENV['DD_API_KEY'] if ENV.key? 'DD_API_KEY'

lib/datadog_api_client/inflector.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,23 @@ def overrides
19961996
"v2.finding_status" => "FindingStatus",
19971997
"v2.finding_type" => "FindingType",
19981998
"v2.finding_vulnerability_type" => "FindingVulnerabilityType",
1999+
"v2.flaky_test" => "FlakyTest",
2000+
"v2.flaky_test_attributes" => "FlakyTestAttributes",
2001+
"v2.flaky_test_attributes_flaky_state" => "FlakyTestAttributesFlakyState",
2002+
"v2.flaky_test_pipeline_stats" => "FlakyTestPipelineStats",
2003+
"v2.flaky_test_run_metadata" => "FlakyTestRunMetadata",
2004+
"v2.flaky_tests_pagination" => "FlakyTestsPagination",
2005+
"v2.flaky_tests_search_filter" => "FlakyTestsSearchFilter",
2006+
"v2.flaky_tests_search_page_options" => "FlakyTestsSearchPageOptions",
2007+
"v2.flaky_tests_search_request" => "FlakyTestsSearchRequest",
2008+
"v2.flaky_tests_search_request_attributes" => "FlakyTestsSearchRequestAttributes",
2009+
"v2.flaky_tests_search_request_data" => "FlakyTestsSearchRequestData",
2010+
"v2.flaky_tests_search_request_data_type" => "FlakyTestsSearchRequestDataType",
2011+
"v2.flaky_tests_search_response" => "FlakyTestsSearchResponse",
2012+
"v2.flaky_tests_search_response_meta" => "FlakyTestsSearchResponseMeta",
2013+
"v2.flaky_tests_search_sort" => "FlakyTestsSearchSort",
2014+
"v2.flaky_test_stats" => "FlakyTestStats",
2015+
"v2.flaky_test_type" => "FlakyTestType",
19992016
"v2.formula_limit" => "FormulaLimit",
20002017
"v2.framework_handle_and_version_response_data" => "FrameworkHandleAndVersionResponseData",
20012018
"v2.freshservice_api_key" => "FreshserviceAPIKey",
@@ -4110,6 +4127,7 @@ def overrides
41104127
"v2.spans_metrics_api" => "SpansMetricsAPI",
41114128
"v2.synthetics_api" => "SyntheticsAPI",
41124129
"v2.teams_api" => "TeamsAPI",
4130+
"v2.test_optimization_api" => "TestOptimizationAPI",
41134131
"v2.usage_metering_api" => "UsageMeteringAPI",
41144132
"v2.users_api" => "UsersAPI",
41154133
"v2.workflow_automation_api" => "WorkflowAutomationAPI"
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'cgi'
17+
18+
module DatadogAPIClient::V2
19+
class TestOptimizationAPI
20+
attr_accessor :api_client
21+
22+
def initialize(api_client = DatadogAPIClient::APIClient.default)
23+
@api_client = api_client
24+
end
25+
26+
# Search flaky tests.
27+
#
28+
# @see #search_flaky_tests_with_http_info
29+
def search_flaky_tests(opts = {})
30+
data, _status_code, _headers = search_flaky_tests_with_http_info(opts)
31+
data
32+
end
33+
34+
# Search flaky tests.
35+
#
36+
# List endpoint returning flaky tests from Flaky Test Management. Results are paginated.
37+
#
38+
# @param opts [Hash] the optional parameters
39+
# @option opts [FlakyTestsSearchRequest] :body
40+
# @return [Array<(FlakyTestsSearchResponse, Integer, Hash)>] FlakyTestsSearchResponse data, response status code and response headers
41+
def search_flaky_tests_with_http_info(opts = {})
42+
unstable_enabled = @api_client.config.unstable_operations["v2.search_flaky_tests".to_sym]
43+
if unstable_enabled
44+
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.search_flaky_tests")
45+
else
46+
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.search_flaky_tests"))
47+
end
48+
49+
if @api_client.config.debugging
50+
@api_client.config.logger.debug 'Calling API: TestOptimizationAPI.search_flaky_tests ...'
51+
end
52+
# resource path
53+
local_var_path = '/api/v2/test/flaky-test-management/tests'
54+
55+
# query parameters
56+
query_params = opts[:query_params] || {}
57+
58+
# header parameters
59+
header_params = opts[:header_params] || {}
60+
# HTTP header 'Accept' (if needed)
61+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
62+
# HTTP header 'Content-Type'
63+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
64+
65+
# form parameters
66+
form_params = opts[:form_params] || {}
67+
68+
# http body (model)
69+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])
70+
71+
# return_type
72+
return_type = opts[:debug_return_type] || 'FlakyTestsSearchResponse'
73+
74+
# auth_names
75+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]
76+
77+
new_options = opts.merge(
78+
:operation => :search_flaky_tests,
79+
:header_params => header_params,
80+
:query_params => query_params,
81+
:form_params => form_params,
82+
:body => post_body,
83+
:auth_names => auth_names,
84+
:return_type => return_type,
85+
:api_version => "V2"
86+
)
87+
88+
data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
89+
if @api_client.config.debugging
90+
@api_client.config.logger.debug "API called: TestOptimizationAPI#search_flaky_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
91+
end
92+
return data, status_code, headers
93+
end
94+
95+
# Search flaky tests.
96+
#
97+
# Provide a paginated version of {#search_flaky_tests}, returning all items.
98+
#
99+
# To use it you need to use a block: search_flaky_tests_with_pagination { |item| p item }
100+
#
101+
# @yield [FlakyTest] Paginated items
102+
def search_flaky_tests_with_pagination(opts = {})
103+
api_version = "V2"
104+
page_size = @api_client.get_attribute_from_path(opts, "body.data.attributes.page.limit", 10)
105+
@api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.limit", FlakyTestsSearchRequest, page_size)
106+
while true do
107+
response = search_flaky_tests(opts)
108+
@api_client.get_attribute_from_path(response, "data").each { |item| yield(item) }
109+
if @api_client.get_attribute_from_path(response, "data").length < page_size
110+
break
111+
end
112+
@api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.cursor", FlakyTestsSearchRequest, @api_client.get_attribute_from_path(response, "meta.pagination.next_page"))
113+
end
114+
end
115+
end
116+
end

0 commit comments

Comments
 (0)