From cdcfb64a96aeded982063d851a834632d2a0ab65 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 22 Jan 2026 12:01:22 +0000 Subject: [PATCH] Regenerate client from commit 8b43fc8 of spec repo --- .generator/schemas/v2/openapi.yaml | 170 ++++++++++++++++++ docs/datadog_api_client.v2.model.rst | 77 ++++++++ .../v2/test-optimization/UpdateFlakyTests.py | 34 ++++ src/datadog_api_client/configuration.py | 1 + .../v2/api/test_optimization_api.py | 38 ++++ .../v2/model/update_flaky_tests_request.py | 40 +++++ .../update_flaky_tests_request_attributes.py | 40 +++++ .../model/update_flaky_tests_request_data.py | 48 +++++ .../update_flaky_tests_request_data_type.py | 37 ++++ .../model/update_flaky_tests_request_test.py | 50 ++++++ ...date_flaky_tests_request_test_new_state.py | 44 +++++ .../v2/model/update_flaky_tests_response.py | 42 +++++ .../update_flaky_tests_response_attributes.py | 46 +++++ .../model/update_flaky_tests_response_data.py | 66 +++++++ .../update_flaky_tests_response_data_type.py | 37 ++++ .../update_flaky_tests_response_result.py | 49 +++++ src/datadog_api_client/v2/models/__init__.py | 22 +++ tests/v2/features/test_optimization.feature | 38 +++- tests/v2/features/undo.json | 6 + 19 files changed, 878 insertions(+), 7 deletions(-) create mode 100644 examples/v2/test-optimization/UpdateFlakyTests.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request_attributes.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request_data.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request_data_type.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request_test.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_request_test_new_state.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_response.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_response_attributes.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_response_data.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_response_data_type.py create mode 100644 src/datadog_api_client/v2/model/update_flaky_tests_response_result.py diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 39f6901f1a..c7a12f6264 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -61289,6 +61289,136 @@ components: - name - options type: object + UpdateFlakyTestsRequest: + description: Request to update the state of multiple flaky tests. + properties: + data: + $ref: '#/components/schemas/UpdateFlakyTestsRequestData' + required: + - data + type: object + UpdateFlakyTestsRequestAttributes: + description: Attributes for updating flaky test states. + properties: + tests: + description: List of flaky tests to update. + items: + $ref: '#/components/schemas/UpdateFlakyTestsRequestTest' + type: array + required: + - tests + type: object + UpdateFlakyTestsRequestData: + description: The JSON:API data for updating flaky test states. + properties: + attributes: + $ref: '#/components/schemas/UpdateFlakyTestsRequestAttributes' + type: + $ref: '#/components/schemas/UpdateFlakyTestsRequestDataType' + required: + - type + - attributes + type: object + UpdateFlakyTestsRequestDataType: + description: The definition of `UpdateFlakyTestsRequestDataType` object. + enum: + - update_flaky_test_state_request + example: update_flaky_test_state_request + type: string + x-enum-varnames: + - UPDATE_FLAKY_TEST_STATE_REQUEST + UpdateFlakyTestsRequestTest: + description: Details of what tests to update and their new attributes. + properties: + id: + description: The ID of the flaky test. This is the same ID returned by the + Search flaky tests endpoint and corresponds to the test_fingerprint_fqn + field in test run events. + example: 4eb1887a8adb1847 + type: string + new_state: + $ref: '#/components/schemas/UpdateFlakyTestsRequestTestNewState' + required: + - id + - new_state + type: object + UpdateFlakyTestsRequestTestNewState: + description: The new state to set for the flaky test. + enum: + - active + - quarantined + - disabled + - fixed + example: active + type: string + x-enum-varnames: + - ACTIVE + - QUARANTINED + - DISABLED + - FIXED + UpdateFlakyTestsResponse: + description: Response object for updating flaky test states. + properties: + data: + $ref: '#/components/schemas/UpdateFlakyTestsResponseData' + type: object + UpdateFlakyTestsResponseAttributes: + description: Attributes for the update flaky test state response. + properties: + has_errors: + description: '`True` if any errors occurred during the update operations. + `False` if all tests succeeded to be updated.' + example: true + type: boolean + results: + description: Results of the update operation for each test. + items: + $ref: '#/components/schemas/UpdateFlakyTestsResponseResult' + type: array + required: + - has_errors + - results + type: object + UpdateFlakyTestsResponseData: + description: Summary of the update operations. Tells whether a test succeeded + or failed to be updated. + properties: + attributes: + $ref: '#/components/schemas/UpdateFlakyTestsResponseAttributes' + id: + description: The ID of the response. + type: string + type: + $ref: '#/components/schemas/UpdateFlakyTestsResponseDataType' + type: object + UpdateFlakyTestsResponseDataType: + description: The definition of `UpdateFlakyTestsResponseDataType` object. + enum: + - update_flaky_test_state_response + type: string + x-enum-varnames: + - UPDATE_FLAKY_TEST_STATE_RESPONSE + UpdateFlakyTestsResponseResult: + description: Result of updating a single flaky test state. + properties: + error: + description: Error message if the update failed. + type: string + id: + description: The ID of the flaky test from the request. This is the same + ID returned by the Search flaky tests endpoint and corresponds to the + test_fingerprint_fqn field in test run events. + example: 4eb1887a8adb1847 + type: string + success: + description: '`True` if the update was successful, `False` if there were + any errors.' + example: false + type: boolean + required: + - id + - success + type: object UpdateOnCallNotificationRuleRequest: description: A top-level wrapper for updating a notification rule for a user example: @@ -63638,6 +63768,8 @@ components: teams_read: Read Teams data. A User with this permission can view Team names, metadata, and which Users are on each Team. test_optimization_read: View Test Optimization. + test_optimization_write: Update flaky tests from Flaky Tests Management + of Test Optimization. timeseries_query: Query Timeseries data. usage_read: View your organization's usage and usage attribution. user_access_invite: Invite other users to your organization. @@ -94850,6 +94982,44 @@ paths: - 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: + patch: + description: Update the state of multiple flaky tests in Flaky Test Management. + operationId: UpdateFlakyTests + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateFlakyTestsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateFlakyTestsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - test_optimization_write + summary: Update flaky test states + tags: + - Test Optimization + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - test_optimization_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: description: List endpoint returning flaky tests from Flaky Test Management. Results are paginated. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 556133a832..99578b3a06 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -26975,6 +26975,83 @@ datadog\_api\_client.v2.model.update\_deployment\_rule\_params\_data\_attributes :members: :show-inheritance: +datadog\_api\_client.v2.model.update\_flaky\_tests\_request module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_attributes module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_data module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_data\_type module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_data_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_test module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_test + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_test\_new\_state module +------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_test_new_state + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_response module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_attributes module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_data module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_data\_type module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_data_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_result module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_result + :members: + :show-inheritance: + datadog\_api\_client.v2.model.update\_on\_call\_notification\_rule\_request module ---------------------------------------------------------------------------------- diff --git a/examples/v2/test-optimization/UpdateFlakyTests.py b/examples/v2/test-optimization/UpdateFlakyTests.py new file mode 100644 index 0000000000..6ee67e61d3 --- /dev/null +++ b/examples/v2/test-optimization/UpdateFlakyTests.py @@ -0,0 +1,34 @@ +""" +Update flaky test states returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi +from datadog_api_client.v2.model.update_flaky_tests_request import UpdateFlakyTestsRequest +from datadog_api_client.v2.model.update_flaky_tests_request_attributes import UpdateFlakyTestsRequestAttributes +from datadog_api_client.v2.model.update_flaky_tests_request_data import UpdateFlakyTestsRequestData +from datadog_api_client.v2.model.update_flaky_tests_request_data_type import UpdateFlakyTestsRequestDataType +from datadog_api_client.v2.model.update_flaky_tests_request_test import UpdateFlakyTestsRequestTest +from datadog_api_client.v2.model.update_flaky_tests_request_test_new_state import UpdateFlakyTestsRequestTestNewState + +body = UpdateFlakyTestsRequest( + data=UpdateFlakyTestsRequestData( + attributes=UpdateFlakyTestsRequestAttributes( + tests=[ + UpdateFlakyTestsRequestTest( + id="4eb1887a8adb1847", + new_state=UpdateFlakyTestsRequestTestNewState.ACTIVE, + ), + ], + ), + type=UpdateFlakyTestsRequestDataType.UPDATE_FLAKY_TEST_STATE_REQUEST, + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_flaky_tests"] = True +with ApiClient(configuration) as api_client: + api_instance = TestOptimizationApi(api_client) + response = api_instance.update_flaky_tests(body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 9332cb91fd..74a52575e9 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -415,6 +415,7 @@ def __init__( "v2.list_incident_teams": False, "v2.update_incident_team": False, "v2.search_flaky_tests": False, + "v2.update_flaky_tests": False, } ) diff --git a/src/datadog_api_client/v2/api/test_optimization_api.py b/src/datadog_api_client/v2/api/test_optimization_api.py index a94363c559..3d63373d34 100644 --- a/src/datadog_api_client/v2/api/test_optimization_api.py +++ b/src/datadog_api_client/v2/api/test_optimization_api.py @@ -14,6 +14,8 @@ UnsetType, unset, ) +from datadog_api_client.v2.model.update_flaky_tests_response import UpdateFlakyTestsResponse +from datadog_api_client.v2.model.update_flaky_tests_request import UpdateFlakyTestsRequest from datadog_api_client.v2.model.flaky_tests_search_response import FlakyTestsSearchResponse from datadog_api_client.v2.model.flaky_tests_search_request import FlakyTestsSearchRequest from datadog_api_client.v2.model.flaky_test import FlakyTest @@ -48,6 +50,26 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_flaky_tests_endpoint = _Endpoint( + settings={ + "response_type": (UpdateFlakyTestsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/test/flaky-test-management/tests", + "operation_id": "update_flaky_tests", + "http_method": "PATCH", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (UpdateFlakyTestsRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + def search_flaky_tests( self, *, @@ -96,3 +118,19 @@ def search_flaky_tests_with_pagination( "kwargs": kwargs, } return endpoint.call_with_http_info_paginated(pagination) + + def update_flaky_tests( + self, + body: UpdateFlakyTestsRequest, + ) -> UpdateFlakyTestsResponse: + """Update flaky test states. + + Update the state of multiple flaky tests in Flaky Test Management. + + :type body: UpdateFlakyTestsRequest + :rtype: UpdateFlakyTestsResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._update_flaky_tests_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request.py b/src/datadog_api_client/v2/model/update_flaky_tests_request.py new file mode 100644 index 0000000000..15c4464293 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_request_data import UpdateFlakyTestsRequestData + + +class UpdateFlakyTestsRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_request_data import UpdateFlakyTestsRequestData + + return { + "data": (UpdateFlakyTestsRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: UpdateFlakyTestsRequestData, **kwargs): + """ + Request to update the state of multiple flaky tests. + + :param data: The JSON:API data for updating flaky test states. + :type data: UpdateFlakyTestsRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request_attributes.py b/src/datadog_api_client/v2/model/update_flaky_tests_request_attributes.py new file mode 100644 index 0000000000..891c0a45d6 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request_attributes.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_request_test import UpdateFlakyTestsRequestTest + + +class UpdateFlakyTestsRequestAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_request_test import UpdateFlakyTestsRequestTest + + return { + "tests": ([UpdateFlakyTestsRequestTest],), + } + + attribute_map = { + "tests": "tests", + } + + def __init__(self_, tests: List[UpdateFlakyTestsRequestTest], **kwargs): + """ + Attributes for updating flaky test states. + + :param tests: List of flaky tests to update. + :type tests: [UpdateFlakyTestsRequestTest] + """ + super().__init__(kwargs) + + self_.tests = tests diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request_data.py b/src/datadog_api_client/v2/model/update_flaky_tests_request_data.py new file mode 100644 index 0000000000..1eb8f2efa3 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request_data.py @@ -0,0 +1,48 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_request_attributes import UpdateFlakyTestsRequestAttributes + from datadog_api_client.v2.model.update_flaky_tests_request_data_type import UpdateFlakyTestsRequestDataType + + +class UpdateFlakyTestsRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_request_attributes import UpdateFlakyTestsRequestAttributes + from datadog_api_client.v2.model.update_flaky_tests_request_data_type import UpdateFlakyTestsRequestDataType + + return { + "attributes": (UpdateFlakyTestsRequestAttributes,), + "type": (UpdateFlakyTestsRequestDataType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: UpdateFlakyTestsRequestAttributes, type: UpdateFlakyTestsRequestDataType, **kwargs): + """ + The JSON:API data for updating flaky test states. + + :param attributes: Attributes for updating flaky test states. + :type attributes: UpdateFlakyTestsRequestAttributes + + :param type: The definition of ``UpdateFlakyTestsRequestDataType`` object. + :type type: UpdateFlakyTestsRequestDataType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request_data_type.py b/src/datadog_api_client/v2/model/update_flaky_tests_request_data_type.py new file mode 100644 index 0000000000..c7093ae932 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request_data_type.py @@ -0,0 +1,37 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class UpdateFlakyTestsRequestDataType(ModelSimple): + """ + The definition of `UpdateFlakyTestsRequestDataType` object. + + :param value: If omitted defaults to "update_flaky_test_state_request". Must be one of ["update_flaky_test_state_request"]. + :type value: str + """ + + allowed_values = { + "update_flaky_test_state_request", + } + UPDATE_FLAKY_TEST_STATE_REQUEST: ClassVar["UpdateFlakyTestsRequestDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +UpdateFlakyTestsRequestDataType.UPDATE_FLAKY_TEST_STATE_REQUEST = UpdateFlakyTestsRequestDataType( + "update_flaky_test_state_request" +) diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request_test.py b/src/datadog_api_client/v2/model/update_flaky_tests_request_test.py new file mode 100644 index 0000000000..9b65eb1eab --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request_test.py @@ -0,0 +1,50 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_request_test_new_state import ( + UpdateFlakyTestsRequestTestNewState, + ) + + +class UpdateFlakyTestsRequestTest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_request_test_new_state import ( + UpdateFlakyTestsRequestTestNewState, + ) + + return { + "id": (str,), + "new_state": (UpdateFlakyTestsRequestTestNewState,), + } + + attribute_map = { + "id": "id", + "new_state": "new_state", + } + + def __init__(self_, id: str, new_state: UpdateFlakyTestsRequestTestNewState, **kwargs): + """ + Details of what tests to update and their new attributes. + + :param id: The ID of the flaky test. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events. + :type id: str + + :param new_state: The new state to set for the flaky test. + :type new_state: UpdateFlakyTestsRequestTestNewState + """ + super().__init__(kwargs) + + self_.id = id + self_.new_state = new_state diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_request_test_new_state.py b/src/datadog_api_client/v2/model/update_flaky_tests_request_test_new_state.py new file mode 100644 index 0000000000..85d4dc5ff4 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_request_test_new_state.py @@ -0,0 +1,44 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class UpdateFlakyTestsRequestTestNewState(ModelSimple): + """ + The new state to set for the flaky test. + + :param value: Must be one of ["active", "quarantined", "disabled", "fixed"]. + :type value: str + """ + + allowed_values = { + "active", + "quarantined", + "disabled", + "fixed", + } + ACTIVE: ClassVar["UpdateFlakyTestsRequestTestNewState"] + QUARANTINED: ClassVar["UpdateFlakyTestsRequestTestNewState"] + DISABLED: ClassVar["UpdateFlakyTestsRequestTestNewState"] + FIXED: ClassVar["UpdateFlakyTestsRequestTestNewState"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +UpdateFlakyTestsRequestTestNewState.ACTIVE = UpdateFlakyTestsRequestTestNewState("active") +UpdateFlakyTestsRequestTestNewState.QUARANTINED = UpdateFlakyTestsRequestTestNewState("quarantined") +UpdateFlakyTestsRequestTestNewState.DISABLED = UpdateFlakyTestsRequestTestNewState("disabled") +UpdateFlakyTestsRequestTestNewState.FIXED = UpdateFlakyTestsRequestTestNewState("fixed") diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_response.py b/src/datadog_api_client/v2/model/update_flaky_tests_response.py new file mode 100644 index 0000000000..ab2ee724c4 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_response.py @@ -0,0 +1,42 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_response_data import UpdateFlakyTestsResponseData + + +class UpdateFlakyTestsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_response_data import UpdateFlakyTestsResponseData + + return { + "data": (UpdateFlakyTestsResponseData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[UpdateFlakyTestsResponseData, UnsetType] = unset, **kwargs): + """ + Response object for updating flaky test states. + + :param data: Summary of the update operations. Tells whether a test succeeded or failed to be updated. + :type data: UpdateFlakyTestsResponseData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_response_attributes.py b/src/datadog_api_client/v2/model/update_flaky_tests_response_attributes.py new file mode 100644 index 0000000000..a63af4fff9 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_response_attributes.py @@ -0,0 +1,46 @@ +# 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. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_response_result import UpdateFlakyTestsResponseResult + + +class UpdateFlakyTestsResponseAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_response_result import UpdateFlakyTestsResponseResult + + return { + "has_errors": (bool,), + "results": ([UpdateFlakyTestsResponseResult],), + } + + attribute_map = { + "has_errors": "has_errors", + "results": "results", + } + + def __init__(self_, has_errors: bool, results: List[UpdateFlakyTestsResponseResult], **kwargs): + """ + Attributes for the update flaky test state response. + + :param has_errors: ``True`` if any errors occurred during the update operations. ``False`` if all tests succeeded to be updated. + :type has_errors: bool + + :param results: Results of the update operation for each test. + :type results: [UpdateFlakyTestsResponseResult] + """ + super().__init__(kwargs) + + self_.has_errors = has_errors + self_.results = results diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_response_data.py b/src/datadog_api_client/v2/model/update_flaky_tests_response_data.py new file mode 100644 index 0000000000..1d59432bfc --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_response_data.py @@ -0,0 +1,66 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.update_flaky_tests_response_attributes import UpdateFlakyTestsResponseAttributes + from datadog_api_client.v2.model.update_flaky_tests_response_data_type import UpdateFlakyTestsResponseDataType + + +class UpdateFlakyTestsResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_flaky_tests_response_attributes import ( + UpdateFlakyTestsResponseAttributes, + ) + from datadog_api_client.v2.model.update_flaky_tests_response_data_type import UpdateFlakyTestsResponseDataType + + return { + "attributes": (UpdateFlakyTestsResponseAttributes,), + "id": (str,), + "type": (UpdateFlakyTestsResponseDataType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[UpdateFlakyTestsResponseAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + type: Union[UpdateFlakyTestsResponseDataType, UnsetType] = unset, + **kwargs, + ): + """ + Summary of the update operations. Tells whether a test succeeded or failed to be updated. + + :param attributes: Attributes for the update flaky test state response. + :type attributes: UpdateFlakyTestsResponseAttributes, optional + + :param id: The ID of the response. + :type id: str, optional + + :param type: The definition of ``UpdateFlakyTestsResponseDataType`` object. + :type type: UpdateFlakyTestsResponseDataType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_response_data_type.py b/src/datadog_api_client/v2/model/update_flaky_tests_response_data_type.py new file mode 100644 index 0000000000..078bd3d4f4 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_response_data_type.py @@ -0,0 +1,37 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class UpdateFlakyTestsResponseDataType(ModelSimple): + """ + The definition of `UpdateFlakyTestsResponseDataType` object. + + :param value: If omitted defaults to "update_flaky_test_state_response". Must be one of ["update_flaky_test_state_response"]. + :type value: str + """ + + allowed_values = { + "update_flaky_test_state_response", + } + UPDATE_FLAKY_TEST_STATE_RESPONSE: ClassVar["UpdateFlakyTestsResponseDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +UpdateFlakyTestsResponseDataType.UPDATE_FLAKY_TEST_STATE_RESPONSE = UpdateFlakyTestsResponseDataType( + "update_flaky_test_state_response" +) diff --git a/src/datadog_api_client/v2/model/update_flaky_tests_response_result.py b/src/datadog_api_client/v2/model/update_flaky_tests_response_result.py new file mode 100644 index 0000000000..059c265316 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_flaky_tests_response_result.py @@ -0,0 +1,49 @@ +# 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. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class UpdateFlakyTestsResponseResult(ModelNormal): + @cached_property + def openapi_types(_): + return { + "error": (str,), + "id": (str,), + "success": (bool,), + } + + attribute_map = { + "error": "error", + "id": "id", + "success": "success", + } + + def __init__(self_, id: str, success: bool, error: Union[str, UnsetType] = unset, **kwargs): + """ + Result of updating a single flaky test state. + + :param error: Error message if the update failed. + :type error: str, optional + + :param id: The ID of the flaky test from the request. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events. + :type id: str + + :param success: ``True`` if the update was successful, ``False`` if there were any errors. + :type success: bool + """ + if error is not unset: + kwargs["error"] = error + super().__init__(kwargs) + + self_.id = id + self_.success = success diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 04de478c72..ffa0a0936e 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -5484,6 +5484,17 @@ from datadog_api_client.v2.model.update_deployment_rule_params_data_attributes import ( UpdateDeploymentRuleParamsDataAttributes, ) +from datadog_api_client.v2.model.update_flaky_tests_request import UpdateFlakyTestsRequest +from datadog_api_client.v2.model.update_flaky_tests_request_attributes import UpdateFlakyTestsRequestAttributes +from datadog_api_client.v2.model.update_flaky_tests_request_data import UpdateFlakyTestsRequestData +from datadog_api_client.v2.model.update_flaky_tests_request_data_type import UpdateFlakyTestsRequestDataType +from datadog_api_client.v2.model.update_flaky_tests_request_test import UpdateFlakyTestsRequestTest +from datadog_api_client.v2.model.update_flaky_tests_request_test_new_state import UpdateFlakyTestsRequestTestNewState +from datadog_api_client.v2.model.update_flaky_tests_response import UpdateFlakyTestsResponse +from datadog_api_client.v2.model.update_flaky_tests_response_attributes import UpdateFlakyTestsResponseAttributes +from datadog_api_client.v2.model.update_flaky_tests_response_data import UpdateFlakyTestsResponseData +from datadog_api_client.v2.model.update_flaky_tests_response_data_type import UpdateFlakyTestsResponseDataType +from datadog_api_client.v2.model.update_flaky_tests_response_result import UpdateFlakyTestsResponseResult from datadog_api_client.v2.model.update_on_call_notification_rule_request import UpdateOnCallNotificationRuleRequest from datadog_api_client.v2.model.update_on_call_notification_rule_request_attributes import ( UpdateOnCallNotificationRuleRequestAttributes, @@ -9535,6 +9546,17 @@ "UpdateDeploymentRuleParams", "UpdateDeploymentRuleParamsData", "UpdateDeploymentRuleParamsDataAttributes", + "UpdateFlakyTestsRequest", + "UpdateFlakyTestsRequestAttributes", + "UpdateFlakyTestsRequestData", + "UpdateFlakyTestsRequestDataType", + "UpdateFlakyTestsRequestTest", + "UpdateFlakyTestsRequestTestNewState", + "UpdateFlakyTestsResponse", + "UpdateFlakyTestsResponseAttributes", + "UpdateFlakyTestsResponseData", + "UpdateFlakyTestsResponseDataType", + "UpdateFlakyTestsResponseResult", "UpdateOnCallNotificationRuleRequest", "UpdateOnCallNotificationRuleRequestAttributes", "UpdateOnCallNotificationRuleRequestData", diff --git a/tests/v2/features/test_optimization.feature b/tests/v2/features/test_optimization.feature index 18af1e9cad..d21278d764 100644 --- a/tests/v2/features/test_optimization.feature +++ b/tests/v2/features/test_optimization.feature @@ -8,35 +8,59 @@ Feature: Test Optimization 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"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And 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"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And 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"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And 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"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And 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"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And 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 + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update flaky test states returns "Bad Request" response + Given operation "UpdateFlakyTests" enabled + And new "UpdateFlakyTests" request + And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update flaky test states returns "OK" response + Given operation "UpdateFlakyTests" enabled + And new "UpdateFlakyTests" request + And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index bfcee722b4..980e3bbbac 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -5149,6 +5149,12 @@ "type": "idempotent" } }, + "UpdateFlakyTests": { + "tag": "Test Optimization", + "undo": { + "type": "unsafe" + } + }, "SearchFlakyTests": { "tag": "Test Optimization", "undo": {