Skip to content

Commit bc54c5b

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

17 files changed

+1977
-7
lines changed

.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.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Update flaky test states returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.TestOptimizationApi;
6+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequest;
7+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequestAttributes;
8+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequestData;
9+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequestDataType;
10+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequestTest;
11+
import com.datadog.api.client.v2.model.UpdateFlakyTestsRequestTestNewState;
12+
import com.datadog.api.client.v2.model.UpdateFlakyTestsResponse;
13+
import java.util.Collections;
14+
15+
public class Example {
16+
public static void main(String[] args) {
17+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
18+
defaultClient.setUnstableOperationEnabled("v2.updateFlakyTests", true);
19+
TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient);
20+
21+
UpdateFlakyTestsRequest body =
22+
new UpdateFlakyTestsRequest()
23+
.data(
24+
new UpdateFlakyTestsRequestData()
25+
.attributes(
26+
new UpdateFlakyTestsRequestAttributes()
27+
.tests(
28+
Collections.singletonList(
29+
new UpdateFlakyTestsRequestTest()
30+
.id("4eb1887a8adb1847")
31+
.newState(UpdateFlakyTestsRequestTestNewState.ACTIVE))))
32+
.type(UpdateFlakyTestsRequestDataType.UPDATE_FLAKY_TEST_STATE_REQUEST));
33+
34+
try {
35+
UpdateFlakyTestsResponse result = apiInstance.updateFlakyTests(body);
36+
System.out.println(result);
37+
} catch (ApiException e) {
38+
System.err.println("Exception when calling TestOptimizationApi#updateFlakyTests");
39+
System.err.println("Status code: " + e.getCode());
40+
System.err.println("Reason: " + e.getResponseBody());
41+
System.err.println("Response headers: " + e.getResponseHeaders());
42+
e.printStackTrace();
43+
}
44+
}
45+
}

src/main/java/com/datadog/api/client/ApiClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ public class ApiClient {
922922
put("v2.listIncidentTeams", false);
923923
put("v2.updateIncidentTeam", false);
924924
put("v2.searchFlakyTests", false);
925+
put("v2.updateFlakyTests", false);
925926
}
926927
};
927928
protected static final java.util.logging.Logger logger =

0 commit comments

Comments
 (0)