Skip to content

Commit ebd93fd

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Support provisioning teams from external sources (DataDog#3467)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3368782 commit ebd93fd

13 files changed

Lines changed: 522 additions & 14 deletions

.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:

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ func NewConfiguration() *Configuration {
725725
"v2.CreateSCAResolveVulnerableSymbols": false,
726726
"v2.CreateSCAResult": false,
727727
"v2.AddMemberTeam": false,
728+
"v2.GetTeamSync": false,
728729
"v2.ListMemberTeams": false,
729730
"v2.RemoveMemberTeam": false,
730731
"v2.SyncTeams": false,

api/datadogV2/api_teams.go

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,94 @@ func (a *TeamsApi) GetTeamPermissionSettings(ctx _context.Context, teamId string
10451045
return localVarReturnValue, localVarHTTPResponse, nil
10461046
}
10471047

1048+
// GetTeamSync Get team sync configurations.
1049+
// Get all team synchronization configurations.
1050+
// Returns a list of configurations used for linking or provisioning teams with external sources like GitHub.
1051+
func (a *TeamsApi) GetTeamSync(ctx _context.Context, filterSource TeamSyncAttributesSource) (TeamSyncResponse, *_nethttp.Response, error) {
1052+
var (
1053+
localVarHTTPMethod = _nethttp.MethodGet
1054+
localVarPostBody interface{}
1055+
localVarReturnValue TeamSyncResponse
1056+
)
1057+
1058+
operationId := "v2.GetTeamSync"
1059+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
1060+
if !isOperationEnabled {
1061+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
1062+
}
1063+
if isOperationEnabled && a.Client.Cfg.Debug {
1064+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
1065+
}
1066+
1067+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.TeamsApi.GetTeamSync")
1068+
if err != nil {
1069+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
1070+
}
1071+
1072+
localVarPath := localBasePath + "/api/v2/team/sync"
1073+
1074+
localVarHeaderParams := make(map[string]string)
1075+
localVarQueryParams := _neturl.Values{}
1076+
localVarFormParams := _neturl.Values{}
1077+
localVarQueryParams.Add("filter[source]", datadog.ParameterToString(filterSource, ""))
1078+
localVarHeaderParams["Accept"] = "application/json"
1079+
1080+
if a.Client.Cfg.DelegatedTokenConfig != nil {
1081+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
1082+
if err != nil {
1083+
return localVarReturnValue, nil, err
1084+
}
1085+
} else {
1086+
datadog.SetAuthKeys(
1087+
ctx,
1088+
&localVarHeaderParams,
1089+
[2]string{"apiKeyAuth", "DD-API-KEY"},
1090+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
1091+
)
1092+
}
1093+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
1094+
if err != nil {
1095+
return localVarReturnValue, nil, err
1096+
}
1097+
1098+
localVarHTTPResponse, err := a.Client.CallAPI(req)
1099+
if err != nil || localVarHTTPResponse == nil {
1100+
return localVarReturnValue, localVarHTTPResponse, err
1101+
}
1102+
1103+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
1104+
if err != nil {
1105+
return localVarReturnValue, localVarHTTPResponse, err
1106+
}
1107+
1108+
if localVarHTTPResponse.StatusCode >= 300 {
1109+
newErr := datadog.GenericOpenAPIError{
1110+
ErrorBody: localVarBody,
1111+
ErrorMessage: localVarHTTPResponse.Status,
1112+
}
1113+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
1114+
var v APIErrorResponse
1115+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
1116+
if err != nil {
1117+
return localVarReturnValue, localVarHTTPResponse, newErr
1118+
}
1119+
newErr.ErrorModel = v
1120+
}
1121+
return localVarReturnValue, localVarHTTPResponse, newErr
1122+
}
1123+
1124+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
1125+
if err != nil {
1126+
newErr := datadog.GenericOpenAPIError{
1127+
ErrorBody: localVarBody,
1128+
ErrorMessage: err.Error(),
1129+
}
1130+
return localVarReturnValue, localVarHTTPResponse, newErr
1131+
}
1132+
1133+
return localVarReturnValue, localVarHTTPResponse, nil
1134+
}
1135+
10481136
// GetUserMemberships Get user memberships.
10491137
// Get a list of memberships for a user
10501138
func (a *TeamsApi) GetUserMemberships(ctx _context.Context, userUuid string) (UserTeamsResponse, *_nethttp.Response, error) {
@@ -1617,7 +1705,7 @@ func (a *TeamsApi) RemoveMemberTeam(ctx _context.Context, superTeamId string, me
16171705
// [A GitHub organization must be connected to your Datadog account](https://docs.datadoghq.com/integrations/github/),
16181706
// and the GitHub App integrated with Datadog must have the `Members Read` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug
16191707
// using a normalized exact match; case is ignored and spaces are removed. No modifications are made
1620-
// to teams in GitHub. This will not create new Teams in Datadog.
1708+
// to teams in GitHub. This only creates new teams in Datadog when type is set to `provision`.
16211709
func (a *TeamsApi) SyncTeams(ctx _context.Context, body TeamSyncRequest) (*_nethttp.Response, error) {
16221710
var (
16231711
localVarHTTPMethod = _nethttp.MethodPost

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@
631631
// - [TeamsApi.GetTeamLinks]
632632
// - [TeamsApi.GetTeamMemberships]
633633
// - [TeamsApi.GetTeamPermissionSettings]
634+
// - [TeamsApi.GetTeamSync]
634635
// - [TeamsApi.GetUserMemberships]
635636
// - [TeamsApi.ListMemberTeams]
636637
// - [TeamsApi.ListTeams]

0 commit comments

Comments
 (0)