Skip to content

Commit d056e18

Browse files
Added OPS outgoing call (Azure#46816)
* Added OPS outgoing call * updated API * updated callInvite
1 parent 4f733df commit d056e18

File tree

10 files changed

+138
-14
lines changed

10 files changed

+138
-14
lines changed

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public CallAutomationClient(string connectionString, Azure.Communication.CallAut
112112
public CallAutomationClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Communication.CallAutomation.CallAutomationClientOptions options = null) { }
113113
public CallAutomationClient(System.Uri pmaEndpoint, string connectionString, Azure.Communication.CallAutomation.CallAutomationClientOptions options = null) { }
114114
public CallAutomationClient(System.Uri pmaEndpoint, System.Uri acsEndpoint, Azure.Core.TokenCredential credential, Azure.Communication.CallAutomation.CallAutomationClientOptions options = null) { }
115+
public Azure.Communication.MicrosoftTeamsAppIdentifier OPSSource { get { throw null; } }
115116
public Azure.Communication.CommunicationUserIdentifier Source { get { throw null; } }
116117
public virtual Azure.Response<Azure.Communication.CallAutomation.AnswerCallResult> AnswerCall(Azure.Communication.CallAutomation.AnswerCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
117118
public virtual Azure.Response<Azure.Communication.CallAutomation.AnswerCallResult> AnswerCall(string incomingCallContext, System.Uri callbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -138,6 +139,7 @@ public CallAutomationClient(System.Uri pmaEndpoint, System.Uri acsEndpoint, Azur
138139
public partial class CallAutomationClientOptions : Azure.Core.ClientOptions
139140
{
140141
public CallAutomationClientOptions(Azure.Communication.CallAutomation.CallAutomationClientOptions.ServiceVersion version = Azure.Communication.CallAutomation.CallAutomationClientOptions.ServiceVersion.V2023_10_03_Preview) { }
142+
public Azure.Communication.MicrosoftTeamsAppIdentifier OPSSource { get { throw null; } set { } }
141143
public Azure.Communication.CommunicationUserIdentifier Source { get { throw null; } set { } }
142144
public enum ServiceVersion
143145
{
@@ -341,6 +343,7 @@ public CallIntelligenceOptions() { }
341343
public partial class CallInvite
342344
{
343345
public CallInvite(Azure.Communication.CommunicationUserIdentifier targetIdentity) { }
346+
public CallInvite(Azure.Communication.MicrosoftTeamsAppIdentifier targetIdentity) { }
344347
public CallInvite(Azure.Communication.MicrosoftTeamsUserIdentifier targetIdentity) { }
345348
public CallInvite(Azure.Communication.PhoneNumberIdentifier targetPhoneNumberIdentity, Azure.Communication.PhoneNumberIdentifier callerIdNumber) { }
346349
public Azure.Communication.CallAutomation.CustomCallingContext CustomCallingContext { get { throw null; } }

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ public class CallAutomationClient
3636
/// </summary>
3737
public CommunicationUserIdentifier Source { get; }
3838

39+
/// <summary>
40+
/// MicrosoftTeamsAppIdentifier that makes the outbound call.
41+
/// This can be provided by providing CallAutomationClientOption during construction of CallAutomationClient.
42+
/// If left blank, Source is the default outbound call identity.
43+
/// This should be mutual exclusive with Source.
44+
/// </summary>
45+
public MicrosoftTeamsAppIdentifier OPSSource { get; }
46+
3947
#region public constructors
4048
/// <summary> Initializes a new instance of <see cref="CallAutomationClient"/>.</summary>
4149
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
@@ -119,6 +127,7 @@ private CallAutomationClient(Uri endpoint, HttpPipeline httpPipeline, CallAutoma
119127
CallDialogRestClient = new CallDialogRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion);
120128
EventProcessor = new CallAutomationEventProcessor();
121129
Source = options.Source;
130+
OPSSource = options.OPSSource;
122131
}
123132

124133
private CallAutomationClient(
@@ -620,6 +629,7 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
620629
: new PhoneNumberIdentifierModel(options?.CallInvite?.SourceCallerIdNumber?.PhoneNumber),
621630
SourceDisplayName = options?.CallInvite?.SourceDisplayName,
622631
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
632+
OpsSource = OPSSource == null ? null : new MicrosoftTeamsAppIdentifierModel(OPSSource.AppId),
623633
};
624634

625635
request.CustomCallingContext = new CustomCallingContextInternal(
@@ -654,6 +664,7 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
654664
: new PhoneNumberIdentifierModel(options?.SourceCallerIdNumber?.PhoneNumber),
655665
SourceDisplayName = options?.SourceDisplayName,
656666
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
667+
OpsSource = OPSSource == null ? null : new MicrosoftTeamsAppIdentifierModel(OPSSource.AppId)
657668
};
658669

659670
request.CustomCallingContext = new CustomCallingContextInternal(

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationClientOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ public class CallAutomationClientOptions : ClientOptions
2222

2323
/// <summary>
2424
/// The caller source of the call automation client.
25+
/// Mutual exclusive with <see cref="OPSSource"/>.
2526
/// </summary>
2627
public CommunicationUserIdentifier Source { get; set; }
2728

29+
/// <summary>
30+
/// The One Phone System caller source of the call automation client.
31+
/// Mutual exclusive with <see cref="Source"/>.
32+
/// </summary>
33+
public MicrosoftTeamsAppIdentifier OPSSource { get; set; }
34+
2835
/// <summary>
2936
/// Initializes a new instance of the <see cref="CallAutomationClientOptions"/>.
3037
/// </summary>

sdk/communication/Azure.Communication.CallAutomation/src/Generated/CallDialogRestClient.cs

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

sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CreateCallRequestInternal.Serialization.cs

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

sdk/communication/Azure.Communication.CallAutomation/src/Generated/Models/CreateCallRequestInternal.cs

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.CallAutomation/src/Models/CallInvite.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public CallInvite(MicrosoftTeamsUserIdentifier targetIdentity)
4242
CustomCallingContext = new CustomCallingContext(sipHeaders: null, voipHeaders: new Dictionary<string, string>());
4343
}
4444

45+
/// <summary>
46+
/// Creates a new CallInvite object.
47+
/// </summary>
48+
/// <param name="targetIdentity"></param>
49+
public CallInvite(MicrosoftTeamsAppIdentifier targetIdentity)
50+
{
51+
Target = targetIdentity;
52+
CustomCallingContext = new CustomCallingContext(sipHeaders: null, voipHeaders: new Dictionary<string, string>());
53+
}
54+
4555
/// <summary>
4656
/// The target callee.
4757
/// </summary>

sdk/communication/Azure.Communication.CallAutomation/src/autorest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ model-namespace: false
1010
tag: package-2023-10-03-preview
1111

1212
require:
13-
- https://github.com/Azure/azure-rest-api-specs/blob/73e737262249936932d2f7a3e3c400ce2b14a92c/specification/communication/data-plane/CallAutomation/readme.md
13+
- https://github.com/Azure/azure-rest-api-specs/blob/be2a0fa68829fcb15c4e6b47aa6bc4bdd566c1cf/specification/communication/data-plane/CallAutomation/readme.md
1414

1515

1616
title: Azure Communication Services

sdk/communication/Azure.Communication.CallAutomation/tests/CallAutomationClients/CallAutomationClientTests.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,38 @@ public void CreateCall_201Created(CallInvite target, Uri callbackUri)
235235
Assert.AreEqual(CallConnectionId, result.CallConnection.CallConnectionId);
236236
}
237237

238+
[TestCaseSource(nameof(TestData_CreateCall))]
239+
public async Task CreateCallWithOPSSourceAsync_201Created(CallInvite target, Uri callbackUri)
240+
{
241+
CallAutomationClient callAutomationClient = CreateMockCallAutomationClient(201, CreateOrAnswerCallOrGetCallConnectionPayloadForOPSCall, isOPSCall:true);
242+
243+
var options = new CreateCallOptions(target, callbackUri);
244+
var response = await callAutomationClient.CreateCallAsync(options).ConfigureAwait(false);
245+
CreateCallResult result = (CreateCallResult)response;
246+
Assert.NotNull(result);
247+
Assert.AreEqual((int)HttpStatusCode.Created, response.GetRawResponse().Status);
248+
verifyOPSCallConnectionProperties(result.CallConnectionProperties);
249+
Assert.Null(result.CallConnectionProperties.MediaSubscriptionId);
250+
Assert.Null(result.CallConnectionProperties.DataSubscriptionId);
251+
Assert.AreEqual(CallConnectionId, result.CallConnection.CallConnectionId);
252+
}
253+
254+
[TestCaseSource(nameof(TestData_CreateCall))]
255+
public void CreateCallWithOPSSource_201Created(CallInvite target, Uri callbackUri)
256+
{
257+
CallAutomationClient callAutomationClient = CreateMockCallAutomationClient(201, CreateOrAnswerCallOrGetCallConnectionPayloadForOPSCall, isOPSCall: true);
258+
259+
var options = new CreateCallOptions(target, callbackUri);
260+
var response = callAutomationClient.CreateCall(options);
261+
CreateCallResult result = (CreateCallResult)response;
262+
Assert.NotNull(result);
263+
Assert.AreEqual((int)HttpStatusCode.Created, response.GetRawResponse().Status);
264+
verifyOPSCallConnectionProperties(result.CallConnectionProperties);
265+
Assert.Null(result.CallConnectionProperties.MediaSubscriptionId);
266+
Assert.Null(result.CallConnectionProperties.DataSubscriptionId);
267+
Assert.AreEqual(CallConnectionId, result.CallConnection.CallConnectionId);
268+
}
269+
238270
[TestCaseSource(nameof(TestData_CreateCall))]
239271
public async Task CreateCallWithOptionsAsync_201Created(CallInvite target, Uri callbackUri)
240272
{
@@ -415,7 +447,19 @@ private static void ValidateCallConnectionProperties(CallConnectionProperties pr
415447
{
416448
new object?[]
417449
{
418-
new CallInvite(new CommunicationUserIdentifier("12345")),
450+
new CallInvite(new CommunicationUserIdentifier("8:acs:12345")),
451+
new Uri("https://bot.contoso.com/callback")
452+
},
453+
};
454+
}
455+
456+
private static IEnumerable<object?[]> TestData_CreateOPSCall()
457+
{
458+
return new[]
459+
{
460+
new object?[]
461+
{
462+
new CallInvite(new MicrosoftTeamsAppIdentifier("28:acs:12345")),
419463
new Uri("https://bot.contoso.com/callback")
420464
},
421465
};

0 commit comments

Comments
 (0)