Skip to content

Commit 4cf79f6

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add partial hierarchy selection to team sync endpoints (#3767)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 68f81b7 commit 4cf79f6

15 files changed

Lines changed: 706 additions & 67 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65885,6 +65885,8 @@ components:
6588565885
properties:
6588665886
frequency:
6588765887
$ref: "#/components/schemas/TeamSyncAttributesFrequency"
65888+
selection_state:
65889+
$ref: "#/components/schemas/TeamSyncAttributesSelectionState"
6588865890
source:
6588965891
$ref: "#/components/schemas/TeamSyncAttributesSource"
6589065892
sync_membership:
@@ -65907,6 +65909,14 @@ components:
6590765909
- ONCE
6590865910
- CONTINUOUSLY
6590965911
- PAUSED
65912+
TeamSyncAttributesSelectionState:
65913+
description: |-
65914+
Specifies which teams or organizations to sync. When
65915+
provided, synchronization is limited to the specified
65916+
items and their subtrees.
65917+
items:
65918+
$ref: "#/components/schemas/TeamSyncSelectionStateItem"
65919+
type: array
6591065920
TeamSyncAttributesSource:
6591165921
description: The external source platform for team synchronization. Only "github" is supported.
6591265922
enum:
@@ -65916,6 +65926,7 @@ components:
6591665926
x-enum-varnames:
6591765927
- GITHUB
6591865928
TeamSyncAttributesSyncMembership:
65929+
default: false
6591965930
description: Whether to sync members from the external team to the Datadog team. Defaults to `false` when not provided.
6592065931
example: true
6592165932
type: boolean
@@ -65975,6 +65986,72 @@ components:
6597565986
$ref: "#/components/schemas/TeamSyncData"
6597665987
type: array
6597765988
type: object
65989+
TeamSyncSelectionStateExternalId:
65990+
description: The external identifier for a team or organization in the source platform.
65991+
properties:
65992+
type:
65993+
$ref: "#/components/schemas/TeamSyncSelectionStateExternalIdType"
65994+
value:
65995+
$ref: "#/components/schemas/TeamSyncSelectionStateExternalIdValue"
65996+
required:
65997+
- type
65998+
- value
65999+
type: object
66000+
TeamSyncSelectionStateExternalIdType:
66001+
description: |-
66002+
The type of external identifier for the selection state item.
66003+
For GitHub synchronization, the allowed values are `team` and
66004+
`organization`.
66005+
enum:
66006+
- team
66007+
- organization
66008+
example: team
66009+
type: string
66010+
x-enum-varnames:
66011+
- TEAM
66012+
- ORGANIZATION
66013+
TeamSyncSelectionStateExternalIdValue:
66014+
description: |-
66015+
The external identifier value from the source
66016+
platform. For GitHub, this is the string
66017+
representation of a GitHub organization ID or team
66018+
ID.
66019+
example: "1"
66020+
type: string
66021+
TeamSyncSelectionStateItem:
66022+
description: Identifies a team or organization hierarchy to include in synchronization.
66023+
properties:
66024+
external_id:
66025+
$ref: "#/components/schemas/TeamSyncSelectionStateExternalId"
66026+
operation:
66027+
$ref: "#/components/schemas/TeamSyncSelectionStateOperation"
66028+
scope:
66029+
$ref: "#/components/schemas/TeamSyncSelectionStateScope"
66030+
required:
66031+
- external_id
66032+
type: object
66033+
TeamSyncSelectionStateOperation:
66034+
description: |-
66035+
The operation to perform on the selected hierarchy.
66036+
When set to `include`, synchronization covers the
66037+
referenced teams or organizations.
66038+
enum:
66039+
- include
66040+
example: include
66041+
type: string
66042+
x-enum-varnames:
66043+
- INCLUDE
66044+
TeamSyncSelectionStateScope:
66045+
description: |-
66046+
The scope of the selection. When set to `subtree`,
66047+
synchronization includes the referenced team or
66048+
organization and everything nested under it.
66049+
enum:
66050+
- subtree
66051+
example: subtree
66052+
type: string
66053+
x-enum-varnames:
66054+
- SUBTREE
6597866055
TeamTarget:
6597966056
description: "Represents a team target for an escalation policy step, including the team's ID and resource type."
6598066057
properties:
@@ -105434,12 +105511,6 @@ paths:
105434105511
description: OK
105435105512
"403":
105436105513
$ref: "#/components/responses/ForbiddenResponse"
105437-
"404":
105438-
content:
105439-
application/json:
105440-
schema:
105441-
$ref: "#/components/schemas/APIErrorResponse"
105442-
description: Team sync configurations not found
105443105514
"429":
105444105515
$ref: "#/components/responses/TooManyRequestsResponse"
105445105516
security:
@@ -105456,13 +105527,17 @@ paths:
105456105527
- teams_read
105457105528
post:
105458105529
description: |-
105459-
This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names.
105530+
This endpoint configures synchronization between your existing Datadog teams and GitHub teams by matching their names.
105460105531
It evaluates all current Datadog teams and compares them against teams in the GitHub organization
105461105532
connected to your Datadog account, based on Datadog Team handle and GitHub Team slug
105462105533
(lowercased and kebab-cased).
105463105534

105464105535
This operation is read-only on the GitHub side, no teams will be modified or created.
105465105536

105537+
Optionally, provide `selection_state` to limit synchronization
105538+
to specific teams or organizations and their subtrees, instead
105539+
of syncing all teams.
105540+
105466105541
[A GitHub organization must be connected to your Datadog account](https://docs.datadoghq.com/integrations/github/),
105467105542
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
105468105543
using a normalized exact match; case is ignored and spaces are removed. No modifications are made
@@ -105477,6 +105552,8 @@ paths:
105477105552
responses:
105478105553
"200":
105479105554
description: OK
105555+
"204":
105556+
description: No Content
105480105557
"403":
105481105558
$ref: "#/components/responses/ForbiddenResponse"
105482105559
"429":

api/datadogV2/api_teams.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ func (a *TeamsApi) GetTeamSync(ctx _context.Context, filterSource TeamSyncAttrib
17241724
ErrorBody: localVarBody,
17251725
ErrorMessage: localVarHTTPResponse.Status,
17261726
}
1727-
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
1727+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
17281728
var v APIErrorResponse
17291729
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
17301730
if err != nil {
@@ -2772,13 +2772,17 @@ func (a *TeamsApi) RemoveTeamHierarchyLink(ctx _context.Context, linkId string)
27722772
}
27732773

27742774
// SyncTeams Link Teams with GitHub Teams.
2775-
// This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names.
2775+
// This endpoint configures synchronization between your existing Datadog teams and GitHub teams by matching their names.
27762776
// It evaluates all current Datadog teams and compares them against teams in the GitHub organization
27772777
// connected to your Datadog account, based on Datadog Team handle and GitHub Team slug
27782778
// (lowercased and kebab-cased).
27792779
//
27802780
// This operation is read-only on the GitHub side, no teams will be modified or created.
27812781
//
2782+
// Optionally, provide `selection_state` to limit synchronization
2783+
// to specific teams or organizations and their subtrees, instead
2784+
// of syncing all teams.
2785+
//
27822786
// [A GitHub organization must be connected to your Datadog account](https://docs.datadoghq.com/integrations/github/),
27832787
// 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
27842788
// using a normalized exact match; case is ignored and spaces are removed. No modifications are made

api/datadogV2/model_team_sync_attributes.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import (
1414
type TeamSyncAttributes struct {
1515
// How often the sync process should be run. Defaults to `once` when not provided.
1616
Frequency *TeamSyncAttributesFrequency `json:"frequency,omitempty"`
17+
// Specifies which teams or organizations to sync. When
18+
// provided, synchronization is limited to the specified
19+
// items and their subtrees.
20+
SelectionState []TeamSyncSelectionStateItem `json:"selection_state,omitempty"`
1721
// The external source platform for team synchronization. Only "github" is supported.
1822
Source TeamSyncAttributesSource `json:"source"`
1923
// Whether to sync members from the external team to the Datadog team. Defaults to `false` when not provided.
@@ -32,6 +36,8 @@ type TeamSyncAttributes struct {
3236
func NewTeamSyncAttributes(source TeamSyncAttributesSource, typeVar TeamSyncAttributesType) *TeamSyncAttributes {
3337
this := TeamSyncAttributes{}
3438
this.Source = source
39+
var syncMembership bool = false
40+
this.SyncMembership = &syncMembership
3541
this.Type = typeVar
3642
return &this
3743
}
@@ -41,6 +47,8 @@ func NewTeamSyncAttributes(source TeamSyncAttributesSource, typeVar TeamSyncAttr
4147
// but it doesn't guarantee that properties required by API are set.
4248
func NewTeamSyncAttributesWithDefaults() *TeamSyncAttributes {
4349
this := TeamSyncAttributes{}
50+
var syncMembership bool = false
51+
this.SyncMembership = &syncMembership
4452
return &this
4553
}
4654

@@ -72,6 +80,34 @@ func (o *TeamSyncAttributes) SetFrequency(v TeamSyncAttributesFrequency) {
7280
o.Frequency = &v
7381
}
7482

83+
// GetSelectionState returns the SelectionState field value if set, zero value otherwise.
84+
func (o *TeamSyncAttributes) GetSelectionState() []TeamSyncSelectionStateItem {
85+
if o == nil || o.SelectionState == nil {
86+
var ret []TeamSyncSelectionStateItem
87+
return ret
88+
}
89+
return o.SelectionState
90+
}
91+
92+
// GetSelectionStateOk returns a tuple with the SelectionState field value if set, nil otherwise
93+
// and a boolean to check if the value has been set.
94+
func (o *TeamSyncAttributes) GetSelectionStateOk() (*[]TeamSyncSelectionStateItem, bool) {
95+
if o == nil || o.SelectionState == nil {
96+
return nil, false
97+
}
98+
return &o.SelectionState, true
99+
}
100+
101+
// HasSelectionState returns a boolean if a field has been set.
102+
func (o *TeamSyncAttributes) HasSelectionState() bool {
103+
return o != nil && o.SelectionState != nil
104+
}
105+
106+
// SetSelectionState gets a reference to the given []TeamSyncSelectionStateItem and assigns it to the SelectionState field.
107+
func (o *TeamSyncAttributes) SetSelectionState(v []TeamSyncSelectionStateItem) {
108+
o.SelectionState = v
109+
}
110+
75111
// GetSource returns the Source field value.
76112
func (o *TeamSyncAttributes) GetSource() TeamSyncAttributesSource {
77113
if o == nil {
@@ -155,6 +191,9 @@ func (o TeamSyncAttributes) MarshalJSON() ([]byte, error) {
155191
if o.Frequency != nil {
156192
toSerialize["frequency"] = o.Frequency
157193
}
194+
if o.SelectionState != nil {
195+
toSerialize["selection_state"] = o.SelectionState
196+
}
158197
toSerialize["source"] = o.Source
159198
if o.SyncMembership != nil {
160199
toSerialize["sync_membership"] = o.SyncMembership
@@ -171,6 +210,7 @@ func (o TeamSyncAttributes) MarshalJSON() ([]byte, error) {
171210
func (o *TeamSyncAttributes) UnmarshalJSON(bytes []byte) (err error) {
172211
all := struct {
173212
Frequency *TeamSyncAttributesFrequency `json:"frequency,omitempty"`
213+
SelectionState []TeamSyncSelectionStateItem `json:"selection_state,omitempty"`
174214
Source *TeamSyncAttributesSource `json:"source"`
175215
SyncMembership *bool `json:"sync_membership,omitempty"`
176216
Type *TeamSyncAttributesType `json:"type"`
@@ -186,7 +226,7 @@ func (o *TeamSyncAttributes) UnmarshalJSON(bytes []byte) (err error) {
186226
}
187227
additionalProperties := make(map[string]interface{})
188228
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
189-
datadog.DeleteKeys(additionalProperties, &[]string{"frequency", "source", "sync_membership", "type"})
229+
datadog.DeleteKeys(additionalProperties, &[]string{"frequency", "selection_state", "source", "sync_membership", "type"})
190230
} else {
191231
return err
192232
}
@@ -197,6 +237,7 @@ func (o *TeamSyncAttributes) UnmarshalJSON(bytes []byte) (err error) {
197237
} else {
198238
o.Frequency = all.Frequency
199239
}
240+
o.SelectionState = all.SelectionState
200241
if !all.Source.IsValid() {
201242
hasInvalidField = true
202243
} else {

0 commit comments

Comments
 (0)