Skip to content

Commit 38a04fd

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Support provisioning teams from external sources (#3252)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 2809020 commit 38a04fd

File tree

12 files changed

+613
-18
lines changed

12 files changed

+613
-18
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52263,14 +52263,31 @@ components:
5226352263
TeamSyncAttributes:
5226452264
description: Team sync attributes.
5226552265
properties:
52266+
frequency:
52267+
$ref: '#/components/schemas/TeamSyncAttributesFrequency'
5226652268
source:
5226752269
$ref: '#/components/schemas/TeamSyncAttributesSource'
52270+
sync_membership:
52271+
$ref: '#/components/schemas/TeamSyncAttributesSyncMembership'
5226852272
type:
5226952273
$ref: '#/components/schemas/TeamSyncAttributesType'
5227052274
required:
5227152275
- source
5227252276
- type
5227352277
type: object
52278+
TeamSyncAttributesFrequency:
52279+
description: How often the sync process should be run. Defaults to `once` when
52280+
not provided.
52281+
enum:
52282+
- once
52283+
- continuously
52284+
- paused
52285+
example: once
52286+
type: string
52287+
x-enum-varnames:
52288+
- ONCE
52289+
- CONTINUOUSLY
52290+
- PAUSED
5227452291
TeamSyncAttributesSource:
5227552292
description: The external source platform for team synchronization. Only "github"
5227652293
is supported.
@@ -52280,15 +52297,22 @@ components:
5228052297
type: string
5228152298
x-enum-varnames:
5228252299
- GITHUB
52300+
TeamSyncAttributesSyncMembership:
52301+
description: Whether to sync members from the external team to the Datadog team.
52302+
Defaults to `false` when not provided.
52303+
example: true
52304+
type: boolean
5228352305
TeamSyncAttributesType:
52284-
description: The type of synchronization operation. Only "link" is supported,
52285-
which links existing teams by matching names.
52306+
description: The type of synchronization operation. "link" connects teams by
52307+
matching names. "provision" creates new teams when no match is found.
5228652308
enum:
5228752309
- link
52310+
- provision
5228852311
example: link
5228952312
type: string
5229052313
x-enum-varnames:
5229152314
- LINK
52315+
- PROVISION
5229252316
TeamSyncBulkType:
5229352317
description: Team sync bulk type.
5229452318
enum:
@@ -52298,10 +52322,15 @@ components:
5229852322
x-enum-varnames:
5229952323
- TEAM_SYNC_BULK
5230052324
TeamSyncData:
52301-
description: Team sync data.
52325+
description: A configuration governing syncing between Datadog teams and teams
52326+
from an external system.
5230252327
properties:
5230352328
attributes:
5230452329
$ref: '#/components/schemas/TeamSyncAttributes'
52330+
id:
52331+
description: The sync's identifier
52332+
example: aeadc05e-98a8-11ec-ac2c-da7ad0900001
52333+
type: string
5230552334
type:
5230652335
$ref: '#/components/schemas/TeamSyncBulkType'
5230752336
required:
@@ -52322,6 +52351,15 @@ components:
5232252351
required:
5232352352
- data
5232452353
type: object
52354+
TeamSyncResponse:
52355+
description: Team sync configurations response.
52356+
properties:
52357+
data:
52358+
description: List of team sync configurations
52359+
items:
52360+
$ref: '#/components/schemas/TeamSyncData'
52361+
type: array
52362+
type: object
5232552363
TeamTarget:
5232652364
description: Represents a team target for an escalation policy step, including
5232752365
the team's ID and resource type.
@@ -81182,6 +81220,52 @@ paths:
8118281220

8118381221
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
8118481222
/api/v2/team/sync:
81223+
get:
81224+
description: 'Get all team synchronization configurations.
81225+
81226+
Returns a list of configurations used for linking or provisioning teams with
81227+
external sources like GitHub.'
81228+
operationId: GetTeamSync
81229+
parameters:
81230+
- description: Filter by the external source platform for team synchronization
81231+
in: query
81232+
name: filter[source]
81233+
required: true
81234+
schema:
81235+
$ref: '#/components/schemas/TeamSyncAttributesSource'
81236+
responses:
81237+
'200':
81238+
content:
81239+
application/json:
81240+
schema:
81241+
$ref: '#/components/schemas/TeamSyncResponse'
81242+
description: OK
81243+
'403':
81244+
$ref: '#/components/responses/ForbiddenResponse'
81245+
'404':
81246+
content:
81247+
application/json:
81248+
schema:
81249+
$ref: '#/components/schemas/APIErrorResponse'
81250+
description: Team sync configurations not found
81251+
'429':
81252+
$ref: '#/components/responses/TooManyRequestsResponse'
81253+
security:
81254+
- apiKeyAuth: []
81255+
appKeyAuth: []
81256+
- AuthZ:
81257+
- teams_read
81258+
summary: Get team sync configurations
81259+
tags:
81260+
- Teams
81261+
x-permission:
81262+
operator: OR
81263+
permissions:
81264+
- teams_read
81265+
x-unstable: '**Note**: This endpoint is in Preview. To request access, fill
81266+
out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/).
81267+
81268+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
8118581269
post:
8118681270
description: 'This endpoint attempts to link your existing Datadog teams with
8118781271
GitHub teams by matching their names.
@@ -81208,7 +81292,8 @@ paths:
8120881292
using a normalized exact match; case is ignored and spaces are removed. No
8120981293
modifications are made
8121081294

