Skip to content

Commit a42509d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add UpdateFlakyTestState endpoint to Flaky Test Management API (#3118)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0162619 commit a42509d

19 files changed

Lines changed: 878 additions & 7 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61408,6 +61408,136 @@ components:
6140861408
- name
6140961409
- options
6141061410
type: object
61411+
UpdateFlakyTestsRequest:
61412+
description: Request to update the state of multiple flaky tests.
61413+
properties:
61414+
data:
61415+
$ref: '#/components/schemas/UpdateFlakyTestsRequestData'
61416+
required:
61417+
- data
61418+
type: object
61419+
UpdateFlakyTestsRequestAttributes:
61420+
description: Attributes for updating flaky test states.
61421+
properties:
61422+
tests:
61423+
description: List of flaky tests to update.
61424+
items:
61425+
$ref: '#/components/schemas/UpdateFlakyTestsRequestTest'
61426+
type: array
61427+
required:
61428+
- tests
61429+
type: object
61430+
UpdateFlakyTestsRequestData:
61431+
description: The JSON:API data for updating flaky test states.
61432+
properties:
61433+
attributes:
61434+
$ref: '#/components/schemas/UpdateFlakyTestsRequestAttributes'
61435+
type:
61436+
$ref: '#/components/schemas/UpdateFlakyTestsRequestDataType'
61437+
required:
61438+
- type
61439+
- attributes
61440+
type: object
61441+
UpdateFlakyTestsRequestDataType:
61442+
description: The definition of `UpdateFlakyTestsRequestDataType` object.
61443+
enum:
61444+
- update_flaky_test_state_request
61445+
example: update_flaky_test_state_request
61446+
type: string
61447+
x-enum-varnames:
61448+
- UPDATE_FLAKY_TEST_STATE_REQUEST
61449+
UpdateFlakyTestsRequestTest:
61450+
description: Details of what tests to update and their new attributes.
61451+
properties:
61452+
id:
61453+
description: The ID of the flaky test. This is the same ID returned by the
61454+
Search flaky tests endpoint and corresponds to the test_fingerprint_fqn
61455+
field in test run events.
61456+
example: 4eb1887a8adb1847
61457+
type: string
61458+
new_state:
61459+
$ref: '#/components/schemas/UpdateFlakyTestsRequestTestNewState'
61460+
required:
61461+
- id
61462+
- new_state
61463+
type: object
61464+
UpdateFlakyTestsRequestTestNewState:
61465+
description: The new state to set for the flaky test.
61466+
enum:
61467+
- active
61468+
- quarantined
61469+
- disabled
61470+
- fixed
61471+
example: active
61472+
type: string
61473+
x-enum-varnames:
61474+
- ACTIVE
61475+
- QUARANTINED
61476+
- DISABLED
61477+
- FIXED
61478+
UpdateFlakyTestsResponse:
61479+
description: Response object for updating flaky test states.
61480+
properties:
61481+
data:
61482+
$ref: '#/components/schemas/UpdateFlakyTestsResponseData'
61483+
type: object
61484+
UpdateFlakyTestsResponseAttributes:
61485+
description: Attributes for the update flaky test state response.
61486+
properties:
61487+
has_errors:
61488+
description: '`True` if any errors occurred during the update operations.
61489+
`False` if all tests succeeded to be updated.'
61490+
example: true
61491+
type: boolean
61492+
results:
61493+
description: Results of the update operation for each test.
61494+
items:
61495+
$ref: '#/components/schemas/UpdateFlakyTestsResponseResult'
61496+
type: array
61497+
required:
61498+
- has_errors
61499+
- results
61500+
type: object
61501+
UpdateFlakyTestsResponseData:
61502+
description: Summary of the update operations. Tells whether a test succeeded
61503+
or failed to be updated.
61504+
properties:
61505+
attributes:
61506+
$ref: '#/components/schemas/UpdateFlakyTestsResponseAttributes'
61507+
id:
61508+
description: The ID of the response.
61509+
type: string
61510+
type:
61511+
$ref: '#/components/schemas/UpdateFlakyTestsResponseDataType'
61512+
type: object
61513+
UpdateFlakyTestsResponseDataType:
61514+
description: The definition of `UpdateFlakyTestsResponseDataType` object.
61515+
enum:
61516+
- update_flaky_test_state_response
61517+
type: string
61518+
x-enum-varnames:
61519+
- UPDATE_FLAKY_TEST_STATE_RESPONSE
61520+
UpdateFlakyTestsResponseResult:
61521+
description: Result of updating a single flaky test state.
61522+
properties:
61523+
error:
61524+
description: Error message if the update failed.
61525+
type: string
61526+
id:
61527+
description: The ID of the flaky test from the request. This is the same
61528+
ID returned by the Search flaky tests endpoint and corresponds to the
61529+
test_fingerprint_fqn field in test run events.
61530+
example: 4eb1887a8adb1847
61531+
type: string
61532+
success:
61533+
description: '`True` if the update was successful, `False` if there were
61534+
any errors.'
61535+
example: false
61536+
type: boolean
61537+
required:
61538+
- id
61539+
- success
61540+
type: object
6141161541
UpdateOnCallNotificationRuleRequest:
6141261542
description: A top-level wrapper for updating a notification rule for a user
6141361543
example:
@@ -63757,6 +63887,8 @@ components:
6375763887
teams_read: Read Teams data. A User with this permission can view Team
6375863888
names, metadata, and which Users are on each Team.
6375963889
test_optimization_read: View Test Optimization.
63890+
test_optimization_write: Update flaky tests from Flaky Tests Management
63891+
of Test Optimization.
6376063892
timeseries_query: Query Timeseries data.
6376163893
usage_read: View your organization's usage and usage attribution.
6376263894
user_access_invite: Invite other users to your organization.
@@ -94990,6 +95122,44 @@ paths:
9499095122
- incident_settings_write
9499195123
x-unstable: '**Note**: This endpoint is deprecated. See the [Teams API endpoints](https://docs.datadoghq.com/api/latest/teams/).'
9499295124
/api/v2/test/flaky-test-management/tests:
95125+
patch:
95126+
description: Update the state of multiple flaky tests in Flaky Test Management.
95127+
operationId: UpdateFlakyTests
95128+
requestBody:
95129+
content:
95130+
application/json:
95131+
schema:
95132+
$ref: '#/components/schemas/UpdateFlakyTestsRequest'
95133+
required: true
95134+
responses:
95135+
'200':
95136+
content:
95137+
application/json:
95138+
schema:
95139+
$ref: '#/components/schemas/UpdateFlakyTestsResponse'
95140+
description: OK
95141+
'400':
95142+
$ref: '#/components/responses/BadRequestResponse'
95143+
'403':
95144+
$ref: '#/components/responses/NotAuthorizedResponse'
95145+
'429':
95146+
$ref: '#/components/responses/TooManyRequestsResponse'
95147+
security:
95148+
- apiKeyAuth: []
95149+
appKeyAuth: []
95150+
- AuthZ:
95151+
- test_optimization_write
95152+
summary: Update flaky test states
95153+
tags:
95154+
- Test Optimization
95155+
x-codegen-request-body-name: body
95156+
x-permission:
95157+
operator: OR
95158+
permissions:
95159+
- test_optimization_write
95160+
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.
95161+
95162+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
9499395163
post:
9499495164
description: List endpoint returning flaky tests from Flaky Test Management.
9499595165
Results are paginated.

docs/datadog_api_client.v2.model.rst

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27031,6 +27031,83 @@ datadog\_api\_client.v2.model.update\_deployment\_rule\_params\_data\_attributes
2703127031
:members:
2703227032
:show-inheritance:
2703327033

27034+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request module
27035+
------------------------------------------------------------------
27036+
27037+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request
27038+
:members:
27039+
:show-inheritance:
27040+
27041+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_attributes module
27042+
------------------------------------------------------------------------------
27043+
27044+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_attributes
27045+
:members:
27046+
:show-inheritance:
27047+
27048+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_data module
27049+
------------------------------------------------------------------------
27050+
27051+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_data
27052+
:members:
27053+
:show-inheritance:
27054+
27055+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_data\_type module
27056+
------------------------------------------------------------------------------
27057+
27058+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_data_type
27059+
:members:
27060+
:show-inheritance:
27061+
27062+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_test module
27063+
------------------------------------------------------------------------
27064+
27065+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_test
27066+
:members:
27067+
:show-inheritance:
27068+
27069+
datadog\_api\_client.v2.model.update\_flaky\_tests\_request\_test\_new\_state module
27070+
------------------------------------------------------------------------------------
27071+
27072+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_request_test_new_state
27073+
:members:
27074+
:show-inheritance:
27075+
27076+
datadog\_api\_client.v2.model.update\_flaky\_tests\_response module
27077+
-------------------------------------------------------------------
27078+
27079+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response
27080+
:members:
27081+
:show-inheritance:
27082+
27083+
datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_attributes module
27084+
-------------------------------------------------------------------------------
27085+
27086+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_attributes
27087+
:members:
27088+
:show-inheritance:
27089+
27090+
datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_data module
27091+
-------------------------------------------------------------------------
27092+
27093+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_data
27094+
:members:
27095+
:show-inheritance:
27096+
27097+
datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_data\_type module
27098+
-------------------------------------------------------------------------------
27099+
27100+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_data_type
27101+
:members:
27102+
:show-inheritance:
27103+
27104+
datadog\_api\_client.v2.model.update\_flaky\_tests\_response\_result module
27105+
---------------------------------------------------------------------------
27106+
27107+
.. automodule:: datadog_api_client.v2.model.update_flaky_tests_response_result
27108+
:members:
27109+
:show-inheritance:
27110+
2703427111
datadog\_api\_client.v2.model.update\_on\_call\_notification\_rule\_request module
2703527112
----------------------------------------------------------------------------------
2703627113

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Update flaky test states returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi
7+
from datadog_api_client.v2.model.update_flaky_tests_request import UpdateFlakyTestsRequest
8+
from datadog_api_client.v2.model.update_flaky_tests_request_attributes import UpdateFlakyTestsRequestAttributes
9+
from datadog_api_client.v2.model.update_flaky_tests_request_data import UpdateFlakyTestsRequestData
10+
from datadog_api_client.v2.model.update_flaky_tests_request_data_type import UpdateFlakyTestsRequestDataType
11+
from datadog_api_client.v2.model.update_flaky_tests_request_test import UpdateFlakyTestsRequestTest
12+
from datadog_api_client.v2.model.update_flaky_tests_request_test_new_state import UpdateFlakyTestsRequestTestNewState
13+
14+
body = UpdateFlakyTestsRequest(
15+
data=UpdateFlakyTestsRequestData(
16+
attributes=UpdateFlakyTestsRequestAttributes(
17+
tests=[
18+
UpdateFlakyTestsRequestTest(
19+
id="4eb1887a8adb1847",
20+
new_state=UpdateFlakyTestsRequestTestNewState.ACTIVE,
21+
),
22+
],
23+
),
24+
type=UpdateFlakyTestsRequestDataType.UPDATE_FLAKY_TEST_STATE_REQUEST,
25+
),
26+
)
27+
28+
configuration = Configuration()
29+
configuration.unstable_operations["update_flaky_tests"] = True
30+
with ApiClient(configuration) as api_client:
31+
api_instance = TestOptimizationApi(api_client)
32+
response = api_instance.update_flaky_tests(body=body)
33+
34+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def __init__(
413413
"v2.list_incident_teams": False,
414414
"v2.update_incident_team": False,
415415
"v2.search_flaky_tests": False,
416+
"v2.update_flaky_tests": False,
416417
}
417418
)
418419

