diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 661976d24e3..d4dfe8ead6b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -18645,6 +18645,376 @@ components: - ATTACK_PATH - IDENTITY_RISK - API_SECURITY + FlakyTest: + description: A flaky test object. + properties: + attributes: + $ref: '#/components/schemas/FlakyTestAttributes' + id: + description: Test's ID. This ID is the hash of the test's Fully Qualified + Name and Git repository ID. On the Test Runs UI it is the same as the + `test_fingerprint_fqn` tag. + type: string + type: + $ref: '#/components/schemas/FlakyTestType' + type: object + FlakyTestAttributes: + description: Attributes of a flaky test. + properties: + attempt_to_fix_id: + description: 'Unique identifier for the attempt to fix this flaky test. + Use this ID in the Git commit message in order to trigger the attempt + to fix workflow. + + + When the workflow is triggered the test is automatically retried by the + tracer a certain number of configurable times. When all retries pass, + the test is automatically marked as fixed in Flaky Test Management. + + Test runs are tagged with @test.test_management.attempt_to_fix_passed + and @test.test_management.is_attempt_to_fix when the attempt to fix workflow + is triggered.' + example: I42TEO + type: string + codeowners: + description: The name of the test's code owners as inferred from the repository + configuration. + example: + - '@foo' + - '@bar' + items: + type: string + type: array + envs: + description: List of environments where this test has been flaky. + example: prod + items: + type: string + type: array + first_flaked_branch: + description: The branch name where the test exhibited flakiness for the + first time. + example: main + type: string + first_flaked_sha: + description: The commit SHA where the test exhibited flakiness for the first + time. + example: 0c6be03165b7f7ffe96e076ffb29afb2825616c3 + type: string + first_flaked_ts: + description: Unix timestamp when the test exhibited flakiness for the first + time. + example: 1757688149 + format: int64 + type: integer + flaky_category: + description: The category of a flaky test. + example: Timeout + nullable: true + type: string + flaky_state: + $ref: '#/components/schemas/FlakyTestAttributesFlakyState' + last_flaked_branch: + description: The branch name where the test exhibited flakiness for the + last time. + example: main + type: string + last_flaked_sha: + description: The commit SHA where the test exhibited flakiness for the last + time. + example: 0c6be03165b7f7ffe96e076ffb29afb2825616c3 + type: string + last_flaked_ts: + description: Unix timestamp when the test exhibited flakiness for the last + time. + example: 1757688149 + format: int64 + type: integer + module: + description: 'The name of the test module. The definition of module changes + slightly per language: + + - In .NET, a test module groups every test that is run under the same + unit test project. + + - In Swift, a test module groups every test that is run for a given bundle. + + - In JavaScript, the test modules map one-to-one to test sessions. + + - In Java, a test module groups every test that is run by the same Maven + Surefire/Failsafe or Gradle Test task execution. + + - In Python, a test module groups every test that is run under the same + `.py` file as part of a test suite, which is typically managed by a framework + like `unittest` or `pytest`. + + - In Ruby, a test module groups every test that is run within the same + test file, which is typically managed by a framework like `RSpec` or `Minitest`.' + example: TestModule + nullable: true + type: string + name: + description: The test name. A concise name for a test case. Defined in the + test itself. + example: TestName + type: string + pipeline_stats: + $ref: '#/components/schemas/FlakyTestPipelineStats' + nullable: true + services: + description: 'List of test service names where this test has been flaky. + + + A test service is a group of tests associated with a project or repository. + It contains all the individual tests for your code, optionally organized + into test suites, which are like folders for your tests.' + example: + - foo + - bar + items: + type: string + type: array + suite: + description: The name of the test suite. A group of tests exercising the + same unit of code depending on your language and testing framework. + example: TestSuite + type: string + test_run_metadata: + $ref: '#/components/schemas/FlakyTestRunMetadata' + test_stats: + $ref: '#/components/schemas/FlakyTestStats' + type: object + FlakyTestAttributesFlakyState: + description: The current state of the flaky test. + enum: + - active + - fixed + - quarantined + - disabled + example: active + type: string + x-enum-varnames: + - ACTIVE + - FIXED + - QUARANTINED + - DISABLED + FlakyTestPipelineStats: + description: CI pipeline related statistics for the flaky test. This information + is only available if test runs are associated with CI pipeline events from + CI Visibility. + properties: + failed_pipelines: + description: The number of pipelines that failed due to this test for the + past 7 days. This is computed as the sum of failed CI pipeline events + associated with test runs where the flaky test failed. + example: 319 + format: int64 + nullable: true + type: integer + total_lost_time_ms: + description: The total time lost by CI pipelines due to this flaky test + in milliseconds. This is computed as the sum of the duration of failed + CI pipeline events associated with test runs where the flaky test failed. + example: 1527550000 + format: int64 + nullable: true + type: integer + type: object + FlakyTestRunMetadata: + description: Metadata about the latest failed test run of the flaky test. + properties: + duration_ms: + description: The duration of the test run in milliseconds. + example: 27398 + format: int64 + nullable: true + type: integer + error_message: + description: The error message from the test failure. + example: Expecting actual not to be empty + nullable: true + type: string + error_stack: + description: The stack trace from the test failure. + example: "Traceback (most recent call last):\n File \"test_foo.py\", line + 10, in test_foo\n assert actual == expected\nAssertionError: Expecting + actual not to be empty" + nullable: true + type: string + source_end: + description: The line number where the test ends in the source file. + example: 20 + format: int64 + nullable: true + type: integer + source_file: + description: The source file where the test is defined. + example: test_foo.py + nullable: true + type: string + source_start: + description: The line number where the test starts in the source file. + example: 10 + format: int64 + nullable: true + type: integer + type: object + FlakyTestStats: + description: Test statistics for the flaky test. + properties: + failure_rate_pct: + description: The failure rate percentage of the test for the past 7 days. + This is the number of failed test runs divided by the total number of + test runs (excluding skipped test runs). + example: 0.1 + format: double + nullable: true + type: number + type: object + FlakyTestType: + description: The type of the flaky test from Flaky Test Management. + enum: + - flaky_test + type: string + x-enum-varnames: + - FLAKY_TEST + FlakyTestsPagination: + description: Pagination metadata for flaky tests. + properties: + next_page: + description: Cursor for the next page of results. + nullable: true + type: string + type: object + FlakyTestsSearchFilter: + description: Search filter settings. + properties: + query: + default: '*' + description: 'Search query following log syntax used to filter flaky tests, + same as on Flaky Tests Management UI. The supported search keys are: + + - `flaky_test_state` + + - `flaky_test_category` + + - `@test.name` + + - `@test.suite` + + - `@test.module` + + - `@test.service` + + - `@git.repository.id_v2` + + - `@git.branch` + + - `@test.codeowners` + + - `env` + + ' + example: flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" + type: string + type: object + FlakyTestsSearchPageOptions: + description: Pagination attributes for listing flaky tests. + properties: + cursor: + description: List following results with a cursor provided in the previous + request. + example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== + type: string + limit: + default: 10 + description: Maximum number of flaky tests in the response. + example: 25 + format: int64 + maximum: 1000 + minimum: 1 + type: integer + type: object + FlakyTestsSearchRequest: + description: The request for a flaky tests search. + properties: + data: + $ref: '#/components/schemas/FlakyTestsSearchRequestData' + type: object + FlakyTestsSearchRequestAttributes: + description: Attributes for the flaky tests search request. + properties: + filter: + $ref: '#/components/schemas/FlakyTestsSearchFilter' + page: + $ref: '#/components/schemas/FlakyTestsSearchPageOptions' + sort: + $ref: '#/components/schemas/FlakyTestsSearchSort' + type: object + FlakyTestsSearchRequestData: + description: The JSON:API data for flaky tests search request. + properties: + attributes: + $ref: '#/components/schemas/FlakyTestsSearchRequestAttributes' + type: + $ref: '#/components/schemas/FlakyTestsSearchRequestDataType' + type: object + FlakyTestsSearchRequestDataType: + description: The definition of `FlakyTestsSearchRequestDataType` object. + enum: + - search_flaky_tests_request + type: string + x-enum-varnames: + - SEARCH_FLAKY_TESTS_REQUEST + FlakyTestsSearchResponse: + description: Response object with flaky tests matching the search request. + properties: + data: + description: Array of flaky tests matching the request. + items: + $ref: '#/components/schemas/FlakyTest' + type: array + meta: + $ref: '#/components/schemas/FlakyTestsSearchResponseMeta' + type: object + FlakyTestsSearchResponseMeta: + description: Metadata for the flaky tests search response. + properties: + pagination: + $ref: '#/components/schemas/FlakyTestsPagination' + type: object + FlakyTestsSearchSort: + description: Parameter for sorting flaky test results. The default sort is by + ascending Fully Qualified Name (FQN). The FQN is the concatenation of the + test module, suite, and name. + enum: + - fqn + - -fqn + - first_flaked + - -first_flaked + - last_flaked + - -last_flaked + - failure_rate + - -failure_rate + - pipelines_failed + - -pipelines_failed + - pipelines_duration_lost + - -pipelines_duration_lost + example: failure_rate + type: string + x-enum-varnames: + - FQN_ASCENDING + - FQN_DESCENDING + - FIRST_FLAKED_ASCENDING + - FIRST_FLAKED_DESCENDING + - LAST_FLAKED_ASCENDING + - LAST_FLAKED_DESCENDING + - FAILURE_RATE_ASCENDING + - FAILURE_RATE_DESCENDING + - PIPELINES_FAILED_ASCENDING + - PIPELINES_FAILED_DESCENDING + - PIPELINES_DURATION_LOST_ASCENDING + - PIPELINES_DURATION_LOST_DESCENDING FormulaLimit: description: 'Message for specifying limits to the number of values returned by a query. @@ -74196,6 +74566,52 @@ paths: permissions: - incident_settings_write x-unstable: '**Note**: This endpoint is deprecated. See the [Teams API endpoints](https://docs.datadoghq.com/api/latest/teams/).' + /api/v2/test/flaky-test-management/tests: + post: + description: List endpoint returning flaky tests from Flaky Test Management. + Results are paginated. + operationId: SearchFlakyTests + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FlakyTestsSearchRequest' + required: false + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FlakyTestsSearchResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - test_optimization_read + summary: Search flaky tests + tags: + - Test Optimization + x-codegen-request-body-name: body + x-pagination: + cursorParam: body.data.attributes.page.cursor + cursorPath: meta.pagination.next_page + limitParam: body.data.attributes.page.limit + resultsPath: data + x-permission: + operator: OR + permissions: + - test_optimization_read + x-unstable: '**Note**: This endpoint is in public beta and may be subject to + change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/usage/application_security: get: deprecated: true @@ -76239,6 +76655,9 @@ tags: - description: View and manage teams within Datadog. See the [Teams page](https://docs.datadoghq.com/account_management/teams/) for more information. name: Teams +- description: Search and manage flaky tests through Test Optimization. See the [Test + Optimization page](https://docs.datadoghq.com/tests/) for more information. + name: Test Optimization - description: 'The usage metering API allows you to get hourly, daily, and monthly usage across multiple facets of Datadog. diff --git a/examples/v2/test-optimization/SearchFlakyTests.rb b/examples/v2/test-optimization/SearchFlakyTests.rb new file mode 100644 index 00000000000..d0707c69930 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests.rb @@ -0,0 +1,27 @@ +# Search flaky tests returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.search_flaky_tests".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new + +body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({ + data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({ + attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({ + filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({ + query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"', + }), + page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({ + cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", + limit: 25, + }), + sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FAILURE_RATE_ASCENDING, + }), + type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST, + }), +}) +opts = { + body: body, +} +p api_instance.search_flaky_tests(opts) diff --git a/examples/v2/test-optimization/SearchFlakyTests_1224086727.rb b/examples/v2/test-optimization/SearchFlakyTests_1224086727.rb new file mode 100644 index 00000000000..0fa528df442 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests_1224086727.rb @@ -0,0 +1,27 @@ +# Search flaky tests returns "OK" response with pagination + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.search_flaky_tests".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new + +body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({ + data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({ + attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({ + filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({ + query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"', + }), + page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({ + cursor: "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", + limit: 25, + }), + sort: DatadogAPIClient::V2::FlakyTestsSearchSort::FAILURE_RATE_ASCENDING, + }), + type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST, + }), +}) +opts = { + body: body, +} +api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item } diff --git a/examples/v2/test-optimization/SearchFlakyTests_2665223746.rb b/examples/v2/test-optimization/SearchFlakyTests_2665223746.rb new file mode 100644 index 00000000000..f24e3605ef0 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests_2665223746.rb @@ -0,0 +1,26 @@ +# Search flaky tests returns "OK" response with filtered query + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.search_flaky_tests".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new + +body = DatadogAPIClient::V2::FlakyTestsSearchRequest.new({ + data: DatadogAPIClient::V2::FlakyTestsSearchRequestData.new({ + attributes: DatadogAPIClient::V2::FlakyTestsSearchRequestAttributes.new({ + filter: DatadogAPIClient::V2::FlakyTestsSearchFilter.new({ + query: 'flaky_test_state:active @git.repository.id_v2:"github.com/datadog/cart-tracking"', + }), + page: DatadogAPIClient::V2::FlakyTestsSearchPageOptions.new({ + limit: 10, + }), + sort: DatadogAPIClient::V2::FlakyTestsSearchSort::LAST_FLAKED_DESCENDING, + }), + type: DatadogAPIClient::V2::FlakyTestsSearchRequestDataType::SEARCH_FLAKY_TESTS_REQUEST, + }), +}) +opts = { + body: body, +} +api_instance.search_flaky_tests_with_pagination(opts) { |item| puts item } diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index ef0a2707bb6..8f39e632b35 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2976,6 +2976,9 @@ "team_id" => "String", "body" => "IncidentTeamUpdateRequest", }, + "v2.SearchFlakyTests" => { + "body" => "FlakyTestsSearchRequest", + }, "v2.SendInvitations" => { "body" => "UserInvitationsRequest", }, diff --git a/features/v2/test_optimization.feature b/features/v2/test_optimization.feature new file mode 100644 index 00000000000..18af1e9cad9 --- /dev/null +++ b/features/v2/test_optimization.feature @@ -0,0 +1,42 @@ +@endpoint(test-optimization) @endpoint(test-optimization-v2) +Feature: Test Optimization + Search and manage flaky tests through Test Optimization. See the [Test + Optimization page](https://docs.datadoghq.com/tests/) for more + information. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "TestOptimization" API + And operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Search flaky tests returns "Bad Request" response + 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"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Search flaky tests returns "Bad Request" response with invalid limit + Given body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Search flaky tests returns "OK" response + 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"}} + When the request is sent + Then the response status is 200 OK + + @replay-only @skip @skip-validation @team:DataDog/ci-app-backend @with-pagination + Scenario: Search flaky tests returns "OK" response with filtered query + 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"}} + When the request with pagination is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/ci-app-backend @with-pagination + Scenario: Search flaky tests returns "OK" response with pagination + 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"}} + When the request with pagination is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index 85202abf346..92c07fe002e 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3978,6 +3978,12 @@ "type": "idempotent" } }, + "SearchFlakyTests": { + "tag": "Test Optimization", + "undo": { + "type": "safe" + } + }, "GetUsageApplicationSecurityMonitoring": { "tag": "Usage Metering", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 758ac77f7a9..7754333a417 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -294,6 +294,7 @@ def initialize "v2.get_incident_team": false, "v2.list_incident_teams": false, "v2.update_incident_team": false, + "v2.search_flaky_tests": false, } @server_variables[:site] = ENV['DD_SITE'] if ENV.key? 'DD_SITE' @api_key['apiKeyAuth'] = ENV['DD_API_KEY'] if ENV.key? 'DD_API_KEY' diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 3cab7bead9c..717bcfd0cac 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2035,6 +2035,23 @@ def overrides "v2.finding_status" => "FindingStatus", "v2.finding_type" => "FindingType", "v2.finding_vulnerability_type" => "FindingVulnerabilityType", + "v2.flaky_test" => "FlakyTest", + "v2.flaky_test_attributes" => "FlakyTestAttributes", + "v2.flaky_test_attributes_flaky_state" => "FlakyTestAttributesFlakyState", + "v2.flaky_test_pipeline_stats" => "FlakyTestPipelineStats", + "v2.flaky_test_run_metadata" => "FlakyTestRunMetadata", + "v2.flaky_tests_pagination" => "FlakyTestsPagination", + "v2.flaky_tests_search_filter" => "FlakyTestsSearchFilter", + "v2.flaky_tests_search_page_options" => "FlakyTestsSearchPageOptions", + "v2.flaky_tests_search_request" => "FlakyTestsSearchRequest", + "v2.flaky_tests_search_request_attributes" => "FlakyTestsSearchRequestAttributes", + "v2.flaky_tests_search_request_data" => "FlakyTestsSearchRequestData", + "v2.flaky_tests_search_request_data_type" => "FlakyTestsSearchRequestDataType", + "v2.flaky_tests_search_response" => "FlakyTestsSearchResponse", + "v2.flaky_tests_search_response_meta" => "FlakyTestsSearchResponseMeta", + "v2.flaky_tests_search_sort" => "FlakyTestsSearchSort", + "v2.flaky_test_stats" => "FlakyTestStats", + "v2.flaky_test_type" => "FlakyTestType", "v2.formula_limit" => "FormulaLimit", "v2.framework_handle_and_version_response_data" => "FrameworkHandleAndVersionResponseData", "v2.freshservice_api_key" => "FreshserviceAPIKey", @@ -4213,6 +4230,7 @@ def overrides "v2.spans_metrics_api" => "SpansMetricsAPI", "v2.synthetics_api" => "SyntheticsAPI", "v2.teams_api" => "TeamsAPI", + "v2.test_optimization_api" => "TestOptimizationAPI", "v2.usage_metering_api" => "UsageMeteringAPI", "v2.users_api" => "UsersAPI", "v2.workflow_automation_api" => "WorkflowAutomationAPI" diff --git a/lib/datadog_api_client/v2/api/test_optimization_api.rb b/lib/datadog_api_client/v2/api/test_optimization_api.rb new file mode 100644 index 00000000000..6d41419f559 --- /dev/null +++ b/lib/datadog_api_client/v2/api/test_optimization_api.rb @@ -0,0 +1,116 @@ +=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 'cgi' + +module DatadogAPIClient::V2 + class TestOptimizationAPI + attr_accessor :api_client + + def initialize(api_client = DatadogAPIClient::APIClient.default) + @api_client = api_client + end + + # Search flaky tests. + # + # @see #search_flaky_tests_with_http_info + def search_flaky_tests(opts = {}) + data, _status_code, _headers = search_flaky_tests_with_http_info(opts) + data + end + + # Search flaky tests. + # + # List endpoint returning flaky tests from Flaky Test Management. Results are paginated. + # + # @param opts [Hash] the optional parameters + # @option opts [FlakyTestsSearchRequest] :body + # @return [Array<(FlakyTestsSearchResponse, Integer, Hash)>] FlakyTestsSearchResponse data, response status code and response headers + def search_flaky_tests_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.search_flaky_tests".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.search_flaky_tests") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.search_flaky_tests")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TestOptimizationAPI.search_flaky_tests ...' + end + # resource path + local_var_path = '/api/v2/test/flaky-test-management/tests' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body']) + + # return_type + return_type = opts[:debug_return_type] || 'FlakyTestsSearchResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :search_flaky_tests, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TestOptimizationAPI#search_flaky_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Search flaky tests. + # + # Provide a paginated version of {#search_flaky_tests}, returning all items. + # + # To use it you need to use a block: search_flaky_tests_with_pagination { |item| p item } + # + # @yield [FlakyTest] Paginated items + def search_flaky_tests_with_pagination(opts = {}) + api_version = "V2" + page_size = @api_client.get_attribute_from_path(opts, "body.data.attributes.page.limit", 10) + @api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.limit", FlakyTestsSearchRequest, page_size) + while true do + response = search_flaky_tests(opts) + @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) } + if @api_client.get_attribute_from_path(response, "data").length < page_size + break + end + @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")) + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test.rb b/lib/datadog_api_client/v2/models/flaky_test.rb new file mode 100644 index 00000000000..ca3c7a8f901 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test.rb @@ -0,0 +1,125 @@ +=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 + # A flaky test object. + class FlakyTest + include BaseGenericModel + + # Attributes of a flaky test. + attr_accessor :attributes + + # Test's ID. This ID is the hash of the test's Fully Qualified Name and Git repository ID. On the Test Runs UI it is the same as the `test_fingerprint_fqn` tag. + attr_accessor :id + + # The type of the flaky test from Flaky Test Management. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'FlakyTestAttributes', + :'id' => :'String', + :'type' => :'FlakyTestType' + } + 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::FlakyTest` 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_attributes.rb b/lib/datadog_api_client/v2/models/flaky_test_attributes.rb new file mode 100644 index 00000000000..81256458ad2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_attributes.rb @@ -0,0 +1,301 @@ +=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 + # Attributes of a flaky test. + class FlakyTestAttributes + include BaseGenericModel + + # Unique identifier for the attempt to fix this flaky test. Use this ID in the Git commit message in order to trigger the attempt to fix workflow. + # + # When the workflow is triggered the test is automatically retried by the tracer a certain number of configurable times. When all retries pass, the test is automatically marked as fixed in Flaky Test Management. + # Test runs are tagged with @test.test_management.attempt_to_fix_passed and @test.test_management.is_attempt_to_fix when the attempt to fix workflow is triggered. + attr_accessor :attempt_to_fix_id + + # The name of the test's code owners as inferred from the repository configuration. + attr_accessor :codeowners + + # List of environments where this test has been flaky. + attr_accessor :envs + + # The branch name where the test exhibited flakiness for the first time. + attr_accessor :first_flaked_branch + + # The commit SHA where the test exhibited flakiness for the first time. + attr_accessor :first_flaked_sha + + # Unix timestamp when the test exhibited flakiness for the first time. + attr_accessor :first_flaked_ts + + # The category of a flaky test. + attr_accessor :flaky_category + + # The current state of the flaky test. + attr_accessor :flaky_state + + # The branch name where the test exhibited flakiness for the last time. + attr_accessor :last_flaked_branch + + # The commit SHA where the test exhibited flakiness for the last time. + attr_accessor :last_flaked_sha + + # Unix timestamp when the test exhibited flakiness for the last time. + attr_accessor :last_flaked_ts + + # The name of the test module. The definition of module changes slightly per language: + # - In .NET, a test module groups every test that is run under the same unit test project. + # - In Swift, a test module groups every test that is run for a given bundle. + # - In JavaScript, the test modules map one-to-one to test sessions. + # - In Java, a test module groups every test that is run by the same Maven Surefire/Failsafe or Gradle Test task execution. + # - In Python, a test module groups every test that is run under the same `.py` file as part of a test suite, which is typically managed by a framework like `unittest` or `pytest`. + # - In Ruby, a test module groups every test that is run within the same test file, which is typically managed by a framework like `RSpec` or `Minitest`. + attr_accessor :_module + + # The test name. A concise name for a test case. Defined in the test itself. + attr_accessor :name + + # CI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from CI Visibility. + attr_accessor :pipeline_stats + + # List of test service names where this test has been flaky. + # + # A test service is a group of tests associated with a project or repository. It contains all the individual tests for your code, optionally organized into test suites, which are like folders for your tests. + attr_accessor :services + + # The name of the test suite. A group of tests exercising the same unit of code depending on your language and testing framework. + attr_accessor :suite + + # Metadata about the latest failed test run of the flaky test. + attr_accessor :test_run_metadata + + # Test statistics for the flaky test. + attr_accessor :test_stats + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attempt_to_fix_id' => :'attempt_to_fix_id', + :'codeowners' => :'codeowners', + :'envs' => :'envs', + :'first_flaked_branch' => :'first_flaked_branch', + :'first_flaked_sha' => :'first_flaked_sha', + :'first_flaked_ts' => :'first_flaked_ts', + :'flaky_category' => :'flaky_category', + :'flaky_state' => :'flaky_state', + :'last_flaked_branch' => :'last_flaked_branch', + :'last_flaked_sha' => :'last_flaked_sha', + :'last_flaked_ts' => :'last_flaked_ts', + :'_module' => :'module', + :'name' => :'name', + :'pipeline_stats' => :'pipeline_stats', + :'services' => :'services', + :'suite' => :'suite', + :'test_run_metadata' => :'test_run_metadata', + :'test_stats' => :'test_stats' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attempt_to_fix_id' => :'String', + :'codeowners' => :'Array', + :'envs' => :'Array', + :'first_flaked_branch' => :'String', + :'first_flaked_sha' => :'String', + :'first_flaked_ts' => :'Integer', + :'flaky_category' => :'String', + :'flaky_state' => :'FlakyTestAttributesFlakyState', + :'last_flaked_branch' => :'String', + :'last_flaked_sha' => :'String', + :'last_flaked_ts' => :'Integer', + :'_module' => :'String', + :'name' => :'String', + :'pipeline_stats' => :'FlakyTestPipelineStats', + :'services' => :'Array', + :'suite' => :'String', + :'test_run_metadata' => :'FlakyTestRunMetadata', + :'test_stats' => :'FlakyTestStats' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'flaky_category', + :'_module', + ]) + 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::FlakyTestAttributes` 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?(:'attempt_to_fix_id') + self.attempt_to_fix_id = attributes[:'attempt_to_fix_id'] + end + + if attributes.key?(:'codeowners') + if (value = attributes[:'codeowners']).is_a?(Array) + self.codeowners = value + end + end + + if attributes.key?(:'envs') + if (value = attributes[:'envs']).is_a?(Array) + self.envs = value + end + end + + if attributes.key?(:'first_flaked_branch') + self.first_flaked_branch = attributes[:'first_flaked_branch'] + end + + if attributes.key?(:'first_flaked_sha') + self.first_flaked_sha = attributes[:'first_flaked_sha'] + end + + if attributes.key?(:'first_flaked_ts') + self.first_flaked_ts = attributes[:'first_flaked_ts'] + end + + if attributes.key?(:'flaky_category') + self.flaky_category = attributes[:'flaky_category'] + end + + if attributes.key?(:'flaky_state') + self.flaky_state = attributes[:'flaky_state'] + end + + if attributes.key?(:'last_flaked_branch') + self.last_flaked_branch = attributes[:'last_flaked_branch'] + end + + if attributes.key?(:'last_flaked_sha') + self.last_flaked_sha = attributes[:'last_flaked_sha'] + end + + if attributes.key?(:'last_flaked_ts') + self.last_flaked_ts = attributes[:'last_flaked_ts'] + end + + if attributes.key?(:'_module') + self._module = attributes[:'_module'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'pipeline_stats') + self.pipeline_stats = attributes[:'pipeline_stats'] + end + + if attributes.key?(:'services') + if (value = attributes[:'services']).is_a?(Array) + self.services = value + end + end + + if attributes.key?(:'suite') + self.suite = attributes[:'suite'] + end + + if attributes.key?(:'test_run_metadata') + self.test_run_metadata = attributes[:'test_run_metadata'] + end + + if attributes.key?(:'test_stats') + self.test_stats = attributes[:'test_stats'] + 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 && + attempt_to_fix_id == o.attempt_to_fix_id && + codeowners == o.codeowners && + envs == o.envs && + first_flaked_branch == o.first_flaked_branch && + first_flaked_sha == o.first_flaked_sha && + first_flaked_ts == o.first_flaked_ts && + flaky_category == o.flaky_category && + flaky_state == o.flaky_state && + last_flaked_branch == o.last_flaked_branch && + last_flaked_sha == o.last_flaked_sha && + last_flaked_ts == o.last_flaked_ts && + _module == o._module && + name == o.name && + pipeline_stats == o.pipeline_stats && + services == o.services && + suite == o.suite && + test_run_metadata == o.test_run_metadata && + test_stats == o.test_stats && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attempt_to_fix_id, codeowners, envs, first_flaked_branch, first_flaked_sha, first_flaked_ts, flaky_category, flaky_state, last_flaked_branch, last_flaked_sha, last_flaked_ts, _module, name, pipeline_stats, services, suite, test_run_metadata, test_stats, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_attributes_flaky_state.rb b/lib/datadog_api_client/v2/models/flaky_test_attributes_flaky_state.rb new file mode 100644 index 00000000000..7dbcaa81e7a --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_attributes_flaky_state.rb @@ -0,0 +1,29 @@ +=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 current state of the flaky test. + class FlakyTestAttributesFlakyState + include BaseEnumModel + + ACTIVE = "active".freeze + FIXED = "fixed".freeze + QUARANTINED = "quarantined".freeze + DISABLED = "disabled".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_pipeline_stats.rb b/lib/datadog_api_client/v2/models/flaky_test_pipeline_stats.rb new file mode 100644 index 00000000000..4ece743241a --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_pipeline_stats.rb @@ -0,0 +1,124 @@ +=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 + # CI pipeline related statistics for the flaky test. This information is only available if test runs are associated with CI pipeline events from CI Visibility. + class FlakyTestPipelineStats + include BaseGenericModel + + # The number of pipelines that failed due to this test for the past 7 days. This is computed as the sum of failed CI pipeline events associated with test runs where the flaky test failed. + attr_accessor :failed_pipelines + + # The total time lost by CI pipelines due to this flaky test in milliseconds. This is computed as the sum of the duration of failed CI pipeline events associated with test runs where the flaky test failed. + attr_accessor :total_lost_time_ms + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'failed_pipelines' => :'failed_pipelines', + :'total_lost_time_ms' => :'total_lost_time_ms' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'failed_pipelines' => :'Integer', + :'total_lost_time_ms' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'failed_pipelines', + :'total_lost_time_ms', + ]) + 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::FlakyTestPipelineStats` 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?(:'failed_pipelines') + self.failed_pipelines = attributes[:'failed_pipelines'] + end + + if attributes.key?(:'total_lost_time_ms') + self.total_lost_time_ms = attributes[:'total_lost_time_ms'] + 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 && + failed_pipelines == o.failed_pipelines && + total_lost_time_ms == o.total_lost_time_ms && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [failed_pipelines, total_lost_time_ms, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_run_metadata.rb b/lib/datadog_api_client/v2/models/flaky_test_run_metadata.rb new file mode 100644 index 00000000000..26c20d25686 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_run_metadata.rb @@ -0,0 +1,168 @@ +=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 + # Metadata about the latest failed test run of the flaky test. + class FlakyTestRunMetadata + include BaseGenericModel + + # The duration of the test run in milliseconds. + attr_accessor :duration_ms + + # The error message from the test failure. + attr_accessor :error_message + + # The stack trace from the test failure. + attr_accessor :error_stack + + # The line number where the test ends in the source file. + attr_accessor :source_end + + # The source file where the test is defined. + attr_accessor :source_file + + # The line number where the test starts in the source file. + attr_accessor :source_start + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'duration_ms' => :'duration_ms', + :'error_message' => :'error_message', + :'error_stack' => :'error_stack', + :'source_end' => :'source_end', + :'source_file' => :'source_file', + :'source_start' => :'source_start' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'duration_ms' => :'Integer', + :'error_message' => :'String', + :'error_stack' => :'String', + :'source_end' => :'Integer', + :'source_file' => :'String', + :'source_start' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'duration_ms', + :'error_message', + :'error_stack', + :'source_end', + :'source_file', + :'source_start', + ]) + 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::FlakyTestRunMetadata` 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?(:'duration_ms') + self.duration_ms = attributes[:'duration_ms'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_stack') + self.error_stack = attributes[:'error_stack'] + end + + if attributes.key?(:'source_end') + self.source_end = attributes[:'source_end'] + end + + if attributes.key?(:'source_file') + self.source_file = attributes[:'source_file'] + end + + if attributes.key?(:'source_start') + self.source_start = attributes[:'source_start'] + 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 && + duration_ms == o.duration_ms && + error_message == o.error_message && + error_stack == o.error_stack && + source_end == o.source_end && + source_file == o.source_file && + source_start == o.source_start && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [duration_ms, error_message, error_stack, source_end, source_file, source_start, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_stats.rb b/lib/datadog_api_client/v2/models/flaky_test_stats.rb new file mode 100644 index 00000000000..c50c62bf60e --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_stats.rb @@ -0,0 +1,113 @@ +=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 + # Test statistics for the flaky test. + class FlakyTestStats + include BaseGenericModel + + # The failure rate percentage of the test for the past 7 days. This is the number of failed test runs divided by the total number of test runs (excluding skipped test runs). + attr_accessor :failure_rate_pct + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'failure_rate_pct' => :'failure_rate_pct' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'failure_rate_pct' => :'Float' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'failure_rate_pct', + ]) + 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::FlakyTestStats` 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?(:'failure_rate_pct') + self.failure_rate_pct = attributes[:'failure_rate_pct'] + 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 && + failure_rate_pct == o.failure_rate_pct && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [failure_rate_pct, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_test_type.rb b/lib/datadog_api_client/v2/models/flaky_test_type.rb new file mode 100644 index 00000000000..180f720b5df --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_test_type.rb @@ -0,0 +1,26 @@ +=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 type of the flaky test from Flaky Test Management. + class FlakyTestType + include BaseEnumModel + + FLAKY_TEST = "flaky_test".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_pagination.rb b/lib/datadog_api_client/v2/models/flaky_tests_pagination.rb new file mode 100644 index 00000000000..7e27888784d --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_pagination.rb @@ -0,0 +1,113 @@ +=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 + # Pagination metadata for flaky tests. + class FlakyTestsPagination + include BaseGenericModel + + # Cursor for the next page of results. + attr_accessor :next_page + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'next_page' => :'next_page' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'next_page' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'next_page', + ]) + 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::FlakyTestsPagination` 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?(:'next_page') + self.next_page = attributes[:'next_page'] + 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 && + next_page == o.next_page && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [next_page, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_filter.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_filter.rb new file mode 100644 index 00000000000..cddb898eef0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_filter.rb @@ -0,0 +1,116 @@ +=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 + # Search filter settings. + class FlakyTestsSearchFilter + include BaseGenericModel + + # Search query following log syntax used to filter flaky tests, same as on Flaky Tests Management UI. The supported search keys are: + # - `flaky_test_state` + # - `flaky_test_category` + # - `@test.name` + # - `@test.suite` + # - `@test.module` + # - `@test.service` + # - `@git.repository.id_v2` + # - `@git.branch` + # - `@test.codeowners` + # - `env` + # + attr_accessor :query + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'query' => :'query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'query' => :'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::FlakyTestsSearchFilter` 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?(:'query') + self.query = attributes[:'query'] + 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 && + query == o.query && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [query, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_page_options.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_page_options.rb new file mode 100644 index 00000000000..8b82700b725 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_page_options.rb @@ -0,0 +1,137 @@ +=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 + # Pagination attributes for listing flaky tests. + class FlakyTestsSearchPageOptions + include BaseGenericModel + + # List following results with a cursor provided in the previous request. + attr_accessor :cursor + + # Maximum number of flaky tests in the response. + attr_reader :limit + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'cursor' => :'cursor', + :'limit' => :'limit' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'cursor' => :'String', + :'limit' => :'Integer' + } + 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::FlakyTestsSearchPageOptions` 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?(:'cursor') + self.cursor = attributes[:'cursor'] + end + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + 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 !@limit.nil? && @limit > 1000 + return false if !@limit.nil? && @limit < 1 + true + end + + # Custom attribute writer method with validation + # @param limit [Object] Object to be assigned + # @!visibility private + def limit=(limit) + if !limit.nil? && limit > 1000 + fail ArgumentError, 'invalid value for "limit", must be smaller than or equal to 1000.' + end + if !limit.nil? && limit < 1 + fail ArgumentError, 'invalid value for "limit", must be greater than or equal to 1.' + end + @limit = limit + 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 && + cursor == o.cursor && + limit == o.limit && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [cursor, limit, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_request.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_request.rb new file mode 100644 index 00000000000..d44d308517f --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_request.rb @@ -0,0 +1,105 @@ +=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 request for a flaky tests search. + class FlakyTestsSearchRequest + include BaseGenericModel + + # The JSON:API data for flaky tests search request. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'FlakyTestsSearchRequestData' + } + 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::FlakyTestsSearchRequest` 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?(:'data') + self.data = attributes[:'data'] + 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 && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_request_attributes.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_request_attributes.rb new file mode 100644 index 00000000000..8dfed991364 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_request_attributes.rb @@ -0,0 +1,125 @@ +=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 + # Attributes for the flaky tests search request. + class FlakyTestsSearchRequestAttributes + include BaseGenericModel + + # Search filter settings. + attr_accessor :filter + + # Pagination attributes for listing flaky tests. + attr_accessor :page + + # Parameter for sorting flaky test results. The default sort is by ascending Fully Qualified Name (FQN). The FQN is the concatenation of the test module, suite, and name. + attr_accessor :sort + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'filter' => :'filter', + :'page' => :'page', + :'sort' => :'sort' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'filter' => :'FlakyTestsSearchFilter', + :'page' => :'FlakyTestsSearchPageOptions', + :'sort' => :'FlakyTestsSearchSort' + } + 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::FlakyTestsSearchRequestAttributes` 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?(:'filter') + self.filter = attributes[:'filter'] + end + + if attributes.key?(:'page') + self.page = attributes[:'page'] + end + + if attributes.key?(:'sort') + self.sort = attributes[:'sort'] + 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 && + filter == o.filter && + page == o.page && + sort == o.sort && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [filter, page, sort, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_request_data.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_request_data.rb new file mode 100644 index 00000000000..525d2db9dd3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_request_data.rb @@ -0,0 +1,115 @@ +=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 JSON:API data for flaky tests search request. + class FlakyTestsSearchRequestData + include BaseGenericModel + + # Attributes for the flaky tests search request. + attr_accessor :attributes + + # The definition of `FlakyTestsSearchRequestDataType` object. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'FlakyTestsSearchRequestAttributes', + :'type' => :'FlakyTestsSearchRequestDataType' + } + 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::FlakyTestsSearchRequestData` 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_request_data_type.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_request_data_type.rb new file mode 100644 index 00000000000..efa0d78690f --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_request_data_type.rb @@ -0,0 +1,26 @@ +=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 definition of `FlakyTestsSearchRequestDataType` object. + class FlakyTestsSearchRequestDataType + include BaseEnumModel + + SEARCH_FLAKY_TESTS_REQUEST = "search_flaky_tests_request".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_response.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_response.rb new file mode 100644 index 00000000000..b891221a31e --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_response.rb @@ -0,0 +1,117 @@ +=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 + # Response object with flaky tests matching the search request. + class FlakyTestsSearchResponse + include BaseGenericModel + + # Array of flaky tests matching the request. + attr_accessor :data + + # Metadata for the flaky tests search response. + attr_accessor :meta + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'meta' => :'meta' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'meta' => :'FlakyTestsSearchResponseMeta' + } + 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::FlakyTestsSearchResponse` 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?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + 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 && + data == o.data && + meta == o.meta && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, meta, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_response_meta.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_response_meta.rb new file mode 100644 index 00000000000..592c708e282 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_response_meta.rb @@ -0,0 +1,105 @@ +=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 + # Metadata for the flaky tests search response. + class FlakyTestsSearchResponseMeta + include BaseGenericModel + + # Pagination metadata for flaky tests. + attr_accessor :pagination + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'pagination' => :'pagination' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'pagination' => :'FlakyTestsPagination' + } + 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::FlakyTestsSearchResponseMeta` 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?(:'pagination') + self.pagination = attributes[:'pagination'] + 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 && + pagination == o.pagination && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [pagination, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/flaky_tests_search_sort.rb b/lib/datadog_api_client/v2/models/flaky_tests_search_sort.rb new file mode 100644 index 00000000000..2e45dd60db9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/flaky_tests_search_sort.rb @@ -0,0 +1,37 @@ +=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 + # Parameter for sorting flaky test results. The default sort is by ascending Fully Qualified Name (FQN). The FQN is the concatenation of the test module, suite, and name. + class FlakyTestsSearchSort + include BaseEnumModel + + FQN_ASCENDING = "fqn".freeze + FQN_DESCENDING = "-fqn".freeze + FIRST_FLAKED_ASCENDING = "first_flaked".freeze + FIRST_FLAKED_DESCENDING = "-first_flaked".freeze + LAST_FLAKED_ASCENDING = "last_flaked".freeze + LAST_FLAKED_DESCENDING = "-last_flaked".freeze + FAILURE_RATE_ASCENDING = "failure_rate".freeze + FAILURE_RATE_DESCENDING = "-failure_rate".freeze + PIPELINES_FAILED_ASCENDING = "pipelines_failed".freeze + PIPELINES_FAILED_DESCENDING = "-pipelines_failed".freeze + PIPELINES_DURATION_LOST_ASCENDING = "pipelines_duration_lost".freeze + PIPELINES_DURATION_LOST_DESCENDING = "-pipelines_duration_lost".freeze + end +end