Skip to content

Commit a3ef6f3

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Document /api/v2/roles/templates (#3170)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent e28a28e commit a3ef6f3

File tree

10 files changed

+808
-0
lines changed

10 files changed

+808
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38435,6 +38435,49 @@ components:
3843538435
permissions:
3843638436
$ref: '#/components/schemas/RelationshipToPermissions'
3843738437
type: object
38438+
RoleTemplateArray:
38439+
description: The definition of `RoleTemplateArray` object.
38440+
properties:
38441+
data:
38442+
description: The `RoleTemplateArray` `data`.
38443+
items:
38444+
$ref: '#/components/schemas/RoleTemplateData'
38445+
type: array
38446+
required:
38447+
- data
38448+
type: object
38449+
RoleTemplateData:
38450+
description: The definition of `RoleTemplateData` object.
38451+
properties:
38452+
attributes:
38453+
$ref: '#/components/schemas/RoleTemplateDataAttributes'
38454+
id:
38455+
description: The `RoleTemplateData` `id`.
38456+
type: string
38457+
type:
38458+
$ref: '#/components/schemas/RoleTemplateDataType'
38459+
required:
38460+
- type
38461+
type: object
38462+
RoleTemplateDataAttributes:
38463+
description: The definition of `RoleTemplateDataAttributes` object.
38464+
properties:
38465+
description:
38466+
description: The `attributes` `description`.
38467+
type: string
38468+
name:
38469+
description: The `attributes` `name`.
38470+
type: string
38471+
type: object
38472+
RoleTemplateDataType:
38473+
default: roles
38474+
description: Roles resource type.
38475+
enum:
38476+
- roles
38477+
example: roles
38478+
type: string
38479+
x-enum-varnames:
38480+
- ROLES
3843838481
RoleUpdateAttributes:
3843938482
description: Attributes of the role.
3844038483
properties:
@@ -67658,6 +67701,28 @@ paths:
6765867701
operator: OR
6765967702
permissions:
6766067703
- user_access_manage
67704+
/api/v2/roles/templates:
67705+
get:
67706+
description: List all role templates
67707+
operationId: ListRoleTemplates
67708+
responses:
67709+
'200':
67710+
content:
67711+
application/json:
67712+
schema:
67713+
$ref: '#/components/schemas/RoleTemplateArray'
67714+
description: OK
67715+
'429':
67716+
$ref: '#/components/responses/TooManyRequestsResponse'
67717+
security:
67718+
- apiKeyAuth: []
67719+
appKeyAuth: []
67720+
- AuthZ:
67721+
- user_access_read
67722+
summary: List role templates
67723+
tags:
67724+
- Roles
67725+
x-unstable: '**Note**: This endpoint may be subject to changes.'
6766167726
/api/v2/roles/{role_id}:
6766267727
delete:
6766367728
description: Disables a role.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// List role templates 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.RolesApi;
6+
import com.datadog.api.client.v2.model.RoleTemplateArray;
7+
8+
public class Example {
9+
public static void main(String[] args) {
10+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
11+
defaultClient.setUnstableOperationEnabled("v2.listRoleTemplates", true);
12+
RolesApi apiInstance = new RolesApi(defaultClient);
13+
14+
try {
15+
RoleTemplateArray result = apiInstance.listRoleTemplates();
16+
System.out.println(result);
17+
} catch (ApiException e) {
18+
System.err.println("Exception when calling RolesApi#listRoleTemplates");
19+
System.err.println("Status code: " + e.getCode());
20+
System.err.println("Reason: " + e.getResponseBody());
21+
System.err.println("Response headers: " + e.getResponseHeaders());
22+
e.printStackTrace();
23+
}
24+
}
25+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ public class ApiClient {
761761
put("v2.updateMonitorUserTemplate", false);
762762
put("v2.validateExistingMonitorUserTemplate", false);
763763
put("v2.validateMonitorUserTemplate", false);
764+
put("v2.listRoleTemplates", false);
764765
put("v2.createPipeline", false);
765766
put("v2.deletePipeline", false);
766767
put("v2.getPipeline", false);

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

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.datadog.api.client.v2.model.RoleCreateRequest;
1212
import com.datadog.api.client.v2.model.RoleCreateResponse;
1313
import com.datadog.api.client.v2.model.RoleResponse;
14+
import com.datadog.api.client.v2.model.RoleTemplateArray;
1415
import com.datadog.api.client.v2.model.RoleUpdateRequest;
1516
import com.datadog.api.client.v2.model.RoleUpdateResponse;
1617
import com.datadog.api.client.v2.model.RolesResponse;
@@ -1389,6 +1390,131 @@ public CompletableFuture<ApiResponse<RolesResponse>> listRolesWithHttpInfoAsync(
13891390
new GenericType<RolesResponse>() {});
13901391
}
13911392

1393+
/**
1394+
* List role templates.
1395+
*
1396+
* <p>See {@link #listRoleTemplatesWithHttpInfo}.
1397+
*
1398+
* @return RoleTemplateArray
1399+
* @throws ApiException if fails to make API call
1400+
*/
1401+
public RoleTemplateArray listRoleTemplates() throws ApiException {
1402+
return listRoleTemplatesWithHttpInfo().getData();
1403+
}
1404+
1405+
/**
1406+
* List role templates.
1407+
*
1408+
* <p>See {@link #listRoleTemplatesWithHttpInfoAsync}.
1409+
*
1410+
* @return CompletableFuture&lt;RoleTemplateArray&gt;
1411+
*/
1412+
public CompletableFuture<RoleTemplateArray> listRoleTemplatesAsync() {
1413+
return listRoleTemplatesWithHttpInfoAsync()
1414+
.thenApply(
1415+
response -> {
1416+
return response.getData();
1417+
});
1418+
}
1419+
1420+
/**
1421+
* List all role templates
1422+
*
1423+
* @return ApiResponse&lt;RoleTemplateArray&gt;
1424+
* @throws ApiException if fails to make API call
1425+
* @http.response.details
1426+
* <table border="1">
1427+
* <caption>Response details</caption>
1428+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
1429+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
1430+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
1431+
* </table>
1432+
*/
1433+
public ApiResponse<RoleTemplateArray> listRoleTemplatesWithHttpInfo() throws ApiException {
1434+
// Check if unstable operation is enabled
1435+
String operationId = "listRoleTemplates";
1436+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
1437+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
1438+
} else {
1439+
throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
1440+
}
1441+
Object localVarPostBody = null;
1442+
// create path and map variables
1443+
String localVarPath = "/api/v2/roles/templates";
1444+
1445+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1446+
1447+
Invocation.Builder builder =
1448+
apiClient.createBuilder(
1449+
"v2.RolesApi.listRoleTemplates",
1450+
localVarPath,
1451+
new ArrayList<Pair>(),
1452+
localVarHeaderParams,
1453+
new HashMap<String, String>(),
1454+
new String[] {"application/json"},
1455+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
1456+
return apiClient.invokeAPI(
1457+
"GET",
1458+
builder,
1459+
localVarHeaderParams,
1460+
new String[] {},
1461+
localVarPostBody,
1462+
new HashMap<String, Object>(),
1463+
false,
1464+
new GenericType<RoleTemplateArray>() {});
1465+
}
1466+
1467+
/**
1468+
* List role templates.
1469+
*
1470+
* <p>See {@link #listRoleTemplatesWithHttpInfo}.
1471+
*
1472+
* @return CompletableFuture&lt;ApiResponse&lt;RoleTemplateArray&gt;&gt;
1473+
*/
1474+
public CompletableFuture<ApiResponse<RoleTemplateArray>> listRoleTemplatesWithHttpInfoAsync() {
1475+
// Check if unstable operation is enabled
1476+
String operationId = "listRoleTemplates";
1477+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
1478+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
1479+
} else {
1480+
CompletableFuture<ApiResponse<RoleTemplateArray>> result = new CompletableFuture<>();
1481+
result.completeExceptionally(
1482+
new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
1483+
return result;
1484+
}
1485+
Object localVarPostBody = null;
1486+
// create path and map variables
1487+
String localVarPath = "/api/v2/roles/templates";
1488+
1489+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1490+
1491+
Invocation.Builder builder;
1492+
try {
1493+
builder =
1494+
apiClient.createBuilder(
1495+
"v2.RolesApi.listRoleTemplates",
1496+
localVarPath,
1497+
new ArrayList<Pair>(),
1498+
localVarHeaderParams,
1499+
new HashMap<String, String>(),
1500+
new String[] {"application/json"},
1501+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
1502+
} catch (ApiException ex) {
1503+
CompletableFuture<ApiResponse<RoleTemplateArray>> result = new CompletableFuture<>();
1504+
result.completeExceptionally(ex);
1505+
return result;
1506+
}
1507+
return apiClient.invokeAPIAsync(
1508+
"GET",
1509+
builder,
1510+
localVarHeaderParams,
1511+
new String[] {},
1512+
localVarPostBody,
1513+
new HashMap<String, Object>(),
1514+
false,
1515+
new GenericType<RoleTemplateArray>() {});
1516+
}
1517+
13921518
/** Manage optional parameters to listRoleUsers. */
13931519
public static class ListRoleUsersOptionalParameters {
13941520
private Long pageSize;

0 commit comments

Comments
 (0)