diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 922424a28d..cb64b3bf5b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -11515,6 +11515,35 @@ components: $ref: '#/components/schemas/ConfluentResourceResponseData' type: array type: object + ConnectedTeamRef: + description: Reference to a team from an external system. + properties: + data: + $ref: '#/components/schemas/ConnectedTeamRefData' + type: object + ConnectedTeamRefData: + description: Reference to connected external team. + properties: + id: + description: The connected team ID as it is referenced throughout the Datadog + ecosystem. + example: '@GitHubOrg/team-handle' + type: string + type: + $ref: '#/components/schemas/ConnectedTeamRefDataType' + required: + - id + - type + type: object + ConnectedTeamRefDataType: + default: github_team + description: External team resource type. + enum: + - github_team + example: github_team + type: string + x-enum-varnames: + - GITHUB_TEAM Connection: description: The definition of `Connection` object. properties: @@ -11579,6 +11608,50 @@ components: - label - tags type: object + ConnectionsPagePagination: + description: Page-based pagination metadata. + properties: + first_number: + description: The first page number. + format: int64 + type: integer + last_number: + description: The last page number. + format: int64 + type: integer + next_number: + description: The next page number. + format: int64 + nullable: true + type: integer + number: + description: The current page number. + format: int64 + type: integer + prev_number: + description: The previous page number. + format: int64 + nullable: true + type: integer + size: + description: The page size. + format: int64 + type: integer + total: + description: Total connections matching request. + format: int64 + type: integer + type: + description: Pagination type. + example: number_size + type: string + type: object + ConnectionsResponseMeta: + description: Connections response metadata. + properties: + page: + $ref: '#/components/schemas/ConnectionsPagePagination' + type: object Container: description: Container object. properties: @@ -51345,6 +51418,111 @@ components: - handle - name type: object + TeamConnection: + description: A relationship between a Datadog team and a team from another external + system. + properties: + attributes: + $ref: '#/components/schemas/TeamConnectionAttributes' + id: + description: The unique identifier of the team connection. + example: 12345678-1234-5678-9abc-123456789012 + type: string + relationships: + $ref: '#/components/schemas/TeamConnectionRelationships' + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - id + - type + type: object + TeamConnectionAttributes: + description: Attributes of the team connection. + properties: + managed_by: + description: The entity that manages this team connection. + example: github_sync + type: string + source: + description: The name of the external source. + example: github + type: string + type: object + TeamConnectionCreateData: + description: Data for creating a team connection. + properties: + attributes: + $ref: '#/components/schemas/TeamConnectionAttributes' + relationships: + $ref: '#/components/schemas/TeamConnectionRelationships' + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - type + type: object + TeamConnectionCreateRequest: + description: Request for creating team connections. + properties: + data: + description: Array of team connections to create. + items: + $ref: '#/components/schemas/TeamConnectionCreateData' + type: array + required: + - data + type: object + TeamConnectionDeleteRequest: + description: Request for deleting team connections. + properties: + data: + description: Array of team connection IDs to delete. + items: + $ref: '#/components/schemas/TeamConnectionDeleteRequestDataItem' + type: array + required: + - data + type: object + TeamConnectionDeleteRequestDataItem: + description: A collection of connection ids to delete. + properties: + id: + description: The unique identifier of the team connection to delete. + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: + $ref: '#/components/schemas/TeamConnectionType' + required: + - id + - type + type: object + TeamConnectionRelationships: + description: Relationships of the team connection. + properties: + connected_team: + $ref: '#/components/schemas/ConnectedTeamRef' + team: + $ref: '#/components/schemas/TeamRef' + type: object + TeamConnectionType: + default: team_connection + description: Team connection resource type. + enum: + - team_connection + example: team_connection + type: string + x-enum-varnames: + - TEAM_CONNECTION + TeamConnectionsResponse: + description: Response containing information about multiple team connections. + properties: + data: + description: Array of team connections. + items: + $ref: '#/components/schemas/TeamConnection' + type: array + meta: + $ref: '#/components/schemas/ConnectionsResponseMeta' + type: object TeamCreate: description: Team create properties: @@ -51762,6 +51940,34 @@ components: $ref: '#/components/schemas/TeamPermissionSetting' type: array type: object + TeamRef: + description: Reference to a Datadog team. + properties: + data: + $ref: '#/components/schemas/TeamRefData' + type: object + TeamRefData: + description: Reference to a Datadog team. + properties: + id: + description: The Datadog team ID. + example: 87654321-4321-8765-dcba-210987654321 + type: string + type: + $ref: '#/components/schemas/TeamRefDataType' + required: + - id + - type + type: object + TeamRefDataType: + default: team + description: Datadog team resource type. + enum: + - team + example: team + type: string + x-enum-varnames: + - TEAM TeamReference: description: Provides a reference to a team, including ID, type, and basic attributes/relationships. properties: @@ -80787,6 +80993,166 @@ paths: permissions: - teams_read - teams_manage + /api/v2/team/connections: + delete: + description: Delete multiple team connections. + operationId: DeleteTeamConnections + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionDeleteRequest' + required: true + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Delete team connections + tags: + - Team Connections + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Returns all team connections. + operationId: ListTeamConnections + parameters: + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + - description: Filter team connections by external source systems. + explode: false + in: query + name: filter[sources] + required: false + schema: + items: + example: github + type: string + type: array + style: form + - description: Filter team connections by Datadog team IDs. + explode: false + in: query + name: filter[team_ids] + required: false + schema: + items: + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: array + style: form + - description: Filter team connections by connected team IDs from external systems. + explode: false + in: query + name: filter[connected_team_ids] + required: false + schema: + items: + example: '@MyGitHubAccount/my-team-name' + type: string + type: array + style: form + - description: Filter team connections by connection IDs. + explode: false + in: query + name: filter[connection_ids] + required: false + schema: + items: + example: 12345678-1234-5678-9abc-123456789012 + type: string + type: array + style: form + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: List team connections + tags: + - Team Connections + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create multiple team connections. + operationId: CreateTeamConnections + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamConnectionsResponse' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Create team connections + tags: + - Team Connections + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/sync: post: description: 'This endpoint attempts to link your existing Datadog teams with @@ -83992,6 +84358,9 @@ tags: use Datadog\u2019s API to\nmanage both test types programmatically.\n\nFor more information about Synthetics, see the [Synthetics overview](https://docs.datadoghq.com/synthetics/)." name: Synthetics +- description: View and manage relationships between Datadog teams and teams from + external sources, such as GitHub. + name: Team Connections - description: View and manage teams within Datadog. See the [Teams page](https://docs.datadoghq.com/account_management/teams/) for more information. name: Teams diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 13c0fb8992..670c94df3a 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -543,6 +543,13 @@ datadog\_api\_client.v2.api.synthetics\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.team\_connections\_api module +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.team_connections_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.teams\_api module --------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index e91add8e03..d3b3e6cfe5 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -4484,6 +4484,27 @@ datadog\_api\_client.v2.model.confluent\_resources\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.connected\_team\_ref module +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.connected_team_ref + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.connected\_team\_ref\_data module +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.connected_team_ref_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.connected\_team\_ref\_data\_type module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.connected_team_ref_data_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.connection module ----------------------------------------------- @@ -4512,6 +4533,20 @@ datadog\_api\_client.v2.model.connection\_group module :members: :show-inheritance: +datadog\_api\_client.v2.model.connections\_page\_pagination module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.connections_page_pagination + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.connections\_response\_meta module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.connections_response_meta + :members: + :show-inheritance: + datadog\_api\_client.v2.model.container module ---------------------------------------------- @@ -22628,6 +22663,69 @@ datadog\_api\_client.v2.model.team\_attributes module :members: :show-inheritance: +datadog\_api\_client.v2.model.team\_connection module +----------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_attributes module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_create\_data module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_create_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_create\_request module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_create_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_delete\_request module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_delete_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_delete\_request\_data\_item module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_delete_request_data_item + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_relationships module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_relationships + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connection\_type module +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connection_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_connections\_response module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_connections_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.team\_create module ------------------------------------------------- @@ -22866,6 +22964,27 @@ datadog\_api\_client.v2.model.team\_permission\_settings\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.team\_ref module +---------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_ref + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_ref\_data module +---------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_ref_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.team\_ref\_data\_type module +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.team_ref_data_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.team\_reference module ---------------------------------------------------- diff --git a/examples/v2/team-connections/CreateTeamConnections.py b/examples/v2/team-connections/CreateTeamConnections.py new file mode 100644 index 0000000000..d5df138fae --- /dev/null +++ b/examples/v2/team-connections/CreateTeamConnections.py @@ -0,0 +1,55 @@ +""" +Create team connections returns "Created" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi +from datadog_api_client.v2.model.connected_team_ref import ConnectedTeamRef +from datadog_api_client.v2.model.connected_team_ref_data import ConnectedTeamRefData +from datadog_api_client.v2.model.connected_team_ref_data_type import ConnectedTeamRefDataType +from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes +from datadog_api_client.v2.model.team_connection_create_data import TeamConnectionCreateData +from datadog_api_client.v2.model.team_connection_create_request import TeamConnectionCreateRequest +from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships +from datadog_api_client.v2.model.team_connection_type import TeamConnectionType +from datadog_api_client.v2.model.team_ref import TeamRef +from datadog_api_client.v2.model.team_ref_data import TeamRefData +from datadog_api_client.v2.model.team_ref_data_type import TeamRefDataType + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +body = TeamConnectionCreateRequest( + data=[ + TeamConnectionCreateData( + type=TeamConnectionType.TEAM_CONNECTION, + attributes=TeamConnectionAttributes( + source="github", + managed_by="datadog", + ), + relationships=TeamConnectionRelationships( + team=TeamRef( + data=TeamRefData( + id=DD_TEAM_DATA_ID, + type=TeamRefDataType.TEAM, + ), + ), + connected_team=ConnectedTeamRef( + data=ConnectedTeamRefData( + id="@MyGitHubAccount/my-team-name", + type=ConnectedTeamRefDataType.GITHUB_TEAM, + ), + ), + ), + ), + ], +) + +configuration = Configuration() +configuration.unstable_operations["create_team_connections"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamConnectionsApi(api_client) + response = api_instance.create_team_connections(body=body) + + print(response) diff --git a/examples/v2/team-connections/DeleteTeamConnections.py b/examples/v2/team-connections/DeleteTeamConnections.py new file mode 100644 index 0000000000..8e80166703 --- /dev/null +++ b/examples/v2/team-connections/DeleteTeamConnections.py @@ -0,0 +1,24 @@ +""" +Delete team connections returns "No Content" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi +from datadog_api_client.v2.model.team_connection_delete_request import TeamConnectionDeleteRequest +from datadog_api_client.v2.model.team_connection_delete_request_data_item import TeamConnectionDeleteRequestDataItem +from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + +body = TeamConnectionDeleteRequest( + data=[ + TeamConnectionDeleteRequestDataItem( + id="12345678-1234-5678-9abc-123456789012", + type=TeamConnectionType.TEAM_CONNECTION, + ), + ], +) + +configuration = Configuration() +configuration.unstable_operations["delete_team_connections"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamConnectionsApi(api_client) + api_instance.delete_team_connections(body=body) diff --git a/examples/v2/team-connections/ListTeamConnections.py b/examples/v2/team-connections/ListTeamConnections.py new file mode 100644 index 0000000000..f44297c8df --- /dev/null +++ b/examples/v2/team-connections/ListTeamConnections.py @@ -0,0 +1,14 @@ +""" +List team connections returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi + +configuration = Configuration() +configuration.unstable_operations["list_team_connections"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamConnectionsApi(api_client) + response = api_instance.list_team_connections() + + print(response) diff --git a/examples/v2/team-connections/ListTeamConnections_1473516764.py b/examples/v2/team-connections/ListTeamConnections_1473516764.py new file mode 100644 index 0000000000..484b3068c8 --- /dev/null +++ b/examples/v2/team-connections/ListTeamConnections_1473516764.py @@ -0,0 +1,19 @@ +""" +List team connections with filters returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi + +configuration = Configuration() +configuration.unstable_operations["list_team_connections"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamConnectionsApi(api_client) + response = api_instance.list_team_connections( + page_size=10, + filter_sources=[ + "github", + ], + ) + + print(response) diff --git a/examples/v2/team-connections/ListTeamConnections_2418873869.py b/examples/v2/team-connections/ListTeamConnections_2418873869.py new file mode 100644 index 0000000000..c73fda4c74 --- /dev/null +++ b/examples/v2/team-connections/ListTeamConnections_2418873869.py @@ -0,0 +1,14 @@ +""" +List team connections returns "OK" response with pagination +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi + +configuration = Configuration() +configuration.unstable_operations["list_team_connections"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamConnectionsApi(api_client) + items = api_instance.list_team_connections_with_pagination() + for item in items: + print(item) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index e02030186f..edfd2cf5de 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -375,6 +375,9 @@ def __init__( "v2.list_member_teams": False, "v2.remove_member_team": False, "v2.sync_teams": False, + "v2.create_team_connections": False, + "v2.delete_team_connections": False, + "v2.list_team_connections": False, "v2.create_incident_team": False, "v2.delete_incident_team": False, "v2.get_incident_team": False, diff --git a/src/datadog_api_client/v2/api/team_connections_api.py b/src/datadog_api_client/v2/api/team_connections_api.py new file mode 100644 index 0000000000..465350cb4f --- /dev/null +++ b/src/datadog_api_client/v2/api/team_connections_api.py @@ -0,0 +1,264 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +import collections +from typing import Any, Dict, List, Union + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + set_attribute_from_path, + get_attribute_from_path, + UnsetType, + unset, +) +from datadog_api_client.v2.model.team_connection_delete_request import TeamConnectionDeleteRequest +from datadog_api_client.v2.model.team_connections_response import TeamConnectionsResponse +from datadog_api_client.v2.model.team_connection import TeamConnection +from datadog_api_client.v2.model.team_connection_create_request import TeamConnectionCreateRequest + + +class TeamConnectionsApi: + """ + View and manage relationships between Datadog teams and teams from external sources, such as GitHub. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._create_team_connections_endpoint = _Endpoint( + settings={ + "response_type": (TeamConnectionsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/team/connections", + "operation_id": "create_team_connections", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (TeamConnectionCreateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + self._delete_team_connections_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/team/connections", + "operation_id": "delete_team_connections", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (TeamConnectionDeleteRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["*/*"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + self._list_team_connections_endpoint = _Endpoint( + settings={ + "response_type": (TeamConnectionsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/team/connections", + "operation_id": "list_team_connections", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "page_size": { + "openapi_types": (int,), + "attribute": "page[size]", + "location": "query", + }, + "page_number": { + "openapi_types": (int,), + "attribute": "page[number]", + "location": "query", + }, + "filter_sources": { + "openapi_types": ([str],), + "attribute": "filter[sources]", + "location": "query", + "collection_format": "csv", + }, + "filter_team_ids": { + "openapi_types": ([str],), + "attribute": "filter[team_ids]", + "location": "query", + "collection_format": "csv", + }, + "filter_connected_team_ids": { + "openapi_types": ([str],), + "attribute": "filter[connected_team_ids]", + "location": "query", + "collection_format": "csv", + }, + "filter_connection_ids": { + "openapi_types": ([str],), + "attribute": "filter[connection_ids]", + "location": "query", + "collection_format": "csv", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + def create_team_connections( + self, + body: TeamConnectionCreateRequest, + ) -> TeamConnectionsResponse: + """Create team connections. + + Create multiple team connections. + + :type body: TeamConnectionCreateRequest + :rtype: TeamConnectionsResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_team_connections_endpoint.call_with_http_info(**kwargs) + + def delete_team_connections( + self, + body: TeamConnectionDeleteRequest, + ) -> None: + """Delete team connections. + + Delete multiple team connections. + + :type body: TeamConnectionDeleteRequest + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._delete_team_connections_endpoint.call_with_http_info(**kwargs) + + def list_team_connections( + self, + *, + page_size: Union[int, UnsetType] = unset, + page_number: Union[int, UnsetType] = unset, + filter_sources: Union[List[str], UnsetType] = unset, + filter_team_ids: Union[List[str], UnsetType] = unset, + filter_connected_team_ids: Union[List[str], UnsetType] = unset, + filter_connection_ids: Union[List[str], UnsetType] = unset, + ) -> TeamConnectionsResponse: + """List team connections. + + Returns all team connections. + + :param page_size: Size for a given page. The maximum allowed value is 100. + :type page_size: int, optional + :param page_number: Specific page number to return. + :type page_number: int, optional + :param filter_sources: Filter team connections by external source systems. + :type filter_sources: [str], optional + :param filter_team_ids: Filter team connections by Datadog team IDs. + :type filter_team_ids: [str], optional + :param filter_connected_team_ids: Filter team connections by connected team IDs from external systems. + :type filter_connected_team_ids: [str], optional + :param filter_connection_ids: Filter team connections by connection IDs. + :type filter_connection_ids: [str], optional + :rtype: TeamConnectionsResponse + """ + kwargs: Dict[str, Any] = {} + if page_size is not unset: + kwargs["page_size"] = page_size + + if page_number is not unset: + kwargs["page_number"] = page_number + + if filter_sources is not unset: + kwargs["filter_sources"] = filter_sources + + if filter_team_ids is not unset: + kwargs["filter_team_ids"] = filter_team_ids + + if filter_connected_team_ids is not unset: + kwargs["filter_connected_team_ids"] = filter_connected_team_ids + + if filter_connection_ids is not unset: + kwargs["filter_connection_ids"] = filter_connection_ids + + return self._list_team_connections_endpoint.call_with_http_info(**kwargs) + + def list_team_connections_with_pagination( + self, + *, + page_size: Union[int, UnsetType] = unset, + page_number: Union[int, UnsetType] = unset, + filter_sources: Union[List[str], UnsetType] = unset, + filter_team_ids: Union[List[str], UnsetType] = unset, + filter_connected_team_ids: Union[List[str], UnsetType] = unset, + filter_connection_ids: Union[List[str], UnsetType] = unset, + ) -> collections.abc.Iterable[TeamConnection]: + """List team connections. + + Provide a paginated version of :meth:`list_team_connections`, returning all items. + + :param page_size: Size for a given page. The maximum allowed value is 100. + :type page_size: int, optional + :param page_number: Specific page number to return. + :type page_number: int, optional + :param filter_sources: Filter team connections by external source systems. + :type filter_sources: [str], optional + :param filter_team_ids: Filter team connections by Datadog team IDs. + :type filter_team_ids: [str], optional + :param filter_connected_team_ids: Filter team connections by connected team IDs from external systems. + :type filter_connected_team_ids: [str], optional + :param filter_connection_ids: Filter team connections by connection IDs. + :type filter_connection_ids: [str], optional + + :return: A generator of paginated results. + :rtype: collections.abc.Iterable[TeamConnection] + """ + kwargs: Dict[str, Any] = {} + if page_size is not unset: + kwargs["page_size"] = page_size + + if page_number is not unset: + kwargs["page_number"] = page_number + + if filter_sources is not unset: + kwargs["filter_sources"] = filter_sources + + if filter_team_ids is not unset: + kwargs["filter_team_ids"] = filter_team_ids + + if filter_connected_team_ids is not unset: + kwargs["filter_connected_team_ids"] = filter_connected_team_ids + + if filter_connection_ids is not unset: + kwargs["filter_connection_ids"] = filter_connection_ids + + local_page_size = get_attribute_from_path(kwargs, "page_size", 10) + endpoint = self._list_team_connections_endpoint + set_attribute_from_path(kwargs, "page_size", local_page_size, endpoint.params_map) + pagination = { + "limit_value": local_page_size, + "results_path": "data", + "page_param": "page_number", + "endpoint": endpoint, + "kwargs": kwargs, + } + return endpoint.call_with_http_info_paginated(pagination) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 3d7276fb2f..db2c3b8d0c 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -75,6 +75,7 @@ from datadog_api_client.v2.api.spans_metrics_api import SpansMetricsApi from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi from datadog_api_client.v2.api.synthetics_api import SyntheticsApi +from datadog_api_client.v2.api.team_connections_api import TeamConnectionsApi from datadog_api_client.v2.api.teams_api import TeamsApi from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi @@ -160,6 +161,7 @@ "SpansMetricsApi", "StaticAnalysisApi", "SyntheticsApi", + "TeamConnectionsApi", "TeamsApi", "TestOptimizationApi", "UsageMeteringApi", diff --git a/src/datadog_api_client/v2/model/connected_team_ref.py b/src/datadog_api_client/v2/model/connected_team_ref.py new file mode 100644 index 0000000000..5e8ea96a4d --- /dev/null +++ b/src/datadog_api_client/v2/model/connected_team_ref.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.connected_team_ref_data import ConnectedTeamRefData + + +class ConnectedTeamRef(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.connected_team_ref_data import ConnectedTeamRefData + + return { + "data": (ConnectedTeamRefData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[ConnectedTeamRefData, UnsetType] = unset, **kwargs): + """ + Reference to a team from an external system. + + :param data: Reference to connected external team. + :type data: ConnectedTeamRefData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/connected_team_ref_data.py b/src/datadog_api_client/v2/model/connected_team_ref_data.py new file mode 100644 index 0000000000..40de88b8e4 --- /dev/null +++ b/src/datadog_api_client/v2/model/connected_team_ref_data.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.connected_team_ref_data_type import ConnectedTeamRefDataType + + +class ConnectedTeamRefData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.connected_team_ref_data_type import ConnectedTeamRefDataType + + return { + "id": (str,), + "type": (ConnectedTeamRefDataType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: str, type: ConnectedTeamRefDataType, **kwargs): + """ + Reference to connected external team. + + :param id: The connected team ID as it is referenced throughout the Datadog ecosystem. + :type id: str + + :param type: External team resource type. + :type type: ConnectedTeamRefDataType + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/connected_team_ref_data_type.py b/src/datadog_api_client/v2/model/connected_team_ref_data_type.py new file mode 100644 index 0000000000..4c2e5a212c --- /dev/null +++ b/src/datadog_api_client/v2/model/connected_team_ref_data_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ConnectedTeamRefDataType(ModelSimple): + """ + External team resource type. + + :param value: If omitted defaults to "github_team". Must be one of ["github_team"]. + :type value: str + """ + + allowed_values = { + "github_team", + } + GITHUB_TEAM: ClassVar["ConnectedTeamRefDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ConnectedTeamRefDataType.GITHUB_TEAM = ConnectedTeamRefDataType("github_team") diff --git a/src/datadog_api_client/v2/model/connections_page_pagination.py b/src/datadog_api_client/v2/model/connections_page_pagination.py new file mode 100644 index 0000000000..991323258e --- /dev/null +++ b/src/datadog_api_client/v2/model/connections_page_pagination.py @@ -0,0 +1,97 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class ConnectionsPagePagination(ModelNormal): + @cached_property + def openapi_types(_): + return { + "first_number": (int,), + "last_number": (int,), + "next_number": (int, none_type), + "number": (int,), + "prev_number": (int, none_type), + "size": (int,), + "total": (int,), + "type": (str,), + } + + attribute_map = { + "first_number": "first_number", + "last_number": "last_number", + "next_number": "next_number", + "number": "number", + "prev_number": "prev_number", + "size": "size", + "total": "total", + "type": "type", + } + + def __init__( + self_, + first_number: Union[int, UnsetType] = unset, + last_number: Union[int, UnsetType] = unset, + next_number: Union[int, none_type, UnsetType] = unset, + number: Union[int, UnsetType] = unset, + prev_number: Union[int, none_type, UnsetType] = unset, + size: Union[int, UnsetType] = unset, + total: Union[int, UnsetType] = unset, + type: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Page-based pagination metadata. + + :param first_number: The first page number. + :type first_number: int, optional + + :param last_number: The last page number. + :type last_number: int, optional + + :param next_number: The next page number. + :type next_number: int, none_type, optional + + :param number: The current page number. + :type number: int, optional + + :param prev_number: The previous page number. + :type prev_number: int, none_type, optional + + :param size: The page size. + :type size: int, optional + + :param total: Total connections matching request. + :type total: int, optional + + :param type: Pagination type. + :type type: str, optional + """ + if first_number is not unset: + kwargs["first_number"] = first_number + if last_number is not unset: + kwargs["last_number"] = last_number + if next_number is not unset: + kwargs["next_number"] = next_number + if number is not unset: + kwargs["number"] = number + if prev_number is not unset: + kwargs["prev_number"] = prev_number + if size is not unset: + kwargs["size"] = size + if total is not unset: + kwargs["total"] = total + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/connections_response_meta.py b/src/datadog_api_client/v2/model/connections_response_meta.py new file mode 100644 index 0000000000..e8894fef99 --- /dev/null +++ b/src/datadog_api_client/v2/model/connections_response_meta.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.connections_page_pagination import ConnectionsPagePagination + + +class ConnectionsResponseMeta(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.connections_page_pagination import ConnectionsPagePagination + + return { + "page": (ConnectionsPagePagination,), + } + + attribute_map = { + "page": "page", + } + + def __init__(self_, page: Union[ConnectionsPagePagination, UnsetType] = unset, **kwargs): + """ + Connections response metadata. + + :param page: Page-based pagination metadata. + :type page: ConnectionsPagePagination, optional + """ + if page is not unset: + kwargs["page"] = page + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_connection.py b/src/datadog_api_client/v2/model/team_connection.py new file mode 100644 index 0000000000..41b6e071e0 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection.py @@ -0,0 +1,73 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes + from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + +class TeamConnection(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes + from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + return { + "attributes": (TeamConnectionAttributes,), + "id": (str,), + "relationships": (TeamConnectionRelationships,), + "type": (TeamConnectionType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + id: str, + type: TeamConnectionType, + attributes: Union[TeamConnectionAttributes, UnsetType] = unset, + relationships: Union[TeamConnectionRelationships, UnsetType] = unset, + **kwargs, + ): + """ + A relationship between a Datadog team and a team from another external system. + + :param attributes: Attributes of the team connection. + :type attributes: TeamConnectionAttributes, optional + + :param id: The unique identifier of the team connection. + :type id: str + + :param relationships: Relationships of the team connection. + :type relationships: TeamConnectionRelationships, optional + + :param type: Team connection resource type. + :type type: TeamConnectionType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_connection_attributes.py b/src/datadog_api_client/v2/model/team_connection_attributes.py new file mode 100644 index 0000000000..ddd81ed446 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_attributes.py @@ -0,0 +1,43 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class TeamConnectionAttributes(ModelNormal): + @cached_property + def openapi_types(_): + return { + "managed_by": (str,), + "source": (str,), + } + + attribute_map = { + "managed_by": "managed_by", + "source": "source", + } + + def __init__(self_, managed_by: Union[str, UnsetType] = unset, source: Union[str, UnsetType] = unset, **kwargs): + """ + Attributes of the team connection. + + :param managed_by: The entity that manages this team connection. + :type managed_by: str, optional + + :param source: The name of the external source. + :type source: str, optional + """ + if managed_by is not unset: + kwargs["managed_by"] = managed_by + if source is not unset: + kwargs["source"] = source + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_connection_create_data.py b/src/datadog_api_client/v2/model/team_connection_create_data.py new file mode 100644 index 0000000000..7054eabcaf --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_create_data.py @@ -0,0 +1,66 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes + from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + +class TeamConnectionCreateData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes + from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + return { + "attributes": (TeamConnectionAttributes,), + "relationships": (TeamConnectionRelationships,), + "type": (TeamConnectionType,), + } + + attribute_map = { + "attributes": "attributes", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + type: TeamConnectionType, + attributes: Union[TeamConnectionAttributes, UnsetType] = unset, + relationships: Union[TeamConnectionRelationships, UnsetType] = unset, + **kwargs, + ): + """ + Data for creating a team connection. + + :param attributes: Attributes of the team connection. + :type attributes: TeamConnectionAttributes, optional + + :param relationships: Relationships of the team connection. + :type relationships: TeamConnectionRelationships, optional + + :param type: Team connection resource type. + :type type: TeamConnectionType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_connection_create_request.py b/src/datadog_api_client/v2/model/team_connection_create_request.py new file mode 100644 index 0000000000..31ea11ba8e --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_create_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection_create_data import TeamConnectionCreateData + + +class TeamConnectionCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection_create_data import TeamConnectionCreateData + + return { + "data": ([TeamConnectionCreateData],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[TeamConnectionCreateData], **kwargs): + """ + Request for creating team connections. + + :param data: Array of team connections to create. + :type data: [TeamConnectionCreateData] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/team_connection_delete_request.py b/src/datadog_api_client/v2/model/team_connection_delete_request.py new file mode 100644 index 0000000000..c8c1eea1af --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_delete_request.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection_delete_request_data_item import TeamConnectionDeleteRequestDataItem + + +class TeamConnectionDeleteRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection_delete_request_data_item import ( + TeamConnectionDeleteRequestDataItem, + ) + + return { + "data": ([TeamConnectionDeleteRequestDataItem],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[TeamConnectionDeleteRequestDataItem], **kwargs): + """ + Request for deleting team connections. + + :param data: Array of team connection IDs to delete. + :type data: [TeamConnectionDeleteRequestDataItem] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/team_connection_delete_request_data_item.py b/src/datadog_api_client/v2/model/team_connection_delete_request_data_item.py new file mode 100644 index 0000000000..f51b978500 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_delete_request_data_item.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + +class TeamConnectionDeleteRequestDataItem(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection_type import TeamConnectionType + + return { + "id": (str,), + "type": (TeamConnectionType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: str, type: TeamConnectionType, **kwargs): + """ + A collection of connection ids to delete. + + :param id: The unique identifier of the team connection to delete. + :type id: str + + :param type: Team connection resource type. + :type type: TeamConnectionType + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_connection_relationships.py b/src/datadog_api_client/v2/model/team_connection_relationships.py new file mode 100644 index 0000000000..83b6cc86c8 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_relationships.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.connected_team_ref import ConnectedTeamRef + from datadog_api_client.v2.model.team_ref import TeamRef + + +class TeamConnectionRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.connected_team_ref import ConnectedTeamRef + from datadog_api_client.v2.model.team_ref import TeamRef + + return { + "connected_team": (ConnectedTeamRef,), + "team": (TeamRef,), + } + + attribute_map = { + "connected_team": "connected_team", + "team": "team", + } + + def __init__( + self_, + connected_team: Union[ConnectedTeamRef, UnsetType] = unset, + team: Union[TeamRef, UnsetType] = unset, + **kwargs, + ): + """ + Relationships of the team connection. + + :param connected_team: Reference to a team from an external system. + :type connected_team: ConnectedTeamRef, optional + + :param team: Reference to a Datadog team. + :type team: TeamRef, optional + """ + if connected_team is not unset: + kwargs["connected_team"] = connected_team + if team is not unset: + kwargs["team"] = team + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_connection_type.py b/src/datadog_api_client/v2/model/team_connection_type.py new file mode 100644 index 0000000000..ccb0a88f8c --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connection_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamConnectionType(ModelSimple): + """ + Team connection resource type. + + :param value: If omitted defaults to "team_connection". Must be one of ["team_connection"]. + :type value: str + """ + + allowed_values = { + "team_connection", + } + TEAM_CONNECTION: ClassVar["TeamConnectionType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamConnectionType.TEAM_CONNECTION = TeamConnectionType("team_connection") diff --git a/src/datadog_api_client/v2/model/team_connections_response.py b/src/datadog_api_client/v2/model/team_connections_response.py new file mode 100644 index 0000000000..d1c3e5b252 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_connections_response.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_connection import TeamConnection + from datadog_api_client.v2.model.connections_response_meta import ConnectionsResponseMeta + + +class TeamConnectionsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_connection import TeamConnection + from datadog_api_client.v2.model.connections_response_meta import ConnectionsResponseMeta + + return { + "data": ([TeamConnection],), + "meta": (ConnectionsResponseMeta,), + } + + attribute_map = { + "data": "data", + "meta": "meta", + } + + def __init__( + self_, + data: Union[List[TeamConnection], UnsetType] = unset, + meta: Union[ConnectionsResponseMeta, UnsetType] = unset, + **kwargs, + ): + """ + Response containing information about multiple team connections. + + :param data: Array of team connections. + :type data: [TeamConnection], optional + + :param meta: Connections response metadata. + :type meta: ConnectionsResponseMeta, optional + """ + if data is not unset: + kwargs["data"] = data + if meta is not unset: + kwargs["meta"] = meta + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_ref.py b/src/datadog_api_client/v2/model/team_ref.py new file mode 100644 index 0000000000..0e9c301bcd --- /dev/null +++ b/src/datadog_api_client/v2/model/team_ref.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_ref_data import TeamRefData + + +class TeamRef(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_ref_data import TeamRefData + + return { + "data": (TeamRefData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[TeamRefData, UnsetType] = unset, **kwargs): + """ + Reference to a Datadog team. + + :param data: Reference to a Datadog team. + :type data: TeamRefData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_ref_data.py b/src/datadog_api_client/v2/model/team_ref_data.py new file mode 100644 index 0000000000..96c2b09e00 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_ref_data.py @@ -0,0 +1,46 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_ref_data_type import TeamRefDataType + + +class TeamRefData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_ref_data_type import TeamRefDataType + + return { + "id": (str,), + "type": (TeamRefDataType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: str, type: TeamRefDataType, **kwargs): + """ + Reference to a Datadog team. + + :param id: The Datadog team ID. + :type id: str + + :param type: Datadog team resource type. + :type type: TeamRefDataType + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_ref_data_type.py b/src/datadog_api_client/v2/model/team_ref_data_type.py new file mode 100644 index 0000000000..744294555b --- /dev/null +++ b/src/datadog_api_client/v2/model/team_ref_data_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamRefDataType(ModelSimple): + """ + Datadog team resource type. + + :param value: If omitted defaults to "team". Must be one of ["team"]. + :type value: str + """ + + allowed_values = { + "team", + } + TEAM: ClassVar["TeamRefDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamRefDataType.TEAM = TeamRefDataType("team") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 317463d212..5ff8672784 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -869,10 +869,15 @@ from datadog_api_client.v2.model.confluent_resource_response_data import ConfluentResourceResponseData from datadog_api_client.v2.model.confluent_resource_type import ConfluentResourceType from datadog_api_client.v2.model.confluent_resources_response import ConfluentResourcesResponse +from datadog_api_client.v2.model.connected_team_ref import ConnectedTeamRef +from datadog_api_client.v2.model.connected_team_ref_data import ConnectedTeamRefData +from datadog_api_client.v2.model.connected_team_ref_data_type import ConnectedTeamRefDataType from datadog_api_client.v2.model.connection import Connection from datadog_api_client.v2.model.connection_env import ConnectionEnv from datadog_api_client.v2.model.connection_env_env import ConnectionEnvEnv from datadog_api_client.v2.model.connection_group import ConnectionGroup +from datadog_api_client.v2.model.connections_page_pagination import ConnectionsPagePagination +from datadog_api_client.v2.model.connections_response_meta import ConnectionsResponseMeta from datadog_api_client.v2.model.container import Container from datadog_api_client.v2.model.container_attributes import ContainerAttributes from datadog_api_client.v2.model.container_group import ContainerGroup @@ -4535,6 +4540,15 @@ from datadog_api_client.v2.model.tags_event_attribute import TagsEventAttribute from datadog_api_client.v2.model.team import Team from datadog_api_client.v2.model.team_attributes import TeamAttributes +from datadog_api_client.v2.model.team_connection import TeamConnection +from datadog_api_client.v2.model.team_connection_attributes import TeamConnectionAttributes +from datadog_api_client.v2.model.team_connection_create_data import TeamConnectionCreateData +from datadog_api_client.v2.model.team_connection_create_request import TeamConnectionCreateRequest +from datadog_api_client.v2.model.team_connection_delete_request import TeamConnectionDeleteRequest +from datadog_api_client.v2.model.team_connection_delete_request_data_item import TeamConnectionDeleteRequestDataItem +from datadog_api_client.v2.model.team_connection_relationships import TeamConnectionRelationships +from datadog_api_client.v2.model.team_connection_type import TeamConnectionType +from datadog_api_client.v2.model.team_connections_response import TeamConnectionsResponse from datadog_api_client.v2.model.team_create import TeamCreate from datadog_api_client.v2.model.team_create_attributes import TeamCreateAttributes from datadog_api_client.v2.model.team_create_relationships import TeamCreateRelationships @@ -4581,6 +4595,9 @@ from datadog_api_client.v2.model.team_permission_setting_value import TeamPermissionSettingValue from datadog_api_client.v2.model.team_permission_setting_values import TeamPermissionSettingValues from datadog_api_client.v2.model.team_permission_settings_response import TeamPermissionSettingsResponse +from datadog_api_client.v2.model.team_ref import TeamRef +from datadog_api_client.v2.model.team_ref_data import TeamRefData +from datadog_api_client.v2.model.team_ref_data_type import TeamRefDataType from datadog_api_client.v2.model.team_reference import TeamReference from datadog_api_client.v2.model.team_reference_attributes import TeamReferenceAttributes from datadog_api_client.v2.model.team_reference_type import TeamReferenceType @@ -5526,10 +5543,15 @@ "ConfluentResourceResponseData", "ConfluentResourceType", "ConfluentResourcesResponse", + "ConnectedTeamRef", + "ConnectedTeamRefData", + "ConnectedTeamRefDataType", "Connection", "ConnectionEnv", "ConnectionEnvEnv", "ConnectionGroup", + "ConnectionsPagePagination", + "ConnectionsResponseMeta", "Container", "ContainerAttributes", "ContainerGroup", @@ -8124,6 +8146,15 @@ "TagsEventAttribute", "Team", "TeamAttributes", + "TeamConnection", + "TeamConnectionAttributes", + "TeamConnectionCreateData", + "TeamConnectionCreateRequest", + "TeamConnectionDeleteRequest", + "TeamConnectionDeleteRequestDataItem", + "TeamConnectionRelationships", + "TeamConnectionType", + "TeamConnectionsResponse", "TeamCreate", "TeamCreateAttributes", "TeamCreateRelationships", @@ -8158,6 +8189,9 @@ "TeamPermissionSettingValue", "TeamPermissionSettingValues", "TeamPermissionSettingsResponse", + "TeamRef", + "TeamRefData", + "TeamRefDataType", "TeamReference", "TeamReferenceAttributes", "TeamReferenceType", diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 12852be0f2..b67e2d5adc 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -1141,6 +1141,13 @@ "tag": "Teams", "operationId": "CreateTeam" }, + { + "source": "data.data[0]", + "step": "there is a valid \"team_connection\" in the system", + "key": "team_connection", + "tag": "Team Connections", + "operationId": "CreateTeamConnections" + }, { "parameters": [ { diff --git a/tests/v2/features/team_connections.feature b/tests/v2/features/team_connections.feature new file mode 100644 index 0000000000..7bbce889e1 --- /dev/null +++ b/tests/v2/features/team_connections.feature @@ -0,0 +1,93 @@ +@endpoint(team-connections) @endpoint(team-connections-v2) +Feature: Team Connections + View and manage relationships between Datadog teams and teams from + external sources, such as GitHub. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "TeamConnections" API + + @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Bad Request" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And body with value {"data": [{"attributes": {"source": "github"}, "relationships": {"connected_team": {"data": {"id": "@MyGitHubAccount/my-team-name", "type": "github_team"}}, "team": {"data": {"type": "team"}}}, "type": "team_connection"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Conflict" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And body with value {"data": [{"attributes": {"managed_by": "github_sync", "source": "github"}, "relationships": {"connected_team": {"data": {"id": "@GitHubOrg/team-handle", "type": "github_team"}}, "team": {"data": {"id": "87654321-4321-8765-dcba-210987654321", "type": "team"}}}, "type": "team_connection"}]} + When the request is sent + Then the response status is 409 Conflict + + @skip @team:DataDog/aaa-omg + Scenario: Create team connections returns "Created" response + Given operation "CreateTeamConnections" enabled + And new "CreateTeamConnections" request + And there is a valid "dd_team" in the system + And body with value {"data": [{"type": "team_connection", "attributes": {"source": "github", "managed_by": "datadog"}, "relationships": {"team": {"data": {"id": "{{ dd_team.data.id }}", "type": "team"}}, "connected_team": {"data": {"id": "@MyGitHubAccount/my-team-name", "type": "github_team"}}}}]} + When the request is sent + Then the response status is 201 Created + And the response "data.data[0].attributes.source" is equal to "github" + And the response "data.data[0].attributes.managed_by" is equal to "datadog" + And the response "data.data[0].relationships.team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "data.data[0].relationships.connected_team.data.id" is equal to "@MyGitHubAccount/my-team-name" + And the response "data.data[0].type" is equal to "team_connection" + + @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "Bad Request" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"type": "team_connection"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "No Content" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"id": "12345678-1234-5678-9abc-123456789012", "type": "team_connection"}]} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/aaa-omg + Scenario: Delete team connections returns "Not Found" response + Given operation "DeleteTeamConnections" enabled + And new "DeleteTeamConnections" request + And body with value {"data": [{"id": "12345678-1234-5678-9abc-123456789012", "type": "team_connection"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-omg + Scenario: List team connections returns "Bad Request" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/aaa-omg + Scenario: List team connections returns "OK" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-omg @with-pagination + Scenario: List team connections returns "OK" response with pagination + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + When the request with pagination is sent + Then the response status is 200 OK + + @skip @team:DataDog/aaa-omg + Scenario: List team connections with filters returns "OK" response + Given operation "ListTeamConnections" enabled + And new "ListTeamConnections" request + And request contains "filter[sources]" parameter with value ["github"] + And request contains "page[size]" parameter with value 10 + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index cd8c18bf07..d25ca0a4db 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -4268,6 +4268,25 @@ "type": "unsafe" } }, + "DeleteTeamConnections": { + "tag": "Team Connections", + "undo": { + "type": "idempotent" + } + }, + "ListTeamConnections": { + "tag": "Team Connections", + "undo": { + "type": "safe" + } + }, + "CreateTeamConnections": { + "tag": "Team Connections", + "undo": { + "operationId": "DeleteTeamConnections", + "type": "unsafe" + } + }, "SyncTeams": { "tag": "Teams", "undo": {