Skip to content

Commit 1b2d5ed

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

File tree

14 files changed

+322
-14
lines changed

14 files changed

+322
-14
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:

docs/datadog_api_client.v2.model.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23125,6 +23125,13 @@ datadog\_api\_client.v2.model.team\_sync\_attributes module
2312523125
:members:
2312623126
:show-inheritance:
2312723127

23128+
datadog\_api\_client.v2.model.team\_sync\_attributes\_frequency module
23129+
----------------------------------------------------------------------
23130+
23131+
.. automodule:: datadog_api_client.v2.model.team_sync_attributes_frequency
23132+
:members:
23133+
:show-inheritance:
23134+
2312823135
datadog\_api\_client.v2.model.team\_sync\_attributes\_source module
2312923136
-------------------------------------------------------------------
2313023137

@@ -23160,6 +23167,13 @@ datadog\_api\_client.v2.model.team\_sync\_request module
2316023167
:members:
2316123168
:show-inheritance:
2316223169

23170+
datadog\_api\_client.v2.model.team\_sync\_response module
23171+
---------------------------------------------------------
23172+
23173+
.. automodule:: datadog_api_client.v2.model.team_sync_response
23174+
:members:
23175+
:show-inheritance:
23176+
2316323177
datadog\_api\_client.v2.model.team\_target module
2316423178
-------------------------------------------------
2316523179

examples/v2/teams/GetTeamSync.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Get team sync configurations returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.teams_api import TeamsApi
7+
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
8+
9+
configuration = Configuration()
10+
configuration.unstable_operations["get_team_sync"] = True
11+
with ApiClient(configuration) as api_client:
12+
api_instance = TeamsApi(api_client)
13+
response = api_instance.get_team_sync(
14+
filter_source=TeamSyncAttributesSource.GITHUB,
15+
)
16+
17+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def __init__(
372372
"v2.create_sca_resolve_vulnerable_symbols": False,
373373
"v2.create_sca_result": False,
374374
"v2.add_member_team": False,
375+
"v2.get_team_sync": False,
375376
"v2.list_member_teams": False,
376377
"v2.remove_member_team": False,
377378
"v2.sync_teams": False,

src/datadog_api_client/v2/api/teams_api.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from datadog_api_client.v2.model.team import Team
2222
from datadog_api_client.v2.model.team_response import TeamResponse
2323
from datadog_api_client.v2.model.team_create_request import TeamCreateRequest
24+
from datadog_api_client.v2.model.team_sync_response import TeamSyncResponse
25+
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
2426
from datadog_api_client.v2.model.team_sync_request import TeamSyncRequest
2527
from datadog_api_client.v2.model.add_member_team_request import AddMemberTeamRequest
2628
from datadog_api_client.v2.model.team_update_request import TeamUpdateRequest
@@ -368,6 +370,29 @@ def __init__(self, api_client=None):
368370
api_client=api_client,
369371
)
370372

