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.java b/examples/v2/test-optimization/SearchFlakyTests.java new file mode 100644 index 00000000000..bd908ce88e3 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests.java @@ -0,0 +1,54 @@ +// Search flaky tests returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.TestOptimizationApi; +import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters; +import com.datadog.api.client.v2.model.FlakyTestsSearchFilter; +import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequest; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType; +import com.datadog.api.client.v2.model.FlakyTestsSearchResponse; +import com.datadog.api.client.v2.model.FlakyTestsSearchSort; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.searchFlakyTests", true); + TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient); + + FlakyTestsSearchRequest body = + new FlakyTestsSearchRequest() + .data( + new FlakyTestsSearchRequestData() + .attributes( + new FlakyTestsSearchRequestAttributes() + .filter( + new FlakyTestsSearchFilter() + .query( + """ +flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" +""")) + .page( + new FlakyTestsSearchPageOptions() + .cursor( + "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==") + .limit(25L)) + .sort(FlakyTestsSearchSort.FAILURE_RATE_ASCENDING)) + .type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST)); + + try { + FlakyTestsSearchResponse result = + apiInstance.searchFlakyTests(new SearchFlakyTestsOptionalParameters().body(body)); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling TestOptimizationApi#searchFlakyTests"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/test-optimization/SearchFlakyTests_1224086727.java b/examples/v2/test-optimization/SearchFlakyTests_1224086727.java new file mode 100644 index 00000000000..7c851377965 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests_1224086727.java @@ -0,0 +1,57 @@ +// Search flaky tests returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.TestOptimizationApi; +import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters; +import com.datadog.api.client.v2.model.FlakyTest; +import com.datadog.api.client.v2.model.FlakyTestsSearchFilter; +import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequest; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType; +import com.datadog.api.client.v2.model.FlakyTestsSearchSort; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.searchFlakyTests", true); + TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient); + + FlakyTestsSearchRequest body = + new FlakyTestsSearchRequest() + .data( + new FlakyTestsSearchRequestData() + .attributes( + new FlakyTestsSearchRequestAttributes() + .filter( + new FlakyTestsSearchFilter() + .query( + """ +flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist" +""")) + .page( + new FlakyTestsSearchPageOptions() + .cursor( + "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==") + .limit(25L)) + .sort(FlakyTestsSearchSort.FAILURE_RATE_ASCENDING)) + .type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST)); + + try { + PaginationIterable iterable = + apiInstance.searchFlakyTestsWithPagination( + new SearchFlakyTestsOptionalParameters().body(body)); + + for (FlakyTest item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println( + "Exception when calling TestOptimizationApi#searchFlakyTestsWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/test-optimization/SearchFlakyTests_2665223746.java b/examples/v2/test-optimization/SearchFlakyTests_2665223746.java new file mode 100644 index 00000000000..8231d4f5d86 --- /dev/null +++ b/examples/v2/test-optimization/SearchFlakyTests_2665223746.java @@ -0,0 +1,53 @@ +// Search flaky tests returns "OK" response with filtered query + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.TestOptimizationApi; +import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters; +import com.datadog.api.client.v2.model.FlakyTest; +import com.datadog.api.client.v2.model.FlakyTestsSearchFilter; +import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequest; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType; +import com.datadog.api.client.v2.model.FlakyTestsSearchSort; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.searchFlakyTests", true); + TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient); + + FlakyTestsSearchRequest body = + new FlakyTestsSearchRequest() + .data( + new FlakyTestsSearchRequestData() + .attributes( + new FlakyTestsSearchRequestAttributes() + .filter( + new FlakyTestsSearchFilter() + .query( + """ +flaky_test_state:active @git.repository.id_v2:"github.com/datadog/cart-tracking" +""")) + .page(new FlakyTestsSearchPageOptions().limit(10L)) + .sort(FlakyTestsSearchSort.LAST_FLAKED_DESCENDING)) + .type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST)); + + try { + PaginationIterable iterable = + apiInstance.searchFlakyTestsWithPagination( + new SearchFlakyTestsOptionalParameters().body(body)); + + for (FlakyTest item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println( + "Exception when calling TestOptimizationApi#searchFlakyTestsWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 3ace2e31e0f..3f0f46d69b5 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -792,6 +792,7 @@ public class ApiClient { put("v2.getIncidentTeam", false); put("v2.listIncidentTeams", false); put("v2.updateIncidentTeam", false); + put("v2.searchFlakyTests", false); } }; protected static final java.util.logging.Logger logger = diff --git a/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java b/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java new file mode 100644 index 00000000000..7335dca2f23 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/api/TestOptimizationApi.java @@ -0,0 +1,298 @@ +package com.datadog.api.client.v2.api; + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.FlakyTest; +import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequest; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes; +import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData; +import com.datadog.api.client.v2.model.FlakyTestsSearchResponse; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.core.GenericType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class TestOptimizationApi { + private ApiClient apiClient; + + public TestOptimizationApi() { + this(ApiClient.getDefaultApiClient()); + } + + public TestOptimizationApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Get the API client. + * + * @return API client + */ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * Set the API client. + * + * @param apiClient an instance of API client + */ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** Manage optional parameters to searchFlakyTests. */ + public static class SearchFlakyTestsOptionalParameters { + private FlakyTestsSearchRequest body; + + /** + * Set body. + * + * @param body (optional) + * @return SearchFlakyTestsOptionalParameters + */ + public SearchFlakyTestsOptionalParameters body(FlakyTestsSearchRequest body) { + this.body = body; + return this; + } + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfo}. + * + * @return FlakyTestsSearchResponse + * @throws ApiException if fails to make API call + */ + public FlakyTestsSearchResponse searchFlakyTests() throws ApiException { + return searchFlakyTestsWithHttpInfo(new SearchFlakyTestsOptionalParameters()).getData(); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfoAsync}. + * + * @return CompletableFuture<FlakyTestsSearchResponse> + */ + public CompletableFuture searchFlakyTestsAsync() { + return searchFlakyTestsWithHttpInfoAsync(new SearchFlakyTestsOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return FlakyTestsSearchResponse + * @throws ApiException if fails to make API call + */ + public FlakyTestsSearchResponse searchFlakyTests(SearchFlakyTestsOptionalParameters parameters) + throws ApiException { + return searchFlakyTestsWithHttpInfo(parameters).getData(); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfoAsync}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<FlakyTestsSearchResponse> + */ + public CompletableFuture searchFlakyTestsAsync( + SearchFlakyTestsOptionalParameters parameters) { + return searchFlakyTestsWithHttpInfoAsync(parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfo}. + * + * @return PaginationIterable<FlakyTest> + */ + public PaginationIterable searchFlakyTestsWithPagination() { + SearchFlakyTestsOptionalParameters parameters = new SearchFlakyTestsOptionalParameters(); + return searchFlakyTestsWithPagination(parameters); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfo}. + * + * @return FlakyTestsSearchResponse + */ + public PaginationIterable searchFlakyTestsWithPagination( + SearchFlakyTestsOptionalParameters parameters) { + String resultsPath = "getData"; + String valueGetterPath = "getMeta.getPagination.getNextPage"; + String valueSetterPath = "body.getData.getAttributes.getPage.setCursor"; + Boolean valueSetterParamOptional = true; + Long limit; + + if (parameters.body == null) { + parameters.body(new FlakyTestsSearchRequest()); + } + + if (parameters.body.getData() == null) { + parameters.body.setData(new FlakyTestsSearchRequestData()); + } + + if (parameters.body.getData().getAttributes() == null) { + parameters.body.getData().setAttributes(new FlakyTestsSearchRequestAttributes()); + } + + if (parameters.body.getData().getAttributes().getPage() == null) { + parameters.body.getData().getAttributes().setPage(new FlakyTestsSearchPageOptions()); + } + + if (parameters.body.getData().getAttributes().getPage().getLimit() == null) { + limit = 10l; + parameters.body.getData().getAttributes().getPage().setLimit(limit); + } else { + limit = parameters.body.getData().getAttributes().getPage().getLimit(); + } + + LinkedHashMap args = new LinkedHashMap(); + args.put("optionalParams", parameters); + + PaginationIterable iterator = + new PaginationIterable( + this, + "searchFlakyTests", + resultsPath, + valueGetterPath, + valueSetterPath, + valueSetterParamOptional, + true, + limit, + args); + + return iterator; + } + + /** + * List endpoint returning flaky tests from Flaky Test Management. Results are paginated. + * + * @param parameters Optional parameters for the request. + * @return ApiResponse<FlakyTestsSearchResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Not Authorized -
429 Too many requests -
+ */ + public ApiResponse searchFlakyTestsWithHttpInfo( + SearchFlakyTestsOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "searchFlakyTests"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = parameters.body; + // create path and map variables + String localVarPath = "/api/v2/test/flaky-test-management/tests"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.TestOptimizationApi.searchFlakyTests", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Search flaky tests. + * + *

See {@link #searchFlakyTestsWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<FlakyTestsSearchResponse>> + */ + public CompletableFuture> searchFlakyTestsWithHttpInfoAsync( + SearchFlakyTestsOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "searchFlakyTests"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = parameters.body; + // create path and map variables + String localVarPath = "/api/v2/test/flaky-test-management/tests"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.TestOptimizationApi.searchFlakyTests", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTest.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTest.java new file mode 100644 index 00000000000..72b32416853 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTest.java @@ -0,0 +1,197 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A flaky test object. */ +@JsonPropertyOrder({ + FlakyTest.JSON_PROPERTY_ATTRIBUTES, + FlakyTest.JSON_PROPERTY_ID, + FlakyTest.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private FlakyTestAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private FlakyTestType type; + + public FlakyTest attributes(FlakyTestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a flaky test. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(FlakyTestAttributes attributes) { + this.attributes = attributes; + } + + public FlakyTest id(String id) { + this.id = id; + return this; + } + + /** + * 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. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public FlakyTest type(FlakyTestType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the flaky test from Flaky Test Management. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestType getType() { + return type; + } + + public void setType(FlakyTestType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTest + */ + @JsonAnySetter + public FlakyTest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTest flakyTest = (FlakyTest) o; + return Objects.equals(this.attributes, flakyTest.attributes) + && Objects.equals(this.id, flakyTest.id) + && Objects.equals(this.type, flakyTest.type) + && Objects.equals(this.additionalProperties, flakyTest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTest {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java new file mode 100644 index 00000000000..18296e02107 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributes.java @@ -0,0 +1,689 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Attributes of a flaky test. */ +@JsonPropertyOrder({ + FlakyTestAttributes.JSON_PROPERTY_ATTEMPT_TO_FIX_ID, + FlakyTestAttributes.JSON_PROPERTY_CODEOWNERS, + FlakyTestAttributes.JSON_PROPERTY_ENVS, + FlakyTestAttributes.JSON_PROPERTY_FIRST_FLAKED_BRANCH, + FlakyTestAttributes.JSON_PROPERTY_FIRST_FLAKED_SHA, + FlakyTestAttributes.JSON_PROPERTY_FIRST_FLAKED_TS, + FlakyTestAttributes.JSON_PROPERTY_FLAKY_CATEGORY, + FlakyTestAttributes.JSON_PROPERTY_FLAKY_STATE, + FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_BRANCH, + FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_SHA, + FlakyTestAttributes.JSON_PROPERTY_LAST_FLAKED_TS, + FlakyTestAttributes.JSON_PROPERTY_MODULE, + FlakyTestAttributes.JSON_PROPERTY_NAME, + FlakyTestAttributes.JSON_PROPERTY_PIPELINE_STATS, + FlakyTestAttributes.JSON_PROPERTY_SERVICES, + FlakyTestAttributes.JSON_PROPERTY_SUITE, + FlakyTestAttributes.JSON_PROPERTY_TEST_RUN_METADATA, + FlakyTestAttributes.JSON_PROPERTY_TEST_STATS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTEMPT_TO_FIX_ID = "attempt_to_fix_id"; + private String attemptToFixId; + + public static final String JSON_PROPERTY_CODEOWNERS = "codeowners"; + private List codeowners = null; + + public static final String JSON_PROPERTY_ENVS = "envs"; + private List envs = null; + + public static final String JSON_PROPERTY_FIRST_FLAKED_BRANCH = "first_flaked_branch"; + private String firstFlakedBranch; + + public static final String JSON_PROPERTY_FIRST_FLAKED_SHA = "first_flaked_sha"; + private String firstFlakedSha; + + public static final String JSON_PROPERTY_FIRST_FLAKED_TS = "first_flaked_ts"; + private Long firstFlakedTs; + + public static final String JSON_PROPERTY_FLAKY_CATEGORY = "flaky_category"; + private JsonNullable flakyCategory = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_FLAKY_STATE = "flaky_state"; + private FlakyTestAttributesFlakyState flakyState; + + public static final String JSON_PROPERTY_LAST_FLAKED_BRANCH = "last_flaked_branch"; + private String lastFlakedBranch; + + public static final String JSON_PROPERTY_LAST_FLAKED_SHA = "last_flaked_sha"; + private String lastFlakedSha; + + public static final String JSON_PROPERTY_LAST_FLAKED_TS = "last_flaked_ts"; + private Long lastFlakedTs; + + public static final String JSON_PROPERTY_MODULE = "module"; + private JsonNullable module = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_PIPELINE_STATS = "pipeline_stats"; + private FlakyTestPipelineStats pipelineStats; + + public static final String JSON_PROPERTY_SERVICES = "services"; + private List services = null; + + public static final String JSON_PROPERTY_SUITE = "suite"; + private String suite; + + public static final String JSON_PROPERTY_TEST_RUN_METADATA = "test_run_metadata"; + private FlakyTestRunMetadata testRunMetadata; + + public static final String JSON_PROPERTY_TEST_STATS = "test_stats"; + private FlakyTestStats testStats; + + public FlakyTestAttributes attemptToFixId(String attemptToFixId) { + this.attemptToFixId = attemptToFixId; + return this; + } + + /** + * 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. + * + * @return attemptToFixId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTEMPT_TO_FIX_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAttemptToFixId() { + return attemptToFixId; + } + + public void setAttemptToFixId(String attemptToFixId) { + this.attemptToFixId = attemptToFixId; + } + + public FlakyTestAttributes codeowners(List codeowners) { + this.codeowners = codeowners; + return this; + } + + public FlakyTestAttributes addCodeownersItem(String codeownersItem) { + if (this.codeowners == null) { + this.codeowners = new ArrayList<>(); + } + this.codeowners.add(codeownersItem); + return this; + } + + /** + * The name of the test's code owners as inferred from the repository configuration. + * + * @return codeowners + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODEOWNERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getCodeowners() { + return codeowners; + } + + public void setCodeowners(List codeowners) { + this.codeowners = codeowners; + } + + public FlakyTestAttributes envs(List envs) { + this.envs = envs; + return this; + } + + public FlakyTestAttributes addEnvsItem(String envsItem) { + if (this.envs == null) { + this.envs = new ArrayList<>(); + } + this.envs.add(envsItem); + return this; + } + + /** + * List of environments where this test has been flaky. + * + * @return envs + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENVS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getEnvs() { + return envs; + } + + public void setEnvs(List envs) { + this.envs = envs; + } + + public FlakyTestAttributes firstFlakedBranch(String firstFlakedBranch) { + this.firstFlakedBranch = firstFlakedBranch; + return this; + } + + /** + * The branch name where the test exhibited flakiness for the first time. + * + * @return firstFlakedBranch + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_FLAKED_BRANCH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstFlakedBranch() { + return firstFlakedBranch; + } + + public void setFirstFlakedBranch(String firstFlakedBranch) { + this.firstFlakedBranch = firstFlakedBranch; + } + + public FlakyTestAttributes firstFlakedSha(String firstFlakedSha) { + this.firstFlakedSha = firstFlakedSha; + return this; + } + + /** + * The commit SHA where the test exhibited flakiness for the first time. + * + * @return firstFlakedSha + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_FLAKED_SHA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstFlakedSha() { + return firstFlakedSha; + } + + public void setFirstFlakedSha(String firstFlakedSha) { + this.firstFlakedSha = firstFlakedSha; + } + + public FlakyTestAttributes firstFlakedTs(Long firstFlakedTs) { + this.firstFlakedTs = firstFlakedTs; + return this; + } + + /** + * Unix timestamp when the test exhibited flakiness for the first time. + * + * @return firstFlakedTs + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIRST_FLAKED_TS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getFirstFlakedTs() { + return firstFlakedTs; + } + + public void setFirstFlakedTs(Long firstFlakedTs) { + this.firstFlakedTs = firstFlakedTs; + } + + public FlakyTestAttributes flakyCategory(String flakyCategory) { + this.flakyCategory = JsonNullable.of(flakyCategory); + return this; + } + + /** + * The category of a flaky test. + * + * @return flakyCategory + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getFlakyCategory() { + return flakyCategory.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FLAKY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getFlakyCategory_JsonNullable() { + return flakyCategory; + } + + @JsonProperty(JSON_PROPERTY_FLAKY_CATEGORY) + public void setFlakyCategory_JsonNullable(JsonNullable flakyCategory) { + this.flakyCategory = flakyCategory; + } + + public void setFlakyCategory(String flakyCategory) { + this.flakyCategory = JsonNullable.of(flakyCategory); + } + + public FlakyTestAttributes flakyState(FlakyTestAttributesFlakyState flakyState) { + this.flakyState = flakyState; + this.unparsed |= !flakyState.isValid(); + return this; + } + + /** + * The current state of the flaky test. + * + * @return flakyState + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FLAKY_STATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestAttributesFlakyState getFlakyState() { + return flakyState; + } + + public void setFlakyState(FlakyTestAttributesFlakyState flakyState) { + if (!flakyState.isValid()) { + this.unparsed = true; + } + this.flakyState = flakyState; + } + + public FlakyTestAttributes lastFlakedBranch(String lastFlakedBranch) { + this.lastFlakedBranch = lastFlakedBranch; + return this; + } + + /** + * The branch name where the test exhibited flakiness for the last time. + * + * @return lastFlakedBranch + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_FLAKED_BRANCH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastFlakedBranch() { + return lastFlakedBranch; + } + + public void setLastFlakedBranch(String lastFlakedBranch) { + this.lastFlakedBranch = lastFlakedBranch; + } + + public FlakyTestAttributes lastFlakedSha(String lastFlakedSha) { + this.lastFlakedSha = lastFlakedSha; + return this; + } + + /** + * The commit SHA where the test exhibited flakiness for the last time. + * + * @return lastFlakedSha + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_FLAKED_SHA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLastFlakedSha() { + return lastFlakedSha; + } + + public void setLastFlakedSha(String lastFlakedSha) { + this.lastFlakedSha = lastFlakedSha; + } + + public FlakyTestAttributes lastFlakedTs(Long lastFlakedTs) { + this.lastFlakedTs = lastFlakedTs; + return this; + } + + /** + * Unix timestamp when the test exhibited flakiness for the last time. + * + * @return lastFlakedTs + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LAST_FLAKED_TS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getLastFlakedTs() { + return lastFlakedTs; + } + + public void setLastFlakedTs(Long lastFlakedTs) { + this.lastFlakedTs = lastFlakedTs; + } + + public FlakyTestAttributes module(String module) { + this.module = JsonNullable.of(module); + return this; + } + + /** + * 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. + * + * @return module + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getModule() { + return module.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MODULE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getModule_JsonNullable() { + return module; + } + + @JsonProperty(JSON_PROPERTY_MODULE) + public void setModule_JsonNullable(JsonNullable module) { + this.module = module; + } + + public void setModule(String module) { + this.module = JsonNullable.of(module); + } + + public FlakyTestAttributes name(String name) { + this.name = name; + return this; + } + + /** + * The test name. A concise name for a test case. Defined in the test itself. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public FlakyTestAttributes pipelineStats(FlakyTestPipelineStats pipelineStats) { + this.pipelineStats = pipelineStats; + this.unparsed |= pipelineStats.unparsed; + return this; + } + + /** + * 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. + * + * @return pipelineStats + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PIPELINE_STATS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestPipelineStats getPipelineStats() { + return pipelineStats; + } + + public void setPipelineStats(FlakyTestPipelineStats pipelineStats) { + this.pipelineStats = pipelineStats; + } + + public FlakyTestAttributes services(List services) { + this.services = services; + return this; + } + + public FlakyTestAttributes addServicesItem(String servicesItem) { + if (this.services == null) { + this.services = new ArrayList<>(); + } + this.services.add(servicesItem); + return this; + } + + /** + * 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. + * + * @return services + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SERVICES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getServices() { + return services; + } + + public void setServices(List services) { + this.services = services; + } + + public FlakyTestAttributes suite(String suite) { + this.suite = suite; + return this; + } + + /** + * The name of the test suite. A group of tests exercising the same unit of code depending on your + * language and testing framework. + * + * @return suite + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUITE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSuite() { + return suite; + } + + public void setSuite(String suite) { + this.suite = suite; + } + + public FlakyTestAttributes testRunMetadata(FlakyTestRunMetadata testRunMetadata) { + this.testRunMetadata = testRunMetadata; + this.unparsed |= testRunMetadata.unparsed; + return this; + } + + /** + * Metadata about the latest failed test run of the flaky test. + * + * @return testRunMetadata + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEST_RUN_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestRunMetadata getTestRunMetadata() { + return testRunMetadata; + } + + public void setTestRunMetadata(FlakyTestRunMetadata testRunMetadata) { + this.testRunMetadata = testRunMetadata; + } + + public FlakyTestAttributes testStats(FlakyTestStats testStats) { + this.testStats = testStats; + this.unparsed |= testStats.unparsed; + return this; + } + + /** + * Test statistics for the flaky test. + * + * @return testStats + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEST_STATS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestStats getTestStats() { + return testStats; + } + + public void setTestStats(FlakyTestStats testStats) { + this.testStats = testStats; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestAttributes + */ + @JsonAnySetter + public FlakyTestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestAttributes flakyTestAttributes = (FlakyTestAttributes) o; + return Objects.equals(this.attemptToFixId, flakyTestAttributes.attemptToFixId) + && Objects.equals(this.codeowners, flakyTestAttributes.codeowners) + && Objects.equals(this.envs, flakyTestAttributes.envs) + && Objects.equals(this.firstFlakedBranch, flakyTestAttributes.firstFlakedBranch) + && Objects.equals(this.firstFlakedSha, flakyTestAttributes.firstFlakedSha) + && Objects.equals(this.firstFlakedTs, flakyTestAttributes.firstFlakedTs) + && Objects.equals(this.flakyCategory, flakyTestAttributes.flakyCategory) + && Objects.equals(this.flakyState, flakyTestAttributes.flakyState) + && Objects.equals(this.lastFlakedBranch, flakyTestAttributes.lastFlakedBranch) + && Objects.equals(this.lastFlakedSha, flakyTestAttributes.lastFlakedSha) + && Objects.equals(this.lastFlakedTs, flakyTestAttributes.lastFlakedTs) + && Objects.equals(this.module, flakyTestAttributes.module) + && Objects.equals(this.name, flakyTestAttributes.name) + && Objects.equals(this.pipelineStats, flakyTestAttributes.pipelineStats) + && Objects.equals(this.services, flakyTestAttributes.services) + && Objects.equals(this.suite, flakyTestAttributes.suite) + && Objects.equals(this.testRunMetadata, flakyTestAttributes.testRunMetadata) + && Objects.equals(this.testStats, flakyTestAttributes.testStats) + && Objects.equals(this.additionalProperties, flakyTestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + attemptToFixId, + codeowners, + envs, + firstFlakedBranch, + firstFlakedSha, + firstFlakedTs, + flakyCategory, + flakyState, + lastFlakedBranch, + lastFlakedSha, + lastFlakedTs, + module, + name, + pipelineStats, + services, + suite, + testRunMetadata, + testStats, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestAttributes {\n"); + sb.append(" attemptToFixId: ").append(toIndentedString(attemptToFixId)).append("\n"); + sb.append(" codeowners: ").append(toIndentedString(codeowners)).append("\n"); + sb.append(" envs: ").append(toIndentedString(envs)).append("\n"); + sb.append(" firstFlakedBranch: ").append(toIndentedString(firstFlakedBranch)).append("\n"); + sb.append(" firstFlakedSha: ").append(toIndentedString(firstFlakedSha)).append("\n"); + sb.append(" firstFlakedTs: ").append(toIndentedString(firstFlakedTs)).append("\n"); + sb.append(" flakyCategory: ").append(toIndentedString(flakyCategory)).append("\n"); + sb.append(" flakyState: ").append(toIndentedString(flakyState)).append("\n"); + sb.append(" lastFlakedBranch: ").append(toIndentedString(lastFlakedBranch)).append("\n"); + sb.append(" lastFlakedSha: ").append(toIndentedString(lastFlakedSha)).append("\n"); + sb.append(" lastFlakedTs: ").append(toIndentedString(lastFlakedTs)).append("\n"); + sb.append(" module: ").append(toIndentedString(module)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" pipelineStats: ").append(toIndentedString(pipelineStats)).append("\n"); + sb.append(" services: ").append(toIndentedString(services)).append("\n"); + sb.append(" suite: ").append(toIndentedString(suite)).append("\n"); + sb.append(" testRunMetadata: ").append(toIndentedString(testRunMetadata)).append("\n"); + sb.append(" testStats: ").append(toIndentedString(testStats)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributesFlakyState.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributesFlakyState.java new file mode 100644 index 00000000000..c23d981103d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestAttributesFlakyState.java @@ -0,0 +1,63 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The current state of the flaky test. */ +@JsonSerialize(using = FlakyTestAttributesFlakyState.FlakyTestAttributesFlakyStateSerializer.class) +public class FlakyTestAttributesFlakyState extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("active", "fixed", "quarantined", "disabled")); + + public static final FlakyTestAttributesFlakyState ACTIVE = + new FlakyTestAttributesFlakyState("active"); + public static final FlakyTestAttributesFlakyState FIXED = + new FlakyTestAttributesFlakyState("fixed"); + public static final FlakyTestAttributesFlakyState QUARANTINED = + new FlakyTestAttributesFlakyState("quarantined"); + public static final FlakyTestAttributesFlakyState DISABLED = + new FlakyTestAttributesFlakyState("disabled"); + + FlakyTestAttributesFlakyState(String value) { + super(value, allowedValues); + } + + public static class FlakyTestAttributesFlakyStateSerializer + extends StdSerializer { + public FlakyTestAttributesFlakyStateSerializer(Class t) { + super(t); + } + + public FlakyTestAttributesFlakyStateSerializer() { + this(null); + } + + @Override + public void serialize( + FlakyTestAttributesFlakyState value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FlakyTestAttributesFlakyState fromValue(String value) { + return new FlakyTestAttributesFlakyState(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestPipelineStats.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestPipelineStats.java new file mode 100644 index 00000000000..169cbfe1fe3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestPipelineStats.java @@ -0,0 +1,191 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * 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. + */ +@JsonPropertyOrder({ + FlakyTestPipelineStats.JSON_PROPERTY_FAILED_PIPELINES, + FlakyTestPipelineStats.JSON_PROPERTY_TOTAL_LOST_TIME_MS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestPipelineStats { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FAILED_PIPELINES = "failed_pipelines"; + private JsonNullable failedPipelines = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_TOTAL_LOST_TIME_MS = "total_lost_time_ms"; + private JsonNullable totalLostTimeMs = JsonNullable.undefined(); + + public FlakyTestPipelineStats failedPipelines(Long failedPipelines) { + this.failedPipelines = JsonNullable.of(failedPipelines); + return this; + } + + /** + * 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. + * + * @return failedPipelines + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getFailedPipelines() { + return failedPipelines.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FAILED_PIPELINES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getFailedPipelines_JsonNullable() { + return failedPipelines; + } + + @JsonProperty(JSON_PROPERTY_FAILED_PIPELINES) + public void setFailedPipelines_JsonNullable(JsonNullable failedPipelines) { + this.failedPipelines = failedPipelines; + } + + public void setFailedPipelines(Long failedPipelines) { + this.failedPipelines = JsonNullable.of(failedPipelines); + } + + public FlakyTestPipelineStats totalLostTimeMs(Long totalLostTimeMs) { + this.totalLostTimeMs = JsonNullable.of(totalLostTimeMs); + return this; + } + + /** + * 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. + * + * @return totalLostTimeMs + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getTotalLostTimeMs() { + return totalLostTimeMs.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TOTAL_LOST_TIME_MS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getTotalLostTimeMs_JsonNullable() { + return totalLostTimeMs; + } + + @JsonProperty(JSON_PROPERTY_TOTAL_LOST_TIME_MS) + public void setTotalLostTimeMs_JsonNullable(JsonNullable totalLostTimeMs) { + this.totalLostTimeMs = totalLostTimeMs; + } + + public void setTotalLostTimeMs(Long totalLostTimeMs) { + this.totalLostTimeMs = JsonNullable.of(totalLostTimeMs); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestPipelineStats + */ + @JsonAnySetter + public FlakyTestPipelineStats putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestPipelineStats object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestPipelineStats flakyTestPipelineStats = (FlakyTestPipelineStats) o; + return Objects.equals(this.failedPipelines, flakyTestPipelineStats.failedPipelines) + && Objects.equals(this.totalLostTimeMs, flakyTestPipelineStats.totalLostTimeMs) + && Objects.equals(this.additionalProperties, flakyTestPipelineStats.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(failedPipelines, totalLostTimeMs, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestPipelineStats {\n"); + sb.append(" failedPipelines: ").append(toIndentedString(failedPipelines)).append("\n"); + sb.append(" totalLostTimeMs: ").append(toIndentedString(totalLostTimeMs)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestRunMetadata.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestRunMetadata.java new file mode 100644 index 00000000000..9a5604f6845 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestRunMetadata.java @@ -0,0 +1,340 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Metadata about the latest failed test run of the flaky test. */ +@JsonPropertyOrder({ + FlakyTestRunMetadata.JSON_PROPERTY_DURATION_MS, + FlakyTestRunMetadata.JSON_PROPERTY_ERROR_MESSAGE, + FlakyTestRunMetadata.JSON_PROPERTY_ERROR_STACK, + FlakyTestRunMetadata.JSON_PROPERTY_SOURCE_END, + FlakyTestRunMetadata.JSON_PROPERTY_SOURCE_FILE, + FlakyTestRunMetadata.JSON_PROPERTY_SOURCE_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestRunMetadata { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DURATION_MS = "duration_ms"; + private JsonNullable durationMs = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_ERROR_MESSAGE = "error_message"; + private JsonNullable errorMessage = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_ERROR_STACK = "error_stack"; + private JsonNullable errorStack = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_SOURCE_END = "source_end"; + private JsonNullable sourceEnd = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_SOURCE_FILE = "source_file"; + private JsonNullable sourceFile = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_SOURCE_START = "source_start"; + private JsonNullable sourceStart = JsonNullable.undefined(); + + public FlakyTestRunMetadata durationMs(Long durationMs) { + this.durationMs = JsonNullable.of(durationMs); + return this; + } + + /** + * The duration of the test run in milliseconds. + * + * @return durationMs + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getDurationMs() { + return durationMs.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DURATION_MS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDurationMs_JsonNullable() { + return durationMs; + } + + @JsonProperty(JSON_PROPERTY_DURATION_MS) + public void setDurationMs_JsonNullable(JsonNullable durationMs) { + this.durationMs = durationMs; + } + + public void setDurationMs(Long durationMs) { + this.durationMs = JsonNullable.of(durationMs); + } + + public FlakyTestRunMetadata errorMessage(String errorMessage) { + this.errorMessage = JsonNullable.of(errorMessage); + return this; + } + + /** + * The error message from the test failure. + * + * @return errorMessage + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getErrorMessage() { + return errorMessage.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ERROR_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getErrorMessage_JsonNullable() { + return errorMessage; + } + + @JsonProperty(JSON_PROPERTY_ERROR_MESSAGE) + public void setErrorMessage_JsonNullable(JsonNullable errorMessage) { + this.errorMessage = errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = JsonNullable.of(errorMessage); + } + + public FlakyTestRunMetadata errorStack(String errorStack) { + this.errorStack = JsonNullable.of(errorStack); + return this; + } + + /** + * The stack trace from the test failure. + * + * @return errorStack + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getErrorStack() { + return errorStack.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ERROR_STACK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getErrorStack_JsonNullable() { + return errorStack; + } + + @JsonProperty(JSON_PROPERTY_ERROR_STACK) + public void setErrorStack_JsonNullable(JsonNullable errorStack) { + this.errorStack = errorStack; + } + + public void setErrorStack(String errorStack) { + this.errorStack = JsonNullable.of(errorStack); + } + + public FlakyTestRunMetadata sourceEnd(Long sourceEnd) { + this.sourceEnd = JsonNullable.of(sourceEnd); + return this; + } + + /** + * The line number where the test ends in the source file. + * + * @return sourceEnd + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getSourceEnd() { + return sourceEnd.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SOURCE_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getSourceEnd_JsonNullable() { + return sourceEnd; + } + + @JsonProperty(JSON_PROPERTY_SOURCE_END) + public void setSourceEnd_JsonNullable(JsonNullable sourceEnd) { + this.sourceEnd = sourceEnd; + } + + public void setSourceEnd(Long sourceEnd) { + this.sourceEnd = JsonNullable.of(sourceEnd); + } + + public FlakyTestRunMetadata sourceFile(String sourceFile) { + this.sourceFile = JsonNullable.of(sourceFile); + return this; + } + + /** + * The source file where the test is defined. + * + * @return sourceFile + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getSourceFile() { + return sourceFile.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SOURCE_FILE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getSourceFile_JsonNullable() { + return sourceFile; + } + + @JsonProperty(JSON_PROPERTY_SOURCE_FILE) + public void setSourceFile_JsonNullable(JsonNullable sourceFile) { + this.sourceFile = sourceFile; + } + + public void setSourceFile(String sourceFile) { + this.sourceFile = JsonNullable.of(sourceFile); + } + + public FlakyTestRunMetadata sourceStart(Long sourceStart) { + this.sourceStart = JsonNullable.of(sourceStart); + return this; + } + + /** + * The line number where the test starts in the source file. + * + * @return sourceStart + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getSourceStart() { + return sourceStart.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SOURCE_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getSourceStart_JsonNullable() { + return sourceStart; + } + + @JsonProperty(JSON_PROPERTY_SOURCE_START) + public void setSourceStart_JsonNullable(JsonNullable sourceStart) { + this.sourceStart = sourceStart; + } + + public void setSourceStart(Long sourceStart) { + this.sourceStart = JsonNullable.of(sourceStart); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestRunMetadata + */ + @JsonAnySetter + public FlakyTestRunMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestRunMetadata object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestRunMetadata flakyTestRunMetadata = (FlakyTestRunMetadata) o; + return Objects.equals(this.durationMs, flakyTestRunMetadata.durationMs) + && Objects.equals(this.errorMessage, flakyTestRunMetadata.errorMessage) + && Objects.equals(this.errorStack, flakyTestRunMetadata.errorStack) + && Objects.equals(this.sourceEnd, flakyTestRunMetadata.sourceEnd) + && Objects.equals(this.sourceFile, flakyTestRunMetadata.sourceFile) + && Objects.equals(this.sourceStart, flakyTestRunMetadata.sourceStart) + && Objects.equals(this.additionalProperties, flakyTestRunMetadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + durationMs, + errorMessage, + errorStack, + sourceEnd, + sourceFile, + sourceStart, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestRunMetadata {\n"); + sb.append(" durationMs: ").append(toIndentedString(durationMs)).append("\n"); + sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); + sb.append(" errorStack: ").append(toIndentedString(errorStack)).append("\n"); + sb.append(" sourceEnd: ").append(toIndentedString(sourceEnd)).append("\n"); + sb.append(" sourceFile: ").append(toIndentedString(sourceFile)).append("\n"); + sb.append(" sourceStart: ").append(toIndentedString(sourceStart)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestStats.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestStats.java new file mode 100644 index 00000000000..dfa6f8c7cf5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestStats.java @@ -0,0 +1,147 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Test statistics for the flaky test. */ +@JsonPropertyOrder({FlakyTestStats.JSON_PROPERTY_FAILURE_RATE_PCT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestStats { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FAILURE_RATE_PCT = "failure_rate_pct"; + private JsonNullable failureRatePct = JsonNullable.undefined(); + + public FlakyTestStats failureRatePct(Double failureRatePct) { + this.failureRatePct = JsonNullable.of(failureRatePct); + return this; + } + + /** + * 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). + * + * @return failureRatePct + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Double getFailureRatePct() { + return failureRatePct.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FAILURE_RATE_PCT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getFailureRatePct_JsonNullable() { + return failureRatePct; + } + + @JsonProperty(JSON_PROPERTY_FAILURE_RATE_PCT) + public void setFailureRatePct_JsonNullable(JsonNullable failureRatePct) { + this.failureRatePct = failureRatePct; + } + + public void setFailureRatePct(Double failureRatePct) { + this.failureRatePct = JsonNullable.of(failureRatePct); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestStats + */ + @JsonAnySetter + public FlakyTestStats putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestStats object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestStats flakyTestStats = (FlakyTestStats) o; + return Objects.equals(this.failureRatePct, flakyTestStats.failureRatePct) + && Objects.equals(this.additionalProperties, flakyTestStats.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(failureRatePct, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestStats {\n"); + sb.append(" failureRatePct: ").append(toIndentedString(failureRatePct)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestType.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestType.java new file mode 100644 index 00000000000..44f220d136d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestType.java @@ -0,0 +1,53 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The type of the flaky test from Flaky Test Management. */ +@JsonSerialize(using = FlakyTestType.FlakyTestTypeSerializer.class) +public class FlakyTestType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("flaky_test")); + + public static final FlakyTestType FLAKY_TEST = new FlakyTestType("flaky_test"); + + FlakyTestType(String value) { + super(value, allowedValues); + } + + public static class FlakyTestTypeSerializer extends StdSerializer { + public FlakyTestTypeSerializer(Class t) { + super(t); + } + + public FlakyTestTypeSerializer() { + this(null); + } + + @Override + public void serialize(FlakyTestType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FlakyTestType fromValue(String value) { + return new FlakyTestType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsPagination.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsPagination.java new file mode 100644 index 00000000000..289dc8c37a4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsPagination.java @@ -0,0 +1,146 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Pagination metadata for flaky tests. */ +@JsonPropertyOrder({FlakyTestsPagination.JSON_PROPERTY_NEXT_PAGE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsPagination { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NEXT_PAGE = "next_page"; + private JsonNullable nextPage = JsonNullable.undefined(); + + public FlakyTestsPagination nextPage(String nextPage) { + this.nextPage = JsonNullable.of(nextPage); + return this; + } + + /** + * Cursor for the next page of results. + * + * @return nextPage + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getNextPage() { + return nextPage.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NEXT_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getNextPage_JsonNullable() { + return nextPage; + } + + @JsonProperty(JSON_PROPERTY_NEXT_PAGE) + public void setNextPage_JsonNullable(JsonNullable nextPage) { + this.nextPage = nextPage; + } + + public void setNextPage(String nextPage) { + this.nextPage = JsonNullable.of(nextPage); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsPagination + */ + @JsonAnySetter + public FlakyTestsPagination putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsPagination object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsPagination flakyTestsPagination = (FlakyTestsPagination) o; + return Objects.equals(this.nextPage, flakyTestsPagination.nextPage) + && Objects.equals(this.additionalProperties, flakyTestsPagination.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(nextPage, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsPagination {\n"); + sb.append(" nextPage: ").append(toIndentedString(nextPage)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchFilter.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchFilter.java new file mode 100644 index 00000000000..e69ed3f25a0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchFilter.java @@ -0,0 +1,139 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Search filter settings. */ +@JsonPropertyOrder({FlakyTestsSearchFilter.JSON_PROPERTY_QUERY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchFilter { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_QUERY = "query"; + private String query = "*"; + + public FlakyTestsSearchFilter query(String query) { + this.query = query; + return this; + } + + /** + * 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 + * + * @return query + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchFilter + */ + @JsonAnySetter + public FlakyTestsSearchFilter putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchFilter object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchFilter flakyTestsSearchFilter = (FlakyTestsSearchFilter) o; + return Objects.equals(this.query, flakyTestsSearchFilter.query) + && Objects.equals(this.additionalProperties, flakyTestsSearchFilter.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(query, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchFilter {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchPageOptions.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchPageOptions.java new file mode 100644 index 00000000000..9f32e4f39d4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchPageOptions.java @@ -0,0 +1,165 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Pagination attributes for listing flaky tests. */ +@JsonPropertyOrder({ + FlakyTestsSearchPageOptions.JSON_PROPERTY_CURSOR, + FlakyTestsSearchPageOptions.JSON_PROPERTY_LIMIT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchPageOptions { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CURSOR = "cursor"; + private String cursor; + + public static final String JSON_PROPERTY_LIMIT = "limit"; + private Long limit = 10l; + + public FlakyTestsSearchPageOptions cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * List following results with a cursor provided in the previous request. + * + * @return cursor + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CURSOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public FlakyTestsSearchPageOptions limit(Long limit) { + this.limit = limit; + return this; + } + + /** + * Maximum number of flaky tests in the response. minimum: 1 maximum: 1000 + * + * @return limit + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LIMIT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getLimit() { + return limit; + } + + public void setLimit(Long limit) { + this.limit = limit; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchPageOptions + */ + @JsonAnySetter + public FlakyTestsSearchPageOptions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchPageOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchPageOptions flakyTestsSearchPageOptions = (FlakyTestsSearchPageOptions) o; + return Objects.equals(this.cursor, flakyTestsSearchPageOptions.cursor) + && Objects.equals(this.limit, flakyTestsSearchPageOptions.limit) + && Objects.equals( + this.additionalProperties, flakyTestsSearchPageOptions.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(cursor, limit, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchPageOptions {\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequest.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequest.java new file mode 100644 index 00000000000..90d197d6a99 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequest.java @@ -0,0 +1,136 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The request for a flaky tests search. */ +@JsonPropertyOrder({FlakyTestsSearchRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private FlakyTestsSearchRequestData data; + + public FlakyTestsSearchRequest data(FlakyTestsSearchRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The JSON:API data for flaky tests search request. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchRequestData getData() { + return data; + } + + public void setData(FlakyTestsSearchRequestData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchRequest + */ + @JsonAnySetter + public FlakyTestsSearchRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchRequest flakyTestsSearchRequest = (FlakyTestsSearchRequest) o; + return Objects.equals(this.data, flakyTestsSearchRequest.data) + && Objects.equals(this.additionalProperties, flakyTestsSearchRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java new file mode 100644 index 00000000000..eb6799104de --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestAttributes.java @@ -0,0 +1,200 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes for the flaky tests search request. */ +@JsonPropertyOrder({ + FlakyTestsSearchRequestAttributes.JSON_PROPERTY_FILTER, + FlakyTestsSearchRequestAttributes.JSON_PROPERTY_PAGE, + FlakyTestsSearchRequestAttributes.JSON_PROPERTY_SORT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FILTER = "filter"; + private FlakyTestsSearchFilter filter; + + public static final String JSON_PROPERTY_PAGE = "page"; + private FlakyTestsSearchPageOptions page; + + public static final String JSON_PROPERTY_SORT = "sort"; + private FlakyTestsSearchSort sort; + + public FlakyTestsSearchRequestAttributes filter(FlakyTestsSearchFilter filter) { + this.filter = filter; + this.unparsed |= filter.unparsed; + return this; + } + + /** + * Search filter settings. + * + * @return filter + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FILTER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchFilter getFilter() { + return filter; + } + + public void setFilter(FlakyTestsSearchFilter filter) { + this.filter = filter; + } + + public FlakyTestsSearchRequestAttributes page(FlakyTestsSearchPageOptions page) { + this.page = page; + this.unparsed |= page.unparsed; + return this; + } + + /** + * Pagination attributes for listing flaky tests. + * + * @return page + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchPageOptions getPage() { + return page; + } + + public void setPage(FlakyTestsSearchPageOptions page) { + this.page = page; + } + + public FlakyTestsSearchRequestAttributes sort(FlakyTestsSearchSort sort) { + this.sort = sort; + this.unparsed |= !sort.isValid(); + return this; + } + + /** + * 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. + * + * @return sort + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchSort getSort() { + return sort; + } + + public void setSort(FlakyTestsSearchSort sort) { + if (!sort.isValid()) { + this.unparsed = true; + } + this.sort = sort; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchRequestAttributes + */ + @JsonAnySetter + public FlakyTestsSearchRequestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchRequestAttributes flakyTestsSearchRequestAttributes = + (FlakyTestsSearchRequestAttributes) o; + return Objects.equals(this.filter, flakyTestsSearchRequestAttributes.filter) + && Objects.equals(this.page, flakyTestsSearchRequestAttributes.page) + && Objects.equals(this.sort, flakyTestsSearchRequestAttributes.sort) + && Objects.equals( + this.additionalProperties, flakyTestsSearchRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(filter, page, sort, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchRequestAttributes {\n"); + sb.append(" filter: ").append(toIndentedString(filter)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestData.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestData.java new file mode 100644 index 00000000000..7ed24eb8ccd --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestData.java @@ -0,0 +1,170 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The JSON:API data for flaky tests search request. */ +@JsonPropertyOrder({ + FlakyTestsSearchRequestData.JSON_PROPERTY_ATTRIBUTES, + FlakyTestsSearchRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private FlakyTestsSearchRequestAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private FlakyTestsSearchRequestDataType type; + + public FlakyTestsSearchRequestData attributes(FlakyTestsSearchRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for the flaky tests search request. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(FlakyTestsSearchRequestAttributes attributes) { + this.attributes = attributes; + } + + public FlakyTestsSearchRequestData type(FlakyTestsSearchRequestDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The definition of FlakyTestsSearchRequestDataType object. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchRequestDataType getType() { + return type; + } + + public void setType(FlakyTestsSearchRequestDataType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchRequestData + */ + @JsonAnySetter + public FlakyTestsSearchRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchRequestData flakyTestsSearchRequestData = (FlakyTestsSearchRequestData) o; + return Objects.equals(this.attributes, flakyTestsSearchRequestData.attributes) + && Objects.equals(this.type, flakyTestsSearchRequestData.type) + && Objects.equals( + this.additionalProperties, flakyTestsSearchRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestDataType.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestDataType.java new file mode 100644 index 00000000000..2e298d743a7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchRequestDataType.java @@ -0,0 +1,58 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The definition of FlakyTestsSearchRequestDataType object. */ +@JsonSerialize( + using = FlakyTestsSearchRequestDataType.FlakyTestsSearchRequestDataTypeSerializer.class) +public class FlakyTestsSearchRequestDataType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("search_flaky_tests_request")); + + public static final FlakyTestsSearchRequestDataType SEARCH_FLAKY_TESTS_REQUEST = + new FlakyTestsSearchRequestDataType("search_flaky_tests_request"); + + FlakyTestsSearchRequestDataType(String value) { + super(value, allowedValues); + } + + public static class FlakyTestsSearchRequestDataTypeSerializer + extends StdSerializer { + public FlakyTestsSearchRequestDataTypeSerializer(Class t) { + super(t); + } + + public FlakyTestsSearchRequestDataTypeSerializer() { + this(null); + } + + @Override + public void serialize( + FlakyTestsSearchRequestDataType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FlakyTestsSearchRequestDataType fromValue(String value) { + return new FlakyTestsSearchRequestDataType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponse.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponse.java new file mode 100644 index 00000000000..ce3906354db --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponse.java @@ -0,0 +1,179 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response object with flaky tests matching the search request. */ +@JsonPropertyOrder({ + FlakyTestsSearchResponse.JSON_PROPERTY_DATA, + FlakyTestsSearchResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_META = "meta"; + private FlakyTestsSearchResponseMeta meta; + + public FlakyTestsSearchResponse data(List data) { + this.data = data; + for (FlakyTest item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public FlakyTestsSearchResponse addDataItem(FlakyTest dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Array of flaky tests matching the request. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public FlakyTestsSearchResponse meta(FlakyTestsSearchResponseMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Metadata for the flaky tests search response. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsSearchResponseMeta getMeta() { + return meta; + } + + public void setMeta(FlakyTestsSearchResponseMeta meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchResponse + */ + @JsonAnySetter + public FlakyTestsSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchResponse flakyTestsSearchResponse = (FlakyTestsSearchResponse) o; + return Objects.equals(this.data, flakyTestsSearchResponse.data) + && Objects.equals(this.meta, flakyTestsSearchResponse.meta) + && Objects.equals(this.additionalProperties, flakyTestsSearchResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponseMeta.java new file mode 100644 index 00000000000..912f84ef3a7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchResponseMeta.java @@ -0,0 +1,137 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Metadata for the flaky tests search response. */ +@JsonPropertyOrder({FlakyTestsSearchResponseMeta.JSON_PROPERTY_PAGINATION}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FlakyTestsSearchResponseMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PAGINATION = "pagination"; + private FlakyTestsPagination pagination; + + public FlakyTestsSearchResponseMeta pagination(FlakyTestsPagination pagination) { + this.pagination = pagination; + this.unparsed |= pagination.unparsed; + return this; + } + + /** + * Pagination metadata for flaky tests. + * + * @return pagination + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGINATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FlakyTestsPagination getPagination() { + return pagination; + } + + public void setPagination(FlakyTestsPagination pagination) { + this.pagination = pagination; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FlakyTestsSearchResponseMeta + */ + @JsonAnySetter + public FlakyTestsSearchResponseMeta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FlakyTestsSearchResponseMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlakyTestsSearchResponseMeta flakyTestsSearchResponseMeta = (FlakyTestsSearchResponseMeta) o; + return Objects.equals(this.pagination, flakyTestsSearchResponseMeta.pagination) + && Objects.equals( + this.additionalProperties, flakyTestsSearchResponseMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(pagination, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlakyTestsSearchResponseMeta {\n"); + sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchSort.java b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchSort.java new file mode 100644 index 00000000000..8dd2d841ff7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FlakyTestsSearchSort.java @@ -0,0 +1,92 @@ +/* + * 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 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * 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. + */ +@JsonSerialize(using = FlakyTestsSearchSort.FlakyTestsSearchSortSerializer.class) +public class FlakyTestsSearchSort extends ModelEnum { + + private static final Set allowedValues = + new HashSet( + Arrays.asList( + "fqn", + "-fqn", + "first_flaked", + "-first_flaked", + "last_flaked", + "-last_flaked", + "failure_rate", + "-failure_rate", + "pipelines_failed", + "-pipelines_failed", + "pipelines_duration_lost", + "-pipelines_duration_lost")); + + public static final FlakyTestsSearchSort FQN_ASCENDING = new FlakyTestsSearchSort("fqn"); + public static final FlakyTestsSearchSort FQN_DESCENDING = new FlakyTestsSearchSort("-fqn"); + public static final FlakyTestsSearchSort FIRST_FLAKED_ASCENDING = + new FlakyTestsSearchSort("first_flaked"); + public static final FlakyTestsSearchSort FIRST_FLAKED_DESCENDING = + new FlakyTestsSearchSort("-first_flaked"); + public static final FlakyTestsSearchSort LAST_FLAKED_ASCENDING = + new FlakyTestsSearchSort("last_flaked"); + public static final FlakyTestsSearchSort LAST_FLAKED_DESCENDING = + new FlakyTestsSearchSort("-last_flaked"); + public static final FlakyTestsSearchSort FAILURE_RATE_ASCENDING = + new FlakyTestsSearchSort("failure_rate"); + public static final FlakyTestsSearchSort FAILURE_RATE_DESCENDING = + new FlakyTestsSearchSort("-failure_rate"); + public static final FlakyTestsSearchSort PIPELINES_FAILED_ASCENDING = + new FlakyTestsSearchSort("pipelines_failed"); + public static final FlakyTestsSearchSort PIPELINES_FAILED_DESCENDING = + new FlakyTestsSearchSort("-pipelines_failed"); + public static final FlakyTestsSearchSort PIPELINES_DURATION_LOST_ASCENDING = + new FlakyTestsSearchSort("pipelines_duration_lost"); + public static final FlakyTestsSearchSort PIPELINES_DURATION_LOST_DESCENDING = + new FlakyTestsSearchSort("-pipelines_duration_lost"); + + FlakyTestsSearchSort(String value) { + super(value, allowedValues); + } + + public static class FlakyTestsSearchSortSerializer extends StdSerializer { + public FlakyTestsSearchSortSerializer(Class t) { + super(t); + } + + public FlakyTestsSearchSortSerializer() { + this(null); + } + + @Override + public void serialize( + FlakyTestsSearchSort value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FlakyTestsSearchSort fromValue(String value) { + return new FlakyTestsSearchSort(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature b/src/test/resources/com/datadog/api/client/v2/api/test_optimization.feature new file mode 100644 index 00000000000..18af1e9cad9 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v2/api/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/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 85202abf346..92c07fe002e 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -3978,6 +3978,12 @@ "type": "idempotent" } }, + "SearchFlakyTests": { + "tag": "Test Optimization", + "undo": { + "type": "safe" + } + }, "GetUsageApplicationSecurityMonitoring": { "tag": "Usage Metering", "undo": {