UNPKG

@azure/communication-call-automation

Version:
402 lines 15.1 kB
/* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib"; import { setContinuationToken } from "../pagingHelper.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing CallConnection operations. */ export class CallConnectionImpl { /** * Initialize a new instance of the class CallConnection class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Get participants from a call. Recording and transcription bots are omitted from this list. * @param callConnectionId The call connection Id * @param options The options parameters. */ listParticipants(callConnectionId, options) { const iter = this.getParticipantsPagingAll(callConnectionId, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.getParticipantsPagingPage(callConnectionId, options, settings); }, }; } getParticipantsPagingPage(callConnectionId, options, settings) { return __asyncGenerator(this, arguments, function* getParticipantsPagingPage_1() { let result; let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken; if (!continuationToken) { result = yield __await(this._getParticipants(callConnectionId, options)); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield yield __await(page); } while (continuationToken) { result = yield __await(this._getParticipantsNext(callConnectionId, continuationToken, options)); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield yield __await(page); } }); } getParticipantsPagingAll(callConnectionId, options) { return __asyncGenerator(this, arguments, function* getParticipantsPagingAll_1() { var _a, e_1, _b, _c; try { for (var _d = true, _e = __asyncValues(this.getParticipantsPagingPage(callConnectionId, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const page = _c; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e)); } finally { if (e_1) throw e_1.error; } } }); } /** * Get the detail properties of an ongoing call. * @param callConnectionId The call connection id. * @param options The options parameters. */ getCall(callConnectionId, options) { return this.client.sendOperationRequest({ callConnectionId, options }, getCallOperationSpec); } /** * Hang up call automation service from the call. This will make call automation service leave the * call, but does not terminate if there are more than 1 caller in the call. * @param callConnectionId The call connection id. * @param options The options parameters. */ hangupCall(callConnectionId, options) { return this.client.sendOperationRequest({ callConnectionId, options }, hangupCallOperationSpec); } /** * Terminate a call using CallConnectionId. * @param callConnectionId The terminate call request. * @param options The options parameters. */ terminateCall(callConnectionId, options) { return this.client.sendOperationRequest({ callConnectionId, options }, terminateCallOperationSpec); } /** * Transfer the call to a participant. * @param callConnectionId The call connection id. * @param transferToParticipantRequest The transfer to participant request. * @param options The options parameters. */ transferToParticipant(callConnectionId, transferToParticipantRequest, options) { return this.client.sendOperationRequest({ callConnectionId, transferToParticipantRequest, options }, transferToParticipantOperationSpec); } /** * Get participants from a call. Recording and transcription bots are omitted from this list. * @param callConnectionId The call connection Id * @param options The options parameters. */ _getParticipants(callConnectionId, options) { return this.client.sendOperationRequest({ callConnectionId, options }, getParticipantsOperationSpec); } /** * Add a participant to the call. * @param callConnectionId The call connection Id * @param addParticipantRequest The request payload for adding participant to the call. * @param options The options parameters. */ addParticipant(callConnectionId, addParticipantRequest, options) { return this.client.sendOperationRequest({ callConnectionId, addParticipantRequest, options }, addParticipantOperationSpec); } /** * Remove a participant from the call using identifier. * @param callConnectionId The call connection id. * @param removeParticipantRequest The participant to be removed from the call. * @param options The options parameters. */ removeParticipant(callConnectionId, removeParticipantRequest, options) { return this.client.sendOperationRequest({ callConnectionId, removeParticipantRequest, options }, removeParticipantOperationSpec); } /** * Mute participants from the call using identifier. * @param callConnectionId The call connection id. * @param muteParticipantsRequest The participants to be muted from the call. * @param options The options parameters. */ mute(callConnectionId, muteParticipantsRequest, options) { return this.client.sendOperationRequest({ callConnectionId, muteParticipantsRequest, options }, muteOperationSpec); } /** * Cancel add participant operation. * @param callConnectionId The call connection Id * @param cancelAddParticipantRequest Cancellation request. * @param options The options parameters. */ cancelAddParticipant(callConnectionId, cancelAddParticipantRequest, options) { return this.client.sendOperationRequest({ callConnectionId, cancelAddParticipantRequest, options }, cancelAddParticipantOperationSpec); } /** * Get participant from a call. * @param callConnectionId The call connection Id * @param participantRawId Raw id of the participant to retrieve. * @param options The options parameters. */ getParticipant(callConnectionId, participantRawId, options) { return this.client.sendOperationRequest({ callConnectionId, participantRawId, options }, getParticipantOperationSpec); } /** * GetParticipantsNext * @param callConnectionId The call connection Id * @param nextLink The nextLink from the previous successful call to the GetParticipants method. * @param options The options parameters. */ _getParticipantsNext(callConnectionId, nextLink, options) { return this.client.sendOperationRequest({ callConnectionId, nextLink, options }, getParticipantsNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CallConnectionPropertiesInternal, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer, }; const hangupCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}", httpMethod: "DELETE", responses: { 204: {}, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer, }; const terminateCallOperationSpec = { path: "/calling/callConnections/{callConnectionId}:terminate", httpMethod: "POST", responses: { 204: {}, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], serializer, }; const transferToParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}:transferToParticipant", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.TransferCallResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, requestBody: Parameters.transferToParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], mediaType: "json", serializer, }; const getParticipantsOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GetParticipantsResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [Parameters.accept], serializer, }; const addParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:add", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.AddParticipantResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, requestBody: Parameters.addParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], mediaType: "json", serializer, }; const removeParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:remove", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.RemoveParticipantResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, requestBody: Parameters.removeParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], mediaType: "json", serializer, }; const muteOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:mute", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.MuteParticipantsResult, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, requestBody: Parameters.muteParticipantsRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], mediaType: "json", serializer, }; const cancelAddParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants:cancelAddParticipant", httpMethod: "POST", responses: { 202: { bodyMapper: Mappers.CancelAddParticipantResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, requestBody: Parameters.cancelAddParticipantRequest, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint, Parameters.callConnectionId], headerParameters: [ Parameters.contentType, Parameters.accept, Parameters.repeatabilityRequestID, Parameters.repeatabilityFirstSent, ], mediaType: "json", serializer, }; const getParticipantOperationSpec = { path: "/calling/callConnections/{callConnectionId}/participants/{participantRawId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CallParticipantInternal, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.endpoint, Parameters.callConnectionId, Parameters.participantRawId, ], headerParameters: [Parameters.accept], serializer, }; const getParticipantsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GetParticipantsResponse, }, default: { bodyMapper: Mappers.CommunicationErrorResponse, }, }, urlParameters: [ Parameters.endpoint, Parameters.callConnectionId, Parameters.nextLink, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=callConnection.js.map