Skip to content

CallAutomationClient PMA Endpoint Constructors #50163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f3ff2ae
Adding the ga5 changes
v-dharmarajv May 2, 2025
89d27bd
updating the azure board review comments
v-dharmarajv May 6, 2025
62cf3da
updating the version
v-dharmarajv May 6, 2025
a7c6412
Fixing the apiviews
v-dharmarajv May 13, 2025
0ea0a17
updating the answer failed comment
v-dharmarajv May 13, 2025
ab052f8
ARB Comments GA5 Changes (#50124)
v-saasomani May 20, 2025
a1eeb0d
addressing comments
v-dharmarajv May 20, 2025
b5a1eff
addressing comments
v-dharmarajv May 20, 2025
83d49c4
Added constructors for pma endpoint.
v-saasomani May 20, 2025
4c2382d
Exported API.
v-saasomani May 20, 2025
b4a0a71
Added dtmf data in streaming data parser and added unit test. (#49992)
v-pivamshi May 21, 2025
d89b55d
fixing the connect failed event serializer error
v-dharmarajv May 22, 2025
012f2ec
Merge branch 'callautomation/release/ga5' into users/v-saasomani/ga5/…
v-dharmarajv May 22, 2025
c7ac817
fixing the media streaming error
v-dharmarajv May 22, 2025
8d47ef3
Merge branch 'callautomation/release/ga5' into users/v-saasomani/ga5/…
v-dharmarajv May 22, 2025
0c985f6
Rerecorded media streaming and transcription tests.
v-saasomani May 22, 2025
eefe834
Adding the locale in the transcription subscription
v-dharmarajv May 22, 2025
57e3168
Merge branch 'callautomation/release/ga5' into users/v-saasomani/ga5/…
v-dharmarajv May 22, 2025
4fde7f2
Re-recorded ChoiceRecognizeWithCombinationOfTextAndFileSourcesTest.
v-saasomani May 22, 2025
404fce8
removing the required fields for the transport url
v-dharmarajv May 23, 2025
6eed59e
Merge branch 'callautomation/release/ga5' into users/v-saasomani/ga5/…
v-dharmarajv May 23, 2025
ce338a6
Merge branch 'users/v-saasomani/ga5/alpha-release' of https://github.…
v-dharmarajv May 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/communication/Azure.Communication.CallAutomation",
"Tag": "net/communication/Azure.Communication.CallAutomation_fdf269ce94"
"Tag": "net/communication/Azure.Communication.CallAutomation_13e45d1662"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class CallAutomationClient
internal AzureCommunicationServicesRestClient AzureCommunicationServicesRestClient { get; }
internal CallMediaRestClient CallMediaRestClient { get; }
internal CallRecordingRestClient CallRecordingRestClient { get; }
internal CallDialogRestClient CallDialogRestClient { get; }
internal CallAutomationEventProcessor EventProcessor { get; }

/// <summary>
Expand Down Expand Up @@ -115,17 +114,16 @@ private CallAutomationClient(Uri endpoint, HttpPipeline httpPipeline, CallAutoma
CallConnectionRestClient = new CallConnectionRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion);
CallMediaRestClient = new CallMediaRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion);
CallRecordingRestClient = new CallRecordingRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion);
CallDialogRestClient = new CallDialogRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion);
EventProcessor = new CallAutomationEventProcessor();
Source = options.Source;
}

private CallAutomationClient(
Uri pmaEndpoint,
Uri acsEndpoint,
CallAutomationClientOptions options,
TokenCredential tokenCredential)
: this(pmaEndpoint, options.CustomBuildHttpPipeline(acsEndpoint, tokenCredential), options)
Uri pmaEndpoint,
Uri acsEndpoint,
CallAutomationClientOptions options,
TokenCredential tokenCredential)
: this(pmaEndpoint, options.CustomBuildHttpPipeline(acsEndpoint, tokenCredential), options)
{ }
#endregion

Expand Down Expand Up @@ -242,24 +240,15 @@ private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions opti
AnswerCallRequestInternal request = new AnswerCallRequestInternal(options.IncomingCallContext, options.CallbackUri.AbsoluteUri);

// Add CallIntelligenceOptions such as custom cognitive service domain name
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
string backupCognitiveServicesEndpoint = options.CallIntelligenceOptions?.BackupCognitiveServicesEndpoint?.AbsoluteUri;
if (!string.IsNullOrWhiteSpace(cognitiveServicesEndpoint))
request.CallIntelligenceOptions = new()
{
request.CallIntelligenceOptions = new()
{
CognitiveServicesEndpoint = cognitiveServicesEndpoint,
BackupCognitiveServicesEndpoint = backupCognitiveServicesEndpoint
};
}
CognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri
};

request.MediaStreamingOptions = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
request.TranscriptionOptions = CreateTranscriptionOptionsInternal(options.TranscriptionOptions);
request.AnsweredBy = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id);
request.OperationContext = options.OperationContext;
request.CustomCallingContext = new CustomCallingContextInternal(
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>());

