Skip to content

Commit c66c672

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Adds async Scorecard outcomes batch update endpoint (#3061)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 53dd9de commit c66c672

25 files changed

+1489
-5
lines changed

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "62a19e4",
3-
"generated": "2025-08-27 15:03:03.841"
2+
"spec_repo_commit": "6d9663b",
3+
"generated": "2025-08-27 16:39:35.815"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14485,6 +14485,10 @@ components:
1448514485
description: Entity definition in raw JSON or YAML representation.
1448614486
example: "apiVersion: v3\nkind: service\nmetadata:\n name: myservice\n"
1448714487
type: string
14488+
EntityReference:
14489+
description: The unique reference for an IDP entity.
14490+
example: service:my-service
14491+
type: string
1448814492
EntityRelationships:
1448914493
description: Entity relationships.
1449014494
properties:
@@ -34444,6 +34448,8 @@ components:
3444434448
description: If enabled, the rule is calculated as part of the score.
3444534449
example: true
3444634450
type: boolean
34451+
level:
34452+
$ref: '#/components/schemas/RuleLevel'
3444734453
modified_at:
3444834454
description: Time of the last rule outcome modification.
3444934455
format: date-time
@@ -34464,6 +34470,13 @@ components:
3446434470
description: The unique ID for a scorecard rule.
3446534471
example: q8MQxk8TCqrHnWkx
3446634472
type: string
34473+
RuleLevel:
34474+
description: The maturity level of the rule (1, 2, or 3).
34475+
example: 2
34476+
format: int32
34477+
maximum: 3
34478+
minimum: 1
34479+
type: integer
3446734480
RuleName:
3446834481
description: Name of the notification rule.
3446934482
example: Rule 1
@@ -43835,6 +43848,57 @@ components:
4383543848
id:
4383643849
$ref: '#/components/schemas/ApiID'
4383743850
type: object
43851+
UpdateOutcomesAsyncAttributes:
43852+
description: The JSON:API attributes for a batched set of scorecard outcomes.
43853+
properties:
43854+
results:
43855+
description: Set of scorecard outcomes to update asynchronously.
43856+
items:
43857+
$ref: '#/components/schemas/UpdateOutcomesAsyncRequestItem'
43858+
type: array
43859+
type: object
43860+
UpdateOutcomesAsyncRequest:
43861+
description: Scorecard outcomes batch request.
43862+
properties:
43863+
data:
43864+
$ref: '#/components/schemas/UpdateOutcomesAsyncRequestData'
43865+
type: object
43866+
UpdateOutcomesAsyncRequestData:
43867+
description: Scorecard outcomes batch request data.
43868+
properties:
43869+
attributes:
43870+
$ref: '#/components/schemas/UpdateOutcomesAsyncAttributes'
43871+
type:
43872+
$ref: '#/components/schemas/UpdateOutcomesAsyncType'
43873+
type: object
43874+
UpdateOutcomesAsyncRequestItem:
43875+
description: Scorecard outcome for a single entity and rule.
43876+
properties:
43877+
entity_reference:
43878+
$ref: '#/components/schemas/EntityReference'
43879+
remarks:
43880+
description: Any remarks regarding the scorecard rule's evaluation. Supports
43881+
HTML hyperlinks.
43882+
example: 'See: <a href="https://app.datadoghq.com/services">Services</a>'
43883+
type: string
43884+
rule_id:
43885+
$ref: '#/components/schemas/RuleId'
43886+
state:
43887+
$ref: '#/components/schemas/State'
43888+
required:
43889+
- rule_id
43890+
- entity_reference
43891+
- state
43892+
type: object
43893+
UpdateOutcomesAsyncType:
43894+
default: batched-outcome
43895+
description: The JSON:API type for scorecard outcomes.
43896+
enum:
43897+
- batched-outcome
43898+
example: batched-outcome
43899+
type: string
43900+
x-enum-varnames:
43901+
- BATCHED_OUTCOME
4383843902
UpdateResourceEvaluationFiltersRequest:
4383943903
description: Request object to update a resource filter.
4384043904
properties:
@@ -61882,6 +61946,39 @@ paths:
6188261946
resultsPath: data
6188361947
x-unstable: '**Note**: This endpoint is in public beta.
6188461948

61949+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
61950+
post:
61951+
description: Updates multiple scorecard rule outcomes in a single batched request.
61952+
operationId: UpdateScorecardOutcomesAsync
61953+
requestBody:
61954+
content:
61955+
application/json:
61956+
schema:
61957+
$ref: '#/components/schemas/UpdateOutcomesAsyncRequest'
61958+
description: Set of scorecard outcomes.
61959+
required: true
61960+
responses:
61961+
'202':
61962+
description: Accepted
61963+
'400':
61964+
$ref: '#/components/responses/BadRequestResponse'
61965+
'403':
61966+
$ref: '#/components/responses/ForbiddenResponse'
61967+
'409':
61968+
$ref: '#/components/responses/ConflictResponse'
61969+
'429':
61970+
$ref: '#/components/responses/TooManyRequestsResponse'
61971+
security:
61972+
- apiKeyAuth: []
61973+
appKeyAuth: []
61974+
- AuthZ:
61975+
- apm_service_catalog_write
61976+
summary: Update Scorecard outcomes asynchronously
61977+
tags:
61978+
- Service Scorecards
61979+
x-codegen-request-body-name: body
61980+
x-unstable: '**Note**: This endpoint is in public beta.
61981+
6188561982
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6188661983
/api/v2/scorecard/outcomes/batch:
6188761984
post:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Update Scorecard outcomes asynchronously returns "Accepted" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.ServiceScorecardsApi;
6+
import com.datadog.api.client.v2.model.State;
7+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncAttributes;
8+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequest;
9+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequestData;
10+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequestItem;
11+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncType;
12+
import java.util.Collections;
13+
14+
public class Example {
15+
public static void main(String[] args) {
16+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
17+
defaultClient.setUnstableOperationEnabled("v2.updateScorecardOutcomesAsync", true);
18+
ServiceScorecardsApi apiInstance = new ServiceScorecardsApi(defaultClient);
19+
20+
// there is a valid "create_scorecard_rule" in the system
21+
String CREATE_SCORECARD_RULE_DATA_ID = System.getenv("CREATE_SCORECARD_RULE_DATA_ID");
22+
23+
UpdateOutcomesAsyncRequest body =
24+
new UpdateOutcomesAsyncRequest()
25+
.data(
26+
new UpdateOutcomesAsyncRequestData()
27+
.attributes(
28+
new UpdateOutcomesAsyncAttributes()
29+
.results(
30+
Collections.singletonList(
31+
new UpdateOutcomesAsyncRequestItem()
32+
.ruleId(CREATE_SCORECARD_RULE_DATA_ID)
33+
.entityReference("service:my-service")
34+
.remarks(
35+
"""
36+
See: <a href="https://app.datadoghq.com/services">Services</a>
37+
""")
38+
.state(State.PASS))))
39+
.type(UpdateOutcomesAsyncType.BATCHED_OUTCOME));
40+
41+
try {
42+
apiInstance.updateScorecardOutcomesAsync(body);
43+
} catch (ApiException e) {
44+
System.err.println(
45+
"Exception when calling ServiceScorecardsApi#updateScorecardOutcomesAsync");
46+
System.err.println("Status code: " + e.getCode());
47+
System.err.println("Reason: " + e.getResponseBody());
48+
System.err.println("Response headers: " + e.getResponseHeaders());
49+
e.printStackTrace();
50+
}
51+
}
52+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ public class ApiClient {
763763
put("v2.deleteScorecardRule", false);
764764
put("v2.listScorecardOutcomes", false);
765765
put("v2.listScorecardRules", false);
766+
put("v2.updateScorecardOutcomesAsync", false);
766767
put("v2.updateScorecardRule", false);
767768
put("v2.createIncidentService", false);
768769
put("v2.deleteIncidentService", false);

src/main/java/com/datadog/api/client/v2/api/ServiceScorecardsApi.java

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.datadog.api.client.v2.model.OutcomesBatchResponse;
1414
import com.datadog.api.client.v2.model.OutcomesResponse;
1515
import com.datadog.api.client.v2.model.OutcomesResponseDataItem;
16+
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequest;
1617
import com.datadog.api.client.v2.model.UpdateRuleRequest;
1718
import com.datadog.api.client.v2.model.UpdateRuleResponse;
1819
import jakarta.ws.rs.client.Invocation;
@@ -1295,6 +1296,156 @@ public CompletableFuture<ApiResponse<ListRulesResponse>> listScorecardRulesWithH
12951296
new GenericType<ListRulesResponse>() {});
12961297
}
12971298

1299+
/**
1300+
* Update Scorecard outcomes asynchronously.
1301+
*
1302+
* <p>See {@link #updateScorecardOutcomesAsyncWithHttpInfo}.
1303+
*
1304+
* @param body Set of scorecard outcomes. (required)
1305+
* @throws ApiException if fails to make API call
1306+
*/
1307+
public void updateScorecardOutcomesAsync(UpdateOutcomesAsyncRequest body) throws ApiException {
1308+
updateScorecardOutcomesAsyncWithHttpInfo(body);
1309+
}
1310+
1311+
/**
1312+
* Update Scorecard outcomes asynchronously.
1313+
*
1314+
* <p>See {@link #updateScorecardOutcomesAsyncWithHttpInfoAsync}.
1315+
*
1316+
* @param body Set of scorecard outcomes. (required)
1317+
* @return CompletableFuture
1318+
*/
1319+
public CompletableFuture<Void> updateScorecardOutcomesAsyncAsync(
1320+
UpdateOutcomesAsyncRequest body) {
1321+
return updateScorecardOutcomesAsyncWithHttpInfoAsync(body)
1322+
.thenApply(
1323+
response -> {
1324+
return response.getData();
1325+
});
1326+
}
1327+
1328+
/**
1329+
* Updates multiple scorecard rule outcomes in a single batched request.
1330+
*
1331+
* @param body Set of scorecard outcomes. (required)
1332+
* @return ApiResponse&lt;Void&gt;
1333+
* @throws ApiException if fails to make API call
1334+
* @http.response.details
1335+
* <table border="1">
1336+
* <caption>Response details</caption>
1337+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
1338+
* <tr><td> 202 </td><td> Accepted </td><td> - </td></tr>
1339+
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
1340+
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
1341+
* <tr><td> 409 </td><td> Conflict </td><td> - </td></tr>
1342+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
1343+
* </table>
1344+
*/
1345+
public ApiResponse<Void> updateScorecardOutcomesAsyncWithHttpInfo(UpdateOutcomesAsyncRequest body)
1346+
throws ApiException {
1347+
// Check if unstable operation is enabled
1348+
String operationId = "updateScorecardOutcomesAsync";
1349+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
1350+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
1351+
} else {
1352+
throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
1353+
}
1354+
Object localVarPostBody = body;
1355+
1356+
// verify the required parameter 'body' is set
1357+
if (body == null) {
1358+
throw new ApiException(
1359+
400, "Missing the required parameter 'body' when calling updateScorecardOutcomesAsync");
1360+
}
1361+
// create path and map variables
1362+
String localVarPath = "/api/v2/scorecard/outcomes";
1363+
1364+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1365+
1366+
Invocation.Builder builder =
1367+
apiClient.createBuilder(
1368+
"v2.ServiceScorecardsApi.updateScorecardOutcomesAsync",
1369+
localVarPath,
1370+
new ArrayList<Pair>(),
1371+
localVarHeaderParams,
1372+
new HashMap<String, String>(),
1373+
new String[] {"*/*"},
1374+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
1375+
return apiClient.invokeAPI(
1376+
"POST",
1377+
builder,
1378+
localVarHeaderParams,
1379+
new String[] {"application/json"},
1380+
localVarPostBody,
1381+
new HashMap<String, Object>(),
1382+
false,
1383+
null);
1384+
}
1385+
1386+
/**
1387+
* Update Scorecard outcomes asynchronously.
1388+
*
1389+
* <p>See {@link #updateScorecardOutcomesAsyncWithHttpInfo}.
1390+
*
1391+
* @param body Set of scorecard outcomes. (required)
1392+
* @return CompletableFuture&lt;ApiResponse&lt;Void&gt;&gt;
1393+
*/
1394+
public CompletableFuture<ApiResponse<Void>> updateScorecardOutcomesAsyncWithHttpInfoAsync(
1395+
UpdateOutcomesAsyncRequest body) {
1396+
// Check if unstable operation is enabled
1397+
String operationId = "updateScorecardOutcomesAsync";
1398+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
1399+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
1400+
} else {
1401+
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
1402+
result.completeExceptionally(
1403+
new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
1404+
return result;
1405+
}
1406+
Object localVarPostBody = body;
1407+
1408+
// verify the required parameter 'body' is set
1409+
if (body == null) {
1410+
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
1411+
result.completeExceptionally(
1412+
new ApiException(
1413+
400,
1414+
"Missing the required parameter 'body' when calling updateScorecardOutcomesAsync"));
1415+
return result;
1416+
}
1417+
// create path and map variables
1418+
String localVarPath = "/api/v2/scorecard/outcomes";
1419+
1420+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1421+
1422+
Invocation.Builder builder;
1423+
try {
1424+
builder =
1425+
apiClient.createBuilder(
1426+
"v2.ServiceScorecardsApi.updateScorecardOutcomesAsync",
1427+
localVarPath,
1428+
new ArrayList<Pair>(),
1429+
localVarHeaderParams,
1430+
new HashMap<String, String>(),
1431+
new String[] {"*/*"},
1432+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
1433+
} catch (ApiException ex) {
1434+
CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>();
1435+
result.completeExceptionally(ex);
1436+
return result;
1437+
}
1438+
return apiClient.invokeAPIAsync(
1439+
"POST",
1440+
builder,
1441+
localVarHeaderParams,
1442+
new String[] {"application/json"},
1443+
localVarPostBody,
1444+
new HashMap<String, Object>(),
1445+
false,
1446+
null);
1447+
}
1448+
12981449
/**
12991450
* Update an existing rule.
13001451
*

0 commit comments

Comments
 (0)