src/datadog_api_client/v2/api/test_optimization_api.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
UnsetType,
1515
unset,
1616
)
17+
from datadog_api_client.v2.model.update_flaky_tests_response import UpdateFlakyTestsResponse
18+
from datadog_api_client.v2.model.update_flaky_tests_request import UpdateFlakyTestsRequest
1719
from datadog_api_client.v2.model.flaky_tests_search_response import FlakyTestsSearchResponse
1820
from datadog_api_client.v2.model.flaky_tests_search_request import FlakyTestsSearchRequest
1921
from datadog_api_client.v2.model.flaky_test import FlakyTest
@@ -48,6 +50,26 @@ def __init__(self, api_client=None):
4850
api_client=api_client,
4951
)
5052

53+
self._update_flaky_tests_endpoint = _Endpoint(
54+
settings={
55+
"response_type": (UpdateFlakyTestsResponse,),
56+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
57+
"endpoint_path": "/api/v2/test/flaky-test-management/tests",
58+
"operation_id": "update_flaky_tests",
59+
"http_method": "PATCH",
60+
"version": "v2",
61+
},
62+
params_map={
63+
"body": {
64+
"required": True,
65+
"openapi_types": (UpdateFlakyTestsRequest,),
66+
"location": "body",
67+
},
68+
},
69+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
70+
api_client=api_client,
71+
)
72+
5173
def search_flaky_tests(
5274
self,
5375
*,
@@ -96,3 +118,19 @@ def search_flaky_tests_with_pagination(
96118
"kwargs": kwargs,
97119
}
98120
return endpoint.call_with_http_info_paginated(pagination)
121+
122+
def update_flaky_tests(
123+
self,
124+
body: UpdateFlakyTestsRequest,
125+
) -> UpdateFlakyTestsResponse:
126+
"""Update flaky test states.
127+
128+
Update the state of multiple flaky tests in Flaky Test Management.
129+
130+
:type body: UpdateFlakyTestsRequest
131+
:rtype: UpdateFlakyTestsResponse
132+
"""
133+
kwargs: Dict[str, Any] = {}
134+
kwargs["body"] = body
135+
136+
return self._update_flaky_tests_endpoint.call_with_http_info(**kwargs)

0 commit comments

Comments
 (0)