return request;
}
Expand Down Expand Up @@ -293,11 +282,6 @@ public virtual async Task<Response> RedirectCallAsync(RedirectCallOptions option
throw new ArgumentNullException(nameof(options));

RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));

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

return await AzureCommunicationServicesRestClient.RedirectCallAsync(request, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
Expand Down Expand Up @@ -337,10 +321,6 @@ public virtual Response RedirectCall(RedirectCallOptions options, CancellationTo

RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));

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

return AzureCommunicationServicesRestClient.RedirectCall(request, cancellationToken);
}
catch (Exception ex)
Expand Down Expand Up @@ -724,26 +704,13 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
? null
: new PhoneNumberIdentifierModel(options?.CallInvite?.SourceCallerIdNumber?.PhoneNumber),
SourceDisplayName = options?.CallInvite?.SourceDisplayName,
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
TeamsAppSource = options.TeamsAppSource == null ? null : new MicrosoftTeamsAppIdentifierModel(options.TeamsAppSource.AppId),
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id)
};

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

// Add CallIntelligenceOptions such as custom cognitive service domain name
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
string backupCognitiveServicesEndpoint = options.CallIntelligenceOptions?.BackupCognitiveServicesEndpoint?.AbsoluteUri;
if (!string.IsNullOrWhiteSpace(cognitiveServicesEndpoint))
request.CallIntelligenceOptions = new()
{
request.CallIntelligenceOptions = new()
{
CognitiveServicesEndpoint = cognitiveServicesEndpoint,
BackupCognitiveServicesEndpoint = backupCognitiveServicesEndpoint
};
}

CognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri
};
request.OperationContext = options.OperationContext;
request.MediaStreamingOptions = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
request.TranscriptionOptions = CreateTranscriptionOptionsInternal(options.TranscriptionOptions);
Expand All @@ -761,25 +728,13 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
? null
: new PhoneNumberIdentifierModel(options?.SourceCallerIdNumber?.PhoneNumber),
SourceDisplayName = options?.SourceDisplayName,
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id),
TeamsAppSource = options.TeamsAppSource == null ? null : new MicrosoftTeamsAppIdentifierModel(options.TeamsAppSource.AppId)
Source = Source == null ? null : new CommunicationUserIdentifierModel(Source.Id)
};

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

// Add CallIntelligenceOptions such as custom cognitive service domain name
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
string backupCognitiveServicesEndpoint = options.CallIntelligenceOptions?.BackupCognitiveServicesEndpoint?.AbsoluteUri;
if (!string.IsNullOrWhiteSpace(cognitiveServicesEndpoint))
request.CallIntelligenceOptions = new()
{
request.CallIntelligenceOptions = new()
{
CognitiveServicesEndpoint = cognitiveServicesEndpoint,
BackupCognitiveServicesEndpoint = backupCognitiveServicesEndpoint
};
}
CognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri
};

request.OperationContext = options.OperationContext;
request.MediaStreamingOptions = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
Expand All @@ -795,49 +750,41 @@ private ConnectRequestInternal ConnectRequest(ConnectCallOptions options)
connectRequest.OperationContext = options.OperationContext;
connectRequest.MediaStreamingOptions = CreateMediaStreamingOptionsInternal(options.MediaStreamingOptions);
connectRequest.TranscriptionOptions = CreateTranscriptionOptionsInternal(options.TranscriptionOptions);

string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
string backupCognitiveServicesEndpoint = options.CallIntelligenceOptions?.BackupCognitiveServicesEndpoint?.AbsoluteUri;
if (!string.IsNullOrWhiteSpace(cognitiveServicesEndpoint))
connectRequest.CallIntelligenceOptions = new()
{
connectRequest.CallIntelligenceOptions = new()
{
CognitiveServicesEndpoint = cognitiveServicesEndpoint,
BackupCognitiveServicesEndpoint = backupCognitiveServicesEndpoint
};
}
CognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri
};

return connectRequest;
}

/// <summary>
/// Validates an Https Uri.
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
private static bool IsValidHttpsUri(Uri uri)
{
if (uri == null)
return false;
var uriString = uri.AbsoluteUri;
return Uri.IsWellFormedUriString(uriString, UriKind.Absolute) && new Uri(uriString).Scheme == Uri.UriSchemeHttps;
}

private static MediaStreamingOptionsInternal CreateMediaStreamingOptionsInternal(MediaStreamingOptions configuration)
private static WebSocketMediaStreamingOptionsInternal CreateMediaStreamingOptionsInternal(MediaStreamingOptions configuration)
{
return configuration == default
? default
: new MediaStreamingOptionsInternal(configuration.TransportUri.AbsoluteUri, configuration.MediaStreamingTransport,
configuration.MediaStreamingContent, configuration.MediaStreamingAudioChannel, configuration.StartMediaStreaming,
configuration.EnableBidirectional, configuration.AudioFormat);
: new WebSocketMediaStreamingOptionsInternal(configuration.MediaStreamingAudioChannel)
{
AudioFormat = configuration.AudioFormat,
TransportUrl = configuration.TransportUri?.AbsoluteUri,
TransportType = configuration.MediaStreamingTransport,
ContentType = configuration.MediaStreamingContent,
EnableBidirectional = configuration.EnableBidirectional,
EnableDtmfTones = configuration.EnableDtmfTones,
StartMediaStreaming = configuration.StartMediaStreaming,
};
}
private static TranscriptionOptionsInternal CreateTranscriptionOptionsInternal(TranscriptionOptions configuration)

