Skip to content

Commit

Permalink
[ACS][GA1] Clean Commit (#36550)
Browse files Browse the repository at this point in the history
* clean commit

* Updated comments on start recording options

---------

Co-authored-by: Min Woo Lee 🧊 <[email protected]>
  • Loading branch information
minwoolee-msft and minwoolee-msft authored May 26, 2023
1 parent 7378996 commit b10a956
Show file tree
Hide file tree
Showing 204 changed files with 1,035 additions and 7,057 deletions.
25 changes: 16 additions & 9 deletions sdk/communication/Azure.Communication.CallAutomation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Release History

## 1.0.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
## 1.0.0 (2023-05-29)

### Features Added
- Outbound calls can now be created without providing a User Identifier. This value can be specified in the CallAutomationClientOption if desired.
- AnswerCall now accepts OperationContext.
- Calls can be answered by a specific communication identifier user.
- RemoveParticipant now sends success and failure events with the request.
- ParticipantsUpdated event now includes a sequence number to distinguish the ordering of events.
- CallConnectionProperties now includes CorrelationId.
- StartRecording now accepts ChannelAffinity.
- Added EventProcessor, an easy and powerful way to handle Call Automation events. See README for details.

### Breaking Changes
- AddParticipant and RemoveParticipant now only accept one participant at a time.
- CallSource has been flattened out.
- CallInvite model replaces previous models for handling outbound calls.

## 1.0.0-beta.1 (2022-11-07)
This is a refresh of Azure Communication Service's Calling-Server library. It is now called Call Automation. Call Automation enables developers to build call workflows. Personalise customer interactions by listening to call events and take actions based on your business logic. For more information, please see the [README][read_me].
Expand Down
14 changes: 7 additions & 7 deletions sdk/communication/Azure.Communication.CallAutomation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package contains a C# SDK for Azure Communication Call Automation.
Install the Azure Communication CallAutomation client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.CallAutomation --prerelease
dotnet add package Azure.Communication.CallAutomation
```

### Prerequisites
Expand Down Expand Up @@ -87,11 +87,11 @@ public IActionResult OnMidConnectionCallBackEvent([FromBody] CloudEvent[] events
# cast the event into a ParticipantUpdated event and do something with it. Eg. iterate through the participants
ParticipantsUpdated updatedEvent = (ParticipantsUpdated)ev;
break;
case AddParticipantsSucceeded ev:
# logic to handle an AddParticipantsSucceeded event
case AddParticipantSucceeded ev:
# logic to handle an AddParticipantSucceeded event
break;
case AddParticipantsFailed ev:
# logic to handle an AddParticipantsFailed event
case AddParticipantFailed ev:
# logic to handle an AddParticipantFailed event
break;
case CallTransferAccepted ev:
# logic to handle CallTransferAccepted event
Expand Down Expand Up @@ -155,10 +155,10 @@ CancellationToken token = cts.Token;
try
{
// this will wait until CreateCall is completed or Timesout!
CreateCallEventResult eventResult = await createCallResult.WaitForEventAsync(token);
CreateCallEventResult eventResult = await createCallResult.WaitForEventProcessorAsync(token);

// Once this is recieved, you know the call is now connected.
CallConnected returnedEvent = eventResult.SuccessEvent;
CallConnected returnedEvent = eventResult.SuccessResult;

// ...Do more actions, such as Play or AddParticipant, since the call is established...
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>
This client library enables working with the Microsoft Azure Communication Call Automation service.
This client library enables working with the Microsoft Azure Communication Call Automation service.
For this release, see notes - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.CallAutomation/README.md and https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.CallAutomation/CHANGELOG.md.
Microsoft Azure Communication Call Automation quickstart - https://learn.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/callflows-for-customer-interactions?pivots=programming-language-csharp
</Description>
<AssemblyTitle>Azure Communication CallAutomation Service</AssemblyTitle>
<Version>1.0.0-beta.2</Version>
<Version>1.0.0</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<PackageTags>Microsoft Azure Communication CallAutomation Service;Microsoft;Azure;Azure Communication Service;Azure Communication CallAutomation Service;Calling;Communication;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Azure.Core.Pipeline;
using Azure.Communication.Pipeline;
using System.Collections.Generic;
using System.Net;

namespace Azure.Communication.CallAutomation
{
Expand All @@ -26,7 +27,14 @@ public class CallAutomationClient
internal CallMediaRestClient CallMediaRestClient { get; }
internal CallRecordingRestClient CallRecordingRestClient { get; }
internal CallAutomationEventProcessor EventProcessor { get; }
internal CommunicationUserIdentifier Source { get; }

/// <summary>
/// CommunicationUserIdentifier that makes the outbound call.
/// This can be provided by providing CallAutomationClientOption during construction of CallAutomationClient.
/// If left blank, service will create one each request.
/// </summary>
/// <returns></returns>
public CommunicationUserIdentifier Source { get; }

#region public constructors
/// <summary> Initializes a new instance of <see cref="CallAutomationClient"/>.</summary>
Expand Down Expand Up @@ -56,17 +64,6 @@ public CallAutomationClient(Uri endpoint, TokenCredential credential, CallAutoma
Argument.CheckNotNull(credential, nameof(credential)),
options ?? new CallAutomationClientOptions())
{ }

/// <summary> Initializes a new instance of <see cref="CallAutomationClient"/> with custom PMA endpoint.</summary>
/// <param name="pmaEndpoint">Endpoint for PMA</param>
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
public CallAutomationClient(Uri pmaEndpoint, string connectionString, CallAutomationClientOptions options = default)
: this(
pmaEndpoint,
options ?? new CallAutomationClientOptions(),
ConnectionString.Parse(connectionString))
{ }
#endregion

#region private constructors
Expand All @@ -90,13 +87,6 @@ private CallAutomationClient(Uri endpoint, HttpPipeline httpPipeline, CallAutoma
EventProcessor = new CallAutomationEventProcessor();
Source = options.Source;
}

private CallAutomationClient(Uri endpoint, CallAutomationClientOptions options, ConnectionString connectionString)
: this(
endpoint: endpoint,
httpPipeline: options.CustomBuildHttpPipeline(connectionString),
options: options)
{ }
#endregion

/// <summary>Initializes a new instance of <see cref="CallAutomationClient"/> for mocking.</summary>
Expand Down Expand Up @@ -146,7 +136,7 @@ public virtual async Task<Response<AnswerCallResult>> AnswerCallAsync(AnswerCall

var answerResponse = await AzureCommunicationServicesRestClient.AnswerCallAsync(request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken)
.ConfigureAwait(false);

Expand Down Expand Up @@ -199,7 +189,7 @@ public virtual Response<AnswerCallResult> AnswerCall(AnswerCallOptions options,

var answerResponse = AzureCommunicationServicesRestClient.AnswerCall(request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken);

var result = new AnswerCallResult(GetCallConnection(answerResponse.Value.CallConnectionId), new CallConnectionProperties(answerResponse.Value));
Expand All @@ -217,24 +207,9 @@ public virtual Response<AnswerCallResult> AnswerCall(AnswerCallOptions options,

private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions options)
{
// validate callbackUri
if (!IsValidHttpsUri(options.CallbackUri))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidHttpsUriMessage);
}

AnswerCallRequestInternal request = new AnswerCallRequestInternal(options.IncomingCallContext, options.CallbackUri.AbsoluteUri);
// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
}
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
request.AnsweredByIdentifier = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);

request.AnsweredBy = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);
request.OperationContext = options.OperationContext;

return request;
Expand Down Expand Up @@ -271,14 +246,10 @@ public virtual async Task<Response> RedirectCallAsync(RedirectCallOptions option
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
var repeatabilityHeaders = new RepeatabilityHeaders();

request.CustomContext = new CustomContextInternal(
options.CallInvite.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.SipHeaders,
options.CallInvite.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.VoipHeaders);

return await AzureCommunicationServicesRestClient.RedirectCallAsync(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
).ConfigureAwait(false);
}
Expand Down Expand Up @@ -320,14 +291,10 @@ public virtual Response RedirectCall(RedirectCallOptions options, CancellationTo
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
var repeatabilityHeaders = new RepeatabilityHeaders();

request.CustomContext = new CustomContextInternal(
options.CallInvite.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.SipHeaders,
options.CallInvite.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.VoipHeaders);

return AzureCommunicationServicesRestClient.RedirectCall(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken);
}
catch (Exception ex)
Expand Down Expand Up @@ -370,7 +337,7 @@ public virtual async Task<Response> RejectCallAsync(RejectCallOptions options, C
return await AzureCommunicationServicesRestClient.RejectCallAsync(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
).ConfigureAwait(false);
}
Expand Down Expand Up @@ -414,7 +381,7 @@ public virtual Response RejectCall(RejectCallOptions options, CancellationToken
return AzureCommunicationServicesRestClient.RejectCall(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
);
}
Expand Down Expand Up @@ -466,7 +433,7 @@ public virtual async Task<Response<CreateCallResult>> CreateCallAsync(CreateCall
var createCallResponse = await AzureCommunicationServicesRestClient.CreateCallAsync(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
).ConfigureAwait(false);

Expand Down Expand Up @@ -526,7 +493,7 @@ public virtual Response<CreateCallResult> CreateCall(CreateCallOptions options,
var createCallResponse = AzureCommunicationServicesRestClient.CreateCall(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
);

Expand Down Expand Up @@ -571,7 +538,7 @@ public virtual async Task<Response<CreateCallResult>> CreateGroupCallAsync(Creat
var createCallResponse = await AzureCommunicationServicesRestClient.CreateCallAsync(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
).ConfigureAwait(false);

Expand Down Expand Up @@ -616,7 +583,7 @@ public virtual Response<CreateCallResult> CreateGroupCall(CreateGroupCallOptions
var createCallResponse = AzureCommunicationServicesRestClient.CreateCall(
request,
repeatabilityHeaders.RepeatabilityRequestId,
repeatabilityHeaders.GetRepeatabilityFirstSentString(),
repeatabilityHeaders.RepeatabilityFirstSent,
cancellationToken
);

Expand Down Expand Up @@ -645,24 +612,10 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
? null
: new PhoneNumberIdentifierModel(options?.CallInvite?.SourceCallerIdNumber?.PhoneNumber),
SourceDisplayName = options?.CallInvite?.SourceDisplayName,
SourceIdentity = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
};

request.CustomContext = new CustomContextInternal(
options.CallInvite.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.SipHeaders,
options.CallInvite.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.VoipHeaders);

// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
}
request.OperationContext = options.OperationContext;
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);

return request;
}
Expand All @@ -677,25 +630,10 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
? null
: new PhoneNumberIdentifierModel(options?.SourceCallerIdNumber?.PhoneNumber),
SourceDisplayName = options?.SourceDisplayName,
SourceIdentity = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
};

request.CustomContext = new CustomContextInternal(
options.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.SipHeaders,
options.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.VoipHeaders);

// Add custom cognitive service domain name
if (options.AzureCognitiveServicesEndpointUrl != null)
{
if (!IsValidHttpsUri(options.AzureCognitiveServicesEndpointUrl))
{
throw new ArgumentException(CallAutomationErrorMessages.InvalidCognitiveServiceHttpsUriMessage);
}
request.AzureCognitiveServicesEndpointUrl = options.AzureCognitiveServicesEndpointUrl.AbsoluteUri;
}
request.OperationContext = options.OperationContext;
request.MediaStreamingConfiguration = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);

return request;
}

Expand All @@ -711,14 +649,6 @@ private static bool IsValidHttpsUri(Uri uri) {
return Uri.IsWellFormedUriString(uriString, UriKind.Absolute) && new Uri(uriString).Scheme == Uri.UriSchemeHttps;
}

private static MediaStreamingOptionsInternal CreateMediaStreamingOptionsInternal(MediaStreamingOptions configuration)
{
return configuration == default
? default
: new MediaStreamingOptionsInternal(configuration.TransportUri.AbsoluteUri, configuration.MediaStreamingTransport, configuration.MediaStreamingContent,
configuration.MediaStreamingAudioChannel);
}

/// <summary> Initializes a new instance of CallConnection. <see cref="CallConnection"/>.</summary>
/// <param name="callConnectionId"> The call connection id for the GetCallConnection instance. </param>
public virtual CallConnection GetCallConnection(string callConnectionId)
Expand Down Expand Up @@ -767,24 +697,5 @@ public virtual CallAutomationEventProcessor GetEventProcessor()
throw;
}
}

/// <summary>
/// Get source identity used by Call Automation client.
/// </summary>
/// <returns></returns>
public virtual CommunicationUserIdentifier GetSourceIdentity()
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallAutomationClient)}.{nameof(GetSourceIdentity)}");
scope.Start();
try
{
return Source;
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}
}
}
Loading

0 comments on commit b10a956

Please sign in to comment.