diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 05ce562f5e20..5f8d776278f8 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -83879,7 +83879,7 @@ paths: - teams_read summary: Delete team connections tags: - - Team Connections + - Teams x-permission: operator: OR permissions: @@ -83958,7 +83958,7 @@ paths: - teams_read summary: List team connections tags: - - Team Connections + - Teams x-pagination: limitParam: page[size] pageParam: page[number] @@ -84002,7 +84002,7 @@ paths: - teams_read summary: Create team connections tags: - - Team Connections + - Teams x-permission: operator: OR permissions: @@ -87323,9 +87323,6 @@ 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/examples/v2/team-connections/CreateTeamConnections.ts b/examples/v2/teams/CreateTeamConnections.ts similarity index 89% rename from examples/v2/team-connections/CreateTeamConnections.ts rename to examples/v2/teams/CreateTeamConnections.ts index ade91479cf25..473d85215708 100644 --- a/examples/v2/team-connections/CreateTeamConnections.ts +++ b/examples/v2/teams/CreateTeamConnections.ts @@ -6,12 +6,12 @@ import { client, v2 } from "@datadog/datadog-api-client"; const configuration = client.createConfiguration(); configuration.unstableOperations["v2.createTeamConnections"] = true; -const apiInstance = new v2.TeamConnectionsApi(configuration); +const apiInstance = new v2.TeamsApi(configuration); // there is a valid "dd_team" in the system const DD_TEAM_DATA_ID = process.env.DD_TEAM_DATA_ID as string; -const params: v2.TeamConnectionsApiCreateTeamConnectionsRequest = { +const params: v2.TeamsApiCreateTeamConnectionsRequest = { body: { data: [ { diff --git a/examples/v2/team-connections/DeleteTeamConnections.ts b/examples/v2/teams/DeleteTeamConnections.ts similarity index 82% rename from examples/v2/team-connections/DeleteTeamConnections.ts rename to examples/v2/teams/DeleteTeamConnections.ts index 246210ff00a4..bd283ab7c4be 100644 --- a/examples/v2/team-connections/DeleteTeamConnections.ts +++ b/examples/v2/teams/DeleteTeamConnections.ts @@ -6,9 +6,9 @@ import { client, v2 } from "@datadog/datadog-api-client"; const configuration = client.createConfiguration(); configuration.unstableOperations["v2.deleteTeamConnections"] = true; -const apiInstance = new v2.TeamConnectionsApi(configuration); +const apiInstance = new v2.TeamsApi(configuration); -const params: v2.TeamConnectionsApiDeleteTeamConnectionsRequest = { +const params: v2.TeamsApiDeleteTeamConnectionsRequest = { body: { data: [ { diff --git a/examples/v2/team-connections/ListTeamConnections.ts b/examples/v2/teams/ListTeamConnections.ts similarity index 88% rename from examples/v2/team-connections/ListTeamConnections.ts rename to examples/v2/teams/ListTeamConnections.ts index 2aa4f33a1565..35894563f4c6 100644 --- a/examples/v2/team-connections/ListTeamConnections.ts +++ b/examples/v2/teams/ListTeamConnections.ts @@ -6,7 +6,7 @@ import { client, v2 } from "@datadog/datadog-api-client"; const configuration = client.createConfiguration(); configuration.unstableOperations["v2.listTeamConnections"] = true; -const apiInstance = new v2.TeamConnectionsApi(configuration); +const apiInstance = new v2.TeamsApi(configuration); apiInstance .listTeamConnections() diff --git a/examples/v2/team-connections/ListTeamConnections_1473516764.ts b/examples/v2/teams/ListTeamConnections_1473516764.ts similarity index 80% rename from examples/v2/team-connections/ListTeamConnections_1473516764.ts rename to examples/v2/teams/ListTeamConnections_1473516764.ts index 9de523cb6e1f..e36ef7086a89 100644 --- a/examples/v2/team-connections/ListTeamConnections_1473516764.ts +++ b/examples/v2/teams/ListTeamConnections_1473516764.ts @@ -6,9 +6,9 @@ import { client, v2 } from "@datadog/datadog-api-client"; const configuration = client.createConfiguration(); configuration.unstableOperations["v2.listTeamConnections"] = true; -const apiInstance = new v2.TeamConnectionsApi(configuration); +const apiInstance = new v2.TeamsApi(configuration); -const params: v2.TeamConnectionsApiListTeamConnectionsRequest = { +const params: v2.TeamsApiListTeamConnectionsRequest = { pageSize: 10, filterSources: ["github"], }; diff --git a/examples/v2/team-connections/ListTeamConnections_2418873869.ts b/examples/v2/teams/ListTeamConnections_2418873869.ts similarity index 87% rename from examples/v2/team-connections/ListTeamConnections_2418873869.ts rename to examples/v2/teams/ListTeamConnections_2418873869.ts index 7ffe51bfce9c..824ef7785c59 100644 --- a/examples/v2/team-connections/ListTeamConnections_2418873869.ts +++ b/examples/v2/teams/ListTeamConnections_2418873869.ts @@ -6,7 +6,7 @@ import { client, v2 } from "@datadog/datadog-api-client"; const configuration = client.createConfiguration(); configuration.unstableOperations["v2.listTeamConnections"] = true; -const apiInstance = new v2.TeamConnectionsApi(configuration); +const apiInstance = new v2.TeamsApi(configuration); (async () => { try { diff --git a/features/support/scenarios_model_mapping.ts b/features/support/scenarios_model_mapping.ts index 15636eec553c..a6e6678bd11f 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -8947,6 +8947,47 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "{}", }, + "v2.ListTeamConnections": { + "pageSize": { + "type": "number", + "format": "int64", + }, + "pageNumber": { + "type": "number", + "format": "int64", + }, + "filterSources": { + "type": "Array", + "format": "", + }, + "filterTeamIds": { + "type": "Array", + "format": "", + }, + "filterConnectedTeamIds": { + "type": "Array", + "format": "", + }, + "filterConnectionIds": { + "type": "Array", + "format": "", + }, + "operationResponseType": "TeamConnectionsResponse", + }, + "v2.CreateTeamConnections": { + "body": { + "type": "TeamConnectionCreateRequest", + "format": "", + }, + "operationResponseType": "TeamConnectionsResponse", + }, + "v2.DeleteTeamConnections": { + "body": { + "type": "TeamConnectionDeleteRequest", + "format": "", + }, + "operationResponseType": "{}", + }, "v2.GetTeamSync": { "filterSource": { "type": "TeamSyncAttributesSource", @@ -9171,47 +9212,6 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "UserTeamsResponse", }, - "v2.ListTeamConnections": { - "pageSize": { - "type": "number", - "format": "int64", - }, - "pageNumber": { - "type": "number", - "format": "int64", - }, - "filterSources": { - "type": "Array", - "format": "", - }, - "filterTeamIds": { - "type": "Array", - "format": "", - }, - "filterConnectedTeamIds": { - "type": "Array", - "format": "", - }, - "filterConnectionIds": { - "type": "Array", - "format": "", - }, - "operationResponseType": "TeamConnectionsResponse", - }, - "v2.CreateTeamConnections": { - "body": { - "type": "TeamConnectionCreateRequest", - "format": "", - }, - "operationResponseType": "TeamConnectionsResponse", - }, - "v2.DeleteTeamConnections": { - "body": { - "type": "TeamConnectionDeleteRequest", - "format": "", - }, - "operationResponseType": "{}", - }, "v2.ListIncidentTeams": { "include": { "type": "IncidentRelatedObject", diff --git a/features/v2/given.json b/features/v2/given.json index 6c6d3bf98f4c..d919b9834878 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -1209,7 +1209,7 @@ "source": "data.data[0]", "step": "there is a valid \"team_connection\" in the system", "key": "team_connection", - "tag": "Team Connections", + "tag": "Teams", "operationId": "CreateTeamConnections" }, { diff --git a/features/v2/team_connections.feature b/features/v2/team_connections.feature deleted file mode 100644 index 7bbce889e1ec..000000000000 --- a/features/v2/team_connections.feature +++ /dev/null @@ -1,93 +0,0 @@ -@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/features/v2/teams.feature b/features/v2/teams.feature index faa1ca0889d5..c2f52d0d96e8 100644 --- a/features/v2/teams.feature +++ b/features/v2/teams.feature @@ -115,6 +115,60 @@ Feature: Teams And the response "data.attributes.visible_modules" is equal to ["m1","m2"] And the response "data.attributes.hidden_modules" is equal to ["m3"] + @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 + @team:DataDog/aaa-omg Scenario: Get a team hierarchy link returns "API error response." response Given new "GetTeamHierarchyLink" request @@ -341,6 +395,36 @@ Feature: Teams When the request is sent Then the response status is 200 OK + @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 + + @generated @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 + @generated @skip @team:DataDog/aaa-omg Scenario: Remove a member team returns "API error response." response Given operation "RemoveMemberTeam" enabled diff --git a/features/v2/undo.json b/features/v2/undo.json index 2e54bbe0afb0..2231f8c96132 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -4494,19 +4494,19 @@ } }, "DeleteTeamConnections": { - "tag": "Team Connections", + "tag": "Teams", "undo": { "type": "idempotent" } }, "ListTeamConnections": { - "tag": "Team Connections", + "tag": "Teams", "undo": { "type": "safe" } }, "CreateTeamConnections": { - "tag": "Team Connections", + "tag": "Teams", "undo": { "operationId": "DeleteTeamConnections", "type": "unsafe" diff --git a/packages/datadog-api-client-common/configuration.ts b/packages/datadog-api-client-common/configuration.ts index d41aa2d59ddd..1d939db0ebb5 100644 --- a/packages/datadog-api-client-common/configuration.ts +++ b/packages/datadog-api-client-common/configuration.ts @@ -366,13 +366,13 @@ export function createConfiguration( "v2.createSCAResolveVulnerableSymbols": false, "v2.createSCAResult": false, "v2.addMemberTeam": false, + "v2.createTeamConnections": false, + "v2.deleteTeamConnections": false, "v2.getTeamSync": false, "v2.listMemberTeams": false, + "v2.listTeamConnections": false, "v2.removeMemberTeam": false, "v2.syncTeams": false, - "v2.createTeamConnections": false, - "v2.deleteTeamConnections": false, - "v2.listTeamConnections": false, "v2.createIncidentTeam": false, "v2.deleteIncidentTeam": false, "v2.getIncidentTeam": false, diff --git a/packages/datadog-api-client-v2/apis/TeamConnectionsApi.ts b/packages/datadog-api-client-v2/apis/TeamConnectionsApi.ts deleted file mode 100644 index cc9fda91b816..000000000000 --- a/packages/datadog-api-client-v2/apis/TeamConnectionsApi.ts +++ /dev/null @@ -1,556 +0,0 @@ -import { - BaseAPIRequestFactory, - RequiredError, -} from "../../datadog-api-client-common/baseapi"; -import { - Configuration, - applySecurityAuthentication, -} from "../../datadog-api-client-common/configuration"; -import { - RequestContext, - HttpMethod, - ResponseContext, -} from "../../datadog-api-client-common/http/http"; - -import { logger } from "../../../logger"; -import { ObjectSerializer } from "../models/ObjectSerializer"; -import { ApiException } from "../../datadog-api-client-common/exception"; - -import { APIErrorResponse } from "../models/APIErrorResponse"; -import { TeamConnection } from "../models/TeamConnection"; -import { TeamConnectionCreateRequest } from "../models/TeamConnectionCreateRequest"; -import { TeamConnectionDeleteRequest } from "../models/TeamConnectionDeleteRequest"; -import { TeamConnectionsResponse } from "../models/TeamConnectionsResponse"; - -export class TeamConnectionsApiRequestFactory extends BaseAPIRequestFactory { - public async createTeamConnections( - body: TeamConnectionCreateRequest, - _options?: Configuration - ): Promise { - const _config = _options || this.configuration; - - logger.warn("Using unstable operation 'createTeamConnections'"); - if (!_config.unstableOperations["v2.createTeamConnections"]) { - throw new Error("Unstable operation 'createTeamConnections' is disabled"); - } - - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError("body", "createTeamConnections"); - } - - // Path Params - const localVarPath = "/api/v2/team/connections"; - - // Make Request Context - const requestContext = _config - .getServer("v2.TeamConnectionsApi.createTeamConnections") - .makeRequestContext(localVarPath, HttpMethod.POST); - requestContext.setHeaderParam("Accept", "application/json"); - requestContext.setHttpConfig(_config.httpConfig); - - // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([ - "application/json", - ]); - requestContext.setHeaderParam("Content-Type", contentType); - const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "TeamConnectionCreateRequest", ""), - contentType - ); - requestContext.setBody(serializedBody); - - // Apply auth methods - applySecurityAuthentication(_config, requestContext, [ - "apiKeyAuth", - "appKeyAuth", - "AuthZ", - ]); - - return requestContext; - } - - public async deleteTeamConnections( - body: TeamConnectionDeleteRequest, - _options?: Configuration - ): Promise { - const _config = _options || this.configuration; - - logger.warn("Using unstable operation 'deleteTeamConnections'"); - if (!_config.unstableOperations["v2.deleteTeamConnections"]) { - throw new Error("Unstable operation 'deleteTeamConnections' is disabled"); - } - - // verify required parameter 'body' is not null or undefined - if (body === null || body === undefined) { - throw new RequiredError("body", "deleteTeamConnections"); - } - - // Path Params - const localVarPath = "/api/v2/team/connections"; - - // Make Request Context - const requestContext = _config - .getServer("v2.TeamConnectionsApi.deleteTeamConnections") - .makeRequestContext(localVarPath, HttpMethod.DELETE); - requestContext.setHeaderParam("Accept", "*/*"); - requestContext.setHttpConfig(_config.httpConfig); - - // Body Params - const contentType = ObjectSerializer.getPreferredMediaType([ - "application/json", - ]); - requestContext.setHeaderParam("Content-Type", contentType); - const serializedBody = ObjectSerializer.stringify( - ObjectSerializer.serialize(body, "TeamConnectionDeleteRequest", ""), - contentType - ); - requestContext.setBody(serializedBody); - - // Apply auth methods - applySecurityAuthentication(_config, requestContext, [ - "apiKeyAuth", - "appKeyAuth", - "AuthZ", - ]); - - return requestContext; - } - - public async listTeamConnections( - pageSize?: number, - pageNumber?: number, - filterSources?: Array, - filterTeamIds?: Array, - filterConnectedTeamIds?: Array, - filterConnectionIds?: Array, - _options?: Configuration - ): Promise { - const _config = _options || this.configuration; - - logger.warn("Using unstable operation 'listTeamConnections'"); - if (!_config.unstableOperations["v2.listTeamConnections"]) { - throw new Error("Unstable operation 'listTeamConnections' is disabled"); - } - - // Path Params - const localVarPath = "/api/v2/team/connections"; - - // Make Request Context - const requestContext = _config - .getServer("v2.TeamConnectionsApi.listTeamConnections") - .makeRequestContext(localVarPath, HttpMethod.GET); - requestContext.setHeaderParam("Accept", "application/json"); - requestContext.setHttpConfig(_config.httpConfig); - - // Query Params - if (pageSize !== undefined) { - requestContext.setQueryParam( - "page[size]", - ObjectSerializer.serialize(pageSize, "number", "int64"), - "" - ); - } - if (pageNumber !== undefined) { - requestContext.setQueryParam( - "page[number]", - ObjectSerializer.serialize(pageNumber, "number", "int64"), - "" - ); - } - if (filterSources !== undefined) { - requestContext.setQueryParam( - "filter[sources]", - ObjectSerializer.serialize(filterSources, "Array", ""), - "csv" - ); - } - if (filterTeamIds !== undefined) { - requestContext.setQueryParam( - "filter[team_ids]", - ObjectSerializer.serialize(filterTeamIds, "Array", ""), - "csv" - ); - } - if (filterConnectedTeamIds !== undefined) { - requestContext.setQueryParam( - "filter[connected_team_ids]", - ObjectSerializer.serialize(filterConnectedTeamIds, "Array", ""), - "csv" - ); - } - if (filterConnectionIds !== undefined) { - requestContext.setQueryParam( - "filter[connection_ids]", - ObjectSerializer.serialize(filterConnectionIds, "Array", ""), - "csv" - ); - } - - // Apply auth methods - applySecurityAuthentication(_config, requestContext, [ - "apiKeyAuth", - "appKeyAuth", - "AuthZ", - ]); - - return requestContext; - } -} - -export class TeamConnectionsApiResponseProcessor { - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to createTeamConnections - * @throws ApiException if the response code was not in [200, 299] - */ - public async createTeamConnections( - response: ResponseContext - ): Promise { - const contentType = ObjectSerializer.normalizeMediaType( - response.headers["content-type"] - ); - if (response.httpStatusCode === 201) { - const body: TeamConnectionsResponse = ObjectSerializer.deserialize( - ObjectSerializer.parse(await response.body.text(), contentType), - "TeamConnectionsResponse" - ) as TeamConnectionsResponse; - return body; - } - if ( - response.httpStatusCode === 400 || - response.httpStatusCode === 403 || - response.httpStatusCode === 409 || - response.httpStatusCode === 429 - ) { - const bodyText = ObjectSerializer.parse( - await response.body.text(), - contentType - ); - let body: APIErrorResponse; - try { - body = ObjectSerializer.deserialize( - bodyText, - "APIErrorResponse" - ) as APIErrorResponse; - } catch (error) { - logger.debug(`Got error deserializing error: ${error}`); - throw new ApiException( - response.httpStatusCode, - bodyText - ); - } - throw new ApiException(response.httpStatusCode, body); - } - - // Work around for missing responses in specification, e.g. for petstore.yaml - if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: TeamConnectionsResponse = ObjectSerializer.deserialize( - ObjectSerializer.parse(await response.body.text(), contentType), - "TeamConnectionsResponse", - "" - ) as TeamConnectionsResponse; - return body; - } - - const body = (await response.body.text()) || ""; - throw new ApiException( - response.httpStatusCode, - 'Unknown API Status Code!\nBody: "' + body + '"' - ); - } - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to deleteTeamConnections - * @throws ApiException if the response code was not in [200, 299] - */ - public async deleteTeamConnections(response: ResponseContext): Promise { - const contentType = ObjectSerializer.normalizeMediaType( - response.headers["content-type"] - ); - if (response.httpStatusCode === 204) { - return; - } - if ( - response.httpStatusCode === 400 || - response.httpStatusCode === 403 || - response.httpStatusCode === 404 || - response.httpStatusCode === 429 - ) { - const bodyText = ObjectSerializer.parse( - await response.body.text(), - contentType - ); - let body: APIErrorResponse; - try { - body = ObjectSerializer.deserialize( - bodyText, - "APIErrorResponse" - ) as APIErrorResponse; - } catch (error) { - logger.debug(`Got error deserializing error: ${error}`); - throw new ApiException( - response.httpStatusCode, - bodyText - ); - } - throw new ApiException(response.httpStatusCode, body); - } - - // Work around for missing responses in specification, e.g. for petstore.yaml - if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - return; - } - - const body = (await response.body.text()) || ""; - throw new ApiException( - response.httpStatusCode, - 'Unknown API Status Code!\nBody: "' + body + '"' - ); - } - - /** - * Unwraps the actual response sent by the server from the response context and deserializes the response content - * to the expected objects - * - * @params response Response returned by the server for a request to listTeamConnections - * @throws ApiException if the response code was not in [200, 299] - */ - public async listTeamConnections( - response: ResponseContext - ): Promise { - const contentType = ObjectSerializer.normalizeMediaType( - response.headers["content-type"] - ); - if (response.httpStatusCode === 200) { - const body: TeamConnectionsResponse = ObjectSerializer.deserialize( - ObjectSerializer.parse(await response.body.text(), contentType), - "TeamConnectionsResponse" - ) as TeamConnectionsResponse; - return body; - } - if ( - response.httpStatusCode === 400 || - response.httpStatusCode === 403 || - response.httpStatusCode === 429 - ) { - const bodyText = ObjectSerializer.parse( - await response.body.text(), - contentType - ); - let body: APIErrorResponse; - try { - body = ObjectSerializer.deserialize( - bodyText, - "APIErrorResponse" - ) as APIErrorResponse; - } catch (error) { - logger.debug(`Got error deserializing error: ${error}`); - throw new ApiException( - response.httpStatusCode, - bodyText - ); - } - throw new ApiException(response.httpStatusCode, body); - } - - // Work around for missing responses in specification, e.g. for petstore.yaml - if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: TeamConnectionsResponse = ObjectSerializer.deserialize( - ObjectSerializer.parse(await response.body.text(), contentType), - "TeamConnectionsResponse", - "" - ) as TeamConnectionsResponse; - return body; - } - - const body = (await response.body.text()) || ""; - throw new ApiException( - response.httpStatusCode, - 'Unknown API Status Code!\nBody: "' + body + '"' - ); - } -} - -export interface TeamConnectionsApiCreateTeamConnectionsRequest { - /** - * @type TeamConnectionCreateRequest - */ - body: TeamConnectionCreateRequest; -} - -export interface TeamConnectionsApiDeleteTeamConnectionsRequest { - /** - * @type TeamConnectionDeleteRequest - */ - body: TeamConnectionDeleteRequest; -} - -export interface TeamConnectionsApiListTeamConnectionsRequest { - /** - * Size for a given page. The maximum allowed value is 100. - * @type number - */ - pageSize?: number; - /** - * Specific page number to return. - * @type number - */ - pageNumber?: number; - /** - * Filter team connections by external source systems. - * @type Array - */ - filterSources?: Array; - /** - * Filter team connections by Datadog team IDs. - * @type Array - */ - filterTeamIds?: Array; - /** - * Filter team connections by connected team IDs from external systems. - * @type Array - */ - filterConnectedTeamIds?: Array; - /** - * Filter team connections by connection IDs. - * @type Array - */ - filterConnectionIds?: Array; -} - -export class TeamConnectionsApi { - private requestFactory: TeamConnectionsApiRequestFactory; - private responseProcessor: TeamConnectionsApiResponseProcessor; - private configuration: Configuration; - - public constructor( - configuration: Configuration, - requestFactory?: TeamConnectionsApiRequestFactory, - responseProcessor?: TeamConnectionsApiResponseProcessor - ) { - this.configuration = configuration; - this.requestFactory = - requestFactory || new TeamConnectionsApiRequestFactory(configuration); - this.responseProcessor = - responseProcessor || new TeamConnectionsApiResponseProcessor(); - } - - /** - * Create multiple team connections. - * @param param The request object - */ - public createTeamConnections( - param: TeamConnectionsApiCreateTeamConnectionsRequest, - options?: Configuration - ): Promise { - const requestContextPromise = this.requestFactory.createTeamConnections( - param.body, - options - ); - return requestContextPromise.then((requestContext) => { - return this.configuration.httpApi - .send(requestContext) - .then((responseContext) => { - return this.responseProcessor.createTeamConnections(responseContext); - }); - }); - } - - /** - * Delete multiple team connections. - * @param param The request object - */ - public deleteTeamConnections( - param: TeamConnectionsApiDeleteTeamConnectionsRequest, - options?: Configuration - ): Promise { - const requestContextPromise = this.requestFactory.deleteTeamConnections( - param.body, - options - ); - return requestContextPromise.then((requestContext) => { - return this.configuration.httpApi - .send(requestContext) - .then((responseContext) => { - return this.responseProcessor.deleteTeamConnections(responseContext); - }); - }); - } - - /** - * Returns all team connections. - * @param param The request object - */ - public listTeamConnections( - param: TeamConnectionsApiListTeamConnectionsRequest = {}, - options?: Configuration - ): Promise { - const requestContextPromise = this.requestFactory.listTeamConnections( - param.pageSize, - param.pageNumber, - param.filterSources, - param.filterTeamIds, - param.filterConnectedTeamIds, - param.filterConnectionIds, - options - ); - return requestContextPromise.then((requestContext) => { - return this.configuration.httpApi - .send(requestContext) - .then((responseContext) => { - return this.responseProcessor.listTeamConnections(responseContext); - }); - }); - } - - /** - * Provide a paginated version of listTeamConnections returning a generator with all the items. - */ - public async *listTeamConnectionsWithPagination( - param: TeamConnectionsApiListTeamConnectionsRequest = {}, - options?: Configuration - ): AsyncGenerator { - let pageSize = 10; - if (param.pageSize !== undefined) { - pageSize = param.pageSize; - } - param.pageSize = pageSize; - param.pageNumber = 0; - while (true) { - const requestContext = await this.requestFactory.listTeamConnections( - param.pageSize, - param.pageNumber, - param.filterSources, - param.filterTeamIds, - param.filterConnectedTeamIds, - param.filterConnectionIds, - options - ); - const responseContext = await this.configuration.httpApi.send( - requestContext - ); - - const response = await this.responseProcessor.listTeamConnections( - responseContext - ); - const responseData = response.data; - if (responseData === undefined) { - break; - } - const results = responseData; - for (const item of results) { - yield item; - } - if (results.length < pageSize) { - break; - } - param.pageNumber = param.pageNumber + 1; - } - } -} diff --git a/packages/datadog-api-client-v2/apis/TeamsApi.ts b/packages/datadog-api-client-v2/apis/TeamsApi.ts index a09d88a2dfd0..7e8cc81f5ad3 100644 --- a/packages/datadog-api-client-v2/apis/TeamsApi.ts +++ b/packages/datadog-api-client-v2/apis/TeamsApi.ts @@ -22,6 +22,10 @@ import { GetTeamMembershipsSort } from "../models/GetTeamMembershipsSort"; import { ListTeamsInclude } from "../models/ListTeamsInclude"; import { ListTeamsSort } from "../models/ListTeamsSort"; import { Team } from "../models/Team"; +import { TeamConnection } from "../models/TeamConnection"; +import { TeamConnectionCreateRequest } from "../models/TeamConnectionCreateRequest"; +import { TeamConnectionDeleteRequest } from "../models/TeamConnectionDeleteRequest"; +import { TeamConnectionsResponse } from "../models/TeamConnectionsResponse"; import { TeamCreateRequest } from "../models/TeamCreateRequest"; import { TeamHierarchyLink } from "../models/TeamHierarchyLink"; import { TeamHierarchyLinkCreateRequest } from "../models/TeamHierarchyLinkCreateRequest"; @@ -187,6 +191,53 @@ export class TeamsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async createTeamConnections( + body: TeamConnectionCreateRequest, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'createTeamConnections'"); + if (!_config.unstableOperations["v2.createTeamConnections"]) { + throw new Error("Unstable operation 'createTeamConnections' is disabled"); + } + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "createTeamConnections"); + } + + // Path Params + const localVarPath = "/api/v2/team/connections"; + + // Make Request Context + const requestContext = _config + .getServer("v2.TeamsApi.createTeamConnections") + .makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "TeamConnectionCreateRequest", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async createTeamLink( teamId: string, body: TeamLinkCreateRequest, @@ -323,6 +374,53 @@ export class TeamsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async deleteTeamConnections( + body: TeamConnectionDeleteRequest, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'deleteTeamConnections'"); + if (!_config.unstableOperations["v2.deleteTeamConnections"]) { + throw new Error("Unstable operation 'deleteTeamConnections' is disabled"); + } + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "deleteTeamConnections"); + } + + // Path Params + const localVarPath = "/api/v2/team/connections"; + + // Make Request Context + const requestContext = _config + .getServer("v2.TeamsApi.deleteTeamConnections") + .makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "TeamConnectionDeleteRequest", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async deleteTeamLink( teamId: string, linkId: string, @@ -792,6 +890,86 @@ export class TeamsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async listTeamConnections( + pageSize?: number, + pageNumber?: number, + filterSources?: Array, + filterTeamIds?: Array, + filterConnectedTeamIds?: Array, + filterConnectionIds?: Array, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'listTeamConnections'"); + if (!_config.unstableOperations["v2.listTeamConnections"]) { + throw new Error("Unstable operation 'listTeamConnections' is disabled"); + } + + // Path Params + const localVarPath = "/api/v2/team/connections"; + + // Make Request Context + const requestContext = _config + .getServer("v2.TeamsApi.listTeamConnections") + .makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Query Params + if (pageSize !== undefined) { + requestContext.setQueryParam( + "page[size]", + ObjectSerializer.serialize(pageSize, "number", "int64"), + "" + ); + } + if (pageNumber !== undefined) { + requestContext.setQueryParam( + "page[number]", + ObjectSerializer.serialize(pageNumber, "number", "int64"), + "" + ); + } + if (filterSources !== undefined) { + requestContext.setQueryParam( + "filter[sources]", + ObjectSerializer.serialize(filterSources, "Array", ""), + "csv" + ); + } + if (filterTeamIds !== undefined) { + requestContext.setQueryParam( + "filter[team_ids]", + ObjectSerializer.serialize(filterTeamIds, "Array", ""), + "csv" + ); + } + if (filterConnectedTeamIds !== undefined) { + requestContext.setQueryParam( + "filter[connected_team_ids]", + ObjectSerializer.serialize(filterConnectedTeamIds, "Array", ""), + "csv" + ); + } + if (filterConnectionIds !== undefined) { + requestContext.setQueryParam( + "filter[connection_ids]", + ObjectSerializer.serialize(filterConnectionIds, "Array", ""), + "csv" + ); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async listTeamHierarchyLinks( pageNumber?: number, pageSize?: number, @@ -1458,6 +1636,69 @@ export class TeamsApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createTeamConnections + * @throws ApiException if the response code was not in [200, 299] + */ + public async createTeamConnections( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 201) { + const body: TeamConnectionsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "TeamConnectionsResponse" + ) as TeamConnectionsResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 409 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: TeamConnectionsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "TeamConnectionsResponse", + "" + ) as TeamConnectionsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -1635,6 +1876,58 @@ export class TeamsApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteTeamConnections + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteTeamConnections(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 204) { + return; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -2289,6 +2582,68 @@ export class TeamsApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listTeamConnections + * @throws ApiException if the response code was not in [200, 299] + */ + public async listTeamConnections( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: TeamConnectionsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "TeamConnectionsResponse" + ) as TeamConnectionsResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: TeamConnectionsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "TeamConnectionsResponse", + "" + ) as TeamConnectionsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -2833,6 +3188,13 @@ export interface TeamsApiCreateTeamRequest { body: TeamCreateRequest; } +export interface TeamsApiCreateTeamConnectionsRequest { + /** + * @type TeamConnectionCreateRequest + */ + body: TeamConnectionCreateRequest; +} + export interface TeamsApiCreateTeamLinkRequest { /** * None @@ -2865,6 +3227,13 @@ export interface TeamsApiDeleteTeamRequest { teamId: string; } +export interface TeamsApiDeleteTeamConnectionsRequest { + /** + * @type TeamConnectionDeleteRequest + */ + body: TeamConnectionDeleteRequest; +} + export interface TeamsApiDeleteTeamLinkRequest { /** * None @@ -3003,6 +3372,39 @@ export interface TeamsApiListMemberTeamsRequest { fieldsTeam?: Array; } +export interface TeamsApiListTeamConnectionsRequest { + /** + * Size for a given page. The maximum allowed value is 100. + * @type number + */ + pageSize?: number; + /** + * Specific page number to return. + * @type number + */ + pageNumber?: number; + /** + * Filter team connections by external source systems. + * @type Array + */ + filterSources?: Array; + /** + * Filter team connections by Datadog team IDs. + * @type Array + */ + filterTeamIds?: Array; + /** + * Filter team connections by connected team IDs from external systems. + * @type Array + */ + filterConnectedTeamIds?: Array; + /** + * Filter team connections by connection IDs. + * @type Array + */ + filterConnectionIds?: Array; +} + export interface TeamsApiListTeamHierarchyLinksRequest { /** * Specific page number to return. @@ -3240,6 +3642,27 @@ export class TeamsApi { }); } + /** + * Create multiple team connections. + * @param param The request object + */ + public createTeamConnections( + param: TeamsApiCreateTeamConnectionsRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.createTeamConnections( + param.body, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.createTeamConnections(responseContext); + }); + }); + } + /** * Add a new link to a team. * @param param The request object @@ -3305,6 +3728,27 @@ export class TeamsApi { }); } + /** + * Delete multiple team connections. + * @param param The request object + */ + public deleteTeamConnections( + param: TeamsApiDeleteTeamConnectionsRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.deleteTeamConnections( + param.body, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.deleteTeamConnections(responseContext); + }); + }); + } + /** * Remove a link from a team. * @param param The request object @@ -3639,6 +4083,77 @@ export class TeamsApi { } } + /** + * Returns all team connections. + * @param param The request object + */ + public listTeamConnections( + param: TeamsApiListTeamConnectionsRequest = {}, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.listTeamConnections( + param.pageSize, + param.pageNumber, + param.filterSources, + param.filterTeamIds, + param.filterConnectedTeamIds, + param.filterConnectionIds, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.listTeamConnections(responseContext); + }); + }); + } + + /** + * Provide a paginated version of listTeamConnections returning a generator with all the items. + */ + public async *listTeamConnectionsWithPagination( + param: TeamsApiListTeamConnectionsRequest = {}, + options?: Configuration + ): AsyncGenerator { + let pageSize = 10; + if (param.pageSize !== undefined) { + pageSize = param.pageSize; + } + param.pageSize = pageSize; + param.pageNumber = 0; + while (true) { + const requestContext = await this.requestFactory.listTeamConnections( + param.pageSize, + param.pageNumber, + param.filterSources, + param.filterTeamIds, + param.filterConnectedTeamIds, + param.filterConnectionIds, + options + ); + const responseContext = await this.configuration.httpApi.send( + requestContext + ); + + const response = await this.responseProcessor.listTeamConnections( + responseContext + ); + const responseData = response.data; + if (responseData === undefined) { + break; + } + const results = responseData; + for (const item of results) { + yield item; + } + if (results.length < pageSize) { + break; + } + param.pageNumber = param.pageNumber + 1; + } + } + /** * List all team hierarchy links that match the provided filters. * @param param The request object diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index ed4494f4e4ac..aa06cb223e63 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -881,20 +881,15 @@ export { SyntheticsApi, } from "./apis/SyntheticsApi"; -export { - TeamConnectionsApiCreateTeamConnectionsRequest, - TeamConnectionsApiDeleteTeamConnectionsRequest, - TeamConnectionsApiListTeamConnectionsRequest, - TeamConnectionsApi, -} from "./apis/TeamConnectionsApi"; - export { TeamsApiAddMemberTeamRequest, TeamsApiAddTeamHierarchyLinkRequest, TeamsApiCreateTeamRequest, + TeamsApiCreateTeamConnectionsRequest, TeamsApiCreateTeamLinkRequest, TeamsApiCreateTeamMembershipRequest, TeamsApiDeleteTeamRequest, + TeamsApiDeleteTeamConnectionsRequest, TeamsApiDeleteTeamLinkRequest, TeamsApiDeleteTeamMembershipRequest, TeamsApiGetTeamRequest, @@ -906,6 +901,7 @@ export { TeamsApiGetTeamSyncRequest, TeamsApiGetUserMembershipsRequest, TeamsApiListMemberTeamsRequest, + TeamsApiListTeamConnectionsRequest, TeamsApiListTeamHierarchyLinksRequest, TeamsApiListTeamsRequest, TeamsApiRemoveMemberTeamRequest,