Skip to content

Commit cf83efb

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

18 files changed

Lines changed: 1636 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.

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ func NewConfiguration() *Configuration {
819819
"v2.ListIncidentTeams": false,
820820
"v2.UpdateIncidentTeam": false,
821821
"v2.SearchFlakyTests": false,
822+
"v2.UpdateFlakyTests": false,
822823
},
823824
RetryConfiguration: RetryConfiguration{
824825
EnableRetry: false,

api/datadogV2/api_test_optimization.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,95 @@ func (a *TestOptimizationApi) SearchFlakyTestsWithPagination(ctx _context.Contex
203203
return items, cancel
204204
}
205205

206+
// UpdateFlakyTests Update flaky test states.
207+
// Update the state of multiple flaky tests in Flaky Test Management.
208+
func (a *TestOptimizationApi) UpdateFlakyTests(ctx _context.Context, body UpdateFlakyTestsRequest) (UpdateFlakyTestsResponse, *_nethttp.Response, error) {
209+
var (
210+
localVarHTTPMethod = _nethttp.MethodPatch
211+
localVarPostBody interface{}
212+
localVarReturnValue UpdateFlakyTestsResponse
213+
)
214+
215+
operationId := "v2.UpdateFlakyTests"
216+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
217+
if !isOperationEnabled {
218+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
219+
}
220+
if isOperationEnabled && a.Client.Cfg.Debug {
221+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
222+
}
223+
224+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.TestOptimizationApi.UpdateFlakyTests")
225+
if err != nil {
226+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
227+
}
228+
229+
localVarPath := localBasePath + "/api/v2/test/flaky-test-management/tests"
230+
231+
localVarHeaderParams := make(map[string]string)
232+
localVarQueryParams := _neturl.Values{}
233+
localVarFormParams := _neturl.Values{}
234+
localVarHeaderParams["Content-Type"] = "application/json"
235+
localVarHeaderParams["Accept"] = "application/json"
236+
237+
// body params
238+
localVarPostBody = &body
239+
if a.Client.Cfg.DelegatedTokenConfig != nil {
240+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
241+
if err != nil {
242+
return localVarReturnValue, nil, err
243+
}
244+
} else {
245+
datadog.SetAuthKeys(
246+
ctx,
247+
&localVarHeaderParams,
248+
[2]string{"apiKeyAuth", "DD-API-KEY"},
249+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
250+
)
251+
}
252+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
253+
if err != nil {
254+
return localVarReturnValue, nil, err
255+
}
256+
257+
localVarHTTPResponse, err := a.Client.CallAPI(req)
258+
if err != nil || localVarHTTPResponse == nil {
259+
return localVarReturnValue, localVarHTTPResponse, err
260+
}
261+
262+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
263+
if err != nil {
264+
return localVarReturnValue, localVarHTTPResponse, err
265+
}
266+
267+
if localVarHTTPResponse.StatusCode >= 300 {
268+
newErr := datadog.GenericOpenAPIError{
269+
ErrorBody: localVarBody,
270+
ErrorMessage: localVarHTTPResponse.Status,
271+
}
272+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
273+
var v APIErrorResponse
274+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
275+
if err != nil {
276+
return localVarReturnValue, localVarHTTPResponse, newErr
277+
}
278+
newErr.ErrorModel = v
279+
}
280+
return localVarReturnValue, localVarHTTPResponse, newErr
281+
}
282+
283+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
284+
if err != nil {
285+
newErr := datadog.GenericOpenAPIError{
286+
ErrorBody: localVarBody,
287+
ErrorMessage: err.Error(),
288+
}
289+
return localVarReturnValue, localVarHTTPResponse, newErr
290+
}
291+
292+
return localVarReturnValue, localVarHTTPResponse, nil
293+
}
294+
206295
// NewTestOptimizationApi Returns NewTestOptimizationApi.
207296
func NewTestOptimizationApi(client *datadog.APIClient) *TestOptimizationApi {
208297
return &TestOptimizationApi{

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@
738738
// - [TeamsApi.UpdateTeamNotificationRule]
739739
// - [TeamsApi.UpdateTeamPermissionSetting]
740740
// - [TestOptimizationApi.SearchFlakyTests]
741+
// - [TestOptimizationApi.UpdateFlakyTests]
741742
// - [UsageMeteringApi.GetActiveBillingDimensions]
742743
// - [UsageMeteringApi.GetBillingDimensionMapping]
743744
// - [UsageMeteringApi.GetCostByOrg]

0 commit comments

Comments
 (0)