Skip to content

Commit 45d9f36

Browse files
richardcho-msftroot
andauthored
Richardcho/cancel add participant (#27165)
### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: root <root@DESKTOP-6GBNLER>
1 parent b9b04c2 commit 45d9f36

File tree

14 files changed

+582
-9
lines changed

14 files changed

+582
-9
lines changed

sdk/communication/communication-call-automation/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
"prettier": "^2.5.1",
124124
"rimraf": "^3.0.0",
125125
"sinon": "^15.0.0",
126+
"ts-node": "^10.0.0",
126127
"typescript": "~5.0.0",
127-
"util": "^0.12.1",
128-
"ts-node": "^10.0.0"
128+
"util": "^0.12.1"
129129
}
130130
}

sdk/communication/communication-call-automation/review/communication-call-automation.api.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ import { OperationOptions } from '@azure/core-client';
1616
import { PhoneNumberIdentifier } from '@azure/communication-common';
1717
import { TokenCredential } from '@azure/core-auth';
1818

19+
// @public
20+
export interface AddParticipantCancelled extends Omit<RestAddParticipantCancelled, "callConnectionId" | "serverCallId" | "correlationId" | "participant" | "invitationId" | "operationContext"> {
21+
callConnectionId: string;
22+
correlationId: string;
23+
invitationId: string;
24+
kind: "AddParticipantCancelled";
25+
operationContext?: string;
26+
participant?: CommunicationIdentifier;
27+
serverCallId: string;
28+
}
29+
1930
// @public
2031
export interface AddParticipantFailed extends Omit<RestAddParticipantFailed, "callConnectionId" | "serverCallId" | "correlationId" | "participant" | "resultInformation"> {
2132
callConnectionId: string;
@@ -35,6 +46,7 @@ export interface AddParticipantOptions extends OperationOptions {
3546

3647
// @public
3748
export interface AddParticipantResult {
49+
invitationId?: string;
3850
operationContext?: string;
3951
participant?: CallParticipant;
4052
}
@@ -81,7 +93,7 @@ export interface CallAutomationClientOptions extends CommonClientOptions {
8193
}
8294

8395
// @public
84-
export type CallAutomationEvent = AddParticipantSucceeded | AddParticipantFailed | RemoveParticipantSucceeded | RemoveParticipantFailed | CallConnected | CallDisconnected | CallTransferAccepted | CallTransferFailed | ParticipantsUpdated | RecordingStateChanged | PlayCompleted | PlayFailed | PlayCanceled | RecognizeCompleted | RecognizeCanceled | RecognizeFailed | ContinuousDtmfRecognitionToneReceived | ContinuousDtmfRecognitionToneFailed | ContinuousDtmfRecognitionStopped | SendDtmfCompleted | SendDtmfFailed;
96+
export type CallAutomationEvent = AddParticipantSucceeded | AddParticipantFailed | RemoveParticipantSucceeded | RemoveParticipantFailed | CallConnected | CallDisconnected | CallTransferAccepted | CallTransferFailed | ParticipantsUpdated | RecordingStateChanged | PlayCompleted | PlayFailed | PlayCanceled | RecognizeCompleted | RecognizeCanceled | RecognizeFailed | ContinuousDtmfRecognitionToneReceived | ContinuousDtmfRecognitionToneFailed | ContinuousDtmfRecognitionStopped | SendDtmfCompleted | SendDtmfFailed | AddParticipantCancelled | CancelAddParticipantFailed;
8597

8698
// @public
8799
export interface CallConnected extends Omit<RestCallConnected, "callConnectionId" | "serverCallId" | "correlationId"> {
@@ -96,6 +108,7 @@ export class CallConnection {
96108
// Warning: (ae-forgotten-export) The symbol "CallAutomationApiClientOptionalParams" needs to be exported by the entry point index.d.ts
97109
constructor(callConnectionId: string, endpoint: string, credential: KeyCredential | TokenCredential, options?: CallAutomationApiClientOptionalParams);
98110
addParticipant(targetParticipant: CallInvite, options?: AddParticipantOptions): Promise<AddParticipantResult>;
111+
cancelAddParticipant(invitationId: string, options?: CancelAddParticipantOptions): Promise<CancelAddParticipantResult>;
99112
getCallConnectionProperties(options?: GetCallConnectionPropertiesOptions): Promise<CallConnectionProperties>;
100113
getCallMedia(): CallMedia;
101114
getParticipant(targetParticipant: CommunicationIdentifier, options?: GetParticipantOptions): Promise<CallParticipant>;
@@ -259,6 +272,29 @@ export interface CallTransferFailed extends Omit<RestCallTransferFailed, "callCo
259272
serverCallId: string;
260273
}
261274

275+
// @public
276+
export interface CancelAddParticipantFailed extends Omit<RestCancelAddParticipantFailed, "callConnectionId" | "serverCallId" | "correlationId" | "invitationId" | "operationContext" | "resultInformation"> {
277+
callConnectionId: string;
278+
correlationId: string;
279+
invitationId: string;
280+
kind: "CancelAddParticipantFailed";
281+
operationContext?: string;
282+
resultInformation?: ResultInformation;
283+
serverCallId: string;
284+
}
285+
286+
// @public
287+
export interface CancelAddParticipantOptions extends OperationOptions {
288+
callbackUrl?: string;
289+
operationContext?: string;
290+
}
291+
292+
// @public
293+
export interface CancelAddParticipantResult {
294+
invitationId: string;
295+
operationContext?: string;
296+
}
297+
262298
// @public
263299
export interface ChannelAffinity {
264300
channel?: number;
@@ -618,12 +654,22 @@ export interface RemoveParticipantSucceeded extends Omit<RestRemoveParticipantSu
618654
}
619655

620656
// @public
621-
export interface RestAddParticipantFailed {
657+
export interface RestAddParticipantCancelled {
622658
callConnectionId?: string;
623659
correlationId?: string;
660+
invitationId?: string;
624661
operationContext?: string;
625662
// Warning: (ae-forgotten-export) The symbol "CommunicationIdentifierModel" needs to be exported by the entry point index.d.ts
626663
participant?: CommunicationIdentifierModel;
664+
serverCallId?: string;
665+
}
666+
667+
// @public
668+
export interface RestAddParticipantFailed {
669+
callConnectionId?: string;
670+
correlationId?: string;
671+
operationContext?: string;
672+
participant?: CommunicationIdentifierModel;
627673
resultInformation?: RestResultInformation;
628674
serverCallId?: string;
629675
}
@@ -674,6 +720,16 @@ export interface RestCallTransferFailed {
674720
serverCallId?: string;
675721
}
676722

723+
// @public
724+
export interface RestCancelAddParticipantFailed {
725+
callConnectionId?: string;
726+
correlationId?: string;
727+
invitationId?: string;
728+
operationContext?: string;
729+
resultInformation?: RestResultInformation;
730+
serverCallId?: string;
731+
}
732+
677733
// @public (undocumented)
678734
export interface RestContinuousDtmfRecognitionStopped {
679735
callConnectionId?: string;

sdk/communication/communication-call-automation/src/callAutomationEventParser.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
ContinuousDtmfRecognitionStopped,
2929
SendDtmfCompleted,
3030
SendDtmfFailed,
31+
AddParticipantCancelled,
32+
CancelAddParticipantFailed,
3133
} from "./models/events";
3234

3335
import { CloudEventMapper } from "./models/mapper";
@@ -126,6 +128,13 @@ export function parseCallAutomationEvent(
126128
case "Microsoft.Communication.SendDtmfFailed":
127129
callbackEvent = { kind: "SendDtmfFailed" } as SendDtmfFailed;
128130
break;
131+
case "Microsoft.Communication.AddParticipantCancelled":
132+
callbackEvent = { kind: "AddParticipantCancelled" } as AddParticipantCancelled;
133+
parsed.participant = communicationIdentifierConverter(data.participant);
134+
break;
135+
case "Microsoft.Communication.CancelAddParticipantFailed":
136+
callbackEvent = { kind: "CancelAddParticipantFailed" } as CancelAddParticipantFailed;
137+
break;
129138
default:
130139
throw new TypeError(`Unknown Call Automation Event type: ${eventType}`);
131140
}

sdk/communication/communication-call-automation/src/callConnection.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { CallConnectionImpl } from "./generated/src/operations";
1818
import { CallConnectionProperties, CallInvite, CallParticipant } from "./models/models";
1919
import {
2020
AddParticipantOptions,
21+
CancelAddParticipantOptions,
2122
GetCallConnectionPropertiesOptions,
2223
GetParticipantOptions,
2324
HangUpOptions,
@@ -31,6 +32,7 @@ import {
3132
AddParticipantResult,
3233
RemoveParticipantResult,
3334
MuteParticipantsResult,
35+
CancelAddParticipantResult,
3436
} from "./models/responses";
3537
import {
3638
callParticipantConverter,
@@ -301,4 +303,31 @@ export class CallConnection {
301303
};
302304
return muteParticipantsResult;
303305
}
306+
307+
/** Cancel add participant request.
308+
*
309+
* @param invitationId - Invitation ID used to cancel the add participant request.
310+
*/
311+
public cancelAddParticipant(
312+
invitationId: string,
313+
options: CancelAddParticipantOptions = {}
314+
): Promise<CancelAddParticipantResult> {
315+
const { operationContext, callbackUrl: callbackUri, ...operationOptions } = options;
316+
const cancelAddParticipantRequest = {
317+
invitationId,
318+
operationContext,
319+
callbackUri,
320+
};
321+
const optionsInternal = {
322+
...operationOptions,
323+
repeatabilityFirstSent: new Date(),
324+
repeatabilityRequestID: uuidv4(),
325+
};
326+
327+
return this.callConnection.cancelAddParticipant(
328+
this.callConnectionId,
329+
cancelAddParticipantRequest,
330+
optionsInternal
331+
) as Promise<CancelAddParticipantResult>;
332+
}
304333
}

sdk/communication/communication-call-automation/src/generated/src/models/index.ts

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)