|
| 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