81211-
to teams in GitHub. This will not create new Teams in Datadog.'
81295+
to teams in GitHub. This only creates new teams in Datadog when type is set
81296+
to `provision`.'
8121281297
operationId: SyncTeams
8121381298
requestBody:
8121481299
content:

examples/v2/teams/GetTeamSync.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Get team sync configurations 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.TeamsApi;
6+
import com.datadog.api.client.v2.model.TeamSyncAttributesSource;
7+
import com.datadog.api.client.v2.model.TeamSyncResponse;
8+
9+
public class Example {
10+
public static void main(String[] args) {
11+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
12+
defaultClient.setUnstableOperationEnabled("v2.getTeamSync", true);
13+
TeamsApi apiInstance = new TeamsApi(defaultClient);
14+
15+
try {
16+
TeamSyncResponse result = apiInstance.getTeamSync(TeamSyncAttributesSource.GITHUB);
17+
System.out.println(result);
18+
} catch (ApiException e) {
19+
System.err.println("Exception when calling TeamsApi#getTeamSync");
20+
System.err.println("Status code: " + e.getCode());
21+
System.err.println("Reason: " + e.getResponseBody());
22+
System.err.println("Response headers: " + e.getResponseHeaders());
23+
e.printStackTrace();
24+
}
25+
}
26+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ public class ApiClient {
812812
put("v2.createSCAResolveVulnerableSymbols", false);
813813
put("v2.createSCAResult", false);
814814
put("v2.addMemberTeam", false);
815+
put("v2.getTeamSync", false);
815816
put("v2.listMemberTeams", false);
816817
put("v2.removeMemberTeam", false);
817818
put("v2.syncTeams", false);

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

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import com.datadog.api.client.v2.model.TeamPermissionSettingUpdateRequest;
1919
import com.datadog.api.client.v2.model.TeamPermissionSettingsResponse;
2020
import com.datadog.api.client.v2.model.TeamResponse;
21+
import com.datadog.api.client.v2.model.TeamSyncAttributesSource;
2122
import com.datadog.api.client.v2.model.TeamSyncRequest;
23+
import com.datadog.api.client.v2.model.TeamSyncResponse;
2224
import com.datadog.api.client.v2.model.TeamUpdateRequest;
2325
import com.datadog.api.client.v2.model.TeamsField;
2426
import com.datadog.api.client.v2.model.TeamsResponse;
@@ -1987,6 +1989,162 @@ public ApiResponse<TeamPermissionSettingsResponse> getTeamPermissionSettingsWith
19871989
new GenericType<TeamPermissionSettingsResponse>() {});
19881990
}
19891991