373+
self._get_team_sync_endpoint = _Endpoint(
374+
settings={
375+
"response_type": (TeamSyncResponse,),
376+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
377+
"endpoint_path": "/api/v2/team/sync",
378+
"operation_id": "get_team_sync",
379+
"http_method": "GET",
380+
"version": "v2",
381+
},
382+
params_map={
383+
"filter_source": {
384+
"required": True,
385+
"openapi_types": (TeamSyncAttributesSource,),
386+
"attribute": "filter[source]",
387+
"location": "query",
388+
},
389+
},
390+
headers_map={
391+
"accept": ["application/json"],
392+
},
393+
api_client=api_client,
394+
)
395+
371396
self._get_user_memberships_endpoint = _Endpoint(
372397
settings={
373398
"response_type": (UserTeamsResponse,),
@@ -966,6 +991,24 @@ def get_team_permission_settings(
966991

967992
return self._get_team_permission_settings_endpoint.call_with_http_info(**kwargs)
968993

994+
def get_team_sync(
995+
self,
996+
filter_source: TeamSyncAttributesSource,
997+
) -> TeamSyncResponse:
998+
"""Get team sync configurations.
999+
1000+
Get all team synchronization configurations.
1001+
Returns a list of configurations used for linking or provisioning teams with external sources like GitHub.
1002+
1003+
:param filter_source: Filter by the external source platform for team synchronization
1004+
:type filter_source: TeamSyncAttributesSource
1005+
:rtype: TeamSyncResponse
1006+
"""
1007+
kwargs: Dict[str, Any] = {}
1008+
kwargs["filter_source"] = filter_source
1009+
1010+
return self._get_team_sync_endpoint.call_with_http_info(**kwargs)
1011+
9691012
def get_user_memberships(
9701013
self,
9711014
user_uuid: str,
@@ -1228,7 +1271,7 @@ def sync_teams(
12281271
`A GitHub organization must be connected to your Datadog account <https://docs.datadoghq.com/integrations/github/>`_ ,
12291272
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
12301273
using a normalized exact match; case is ignored and spaces are removed. No modifications are made
1231-
to teams in GitHub. This will not create new Teams in Datadog.
1274+
to teams in GitHub. This only creates new teams in Datadog when type is set to ``provision``.
12321275
12331276
:type body: TeamSyncRequest
12341277
:rtype: None

src/datadog_api_client/v2/model/team_sync_attributes.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,70 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import TYPE_CHECKING
6+
from typing import Union, TYPE_CHECKING
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
1010
cached_property,
11+
unset,
12+
UnsetType,
1113
)
1214

1315

1416
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.team_sync_attributes_frequency import TeamSyncAttributesFrequency
1518
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
1619
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType
1720

1821

1922
class TeamSyncAttributes(ModelNormal):
2023
@cached_property
2124
def openapi_types(_):
25+
from datadog_api_client.v2.model.team_sync_attributes_frequency import TeamSyncAttributesFrequency
2226
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
2327
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType
2428

2529
return {
30+
"frequency": (TeamSyncAttributesFrequency,),
2631
"source": (TeamSyncAttributesSource,),
32+
"sync_membership": (bool,),
2733
"type": (TeamSyncAttributesType,),
2834
}
2935

3036
attribute_map = {
37+
"frequency": "frequency",
3138
"source": "source",
39+
"sync_membership": "sync_membership",
3240
"type": "type",
3341
}
3442

35-
def __init__(self_, source: TeamSyncAttributesSource, type: TeamSyncAttributesType, **kwargs):
43+
def __init__(
44+
self_,
45+
source: TeamSyncAttributesSource,
46+
type: TeamSyncAttributesType,
47+
frequency: Union[TeamSyncAttributesFrequency, UnsetType] = unset,
48+
sync_membership: Union[bool, UnsetType] = unset,
49+
**kwargs,
50+
):
3651
"""
3752
Team sync attributes.
3853
54+
:param frequency: How often the sync process should be run. Defaults to ``once`` when not provided.
55+
:type frequency: TeamSyncAttributesFrequency, optional
56+
3957
:param source: The external source platform for team synchronization. Only "github" is supported.
4058
:type source: TeamSyncAttributesSource
4159
42-
:param type: The type of synchronization operation. Only "link" is supported, which links existing teams by matching names.
60+
:param sync_membership: Whether to sync members from the external team to the Datadog team. Defaults to ``false`` when not provided.
61+
:type sync_membership: bool, optional
62+
63+
:param type: The type of synchronization operation. "link" connects teams by matching names. "provision" creates new teams when no match is found.
4364
:type type: TeamSyncAttributesType
4465
"""
66+
if frequency is not unset:
67+
kwargs["frequency"] = frequency
68+
if sync_membership is not unset:
69+
kwargs["sync_membership"] = sync_membership
4570
super().__init__(kwargs)
4671

4772
self_.source = source
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class TeamSyncAttributesFrequency(ModelSimple):
16+
"""
17+
How often the sync process should be run. Defaults to `once` when not provided.
18+
19+
:param value: Must be one of ["once", "continuously", "paused"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"once",
25+
"continuously",
26+
"paused",
27+
}
28+
ONCE: ClassVar["TeamSyncAttributesFrequency"]
29+
CONTINUOUSLY: ClassVar["TeamSyncAttributesFrequency"]
30+
PAUSED: ClassVar["TeamSyncAttributesFrequency"]
31+
32+
@cached_property
33+
def openapi_types(_):
34+
return {
35+
"value": (str,),
36+
}
37+
38+
39+
TeamSyncAttributesFrequency.ONCE = TeamSyncAttributesFrequency("once")
40+
TeamSyncAttributesFrequency.CONTINUOUSLY = TeamSyncAttributesFrequency("continuously")
41+
TeamSyncAttributesFrequency.PAUSED = TeamSyncAttributesFrequency("paused")

0 commit comments

Comments
 (0)