private static WebSocketTranscriptionOptionsInternal CreateTranscriptionOptionsInternal(TranscriptionOptions configuration)
{
return configuration == default
? default
: new TranscriptionOptionsInternal(configuration.TransportUrl.AbsoluteUri, configuration.TranscriptionTransport, configuration.Locale,
configuration.StartTranscription.GetValueOrDefault())
: new WebSocketTranscriptionOptionsInternal(
configuration.Locale)
{
SpeechModelEndpointId = configuration.SpeechRecognitionModelEndpointId,
StartTranscription = configuration.StartTranscription,
TransportUrl = configuration.TransportUri?.AbsoluteUri,
TransportType = configuration.TranscriptionTransport,
EnableIntermediateResults = configuration.EnableIntermediateResults,
SpeechRecognitionModelEndpointId = configuration.SpeechRecognitionModelEndpointId
};
Expand All @@ -851,7 +798,7 @@ public virtual CallConnection GetCallConnection(string callConnectionId)
scope.Start();
try
{
return new CallConnection(callConnectionId, CallConnectionRestClient, CallMediaRestClient, CallDialogRestClient, _clientDiagnostics, EventProcessor);
return new CallConnection(callConnectionId, CallConnectionRestClient, CallMediaRestClient, _clientDiagnostics, EventProcessor);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CallAutomationClientOptions : ClientOptions
/// <summary>
/// The latest version of the CallAutomation service.
/// </summary>
internal const ServiceVersion LatestVersion = ServiceVersion.V2024_09_01_Preview;
internal const ServiceVersion LatestVersion = ServiceVersion.V2025_05_15;

internal string ApiVersion { get; }

Expand All @@ -33,10 +33,10 @@ public CallAutomationClientOptions(ServiceVersion version = LatestVersion)
ApiVersion = version switch
{
ServiceVersion.V2023_03_06 => "2023-03-06",
ServiceVersion.V2023_06_15_Preview => "2023-06-15-preview",
ServiceVersion.V2023_10_15 => "2023-10-15",
ServiceVersion.V2023_10_03_Preview => "2023-10-03-preview",
ServiceVersion.V2024_09_01_Preview => "2024-09-01-preview",
ServiceVersion.V2024_04_15 => "2024-04-15",
ServiceVersion.V2024_09_15 => "2024-09-15",
ServiceVersion.V2025_05_15 => "2025-05-15",
_ => throw new ArgumentOutOfRangeException(nameof(version)),
};
}
Expand All @@ -53,24 +53,24 @@ public enum ServiceVersion
V2023_03_06 = 1,

/// <summary>
/// The BETA2 (1.1.0-beta) of the CallAutomation service.
/// The GA2 (1.1.0) of the CallAutomation service.
/// </summary>
V2023_06_15_Preview = 2,
V2023_10_15 = 2,

/// <summary>
/// The GA2 (1.1.0) of the CallAutomation service.
/// The GA3 (1.2.0) of the CallAutomation service.
/// </summary>
V2023_10_15 = 3,
V2024_04_15 = 3,

/// <summary>
/// Latest ALPHA3 (1.2.0-alpha) preview of the CallAutomation service.
/// The GA4 (1.3.0) of the CallAutomation service.
/// </summary>
V2023_10_03_Preview = 4,
V2024_09_15 = 4,

/// <summary>
/// Latest ALPHA4 (1.4.0-alpha) preview of the CallAutomation service.
/// The GA5 (1.4.0) of the CallAutomation service.
/// </summary>
V2024_09_01_Preview = 5
V2025_05_15 = 5,
#pragma warning restore CA1707 // Identifiers should not contain underscores
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,14 @@ public class CancelAddParticipantEventResult
/// </summary>
public CancelAddParticipantFailed FailureResult { get; }

/// <summary>
/// <see cref="CommunicationIdentifier"/> Participant whoose invitation was cancelled. Only applicable for
/// <see cref="CancelAddParticipantSucceeded"/> event
/// </summary>
public CommunicationIdentifier Participant { get; }

/// <summary>
/// Invitation ID used to cancel the request.
/// </summary>
public string InvitationId { get; }

internal CancelAddParticipantEventResult(
bool isSuccess,
CancelAddParticipantSucceeded successResult,
CancelAddParticipantFailed failureResult,
string invitationId,
CommunicationIdentifier participant = null)
CancelAddParticipantFailed failureResult)
{
IsSuccess = isSuccess;
SuccessResult = successResult;
FailureResult = failureResult;
Participant = participant;
InvitationId = invitationId;
}
}
}
Loading