1992+
/**
1993+
* Get team sync configurations.
1994+
*
1995+
* <p>See {@link #getTeamSyncWithHttpInfo}.
1996+
*
1997+
* @param filterSource Filter by the external source platform for team synchronization (required)
1998+
* @return TeamSyncResponse
1999+
* @throws ApiException if fails to make API call
2000+
*/
2001+
public TeamSyncResponse getTeamSync(TeamSyncAttributesSource filterSource) throws ApiException {
2002+
return getTeamSyncWithHttpInfo(filterSource).getData();
2003+
}
2004+
2005+
/**
2006+
* Get team sync configurations.
2007+
*
2008+
* <p>See {@link #getTeamSyncWithHttpInfoAsync}.
2009+
*
2010+
* @param filterSource Filter by the external source platform for team synchronization (required)
2011+
* @return CompletableFuture&lt;TeamSyncResponse&gt;
2012+
*/
2013+
public CompletableFuture<TeamSyncResponse> getTeamSyncAsync(
2014+
TeamSyncAttributesSource filterSource) {
2015+
return getTeamSyncWithHttpInfoAsync(filterSource)
2016+
.thenApply(
2017+
response -> {
2018+
return response.getData();
2019+
});
2020+
}
2021+
2022+
/**
2023+
* Get all team synchronization configurations. Returns a list of configurations used for linking
2024+
* or provisioning teams with external sources like GitHub.
2025+
*
2026+
* @param filterSource Filter by the external source platform for team synchronization (required)
2027+
* @return ApiResponse&lt;TeamSyncResponse&gt;
2028+
* @throws ApiException if fails to make API call
2029+
* @http.response.details
2030+
* <table border="1">
2031+
* <caption>Response details</caption>
2032+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
2033+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
2034+
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
2035+
* <tr><td> 404 </td><td> Team sync configurations not found </td><td> - </td></tr>
2036+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
2037+
* </table>
2038+
*/
2039+
public ApiResponse<TeamSyncResponse> getTeamSyncWithHttpInfo(
2040+
TeamSyncAttributesSource filterSource) throws ApiException {
2041+
// Check if unstable operation is enabled
2042+
String operationId = "getTeamSync";
2043+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
2044+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
2045+
} else {
2046+
throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
2047+
}
2048+
Object localVarPostBody = null;
2049+
2050+
// verify the required parameter 'filterSource' is set
2051+
if (filterSource == null) {
2052+
throw new ApiException(
2053+
400, "Missing the required parameter 'filterSource' when calling getTeamSync");
2054+
}
2055+
// create path and map variables
2056+
String localVarPath = "/api/v2/team/sync";
2057+
2058+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
2059+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
2060+
2061+
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[source]", filterSource));
2062+
2063+
Invocation.Builder builder =
2064+
apiClient.createBuilder(
2065+
"v2.TeamsApi.getTeamSync",
2066+
localVarPath,
2067+
localVarQueryParams,
2068+
localVarHeaderParams,
2069+
new HashMap<String, String>(),
2070+
new String[] {"application/json"},
2071+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
2072+
return apiClient.invokeAPI(
2073+
"GET",
2074+
builder,
2075+
localVarHeaderParams,
2076+
new String[] {},
2077+
localVarPostBody,
2078+
new HashMap<String, Object>(),
2079+
false,
2080+
new GenericType<TeamSyncResponse>() {});
2081+
}
2082+
2083+
/**
2084+
* Get team sync configurations.
2085+
*
2086+
* <p>See {@link #getTeamSyncWithHttpInfo}.
2087+
*
2088+
* @param filterSource Filter by the external source platform for team synchronization (required)
2089+
* @return CompletableFuture&lt;ApiResponse&lt;TeamSyncResponse&gt;&gt;
2090+
*/
2091+
public CompletableFuture<ApiResponse<TeamSyncResponse>> getTeamSyncWithHttpInfoAsync(
2092+
TeamSyncAttributesSource filterSource) {
2093+
// Check if unstable operation is enabled
2094+
String operationId = "getTeamSync";
2095+
if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
2096+
apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
2097+
} else {
2098+
CompletableFuture<ApiResponse<TeamSyncResponse>> result = new CompletableFuture<>();
2099+
result.completeExceptionally(
2100+
new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
2101+
return result;
2102+
}
2103+
Object localVarPostBody = null;
2104+
2105+
// verify the required parameter 'filterSource' is set
2106+
if (filterSource == null) {
2107+
CompletableFuture<ApiResponse<TeamSyncResponse>> result = new CompletableFuture<>();
2108+
result.completeExceptionally(
2109+
new ApiException(
2110+
400, "Missing the required parameter 'filterSource' when calling getTeamSync"));
2111+
return result;
2112+
}
2113+
// create path and map variables
2114+
String localVarPath = "/api/v2/team/sync";
2115+
2116+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
2117+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
2118+
2119+
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[source]", filterSource));
2120+
2121+
Invocation.Builder builder;
2122+
try {
2123+
builder =
2124+
apiClient.createBuilder(
2125+
"v2.TeamsApi.getTeamSync",
2126+
localVarPath,
2127+
localVarQueryParams,
2128+
localVarHeaderParams,
2129+
new HashMap<String, String>(),
2130+
new String[] {"application/json"},
2131+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
2132+
} catch (ApiException ex) {
2133+
CompletableFuture<ApiResponse<TeamSyncResponse>> result = new CompletableFuture<>();
2134+
result.completeExceptionally(ex);
2135+
return result;
2136+
}
2137+
return apiClient.invokeAPIAsync(
2138+
"GET",
2139+
builder,
2140+
localVarHeaderParams,
2141+
new String[] {},
2142+
localVarPostBody,
2143+
new HashMap<String, Object>(),
2144+
false,
2145+
new GenericType<TeamSyncResponse>() {});
2146+
}
2147+
19902148
/**
19912149
* Get user memberships.
19922150
*
@@ -2958,8 +3116,8 @@ public CompletableFuture<Void> syncTeamsAsync(TeamSyncRequest body) {
29583116
* connected to your Datadog account</a>, and the GitHub App integrated with Datadog must have the
29593117
* <code>Members Read</code> permission. Matching is performed by comparing the Datadog team
29603118
* handle to the GitHub team slug using a normalized exact match; case is ignored and spaces are
2961-
* removed. No modifications are made to teams in GitHub. This will not create new Teams in
2962-
* Datadog.
3119+
* removed. No modifications are made to teams in GitHub. This only creates new teams in Datadog
3120+
* when type is set to <code>provision</code>.
29633121
*
29643122
* @param body (required)
29653123
* @return ApiResponse&lt;Void&gt;

0 commit comments

Comments
 (0)