diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 117b5722194eb..9cc151b708063 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -37,6 +37,7 @@ "contoso", "deserializes", "diagnoser", + "dtmf", "epsg", "expando", "finalizer", @@ -50,6 +51,7 @@ "overridden", "parallelization", "pkcs", + "pstn", "pwsh", "referer", "renormalize", @@ -57,6 +59,7 @@ "structs", "uints", "unformattable", + "unhold", "uninstrumented", "westus", "xunit" diff --git a/sdk/communication/Azure.Communication.CallingServer/README.md b/sdk/communication/Azure.Communication.CallingServer/README.md index f5c7ab2f5aba8..0e2da8398ef1e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/README.md +++ b/sdk/communication/Azure.Communication.CallingServer/README.md @@ -1,4 +1,4 @@ -# Azure Communication Server Calling client library for .NET +# Azure Communication CallingServer client library for .NET This package contains a C# SDK for Azure Communication Services for Calling. @@ -6,7 +6,7 @@ This package contains a C# SDK for Azure Communication Services for Calling. ## Getting started ### Install the package -Install the Azure Communication Server Calling client library for .NET with [NuGet][nuget]: +Install the Azure Communication CallingServer client library for .NET with [NuGet][nuget]: ```PowerShell dotnet add package Azure.Communication.CallingServer --version 1.0.0-beta.1 @@ -18,7 +18,7 @@ You need an [Azure subscription][azure_sub] and a [Communication Service Resourc To create a new Communication Service, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell], or the [.NET management client library][communication_resource_create_net]. ### Key concepts -`CallClient` provides the functionality to make call related operations. +`CallingServerClient` provides the functionality to make call connection, join call connection or initialize a server call. ### Using statements ```C# Snippet:Azure_Communication_ServerCalling_Tests_UsingStatements @@ -28,33 +28,33 @@ using Azure.Communication.CallingServer; ``` ### Authenticate the client -Server Calling clients can be authenticated using the connection string acquired from an Azure Communication Resource in the [Azure Portal][azure_portal]. +Calling server client can be authenticated using the connection string acquired from an Azure Communication Resource in the [Azure Portal][azure_portal]. ```C# Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient var connectionString = ""; // Find your Communication Services resource in the Azure portal -CallClient client = new CallClient(connectionString); +CallingServerClient callingServerClient = new CallingServerClient(connectionString); ``` ## Examples ### Make a call to a phone number recipient -To make a call, call the `CreateCall` or `CreateCallAsync` function from the `CallClient`. +To make an outbound call, call the `CreateCallConnection` or `CreateCallConnectionAsync` function from the `CallingServerClient`. ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); ``` ```C# Snippet:Azure_Communication_Call_Tests_CreateCallAsync -CreateCallResponse createCallResponse = await callClient.CreateCallAsync( +var callConnection = await callingServerClient.CreateCallConnectionAsync( source: new CommunicationUserIdentifier(""), // Your Azure Communication Resource Guid Id used to make a Call targets: new List() { new PhoneNumberIdentifier("") }, // E.164 formatted recipient phone number options: createCallOption // The options for creating a call. ); -Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); +Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}"); ``` ## Troubleshooting diff --git a/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs b/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs index c87567dfa6b88..6a748a9c5152e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs +++ b/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs @@ -1,46 +1,88 @@ namespace Azure.Communication.CallingServer { - public static partial class AzureCommunicationCallingServerServiceModelFactory + public partial class AddParticipantResult { - public static Azure.Communication.CallingServer.CancelAllMediaOperationsResponse CancelAllMediaOperationsResponse(string id = null, Azure.Communication.CallingServer.OperationStatus? status = default(Azure.Communication.CallingServer.OperationStatus?), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } - public static Azure.Communication.CallingServer.CreateCallResponse CreateCallResponse(string callLegId = null) { throw null; } - public static Azure.Communication.CallingServer.GetCallRecordingStateResponse GetCallRecordingStateResponse(Azure.Communication.CallingServer.CallRecordingState? recordingState = default(Azure.Communication.CallingServer.CallRecordingState?)) { throw null; } - public static Azure.Communication.CallingServer.JoinCallResponse JoinCallResponse(string callLegId = null) { throw null; } - public static Azure.Communication.CallingServer.PlayAudioResponse PlayAudioResponse(string id = null, Azure.Communication.CallingServer.OperationStatus? status = default(Azure.Communication.CallingServer.OperationStatus?), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } - public static Azure.Communication.CallingServer.ResultInfo ResultInfo(int? code = default(int?), int? subcode = default(int?), string message = null) { throw null; } - public static Azure.Communication.CallingServer.StartCallRecordingResponse StartCallRecordingResponse(string recordingId = null) { throw null; } + internal AddParticipantResult() { } + public string ParticipantId { get { throw null; } } } - public partial class CallClient + public partial class AddParticipantResultEvent : Azure.Communication.CallingServer.CallingServerEventBase { - protected CallClient() { } - public CallClient(string connectionString) { } - public CallClient(string connectionString, Azure.Communication.CallingServer.CallClientOptions options = null) { } - public CallClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.CallingServer.CallClientOptions options = null) { } - public CallClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.CallingServer.CallClientOptions options = null) { } - public virtual Azure.Response AddParticipant(string callLegId, Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task AddParticipantAsync(string callLegId, Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response CancelAllMediaOperations(string callLegId, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> CancelAllMediaOperationsAsync(string callLegId, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response CreateCall(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> CreateCallAsync(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response DeleteCall(string callLegId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task DeleteCallAsync(string callLegId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response HangupCall(string callLegId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task HangupCallAsync(string callLegId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(string callLegId, Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(string callLegId, System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(string callLegId, Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(string callLegId, System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RemoveParticipant(string callLegId, string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string callLegId, string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + internal AddParticipantResultEvent() { } + public string OperationContext { get { throw null; } } + public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } + public Azure.Communication.CallingServer.OperationStatus Status { get { throw null; } } + public static Azure.Communication.CallingServer.AddParticipantResultEvent Deserialize(string content) { throw null; } + } + public partial class CallConnection + { + protected CallConnection() { } + public virtual string CallConnectionId { get { throw null; } } + public virtual Azure.Response AddParticipant(Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddParticipantAsync(Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CancelAllMediaOperations(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CancelAllMediaOperationsAsync(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Hangup(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task HangupAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveParticipant(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CallConnectionState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CallConnectionState(string value) { throw null; } + public static Azure.Communication.CallingServer.CallConnectionState Connected { get { throw null; } } + public static Azure.Communication.CallingServer.CallConnectionState Connecting { get { throw null; } } + public static Azure.Communication.CallingServer.CallConnectionState Disconnected { get { throw null; } } + public static Azure.Communication.CallingServer.CallConnectionState Disconnecting { get { throw null; } } + public static Azure.Communication.CallingServer.CallConnectionState Incoming { get { throw null; } } + public bool Equals(Azure.Communication.CallingServer.CallConnectionState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Communication.CallingServer.CallConnectionState left, Azure.Communication.CallingServer.CallConnectionState right) { throw null; } + public static implicit operator Azure.Communication.CallingServer.CallConnectionState (string value) { throw null; } + public static bool operator !=(Azure.Communication.CallingServer.CallConnectionState left, Azure.Communication.CallingServer.CallConnectionState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class CallConnectionStateChangedEvent : Azure.Communication.CallingServer.CallingServerEventBase + { + internal CallConnectionStateChangedEvent() { } + public string CallConnectionId { get { throw null; } } + public Azure.Communication.CallingServer.CallConnectionState CallConnectionState { get { throw null; } } + public string ServerCallId { get { throw null; } } + public static Azure.Communication.CallingServer.CallConnectionStateChangedEvent Deserialize(string content) { throw null; } } - public partial class CallClientOptions : Azure.Core.ClientOptions + public partial class CallingServerClient { - public const Azure.Communication.CallingServer.CallClientOptions.ServiceVersion LatestVersion = Azure.Communication.CallingServer.CallClientOptions.ServiceVersion.V2021_04_15_Preview1; - public CallClientOptions(Azure.Communication.CallingServer.CallClientOptions.ServiceVersion version = Azure.Communication.CallingServer.CallClientOptions.ServiceVersion.V2021_04_15_Preview1) { } + protected CallingServerClient() { } + public CallingServerClient(string connectionString) { } + public CallingServerClient(string connectionString, Azure.Communication.CallingServer.CallingServerClientOptions options) { } + public virtual Azure.Response CreateCallConnection(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateCallConnectionAsync(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DownloadStreaming(System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> DownloadStreamingAsync(System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DownloadTo(System.Uri sourceEndpoint, System.IO.Stream destinationStream, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DownloadTo(System.Uri sourceEndpoint, string destinationPath, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DownloadToAsync(System.Uri sourceEndpoint, System.IO.Stream destinationStream, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DownloadToAsync(System.Uri sourceEndpoint, string destinationPath, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Communication.CallingServer.CallConnection GetCallConnection(string callConnectionId) { throw null; } + public virtual Azure.Communication.CallingServer.ServerCall InitializeServerCall(string serverCallId) { throw null; } + public virtual Azure.Response JoinCall(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> JoinCallAsync(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class CallingServerClientOptions : Azure.Core.ClientOptions + { + public CallingServerClientOptions(Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion version = Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion.V2021_06_15_Preview) { } public enum ServiceVersion { - V2021_04_15_Preview1 = 0, + V2021_06_15_Preview = 1, } } public abstract partial class CallingServerEventBase @@ -53,9 +95,9 @@ protected CallingServerEventBase() { } private readonly object _dummy; private readonly int _dummyPrimitive; public CallingServerEventType(string value) { throw null; } - public static Azure.Communication.CallingServer.CallingServerEventType CallLegStateChangedEvent { get { throw null; } } + public static Azure.Communication.CallingServer.CallingServerEventType AddParticipantResultEvent { get { throw null; } } + public static Azure.Communication.CallingServer.CallingServerEventType CallConnectionStateChangedEvent { get { throw null; } } public static Azure.Communication.CallingServer.CallingServerEventType CallRecordingStateChangeEvent { get { throw null; } } - public static Azure.Communication.CallingServer.CallingServerEventType InviteParticipantsResultEvent { get { throw null; } } public static Azure.Communication.CallingServer.CallingServerEventType ParticipantsUpdatedEvent { get { throw null; } } public static Azure.Communication.CallingServer.CallingServerEventType PlayAudioResultEvent { get { throw null; } } public static Azure.Communication.CallingServer.CallingServerEventType ToneReceivedEvent { get { throw null; } } @@ -68,31 +110,17 @@ protected CallingServerEventBase() { } public static bool operator !=(Azure.Communication.CallingServer.CallingServerEventType left, Azure.Communication.CallingServer.CallingServerEventType right) { throw null; } public override string ToString() { throw null; } } - public partial class CallLegStateChangedEvent : Azure.Communication.CallingServer.CallingServerEventBase + public partial class CallParticipant { - public CallLegStateChangedEvent() { } - public string CallLegId { get { throw null; } set { } } - public Azure.Communication.CallingServer.CallState? CallState { get { throw null; } set { } } - public string ConversationId { get { throw null; } set { } } - public static Azure.Communication.CallingServer.CallLegStateChangedEvent Deserialize(string content) { throw null; } + internal CallParticipant() { } + public Azure.Communication.CommunicationIdentifier Identifier { get { throw null; } } + public bool IsMuted { get { throw null; } } + public string ParticipantId { get { throw null; } } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct CallModality : System.IEquatable + public partial class CallRecordingProperties { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public CallModality(string value) { throw null; } - public static Azure.Communication.CallingServer.CallModality Audio { get { throw null; } } - public static Azure.Communication.CallingServer.CallModality Video { get { throw null; } } - public bool Equals(Azure.Communication.CallingServer.CallModality other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.Communication.CallingServer.CallModality left, Azure.Communication.CallingServer.CallModality right) { throw null; } - public static implicit operator Azure.Communication.CallingServer.CallModality (string value) { throw null; } - public static bool operator !=(Azure.Communication.CallingServer.CallModality left, Azure.Communication.CallingServer.CallModality right) { throw null; } - public override string ToString() { throw null; } + internal CallRecordingProperties() { } + public Azure.Communication.CallingServer.CallRecordingState RecordingState { get { throw null; } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct CallRecordingState : System.IEquatable @@ -114,55 +142,20 @@ public CallLegStateChangedEvent() { } } public partial class CallRecordingStateChangeEvent : Azure.Communication.CallingServer.CallingServerEventBase { - public CallRecordingStateChangeEvent() { } - public string ConversationId { get { throw null; } set { } } - public string RecordingId { get { throw null; } set { } } - public System.DateTimeOffset? StartDateTime { get { throw null; } set { } } - public Azure.Communication.CallingServer.CallRecordingState? State { get { throw null; } set { } } + internal CallRecordingStateChangeEvent() { } + public string RecordingId { get { throw null; } } + public string ServerCallId { get { throw null; } } + public System.DateTimeOffset StartDateTime { get { throw null; } } + public Azure.Communication.CallingServer.CallRecordingState State { get { throw null; } } public static Azure.Communication.CallingServer.CallRecordingStateChangeEvent Deserialize(string content) { throw null; } } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct CallState : System.IEquatable + public partial class CancelAllMediaOperationsResult { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public CallState(string value) { throw null; } - public static Azure.Communication.CallingServer.CallState Established { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Establishing { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Hold { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Idle { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Incoming { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Redirecting { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Terminated { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Terminating { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Transferring { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Unhold { get { throw null; } } - public static Azure.Communication.CallingServer.CallState Unknown { get { throw null; } } - public bool Equals(Azure.Communication.CallingServer.CallState other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.Communication.CallingServer.CallState left, Azure.Communication.CallingServer.CallState right) { throw null; } - public static implicit operator Azure.Communication.CallingServer.CallState (string value) { throw null; } - public static bool operator !=(Azure.Communication.CallingServer.CallState left, Azure.Communication.CallingServer.CallState right) { throw null; } - public override string ToString() { throw null; } - } - public partial class CancelAllMediaOperationsResponse - { - internal CancelAllMediaOperationsResponse() { } - public string Id { get { throw null; } } + internal CancelAllMediaOperationsResult() { } public string OperationContext { get { throw null; } } + public string OperationId { get { throw null; } } public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } - public Azure.Communication.CallingServer.OperationStatus? Status { get { throw null; } } - } - public partial class CommunicationParticipant - { - public CommunicationParticipant() { } - public CommunicationParticipant(Azure.Communication.CommunicationIdentifier identifier, string participantId, bool? isMuted) { } - public Azure.Communication.CommunicationIdentifier Identifier { get { throw null; } set { } } - public bool? IsMuted { get { throw null; } set { } } - public string ParticipantId { get { throw null; } set { } } + public Azure.Communication.CallingServer.OperationStatus Status { get { throw null; } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public partial struct ContentTransferOptions : System.IEquatable @@ -181,54 +174,15 @@ public partial struct ContentTransferOptions : System.IEquatable AddParticipantAsync(string conversationId, Azure.Communication.CommunicationIdentifier participant, System.Uri callbackUri, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response DownloadStreaming(System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> DownloadStreamingAsync(System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response DownloadTo(System.Uri sourceEndpoint, System.IO.Stream destinationStream, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response DownloadTo(System.Uri sourceEndpoint, string destinationPath, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task DownloadToAsync(System.Uri sourceEndpoint, System.IO.Stream destinationStream, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task DownloadToAsync(System.Uri sourceEndpoint, string destinationPath, Azure.Communication.CallingServer.ContentTransferOptions transferOptions = default(Azure.Communication.CallingServer.ContentTransferOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetRecordingState(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetRecordingStateAsync(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response JoinCall(string conversationId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> JoinCallAsync(string conversationId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PauseRecording(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task PauseRecordingAsync(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(string conversationId, Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(string conversationId, System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(string conversationId, Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(string conversationId, System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response RemoveParticipant(string conversationId, string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string conversationId, string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response ResumeRecording(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task ResumeRecordingAsync(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response StartRecording(string conversationId, System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> StartRecordingAsync(string conversationId, System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response StopRecording(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StopRecordingAsync(string conversationId, string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - } public partial class CreateCallOptions { - public CreateCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnumerable requestedModalities, System.Collections.Generic.IEnumerable requestedCallEvents) { } + public CreateCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnumerable requestedMediaTypes, System.Collections.Generic.IEnumerable requestedCallEvents) { } public Azure.Communication.PhoneNumberIdentifier AlternateCallerId { get { throw null; } set { } } public System.Uri CallbackUri { get { throw null; } } public System.Collections.Generic.IList RequestedCallEvents { get { throw null; } } - public System.Collections.Generic.IList RequestedModalities { get { throw null; } } + public System.Collections.Generic.IList RequestedMediaTypes { get { throw null; } } public string Subject { get { throw null; } set { } } } - public partial class CreateCallResponse - { - internal CreateCallResponse() { } - public string CallLegId { get { throw null; } } - } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct EventSubscriptionType : System.IEquatable { @@ -247,31 +201,31 @@ internal CreateCallResponse() { } public static bool operator !=(Azure.Communication.CallingServer.EventSubscriptionType left, Azure.Communication.CallingServer.EventSubscriptionType right) { throw null; } public override string ToString() { throw null; } } - public partial class GetCallRecordingStateResponse - { - internal GetCallRecordingStateResponse() { } - public Azure.Communication.CallingServer.CallRecordingState? RecordingState { get { throw null; } } - } - public partial class InviteParticipantsResultEvent : Azure.Communication.CallingServer.CallingServerEventBase - { - public InviteParticipantsResultEvent() { } - public string OperationContext { get { throw null; } set { } } - public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } set { } } - public Azure.Communication.CallingServer.OperationStatus? Status { get { throw null; } set { } } - public static Azure.Communication.CallingServer.InviteParticipantsResultEvent Deserialize(string content) { throw null; } - } public partial class JoinCallOptions { - public JoinCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnumerable requestedModalities, System.Collections.Generic.IEnumerable requestedCallEvents) { } + public JoinCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnumerable requestedMediaTypes, System.Collections.Generic.IEnumerable requestedCallEvents) { } public System.Uri CallbackUri { get { throw null; } } public System.Collections.Generic.IList RequestedCallEvents { get { throw null; } } - public System.Collections.Generic.IList RequestedModalities { get { throw null; } } + public System.Collections.Generic.IList RequestedMediaTypes { get { throw null; } } public string Subject { get { throw null; } set { } } } - public partial class JoinCallResponse + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MediaType : System.IEquatable { - internal JoinCallResponse() { } - public string CallLegId { get { throw null; } } + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MediaType(string value) { throw null; } + public static Azure.Communication.CallingServer.MediaType Audio { get { throw null; } } + public static Azure.Communication.CallingServer.MediaType Video { get { throw null; } } + public bool Equals(Azure.Communication.CallingServer.MediaType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Communication.CallingServer.MediaType left, Azure.Communication.CallingServer.MediaType right) { throw null; } + public static implicit operator Azure.Communication.CallingServer.MediaType (string value) { throw null; } + public static bool operator !=(Azure.Communication.CallingServer.MediaType left, Azure.Communication.CallingServer.MediaType right) { throw null; } + public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct OperationStatus : System.IEquatable @@ -295,9 +249,9 @@ internal JoinCallResponse() { } } public partial class ParticipantsUpdatedEvent : Azure.Communication.CallingServer.CallingServerEventBase { - public ParticipantsUpdatedEvent() { } - public string CallLegId { get { throw null; } set { } } - public System.Collections.Generic.IEnumerable Participants { get { throw null; } set { } } + internal ParticipantsUpdatedEvent() { } + public string CallConnectionId { get { throw null; } } + public System.Collections.Generic.IEnumerable Participants { get { throw null; } } public static Azure.Communication.CallingServer.ParticipantsUpdatedEvent Deserialize(string content) { throw null; } } public partial class PlayAudioOptions @@ -309,45 +263,65 @@ public PlayAudioOptions() { } public bool? Loop { get { throw null; } set { } } public string OperationContext { get { throw null; } set { } } } - public partial class PlayAudioResponse + public partial class PlayAudioResult { - internal PlayAudioResponse() { } - public string Id { get { throw null; } } + internal PlayAudioResult() { } public string OperationContext { get { throw null; } } + public string OperationId { get { throw null; } } public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } - public Azure.Communication.CallingServer.OperationStatus? Status { get { throw null; } } + public Azure.Communication.CallingServer.OperationStatus Status { get { throw null; } } } public partial class PlayAudioResultEvent : Azure.Communication.CallingServer.CallingServerEventBase { - public PlayAudioResultEvent() { } - public string OperationContext { get { throw null; } set { } } - public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } set { } } - public Azure.Communication.CallingServer.OperationStatus? Status { get { throw null; } set { } } + internal PlayAudioResultEvent() { } + public string OperationContext { get { throw null; } } + public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } + public Azure.Communication.CallingServer.OperationStatus Status { get { throw null; } } public static Azure.Communication.CallingServer.PlayAudioResultEvent Deserialize(string content) { throw null; } } public partial class ResultInfo { internal ResultInfo() { } - public int? Code { get { throw null; } } + public int Code { get { throw null; } } public string Message { get { throw null; } } - public int? Subcode { get { throw null; } } + public int Subcode { get { throw null; } } + } + public partial class ServerCall + { + protected ServerCall() { } + public virtual Azure.Response AddParticipant(Azure.Communication.CommunicationIdentifier participant, System.Uri callbackUri, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddParticipantAsync(Azure.Communication.CommunicationIdentifier participant, System.Uri callbackUri, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetRecordingState(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRecordingStateAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PauseRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task PauseRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveParticipant(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response ResumeRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task ResumeRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartRecording(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> StartRecordingAsync(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StopRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StopRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class StartCallRecordingResponse + public partial class StartCallRecordingResult { - internal StartCallRecordingResponse() { } + internal StartCallRecordingResult() { } public string RecordingId { get { throw null; } } } public partial class ToneInfo { - public ToneInfo() { } - public int? SequenceId { get { throw null; } set { } } - public Azure.Communication.CallingServer.ToneValue? Tone { get { throw null; } set { } } + internal ToneInfo() { } + public int SequenceId { get { throw null; } } + public Azure.Communication.CallingServer.ToneValue Tone { get { throw null; } } } public partial class ToneReceivedEvent : Azure.Communication.CallingServer.CallingServerEventBase { - public ToneReceivedEvent() { } - public string CallLegId { get { throw null; } set { } } - public Azure.Communication.CallingServer.ToneInfo ToneInfo { get { throw null; } set { } } + internal ToneReceivedEvent() { } + public string CallConnectionId { get { throw null; } } + public Azure.Communication.CallingServer.ToneInfo ToneInfo { get { throw null; } } public static Azure.Communication.CallingServer.ToneReceivedEvent Deserialize(string content) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -384,3 +358,21 @@ public ToneReceivedEvent() { } public override string ToString() { throw null; } } } +namespace Azure.Communication.CallingServer.Models +{ + public static partial class CallingServerModelFactory + { + public static Azure.Communication.CallingServer.AddParticipantResult AddParticipantResult(string participantId = null) { throw null; } + public static Azure.Communication.CallingServer.AddParticipantResultEvent AddParticipantResultEvent(Azure.Communication.CallingServer.ResultInfo resultInfo = null, string operationContext = null, Azure.Communication.CallingServer.OperationStatus status = default(Azure.Communication.CallingServer.OperationStatus)) { throw null; } + public static Azure.Communication.CallingServer.CallConnectionStateChangedEvent CallConnectionStateChangedEvent(string serverCallId = null, string callConnectionId = null, Azure.Communication.CallingServer.CallConnectionState callConnectionState = default(Azure.Communication.CallingServer.CallConnectionState)) { throw null; } + public static Azure.Communication.CallingServer.CallRecordingProperties CallRecordingProperties(Azure.Communication.CallingServer.CallRecordingState recordingState = default(Azure.Communication.CallingServer.CallRecordingState)) { throw null; } + public static Azure.Communication.CallingServer.CallRecordingStateChangeEvent CallRecordingStateChangeEvent(string recordingId = null, Azure.Communication.CallingServer.CallRecordingState state = default(Azure.Communication.CallingServer.CallRecordingState), System.DateTimeOffset startDateTime = default(System.DateTimeOffset), string serverCallId = null) { throw null; } + public static Azure.Communication.CallingServer.CancelAllMediaOperationsResult CancelAllMediaOperationsResult(string operationId = null, Azure.Communication.CallingServer.OperationStatus status = default(Azure.Communication.CallingServer.OperationStatus), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } + public static Azure.Communication.CallingServer.PlayAudioResult PlayAudioResult(string operationId = null, Azure.Communication.CallingServer.OperationStatus status = default(Azure.Communication.CallingServer.OperationStatus), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } + public static Azure.Communication.CallingServer.PlayAudioResultEvent PlayAudioResultEvent(Azure.Communication.CallingServer.ResultInfo resultInfo = null, string operationContext = null, Azure.Communication.CallingServer.OperationStatus status = default(Azure.Communication.CallingServer.OperationStatus)) { throw null; } + public static Azure.Communication.CallingServer.ResultInfo ResultInfo(int code = 0, int subcode = 0, string message = null) { throw null; } + public static Azure.Communication.CallingServer.StartCallRecordingResult StartCallRecordingResult(string recordingId = null) { throw null; } + public static Azure.Communication.CallingServer.ToneInfo ToneInfo(int sequenceId = 0, Azure.Communication.CallingServer.ToneValue tone = default(Azure.Communication.CallingServer.ToneValue)) { throw null; } + public static Azure.Communication.CallingServer.ToneReceivedEvent ToneReceivedEvent(Azure.Communication.CallingServer.ToneInfo toneInfo = null, string callConnectionId = null) { throw null; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/samples/README.md b/sdk/communication/Azure.Communication.CallingServer/samples/README.md index 502d01001f010..e775faa2a3825 100644 --- a/sdk/communication/Azure.Communication.CallingServer/samples/README.md +++ b/sdk/communication/Azure.Communication.CallingServer/samples/README.md @@ -5,13 +5,13 @@ languages: products: - azure - azure-communication-services -name: Azure Communication Server Calling samples for .NET +name: Azure Communication CallingServer samples for .NET description: Samples for the Azure.Communication.CallingServer client library --- -# Azure Communication Server Calling SDK samples +# Azure Communication CallingServer SDK samples -Azure Communication Server Calling is a client library that provides the functionality to make call between user identities. +Azure Communication CallingServer is a client library that provides the functionality to make call between user identities. To get started you will need to have an Azure Subscription. Once you have this you can go into the Azure portal and create Azure Communication Services resource. The page will give you necessary information to be able to use the sample codes here such as connections string, shared access key, etc. This client library allows to do following operations: diff --git a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md index 8ea57baf5a1e0..7b8b15a9b5fb8 100644 --- a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md +++ b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md @@ -4,13 +4,13 @@ This sample demonstrates how to make a call to a phone number recipient. To get started you'll need a Communication Service Resource. See [README][README] for prerequisites and instructions. -## Creating an `ServerCallingClient` +## Creating a `CallingServerClient` -Server Calling clients can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal. +CallingServer client can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal. ```C# Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient var connectionString = ""; // Find your Communication Services resource in the Azure portal -CallClient client = new CallClient(connectionString); +CallingServerClient callingServerClient = new CallingServerClient(connectionString); ``` ## Make a call to a phone number recipient @@ -19,20 +19,20 @@ To make a call, call the `CreateCall` or `CreateCallAsync` function from the `Ca ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); ``` ```C# Snippet:Azure_Communication_Call_Tests_CreateCall -CreateCallResponse createCallResponse = callClient.CreateCall( +var callConnection = callingServerClient.CreateCallConnection( source: new CommunicationUserIdentifier(""), // Your Azure Communication Resource Guid Id used to make a Call targets: new List() { new PhoneNumberIdentifier("") }, // E.164 formatted recipient phone number options: createCallOption // The options for creating a call. ); -Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); +Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}"); ``` To see the full example source files, see: diff --git a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md index 1ad5703e3a794..18b334d34625e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md +++ b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md @@ -4,13 +4,13 @@ This sample demonstrates how to make a call to a recipient phone number. To get started you'll need a Communication Service Resource. See [README][README] for prerequisites and instructions. -## Creating an `ServerCallingClient` +## Creating a `CallingServerClient` -Server Calling clients can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal. +CallingServer client can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal. ```C# Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient var connectionString = ""; // Find your Communication Services resource in the Azure portal -CallClient client = new CallClient(connectionString); +CallingServerClient callingServerClient = new CallingServerClient(connectionString); ``` ## Make a call to a phone number recipient @@ -19,20 +19,20 @@ To make a Call, call the `CreateCall` or `CreateCallAsync` function from the `Ca ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); ``` ```C# Snippet:Azure_Communication_Call_Tests_CreateCallAsync -CreateCallResponse createCallResponse = await callClient.CreateCallAsync( +var callConnection = await callingServerClient.CreateCallConnectionAsync( source: new CommunicationUserIdentifier(""), // Your Azure Communication Resource Guid Id used to make a Call targets: new List() { new PhoneNumberIdentifier("") }, // E.164 formatted recipient phone number options: createCallOption // The options for creating a call. ); -Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); +Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}"); ``` To see the full example source files, see: diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Azure.Communication.CallingServer.csproj b/sdk/communication/Azure.Communication.CallingServer/src/Azure.Communication.CallingServer.csproj index af9fd5b53b07a..b6c54a2c7064a 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Azure.Communication.CallingServer.csproj +++ b/sdk/communication/Azure.Communication.CallingServer/src/Azure.Communication.CallingServer.csproj @@ -1,13 +1,13 @@  - This client library enables working with the Microsoft Azure Communication Service Calling Server APIs. + This client library enables working with the Microsoft Azure Communication CallingServer service. For this release, see notes - https://github.com/Azure/azure-sdk-for-net-pr/blob/master/sdk/communication/Azure.Communication.ServerCalling/README.md and https://github.com/Azure/azure-sdk-for-net-pr/blob/master/sdk/communication/Azure.Communication.ServerCalling/CHANGELOG.md. - Azure Communication Service Calling Server APIs + Azure Communication CallingServer Service 1.0.0-beta.1 - Microsoft Azure Communication Calling Server APIs;Microsoft;Azure;Azure Communication Service;Azure Communication Calling Server APIs;Calling;Communication;$(PackageCommonTags) + Microsoft Azure Communication CallingServer Service;Microsoft;Azure;Azure Communication Service;Azure Communication CallingServer Service;Calling;Communication;$(PackageCommonTags) $(RequiredTargetFrameworks) diff --git a/sdk/communication/Azure.Communication.CallingServer/src/CallClient.cs b/sdk/communication/Azure.Communication.CallingServer/src/CallClient.cs deleted file mode 100644 index 6ddf78a66d82e..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/CallClient.cs +++ /dev/null @@ -1,533 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.Communication.Pipeline; - -namespace Azure.Communication.CallingServer -{ - /// - /// The Azure Communication Services Calling Server client. - /// - public class CallClient - { - private readonly ClientDiagnostics _clientDiagnostics; - internal CallRestClient RestClient { get; } - - #region public constructors - all arguments need null check - - /// Initializes a new instance of . - /// Connection string acquired from the Azure Communication Services resource. - public CallClient(string connectionString) - : this( - ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), - new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// Connection string acquired from the Azure Communication Services resource. - /// Client option exposing , , , etc. - public CallClient(string connectionString, CallClientOptions options = default) - : this( - ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), - options ?? new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// The URI of the Azure Communication Services resource. - /// The used to authenticate requests. - /// Client option exposing , , , etc. - public CallClient(Uri endpoint, AzureKeyCredential keyCredential, CallClientOptions options = default) - : this( - Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri, - Argument.CheckNotNull(keyCredential, nameof(keyCredential)), - options ?? new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// The URI of the Azure Communication Services resource. - /// The TokenCredential used to authenticate requests, such as DefaultAzureCredential. - /// Client option exposing , , , etc. - public CallClient(Uri endpoint, TokenCredential tokenCredential, CallClientOptions options = default) - : this( - Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri, - Argument.CheckNotNull(tokenCredential, nameof(tokenCredential)), - options ?? new CallClientOptions()) - { } - - #endregion - - #region private constructors - - private CallClient(ConnectionString connectionString, CallClientOptions options) - : this(connectionString.GetRequired("endpoint"), options.BuildHttpPipeline(connectionString), options) - { } - - private CallClient(string endpoint, TokenCredential tokenCredential, CallClientOptions options) - : this(endpoint, options.BuildHttpPipeline(tokenCredential), options) - { } - - private CallClient(string endpoint, AzureKeyCredential keyCredential, CallClientOptions options) - : this(endpoint, options.BuildHttpPipeline(keyCredential), options) - { } - - private CallClient(string endpoint, HttpPipeline httpPipeline, CallClientOptions options) - { - _clientDiagnostics = new ClientDiagnostics(options); - RestClient = new CallRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion); - } - - #endregion - - /// Initializes a new instance of for mocking. - protected CallClient() - { - _clientDiagnostics = null; - RestClient = null; - } - - /// Create an outgoing call from source to target identities. - /// The source identity - /// The target identities. - /// The call options. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - /// is null. - /// is null. - public virtual async Task> CreateCallAsync(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CreateCall)}"); - scope.Start(); - try - { - Argument.AssertNotNull(source, nameof(source)); - Argument.AssertNotNullOrEmpty(targets, nameof(targets)); - Argument.AssertNotNull(options, nameof(options)); - - var sourceAlternateIdentity = options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber); - - return await RestClient.CreateCallAsync( - targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)), - source: CommunicationIdentifierSerializer.Serialize(source), - callbackUri: options.CallbackUri?.AbsoluteUri, - requestedModalities: options.RequestedModalities, - requestedCallEvents: options.RequestedCallEvents, - sourceAlternateIdentity: sourceAlternateIdentity, - subject: options.Subject, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Create an outgoing call from source to target identities. - /// The source identity - /// The target identities. - /// The call options. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - /// is null. - /// is null. - public virtual Response CreateCall(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CreateCall)}"); - scope.Start(); - try - { - Argument.AssertNotNull(source, nameof(source)); - Argument.AssertNotNullOrEmpty(targets, nameof(targets)); - Argument.AssertNotNull(options, nameof(options)); - - var sourceAlternateIdentity = options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber); - - return RestClient.CreateCall( - targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)), - source: CommunicationIdentifierSerializer.Serialize(source), - callbackUri: options.CallbackUri?.AbsoluteUri, - requestedModalities: options.RequestedModalities, - requestedCallEvents: options.RequestedCallEvents, - sourceAlternateIdentity: sourceAlternateIdentity, - subject: options.Subject, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Deletes the call. - /// The call leg id. - /// The cancellation token . - /// The server returned an error. See for details returned from the server. - public virtual async Task DeleteCallAsync(string callLegId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(DeleteCall)}"); - scope.Start(); - try - { - return await RestClient.DeleteCallAsync( - callId: callLegId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Deletes the call. - /// The call leg id. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - public virtual Response DeleteCall(string callLegId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(DeleteCall)}"); - scope.Start(); - try - { - return RestClient.DeleteCall( - callId: callLegId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Disconnect the current caller in a group-call or end a p2p-call. - /// The call leg id. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - public virtual async Task HangupCallAsync(string callLegId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(HangupCall)}"); - scope.Start(); - try - { - return await RestClient.HangupCallAsync( - callId: callLegId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Disconnect the current caller in a group-call or end a p2p-call. - /// The call leg id. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - public virtual Response HangupCall(string callLegId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(HangupCall)}"); - scope.Start(); - try - { - return RestClient.HangupCall( - callId: callLegId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Cancel all media operations in the call. - /// The call leg id. - /// The operation context. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - public virtual async Task> CancelAllMediaOperationsAsync(string callLegId, string operationContext = null, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CancelAllMediaOperations)}"); - scope.Start(); - try - { - return await RestClient.CancelAllMediaOperationsAsync( - callId: callLegId, - operationContext: operationContext, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Cancel all media operations in the call. - /// The call leg id. - /// The operation context. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - public virtual Response CancelAllMediaOperations(string callLegId, string operationContext = null, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CancelAllMediaOperations)}"); - scope.Start(); - try - { - return RestClient.CancelAllMediaOperations( - callId: callLegId, - operationContext: operationContext, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Play audio in the call. - /// The call leg id. - /// The uri of the audio file. - /// The flag to indicate if audio file need to be played in a loop or not. - /// Tne id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. - /// The operation context. - /// The cancellation token to use. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task> PlayAudioAsync(string callLegId, Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) - => await PlayAudioAsync( - callLegId: callLegId, - options: new PlayAudioOptions { - AudioFileUri = audioFileUri, - Loop = loop, - AudioFileId = audioFileId, - CallbackUri = callbackUri, - OperationContext = operationContext - }, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - - /// Play audio in the call. - /// The call leg id. - /// Play audio request. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task> PlayAudioAsync(string callLegId, PlayAudioOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(PlayAudio)}"); - scope.Start(); - try - { - Argument.AssertNotNull(options, nameof(options)); - - return await RestClient.PlayAudioAsync( - callId: callLegId, - audioFileUri: options.AudioFileUri?.AbsoluteUri, - loop: options.Loop, - audioFileId: options.AudioFileId, - callbackUri: options.CallbackUri?.AbsoluteUri, - operationContext: options.OperationContext, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Play audio in the call. - /// The call leg id. - /// The uri of the audio file. - /// The flag to indicate if audio file need to be played in a loop or not. - /// Tne id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. - /// The operation context. - /// The cancellation token to use. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual Response PlayAudio(string callLegId, Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) - => PlayAudio( - callLegId: callLegId, - options: new PlayAudioOptions { - AudioFileUri = audioFileUri, - Loop = loop, - AudioFileId = audioFileId, - CallbackUri = callbackUri, - OperationContext = operationContext - }, - cancellationToken: cancellationToken - ); - - /// Play audio in the call. - /// The call leg id. - /// Play audio request. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual Response PlayAudio(string callLegId, PlayAudioOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(PlayAudio)}"); - scope.Start(); - try - { - Argument.AssertNotNull(options, nameof(options)); - - return RestClient.PlayAudio( - callId: callLegId, - audioFileUri: options.AudioFileUri?.AbsoluteUri, - loop: options.Loop, - audioFileId: options.AudioFileId, - callbackUri: options.CallbackUri?.AbsoluteUri, - operationContext: options.OperationContext, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Add a participant to the call. - /// The call leg id. - /// The identity of participant to be added to the call. - /// The phone number to use when adding a pstn participant. - /// The operation context. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task AddParticipantAsync(string callLegId, CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(AddParticipant)}"); - scope.Start(); - try - { - Argument.AssertNotNull(participant, nameof(participant)); - Argument.AssertNotNullOrEmpty(alternateCallerId, nameof(alternateCallerId)); - - return await RestClient.InviteParticipantsAsync( - callId: callLegId, - participants: new List() { CommunicationIdentifierSerializer.Serialize(participant) }, - alternateCallerId: new PhoneNumberIdentifierModel(alternateCallerId), - operationContext: operationContext, - callbackUri: null, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Add a participant to the call. - /// The call leg id. - /// The identity of participant to be added to the call. - /// The phone number to use when adding a pstn participant. - /// The operation context. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual Response AddParticipant(string callLegId, CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(AddParticipant)}"); - scope.Start(); - try - { - Argument.AssertNotNull(participant, nameof(participant)); - Argument.AssertNotNullOrEmpty(alternateCallerId, nameof(alternateCallerId)); - - return RestClient.InviteParticipants( - callId: callLegId, - participants: new List() { CommunicationIdentifierSerializer.Serialize(participant) }, - alternateCallerId: new PhoneNumberIdentifierModel(alternateCallerId), - operationContext: operationContext, - callbackUri: null, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Remove a participant from the call. - /// The call leg id. - /// The participant id. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task RemoveParticipantAsync(string callLegId, string participantId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(RemoveParticipant)}"); - scope.Start(); - try - { - return await RestClient.RemoveParticipantAsync( - callId: callLegId, - participantId: participantId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Remove a participants from the call. - /// The call leg id. - /// The participant id. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual Response RemoveParticipant(string callLegId, string participantId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(RemoveParticipant)}"); - scope.Start(); - try - { - return RestClient.RemoveParticipant( - callId: callLegId, - participantId: participantId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/CallConnection.cs b/sdk/communication/Azure.Communication.CallingServer/src/CallConnection.cs new file mode 100644 index 0000000000000..b51276df2bbc6 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/CallConnection.cs @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Communication.CallingServer +{ + /// + /// The Azure Communication Services Calling Server client. + /// + public class CallConnection + { + private readonly ClientDiagnostics _clientDiagnostics; + internal CallConnectionsRestClient RestClient { get; } + + /// + /// The call connection id. + /// + public virtual string CallConnectionId { get; internal set; } + + internal CallConnection(string callConnectionId, CallConnectionsRestClient callConnectionRestClient, ClientDiagnostics clientDiagnostics) + { + this.CallConnectionId = callConnectionId; + this.RestClient = callConnectionRestClient; + this._clientDiagnostics = clientDiagnostics; + } + + /// Initializes a new instance of for mocking. + protected CallConnection() + { + _clientDiagnostics = null; + RestClient = null; + CallConnectionId = null; + } + + /// Disconnect the current caller in a group-call or end a p2p-call. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual async Task HangupAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(Hangup)}"); + scope.Start(); + try + { + return await RestClient.HangupCallAsync( + callConnectionId: CallConnectionId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Disconnect the current caller in a group-call or end a p2p-call. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual Response Hangup(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(Hangup)}"); + scope.Start(); + try + { + return RestClient.HangupCall( + callConnectionId: CallConnectionId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Cancel all media operations in the call. + /// The operation context. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual async Task> CancelAllMediaOperationsAsync(string operationContext = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(CancelAllMediaOperations)}"); + scope.Start(); + try + { + return await RestClient.CancelAllMediaOperationsAsync( + callConnectionId: CallConnectionId, + operationContext: operationContext, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Cancel all media operations in the call. + /// The operation context. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual Response CancelAllMediaOperations(string operationContext = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(CancelAllMediaOperations)}"); + scope.Start(); + try + { + return RestClient.CancelAllMediaOperations( + callConnectionId: CallConnectionId, + operationContext: operationContext, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Play audio in the call. + /// The uri of the audio file. + /// The flag to indicate if audio file need to be played in a loop or not. + /// Tne id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. + /// The operation context. + /// The cancellation token to use. + /// The server returned an error. See for details returned from the server. + public virtual async Task> PlayAudioAsync(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) + => await PlayAudioAsync( + options: new PlayAudioOptions { + AudioFileUri = audioFileUri, + Loop = loop, + AudioFileId = audioFileId, + CallbackUri = callbackUri, + OperationContext = operationContext + }, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + /// Play audio in the call. + /// Play audio request. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + public virtual async Task> PlayAudioAsync(PlayAudioOptions options, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(PlayAudio)}"); + scope.Start(); + try + { + Argument.AssertNotNull(options, nameof(options)); + + return await RestClient.PlayAudioAsync( + callConnectionId: CallConnectionId, + audioFileUri: options.AudioFileUri?.AbsoluteUri, + loop: options.Loop, + audioFileId: options.AudioFileId, + callbackUri: options.CallbackUri?.AbsoluteUri, + operationContext: options.OperationContext, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Play audio in the call. + /// The uri of the audio file. + /// The flag to indicate if audio file need to be played in a loop or not. + /// Tne id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. + /// The operation context. + /// The cancellation token to use. + /// The server returned an error. See for details returned from the server. + public virtual Response PlayAudio(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) + => PlayAudio( + options: new PlayAudioOptions { + AudioFileUri = audioFileUri, + Loop = loop, + AudioFileId = audioFileId, + CallbackUri = callbackUri, + OperationContext = operationContext + }, + cancellationToken: cancellationToken + ); + + /// Play audio in the call. + /// Play audio request. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + public virtual Response PlayAudio(PlayAudioOptions options, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(PlayAudio)}"); + scope.Start(); + try + { + Argument.AssertNotNull(options, nameof(options)); + + return RestClient.PlayAudio( + callConnectionId: CallConnectionId, + audioFileUri: options.AudioFileUri?.AbsoluteUri, + loop: options.Loop, + audioFileId: options.AudioFileId, + callbackUri: options.CallbackUri?.AbsoluteUri, + operationContext: options.OperationContext, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Add a participant to the call. + /// The identity of participant to be added to the call. + /// The phone number to use when adding a pstn participant. + /// The operation context. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + public virtual async Task> AddParticipantAsync(CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(AddParticipant)}"); + scope.Start(); + try + { + Argument.AssertNotNull(participant, nameof(participant)); + + return await RestClient.AddParticipantAsync( + callConnectionId: CallConnectionId, + participant: CommunicationIdentifierSerializer.Serialize(participant), + alternateCallerId: alternateCallerId == null ? null : new PhoneNumberIdentifierModel(alternateCallerId), + operationContext: operationContext, + callbackUri: null, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Add a participant to the call. + /// The identity of participant to be added to the call. + /// The phone number to use when adding a pstn participant. + /// The operation context. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + public virtual Response AddParticipant(CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(AddParticipant)}"); + scope.Start(); + try + { + Argument.AssertNotNull(participant, nameof(participant)); + + return RestClient.AddParticipant( + callConnectionId: CallConnectionId, + participant: CommunicationIdentifierSerializer.Serialize(participant), + alternateCallerId: alternateCallerId == null ? null : new PhoneNumberIdentifierModel(alternateCallerId), + operationContext: operationContext, + callbackUri: null, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Remove a participant from the call. + /// The participant id. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual async Task RemoveParticipantAsync(string participantId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(RemoveParticipant)}"); + scope.Start(); + try + { + return await RestClient.RemoveParticipantAsync( + callConnectionId: CallConnectionId, + participantId: participantId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Remove a participants from the call. + /// The participant id. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + public virtual Response RemoveParticipant(string participantId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(RemoveParticipant)}"); + scope.Start(); + try + { + return RestClient.RemoveParticipant( + callConnectionId: CallConnectionId, + participantId: participantId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/CallingServerClient.cs b/sdk/communication/Azure.Communication.CallingServer/src/CallingServerClient.cs new file mode 100644 index 0000000000000..d6b5143d7049e --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/CallingServerClient.cs @@ -0,0 +1,476 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Communication.Pipeline; + +namespace Azure.Communication.CallingServer +{ + /// + /// The Azure Communication Services Calling Server client. + /// + public class CallingServerClient + { + internal readonly ClientDiagnostics _clientDiagnostics; + internal readonly HttpPipeline _pipeline; + internal readonly string _resourceEndpoint; + internal readonly ContentDownloader _contentDownloader; + + internal CallConnectionsRestClient CallConnectionRestClient { get; } + internal ServerCallsRestClient ServerCallRestClient { get; } + + #region public constructors + /// Initializes a new instance of . + /// Connection string acquired from the Azure Communication Services resource. + public CallingServerClient(string connectionString) + : this( + ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), + new CallingServerClientOptions()) + { } + + /// Initializes a new instance of . + /// Connection string acquired from the Azure Communication Services resource. + /// Client option exposing , , , etc. + public CallingServerClient(string connectionString, CallingServerClientOptions options) + : this( + ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), + Argument.CheckNotNull(options, nameof(options))) + { } + + #endregion + + #region private constructors + + private CallingServerClient(ConnectionString connectionString, CallingServerClientOptions options) + : this(connectionString.GetRequired("endpoint"), options.BuildHttpPipeline(connectionString), options) + { } + + private CallingServerClient(string endpoint, HttpPipeline httpPipeline, CallingServerClientOptions options) + { + _pipeline = httpPipeline; + _resourceEndpoint = endpoint; + _clientDiagnostics = new ClientDiagnostics(options); + _contentDownloader = new(this); + CallConnectionRestClient = new CallConnectionsRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion); + ServerCallRestClient = new ServerCallsRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion); + } + + #endregion + + /// Initializes a new instance of for mocking. + protected CallingServerClient() + { + _pipeline = null; + _resourceEndpoint = null; + _clientDiagnostics = null; + _contentDownloader = new(this); + CallConnectionRestClient = null; + ServerCallRestClient = null; + } + + /// Create an outgoing call from source to target identities. + /// The source identity + /// The target identities. + /// The call options. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + /// is null. + /// is null. + public virtual async Task> CreateCallConnectionAsync(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions options, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(CreateCallConnection)}"); + scope.Start(); + try + { + Argument.AssertNotNull(source, nameof(source)); + Argument.AssertNotNullOrEmpty(targets, nameof(targets)); + Argument.AssertNotNull(options, nameof(options)); + + var createCallResponse = await CallConnectionRestClient.CreateCallAsync( + source: CommunicationIdentifierSerializer.Serialize(source), + targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)), + callbackUri: options.CallbackUri?.AbsoluteUri, + requestedMediaTypes: options.RequestedMediaTypes, + requestedCallEvents: options.RequestedCallEvents, + alternateCallerId: options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber), + subject: options.Subject, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return Response.FromValue( + new CallConnection(createCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics), + createCallResponse.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Create an outgoing call from source to target identities. + /// The source identity + /// The target identities. + /// The call options. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + /// is null. + /// is null. + public virtual Response CreateCallConnection(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions options, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(CreateCallConnection)}"); + scope.Start(); + try + { + Argument.AssertNotNull(source, nameof(source)); + Argument.AssertNotNullOrEmpty(targets, nameof(targets)); + Argument.AssertNotNull(options, nameof(options)); + + var createCallResponse = CallConnectionRestClient.CreateCall( + source: CommunicationIdentifierSerializer.Serialize(source), + targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)), + callbackUri: options.CallbackUri?.AbsoluteUri, + requestedMediaTypes: options.RequestedMediaTypes, + requestedCallEvents: options.RequestedCallEvents, + alternateCallerId: options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber), + subject: options.Subject, + cancellationToken: cancellationToken + ); + + return Response.FromValue( + new CallConnection(createCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics), + createCallResponse.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Join the call using server call id. + /// The server call id. + /// The source identity. + /// The call Options. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + /// is null. + /// is null. + public virtual async Task> JoinCallAsync(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCall)}"); + scope.Start(); + try + { + Argument.AssertNotNull(source, nameof(source)); + Argument.AssertNotNull(callOptions, nameof(callOptions)); + + var joinCallResponse = await ServerCallRestClient.JoinCallAsync( + serverCallId: serverCallId, + source: CommunicationIdentifierSerializer.Serialize(source), + callbackUri: callOptions.CallbackUri?.AbsoluteUri, + requestedMediaTypes: callOptions.RequestedMediaTypes, + requestedCallEvents: callOptions.RequestedCallEvents, + subject: null, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return Response.FromValue( + new CallConnection(joinCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics), + joinCallResponse.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Join the call using server call id. + /// The server call id. + /// The source identity. + /// The call Options. + /// The cancellation token. + /// The server returned an error. See for details returned from the server. + /// is null. + /// is null. + /// is null. + public virtual Response JoinCall(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCall)}"); + scope.Start(); + try + { + Argument.AssertNotNull(source, nameof(source)); + Argument.AssertNotNull(callOptions, nameof(callOptions)); + + var joinCallResponse = ServerCallRestClient.JoinCall( + serverCallId: serverCallId, + source: CommunicationIdentifierSerializer.Serialize(source), + callbackUri: callOptions.CallbackUri?.AbsoluteUri, + requestedMediaTypes: callOptions.RequestedMediaTypes, + requestedCallEvents: callOptions.RequestedCallEvents, + subject: null, + cancellationToken: cancellationToken + ); + + return Response.FromValue( + new CallConnection(joinCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics), + joinCallResponse.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Initializes a new instance of CallConnection. . + /// The thread id for the ChatThreadClient instance. + public virtual CallConnection GetCallConnection(string callConnectionId) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(CallingServerClient)}"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(callConnectionId, nameof(callConnectionId)); + + return new CallConnection(callConnectionId, CallConnectionRestClient, _clientDiagnostics); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Initializes a server call. + /// + /// The server call id. + /// + public virtual ServerCall InitializeServerCall(string serverCallId) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(InitializeServerCall)}"); + scope.Start(); + try + { + Argument.AssertNotNull(serverCallId, nameof(serverCallId)); + + return new ServerCall(serverCallId, ServerCallRestClient, _clientDiagnostics); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// The + /// operation downloads the recording's content. + /// + /// + /// + /// Recording's content's url location. + /// + /// + /// If provided, only download the bytes of the content in the specified range. + /// If not provided, download the entire content. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A containing the + /// downloaded content. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual async Task> DownloadStreamingAsync( + Uri sourceEndpoint, + HttpRange range = default, + CancellationToken cancellationToken = default) => + await _contentDownloader.DownloadStreamingInternal( + sourceEndpoint, + range, + async: true, + cancellationToken) + .ConfigureAwait(false); + + /// + /// The + /// operation downloads the recording's content. + /// + /// + /// + /// Recording's content's url location. + /// + /// + /// If provided, only download the bytes of the content in the specified range. + /// If not provided, download the entire content. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A containing the + /// downloaded content. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual Response DownloadStreaming( + Uri sourceEndpoint, + HttpRange range = default, + CancellationToken cancellationToken = default) => + _contentDownloader.DownloadStreamingInternal( + sourceEndpoint, + range, + async: false, + cancellationToken) + .EnsureCompleted(); + + /// + /// The + /// operation downloads the specified content using parallel requests, + /// and writes the content to . + /// + /// + /// A with the Recording's content's url location. + /// + /// + /// A to write the downloaded content to. + /// + /// + /// Optional to configure + /// parallel transfer behavior. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A describing the operation. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual Response DownloadTo(Uri sourceEndpoint, Stream destinationStream, + ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) => + _contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: false, cancellationToken: cancellationToken).EnsureCompleted(); + + /// + /// The + /// operation downloads the specified content using parallel requests, + /// and writes the content to . + /// + /// + /// A with the Recording's content's url location. + /// + /// + /// A to write the downloaded content to. + /// + /// + /// Optional to configure + /// parallel transfer behavior. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A describing the operation. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual async Task DownloadToAsync(Uri sourceEndpoint, Stream destinationStream, ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) => + await _contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: true, cancellationToken: cancellationToken).ConfigureAwait(false); + + /// + /// The + /// operation downloads the specified content using parallel requests, + /// and writes the content to . + /// + /// + /// A with the Recording's content's url location. + /// + /// + /// A file path to write the downloaded content to. + /// + /// + /// Optional to configure + /// parallel transfer behavior. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A describing the operation. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual Response DownloadTo(Uri sourceEndpoint, string destinationPath, + ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) + { + using Stream destination = File.Create(destinationPath); + return _contentDownloader.StagedDownloadAsync(sourceEndpoint, destination, transferOptions, + async: false, cancellationToken: cancellationToken).EnsureCompleted(); + } + + /// + /// The + /// operation downloads the specified content using parallel requests, + /// and writes the content to . + /// + /// + /// A with the Recording's content's url location. + /// + /// + /// A file path to write the downloaded content to. + /// + /// + /// Optional to configure + /// parallel transfer behavior. + /// + /// + /// Optional to propagate + /// notifications that the operation should be cancelled. + /// + /// + /// A describing the operation. + /// + /// + /// A will be thrown if + /// a failure occurs. + /// + public virtual async Task DownloadToAsync(Uri sourceEndpoint, string destinationPath, + ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) + { + using Stream destination = File.Create(destinationPath); + return await _contentDownloader.StagedDownloadAsync(sourceEndpoint, destination, transferOptions, + async: true, cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/CallClientOptions.cs b/sdk/communication/Azure.Communication.CallingServer/src/CallingServerClientOptions.cs similarity index 65% rename from sdk/communication/Azure.Communication.CallingServer/src/CallClientOptions.cs rename to sdk/communication/Azure.Communication.CallingServer/src/CallingServerClientOptions.cs index 6427a29955615..737b9a76425b3 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/CallClientOptions.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/CallingServerClientOptions.cs @@ -7,25 +7,25 @@ namespace Azure.Communication.CallingServer { /// - /// The options for communication . + /// The options for communication and . /// - public class CallClientOptions : ClientOptions + public class CallingServerClientOptions : ClientOptions { /// /// The latest version of the CallingServer service. /// - public const ServiceVersion LatestVersion = ServiceVersion.V2021_04_15_Preview1; + internal const ServiceVersion LatestVersion = ServiceVersion.V2021_06_15_Preview; internal string ApiVersion { get; } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// - public CallClientOptions(ServiceVersion version = LatestVersion) + public CallingServerClientOptions(ServiceVersion version = LatestVersion) { ApiVersion = version switch { - ServiceVersion.V2021_04_15_Preview1 => "2021-04-15-preview1", + ServiceVersion.V2021_06_15_Preview => "2021-06-15-preview", _ => throw new ArgumentOutOfRangeException(nameof(version)), }; } @@ -39,7 +39,7 @@ public enum ServiceVersion /// The Beta of the CallingServer service. /// #pragma warning disable CA1707 // Identifiers should not contain underscores - V2021_04_15_Preview1 = 0 + V2021_06_15_Preview = 1 #pragma warning restore CA1707 // Identifiers should not contain underscores } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/ConversationClient.cs b/sdk/communication/Azure.Communication.CallingServer/src/ConversationClient.cs deleted file mode 100644 index e95c96d460785..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/ConversationClient.cs +++ /dev/null @@ -1,863 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.Communication.Pipeline; -using System.Collections.Generic; -using System.Linq; -using System.IO; - -namespace Azure.Communication.CallingServer -{ - /// - /// The Azure Communication Services Conversation Client. - /// - public class ConversationClient - { - internal readonly ClientDiagnostics _clientDiagnostics; - internal readonly HttpPipeline _pipeline; - internal readonly string _resourceEndpoint; - private readonly ContentDownloader _contentDownloader; - - internal ConversationRestClient RestClient { get; } - - #region public constructors - all arguments need null check - - /// Initializes a new instance of . - /// Connection string acquired from the Azure Communication Services resource. - public ConversationClient(string connectionString) - : this( - ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), - new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// Connection string acquired from the Azure Communication Services resource. - /// Client option exposing , , , etc. - public ConversationClient(string connectionString, CallClientOptions options) - : this( - ConnectionString.Parse(Argument.CheckNotNullOrEmpty(connectionString, nameof(connectionString))), - options ?? new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// The URI of the Azure Communication Services resource. - /// The used to authenticate requests. - /// Client option exposing , , , etc. - public ConversationClient(Uri endpoint, AzureKeyCredential keyCredential, CallClientOptions options = default) - : this( - Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri, - Argument.CheckNotNull(keyCredential, nameof(keyCredential)), - options ?? new CallClientOptions()) - { } - - /// Initializes a new instance of . - /// The URI of the Azure Communication Services resource. - /// The TokenCredential used to authenticate requests, such as DefaultAzureCredential. - /// Client option exposing , , , etc. - public ConversationClient(Uri endpoint, TokenCredential tokenCredential, CallClientOptions options = default) - : this( - Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri, - Argument.CheckNotNull(tokenCredential, nameof(tokenCredential)), - options ?? new CallClientOptions()) - { } - - #endregion - - #region private constructors - - private ConversationClient(ConnectionString connectionString, CallClientOptions options) - : this(connectionString.GetRequired("endpoint"), options.BuildHttpPipeline(connectionString), options) - { } - - private ConversationClient(string endpoint, TokenCredential tokenCredential, CallClientOptions options) - : this(endpoint, options.BuildHttpPipeline(tokenCredential), options) - { } - - private ConversationClient(string endpoint, AzureKeyCredential keyCredential, CallClientOptions options) - : this(endpoint, options.BuildHttpPipeline(keyCredential), options) - { } - - private ConversationClient(string endpoint, HttpPipeline httpPipeline, CallClientOptions options) - { - _clientDiagnostics = new ClientDiagnostics(options); - _pipeline = httpPipeline; - _resourceEndpoint = endpoint; - _contentDownloader = new(this); - RestClient = new ConversationRestClient(_clientDiagnostics, httpPipeline, endpoint, options.ApiVersion); - } - - #endregion - - /// Initializes a new instance of for mocking. - protected ConversationClient() - { - _clientDiagnostics = null; - _pipeline = null; - _resourceEndpoint = null; - _contentDownloader = new(this); - RestClient = null; - } - - /// Join the call using conversation id. - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The source identity. - /// The call Options. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - /// is null. - /// is null. - public virtual async Task> JoinCallAsync(string conversationId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(JoinCall)}"); - scope.Start(); - try - { - Argument.AssertNotNull(source, nameof(source)); - Argument.AssertNotNull(callOptions, nameof(callOptions)); - - return await RestClient.JoinCallAsync( - conversationId: conversationId, - source: CommunicationIdentifierSerializer.Serialize(source), - callbackUri: callOptions.CallbackUri?.AbsoluteUri, - requestedModalities: callOptions.RequestedModalities, - requestedCallEvents: callOptions.RequestedCallEvents, - subject: null, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Join the call using conversation id. - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The source identity. - /// The call Options. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - /// is null. - /// is null. - public virtual Response JoinCall(string conversationId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(JoinCall)}"); - scope.Start(); - try - { - Argument.AssertNotNull(source, nameof(source)); - Argument.AssertNotNull(callOptions, nameof(callOptions)); - - return RestClient.JoinCall( - conversationId: conversationId, - source: CommunicationIdentifierSerializer.Serialize(source), - callbackUri: callOptions.CallbackUri?.AbsoluteUri, - requestedModalities: callOptions.RequestedModalities, - requestedCallEvents: callOptions.RequestedCallEvents, - subject: null, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Play audio in the call. - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The uri of the audio file. - /// Tne id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. - /// The operation context. - /// The cancellation token to use. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task> PlayAudioAsync(string conversationId, Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) - => await PlayAudioAsync( - conversationId: conversationId, - options: new PlayAudioOptions - { - AudioFileUri = audioFileUri, - AudioFileId = audioFileId, - CallbackUri = callbackUri, - OperationContext = operationContext - }, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - - /// Play audio in the call. - /// The call leg id. - /// Play audio request. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual async Task> PlayAudioAsync(string conversationId, PlayAudioOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudio)}"); - scope.Start(); - try - { - Argument.AssertNotNull(options, nameof(options)); - - // Currently looping media is not supported for out-call scenarios, thus setting it to false. - return await RestClient.PlayAudioAsync( - conversationId: conversationId, - audioFileUri: options.AudioFileUri?.AbsoluteUri, - loop: false, - audioFileId: options.AudioFileId, - callbackUri: options.CallbackUri?.AbsoluteUri, - operationContext: options.OperationContext, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// Play audio in the call. - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The uri of the audio file. - /// Tne id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. - /// The operation context. - /// The cancellation token to use. - /// - public virtual Response PlayAudio(string conversationId, Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) - => PlayAudio( - conversationId: conversationId, - options: new PlayAudioOptions - { - AudioFileUri = audioFileUri, - AudioFileId = audioFileId, - CallbackUri = callbackUri, - OperationContext = operationContext - }, - cancellationToken: cancellationToken - ); - - /// Play audio in the call. - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// Play audio request. - /// The cancellation token. - /// The server returned an error. See for details returned from the server. - /// is null. - public virtual Response PlayAudio(string conversationId, PlayAudioOptions options, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudio)}"); - scope.Start(); - try - { - Argument.AssertNotNull(options, nameof(options)); - - // Currently looping media is not supported for out-call scenarios, thus setting it to false. - return RestClient.PlayAudio( - conversationId: conversationId, - audioFileUri: options.AudioFileUri?.AbsoluteUri, - loop: false, - audioFileId: options.AudioFileId, - callbackUri: options.CallbackUri?.AbsoluteUri, - operationContext: options.OperationContext, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Add participant to the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The identity of participant to be added to the call. - /// The callback uri to receive the notification. - /// The phone number to use when adding a pstn participant. - /// The operation context. - /// The cancellation token. - public virtual Response AddParticipant(string conversationId, CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(AddParticipant)}"); - scope.Start(); - try - { - Argument.AssertNotNull(participant, nameof(participant)); - - var participantsInternal = new List { CommunicationIdentifierSerializer.Serialize(participant) }; - var alternateCallerIdInternal = string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId); - return RestClient.InviteParticipants( - conversationId: conversationId, - participants: participantsInternal, - alternateCallerId: alternateCallerIdInternal, - callbackUri: callbackUri?.AbsoluteUri, - operationContext: operationContext, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Add participant to the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The identity of participant to be added to the call. - /// - /// The phone number to use when adding a pstn participant. - /// The operation context. - /// The cancellation token. - public virtual async Task AddParticipantAsync(string conversationId, CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(AddParticipant)}"); - scope.Start(); - try - { - Argument.AssertNotNull(participant, nameof(participant)); - - var participantsInternal = new List { CommunicationIdentifierSerializer.Serialize(participant) }; - var alternateCallerIdInternal = string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId); - return await RestClient.InviteParticipantsAsync( - conversationId: conversationId, - participants: participantsInternal, - alternateCallerId: alternateCallerIdInternal, - callbackUri: callbackUri?.AbsoluteUri, - operationContext: operationContext, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Remove participant from the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The participant id. - /// The cancellation token. - public virtual Response RemoveParticipant(string conversationId, string participantId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(RemoveParticipant)}"); - scope.Start(); - try - { - return RestClient.RemoveParticipant( - conversationId: conversationId, - participantId: participantId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Remove participant from the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The participant id. - /// The cancellation token. - public virtual async Task RemoveParticipantAsync(string conversationId, string participantId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(RemoveParticipant)}"); - scope.Start(); - try - { - return await RestClient.RemoveParticipantAsync( - conversationId: conversationId, - participantId: participantId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Start recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The uri to send state change callbacks. - /// The cancellation token. - public virtual async Task> StartRecordingAsync(string conversationId, Uri recordingStateCallbackUri, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(StartRecording)}"); - scope.Start(); - try - { - return await RestClient.StartRecordingAsync( - conversationId: conversationId, - recordingStateCallbackUri: recordingStateCallbackUri.AbsoluteUri, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Start recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The uri to send state change callbacks. - /// The cancellation token. - public virtual Response StartRecording(string conversationId, Uri recordingStateCallbackUri, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(StartRecording)}"); - scope.Start(); - try - { - return RestClient.StartRecording( - conversationId: conversationId, - recordingStateCallbackUri: recordingStateCallbackUri.AbsoluteUri, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Get the current recording state by recording id. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to get the state of. - /// The cancellation token. - public virtual async Task> GetRecordingStateAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(GetRecordingState)}"); - scope.Start(); - try - { - return await RestClient.RecordingStateAsync( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Get the current recording state by recording id. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to get the state of. - /// The cancellation token. - public virtual Response GetRecordingState(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(GetRecordingState)}"); - scope.Start(); - try - { - return RestClient.RecordingState( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Stop recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to stop. - /// The cancellation token. - public virtual async Task StopRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(StopRecording)}"); - scope.Start(); - try - { - return await RestClient.StopRecordingAsync( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Stop recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to stop. - /// The cancellation token. - public virtual Response StopRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(StopRecording)}"); - scope.Start(); - try - { - return RestClient.StopRecording( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Pause recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to pause. - /// The cancellation token. - public virtual async Task PauseRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PauseRecording)}"); - scope.Start(); - try - { - return await RestClient.PauseRecordingAsync( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Pause recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to pause. - /// The cancellation token. - public virtual Response PauseRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PauseRecording)}"); - scope.Start(); - try - { - return RestClient.PauseRecording( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// Resume recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to pause. - /// The cancellation token. - public virtual async Task ResumeRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(ResumeRecording)}"); - scope.Start(); - try - { - return await RestClient.ResumeRecordingAsync( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ).ConfigureAwait(false); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// resume recording of the call. - /// - /// The conversation id that can be a group id or a encoded conversation url retrieve from client. - /// The recording id to resume. - /// The cancellation token. - public virtual Response ResumeRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) - { - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(ResumeRecording)}"); - scope.Start(); - try - { - return RestClient.ResumeRecording( - conversationId: conversationId, - recordingId: recordingId, - cancellationToken: cancellationToken - ); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } - } - - /// - /// The - /// operation downloads the recording's content. - /// - /// - /// - /// Recording's content's url location. - /// - /// - /// If provided, only download the bytes of the content in the specified range. - /// If not provided, download the entire content. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A containing the - /// downloaded content. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual async Task> DownloadStreamingAsync( - Uri sourceEndpoint, - HttpRange range = default, - CancellationToken cancellationToken = default) => - await _contentDownloader.DownloadStreamingInternal( - sourceEndpoint, - range, - async: true, - cancellationToken) - .ConfigureAwait(false); - - /// - /// The - /// operation downloads the recording's content. - /// - /// - /// - /// Recording's content's url location. - /// - /// - /// If provided, only download the bytes of the content in the specified range. - /// If not provided, download the entire content. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A containing the - /// downloaded content. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual Response DownloadStreaming( - Uri sourceEndpoint, - HttpRange range = default, - CancellationToken cancellationToken = default) => - _contentDownloader.DownloadStreamingInternal( - sourceEndpoint, - range, - async: false, - cancellationToken) - .EnsureCompleted(); - - /// - /// The - /// operation downloads the specified content using parallel requests, - /// and writes the content to . - /// - /// - /// A with the Recording's content's url location. - /// - /// - /// A to write the downloaded content to. - /// - /// - /// Optional to configure - /// parallel transfer behavior. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A describing the operation. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual Response DownloadTo(Uri sourceEndpoint, Stream destinationStream, - ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) => - _contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: false, cancellationToken: cancellationToken).EnsureCompleted(); - - /// - /// The - /// operation downloads the specified content using parallel requests, - /// and writes the content to . - /// - /// - /// A with the Recording's content's url location. - /// - /// - /// A to write the downloaded content to. - /// - /// - /// Optional to configure - /// parallel transfer behavior. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A describing the operation. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual async Task DownloadToAsync(Uri sourceEndpoint, Stream destinationStream, ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) => - await _contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: true, cancellationToken: cancellationToken).ConfigureAwait(false); - - /// - /// The - /// operation downloads the specified content using parallel requests, - /// and writes the content to . - /// - /// - /// A with the Recording's content's url location. - /// - /// - /// A file path to write the downloaded content to. - /// - /// - /// Optional to configure - /// parallel transfer behavior. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A describing the operation. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual Response DownloadTo(Uri sourceEndpoint, string destinationPath, - ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) - { - using Stream destination = File.Create(destinationPath); - return _contentDownloader.StagedDownloadAsync(sourceEndpoint, destination, transferOptions, - async: false, cancellationToken: cancellationToken).EnsureCompleted(); - } - - /// - /// The - /// operation downloads the specified content using parallel requests, - /// and writes the content to . - /// - /// - /// A with the Recording's content's url location. - /// - /// - /// A file path to write the downloaded content to. - /// - /// - /// Optional to configure - /// parallel transfer behavior. - /// - /// - /// Optional to propagate - /// notifications that the operation should be cancelled. - /// - /// - /// A describing the operation. - /// - /// - /// A will be thrown if - /// a failure occurs. - /// - public virtual async Task DownloadToAsync(Uri sourceEndpoint, string destinationPath, - ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) - { - using Stream destination = File.Create(destinationPath); - return await _contentDownloader.StagedDownloadAsync(sourceEndpoint, destination, transferOptions, - async: true, cancellationToken: cancellationToken).ConfigureAwait(false); - } - - private static T AssertNotNull(T argument, string argumentName) - where T : class - { - Argument.AssertNotNull(argument, argumentName); - return argument; - } - - private static string AssertNotNullOrEmpty(string argument, string argumentName) - { - Argument.AssertNotNullOrEmpty(argument, argumentName); - return argument; - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Constants.cs b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/Constants.cs similarity index 100% rename from sdk/communication/Azure.Communication.CallingServer/src/Constants.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Downloader/Constants.cs diff --git a/sdk/communication/Azure.Communication.CallingServer/src/ContentDownloader.cs b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs similarity index 97% rename from sdk/communication/Azure.Communication.CallingServer/src/ContentDownloader.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs index 74a5aac01b5d3..59cc2248299a0 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/ContentDownloader.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs @@ -12,9 +12,9 @@ namespace Azure.Communication.CallingServer { internal class ContentDownloader { - private readonly ConversationClient _client; + private readonly CallingServerClient _client; - internal ContentDownloader(ConversationClient client) + internal ContentDownloader(CallingServerClient client) { _client = client; } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/PartitionedDownloader.cs b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/PartitionedDownloader.cs similarity index 98% rename from sdk/communication/Azure.Communication.CallingServer/src/PartitionedDownloader.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Downloader/PartitionedDownloader.cs index 0309a1f6ca362..23ff1ce9a56da 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/PartitionedDownloader.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/PartitionedDownloader.cs @@ -15,7 +15,7 @@ internal class PartitionedDownloader /// /// The client used to download the blob. /// - private readonly ConversationClient _client; + private readonly CallingServerClient _client; /// /// The maximum number of simultaneous workers. @@ -34,7 +34,7 @@ internal class PartitionedDownloader private readonly long _rangeSize; internal PartitionedDownloader( - ConversationClient client, + CallingServerClient client, ContentTransferOptions transferOptions = default) { _client = client; diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/AzureCommunicationCallingServerServiceModelFactory.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/AzureCommunicationCallingServerServiceModelFactory.cs deleted file mode 100644 index 7a1b5cdbef82d..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/AzureCommunicationCallingServerServiceModelFactory.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// Model factory for read-only models. - public static partial class AzureCommunicationCallingServerServiceModelFactory - { - /// Initializes new instance of CreateCallResponse class. - /// Call leg id of the call. - /// A new instance for mocking. - public static CreateCallResponse CreateCallResponse(string callLegId = default) - { - return new CreateCallResponse(callLegId); - } - - /// Initializes new instance of PlayAudioResponse class. - /// Gets or sets the identifier. - /// Gets or sets the status of the operation. - /// Gets or sets the operation context. - /// Gets or sets the result info. - /// A new instance for mocking. - public static PlayAudioResponse PlayAudioResponse(string id = default, OperationStatus? status = default, string operationContext = default, ResultInfo resultInfo = default) - { - return new PlayAudioResponse(id, status, operationContext, resultInfo); - } - - /// Initializes new instance of ResultInfo class. - /// - /// Gets or sets the result code - /// - /// For synchronous failures, this maps one-to-one with HTTP responses. For asynchronous failures or messages, it is contextual. - /// - /// - /// Gets or sets the result subcode. - /// - /// The subcode further classifies a failure. For example. - /// - /// - /// Gets or sets the message - /// - /// The message is a detail explanation of subcode. - /// - /// A new instance for mocking. - public static ResultInfo ResultInfo(int? code = default, int? subcode = default, string message = default) - { - return new ResultInfo(code, subcode, message); - } - - /// Initializes new instance of CancelAllMediaOperationsResponse class. - /// Gets or sets the identifier. - /// Gets or sets the status of the operation. - /// Gets or sets the operation context. - /// Gets or sets the result info. - /// A new instance for mocking. - public static CancelAllMediaOperationsResponse CancelAllMediaOperationsResponse(string id = default, OperationStatus? status = default, string operationContext = default, ResultInfo resultInfo = default) - { - return new CancelAllMediaOperationsResponse(id, status, operationContext, resultInfo); - } - - /// Initializes new instance of JoinCallResponse class. - /// Call leg id of the call. - /// A new instance for mocking. - public static JoinCallResponse JoinCallResponse(string callLegId = default) - { - return new JoinCallResponse(callLegId); - } - - /// Initializes new instance of StartCallRecordingResponse class. - /// The recording id of the started recording. - /// A new instance for mocking. - public static StartCallRecordingResponse StartCallRecordingResponse(string recordingId = default) - { - return new StartCallRecordingResponse(recordingId); - } - - /// Initializes new instance of GetCallRecordingStateResponse class. - /// The recording state of the recording. - /// A new instance for mocking. - public static GetCallRecordingStateResponse GetCallRecordingStateResponse(CallRecordingState? recordingState = default) - { - return new GetCallRecordingStateResponse(recordingState); - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallRestClient.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallConnectionsRestClient.cs similarity index 57% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/CallRestClient.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/CallConnectionsRestClient.cs index 8724406844a5b..d5010fe774dc6 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallRestClient.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallConnectionsRestClient.cs @@ -18,20 +18,20 @@ namespace Azure.Communication.CallingServer { - internal partial class CallRestClient + internal partial class CallConnectionsRestClient { private string endpoint; private string apiVersion; private ClientDiagnostics _clientDiagnostics; private HttpPipeline _pipeline; - /// Initializes a new instance of CallRestClient. + /// Initializes a new instance of CallConnectionsRestClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. /// The endpoint of the Azure Communication resource. /// Api Version. /// or is null. - public CallRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiVersion = "2021-04-15-preview1") + public CallConnectionsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiVersion = "2021-06-15-preview") { if (endpoint == null) { @@ -48,23 +48,38 @@ public CallRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline _pipeline = pipeline; } - internal HttpMessage CreateCreateCallRequest(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, PhoneNumberIdentifierModel sourceAlternateIdentity, string subject) + internal HttpMessage CreateCreateCallRequest(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, PhoneNumberIdentifierModel alternateCallerId, string subject, IEnumerable requestedMediaTypes, IEnumerable requestedCallEvents) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls", false); + uri.AppendPath("/calling/callConnections", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); - var model = new CreateCallRequestInternal(targets.ToList(), source, callbackUri, requestedModalities.ToList(), requestedCallEvents.ToList()) + CreateCallRequestInternal createCallRequestInternal = new CreateCallRequestInternal(targets.ToList(), source, callbackUri) { - SourceAlternateIdentity = sourceAlternateIdentity, + AlternateCallerId = alternateCallerId, Subject = subject }; + if (requestedMediaTypes != null) + { + foreach (var value in requestedMediaTypes) + { + createCallRequestInternal.RequestedMediaTypes.Add(value); + } + } + if (requestedCallEvents != null) + { + foreach (var value in requestedCallEvents) + { + createCallRequestInternal.RequestedCallEvents.Add(value); + } + } + var model = createCallRequestInternal; var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(model); request.Content = content; @@ -75,13 +90,13 @@ internal HttpMessage CreateCreateCallRequest(IEnumerable The targets of the call. /// The source of the call. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// The alternate identity of the source of the call if dialing out to a pstn number. + /// The alternate identity of the source of the call if dialing out to a pstn number. /// The subject. + /// The requested modalities. + /// The requested call events to subscribe to. /// The cancellation token to use. - /// , , , , or is null. - public async Task> CreateCallAsync(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, PhoneNumberIdentifierModel sourceAlternateIdentity = null, string subject = null, CancellationToken cancellationToken = default) + /// , , or is null. + public async Task> CreateCallAsync(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, PhoneNumberIdentifierModel alternateCallerId = null, string subject = null, IEnumerable requestedMediaTypes = null, IEnumerable requestedCallEvents = null, CancellationToken cancellationToken = default) { if (targets == null) { @@ -95,24 +110,16 @@ public async Task> CreateCallAsync(IEnumerable> CreateCallAsync(IEnumerable The targets of the call. /// The source of the call. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// The alternate identity of the source of the call if dialing out to a pstn number. + /// The alternate identity of the source of the call if dialing out to a pstn number. /// The subject. + /// The requested modalities. + /// The requested call events to subscribe to. /// The cancellation token to use. - /// , , , , or is null. - public Response CreateCall(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, PhoneNumberIdentifierModel sourceAlternateIdentity = null, string subject = null, CancellationToken cancellationToken = default) + /// , , or is null. + public Response CreateCall(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, PhoneNumberIdentifierModel alternateCallerId = null, string subject = null, IEnumerable requestedMediaTypes = null, IEnumerable requestedCallEvents = null, CancellationToken cancellationToken = default) { if (targets == null) { @@ -144,24 +151,16 @@ public Response CreateCall(IEnumerable CreateCall(IEnumerable Hangup a call. - /// Call id. + /// Hangup the call. + /// The call connection id. /// The cancellation token to use. - /// is null. - public async Task HangupCallAsync(string callId, CancellationToken cancellationToken = default) + /// is null. + public async Task HangupCallAsync(string callConnectionId, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateHangupCallRequest(callId); + using var message = CreateHangupCallRequest(callConnectionId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -207,18 +206,18 @@ public async Task HangupCallAsync(string callId, CancellationToken can } } - /// Hangup a call. - /// Call id. + /// Hangup the call. + /// The call connection id. /// The cancellation token to use. - /// is null. - public Response HangupCall(string callId, CancellationToken cancellationToken = default) + /// is null. + public Response HangupCall(string callConnectionId, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateHangupCallRequest(callId); + using var message = CreateHangupCallRequest(callConnectionId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -229,75 +228,16 @@ public Response HangupCall(string callId, CancellationToken cancellationToken = } } - internal HttpMessage CreateDeleteCallRequest(string callId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls/", false); - uri.AppendPath(callId, true); - uri.AppendQuery("api-version", apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - /// Delete a call. - /// Call id. - /// The cancellation token to use. - /// is null. - public async Task DeleteCallAsync(string callId, CancellationToken cancellationToken = default) - { - if (callId == null) - { - throw new ArgumentNullException(nameof(callId)); - } - - using var message = CreateDeleteCallRequest(callId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - return message.Response; - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Delete a call. - /// Call id. - /// The cancellation token to use. - /// is null. - public Response DeleteCall(string callId, CancellationToken cancellationToken = default) - { - if (callId == null) - { - throw new ArgumentNullException(nameof(callId)); - } - - using var message = CreateDeleteCallRequest(callId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - return message.Response; - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreatePlayAudioRequest(string callId, string audioFileUri, bool? loop, string operationContext, string audioFileId, string callbackUri) + internal HttpMessage CreatePlayAudioRequest(string callConnectionId, string audioFileUri, bool? loop, string operationContext, string audioFileId, string callbackUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls/", false); - uri.AppendPath(callId, true); - uri.AppendPath("/PlayAudio", false); + uri.AppendPath("/calling/callConnections/", false); + uri.AppendPath(callConnectionId, true); + uri.AppendPath("/:playAudio", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -316,8 +256,8 @@ internal HttpMessage CreatePlayAudioRequest(string callId, string audioFileUri, return message; } - /// Play audio in a call. - /// The call id. + /// Play audio in the call. + /// The call connection id. /// /// The media resource uri of the play audio request. /// @@ -332,23 +272,23 @@ internal HttpMessage CreatePlayAudioRequest(string callId, string audioFileUri, /// An id for the media in the AudioFileUri, using which we cache the media resource. /// The callback Uri to receive PlayAudio status notifications. /// The cancellation token to use. - /// is null. - public async Task> PlayAudioAsync(string callId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public async Task> PlayAudioAsync(string callConnectionId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreatePlayAudioRequest(callId, audioFileUri, loop, operationContext, audioFileId, callbackUri); + using var message = CreatePlayAudioRequest(callConnectionId, audioFileUri, loop, operationContext, audioFileId, callbackUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: { - PlayAudioResponse value = default; + PlayAudioResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PlayAudioResponse.DeserializePlayAudioResponse(document.RootElement); + value = PlayAudioResult.DeserializePlayAudioResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -356,8 +296,8 @@ public async Task> PlayAudioAsync(string callId, str } } - /// Play audio in a call. - /// The call id. + /// Play audio in the call. + /// The call connection id. /// /// The media resource uri of the play audio request. /// @@ -372,23 +312,23 @@ public async Task> PlayAudioAsync(string callId, str /// An id for the media in the AudioFileUri, using which we cache the media resource. /// The callback Uri to receive PlayAudio status notifications. /// The cancellation token to use. - /// is null. - public Response PlayAudio(string callId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public Response PlayAudio(string callConnectionId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreatePlayAudioRequest(callId, audioFileUri, loop, operationContext, audioFileId, callbackUri); + using var message = CreatePlayAudioRequest(callConnectionId, audioFileUri, loop, operationContext, audioFileId, callbackUri); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 202: { - PlayAudioResponse value = default; + PlayAudioResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PlayAudioResponse.DeserializePlayAudioResponse(document.RootElement); + value = PlayAudioResult.DeserializePlayAudioResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -396,16 +336,16 @@ public Response PlayAudio(string callId, string audioFileUri } } - internal HttpMessage CreateCancelAllMediaOperationsRequest(string callId, string operationContext) + internal HttpMessage CreateCancelAllMediaOperationsRequest(string callConnectionId, string operationContext) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls/", false); - uri.AppendPath(callId, true); - uri.AppendPath("/CancelMediaProcessing", false); + uri.AppendPath("/calling/callConnections/", false); + uri.AppendPath(callConnectionId, true); + uri.AppendPath("/:cancelAllMediaOperations", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); @@ -420,27 +360,27 @@ internal HttpMessage CreateCancelAllMediaOperationsRequest(string callId, string return message; } - /// Cancel Media Processing. - /// The call id. + /// Cancel all media operations. + /// The call connection id. /// The context for this operation. /// The cancellation token to use. - /// is null. - public async Task> CancelAllMediaOperationsAsync(string callId, string operationContext = null, CancellationToken cancellationToken = default) + /// is null. + public async Task> CancelAllMediaOperationsAsync(string callConnectionId, string operationContext = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateCancelAllMediaOperationsRequest(callId, operationContext); + using var message = CreateCancelAllMediaOperationsRequest(callConnectionId, operationContext); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - CancelAllMediaOperationsResponse value = default; + CancelAllMediaOperationsResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = CancelAllMediaOperationsResponse.DeserializeCancelAllMediaOperationsResponse(document.RootElement); + value = CancelAllMediaOperationsResult.DeserializeCancelAllMediaOperationsResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -448,27 +388,27 @@ public async Task> CancelAllMediaOper } } - /// Cancel Media Processing. - /// The call id. + /// Cancel all media operations. + /// The call connection id. /// The context for this operation. /// The cancellation token to use. - /// is null. - public Response CancelAllMediaOperations(string callId, string operationContext = null, CancellationToken cancellationToken = default) + /// is null. + public Response CancelAllMediaOperations(string callConnectionId, string operationContext = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateCancelAllMediaOperationsRequest(callId, operationContext); + using var message = CreateCancelAllMediaOperationsRequest(callConnectionId, operationContext); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - CancelAllMediaOperationsResponse value = default; + CancelAllMediaOperationsResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = CancelAllMediaOperationsResponse.DeserializeCancelAllMediaOperationsResponse(document.RootElement); + value = CancelAllMediaOperationsResult.DeserializeCancelAllMediaOperationsResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -476,23 +416,24 @@ public Response CancelAllMediaOperations(strin } } - internal HttpMessage CreateInviteParticipantsRequest(string callId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId, string operationContext, string callbackUri) + internal HttpMessage CreateAddParticipantRequest(string callConnectionId, PhoneNumberIdentifierModel alternateCallerId, CommunicationIdentifierModel participant, string operationContext, string callbackUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls/", false); - uri.AppendPath(callId, true); + uri.AppendPath("/calling/callConnections/", false); + uri.AppendPath(callConnectionId, true); uri.AppendPath("/participants", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); - var model = new InviteParticipantsRequestInternal(participants.ToList()) + var model = new AddParticipantRequest() { AlternateCallerId = alternateCallerId, + Participant = participant, OperationContext = operationContext, CallbackUri = callbackUri }; @@ -502,75 +443,77 @@ internal HttpMessage CreateInviteParticipantsRequest(string callId, IEnumerable< return message; } - /// Invite participants to the call. - /// Call id. - /// The list of participants to be added to the call. + /// Add a participant to the call. + /// The call connection id. /// The alternate identity of source participant. + /// The participant to be added to the call. /// The operation context. /// The callback URI. /// The cancellation token to use. - /// or is null. - public async Task InviteParticipantsAsync(string callId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public async Task> AddParticipantAsync(string callConnectionId, PhoneNumberIdentifierModel alternateCallerId = null, CommunicationIdentifierModel participant = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); - } - if (participants == null) - { - throw new ArgumentNullException(nameof(participants)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateInviteParticipantsRequest(callId, participants, alternateCallerId, operationContext, callbackUri); + using var message = CreateAddParticipantRequest(callConnectionId, alternateCallerId, participant, operationContext, callbackUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: - return message.Response; + { + AddParticipantResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AddParticipantResult.DeserializeAddParticipantResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Invite participants to the call. - /// Call id. - /// The list of participants to be added to the call. + /// Add a participant to the call. + /// The call connection id. /// The alternate identity of source participant. + /// The participant to be added to the call. /// The operation context. /// The callback URI. /// The cancellation token to use. - /// or is null. - public Response InviteParticipants(string callId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public Response AddParticipant(string callConnectionId, PhoneNumberIdentifierModel alternateCallerId = null, CommunicationIdentifierModel participant = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); - } - if (participants == null) - { - throw new ArgumentNullException(nameof(participants)); + throw new ArgumentNullException(nameof(callConnectionId)); } - using var message = CreateInviteParticipantsRequest(callId, participants, alternateCallerId, operationContext, callbackUri); + using var message = CreateAddParticipantRequest(callConnectionId, alternateCallerId, participant, operationContext, callbackUri); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 202: - return message.Response; + { + AddParticipantResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AddParticipantResult.DeserializeAddParticipantResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateRemoveParticipantRequest(string callId, string participantId) + internal HttpMessage CreateRemoveParticipantRequest(string callConnectionId, string participantId) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Delete; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/calls/", false); - uri.AppendPath(callId, true); + uri.AppendPath("/calling/callConnections/", false); + uri.AppendPath(callConnectionId, true); uri.AppendPath("/participants/", false); uri.AppendPath(participantId, true); uri.AppendQuery("api-version", apiVersion, true); @@ -579,23 +522,23 @@ internal HttpMessage CreateRemoveParticipantRequest(string callId, string partic return message; } - /// Remove participant from the call. - /// Call id. - /// Participant id. + /// Remove a participant from the call. + /// The call connection id. + /// The participant id. /// The cancellation token to use. - /// or is null. - public async Task RemoveParticipantAsync(string callId, string participantId, CancellationToken cancellationToken = default) + /// or is null. + public async Task RemoveParticipantAsync(string callConnectionId, string participantId, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } if (participantId == null) { throw new ArgumentNullException(nameof(participantId)); } - using var message = CreateRemoveParticipantRequest(callId, participantId); + using var message = CreateRemoveParticipantRequest(callConnectionId, participantId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -606,23 +549,23 @@ public async Task RemoveParticipantAsync(string callId, string partici } } - /// Remove participant from the call. - /// Call id. - /// Participant id. + /// Remove a participant from the call. + /// The call connection id. + /// The participant id. /// The cancellation token to use. - /// or is null. - public Response RemoveParticipant(string callId, string participantId, CancellationToken cancellationToken = default) + /// or is null. + public Response RemoveParticipant(string callConnectionId, string participantId, CancellationToken cancellationToken = default) { - if (callId == null) + if (callConnectionId == null) { - throw new ArgumentNullException(nameof(callId)); + throw new ArgumentNullException(nameof(callConnectionId)); } if (participantId == null) { throw new ArgumentNullException(nameof(participantId)); } - using var message = CreateRemoveParticipantRequest(callId, participantId); + using var message = CreateRemoveParticipantRequest(callConnectionId, participantId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallingServerModelFactory.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallingServerModelFactory.cs new file mode 100644 index 0000000000000..1af99b9c7641c --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/CallingServerModelFactory.cs @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Communication.CallingServer; + +namespace Azure.Communication.CallingServer.Models +{ + /// Model factory for read-only models. + public static partial class CallingServerModelFactory + { + /// Initializes new instance of PlayAudioResult class. + /// The operation id. + /// The status of the operation. + /// The operation context provided by client. + /// The result info for the operation. + /// A new instance for mocking. + public static PlayAudioResult PlayAudioResult(string operationId = default, OperationStatus status = default, string operationContext = default, ResultInfo resultInfo = default) + { + return new PlayAudioResult(operationId, status, operationContext, resultInfo); + } + + /// Initializes new instance of ResultInfo class. + /// The result code associated with the operation. + /// The subcode that further classifies the result. + /// The message is a detail explanation of subcode. + /// A new instance for mocking. + public static ResultInfo ResultInfo(int code = default, int subcode = default, string message = default) + { + return new ResultInfo(code, subcode, message); + } + + /// Initializes new instance of CancelAllMediaOperationsResult class. + /// The operation id. + /// The status of the operation. + /// The operation context provided by client. + /// The result info for the operation. + /// A new instance for mocking. + public static CancelAllMediaOperationsResult CancelAllMediaOperationsResult(string operationId = default, OperationStatus status = default, string operationContext = default, ResultInfo resultInfo = default) + { + return new CancelAllMediaOperationsResult(operationId, status, operationContext, resultInfo); + } + + /// Initializes new instance of AddParticipantResult class. + /// The id of the added participant. + /// A new instance for mocking. + public static AddParticipantResult AddParticipantResult(string participantId = default) + { + return new AddParticipantResult(participantId); + } + + /// Initializes new instance of StartCallRecordingResult class. + /// The recording id of the started recording. + /// A new instance for mocking. + public static StartCallRecordingResult StartCallRecordingResult(string recordingId = default) + { + return new StartCallRecordingResult(recordingId); + } + + /// Initializes new instance of CallRecordingProperties class. + /// The state of the recording. + /// A new instance for mocking. + public static CallRecordingProperties CallRecordingProperties(CallRecordingState recordingState = default) + { + return new CallRecordingProperties(recordingState); + } + + /// Initializes new instance of CallConnectionStateChangedEvent class. + /// The server call.id. + /// The call connection id. + /// The call connection state. + /// A new instance for mocking. + public static CallConnectionStateChangedEvent CallConnectionStateChangedEvent(string serverCallId = default, string callConnectionId = default, CallConnectionState callConnectionState = default) + { + return new CallConnectionStateChangedEvent(serverCallId, callConnectionId, callConnectionState); + } + + /// Initializes new instance of CallRecordingStateChangeEvent class. + /// The call recording id. + /// The state of the recording. + /// The time of the recording started. + /// The server call.id. + /// A new instance for mocking. + public static CallRecordingStateChangeEvent CallRecordingStateChangeEvent(string recordingId = default, CallRecordingState state = default, DateTimeOffset startDateTime = default, string serverCallId = default) + { + return new CallRecordingStateChangeEvent(recordingId, state, startDateTime, serverCallId); + } + + /// Initializes new instance of AddParticipantResultEvent class. + /// The result details. + /// The operation context. + /// The status of the operation. + /// A new instance for mocking. + public static AddParticipantResultEvent AddParticipantResultEvent(ResultInfo resultInfo = default, string operationContext = default, OperationStatus status = default) + { + return new AddParticipantResultEvent(resultInfo, operationContext, status); + } + + /// Initializes new instance of PlayAudioResultEvent class. + /// The result details. + /// The operation context. + /// The status of the operation. + /// A new instance for mocking. + public static PlayAudioResultEvent PlayAudioResultEvent(ResultInfo resultInfo = default, string operationContext = default, OperationStatus status = default) + { + return new PlayAudioResultEvent(resultInfo, operationContext, status); + } + + /// Initializes new instance of ToneReceivedEvent class. + /// The tone info. + /// The call connection id. + /// A new instance for mocking. + public static ToneReceivedEvent ToneReceivedEvent(ToneInfo toneInfo = default, string callConnectionId = default) + { + return new ToneReceivedEvent(toneInfo, callConnectionId); + } + + /// Initializes new instance of ToneInfo class. + /// The sequence id which can be used to determine if the same tone was played multiple times or if any tones were missed. + /// The tone value. + /// A new instance for mocking. + public static ToneInfo ToneInfo(int sequenceId = default, ToneValue tone = default) + { + return new ToneInfo(sequenceId, tone); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.Serialization.cs similarity index 76% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.Serialization.cs index 60e7b79684553..407f6e7f12387 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.Serialization.cs @@ -10,7 +10,7 @@ namespace Azure.Communication.CallingServer { - internal partial class InviteParticipantsRequestInternal : IUtf8JsonSerializable + internal partial class AddParticipantRequest : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -20,13 +20,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("alternateCallerId"); writer.WriteObjectValue(AlternateCallerId); } - writer.WritePropertyName("participants"); - writer.WriteStartArray(); - foreach (var item in Participants) + if (Optional.IsDefined(Participant)) { - writer.WriteObjectValue(item); + writer.WritePropertyName("participant"); + writer.WriteObjectValue(Participant); } - writer.WriteEndArray(); if (Optional.IsDefined(OperationContext)) { writer.WritePropertyName("operationContext"); diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.cs new file mode 100644 index 0000000000000..c5c466c3d73ea --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantRequest.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Communication; + +namespace Azure.Communication.CallingServer +{ + /// The add participant request. + internal partial class AddParticipantRequest + { + /// Initializes a new instance of AddParticipantRequest. + public AddParticipantRequest() + { + } + + /// The alternate identity of source participant. + public PhoneNumberIdentifierModel AlternateCallerId { get; set; } + /// The participant to be added to the call. + public CommunicationIdentifierModel Participant { get; set; } + /// The operation context. + public string OperationContext { get; set; } + /// The callback URI. + public string CallbackUri { get; set; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.Serialization.cs similarity index 52% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.Serialization.cs index 837903cd12d2b..1ad1575d62241 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.Serialization.cs @@ -10,20 +10,20 @@ namespace Azure.Communication.CallingServer { - public partial class JoinCallResponse + public partial class AddParticipantResult { - internal static JoinCallResponse DeserializeJoinCallResponse(JsonElement element) + internal static AddParticipantResult DeserializeAddParticipantResult(JsonElement element) { - Optional callLegId = default; + Optional participantId = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("callLegId")) + if (property.NameEquals("participantId")) { - callLegId = property.Value.GetString(); + participantId = property.Value.GetString(); continue; } } - return new JoinCallResponse(callLegId.Value); + return new AddParticipantResult(participantId.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.cs new file mode 100644 index 0000000000000..827e351accce7 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResult.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The add participant result. + public partial class AddParticipantResult + { + /// Initializes a new instance of AddParticipantResult. + internal AddParticipantResult() + { + } + + /// Initializes a new instance of AddParticipantResult. + /// The id of the added participant. + internal AddParticipantResult(string participantId) + { + ParticipantId = participantId; + } + + /// The id of the added participant. + public string ParticipantId { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.Serialization.cs new file mode 100644 index 0000000000000..05004943a3439 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.Serialization.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + public partial class AddParticipantResultEvent + { + internal static AddParticipantResultEvent DeserializeAddParticipantResultEvent(JsonElement element) + { + Optional resultInfo = default; + Optional operationContext = default; + OperationStatus status = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resultInfo")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + resultInfo = ResultInfo.DeserializeResultInfo(property.Value); + continue; + } + if (property.NameEquals("operationContext")) + { + operationContext = property.Value.GetString(); + continue; + } + if (property.NameEquals("status")) + { + status = new OperationStatus(property.Value.GetString()); + continue; + } + } + return new AddParticipantResultEvent(resultInfo.Value, operationContext.Value, status); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.cs new file mode 100644 index 0000000000000..e2bae28a24b4f --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/AddParticipantResultEvent.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The AddParticipantResultEvent. + public partial class AddParticipantResultEvent + { + /// Initializes a new instance of AddParticipantResultEvent. + /// The status of the operation. + internal AddParticipantResultEvent(OperationStatus status) + { + Status = status; + } + + /// Initializes a new instance of AddParticipantResultEvent. + /// The result details. + /// The operation context. + /// The status of the operation. + internal AddParticipantResultEvent(ResultInfo resultInfo, string operationContext, OperationStatus status) + { + ResultInfo = resultInfo; + OperationContext = operationContext; + Status = status; + } + + /// The result details. + public ResultInfo ResultInfo { get; } + /// The operation context. + public string OperationContext { get; } + /// The status of the operation. + public OperationStatus Status { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionState.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionState.cs new file mode 100644 index 0000000000000..6979532fe5e16 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionState.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Communication.CallingServer +{ + /// The call connection state. + public readonly partial struct CallConnectionState : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public CallConnectionState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string IncomingValue = "incoming"; + private const string ConnectingValue = "connecting"; + private const string ConnectedValue = "connected"; + private const string DisconnectingValue = "disconnecting"; + private const string DisconnectedValue = "disconnected"; + + /// incoming. + public static CallConnectionState Incoming { get; } = new CallConnectionState(IncomingValue); + /// connecting. + public static CallConnectionState Connecting { get; } = new CallConnectionState(ConnectingValue); + /// connected. + public static CallConnectionState Connected { get; } = new CallConnectionState(ConnectedValue); + /// disconnecting. + public static CallConnectionState Disconnecting { get; } = new CallConnectionState(DisconnectingValue); + /// disconnected. + public static CallConnectionState Disconnected { get; } = new CallConnectionState(DisconnectedValue); + /// Determines if two values are the same. + public static bool operator ==(CallConnectionState left, CallConnectionState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CallConnectionState left, CallConnectionState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CallConnectionState(string value) => new CallConnectionState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CallConnectionState other && Equals(other); + /// + public bool Equals(CallConnectionState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.Serialization.cs new file mode 100644 index 0000000000000..06d4e92a97689 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + public partial class CallConnectionStateChangedEvent + { + internal static CallConnectionStateChangedEvent DeserializeCallConnectionStateChangedEvent(JsonElement element) + { + Optional serverCallId = default; + Optional callConnectionId = default; + CallConnectionState callConnectionState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serverCallId")) + { + serverCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("callConnectionId")) + { + callConnectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("callConnectionState")) + { + callConnectionState = new CallConnectionState(property.Value.GetString()); + continue; + } + } + return new CallConnectionStateChangedEvent(serverCallId.Value, callConnectionId.Value, callConnectionState); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.cs new file mode 100644 index 0000000000000..c15300cdded33 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallConnectionStateChangedEvent.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The call connection state changed event. + public partial class CallConnectionStateChangedEvent + { + /// Initializes a new instance of CallConnectionStateChangedEvent. + /// The call connection state. + internal CallConnectionStateChangedEvent(CallConnectionState callConnectionState) + { + CallConnectionState = callConnectionState; + } + + /// Initializes a new instance of CallConnectionStateChangedEvent. + /// The server call.id. + /// The call connection id. + /// The call connection state. + internal CallConnectionStateChangedEvent(string serverCallId, string callConnectionId, CallConnectionState callConnectionState) + { + ServerCallId = serverCallId; + CallConnectionId = callConnectionId; + CallConnectionState = callConnectionState; + } + + /// The server call.id. + public string ServerCallId { get; } + /// The call connection id. + public string CallConnectionId { get; } + /// The call connection state. + public CallConnectionState CallConnectionState { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.Serialization.cs deleted file mode 100644 index 5f1db1ce2625a..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.Serialization.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.Communication.CallingServer -{ - public partial class CallLegStateChangedEvent : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(ConversationId)) - { - writer.WritePropertyName("conversationId"); - writer.WriteStringValue(ConversationId); - } - if (Optional.IsDefined(CallLegId)) - { - writer.WritePropertyName("callLegId"); - writer.WriteStringValue(CallLegId); - } - if (Optional.IsDefined(CallState)) - { - writer.WritePropertyName("callState"); - writer.WriteStringValue(CallState.Value.ToString()); - } - writer.WriteEndObject(); - } - - internal static CallLegStateChangedEvent DeserializeCallLegStateChangedEvent(JsonElement element) - { - Optional conversationId = default; - Optional callLegId = default; - Optional callState = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("conversationId")) - { - conversationId = property.Value.GetString(); - continue; - } - if (property.NameEquals("callLegId")) - { - callLegId = property.Value.GetString(); - continue; - } - if (property.NameEquals("callState")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - callState = new CallState(property.Value.GetString()); - continue; - } - } - return new CallLegStateChangedEvent(conversationId.Value, callLegId.Value, Optional.ToNullable(callState)); - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.cs deleted file mode 100644 index de96c72a96864..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallLegStateChangedEvent.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The call state change event. - public partial class CallLegStateChangedEvent - { - /// Initializes a new instance of CallLegStateChangedEvent. - public CallLegStateChangedEvent() - { - } - - /// Initializes a new instance of CallLegStateChangedEvent. - /// The conversation.id. - /// The call leg.id. - /// The call state. - internal CallLegStateChangedEvent(string conversationId, string callLegId, CallState? callState) - { - ConversationId = conversationId; - CallLegId = callLegId; - CallState = callState; - } - - /// The conversation.id. - public string ConversationId { get; set; } - /// The call leg.id. - public string CallLegId { get; set; } - /// The call state. - public CallState? CallState { get; set; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallModality.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallModality.cs deleted file mode 100644 index 731293ed31964..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallModality.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.Communication.CallingServer -{ - /// The CallModality. - public readonly partial struct CallModality : IEquatable - { - private readonly string _value; - - /// Determines if two values are the same. - /// is null. - public CallModality(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AudioValue = "audio"; - private const string VideoValue = "video"; - - /// audio. - public static CallModality Audio { get; } = new CallModality(AudioValue); - /// video. - public static CallModality Video { get; } = new CallModality(VideoValue); - /// Determines if two values are the same. - public static bool operator ==(CallModality left, CallModality right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(CallModality left, CallModality right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator CallModality(string value) => new CallModality(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is CallModality other && Equals(other); - /// - public bool Equals(CallModality other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.Serialization.cs similarity index 69% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.Serialization.cs index a122d06ea9557..87a9c9e45f004 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.Serialization.cs @@ -11,13 +11,13 @@ namespace Azure.Communication.CallingServer { - internal partial class CommunicationParticipantInternal + internal partial class CallParticipantInternal { - internal static CommunicationParticipantInternal DeserializeCommunicationParticipantInternal(JsonElement element) + internal static CallParticipantInternal DeserializeCallParticipantInternal(JsonElement element) { Optional identifier = default; Optional participantId = default; - Optional isMuted = default; + bool isMuted = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("identifier")) @@ -37,16 +37,11 @@ internal static CommunicationParticipantInternal DeserializeCommunicationPartici } if (property.NameEquals("isMuted")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } isMuted = property.Value.GetBoolean(); continue; } } - return new CommunicationParticipantInternal(identifier.Value, participantId.Value, Optional.ToNullable(isMuted)); + return new CallParticipantInternal(identifier.Value, participantId.Value, isMuted); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.cs new file mode 100644 index 0000000000000..d0e9755d677f7 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallParticipantInternal.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Communication; + +namespace Azure.Communication.CallingServer +{ + /// A participant in a call. + internal partial class CallParticipantInternal + { + /// Initializes a new instance of CallParticipantInternal. + /// Is participant muted. + internal CallParticipantInternal(bool isMuted) + { + IsMuted = isMuted; + } + + /// Initializes a new instance of CallParticipantInternal. + /// Communication identifier of the participant. + /// Participant id. + /// Is participant muted. + internal CallParticipantInternal(CommunicationIdentifierModel identifier, string participantId, bool isMuted) + { + Identifier = identifier; + ParticipantId = participantId; + IsMuted = isMuted; + } + + /// Communication identifier of the participant. + public CommunicationIdentifierModel Identifier { get; } + /// Participant id. + public string ParticipantId { get; } + /// Is participant muted. + public bool IsMuted { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.Serialization.cs similarity index 50% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.Serialization.cs index c004a26399d0f..44eca4f222444 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.Serialization.cs @@ -10,25 +10,20 @@ namespace Azure.Communication.CallingServer { - public partial class GetCallRecordingStateResponse + public partial class CallRecordingProperties { - internal static GetCallRecordingStateResponse DeserializeGetCallRecordingStateResponse(JsonElement element) + internal static CallRecordingProperties DeserializeCallRecordingProperties(JsonElement element) { - Optional recordingState = default; + CallRecordingState recordingState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("recordingState")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } recordingState = new CallRecordingState(property.Value.GetString()); continue; } } - return new GetCallRecordingStateResponse(Optional.ToNullable(recordingState)); + return new CallRecordingProperties(recordingState); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.cs new file mode 100644 index 0000000000000..64daf6f9d92bd --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingProperties.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The response payload of get call recording properties operation. + public partial class CallRecordingProperties + { + /// Initializes a new instance of CallRecordingProperties. + /// The state of the recording. + internal CallRecordingProperties(CallRecordingState recordingState) + { + RecordingState = recordingState; + } + + /// The state of the recording. + public CallRecordingState RecordingState { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingState.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingState.cs index 2aa166bbece76..ad9278e1b12cd 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingState.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingState.cs @@ -10,7 +10,7 @@ namespace Azure.Communication.CallingServer { - /// The recording state of the recording. + /// The state of the recording. public readonly partial struct CallRecordingState : IEquatable { private readonly string _value; diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.Serialization.cs index ccf995cb91fc5..a36e9962460c2 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.Serialization.cs @@ -11,40 +11,14 @@ namespace Azure.Communication.CallingServer { - public partial class CallRecordingStateChangeEvent : IUtf8JsonSerializable + public partial class CallRecordingStateChangeEvent { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(RecordingId)) - { - writer.WritePropertyName("recordingId"); - writer.WriteStringValue(RecordingId); - } - if (Optional.IsDefined(State)) - { - writer.WritePropertyName("state"); - writer.WriteStringValue(State.Value.ToString()); - } - if (Optional.IsDefined(StartDateTime)) - { - writer.WritePropertyName("startDateTime"); - writer.WriteStringValue(StartDateTime.Value, "O"); - } - if (Optional.IsDefined(ConversationId)) - { - writer.WritePropertyName("conversationId"); - writer.WriteStringValue(ConversationId); - } - writer.WriteEndObject(); - } - internal static CallRecordingStateChangeEvent DeserializeCallRecordingStateChangeEvent(JsonElement element) { Optional recordingId = default; - Optional state = default; - Optional startDateTime = default; - Optional conversationId = default; + CallRecordingState state = default; + DateTimeOffset startDateTime = default; + Optional serverCallId = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("recordingId")) @@ -54,31 +28,21 @@ internal static CallRecordingStateChangeEvent DeserializeCallRecordingStateChang } if (property.NameEquals("state")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } state = new CallRecordingState(property.Value.GetString()); continue; } if (property.NameEquals("startDateTime")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } startDateTime = property.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("conversationId")) + if (property.NameEquals("serverCallId")) { - conversationId = property.Value.GetString(); + serverCallId = property.Value.GetString(); continue; } } - return new CallRecordingStateChangeEvent(recordingId.Value, Optional.ToNullable(state), Optional.ToNullable(startDateTime), conversationId.Value); + return new CallRecordingStateChangeEvent(recordingId.Value, state, startDateTime, serverCallId.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.cs index ad2a94e870455..481668aa3cbf6 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallRecordingStateChangeEvent.cs @@ -13,30 +13,34 @@ namespace Azure.Communication.CallingServer public partial class CallRecordingStateChangeEvent { /// Initializes a new instance of CallRecordingStateChangeEvent. - public CallRecordingStateChangeEvent() + /// The state of the recording. + /// The time of the recording started. + internal CallRecordingStateChangeEvent(CallRecordingState state, DateTimeOffset startDateTime) { + State = state; + StartDateTime = startDateTime; } /// Initializes a new instance of CallRecordingStateChangeEvent. /// The call recording id. - /// The recording state of the recording. + /// The state of the recording. /// The time of the recording started. - /// The conversation id from a out call start recording request. - internal CallRecordingStateChangeEvent(string recordingId, CallRecordingState? state, DateTimeOffset? startDateTime, string conversationId) + /// The server call.id. + internal CallRecordingStateChangeEvent(string recordingId, CallRecordingState state, DateTimeOffset startDateTime, string serverCallId) { RecordingId = recordingId; State = state; StartDateTime = startDateTime; - ConversationId = conversationId; + ServerCallId = serverCallId; } /// The call recording id. - public string RecordingId { get; set; } - /// The recording state of the recording. - public CallRecordingState? State { get; set; } + public string RecordingId { get; } + /// The state of the recording. + public CallRecordingState State { get; } /// The time of the recording started. - public DateTimeOffset? StartDateTime { get; set; } - /// The conversation id from a out call start recording request. - public string ConversationId { get; set; } + public DateTimeOffset StartDateTime { get; } + /// The server call.id. + public string ServerCallId { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallState.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallState.cs deleted file mode 100644 index cbd5c4ab06150..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CallState.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.Communication.CallingServer -{ - /// The call state. - public readonly partial struct CallState : IEquatable - { - private readonly string _value; - - /// Determines if two values are the same. - /// is null. - public CallState(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string UnknownValue = "unknown"; - private const string IdleValue = "idle"; - private const string IncomingValue = "incoming"; - private const string EstablishingValue = "establishing"; - private const string EstablishedValue = "established"; - private const string HoldValue = "hold"; - private const string UnholdValue = "unhold"; - private const string TransferringValue = "transferring"; - private const string RedirectingValue = "redirecting"; - private const string TerminatingValue = "terminating"; - private const string TerminatedValue = "terminated"; - - /// unknown. - public static CallState Unknown { get; } = new CallState(UnknownValue); - /// idle. - public static CallState Idle { get; } = new CallState(IdleValue); - /// incoming. - public static CallState Incoming { get; } = new CallState(IncomingValue); - /// establishing. - public static CallState Establishing { get; } = new CallState(EstablishingValue); - /// established. - public static CallState Established { get; } = new CallState(EstablishedValue); - /// hold. - public static CallState Hold { get; } = new CallState(HoldValue); - /// unhold. - public static CallState Unhold { get; } = new CallState(UnholdValue); - /// transferring. - public static CallState Transferring { get; } = new CallState(TransferringValue); - /// redirecting. - public static CallState Redirecting { get; } = new CallState(RedirectingValue); - /// terminating. - public static CallState Terminating { get; } = new CallState(TerminatingValue); - /// terminated. - public static CallState Terminated { get; } = new CallState(TerminatedValue); - /// Determines if two values are the same. - public static bool operator ==(CallState left, CallState right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(CallState left, CallState right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator CallState(string value) => new CallState(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is CallState other && Equals(other); - /// - public bool Equals(CallState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsRequest.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsRequest.cs index b9ba588498586..498b236ddf8f0 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsRequest.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsRequest.cs @@ -7,7 +7,7 @@ namespace Azure.Communication.CallingServer { - /// The request payload for cancel media processing. + /// The request payload for cancel all media operations. internal partial class CancelAllMediaOperationsRequest { /// Initializes a new instance of CancelAllMediaOperationsRequest. diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.cs deleted file mode 100644 index 9560e0967afa5..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The response payload of the cancel media processing operation. - public partial class CancelAllMediaOperationsResponse - { - /// Initializes a new instance of CancelAllMediaOperationsResponse. - internal CancelAllMediaOperationsResponse() - { - } - - /// Initializes a new instance of CancelAllMediaOperationsResponse. - /// Gets or sets the identifier. - /// Gets or sets the status of the operation. - /// Gets or sets the operation context. - /// Gets or sets the result info. - internal CancelAllMediaOperationsResponse(string id, OperationStatus? status, string operationContext, ResultInfo resultInfo) - { - Id = id; - Status = status; - OperationContext = operationContext; - ResultInfo = resultInfo; - } - - /// Gets or sets the identifier. - public string Id { get; } - /// Gets or sets the status of the operation. - public OperationStatus? Status { get; } - /// Gets or sets the operation context. - public string OperationContext { get; } - /// Gets or sets the result info. - public ResultInfo ResultInfo { get; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.Serialization.cs similarity index 66% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.Serialization.cs index 8757de91f31ca..0d94214912baa 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.Serialization.cs @@ -10,28 +10,23 @@ namespace Azure.Communication.CallingServer { - public partial class PlayAudioResponse + public partial class CancelAllMediaOperationsResult { - internal static PlayAudioResponse DeserializePlayAudioResponse(JsonElement element) + internal static CancelAllMediaOperationsResult DeserializeCancelAllMediaOperationsResult(JsonElement element) { - Optional id = default; - Optional status = default; + Optional operationId = default; + OperationStatus status = default; Optional operationContext = default; Optional resultInfo = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id")) + if (property.NameEquals("operationId")) { - id = property.Value.GetString(); + operationId = property.Value.GetString(); continue; } if (property.NameEquals("status")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } status = new OperationStatus(property.Value.GetString()); continue; } @@ -51,7 +46,7 @@ internal static PlayAudioResponse DeserializePlayAudioResponse(JsonElement eleme continue; } } - return new PlayAudioResponse(id.Value, Optional.ToNullable(status), operationContext.Value, resultInfo.Value); + return new CancelAllMediaOperationsResult(operationId.Value, status, operationContext.Value, resultInfo.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.cs new file mode 100644 index 0000000000000..e31e114e93f79 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResult.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The response payload of the cancel all media operations. + public partial class CancelAllMediaOperationsResult + { + /// Initializes a new instance of CancelAllMediaOperationsResult. + /// The status of the operation. + internal CancelAllMediaOperationsResult(OperationStatus status) + { + Status = status; + } + + /// Initializes a new instance of CancelAllMediaOperationsResult. + /// The operation id. + /// The status of the operation. + /// The operation context provided by client. + /// The result info for the operation. + internal CancelAllMediaOperationsResult(string operationId, OperationStatus status, string operationContext, ResultInfo resultInfo) + { + OperationId = operationId; + Status = status; + OperationContext = operationContext; + ResultInfo = resultInfo; + } + + /// The operation id. + public string OperationId { get; } + /// The status of the operation. + public OperationStatus Status { get; } + /// The operation context provided by client. + public string OperationContext { get; } + /// The result info for the operation. + public ResultInfo ResultInfo { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.Serialization.cs new file mode 100644 index 0000000000000..6637948463e52 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + internal partial class CommunicationErrorResponse + { + internal static CommunicationErrorResponse DeserializeCommunicationErrorResponse(JsonElement element) + { + CommunicationError error = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("error")) + { + error = CommunicationError.DeserializeCommunicationError(property.Value); + continue; + } + } + return new CommunicationErrorResponse(error); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.cs new file mode 100644 index 0000000000000..08849379fca76 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationErrorResponse.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Communication.CallingServer +{ + /// The Communication Services error. + internal partial class CommunicationErrorResponse + { + /// Initializes a new instance of CommunicationErrorResponse. + /// The Communication Services error. + /// is null. + internal CommunicationErrorResponse(CommunicationError error) + { + if (error == null) + { + throw new ArgumentNullException(nameof(error)); + } + + Error = error; + } + + /// The Communication Services error. + public CommunicationError Error { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.cs deleted file mode 100644 index f4f85d3a97e34..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CommunicationParticipantInternal.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Communication; - -namespace Azure.Communication.CallingServer -{ - /// Class to represent entry in roster. - internal partial class CommunicationParticipantInternal - { - /// Initializes a new instance of CommunicationParticipantInternal. - internal CommunicationParticipantInternal() - { - } - - /// Initializes a new instance of CommunicationParticipantInternal. - /// ACS communication identifier. - /// Participant Id. - /// Is participant muted. - internal CommunicationParticipantInternal(CommunicationIdentifierModel identifier, string participantId, bool? isMuted) - { - Identifier = identifier; - ParticipantId = participantId; - IsMuted = isMuted; - } - - /// ACS communication identifier. - public CommunicationIdentifierModel Identifier { get; } - /// Participant Id. - public string ParticipantId { get; } - /// Is participant muted. - public bool? IsMuted { get; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.Serialization.cs index 8a733b6b2dd3b..b283cbb7b742c 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.Serialization.cs @@ -15,10 +15,10 @@ internal partial class CreateCallRequestInternal : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); - if (Optional.IsDefined(SourceAlternateIdentity)) + if (Optional.IsDefined(AlternateCallerId)) { - writer.WritePropertyName("sourceAlternateIdentity"); - writer.WriteObjectValue(SourceAlternateIdentity); + writer.WritePropertyName("alternateCallerId"); + writer.WriteObjectValue(AlternateCallerId); } writer.WritePropertyName("targets"); writer.WriteStartArray(); @@ -36,20 +36,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("callbackUri"); writer.WriteStringValue(CallbackUri); - writer.WritePropertyName("requestedModalities"); - writer.WriteStartArray(); - foreach (var item in RequestedModalities) + if (Optional.IsCollectionDefined(RequestedMediaTypes)) { - writer.WriteStringValue(item.ToString()); + writer.WritePropertyName("requestedMediaTypes"); + writer.WriteStartArray(); + foreach (var item in RequestedMediaTypes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); } - writer.WriteEndArray(); - writer.WritePropertyName("requestedCallEvents"); - writer.WriteStartArray(); - foreach (var item in RequestedCallEvents) + if (Optional.IsCollectionDefined(RequestedCallEvents)) { - writer.WriteStringValue(item.ToString()); + writer.WritePropertyName("requestedCallEvents"); + writer.WriteStartArray(); + foreach (var item in RequestedCallEvents) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); } - writer.WriteEndArray(); writer.WriteEndObject(); } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.cs index d75474f0b1199..d851487109dcb 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallRequestInternal.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using Azure.Communication; +using Azure.Core; namespace Azure.Communication.CallingServer { @@ -19,10 +20,8 @@ internal partial class CreateCallRequestInternal /// The targets of the call. /// The source of the call. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// , , , , or is null. - public CreateCallRequestInternal(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents) + /// , , or is null. + public CreateCallRequestInternal(IEnumerable targets, CommunicationIdentifierModel source, string callbackUri) { if (targets == null) { @@ -36,24 +35,16 @@ public CreateCallRequestInternal(IEnumerable targe { throw new ArgumentNullException(nameof(callbackUri)); } - if (requestedModalities == null) - { - throw new ArgumentNullException(nameof(requestedModalities)); - } - if (requestedCallEvents == null) - { - throw new ArgumentNullException(nameof(requestedCallEvents)); - } Targets = targets.ToList(); Source = source; CallbackUri = callbackUri; - RequestedModalities = requestedModalities.ToList(); - RequestedCallEvents = requestedCallEvents.ToList(); + RequestedMediaTypes = new ChangeTrackingList(); + RequestedCallEvents = new ChangeTrackingList(); } /// The alternate identity of the source of the call if dialing out to a pstn number. - public PhoneNumberIdentifierModel SourceAlternateIdentity { get; set; } + public PhoneNumberIdentifierModel AlternateCallerId { get; set; } /// The targets of the call. public IList Targets { get; } /// The source of the call. @@ -63,7 +54,7 @@ public CreateCallRequestInternal(IEnumerable targe /// The callback URI. public string CallbackUri { get; } /// The requested modalities. - public IList RequestedModalities { get; } + public IList RequestedMediaTypes { get; } /// The requested call events to subscribe to. public IList RequestedCallEvents { get; } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.Serialization.cs new file mode 100644 index 0000000000000..0181a75d86859 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + internal partial class CreateCallResultInternal + { + internal static CreateCallResultInternal DeserializeCreateCallResultInternal(JsonElement element) + { + Optional callConnectionId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("callConnectionId")) + { + callConnectionId = property.Value.GetString(); + continue; + } + } + return new CreateCallResultInternal(callConnectionId.Value); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.cs similarity index 50% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.cs index cc4aa0e8128c4..a06e1a24a29e7 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResultInternal.cs @@ -8,21 +8,21 @@ namespace Azure.Communication.CallingServer { /// The response payload of the create call operation. - public partial class CreateCallResponse + internal partial class CreateCallResultInternal { - /// Initializes a new instance of CreateCallResponse. - internal CreateCallResponse() + /// Initializes a new instance of CreateCallResultInternal. + internal CreateCallResultInternal() { } - /// Initializes a new instance of CreateCallResponse. - /// Call leg id of the call. - internal CreateCallResponse(string callLegId) + /// Initializes a new instance of CreateCallResultInternal. + /// The call connection id. + internal CreateCallResultInternal(string callConnectionId) { - CallLegId = callLegId; + CallConnectionId = callConnectionId; } - /// Call leg id of the call. - public string CallLegId { get; } + /// The call connection id. + public string CallConnectionId { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.cs deleted file mode 100644 index ea34da593ec18..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/GetCallRecordingStateResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The response payload of get call recording state operation. - public partial class GetCallRecordingStateResponse - { - /// Initializes a new instance of GetCallRecordingStateResponse. - internal GetCallRecordingStateResponse() - { - } - - /// Initializes a new instance of GetCallRecordingStateResponse. - /// The recording state of the recording. - internal GetCallRecordingStateResponse(CallRecordingState? recordingState) - { - RecordingState = recordingState; - } - - /// The recording state of the recording. - public CallRecordingState? RecordingState { get; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.cs deleted file mode 100644 index b806cfa49c030..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsRequestInternal.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; -using Azure.Communication; - -namespace Azure.Communication.CallingServer -{ - /// The invite participants request. - internal partial class InviteParticipantsRequestInternal - { - /// Initializes a new instance of InviteParticipantsRequestInternal. - /// The list of participants to be added to the call. - /// is null. - public InviteParticipantsRequestInternal(IEnumerable participants) - { - if (participants == null) - { - throw new ArgumentNullException(nameof(participants)); - } - - Participants = participants.ToList(); - } - - /// The alternate identity of source participant. - public PhoneNumberIdentifierModel AlternateCallerId { get; set; } - /// The list of participants to be added to the call. - public IList Participants { get; } - /// The operation context. - public string OperationContext { get; set; } - /// The callback URI. - public string CallbackUri { get; set; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.Serialization.cs deleted file mode 100644 index 52d3b47676654..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.Serialization.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.Communication.CallingServer -{ - public partial class InviteParticipantsResultEvent : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(ResultInfo)) - { - writer.WritePropertyName("resultInfo"); - writer.WriteObjectValue(ResultInfo); - } - if (Optional.IsDefined(OperationContext)) - { - writer.WritePropertyName("operationContext"); - writer.WriteStringValue(OperationContext); - } - if (Optional.IsDefined(Status)) - { - writer.WritePropertyName("status"); - writer.WriteStringValue(Status.Value.ToString()); - } - writer.WriteEndObject(); - } - - internal static InviteParticipantsResultEvent DeserializeInviteParticipantsResultEvent(JsonElement element) - { - Optional resultInfo = default; - Optional operationContext = default; - Optional status = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("resultInfo")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - resultInfo = ResultInfo.DeserializeResultInfo(property.Value); - continue; - } - if (property.NameEquals("operationContext")) - { - operationContext = property.Value.GetString(); - continue; - } - if (property.NameEquals("status")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - status = new OperationStatus(property.Value.GetString()); - continue; - } - } - return new InviteParticipantsResultEvent(resultInfo.Value, operationContext.Value, Optional.ToNullable(status)); - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.cs deleted file mode 100644 index 1fd35fffa5b17..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/InviteParticipantsResultEvent.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The InviteParticipantsResultEvent. - public partial class InviteParticipantsResultEvent - { - /// Initializes a new instance of InviteParticipantsResultEvent. - public InviteParticipantsResultEvent() - { - } - - /// Initializes a new instance of InviteParticipantsResultEvent. - /// The result details. - /// The operation context. - /// Gets or sets the status of the operation. - internal InviteParticipantsResultEvent(ResultInfo resultInfo, string operationContext, OperationStatus? status) - { - ResultInfo = resultInfo; - OperationContext = operationContext; - Status = status; - } - - /// The result details. - public ResultInfo ResultInfo { get; set; } - /// The operation context. - public string OperationContext { get; set; } - /// Gets or sets the status of the operation. - public OperationStatus? Status { get; set; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.Serialization.cs index 286ada28f878b..16cadb22366e5 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.Serialization.cs @@ -24,20 +24,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WritePropertyName("callbackUri"); writer.WriteStringValue(CallbackUri); - writer.WritePropertyName("requestedModalities"); - writer.WriteStartArray(); - foreach (var item in RequestedModalities) + if (Optional.IsCollectionDefined(RequestedMediaTypes)) { - writer.WriteStringValue(item.ToString()); + writer.WritePropertyName("requestedMediaTypes"); + writer.WriteStartArray(); + foreach (var item in RequestedMediaTypes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); } - writer.WriteEndArray(); - writer.WritePropertyName("requestedCallEvents"); - writer.WriteStartArray(); - foreach (var item in RequestedCallEvents) + if (Optional.IsCollectionDefined(RequestedCallEvents)) { - writer.WriteStringValue(item.ToString()); + writer.WritePropertyName("requestedCallEvents"); + writer.WriteStartArray(); + foreach (var item in RequestedCallEvents) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); } - writer.WriteEndArray(); writer.WriteEndObject(); } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.cs index 519e2948fec25..bafb78435ca5e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallRequestInternal.cs @@ -7,8 +7,8 @@ using System; using System.Collections.Generic; -using System.Linq; using Azure.Communication; +using Azure.Core; namespace Azure.Communication.CallingServer { @@ -18,10 +18,8 @@ internal partial class JoinCallRequestInternal /// Initializes a new instance of JoinCallRequestInternal. /// The source of the call. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// , , , or is null. - public JoinCallRequestInternal(CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents) + /// or is null. + public JoinCallRequestInternal(CommunicationIdentifierModel source, string callbackUri) { if (source == null) { @@ -31,19 +29,11 @@ public JoinCallRequestInternal(CommunicationIdentifierModel source, string callb { throw new ArgumentNullException(nameof(callbackUri)); } - if (requestedModalities == null) - { - throw new ArgumentNullException(nameof(requestedModalities)); - } - if (requestedCallEvents == null) - { - throw new ArgumentNullException(nameof(requestedCallEvents)); - } Source = source; CallbackUri = callbackUri; - RequestedModalities = requestedModalities.ToList(); - RequestedCallEvents = requestedCallEvents.ToList(); + RequestedMediaTypes = new ChangeTrackingList(); + RequestedCallEvents = new ChangeTrackingList(); } /// The source of the call. @@ -53,7 +43,7 @@ public JoinCallRequestInternal(CommunicationIdentifierModel source, string callb /// The callback URI. public string CallbackUri { get; } /// The requested modalities. - public IList RequestedModalities { get; } + public IList RequestedMediaTypes { get; } /// The requested call events to subscribe to. public IList RequestedCallEvents { get; } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.cs deleted file mode 100644 index 4813790e5a80b..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The response payload of the join call operation. - public partial class JoinCallResponse - { - /// Initializes a new instance of JoinCallResponse. - internal JoinCallResponse() - { - } - - /// Initializes a new instance of JoinCallResponse. - /// Call leg id of the call. - internal JoinCallResponse(string callLegId) - { - CallLegId = callLegId; - } - - /// Call leg id of the call. - public string CallLegId { get; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.Serialization.cs similarity index 50% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.Serialization.cs index 82d8b2c87bdfc..4d226b1a4661a 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CreateCallResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.Serialization.cs @@ -10,20 +10,20 @@ namespace Azure.Communication.CallingServer { - public partial class CreateCallResponse + internal partial class JoinCallResultInternal { - internal static CreateCallResponse DeserializeCreateCallResponse(JsonElement element) + internal static JoinCallResultInternal DeserializeJoinCallResultInternal(JsonElement element) { - Optional callLegId = default; + Optional callConnectionId = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("callLegId")) + if (property.NameEquals("callConnectionId")) { - callLegId = property.Value.GetString(); + callConnectionId = property.Value.GetString(); continue; } } - return new CreateCallResponse(callLegId.Value); + return new JoinCallResultInternal(callConnectionId.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.cs new file mode 100644 index 0000000000000..94b89f2ba7435 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/JoinCallResultInternal.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The response payload of the join call operation. + internal partial class JoinCallResultInternal + { + /// Initializes a new instance of JoinCallResultInternal. + internal JoinCallResultInternal() + { + } + + /// Initializes a new instance of JoinCallResultInternal. + /// The call connection id. + internal JoinCallResultInternal(string callConnectionId) + { + CallConnectionId = callConnectionId; + } + + /// The call connection id. + public string CallConnectionId { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/MediaType.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/MediaType.cs new file mode 100644 index 0000000000000..27cd7f3a34591 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/MediaType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Communication.CallingServer +{ + /// The MediaType. + public readonly partial struct MediaType : IEquatable + { + private readonly string _value; + + /// Determines if two values are the same. + /// is null. + public MediaType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AudioValue = "audio"; + private const string VideoValue = "video"; + + /// audio. + public static MediaType Audio { get; } = new MediaType(AudioValue); + /// video. + public static MediaType Video { get; } = new MediaType(VideoValue); + /// Determines if two values are the same. + public static bool operator ==(MediaType left, MediaType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MediaType left, MediaType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MediaType(string value) => new MediaType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MediaType other && Equals(other); + /// + public bool Equals(MediaType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/OperationStatus.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/OperationStatus.cs index 878c958f9d8ec..63fe782fb8284 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/OperationStatus.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/OperationStatus.cs @@ -10,7 +10,7 @@ namespace Azure.Communication.CallingServer { - /// Gets or sets the status of the operation. + /// The status of the operation. public readonly partial struct OperationStatus : IEquatable { private readonly string _value; diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.Serialization.cs index 954fa3e99465b..61d4cbba4f09f 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.Serialization.cs @@ -15,13 +15,13 @@ internal partial class ParticipantsUpdatedEventInternal { internal static ParticipantsUpdatedEventInternal DeserializeParticipantsUpdatedEventInternal(JsonElement element) { - Optional callLegId = default; - Optional> participants = default; + Optional callConnectionId = default; + Optional> participants = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("callLegId")) + if (property.NameEquals("callConnectionId")) { - callLegId = property.Value.GetString(); + callConnectionId = property.Value.GetString(); continue; } if (property.NameEquals("participants")) @@ -31,16 +31,16 @@ internal static ParticipantsUpdatedEventInternal DeserializeParticipantsUpdatedE property.ThrowNonNullablePropertyIsNull(); continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(CommunicationParticipantInternal.DeserializeCommunicationParticipantInternal(item)); + array.Add(CallParticipantInternal.DeserializeCallParticipantInternal(item)); } participants = array; continue; } } - return new ParticipantsUpdatedEventInternal(callLegId.Value, Optional.ToList(participants)); + return new ParticipantsUpdatedEventInternal(callConnectionId.Value, Optional.ToList(participants)); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.cs index e9a5240bb648c..81254e79aeda2 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ParticipantsUpdatedEventInternal.cs @@ -10,27 +10,27 @@ namespace Azure.Communication.CallingServer { - /// Class to represent roster update. + /// The participant update event. internal partial class ParticipantsUpdatedEventInternal { /// Initializes a new instance of ParticipantsUpdatedEventInternal. internal ParticipantsUpdatedEventInternal() { - Participants = new ChangeTrackingList(); + Participants = new ChangeTrackingList(); } /// Initializes a new instance of ParticipantsUpdatedEventInternal. - /// The call leg.id. + /// The call connection id. /// The list of participants. - internal ParticipantsUpdatedEventInternal(string callLegId, IReadOnlyList participants) + internal ParticipantsUpdatedEventInternal(string callConnectionId, IReadOnlyList participants) { - CallLegId = callLegId; + CallConnectionId = callConnectionId; Participants = participants; } - /// The call leg.id. - public string CallLegId { get; } + /// The call connection id. + public string CallConnectionId { get; } /// The list of participants. - public IReadOnlyList Participants { get; } + public IReadOnlyList Participants { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.cs deleted file mode 100644 index daa01f390e2bb..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResponse.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.Communication.CallingServer -{ - /// The response payload for play audio operation. - public partial class PlayAudioResponse - { - /// Initializes a new instance of PlayAudioResponse. - internal PlayAudioResponse() - { - } - - /// Initializes a new instance of PlayAudioResponse. - /// Gets or sets the identifier. - /// Gets or sets the status of the operation. - /// Gets or sets the operation context. - /// Gets or sets the result info. - internal PlayAudioResponse(string id, OperationStatus? status, string operationContext, ResultInfo resultInfo) - { - Id = id; - Status = status; - OperationContext = operationContext; - ResultInfo = resultInfo; - } - - /// Gets or sets the identifier. - public string Id { get; } - /// Gets or sets the status of the operation. - public OperationStatus? Status { get; } - /// Gets or sets the operation context. - public string OperationContext { get; } - /// Gets or sets the result info. - public ResultInfo ResultInfo { get; } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.Serialization.cs similarity index 64% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.Serialization.cs index 90342df4e8320..bda9dc0250e54 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/CancelAllMediaOperationsResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.Serialization.cs @@ -10,28 +10,23 @@ namespace Azure.Communication.CallingServer { - public partial class CancelAllMediaOperationsResponse + public partial class PlayAudioResult { - internal static CancelAllMediaOperationsResponse DeserializeCancelAllMediaOperationsResponse(JsonElement element) + internal static PlayAudioResult DeserializePlayAudioResult(JsonElement element) { - Optional id = default; - Optional status = default; + Optional operationId = default; + OperationStatus status = default; Optional operationContext = default; Optional resultInfo = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id")) + if (property.NameEquals("operationId")) { - id = property.Value.GetString(); + operationId = property.Value.GetString(); continue; } if (property.NameEquals("status")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } status = new OperationStatus(property.Value.GetString()); continue; } @@ -51,7 +46,7 @@ internal static CancelAllMediaOperationsResponse DeserializeCancelAllMediaOperat continue; } } - return new CancelAllMediaOperationsResponse(id.Value, Optional.ToNullable(status), operationContext.Value, resultInfo.Value); + return new PlayAudioResult(operationId.Value, status, operationContext.Value, resultInfo.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.cs new file mode 100644 index 0000000000000..7dd6b1dfd6d17 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResult.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Communication.CallingServer +{ + /// The response payload for play audio operation. + public partial class PlayAudioResult + { + /// Initializes a new instance of PlayAudioResult. + /// The status of the operation. + internal PlayAudioResult(OperationStatus status) + { + Status = status; + } + + /// Initializes a new instance of PlayAudioResult. + /// The operation id. + /// The status of the operation. + /// The operation context provided by client. + /// The result info for the operation. + internal PlayAudioResult(string operationId, OperationStatus status, string operationContext, ResultInfo resultInfo) + { + OperationId = operationId; + Status = status; + OperationContext = operationContext; + ResultInfo = resultInfo; + } + + /// The operation id. + public string OperationId { get; } + /// The status of the operation. + public OperationStatus Status { get; } + /// The operation context provided by client. + public string OperationContext { get; } + /// The result info for the operation. + public ResultInfo ResultInfo { get; } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.Serialization.cs index b1f1eeae26f4e..865e57a31d3b2 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.Serialization.cs @@ -10,34 +10,13 @@ namespace Azure.Communication.CallingServer { - public partial class PlayAudioResultEvent : IUtf8JsonSerializable + public partial class PlayAudioResultEvent { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(ResultInfo)) - { - writer.WritePropertyName("resultInfo"); - writer.WriteObjectValue(ResultInfo); - } - if (Optional.IsDefined(OperationContext)) - { - writer.WritePropertyName("operationContext"); - writer.WriteStringValue(OperationContext); - } - if (Optional.IsDefined(Status)) - { - writer.WritePropertyName("status"); - writer.WriteStringValue(Status.Value.ToString()); - } - writer.WriteEndObject(); - } - internal static PlayAudioResultEvent DeserializePlayAudioResultEvent(JsonElement element) { Optional resultInfo = default; Optional operationContext = default; - Optional status = default; + OperationStatus status = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("resultInfo")) @@ -57,16 +36,11 @@ internal static PlayAudioResultEvent DeserializePlayAudioResultEvent(JsonElement } if (property.NameEquals("status")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } status = new OperationStatus(property.Value.GetString()); continue; } } - return new PlayAudioResultEvent(resultInfo.Value, operationContext.Value, Optional.ToNullable(status)); + return new PlayAudioResultEvent(resultInfo.Value, operationContext.Value, status); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.cs index a781525bc1669..5c13697c27d97 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/PlayAudioResultEvent.cs @@ -11,15 +11,17 @@ namespace Azure.Communication.CallingServer public partial class PlayAudioResultEvent { /// Initializes a new instance of PlayAudioResultEvent. - public PlayAudioResultEvent() + /// The status of the operation. + internal PlayAudioResultEvent(OperationStatus status) { + Status = status; } /// Initializes a new instance of PlayAudioResultEvent. /// The result details. /// The operation context. - /// Gets or sets the status of the operation. - internal PlayAudioResultEvent(ResultInfo resultInfo, string operationContext, OperationStatus? status) + /// The status of the operation. + internal PlayAudioResultEvent(ResultInfo resultInfo, string operationContext, OperationStatus status) { ResultInfo = resultInfo; OperationContext = operationContext; @@ -27,10 +29,10 @@ internal PlayAudioResultEvent(ResultInfo resultInfo, string operationContext, Op } /// The result details. - public ResultInfo ResultInfo { get; set; } + public ResultInfo ResultInfo { get; } /// The operation context. - public string OperationContext { get; set; } - /// Gets or sets the status of the operation. - public OperationStatus? Status { get; set; } + public string OperationContext { get; } + /// The status of the operation. + public OperationStatus Status { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.Serialization.cs index 2a66db65162b3..afeabc783ff31 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.Serialization.cs @@ -14,28 +14,18 @@ public partial class ResultInfo { internal static ResultInfo DeserializeResultInfo(JsonElement element) { - Optional code = default; - Optional subcode = default; + int code = default; + int subcode = default; Optional message = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } code = property.Value.GetInt32(); continue; } if (property.NameEquals("subcode")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } subcode = property.Value.GetInt32(); continue; } @@ -45,7 +35,7 @@ internal static ResultInfo DeserializeResultInfo(JsonElement element) continue; } } - return new ResultInfo(Optional.ToNullable(code), Optional.ToNullable(subcode), message.Value); + return new ResultInfo(code, subcode, message.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.cs index f40ef9a660a4d..7b4aa9982c196 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ResultInfo.cs @@ -11,50 +11,30 @@ namespace Azure.Communication.CallingServer public partial class ResultInfo { /// Initializes a new instance of ResultInfo. - internal ResultInfo() + /// The result code associated with the operation. + /// The subcode that further classifies the result. + internal ResultInfo(int code, int subcode) { + Code = code; + Subcode = subcode; } /// Initializes a new instance of ResultInfo. - /// - /// Gets or sets the result code - /// - /// For synchronous failures, this maps one-to-one with HTTP responses. For asynchronous failures or messages, it is contextual. - /// - /// - /// Gets or sets the result subcode. - /// - /// The subcode further classifies a failure. For example. - /// - /// - /// Gets or sets the message - /// - /// The message is a detail explanation of subcode. - /// - internal ResultInfo(int? code, int? subcode, string message) + /// The result code associated with the operation. + /// The subcode that further classifies the result. + /// The message is a detail explanation of subcode. + internal ResultInfo(int code, int subcode, string message) { Code = code; Subcode = subcode; Message = message; } - /// - /// Gets or sets the result code - /// - /// For synchronous failures, this maps one-to-one with HTTP responses. For asynchronous failures or messages, it is contextual. - /// - public int? Code { get; } - /// - /// Gets or sets the result subcode. - /// - /// The subcode further classifies a failure. For example. - /// - public int? Subcode { get; } - /// - /// Gets or sets the message - /// - /// The message is a detail explanation of subcode. - /// + /// The result code associated with the operation. + public int Code { get; } + /// The subcode that further classifies the result. + public int Subcode { get; } + /// The message is a detail explanation of subcode. public string Message { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.Serialization.cs similarity index 71% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.Serialization.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.Serialization.cs index 2819ae59c6cd0..0ed327d5f67e7 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.Serialization.cs @@ -10,9 +10,9 @@ namespace Azure.Communication.CallingServer { - public partial class StartCallRecordingResponse + public partial class StartCallRecordingResult { - internal static StartCallRecordingResponse DeserializeStartCallRecordingResponse(JsonElement element) + internal static StartCallRecordingResult DeserializeStartCallRecordingResult(JsonElement element) { Optional recordingId = default; foreach (var property in element.EnumerateObject()) @@ -23,7 +23,7 @@ internal static StartCallRecordingResponse DeserializeStartCallRecordingResponse continue; } } - return new StartCallRecordingResponse(recordingId.Value); + return new StartCallRecordingResult(recordingId.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.cs similarity index 76% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.cs index fdd30e12eb77d..1f34fac12aa16 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResponse.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/StartCallRecordingResult.cs @@ -8,16 +8,16 @@ namespace Azure.Communication.CallingServer { /// The response payload of start call recording operation. - public partial class StartCallRecordingResponse + public partial class StartCallRecordingResult { - /// Initializes a new instance of StartCallRecordingResponse. - internal StartCallRecordingResponse() + /// Initializes a new instance of StartCallRecordingResult. + internal StartCallRecordingResult() { } - /// Initializes a new instance of StartCallRecordingResponse. + /// Initializes a new instance of StartCallRecordingResult. /// The recording id of the started recording. - internal StartCallRecordingResponse(string recordingId) + internal StartCallRecordingResult(string recordingId) { RecordingId = recordingId; } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.Serialization.cs index f97a5a8609285..88f829d9ce48c 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.Serialization.cs @@ -10,52 +10,26 @@ namespace Azure.Communication.CallingServer { - public partial class ToneInfo : IUtf8JsonSerializable + public partial class ToneInfo { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(SequenceId)) - { - writer.WritePropertyName("sequenceId"); - writer.WriteNumberValue(SequenceId.Value); - } - if (Optional.IsDefined(Tone)) - { - writer.WritePropertyName("tone"); - writer.WriteStringValue(Tone.Value.ToString()); - } - writer.WriteEndObject(); - } - internal static ToneInfo DeserializeToneInfo(JsonElement element) { - Optional sequenceId = default; - Optional tone = default; + int sequenceId = default; + ToneValue tone = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sequenceId")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } sequenceId = property.Value.GetInt32(); continue; } if (property.NameEquals("tone")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } tone = new ToneValue(property.Value.GetString()); continue; } } - return new ToneInfo(Optional.ToNullable(sequenceId), Optional.ToNullable(tone)); + return new ToneInfo(sequenceId, tone); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.cs index e22dc97f01a0b..0fc8ed115fa85 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneInfo.cs @@ -7,34 +7,21 @@ namespace Azure.Communication.CallingServer { - /// Gets or sets the tone info. + /// The information about the tone. public partial class ToneInfo { /// Initializes a new instance of ToneInfo. - public ToneInfo() - { - } - - /// Initializes a new instance of ToneInfo. - /// - /// Gets or sets the sequence id. This id can be used to determine if the same tone - /// - /// was played multiple times or if any tones were missed. - /// - /// Gets or sets the tone detected. - internal ToneInfo(int? sequenceId, ToneValue? tone) + /// The sequence id which can be used to determine if the same tone was played multiple times or if any tones were missed. + /// The tone value. + internal ToneInfo(int sequenceId, ToneValue tone) { SequenceId = sequenceId; Tone = tone; } - /// - /// Gets or sets the sequence id. This id can be used to determine if the same tone - /// - /// was played multiple times or if any tones were missed. - /// - public int? SequenceId { get; set; } - /// Gets or sets the tone detected. - public ToneValue? Tone { get; set; } + /// The sequence id which can be used to determine if the same tone was played multiple times or if any tones were missed. + public int SequenceId { get; } + /// The tone value. + public ToneValue Tone { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.Serialization.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.Serialization.cs index 025c53232a1d2..9c2f01a2901aa 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.Serialization.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.Serialization.cs @@ -10,47 +10,26 @@ namespace Azure.Communication.CallingServer { - public partial class ToneReceivedEvent : IUtf8JsonSerializable + public partial class ToneReceivedEvent { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(ToneInfo)) - { - writer.WritePropertyName("toneInfo"); - writer.WriteObjectValue(ToneInfo); - } - if (Optional.IsDefined(CallLegId)) - { - writer.WritePropertyName("callLegId"); - writer.WriteStringValue(CallLegId); - } - writer.WriteEndObject(); - } - internal static ToneReceivedEvent DeserializeToneReceivedEvent(JsonElement element) { - Optional toneInfo = default; - Optional callLegId = default; + ToneInfo toneInfo = default; + Optional callConnectionId = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("toneInfo")) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } toneInfo = ToneInfo.DeserializeToneInfo(property.Value); continue; } - if (property.NameEquals("callLegId")) + if (property.NameEquals("callConnectionId")) { - callLegId = property.Value.GetString(); + callConnectionId = property.Value.GetString(); continue; } } - return new ToneReceivedEvent(toneInfo.Value, callLegId.Value); + return new ToneReceivedEvent(toneInfo, callConnectionId.Value); } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.cs index 7c84fcfde5105..645c5e5e72b06 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneReceivedEvent.cs @@ -5,28 +5,38 @@ #nullable disable +using System; + namespace Azure.Communication.CallingServer { /// The subscribe to tone event. public partial class ToneReceivedEvent { /// Initializes a new instance of ToneReceivedEvent. - public ToneReceivedEvent() + /// The tone info. + /// is null. + internal ToneReceivedEvent(ToneInfo toneInfo) { + if (toneInfo == null) + { + throw new ArgumentNullException(nameof(toneInfo)); + } + + ToneInfo = toneInfo; } /// Initializes a new instance of ToneReceivedEvent. /// The tone info. - /// The call leg.id. - internal ToneReceivedEvent(ToneInfo toneInfo, string callLegId) + /// The call connection id. + internal ToneReceivedEvent(ToneInfo toneInfo, string callConnectionId) { ToneInfo = toneInfo; - CallLegId = callLegId; + CallConnectionId = callConnectionId; } /// The tone info. - public ToneInfo ToneInfo { get; set; } - /// The call leg.id. - public string CallLegId { get; set; } + public ToneInfo ToneInfo { get; } + /// The call connection id. + public string CallConnectionId { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneValue.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneValue.cs index 2881449048c2a..b61260b6d57ec 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneValue.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/Models/ToneValue.cs @@ -10,7 +10,7 @@ namespace Azure.Communication.CallingServer { - /// Gets or sets the tone detected. + /// The tone value. public readonly partial struct ToneValue : IEquatable { private readonly string _value; diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Generated/ConversationRestClient.cs b/sdk/communication/Azure.Communication.CallingServer/src/Generated/ServerCallsRestClient.cs similarity index 59% rename from sdk/communication/Azure.Communication.CallingServer/src/Generated/ConversationRestClient.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Generated/ServerCallsRestClient.cs index 13c588e0121b1..590d85b54afa2 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Generated/ConversationRestClient.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Generated/ServerCallsRestClient.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -18,20 +17,20 @@ namespace Azure.Communication.CallingServer { - internal partial class ConversationRestClient + internal partial class ServerCallsRestClient { private string endpoint; private string apiVersion; private ClientDiagnostics _clientDiagnostics; private HttpPipeline _pipeline; - /// Initializes a new instance of ConversationRestClient. + /// Initializes a new instance of ServerCallsRestClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. /// The endpoint of the Azure Communication resource. /// Api Version. /// or is null. - public ConversationRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiVersion = "2021-04-15-preview1") + public ServerCallsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiVersion = "2021-06-15-preview") { if (endpoint == null) { @@ -48,23 +47,26 @@ public ConversationRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline _pipeline = pipeline; } - internal HttpMessage CreateJoinCallRequest(string conversationId, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, string subject) + internal HttpMessage CreateAddParticipantRequest(string serverCallId, PhoneNumberIdentifierModel alternateCallerId, CommunicationIdentifierModel participant, string operationContext, string callbackUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/Join", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/participants", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); - var model = new JoinCallRequestInternal(source, callbackUri, requestedModalities.ToList(), requestedCallEvents.ToList()) + var model = new AddParticipantRequest() { - Subject = subject + AlternateCallerId = alternateCallerId, + Participant = participant, + OperationContext = operationContext, + CallbackUri = callbackUri }; var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(model); @@ -72,47 +74,30 @@ internal HttpMessage CreateJoinCallRequest(string conversationId, CommunicationI return message; } - /// Join a call. - /// The conversation id which can be guid or encoded cs url. - /// The source of the call. + /// Add a participant to the call. + /// The server call id. + /// The alternate identity of source participant. + /// The participant to be added to the call. + /// The operation context. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// The subject. /// The cancellation token to use. - /// , , , , or is null. - public async Task> JoinCallAsync(string conversationId, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, string subject = null, CancellationToken cancellationToken = default) + /// is null. + public async Task> AddParticipantAsync(string serverCallId, PhoneNumberIdentifierModel alternateCallerId = null, CommunicationIdentifierModel participant = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) - { - throw new ArgumentNullException(nameof(conversationId)); - } - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - if (callbackUri == null) - { - throw new ArgumentNullException(nameof(callbackUri)); - } - if (requestedModalities == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(requestedModalities)); - } - if (requestedCallEvents == null) - { - throw new ArgumentNullException(nameof(requestedCallEvents)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateJoinCallRequest(conversationId, source, callbackUri, requestedModalities, requestedCallEvents, subject); + using var message = CreateAddParticipantRequest(serverCallId, alternateCallerId, participant, operationContext, callbackUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: { - JoinCallResponse value = default; + AddParticipantResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = JoinCallResponse.DeserializeJoinCallResponse(document.RootElement); + value = AddParticipantResult.DeserializeAddParticipantResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -120,47 +105,30 @@ public async Task> JoinCallAsync(string conversationI } } - /// Join a call. - /// The conversation id which can be guid or encoded cs url. - /// The source of the call. + /// Add a participant to the call. + /// The server call id. + /// The alternate identity of source participant. + /// The participant to be added to the call. + /// The operation context. /// The callback URI. - /// The requested modalities. - /// The requested call events to subscribe to. - /// The subject. /// The cancellation token to use. - /// , , , , or is null. - public Response JoinCall(string conversationId, CommunicationIdentifierModel source, string callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents, string subject = null, CancellationToken cancellationToken = default) + /// is null. + public Response AddParticipant(string serverCallId, PhoneNumberIdentifierModel alternateCallerId = null, CommunicationIdentifierModel participant = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); - } - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - if (callbackUri == null) - { - throw new ArgumentNullException(nameof(callbackUri)); - } - if (requestedModalities == null) - { - throw new ArgumentNullException(nameof(requestedModalities)); - } - if (requestedCallEvents == null) - { - throw new ArgumentNullException(nameof(requestedCallEvents)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateJoinCallRequest(conversationId, source, callbackUri, requestedModalities, requestedCallEvents, subject); + using var message = CreateAddParticipantRequest(serverCallId, alternateCallerId, participant, operationContext, callbackUri); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 202: { - JoinCallResponse value = default; + AddParticipantResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream); - value = JoinCallResponse.DeserializeJoinCallResponse(document.RootElement); + value = AddParticipantResult.DeserializeAddParticipantResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -168,133 +136,94 @@ public Response JoinCall(string conversationId, CommunicationI } } - internal HttpMessage CreatePlayAudioRequest(string conversationId, string audioFileUri, bool? loop, string operationContext, string audioFileId, string callbackUri) + internal HttpMessage CreateRemoveParticipantRequest(string serverCallId, string participantId) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Post; + request.Method = RequestMethod.Delete; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/PlayAudio", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/participants/", false); + uri.AppendPath(participantId, true); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var model = new PlayAudioRequest() - { - AudioFileUri = audioFileUri, - Loop = loop, - OperationContext = operationContext, - AudioFileId = audioFileId, - CallbackUri = callbackUri - }; - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(model); - request.Content = content; return message; } - /// Play audio in a call. - /// The conversation id which can be guid or encoded cs url. - /// - /// The media resource uri of the play audio request. - /// - /// Currently only Wave file (.wav) format audio prompts are supported. - /// - /// More specifically, the audio content in the wave file must be mono (single-channel), - /// - /// 16-bit samples with a 16,000 (16KHz) sampling rate. - /// - /// The flag indicating whether audio file needs to be played in loop or not. - /// The value to identify context of the operation. - /// An id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. + /// Remove participant from the call. + /// Server call id. + /// Participant id. /// The cancellation token to use. - /// is null. - public async Task> PlayAudioAsync(string conversationId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// or is null. + public async Task RemoveParticipantAsync(string serverCallId, string participantId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) + { + throw new ArgumentNullException(nameof(serverCallId)); + } + if (participantId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(participantId)); } - using var message = CreatePlayAudioRequest(conversationId, audioFileUri, loop, operationContext, audioFileId, callbackUri); + using var message = CreateRemoveParticipantRequest(serverCallId, participantId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 202: - { - PlayAudioResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = PlayAudioResponse.DeserializePlayAudioResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Play audio in a call. - /// The conversation id which can be guid or encoded cs url. - /// - /// The media resource uri of the play audio request. - /// - /// Currently only Wave file (.wav) format audio prompts are supported. - /// - /// More specifically, the audio content in the wave file must be mono (single-channel), - /// - /// 16-bit samples with a 16,000 (16KHz) sampling rate. - /// - /// The flag indicating whether audio file needs to be played in loop or not. - /// The value to identify context of the operation. - /// An id for the media in the AudioFileUri, using which we cache the media resource. - /// The callback Uri to receive PlayAudio status notifications. + /// Remove participant from the call. + /// Server call id. + /// Participant id. /// The cancellation token to use. - /// is null. - public Response PlayAudio(string conversationId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// or is null. + public Response RemoveParticipant(string serverCallId, string participantId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) + { + throw new ArgumentNullException(nameof(serverCallId)); + } + if (participantId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(participantId)); } - using var message = CreatePlayAudioRequest(conversationId, audioFileUri, loop, operationContext, audioFileId, callbackUri); + using var message = CreateRemoveParticipantRequest(serverCallId, participantId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 202: - { - PlayAudioResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = PlayAudioResponse.DeserializePlayAudioResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateInviteParticipantsRequest(string conversationId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId, string operationContext, string callbackUri) + internal HttpMessage CreateStartRecordingRequest(string serverCallId, string recordingStateCallbackUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/participants", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/recordings", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); - var model = new InviteParticipantsRequestInternal(participants.ToList()) + var model = new StartCallRecordingRequest() { - AlternateCallerId = alternateCallerId, - OperationContext = operationContext, - CallbackUri = callbackUri + RecordingStateCallbackUri = recordingStateCallbackUri }; var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(model); @@ -302,332 +231,321 @@ internal HttpMessage CreateInviteParticipantsRequest(string conversationId, IEnu return message; } - /// Invite participants to the call. - /// Conversation id. - /// The list of participants to be added to the call. - /// The alternate identity of source participant. - /// The operation context. - /// The callback URI. + /// Start recording of the call. + /// The server call id. + /// The uri to send notifications to. /// The cancellation token to use. - /// or is null. - public async Task InviteParticipantsAsync(string conversationId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public async Task> StartRecordingAsync(string serverCallId, string recordingStateCallbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) - { - throw new ArgumentNullException(nameof(conversationId)); - } - if (participants == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(participants)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateInviteParticipantsRequest(conversationId, participants, alternateCallerId, operationContext, callbackUri); + using var message = CreateStartRecordingRequest(serverCallId, recordingStateCallbackUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { - case 202: - return message.Response; + case 200: + { + StartCallRecordingResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StartCallRecordingResult.DeserializeStartCallRecordingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Invite participants to the call. - /// Conversation id. - /// The list of participants to be added to the call. - /// The alternate identity of source participant. - /// The operation context. - /// The callback URI. + /// Start recording of the call. + /// The server call id. + /// The uri to send notifications to. /// The cancellation token to use. - /// or is null. - public Response InviteParticipants(string conversationId, IEnumerable participants, PhoneNumberIdentifierModel alternateCallerId = null, string operationContext = null, string callbackUri = null, CancellationToken cancellationToken = default) + /// is null. + public Response StartRecording(string serverCallId, string recordingStateCallbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) - { - throw new ArgumentNullException(nameof(conversationId)); - } - if (participants == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(participants)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateInviteParticipantsRequest(conversationId, participants, alternateCallerId, operationContext, callbackUri); + using var message = CreateStartRecordingRequest(serverCallId, recordingStateCallbackUri); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { - case 202: - return message.Response; + case 200: + { + StartCallRecordingResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StartCallRecordingResult.DeserializeStartCallRecordingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateRemoveParticipantRequest(string conversationId, string participantId) + internal HttpMessage CreateGetRecordingPropertiesRequest(string serverCallId, string recordingId) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Delete; + request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/participants/", false); - uri.AppendPath(participantId, true); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/recordings/", false); + uri.AppendPath(recordingId, true); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - /// Remove participant from the call. - /// Conversation id. - /// Participant id. + /// Get call recording properties. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public async Task RemoveParticipantAsync(string conversationId, string participantId, CancellationToken cancellationToken = default) + /// or is null. + public async Task> GetRecordingPropertiesAsync(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } - if (participantId == null) + if (recordingId == null) { - throw new ArgumentNullException(nameof(participantId)); + throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateRemoveParticipantRequest(conversationId, participantId); + using var message = CreateGetRecordingPropertiesRequest(serverCallId, recordingId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { - case 202: - return message.Response; + case 200: + { + CallRecordingProperties value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CallRecordingProperties.DeserializeCallRecordingProperties(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Remove participant from the call. - /// Conversation id. - /// Participant id. + /// Get call recording properties. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public Response RemoveParticipant(string conversationId, string participantId, CancellationToken cancellationToken = default) + /// or is null. + public Response GetRecordingProperties(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } - if (participantId == null) + if (recordingId == null) { - throw new ArgumentNullException(nameof(participantId)); + throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateRemoveParticipantRequest(conversationId, participantId); + using var message = CreateGetRecordingPropertiesRequest(serverCallId, recordingId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { - case 202: - return message.Response; + case 200: + { + CallRecordingProperties value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CallRecordingProperties.DeserializeCallRecordingProperties(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateStartRecordingRequest(string conversationId, string recordingStateCallbackUri) + internal HttpMessage CreateStopRecordingRequest(string serverCallId, string recordingId) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Post; + request.Method = RequestMethod.Delete; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/recordings", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/recordings/", false); + uri.AppendPath(recordingId, true); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var model = new StartCallRecordingRequest() - { - RecordingStateCallbackUri = recordingStateCallbackUri - }; - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(model); - request.Content = content; return message; } - /// Start call recording request. - /// Encoded conversation url. - /// The uri to send notifications to. + /// Stop recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// is null. - public async Task> StartRecordingAsync(string conversationId, string recordingStateCallbackUri = null, CancellationToken cancellationToken = default) + /// or is null. + public async Task StopRecordingAsync(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) + { + throw new ArgumentNullException(nameof(serverCallId)); + } + if (recordingId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateStartRecordingRequest(conversationId, recordingStateCallbackUri); + using var message = CreateStopRecordingRequest(serverCallId, recordingId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: - { - StartCallRecordingResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = StartCallRecordingResponse.DeserializeStartCallRecordingResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Start call recording request. - /// Encoded conversation url. - /// The uri to send notifications to. + /// Stop recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// is null. - public Response StartRecording(string conversationId, string recordingStateCallbackUri = null, CancellationToken cancellationToken = default) + /// or is null. + public Response StopRecording(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); + } + if (recordingId == null) + { + throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateStartRecordingRequest(conversationId, recordingStateCallbackUri); + using var message = CreateStopRecordingRequest(serverCallId, recordingId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: - { - StartCallRecordingResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = StartCallRecordingResponse.DeserializeStartCallRecordingResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateRecordingStateRequest(string conversationId, string recordingId) + internal HttpMessage CreatePauseRecordingRequest(string serverCallId, string recordingId) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Get; + request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); uri.AppendPath("/recordings/", false); uri.AppendPath(recordingId, true); + uri.AppendPath("/:pause", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - /// Get call recording state. - /// Encoded conversation url. - /// Recording id. + /// Pause recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public async Task> RecordingStateAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// or is null. + public async Task PauseRecordingAsync(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } if (recordingId == null) { throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateRecordingStateRequest(conversationId, recordingId); + using var message = CreatePauseRecordingRequest(serverCallId, recordingId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: - { - GetCallRecordingStateResponse value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = GetCallRecordingStateResponse.DeserializeGetCallRecordingStateResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Get call recording state. - /// Encoded conversation url. - /// Recording id. + /// Pause recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public Response RecordingState(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// or is null. + public Response PauseRecording(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } if (recordingId == null) { throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateRecordingStateRequest(conversationId, recordingId); + using var message = CreatePauseRecordingRequest(serverCallId, recordingId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: - { - GetCallRecordingStateResponse value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = GetCallRecordingStateResponse.DeserializeGetCallRecordingStateResponse(document.RootElement); - return Response.FromValue(value, message.Response); - } + return message.Response; default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateStopRecordingRequest(string conversationId, string recordingId) + internal HttpMessage CreateResumeRecordingRequest(string serverCallId, string recordingId) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Delete; + request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); uri.AppendPath("/recordings/", false); uri.AppendPath(recordingId, true); + uri.AppendPath("/:resume", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - /// Stop recording a call. - /// Encoded conversation url. - /// Recording id. + /// Resume recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public async Task StopRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// or is null. + public async Task ResumeRecordingAsync(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } if (recordingId == null) { throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateStopRecordingRequest(conversationId, recordingId); + using var message = CreateResumeRecordingRequest(serverCallId, recordingId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -638,23 +556,23 @@ public async Task StopRecordingAsync(string conversationId, string rec } } - /// Stop recording a call. - /// Encoded conversation url. - /// Recording id. + /// Resume recording the call. + /// The server call id. + /// The recording id. /// The cancellation token to use. - /// or is null. - public Response StopRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// or is null. + public Response ResumeRecording(string serverCallId, string recordingId, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } if (recordingId == null) { throw new ArgumentNullException(nameof(recordingId)); } - using var message = CreateStopRecordingRequest(conversationId, recordingId); + using var message = CreateResumeRecordingRequest(serverCallId, recordingId); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -665,145 +583,228 @@ public Response StopRecording(string conversationId, string recordingId, Cancell } } - internal HttpMessage CreatePauseRecordingRequest(string conversationId, string recordingId) + internal HttpMessage CreateJoinCallRequest(string serverCallId, CommunicationIdentifierModel source, string callbackUri, string subject, IEnumerable requestedMediaTypes, IEnumerable requestedCallEvents) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/recordings/", false); - uri.AppendPath(recordingId, true); - uri.AppendPath("/Pause", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/:join", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + JoinCallRequestInternal joinCallRequestInternal = new JoinCallRequestInternal(source, callbackUri) + { + Subject = subject + }; + if (requestedMediaTypes != null) + { + foreach (var value in requestedMediaTypes) + { + joinCallRequestInternal.RequestedMediaTypes.Add(value); + } + } + if (requestedCallEvents != null) + { + foreach (var value in requestedCallEvents) + { + joinCallRequestInternal.RequestedCallEvents.Add(value); + } + } + var model = joinCallRequestInternal; + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(model); + request.Content = content; return message; } - /// Pause recording a call. - /// Encoded conversation url. - /// Recording id. + /// Join a call. + /// The server call id. + /// The source of the call. + /// The callback URI. + /// The subject. + /// The requested modalities. + /// The requested call events to subscribe to. /// The cancellation token to use. - /// or is null. - public async Task PauseRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// , , or is null. + public async Task> JoinCallAsync(string serverCallId, CommunicationIdentifierModel source, string callbackUri, string subject = null, IEnumerable requestedMediaTypes = null, IEnumerable requestedCallEvents = null, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } - if (recordingId == null) + if (source == null) { - throw new ArgumentNullException(nameof(recordingId)); + throw new ArgumentNullException(nameof(source)); + } + if (callbackUri == null) + { + throw new ArgumentNullException(nameof(callbackUri)); } - using var message = CreatePauseRecordingRequest(conversationId, recordingId); + using var message = CreateJoinCallRequest(serverCallId, source, callbackUri, subject, requestedMediaTypes, requestedCallEvents); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { - case 200: - return message.Response; + case 202: + { + JoinCallResultInternal value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = JoinCallResultInternal.DeserializeJoinCallResultInternal(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Pause recording a call. - /// Encoded conversation url. - /// Recording id. + /// Join a call. + /// The server call id. + /// The source of the call. + /// The callback URI. + /// The subject. + /// The requested modalities. + /// The requested call events to subscribe to. /// The cancellation token to use. - /// or is null. - public Response PauseRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// , , or is null. + public Response JoinCall(string serverCallId, CommunicationIdentifierModel source, string callbackUri, string subject = null, IEnumerable requestedMediaTypes = null, IEnumerable requestedCallEvents = null, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); + throw new ArgumentNullException(nameof(serverCallId)); } - if (recordingId == null) + if (source == null) { - throw new ArgumentNullException(nameof(recordingId)); + throw new ArgumentNullException(nameof(source)); + } + if (callbackUri == null) + { + throw new ArgumentNullException(nameof(callbackUri)); } - using var message = CreatePauseRecordingRequest(conversationId, recordingId); + using var message = CreateJoinCallRequest(serverCallId, source, callbackUri, subject, requestedMediaTypes, requestedCallEvents); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { - case 200: - return message.Response; + case 202: + { + JoinCallResultInternal value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = JoinCallResultInternal.DeserializeJoinCallResultInternal(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } - internal HttpMessage CreateResumeRecordingRequest(string conversationId, string recordingId) + internal HttpMessage CreatePlayAudioRequest(string serverCallId, string audioFileUri, bool? loop, string operationContext, string audioFileId, string callbackUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); - uri.AppendPath("/calling/conversations/", false); - uri.AppendPath(conversationId, true); - uri.AppendPath("/recordings/", false); - uri.AppendPath(recordingId, true); - uri.AppendPath("/Resume", false); + uri.AppendPath("/calling/serverCalls/", false); + uri.AppendPath(serverCallId, true); + uri.AppendPath("/:playAudio", false); uri.AppendQuery("api-version", apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var model = new PlayAudioRequest() + { + AudioFileUri = audioFileUri, + Loop = loop, + OperationContext = operationContext, + AudioFileId = audioFileId, + CallbackUri = callbackUri + }; + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(model); + request.Content = content; return message; } - /// Resume recording a call. - /// Encoded conversation url. - /// Recording id. + /// Play audio in the call. + /// The server call id. + /// + /// The media resource uri of the play audio request. + /// + /// Currently only Wave file (.wav) format audio prompts are supported. + /// + /// More specifically, the audio content in the wave file must be mono (single-channel), + /// + /// 16-bit samples with a 16,000 (16KHz) sampling rate. + /// + /// The flag indicating whether audio file needs to be played in loop or not. + /// The value to identify context of the operation. + /// An id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. /// The cancellation token to use. - /// or is null. - public async Task ResumeRecordingAsync(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// is null. + public async Task> PlayAudioAsync(string serverCallId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(conversationId)); - } - if (recordingId == null) - { - throw new ArgumentNullException(nameof(recordingId)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateResumeRecordingRequest(conversationId, recordingId); + using var message = CreatePlayAudioRequest(serverCallId, audioFileUri, loop, operationContext, audioFileId, callbackUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { - case 200: - return message.Response; + case 202: + { + PlayAudioResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PlayAudioResult.DeserializePlayAudioResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } } - /// Resume recording a call. - /// Encoded conversation url. - /// Recording id. + /// Play audio in the call. + /// The server call id. + /// + /// The media resource uri of the play audio request. + /// + /// Currently only Wave file (.wav) format audio prompts are supported. + /// + /// More specifically, the audio content in the wave file must be mono (single-channel), + /// + /// 16-bit samples with a 16,000 (16KHz) sampling rate. + /// + /// The flag indicating whether audio file needs to be played in loop or not. + /// The value to identify context of the operation. + /// An id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. /// The cancellation token to use. - /// or is null. - public Response ResumeRecording(string conversationId, string recordingId, CancellationToken cancellationToken = default) + /// is null. + public Response PlayAudio(string serverCallId, string audioFileUri = null, bool? loop = null, string operationContext = null, string audioFileId = null, string callbackUri = null, CancellationToken cancellationToken = default) { - if (conversationId == null) - { - throw new ArgumentNullException(nameof(conversationId)); - } - if (recordingId == null) + if (serverCallId == null) { - throw new ArgumentNullException(nameof(recordingId)); + throw new ArgumentNullException(nameof(serverCallId)); } - using var message = CreateResumeRecordingRequest(conversationId, recordingId); + using var message = CreatePlayAudioRequest(serverCallId, audioFileUri, loop, operationContext, audioFileId, callbackUri); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { - case 200: - return message.Response; + case 202: + { + PlayAudioResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PlayAudioResult.DeserializePlayAudioResult(document.RootElement); + return Response.FromValue(value, message.Response); + } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CallState.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallConnectionState.cs similarity index 59% rename from sdk/communication/Azure.Communication.CallingServer/src/Models/CallState.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Models/CallConnectionState.cs index bc33da63dffd3..0175802d929d0 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/CallState.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallConnectionState.cs @@ -8,8 +8,8 @@ namespace Azure.Communication.CallingServer /// /// The states of a call. /// - [CodeGenModel("CallState", Usage = new string[] { "input", "output" }, Formats = new string[] { "json" })] - public readonly partial struct CallState + [CodeGenModel("CallConnectionState", Usage = new string[] { "output" }, Formats = new string[] { "json" })] + public readonly partial struct CallConnectionState { } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipant.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipant.cs similarity index 52% rename from sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipant.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipant.cs index 7ce1548733bdb..938623f882f41 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipant.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipant.cs @@ -3,19 +3,14 @@ namespace Azure.Communication.CallingServer { - /// Class to represent entry in roster. - public class CommunicationParticipant + /// The participant in a call. + public class CallParticipant { - /// Initializes a new instance of CommunicationParticipant. - public CommunicationParticipant() - { - } - - /// Initializes a new instance of CommunicationParticipant. + /// Initializes a new instance of CallParticipant. /// The communication identifier. /// Participant Id. /// Is participant muted. - public CommunicationParticipant(CommunicationIdentifier identifier, string participantId, bool? isMuted) + internal CallParticipant(CommunicationIdentifier identifier, string participantId, bool isMuted) { Identifier = identifier; ParticipantId = participantId; @@ -23,12 +18,12 @@ public CommunicationParticipant(CommunicationIdentifier identifier, string parti } /// The communication identifier. - public CommunicationIdentifier Identifier { get; set; } + public CommunicationIdentifier Identifier { get; } /// Participant Id. - public string ParticipantId { get; set; } + public string ParticipantId { get; } /// Is participant muted. - public bool? IsMuted { get; set; } + public bool IsMuted { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipantInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipantInternal.cs similarity index 58% rename from sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipantInternal.cs rename to sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipantInternal.cs index 54ecdbcdfd2fb..781dcb69cedad 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/CommunicationParticipantInternal.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallParticipantInternal.cs @@ -8,8 +8,8 @@ namespace Azure.Communication.CallingServer /// /// The participant in a call. /// - [CodeGenModel("CommunicationParticipant", Usage = new string[] { "output" }, Formats = new string[] { "json" })] - internal partial class CommunicationParticipantInternal + [CodeGenModel("CallParticipant", Usage = new string[] { "output" }, Formats = new string[] { "json" })] + internal partial class CallParticipantInternal { } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CallingServerModelFactory.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallingServerModelFactory.cs new file mode 100644 index 0000000000000..e37cf7fd149b4 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CallingServerModelFactory.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Communication.CallingServer.Models +{ + /// + /// Calling server model factory + /// + [CodeGenModel("AzureCommunicationServicesModelFactory")] + public partial class CallingServerModelFactory + { + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallOptions.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallOptions.cs index 6740661ee3c49..1f3008b4b5e0e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallOptions.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallOptions.cs @@ -20,25 +20,25 @@ public class CreateCallOptions /// The callback URI. public Uri CallbackUri { get; } - /// The requested modalities. - public IList RequestedModalities { get; } + /// The requested media types. + public IList RequestedMediaTypes { get; } /// The requested call events to subscribe to. public IList RequestedCallEvents { get; } /// Initializes a new instance of CreateCallOptions. /// The callback URI. - /// The requested modalities. + /// The requested media types. /// The requested call events to subscribe to. - /// , , or is null. - public CreateCallOptions(Uri callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents) + /// , , or is null. + public CreateCallOptions(Uri callbackUri, IEnumerable requestedMediaTypes, IEnumerable requestedCallEvents) { Argument.AssertNotNull(callbackUri, nameof(callbackUri)); - Argument.AssertNotNull(requestedModalities, nameof(requestedModalities)); + Argument.AssertNotNull(requestedMediaTypes, nameof(requestedMediaTypes)); Argument.AssertNotNull(requestedCallEvents, nameof(requestedCallEvents)); CallbackUri = callbackUri; - RequestedModalities = requestedModalities.ToList(); + RequestedMediaTypes = requestedMediaTypes.ToList(); RequestedCallEvents = requestedCallEvents.ToList(); } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallResultInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallResultInternal.cs new file mode 100644 index 0000000000000..8a5e2b7913dae --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/CreateCallResultInternal.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + [CodeGenModel("CreateCallResult")] + internal partial class CreateCallResultInternal + { + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/AddParticipantResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/AddParticipantResultEvent.cs new file mode 100644 index 0000000000000..29ed58bab1cbf --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/AddParticipantResultEvent.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + /// + /// The added participants result event. + /// + [CodeGenModel("AddParticipantResultEvent", Usage = new string[] { "output" }, Formats = new string[] { "json" })] + public partial class AddParticipantResultEvent : CallingServerEventBase + { + /// + /// Deserialize event. + /// + /// The json content. + /// The new object. + public static AddParticipantResultEvent Deserialize(string content) + { + using var document = JsonDocument.Parse(content); + JsonElement element = document.RootElement; + + return DeserializeAddParticipantResultEvent(element); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallConnectionStateChangedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallConnectionStateChangedEvent.cs new file mode 100644 index 0000000000000..10f8ca12a864a --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallConnectionStateChangedEvent.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + /// + /// The call connection state change event. + /// + [CodeGenModel("CallConnectionStateChangedEvent", Usage = new string[] { "output" }, Formats = new string[] { "json" })] + public partial class CallConnectionStateChangedEvent : CallingServerEventBase + { + /// + /// Deserialize event. + /// + /// The json content. + /// The new object. + public static CallConnectionStateChangedEvent Deserialize(string content) + { + using var document = JsonDocument.Parse(content); + JsonElement element = document.RootElement; + + return DeserializeCallConnectionStateChangedEvent(element); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallLegStateChangedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallLegStateChangedEvent.cs deleted file mode 100644 index 8c6289d39b82b..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallLegStateChangedEvent.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Text.Json; -using Azure.Core; - -namespace Azure.Communication.CallingServer -{ - /// - /// The call leg state change event. - /// - [CodeGenModel("CallLegStateChangedEvent", Usage = new string[] { "input, output" }, Formats = new string[] { "json" })] - public partial class CallLegStateChangedEvent : CallingServerEventBase - { - /// - /// Deserialize event. - /// - /// The json content. - /// The new object. - public static CallLegStateChangedEvent Deserialize(string content) - { - using var document = JsonDocument.Parse(content); - JsonElement element = document.RootElement; - - return DeserializeCallLegStateChangedEvent(element); - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallRecordingStateChangeEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallRecordingStateChangeEvent.cs index 1b84ea2dd9473..81ca894900d54 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallRecordingStateChangeEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallRecordingStateChangeEvent.cs @@ -9,7 +9,7 @@ namespace Azure.Communication.CallingServer /// /// The call recording state change event. /// - [CodeGenModel("CallRecordingStateChangeEvent", Usage = new string[] { "input, output" }, Formats = new string[] { "json" })] + [CodeGenModel("CallRecordingStateChangeEvent", Usage = new string[] { "output" }, Formats = new string[] { "json" })] public partial class CallRecordingStateChangeEvent : CallingServerEventBase { /// diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallingServerEventType.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallingServerEventType.cs index 8e17723f93bce..ecb6b39238df5 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallingServerEventType.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/CallingServerEventType.cs @@ -22,17 +22,17 @@ public CallingServerEventType(string value) _value = value ?? throw new ArgumentNullException(nameof(value)); } - internal const string CallLegStateChangedEventValue = "Microsoft.Communication.CallLegStateChanged"; + internal const string CallConnectionStateChangedEventValue = "Microsoft.Communication.CallConnectionStateChanged"; internal const string ToneReceivedEventValue = "Microsoft.Communication.DtmfReceived"; internal const string PlayAudioResultEventValue = "Microsoft.Communication.PlayAudioResult"; internal const string CallRecordingStateChangeEventValue = "Microsoft.Communication.CallRecordingStateChanged"; - internal const string InviteParticipantsResultEventValue = "Microsoft.Communication.InviteParticipantResult"; + internal const string AddParticipantResultEventValue = "Microsoft.Communication.AddParticipantResult"; internal const string ParticipantsUpdatedEventValue = "Microsoft.Communication.ParticipantsUpdated"; /// - /// The call leg state change event type. + /// The call connection state change event type. /// - public static CallingServerEventType CallLegStateChangedEvent { get; } = new CallingServerEventType(CallLegStateChangedEventValue); + public static CallingServerEventType CallConnectionStateChangedEvent { get; } = new CallingServerEventType(CallConnectionStateChangedEventValue); /// /// The subscribe to tone event type. @@ -50,9 +50,9 @@ public CallingServerEventType(string value) public static CallingServerEventType CallRecordingStateChangeEvent { get; } = new CallingServerEventType(CallRecordingStateChangeEventValue); /// - /// The invited participants result event type. + /// The add participant result event type. /// - public static CallingServerEventType InviteParticipantsResultEvent { get; } = new CallingServerEventType(InviteParticipantsResultEventValue); + public static CallingServerEventType AddParticipantResultEvent { get; } = new CallingServerEventType(AddParticipantResultEventValue); /// /// The call state change event type. @@ -88,7 +88,7 @@ public bool Equals(CallingServerEventType other) [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { - return obj is CallState && Equals((CallingServerEventType)obj); + return obj is CallingServerEventType && Equals((CallingServerEventType)obj); } /// diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/InviteParticipantsResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/InviteParticipantsResultEvent.cs deleted file mode 100644 index 191c0cf224ad6..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/InviteParticipantsResultEvent.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Text.Json; -using Azure.Core; - -namespace Azure.Communication.CallingServer -{ - /// - /// The invited participants result event. - /// - [CodeGenModel("InviteParticipantsResultEvent", Usage = new string[] { "input, output" }, Formats = new string[] { "json" })] - public partial class InviteParticipantsResultEvent : CallingServerEventBase - { - /// - /// Deserialize event. - /// - /// The json content. - /// The new object. - public static InviteParticipantsResultEvent Deserialize(string content) - { - using var document = JsonDocument.Parse(content); - JsonElement element = document.RootElement; - - return DeserializeInviteParticipantsResultEvent(element); - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ParticipantsUpdatedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ParticipantsUpdatedEvent.cs index a96c5490cfde2..4e6293852ee38 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ParticipantsUpdatedEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ParticipantsUpdatedEvent.cs @@ -12,9 +12,13 @@ namespace Azure.Communication.CallingServer /// public class ParticipantsUpdatedEvent : CallingServerEventBase { - /// Initializes a new instance of ParticipantsUpdatedEventInternal. - public ParticipantsUpdatedEvent() + /// Initializes a new instance of ParticipantsUpdatedEvent. + /// The call connection id. + /// The list of participants. + internal ParticipantsUpdatedEvent(string callConnectionId, IEnumerable participants) { + CallConnectionId = callConnectionId; + Participants = participants; } /// @@ -28,18 +32,15 @@ public static ParticipantsUpdatedEvent Deserialize(string content) JsonElement element = document.RootElement; var participantsUpdatedEventInternal = ParticipantsUpdatedEventInternal.DeserializeParticipantsUpdatedEventInternal(element); + var callParticipants = participantsUpdatedEventInternal.Participants?.Select(x => new CallParticipant(identifier: CommunicationIdentifierSerializer.Deserialize(x.Identifier), isMuted: x.IsMuted, participantId: x.ParticipantId)); - return new ParticipantsUpdatedEvent - { - CallLegId = participantsUpdatedEventInternal.CallLegId, - Participants = participantsUpdatedEventInternal.Participants?.Select(x => new CommunicationParticipant { Identifier = CommunicationIdentifierSerializer.Deserialize(x.Identifier), IsMuted = x.IsMuted, ParticipantId = x.ParticipantId }) - }; + return new ParticipantsUpdatedEvent(participantsUpdatedEventInternal.CallConnectionId, callParticipants); } - /// The call leg.id. - public string CallLegId { get; set; } + /// The call connection id. + public string CallConnectionId { get; } /// The list of participants. - public IEnumerable Participants { get; set; } + public IEnumerable Participants { get; } } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/PlayAudioResultEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/PlayAudioResultEvent.cs index 6521c7b799e58..c871bfab7f40f 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/PlayAudioResultEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/PlayAudioResultEvent.cs @@ -9,7 +9,7 @@ namespace Azure.Communication.CallingServer /// /// The play audio result event. /// - [CodeGenModel("PlayAudioResultEvent", Usage = new string[] { "input, output" }, Formats = new string[] { "json" })] + [CodeGenModel("PlayAudioResultEvent", Usage = new string[] { "output" }, Formats = new string[] { "json" })] public partial class PlayAudioResultEvent : CallingServerEventBase { /// diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ToneReceivedEvent.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ToneReceivedEvent.cs index cb209c5d8685f..49aafc51de0e3 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ToneReceivedEvent.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/Events/ToneReceivedEvent.cs @@ -9,7 +9,7 @@ namespace Azure.Communication.CallingServer /// /// The subscribe to tone event /// - [CodeGenModel("ToneReceivedEvent", Usage = new string[] { "model", "input, output" }, Formats = new string[] { "json" })] + [CodeGenModel("ToneReceivedEvent", Usage = new string[] { "model", "output" }, Formats = new string[] { "json" })] public partial class ToneReceivedEvent : CallingServerEventBase { /// diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallOptions.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallOptions.cs index 3f00f13f44205..f52bb95e70414 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallOptions.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallOptions.cs @@ -17,25 +17,25 @@ public class JoinCallOptions /// The callback URI. public Uri CallbackUri { get; } - /// The requested modalities. - public IList RequestedModalities { get; } + /// The requested media types. + public IList RequestedMediaTypes { get; } /// The requested call events to subscribe to. public IList RequestedCallEvents { get; } /// Initializes a new instance of JoinCallOptions. /// The callback URI. - /// The requested modalities. + /// The requested media types. /// The requested call events to subscribe to. - /// , , or is null. - public JoinCallOptions(Uri callbackUri, IEnumerable requestedModalities, IEnumerable requestedCallEvents) + /// , , or is null. + public JoinCallOptions(Uri callbackUri, IEnumerable requestedMediaTypes, IEnumerable requestedCallEvents) { Argument.AssertNotNull(callbackUri, nameof(callbackUri)); - Argument.AssertNotNull(requestedModalities, nameof(requestedModalities)); + Argument.AssertNotNull(requestedMediaTypes, nameof(requestedMediaTypes)); Argument.AssertNotNull(requestedCallEvents, nameof(requestedCallEvents)); CallbackUri = callbackUri; - RequestedModalities = requestedModalities.ToList(); + RequestedMediaTypes = requestedMediaTypes.ToList(); RequestedCallEvents = requestedCallEvents.ToList(); } } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallResultInternal.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallResultInternal.cs new file mode 100644 index 0000000000000..5a05ab52ef1a4 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/JoinCallResultInternal.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Communication.CallingServer +{ + [CodeGenModel("JoinCallResult")] + internal partial class JoinCallResultInternal + { + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneInfo.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneInfo.cs index aa712ecc98c76..ad05aec9e750e 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneInfo.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneInfo.cs @@ -8,7 +8,7 @@ namespace Azure.Communication.CallingServer /// /// The tone info /// - [CodeGenModel("ToneInfo", Usage = new[] { "input", "output" }, Formats = new[] { "json" })] + [CodeGenModel("ToneInfo", Usage = new[] { "output" }, Formats = new[] { "json" })] public partial class ToneInfo { } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneValue.cs b/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneValue.cs index dd8021414b353..665bd6758bdac 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneValue.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Models/ToneValue.cs @@ -8,7 +8,7 @@ namespace Azure.Communication.CallingServer /// /// The tone. /// - [CodeGenModel("ToneValue", Usage = new string[] { "input", "output" }, Formats = new string[] { "json" })] + [CodeGenModel("ToneValue", Usage = new string[] { "output" }, Formats = new string[] { "json" })] public readonly partial struct ToneValue { } diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Properties/AssemblyInfo.cs b/sdk/communication/Azure.Communication.CallingServer/src/Properties/AssemblyInfo.cs index 6522e17d75ccb..12a9c7421e7a2 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/Properties/AssemblyInfo.cs +++ b/sdk/communication/Azure.Communication.CallingServer/src/Properties/AssemblyInfo.cs @@ -4,3 +4,4 @@ using System.Runtime.CompilerServices; [assembly: Azure.Core.AzureResourceProviderNamespace("Communication")] +[assembly: InternalsVisibleTo("Azure.Communication.CallingServer.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/communication/Azure.Communication.CallingServer/src/ServerCall.cs b/sdk/communication/Azure.Communication.CallingServer/src/ServerCall.cs new file mode 100644 index 0000000000000..204d2015f9600 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/src/ServerCall.cs @@ -0,0 +1,455 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Communication.CallingServer +{ + /// + /// The Azure Communication Services Server Call Client. + /// + public class ServerCall + { + private readonly ClientDiagnostics _clientDiagnostics; + internal ServerCallsRestClient RestClient { get; } + + /// + /// The server call id. + /// + internal virtual string ServerCallId { get; set; } + + /// Initializes a new instance of . + internal ServerCall(string serverCallId, ServerCallsRestClient serverCallRestClient, ClientDiagnostics clientDiagnostics) + { + ServerCallId = serverCallId; + RestClient = serverCallRestClient; + _clientDiagnostics = clientDiagnostics; + } + + /// Initializes a new instance of for mocking. + protected ServerCall() + { + ServerCallId = null; + _clientDiagnostics = null; + RestClient = null; + } + + /// Play audio in the call. + /// The uri of the audio file. + /// Tne id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. + /// The operation context. + /// The cancellation token to use. + /// The server returned an error. See for details returned from the server. + public virtual async Task> PlayAudioAsync(Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(PlayAudio)}"); + scope.Start(); + try + { + // Currently looping media is not supported for out-call scenarios, thus setting it to false. + return await RestClient.PlayAudioAsync( + serverCallId: ServerCallId, + audioFileUri: audioFileUri?.AbsoluteUri, + loop: false, + audioFileId: audioFileId, + callbackUri: callbackUri?.AbsoluteUri, + operationContext: operationContext, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// Play audio in the call. + /// The uri of the audio file. + /// Tne id for the media in the AudioFileUri, using which we cache the media resource. + /// The callback Uri to receive PlayAudio status notifications. + /// The operation context. + /// The cancellation token to use. + /// The server returned an error. See for details returned from the server. + public virtual Response PlayAudio(Uri audioFileUri, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(PlayAudio)}"); + scope.Start(); + try + { + // Currently looping media is not supported for out-call scenarios, thus setting it to false. + return RestClient.PlayAudio( + serverCallId: ServerCallId, + audioFileUri: audioFileUri?.AbsoluteUri, + loop: false, + audioFileId: audioFileId, + callbackUri: callbackUri?.AbsoluteUri, + operationContext: operationContext, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Add participant to the call. + /// + /// The identity of participant to be added to the call. + /// The callback uri to receive the notification. + /// The phone number to use when adding a pstn participant. + /// The operation context. + /// The cancellation token. + public virtual Response AddParticipant(CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(AddParticipant)}"); + scope.Start(); + try + { + Argument.AssertNotNull(participant, nameof(participant)); + + return RestClient.AddParticipant( + serverCallId: ServerCallId, + participant: CommunicationIdentifierSerializer.Serialize(participant), + alternateCallerId: string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId), + callbackUri: callbackUri?.AbsoluteUri, + operationContext: operationContext, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Add participant to the call. + /// + /// The identity of participant to be added to the call. + /// + /// The phone number to use when adding a pstn participant. + /// The operation context. + /// The cancellation token. + public virtual async Task> AddParticipantAsync(CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(AddParticipant)}"); + scope.Start(); + try + { + Argument.AssertNotNull(participant, nameof(participant)); + + return await RestClient.AddParticipantAsync( + serverCallId: ServerCallId, + participant: CommunicationIdentifierSerializer.Serialize(participant), + alternateCallerId: string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId), + callbackUri: callbackUri?.AbsoluteUri, + operationContext: operationContext, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Remove participant from the call. + /// + /// The participant id. + /// The cancellation token. + public virtual Response RemoveParticipant(string participantId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(RemoveParticipant)}"); + scope.Start(); + try + { + return RestClient.RemoveParticipant( + serverCallId: ServerCallId, + participantId: participantId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Remove participant from the call. + /// + /// The participant id. + /// The cancellation token. + public virtual async Task RemoveParticipantAsync(string participantId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(RemoveParticipant)}"); + scope.Start(); + try + { + return await RestClient.RemoveParticipantAsync( + serverCallId: ServerCallId, + participantId: participantId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Start recording of the call. + /// + /// The uri to send state change callbacks. + /// The cancellation token. + public virtual async Task> StartRecordingAsync(Uri recordingStateCallbackUri, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(StartRecording)}"); + scope.Start(); + try + { + return await RestClient.StartRecordingAsync( + serverCallId: ServerCallId, + recordingStateCallbackUri: recordingStateCallbackUri.AbsoluteUri, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Start recording of the call. + /// + /// The uri to send state change callbacks. + /// The cancellation token. + public virtual Response StartRecording(Uri recordingStateCallbackUri, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(StartRecording)}"); + scope.Start(); + try + { + return RestClient.StartRecording( + serverCallId: ServerCallId, + recordingStateCallbackUri: recordingStateCallbackUri.AbsoluteUri, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Get the current recording state by recording id. + /// + /// The recording id to get the state of. + /// The cancellation token. + public virtual async Task> GetRecordingStateAsync(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(GetRecordingState)}"); + scope.Start(); + try + { + return await RestClient.GetRecordingPropertiesAsync( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Get the current recording state by recording id. + /// + /// The recording id to get the state of. + /// The cancellation token. + public virtual Response GetRecordingState(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(GetRecordingState)}"); + scope.Start(); + try + { + return RestClient.GetRecordingProperties( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Stop recording of the call. + /// + /// The recording id to stop. + /// The cancellation token. + public virtual async Task StopRecordingAsync(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(StopRecording)}"); + scope.Start(); + try + { + return await RestClient.StopRecordingAsync( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Stop recording of the call. + /// + /// The recording id to stop. + /// The cancellation token. + public virtual Response StopRecording(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(StopRecording)}"); + scope.Start(); + try + { + return RestClient.StopRecording( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Pause recording of the call. + /// + /// The recording id to pause. + /// The cancellation token. + public virtual async Task PauseRecordingAsync(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(PauseRecording)}"); + scope.Start(); + try + { + return await RestClient.PauseRecordingAsync( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Pause recording of the call. + /// + /// The recording id to pause. + /// The cancellation token. + public virtual Response PauseRecording(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(PauseRecording)}"); + scope.Start(); + try + { + return RestClient.PauseRecording( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// Resume recording of the call. + /// + /// The recording id to pause. + /// The cancellation token. + public virtual async Task ResumeRecordingAsync(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(ResumeRecording)}"); + scope.Start(); + try + { + return await RestClient.ResumeRecordingAsync( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + + /// + /// resume recording of the call. + /// + /// The recording id to resume. + /// The cancellation token. + public virtual Response ResumeRecording(string recordingId, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(ResumeRecording)}"); + scope.Start(); + try + { + return RestClient.ResumeRecording( + serverCallId: ServerCallId, + recordingId: recordingId, + cancellationToken: cancellationToken + ); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/src/autorest.md b/sdk/communication/Azure.Communication.CallingServer/src/autorest.md index 065b6602448ad..7f943bd1c6448 100644 --- a/sdk/communication/Azure.Communication.CallingServer/src/autorest.md +++ b/sdk/communication/Azure.Communication.CallingServer/src/autorest.md @@ -8,15 +8,12 @@ If any of the new objects needs to be overwritten, add the required changes to t 3. Repeat 2 and 3 until the desided interface is reflected in the apiview.dev. -## General settings -> see https://aka.ms/autorest - -## Configuration -The following are the settings for generating this API with AutoRest. +### AutoRest Configuration +> see https://aka.ms/autorest ```yaml -tag: beta -input-file: https://github.com/Azure/azure-rest-api-specs/raw/9550e58c98dc0af9474d896493335bf0543b2b4d/specification/communication/data-plane/CallingServer/preview/2021-04-15-preview1/communicationservicescallingserver.json +require: + - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/b4b5fa5ee23f8cce9e1ade4a82076b4c34b25651/specification/communication/data-plane/CallingServer/readme.md payload-flattening-threshold: 10 clear-output-folder: true directive: diff --git a/sdk/communication/Azure.Communication.CallingServer/tests.yml b/sdk/communication/Azure.Communication.CallingServer/tests.yml index 6ba1986eb50f3..7b673422c3543 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests.yml +++ b/sdk/communication/Azure.Communication.CallingServer/tests.yml @@ -18,4 +18,6 @@ extends: Clouds: Public,Int EnvVars: # SKIP_PHONENUMBER_LIVE_TESTS skips certain phone number tests such as purchase and release - SKIP_PHONENUMBER_LIVE_TESTS: TRUE \ No newline at end of file + SKIP_PHONENUMBER_LIVE_TESTS: TRUE + # SKIP_CALLINGSERVER_INTERACTION_LIVE_TESTS skips certain callingserver tests that required human interaction + SKIP_CALLINGSERVER_INTERACTION_LIVE_TESTS: TRUE \ No newline at end of file diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Azure.Communication.CallingServer.Tests.csproj b/sdk/communication/Azure.Communication.CallingServer/tests/Azure.Communication.CallingServer.Tests.csproj index 061c17322b762..52bdf1f75f45c 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/Azure.Communication.CallingServer.Tests.csproj +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Azure.Communication.CallingServer.Tests.csproj @@ -1,4 +1,4 @@ - + $(RequiredTargetFrameworks) enable @@ -14,12 +14,6 @@ - - - - - - diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionLiveTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionLiveTests.cs new file mode 100644 index 0000000000000..3141d7d52efd7 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionLiveTests.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#region Snippet:Azure_Communication_ServerCalling_Tests_UsingStatements +using System; +using System.Collections.Generic; +//@@ using Azure.Communication.CallingServer; +#endregion Snippet:Azure_Communication_ServerCalling_Tests_UsingStatements +using Azure.Communication.Identity; + +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.Communication.CallingServer.Tests +{ + /// + /// The suite of tests for the class. + /// + /// + /// These tests have a dependency on live Azure services and may incur costs for the associated + /// Azure subscription. + /// + public class CallConnectionLiveTests : CallingServerLiveTestBase + { + /// + /// Initializes a new instance of the class. + /// + /// A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods. + public CallConnectionLiveTests(bool isAsync) : base(isAsync) + { + } + + [Test] + public async Task RunCreatePlayCancelHangupScenarioTests() + { + if (SkipCallingServerInteractionLiveTests) + Assert.Ignore("Skip callingserver interaction live tests flag is on."); + + CallingServerClient client = CreateInstrumentedCallingServerClient(); + try + { + // Establish a Call + var callConnection = await CreateCallConnectionOperation(client).ConfigureAwait(false); + + // Play Prompt Audio + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await PlayAudioOperation(callConnection).ConfigureAwait(false); + + // Cancel Prompt Audio + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await CancelAllMediaOperationsOperation(callConnection).ConfigureAwait(false); + + // Hang up the Call, there is one call leg in this test case, hangup the call will also delete the call as the result. + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await HangupOperation(callConnection).ConfigureAwait(false); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task RunCreateAddRemoveHangupScenarioTests() + { + if (SkipCallingServerInteractionLiveTests) + Assert.Ignore("Skip callingserver interaction live tests flag is on."); + + CallingServerClient client = CreateInstrumentedCallingServerClient(); + try + { + // Establish a call + var callConnection = await CreateCallConnectionOperation(client).ConfigureAwait(false); + + // Add Participant + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + var participantId = await AddParticipantOperation(callConnection).ConfigureAwait(false); + + // Remove Participant + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await RemoveParticipantOperation(callConnection, participantId).ConfigureAwait(false); + + // Hang up the Call, there is one call leg in this test case, hangup the call will also delete the call as the result. + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await HangupOperation(callConnection).ConfigureAwait(false); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionTests.cs new file mode 100644 index 0000000000000..c4810d104ad48 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallConnection/CallConnectionTests.cs @@ -0,0 +1,379 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests +{ + public class CallConnectionTests : CallingServerTestBase + { + private const string CancelAllMediaOperaionsResponsePayload = "{" + + "\"operationId\": \"dummyId\"," + + "\"status\": \"completed\"," + + "\"operationContext\": \"dummyOperationContext\"," + + "\"resultInfo\": {" + + "\"code\": 200," + + "\"subcode\": 200," + + "\"message\": \"dummyMessage\"" + + "}" + + "}"; + + private const string PlayAudioResponsePayload = "{" + + "\"operationId\": \"dummyId\"," + + "\"status\": \"running\"," + + "\"operationContext\": \"dummyOperationContext\"," + + "\"resultInfo\": {" + + "\"code\": 200," + + "\"subcode\": 200," + + "\"message\": \"dummyMessage\"" + + "}" + + "}"; + + private const string AddParticipantResultPayload = "{" + + "\"participantId\": \"dummyparticipantid\"" + + "}"; + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public async Task HangupCallAsync_Passes(string callConnectionId) + { + var callConnection = CreateMockCallConnection(202, callConnectionId: callConnectionId); + + var response = await callConnection.HangupAsync().ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void HangupCall_Passes(string callConnectionId) + { + var callConnection = CreateMockCallConnection(202, callConnectionId: callConnectionId); + + var response = callConnection.Hangup(); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void HangupCallAsync_Failed(string callConnectionId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.HangupAsync().ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void HangupCall_Failed(string callConnectionId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.Throws(() => callConnection.Hangup()); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public async Task CancelAllMediaOperationsAsync_Passes(string callConnectionId) + { + var callConnection = CreateMockCallConnection(200, CancelAllMediaOperaionsResponsePayload, callConnectionId: callConnectionId); + + var result = await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false); + VerifyCancelAllMediaOperationsResult(result); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void CancelAllMediaOperations_Passes(string callConnectionId) + { + var callConnection = CreateMockCallConnection(200, CancelAllMediaOperaionsResponsePayload, callConnectionId: callConnectionId); + + var result = callConnection.CancelAllMediaOperations(); + VerifyCancelAllMediaOperationsResult(result); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void CancelAllMediaOperationsAsync_Failed(string callConnectionId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_CallConnectionId))] + public void CancelAllMediaOperations_Failed(string callConnectionId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.Throws(() => callConnection.CancelAllMediaOperations()); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public async Task PlayAudioAsync_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); + + var result = await callConnection.PlayAudioAsync(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext).ConfigureAwait(false); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudio_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); + + var result = callConnection.PlayAudio(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudioAsync_Failed(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.PlayAudioAsync(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudio_Failed(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.Throws(() => callConnection.PlayAudio(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public async Task PlayAudioAsyncOverload_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); + + var playAudio = new PlayAudioOptions() + { + AudioFileUri = sampleAudioFileUri, + AudioFileId = sampleAudioFileId, + CallbackUri = sampleCallbackUri, + Loop = false, + OperationContext = sampleOperationContext + }; + + var result = await callConnection.PlayAudioAsync(playAudio).ConfigureAwait(false); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudioOverload_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); + + var playAudio = new PlayAudioOptions() + { + AudioFileUri = sampleAudioFileUri, + AudioFileId = sampleAudioFileId, + CallbackUri = sampleCallbackUri, + Loop = false, + OperationContext = sampleOperationContext + }; + + var result = callConnection.PlayAudio(playAudio); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudioAsyncOverload_Failed(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(404); + + var playAudio = new PlayAudioOptions() + { + AudioFileUri = sampleAudioFileUri, + AudioFileId = sampleAudioFileId, + CallbackUri = sampleCallbackUri, + Loop = false, + OperationContext = sampleOperationContext + }; + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.PlayAudioAsync(playAudio).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudioOverload_Failed(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + var callConnection = CreateMockCallConnection(404); + + var playAudio = new PlayAudioOptions() + { + AudioFileUri = sampleAudioFileUri, + AudioFileId = sampleAudioFileId, + CallbackUri = sampleCallbackUri, + Loop = false, + OperationContext = sampleOperationContext + }; + + RequestFailedException? ex = Assert.Throws(() => callConnection.PlayAudio(playAudio)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public async Task AddParticipantsAsync_Passes(CommunicationIdentifier participant, string alternateCallerId, string operationContext) + { + var callConnection = CreateMockCallConnection(202, AddParticipantResultPayload); + + var response = await callConnection.AddParticipantAsync(participant, alternateCallerId, operationContext).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipants_Passes(CommunicationIdentifier participant, string alternateCallerId, string operationContext) + { + var callConnection = CreateMockCallConnection(202, AddParticipantResultPayload); + + var response = callConnection.AddParticipant(participant, alternateCallerId, operationContext); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipantsAsync_Failed(CommunicationIdentifier participant, string alternateCallerId, string operationContext) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.AddParticipantAsync(participant, alternateCallerId, operationContext).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipants_Failed(CommunicationIdentifier participant, string alternateCallerId, string operationContext) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.Throws(() => callConnection.AddParticipant(participant, alternateCallerId, operationContext)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public async Task RemoveParticipantsAsync_Passes(string callConnectionId, string participantId) + { + var callConnection = CreateMockCallConnection(202, callConnectionId: callConnectionId); + + var response = await callConnection.RemoveParticipantAsync(participantId).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipants_Passes(string callConnectionId, string participantId) + { + var callConnection = CreateMockCallConnection(202, callConnectionId: callConnectionId); + + var response = callConnection.RemoveParticipant(participantId); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipantsAsync_Failed(string callConnectionId, string participantId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callConnection.RemoveParticipantAsync(participantId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipants_Failed(string callConnectionId, string participantId) + { + var callConnection = CreateMockCallConnection(404); + + RequestFailedException? ex = Assert.Throws(() => callConnection.RemoveParticipant(participantId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + private void VerifyCancelAllMediaOperationsResult(CancelAllMediaOperationsResult result) + { + Assert.AreEqual("dummyId", result.OperationId); + Assert.AreEqual(OperationStatus.Completed, result.Status); + Assert.AreEqual("dummyOperationContext", result.OperationContext); + Assert.AreEqual(200, result.ResultInfo.Code); + Assert.AreEqual("dummyMessage", result.ResultInfo.Message); + } + + private void VerifyPlayAudioResult(PlayAudioResult result) + { + Assert.AreEqual("dummyId", result.OperationId); + Assert.AreEqual(OperationStatus.Running, result.Status); + Assert.AreEqual("dummyOperationContext", result.OperationContext); + Assert.AreEqual(200, result.ResultInfo.Code); + Assert.AreEqual("dummyMessage", result.ResultInfo.Message); + } + + private CallConnection CreateMockCallConnection(int responseCode, string? responseContent = null, string callConnectionId = "9ec7da16-30be-4e74-a941-285cfc4bffc5") + { + return CreateMockCallingServerClient(responseCode, responseContent).GetCallConnection(callConnectionId); + } + + private static IEnumerable TestData_CallConnectionId() + { + return new[] + { + new object?[] + { + "4ab31d78-a189-4e50-afaa-f9610975b6cb", + }, + }; + } + + private static IEnumerable TestData_PlayAudio() + { + return new[] + { + new object?[] + { + new Uri("https://bot.contoso.io/audio/sample-message.wav"), + "sampleAudioFileId", + new Uri("https://bot.contoso.io/callback"), + "sampleOperationContext", + } + }; + } + + private static IEnumerable TestData_AddParticipant() + { + return new[] + { + new object?[] + { + new CommunicationUserIdentifier("8:acs:acsuserid"), + "+14250000000", + "dummycontext" + }, + }; + } + + private static IEnumerable TestData_ParticipantId() + { + return new[] + { + new object?[] + { + "d09038e7-38f7-4aa1-9c5c-4bb07a65aa17", + "66c76529-3e58-45bf-9592-84eadd52bc81" + }, + }; + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientLiveTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientLiveTests.cs new file mode 100644 index 0000000000000..c8f63a6d782f9 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientLiveTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests +{ + /// + /// The suite of tests for the class. + /// + /// + /// These tests have a dependency on live Azure services and may incur costs for the associated + /// Azure subscription. + /// + public class CallingServerClientLiveTests : CallingServerLiveTestBase + { + /// + /// Initializes a new instance of the class. + /// + /// A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods. + public CallingServerClientLiveTests(bool isAsync) : base(isAsync) + { + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientTests.cs new file mode 100644 index 0000000000000..8e57a63958e54 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/CallingServerClientTests.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests +{ + public class CallingServerClientTests : CallingServerTestBase + { + [TestCaseSource(nameof(TestData_CreateCall))] + public async Task CreateCallAsync_Returns201Created(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions createCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(201, CreateOrJoinCallPayload); + + var response = await callingServerClient.CreateCallConnectionAsync(source, targets, createCallOptions).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Created, response.GetRawResponse().Status); + Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId); + } + + [TestCaseSource(nameof(TestData_CreateCall))] + public void CreateCall_Returns201Created(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions createCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(201, CreateOrJoinCallPayload); + + var response = callingServerClient.CreateCallConnection(source, targets, createCallOptions); + Assert.AreEqual((int)HttpStatusCode.Created, response.GetRawResponse().Status); + Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId); + } + + [TestCaseSource(nameof(TestData_CreateCall))] + public void CreateCallAsync_Returns404NotFound(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions createCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callingServerClient.CreateCallConnectionAsync(source, targets, createCallOptions).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_CreateCall))] + public void CreateCall_Returns404NotFound(CommunicationIdentifier source, IEnumerable targets, CreateCallOptions createCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(404); + + RequestFailedException? ex = Assert.Throws(() => callingServerClient.CreateCallConnection(source, targets, createCallOptions)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_JoinCall))] + public async Task JoinCallAsync_Returns202Accepted(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(202, CreateOrJoinCallPayload); + + var response = await callingServerClient.JoinCallAsync(serverCallId, source, joinCallOptions).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId); + } + + [TestCaseSource(nameof(TestData_JoinCall))] + public void JoinCall_Returns202Accepted(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(202, CreateOrJoinCallPayload); + + var response = callingServerClient.JoinCall(serverCallId, source, joinCallOptions); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId); + } + + [TestCaseSource(nameof(TestData_JoinCall))] + public void JoinCallAsync_Returns404NotFound(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await callingServerClient.JoinCallAsync(serverCallId, source, joinCallOptions).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_JoinCall))] + public void JoinCall_Returns404NotFound(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) + { + CallingServerClient callingServerClient = CreateMockCallingServerClient(404); + + RequestFailedException? ex = Assert.Throws(() => callingServerClient.JoinCall(serverCallId, source, joinCallOptions)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + private static IEnumerable TestData_CreateCall() + { + return new[] + { + new object?[] + { + new CommunicationUserIdentifier("8:acs:resource_source"), + new CommunicationIdentifier[] + { + new CommunicationUserIdentifier("8:acs:resource_target"), + new PhoneNumberIdentifier("+14255550123") + }, + new CreateCallOptions( + new Uri("https://bot.contoso.com/callback"), + new[] + { + MediaType.Video + }, + new[] + { + EventSubscriptionType.ParticipantsUpdated + } + ) + { + AlternateCallerId = new PhoneNumberIdentifier("+14255550123"), + Subject = "testsubject" + } + }, + }; + } + + private static IEnumerable TestData_JoinCall() + { + return new[] + { + new object?[] + { + "guid", + new CommunicationUserIdentifier("8:acs:resource_source"), + new JoinCallOptions( + new Uri("https://bot.contoso.com/callback"), + new[] + { + MediaType.Video + }, + new[] + { + EventSubscriptionType.ParticipantsUpdated + } + ) + { + Subject = "testsubject" + } + }, + }; + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ContentDownloadTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/ContentDownloadTests.cs similarity index 64% rename from sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ContentDownloadTests.cs rename to sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/ContentDownloadTests.cs index e757de9e4e382..0db43535cc607 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ContentDownloadTests.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClient/ContentDownloadTests.cs @@ -9,12 +9,11 @@ using NUnit.Framework; using System.Linq; using Azure.Core.Pipeline; -using Azure.Communication.CallingServer.Tests.ConversationClients; using Azure.Core.TestFramework; namespace Azure.Communication.CallingServer.Tests.ContentDownloadTests { - public class ContentDownloadTests : ConversationClientBaseTests + public class ContentDownloadTests : CallingServerTestBase { private const string DummyRecordingMetadata = "{" + "\"chunkDocumentId\": \"dummyDocId\"," + @@ -50,9 +49,9 @@ public class ContentDownloadTests : ConversationClientBaseTests [Test] public void DownloadMetadata_Test() { - ConversationClient _convClient = CreateMockConversationClient(200, DummyRecordingMetadata); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(200, DummyRecordingMetadata); - Stream metadata = _convClient.DownloadStreaming(_dummyMetadataLocation); + Stream metadata = _callingserverClient.DownloadStreaming(_dummyMetadataLocation); VerifyExpectedMetadata(metadata); } @@ -60,9 +59,9 @@ public void DownloadMetadata_Test() [Test] public async Task DownloadMetadataAsync_Test() { - ConversationClient _convClient = CreateMockConversationClient(200, DummyRecordingMetadata); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(200, DummyRecordingMetadata); - Stream metadata = await _convClient.DownloadStreamingAsync(_dummyMetadataLocation); + Stream metadata = await _callingserverClient.DownloadStreamingAsync(_dummyMetadataLocation); VerifyExpectedMetadata(metadata); } @@ -70,9 +69,9 @@ public async Task DownloadMetadataAsync_Test() [Test] public void DownloadRecording_Test() { - ConversationClient _convClient = CreateMockConversationClient(200, _dummyRecordingStream); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(200, _dummyRecordingStream); - Response recording = _convClient.DownloadStreaming(_dummyRecordingLocation); + Response recording = _callingserverClient.DownloadStreaming(_dummyRecordingLocation); VerifyExpectedRecording(recording, 10); } @@ -80,9 +79,9 @@ public void DownloadRecording_Test() [Test] public void DownloadRecordingByRanges_Test() { - ConversationClient _convClient = CreateMockConversationClient(206, _dummyRecordingStream.Take(5).ToArray(), _rangeResponseHeaders); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(206, _dummyRecordingStream.Take(5).ToArray(), _rangeResponseHeaders); - Response recording = _convClient.DownloadStreaming(_dummyRecordingLocation, new HttpRange(0, 4)); + Response recording = _callingserverClient.DownloadStreaming(_dummyRecordingLocation, new HttpRange(0, 4)); VerifyExpectedRecording(recording, 5); } @@ -90,9 +89,9 @@ public void DownloadRecordingByRanges_Test() [Test] public async Task DownloadRecordingAsync_Test() { - ConversationClient _convClient = CreateMockConversationClient(200, _dummyRecordingStream); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(200, _dummyRecordingStream); - Response recording = await _convClient.DownloadStreamingAsync(_dummyRecordingLocation); + Response recording = await _callingserverClient.DownloadStreamingAsync(_dummyRecordingLocation); VerifyExpectedRecording(recording, 10); } @@ -100,9 +99,9 @@ public async Task DownloadRecordingAsync_Test() [Test] public async Task DownloadRecordingByRangesAsync_Test() { - ConversationClient _convClient = CreateMockConversationClient(206, _dummyRecordingStream.Take(5).ToArray(), _rangeResponseHeaders); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(206, _dummyRecordingStream.Take(5).ToArray(), _rangeResponseHeaders); - Response recording = await _convClient.DownloadStreamingAsync(_dummyRecordingLocation, new HttpRange(0, 4)); + Response recording = await _callingserverClient.DownloadStreamingAsync(_dummyRecordingLocation, new HttpRange(0, 4)); VerifyExpectedRecording(recording, 5); } @@ -119,19 +118,50 @@ public void DownloadRecordingToStream_Test() ContentTransferOptions options = new(); options.InitialTransferSize = 10; - ConversationClient _convClient = CreateMockConversationClient(206, _dummyRecordingStream, rangeHeaderResponse); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(206, _dummyRecordingStream, rangeHeaderResponse); Stream destination = new MemoryStream(); - _convClient.DownloadTo(_dummyRecordingLocation, destination, options); + _callingserverClient.DownloadTo(_dummyRecordingLocation, destination, options); Assert.AreEqual(10, destination.Length); } + [Test] + public void DownloadRecordingToStream_ContentTransferOptions_Test() + { + ContentTransferOptions options = new() + { + InitialTransferSize = 10, + MaximumConcurrency = 1, + MaximumTransferSize = 5 + }; + + ContentTransferOptions options_copy = new() + { + InitialTransferSize = 10, + MaximumConcurrency = 1, + MaximumTransferSize = 5 + }; + + ContentTransferOptions options_updated = new() + { + InitialTransferSize = 11, + MaximumConcurrency = 1, + MaximumTransferSize = 5 + }; + + Assert.AreNotEqual(options.GetHashCode(), options_updated.GetHashCode()); + Assert.AreEqual(options.GetHashCode(), options_copy.GetHashCode()); + Assert.True(options.Equals(options_copy)); + Assert.True(options.Equals((object)options_copy)); + Assert.False(options.Equals(options_updated)); + } + [Test] public void DownloadNotExistentContent_Failure_Test() { - ConversationClient _convClient = CreateMockConversationClient(404); - RequestFailedException? ex = Assert.Throws(() => _convClient.DownloadStreaming(_dummyMetadataLocation)); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(404); + RequestFailedException? ex = Assert.Throws(() => _callingserverClient.DownloadStreaming(_dummyMetadataLocation)); Assert.NotNull(ex); Assert.AreEqual(ex?.Status, 404); } @@ -139,8 +169,8 @@ public void DownloadNotExistentContent_Failure_Test() [Test] public void DownloadNotExistentContentAsync_Failure_Test() { - ConversationClient _convClient = CreateMockConversationClient(404); - RequestFailedException? ex = Assert.ThrowsAsync(async () => await _convClient.DownloadStreamingAsync(_dummyMetadataLocation)); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(404); + RequestFailedException? ex = Assert.ThrowsAsync(async () => await _callingserverClient.DownloadStreamingAsync(_dummyMetadataLocation)); Assert.NotNull(ex); Assert.AreEqual(ex?.Status, 404); } @@ -148,8 +178,8 @@ public void DownloadNotExistentContentAsync_Failure_Test() [Test] public void AccessDenied_Failure_Test() { - ConversationClient _convClient = CreateMockConversationClient(401); - RequestFailedException? ex = Assert.Throws(() => _convClient.DownloadStreaming(_dummyMetadataLocation)); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(401); + RequestFailedException? ex = Assert.Throws(() => _callingserverClient.DownloadStreaming(_dummyMetadataLocation)); Assert.NotNull(ex); Assert.AreEqual(ex?.Status, 401); } @@ -157,8 +187,8 @@ public void AccessDenied_Failure_Test() [Test] public void AccessDeniedAsync_Failure_Test() { - ConversationClient _convClient = CreateMockConversationClient(401); - RequestFailedException? ex = Assert.ThrowsAsync(async () => await _convClient.DownloadStreamingAsync(_dummyMetadataLocation)); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(401); + RequestFailedException? ex = Assert.ThrowsAsync(async () => await _callingserverClient.DownloadStreamingAsync(_dummyMetadataLocation)); Assert.NotNull(ex); Assert.AreEqual(ex?.Status, 401); } @@ -183,9 +213,9 @@ public void ParallelDownloadWithInvalidRangeFirst() MaximumTransferSize = 5 }; - ConversationClient _convClient = CreateMockConversationClient(new MockResponse[] { invalidResponse, validResponse1, validResponse2 }); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(new MockResponse[] { invalidResponse, validResponse1, validResponse2 }); Stream destination = new MemoryStream(); - _convClient.DownloadTo(_dummyRecordingLocation, destination, options); + _callingserverClient.DownloadTo(_dummyRecordingLocation, destination, options); Assert.AreEqual(10, destination.Length); } @@ -210,9 +240,9 @@ public async Task ParallelDownloadWithInvalidRangeFirstAsync() MaximumTransferSize = 5 }; - ConversationClient _convClient = CreateMockConversationClient(new MockResponse[] { invalidResponse, validResponse1, validResponse2 }); + CallingServerClient _callingserverClient = CreateMockCallingServerClient(new MockResponse[] { invalidResponse, validResponse1, validResponse2 }); Stream destination = new MemoryStream(); - await _convClient.DownloadToAsync(_dummyRecordingLocation, destination, options); + await _callingserverClient.DownloadToAsync(_dummyRecordingLocation, destination, options); Assert.AreEqual(10, destination.Length); } diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientBaseTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientBaseTests.cs deleted file mode 100644 index 00970201d3a64..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientBaseTests.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Azure.Core; -using Azure.Core.TestFramework; - -namespace Azure.Communication.CallingServer.Tests.ConversationClients -{ - public class ConversationClientBaseTests - { - private const string dummyAccessKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9+eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ+SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV+adQssw5c="; - public ConversationClient CreateMockConversationClient(int statusCode, object? content = null, HttpHeader[]? httpHeaders = null) - { - var uri = new Uri("https://acs.dummyresource.com"); - var communicationTokenCredential = - new AzureKeyCredential(dummyAccessKey); - var mockResponse = new MockResponse(statusCode); - if (content != null) - { - if (content.GetType() == typeof(string)) - mockResponse.SetContent((string)content); - else if (content.GetType() == typeof(byte[])) - mockResponse.SetContent((byte[])content); - } - - if (httpHeaders != null) - { - for (int i = 0; i < httpHeaders.Length; i++) - { - mockResponse.AddHeader(httpHeaders[i]); - } - } - - var callClientOptions = new CallClientOptions - { - Transport = new MockTransport(mockResponse) - }; - - var convClient = new ConversationClient(uri, communicationTokenCredential, callClientOptions); - return convClient; - } - - public ConversationClient CreateMockConversationClient(MockResponse[] mockResponses) - { - var uri = new Uri("https://acs.dummyresource.com"); - var communicationTokenCredential = - new AzureKeyCredential(dummyAccessKey); - - var callClientOptions = new CallClientOptions - { - Transport = new MockTransport(mockResponses) - }; - - var convClient = new ConversationClient(uri, communicationTokenCredential, callClientOptions); - return convClient; - } - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientsTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientsTests.cs deleted file mode 100644 index 7e127e3e16ec4..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/ConversationClients/ConversationClientsTests.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Net; -using System.Threading.Tasks; -using Azure.Communication.CallingServer.Tests.ConversationClients; -using Azure.Core; -using Azure.Core.TestFramework; -using NUnit.Framework; - -namespace Azure.Communication.CallingServer.Tests -{ - public class ConversationClientsTests : ConversationClientBaseTests - { - private const string DummyStartRecordingResponse = "{" + - "\"recordingId\": \"dummyRecordingId\"" + - "}"; - private const string DummyRecordingStateResponse = "{" + - "\"recordingState\": \"active\"" + - "}"; - - private const string DummyPlayAudioResponse = "{" + - "\"id\": \"dummyId\"," + - "\"status\": \"running\"," + - "\"operationContext\": \"dummyOperationContext\"," + - "\"resultInfo\": {" + - "\"code\": 200," + - "\"subcode\": 200," + - "\"message\": \"dummyMessage\"" + - "}" + - "}"; - - [TestCaseSource(nameof(TestData_StartRecording))] - public void StartRecording_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri) - { - ConversationClient _convClient = CreateMockConversationClient(200, DummyStartRecordingResponse); - StartCallRecordingResponse response = _convClient.StartRecording(sampleConversationId, sampleCallBackUri); - Assert.AreEqual("dummyRecordingId", response.RecordingId); - } - - [TestCaseSource(nameof(TestData_StartRecording))] - public async Task StartRecordingAsync_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri) - { - ConversationClient _convClient = CreateMockConversationClient(200, DummyStartRecordingResponse); - Response response = await _convClient.StartRecordingAsync(sampleConversationId, sampleCallBackUri); - Assert.AreEqual("dummyRecordingId", response.Value.RecordingId); - } - - [TestCaseSource(nameof(TestData_StopRecording))] - public void StopRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = _convClient.StopRecording(sampleConversationId, sampleRecordingId); - var temp = response.Status; - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_StopRecording))] - public async Task StopRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = await _convClient.StopRecordingAsync(sampleConversationId, sampleRecordingId); - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_PauseRecording))] - public void PauseRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = _convClient.PauseRecording(sampleConversationId, sampleRecordingId); - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_PauseRecording))] - public async Task PauseRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = await _convClient.PauseRecordingAsync(sampleConversationId, sampleRecordingId); - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_ResumeRecording))] - public void ResumeRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = _convClient.ResumeRecording(sampleConversationId, sampleRecordingId); - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_ResumeRecording))] - public async Task ResumeRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200); - Response response = await _convClient.ResumeRecordingAsync(sampleConversationId, sampleRecordingId); - Assert.AreEqual((int)HttpStatusCode.OK, response.Status); - } - - [TestCaseSource(nameof(TestData_GetRecordingState))] - public void GetRecordingState_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200, DummyRecordingStateResponse); - GetCallRecordingStateResponse response = _convClient.GetRecordingState(sampleConversationId, sampleRecordingId); - Assert.AreEqual(CallRecordingState.Active, response.RecordingState); - } - - [TestCaseSource(nameof(TestData_GetRecordingState))] - public async Task GetRecordingStateAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) - { - ConversationClient _convClient = CreateMockConversationClient(200, DummyRecordingStateResponse); - Response response = await _convClient.GetRecordingStateAsync(sampleConversationId, sampleRecordingId); - Assert.AreEqual(CallRecordingState.Active, response.Value.RecordingState); - } - - [TestCaseSource(nameof(TestData_PlayAudio))] - public void PlayAudio_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) - { - ConversationClient _convClient = CreateMockConversationClient(202, DummyPlayAudioResponse); - PlayAudioResponse response = _convClient.PlayAudio(sampleConversationId, sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); - VerifyPlayAudioResponse(response); - } - - [TestCaseSource(nameof(TestData_PlayAudio))] - public async Task PlayAudioAsync_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) - { - ConversationClient _convClient = CreateMockConversationClient(202, DummyPlayAudioResponse); - Response response = await _convClient.PlayAudioAsync(sampleConversationId, sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); - VerifyPlayAudioResponse(response); - } - - private void VerifyPlayAudioResponse(PlayAudioResponse response) - { - Assert.AreEqual("dummyId", response.Id); - Assert.AreEqual(OperationStatus.Running, response.Status); - Assert.AreEqual("dummyOperationContext", response.OperationContext); - Assert.AreEqual(200, response.ResultInfo.Code); - Assert.AreEqual("dummyMessage", response.ResultInfo.Message); - } - - private static IEnumerable TestData_StartRecording() - { - return new List(){ - new object?[] { - "sampleConversationId", - new Uri("https://somecallbackurl"), - }, - }; - } - - private static IEnumerable TestData_StopRecording() - { - return new List(){ - new object?[] { - "sampleConversationId", - "sampleRecordingId", - }, - }; - } - - private static IEnumerable TestData_PauseRecording() - { - return new List(){ - new object?[] { - "sampleConversationId", - "sampleRecordingId", - }, - }; - } - - private static IEnumerable TestData_ResumeRecording() - { - return new List(){ - new object?[] { - "sampleConversationId", - "sampleRecordingId", - }, - }; - } - - private static IEnumerable TestData_GetRecordingState() - { - return new List(){ - new object?[] { - "sampleConversationId", - "sampleRecordingId", - }, - }; - } - - private static IEnumerable TestData_PlayAudio() - { - return new List(){ - new object?[] { - "sampleConversationId", - new Uri("https://av.ngrok.io/audio/sample-message.wav"), - "sampleAudioFileId", - new Uri("https://av.ngrok.io/someCallbackUri"), - "sampleOperationContext", - } - }; - } - - private static Expression> BuildExpression(Expression> expression) - => expression; - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Events/EventTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/Events/EventTests.cs new file mode 100644 index 0000000000000..9fc788a8afb2d --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Events/EventTests.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Linq; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests.Events +{ + public class EventTests : CallingServerTestBase + { + [Test] + public void CallRecordingStateChangeEventTest() + { + var json = "{\"recordingId\":\"id\",\"state\":\"active\",\"startDateTime\":\"2021-06-18T18:59:23.5718812-07:00\",\"serverCallId\":\"callServerId\"}"; + + var c = CallRecordingStateChangeEvent.Deserialize(json); + + Assert.AreEqual("id", c.RecordingId); + Assert.AreEqual(CallRecordingState.Active, c.State); + Assert.AreEqual("callServerId", c.ServerCallId); + Assert.AreEqual("2021-06-18", c.StartDateTime.ToString("yyyy-MM-dd")); + } + + [Test] + public void CallConnectionStateChangedEventTest() + { + var json = "{\"serverCallId\":\"serverCallId\",\"callConnectionId\":\"callConnectionId\",\"callConnectionState\":\"connected\"}"; + + var c = CallConnectionStateChangedEvent.Deserialize(json); + + Assert.AreEqual("serverCallId", c.ServerCallId); + Assert.AreEqual("callConnectionId", c.CallConnectionId); + Assert.AreEqual(CallConnectionState.Connected, c.CallConnectionState); + } + + [Test] + public void AddParticipantResultEventTest() + { + var json = "{\"resultInfo\":{\"code\":400,\"subcode\":415,\"message\":\"failure message\"},\"operationContext\":\"operatingContext\",\"status\":\"failed\"}"; + + var c = AddParticipantResultEvent.Deserialize(json); + + Assert.AreEqual("operatingContext", c.OperationContext); + Assert.AreEqual(OperationStatus.Failed, c.Status); + Assert.IsNotNull(c.ResultInfo); + Assert.AreEqual(400, c.ResultInfo.Code); + Assert.AreEqual(415, c.ResultInfo.Subcode); + Assert.AreEqual("failure message", c.ResultInfo.Message); + + json = "{\"operationContext\":\"operatingContext\",\"status\":\"running\"}"; + c = AddParticipantResultEvent.Deserialize(json); + + Assert.AreEqual("operatingContext", c.OperationContext); + Assert.AreEqual(OperationStatus.Running, c.Status); + Assert.IsNull(c.ResultInfo); + } + + [Test] + public void PlayAudioResultEventTest() + { + var json = "{\"resultInfo\":{\"code\":500,\"subcode\":505,\"message\":\"failure message\"},\"operationContext\":\"operatingContext\",\"status\":\"failed\"}"; + + var c = PlayAudioResultEvent.Deserialize(json); + + Assert.AreEqual("operatingContext", c.OperationContext); + Assert.AreEqual(OperationStatus.Failed, c.Status); + Assert.IsNotNull(c.ResultInfo); + Assert.AreEqual(500, c.ResultInfo.Code); + Assert.AreEqual(505, c.ResultInfo.Subcode); + Assert.AreEqual("failure message", c.ResultInfo.Message); + + json = "{\"operationContext\":\"operatingContext\",\"status\":\"completed\"}"; + c = PlayAudioResultEvent.Deserialize(json); + + Assert.AreEqual("operatingContext", c.OperationContext); + Assert.AreEqual(OperationStatus.Completed, c.Status); + Assert.IsNull(c.ResultInfo); + } + + [Test] + public void ToneReceivedEventTest() + { + var json = "{\"toneInfo\":{\"sequenceId\":1,\"tone\":\"A\"},\"callConnectionId\": \"8e6ff9fd-dd81-47f9-963a-1989bb95779c\"}"; + + var c = ToneReceivedEvent.Deserialize(json); + + Assert.AreEqual("8e6ff9fd-dd81-47f9-963a-1989bb95779c", c.CallConnectionId); + Assert.IsNotNull(c.ToneInfo); + Assert.AreEqual(1, c.ToneInfo.SequenceId); + Assert.AreEqual(ToneValue.A, c.ToneInfo.Tone); + } + + [Test] + [Ignore("Issue will fix later: A property 'phoneNumber' defined as non-nullable but received as null from the service.")] + public void ParticipantUpdatedEventTest() + { + var json = "{\"callConnectionId\":\"c0623fc9-f723-44e1-b18e-ec2da390fba0\",\"participants\":[{\"identifier\":{\"rawId\":\"8:acs:resource_guid1\",\"communicationUser\":{\"id\":\"8:acs:resource_guid1\"},\"phoneNumber\":null,\"microsoftTeamsUser\":null},\"participantId\":\"participant1\",\"isMuted\":false},{\"identifier\":{\"rawId\":\"8:acs:resource_guid2\",\"communicationUser\":null,\"phoneNumber\":{\"value\":\"\\u002B14250000000\"},\"microsoftTeamsUser\":null},\"participantId\":\"participant2\",\"isMuted\":true}]}"; + + var c = ParticipantsUpdatedEvent.Deserialize(json); + + Assert.AreEqual("c0623fc9-f723-44e1-b18e-ec2da390fba0", c.CallConnectionId); + Assert.IsNotNull(c.Participants); + Assert.AreEqual(2, c.Participants.Count()); + Assert.AreEqual("participant1", c.Participants.ElementAt(0).ParticipantId); + Assert.AreEqual(false, c.Participants.ElementAt(0).IsMuted); + Assert.AreEqual(new CommunicationUserIdentifier("8:acs:resource_guid1"), c.Participants.ElementAt(0).Identifier); + Assert.AreEqual("participant2", c.Participants.ElementAt(1).ParticipantId); + Assert.AreEqual(true, c.Participants.ElementAt(1).IsMuted); + Assert.AreEqual(new PhoneNumberIdentifier("+14250000000"), c.Participants.ElementAt(1).Identifier); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerLiveTestBase.cs b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerLiveTestBase.cs index ee6201103ceb5..40945c931f242 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerLiveTestBase.cs @@ -1,18 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Azure.Communication.Identity; using Azure.Core.TestFramework; +using NUnit.Framework; namespace Azure.Communication.CallingServer.Tests { public class CallingServerLiveTestBase : RecordedTestBase { + // Random Gen Guid + protected const string FROM_USER_IDENTIFIER = "e3560385-776f-41d1-bf04-07ef738f2f23"; + + // Random Gen Guid + protected const string TO_USER_IDENTIFIER = "e3560385-776f-41d1-bf04-07ef738f2fc1"; + + // From ACS Resource "immutableResourceId". + protected const string RESOURCE_IDENTIFIER = "016a7064-0581-40b9-be73-6dde64d69d72"; + + // Random Gen Guid + protected const string GROUP_IDENTIFIER = "3500789f-e11b-4ceb-85cb-bc8df2a01768"; + + protected string GetResourceId() + { + if (Mode == RecordedTestMode.Live) + { + return TestEnvironment.ResourceIdentifier; + } + return RESOURCE_IDENTIFIER; + } + + protected string GetRandomUserId() + { + return "8:acs:" + GetResourceId() + "_" + Guid.NewGuid().ToString(); + } + + protected string GetFixedUserId(string userGuid) + { + return "8:acs:" + GetResourceId() + "_" + userGuid; + } + + protected string GetFromUserId() + { + if (Mode == RecordedTestMode.Live) + { + return GetRandomUserId(); + } + return GetFixedUserId(FROM_USER_IDENTIFIER); + } + + protected string GetToUserId() + { + if (Mode == RecordedTestMode.Live) + { + return GetRandomUserId(); + } + return GetFixedUserId(TO_USER_IDENTIFIER); + } + + protected string GetGroupId() + { + /** + * If tests are running in live mode, we want them to all + * have unique groupId's so they do not conflict with other + * recording tests running in live mode. + */ + if (Mode == RecordedTestMode.Live) + { + return Guid.NewGuid().ToString(); + } + + /** + * For recording tests we need to make sure the groupId + * matches the recorded groupId, or the call will fail. + */ + return GROUP_IDENTIFIER; + } + public CallingServerLiveTestBase(bool isAsync) : base(isAsync) => Sanitizer = new CallingServerRecordedTestSanitizer(); + public bool SkipCallingServerInteractionLiveTests + => TestEnvironment.Mode == RecordedTestMode.Live && Environment.GetEnvironmentVariable("SKIP_CALLINGSERVER_INTERACTION_LIVE_TESTS") == "TRUE"; + /// /// Creates a with the connectionstring via environment /// variables and instruments it to make use of the Azure Core Test Framework functionalities. @@ -21,36 +95,308 @@ public CallingServerLiveTestBase(bool isAsync) : base(isAsync) protected CommunicationIdentityClient CreateInstrumentedCommunicationIdentityClient() => InstrumentClient( new CommunicationIdentityClient( - TestEnvironment.LiveTestDynamicConnectionString, + TestEnvironment.LiveTestStaticConnectionString, InstrumentClientOptions(new CommunicationIdentityClientOptions(CommunicationIdentityClientOptions.ServiceVersion.V2021_03_07)))); /// - /// Creates a + /// Creates a /// - /// The instrumented . - protected CallClient CreateInstrumentedCallingServerClient() + /// The instrumented . + protected CallingServerClient CreateInstrumentedCallingServerClient() { var connectionString = TestEnvironment.LiveTestStaticConnectionString; - CallClient client = new CallClient(connectionString, CreateServerCallingClientOptionsWithCorrelationVectorLogs()); + CallingServerClient callingServerClient = new CallingServerClient(connectionString, CreateServerCallingClientOptionsWithCorrelationVectorLogs()); #region Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient //@@var connectionString = ""; // Find your Communication Services resource in the Azure portal - //@@CallClient client = new CallClient(connectionString); + //@@CallingServerClient callingServerClient = new CallingServerClient(connectionString); #endregion Snippet:Azure_Communication_ServerCalling_Tests_Samples_CreateServerCallingClient - return InstrumentClient(client); + return InstrumentClient(callingServerClient); } - protected async Task SleepIfNotInPlaybackModeAsync() + + #region Api operation functions + #region Snippet:Azure_Communication_ServerCalling_Tests_CreateGroupCallOperation + internal async Task> CreateGroupCallOperation(CallingServerClient callingServerClient, string groupId, string from, string to, string callBackUri) + { + CallConnection? fromCallConnection = null; + CallConnection? toCallConnection = null; + + try + { + CommunicationIdentifier fromParticipant = new CommunicationUserIdentifier(from); + CommunicationIdentifier toParticipant = new CommunicationUserIdentifier(to); + + JoinCallOptions fromCallOptions = new JoinCallOptions( + new Uri(callBackUri), + new MediaType[] { MediaType.Audio }, + new EventSubscriptionType[] { EventSubscriptionType.ParticipantsUpdated }); + fromCallConnection = await callingServerClient.JoinCallAsync(groupId, fromParticipant, fromCallOptions).ConfigureAwait(false); + SleepInTest(1000); + Assert.IsFalse(string.IsNullOrWhiteSpace(fromCallConnection.CallConnectionId)); + + JoinCallOptions joinCallOptions = new JoinCallOptions( + new Uri(callBackUri), + new MediaType[] { MediaType.Audio }, + new EventSubscriptionType[] { EventSubscriptionType.ParticipantsUpdated}); + + toCallConnection = await callingServerClient.JoinCallAsync(groupId, toParticipant, joinCallOptions).ConfigureAwait(false); + SleepInTest(1000); + Assert.IsFalse(string.IsNullOrWhiteSpace(toCallConnection.CallConnectionId)); + + return new CallConnection[] { fromCallConnection, toCallConnection }; + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + throw; + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + + if (fromCallConnection != null) + { + await fromCallConnection.HangupAsync().ConfigureAwait(false); + } + + if (toCallConnection != null) + { + await toCallConnection.HangupAsync().ConfigureAwait(false); + } + throw; + } + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_CreateGroupCallOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_CreateCallConnectionOperation + internal async Task> CreateCallConnectionOperation(CallingServerClient client) + { + CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient(); + var source = await CreateUserAsync(communicationIdentityClient).ConfigureAwait(false); + + var targets = new[] { new PhoneNumberIdentifier(TestEnvironment.TargetPhoneNumber) }; + var createCallOption = new CreateCallOptions( + new Uri(TestEnvironment.AppCallbackUrl), + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); + createCallOption.AlternateCallerId = new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber); + + Console.WriteLine("Performing CreateCall operation"); + + var callConnection = await client.CreateCallConnectionAsync(source: source, targets: targets, options: createCallOption).ConfigureAwait(false); + + Console.WriteLine("Call initiated with Call connection id: {0}", callConnection.Value.CallConnectionId); + + Assert.IsFalse(string.IsNullOrWhiteSpace(callConnection.Value.CallConnectionId)); + return callConnection; + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_CreateCallConnectionOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_PlayAudioOperation + internal async Task PlayAudioOperation(CallConnection callConnection) + { + var playAudioOptions = new PlayAudioOptions() + { + AudioFileUri = new Uri(TestEnvironment.AudioFileUrl), + OperationContext = "de346f03-7f8d-41ab-a232-cc5e14990769", + Loop = false, + AudioFileId = "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" + }; + + Console.WriteLine("Performing PlayAudio operation"); + + var response = await callConnection.PlayAudioAsync(playAudioOptions).ConfigureAwait(false); + + Assert.AreEqual(response.Value.Status, OperationStatus.Running); + } + + internal async Task PlayAudioOperation(ServerCall serverCall) + { + Console.WriteLine("Performing PlayAudio operation"); + + var response = await serverCall.PlayAudioAsync( + audioFileUri: new Uri(TestEnvironment.AudioFileUrl), + audioFileId: "ebb1d98d-fd86-4204-800c-f7bdfc2e515c", + callbackUri: new Uri(TestEnvironment.AppCallbackUrl), + operationContext: "de346f03-7f8d-41ab-a232-cc5e14990769" + ).ConfigureAwait(false); + + Assert.AreEqual(response.Value.Status, OperationStatus.Running); + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_PlayAudioOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_HangupCallOperation + internal async Task HangupOperation(CallConnection callConnection) + { + Console.WriteLine("Performing Hangup operation"); + + var response = await callConnection.HangupAsync().ConfigureAwait(false); + + Assert.AreEqual(202, response.Status); + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_HangupCallOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_CancelMediaOperationsOperation + internal async Task CancelAllMediaOperationsOperation(CallConnection callConnection) + { + Console.WriteLine("Performing cancel media processing operation to stop playing audio"); + + var response = await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false); + + Assert.AreEqual(OperationStatus.Completed, response.Value.Status); + } + + internal async Task CancelAllMediaOperationsOperation(IEnumerable callConnections) + { + Console.WriteLine("Performing cancel media processing operation to stop playing audio"); + + if (callConnections == null) + { + return; + } + foreach (CallConnection callConnection in callConnections) + { + if (callConnection != null) + { + try + { + var response = await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false); + Assert.AreEqual(OperationStatus.Completed, response.Value.Status); + } + catch (Exception ex) + { + Console.WriteLine("Error hanging up: " + ex.Message); + } + } + } + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_CancelMediaOperationsOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_AddParticipantOperation + internal async Task AddParticipantOperation(CallConnection callConnection) + { + Console.WriteLine("Performing add participant operation to add a participant"); + + string invitedUser = GetFixedUserId("0000000a-b200-7a0d-570c-113a0d00288d"); + + var response = await callConnection.AddParticipantAsync(new CommunicationUserIdentifier(invitedUser)).ConfigureAwait(false); + + Assert.AreEqual(false, string.IsNullOrEmpty(response.Value.ParticipantId)); + + return response.Value.ParticipantId; + } + + internal async Task AddParticipantOperation(ServerCall serverCall) + { + Console.WriteLine("Performing add participant operation to add a participant"); + + string invitedUser = GetFixedUserId("0000000a-b200-7a0d-570c-113a0d00288d"); + + var response = await serverCall.AddParticipantAsync( + new CommunicationUserIdentifier(invitedUser), + callbackUri: new Uri(TestEnvironment.AppCallbackUrl) + ).ConfigureAwait(false); + + Assert.AreEqual(false, string.IsNullOrEmpty(response.Value.ParticipantId)); + + return response.Value.ParticipantId; + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_AddParticipantOperation + + #region Snippet:Azure_Communication_ServerCalling_Tests_RemoveParticipantOperation + internal async Task RemoveParticipantOperation(CallConnection callConnection, string participantId) + { + Console.WriteLine("Performing remove participant operation to remove a participant"); + + var response = await callConnection.RemoveParticipantAsync(participantId).ConfigureAwait(false); + + Assert.AreEqual(202, response.Status); + } + + internal async Task RemoveParticipantOperation(ServerCall serverCall, string participantId) + { + Console.WriteLine("Performing remove participant operation to remove a participant"); + + var response = await serverCall.RemoveParticipantAsync(participantId).ConfigureAwait(false); + + Assert.AreEqual(202, response.Status); + } + #endregion Snippet:Azure_Communication_ServerCalling_Tests_RemoveParticipantOperation + #endregion Api operation functions + + #region Support functions + private CommunicationUserIdentifier CreateUser(CommunicationIdentityClient communicationIdentityClient) + { + // reserve for living test, expect adding more content in the future. + return communicationIdentityClient.CreateUser(); + } + + private async Task CreateUserAsync(CommunicationIdentityClient communicationIdentityClient) + { + // reserve for living test, expect adding more content in the future. + return await communicationIdentityClient.CreateUserAsync(); + } + + protected async Task CleanUpConnectionsAsync(IEnumerable connections) + { + if (connections == null) + { + return; + } + foreach (CallConnection connection in connections) + { + if (connection != null) + { + try + { + await connection.HangupAsync().ConfigureAwait(false); + } + catch (Exception ex) + { + Console.WriteLine("Error hanging up: " + ex.Message); + } + } + } + } + + protected async Task SleepIfNotInPlaybackModeAsync(int milliSeconds = 10000) { if (TestEnvironment.Mode != RecordedTestMode.Playback) await Task.Delay(10000); } - private CallClientOptions CreateServerCallingClientOptionsWithCorrelationVectorLogs() + protected void SleepInTest(int milliSeconds) + { + if (Mode == RecordedTestMode.Playback) + return; + Thread.Sleep(milliSeconds); + } + + protected async Task ValidateCallRecordingStateAsync(ServerCall serverCall, + string recordingId, + CallRecordingState expectedCallRecordingState) + { + Assert.NotNull(serverCall); + Assert.NotNull(recordingId); + + // There is a delay between the action and when the state is available. + // Waiting to make sure we get the updated state, when we are running + // against a live service. + SleepInTest(6000); + + CallRecordingProperties callRecordingProperties = await serverCall.GetRecordingStateAsync(recordingId).ConfigureAwait(false); + Assert.NotNull(callRecordingProperties); + Assert.AreEqual(callRecordingProperties.RecordingState, expectedCallRecordingState); + } + + private CallingServerClientOptions CreateServerCallingClientOptionsWithCorrelationVectorLogs() { - CallClientOptions callClientOptions = new CallClientOptions(); + CallingServerClientOptions callClientOptions = new CallingServerClientOptions(); callClientOptions.Diagnostics.LoggedHeaderNames.Add("MS-CV"); return InstrumentClientOptions(callClientOptions); } + #endregion Support functions } } diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestBase.cs b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestBase.cs new file mode 100644 index 0000000000000..ae899c237e408 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestBase.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; + +namespace Azure.Communication.CallingServer.Tests +{ + public class CallingServerTestBase + { + protected const string connectionString = "endpoint=https://contoso.azure.com/;accesskey=ZHVtbXlhY2Nlc3NrZXk="; + + protected const string CreateOrJoinCallPayload = "{" + + "\"callConnectionId\": \"cad9df7b-f3ac-4c53-96f7-c76e7437b3c1\"" + + "}"; + + internal CallingServerClient CreateMockCallingServerClient(int responseCode, object? responseContent = null, HttpHeader[]? httpHeaders = null) + { + var mockResponse = new MockResponse(responseCode); + + if (responseContent != null) + { + if (responseContent is string responseContentString) + { + mockResponse.SetContent(responseContentString); + } + else if (responseContent is byte[] responseContentObjectArr) + { + mockResponse.SetContent(responseContentObjectArr); + } + } + + if (httpHeaders != null) + { + for (int i = 0; i < httpHeaders.Length; i++) + { + mockResponse.AddHeader(httpHeaders[i]); + } + } + + var callingServerClientOptions = new CallingServerClientOptions + { + Transport = new MockTransport(mockResponse) + }; + + return new CallingServerClient(connectionString, callingServerClientOptions); + } + + internal CallingServerClient CreateMockCallingServerClient(params MockResponse[] mockResponses) + { + var callingServerClientOptions = new CallingServerClientOptions + { + Transport = new MockTransport(mockResponses) + }; + + return new CallingServerClient(connectionString, callingServerClientOptions); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestEnvironment.cs b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestEnvironment.cs index fe5f295689187..7a24cbf54bd59 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestEnvironment.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallingServerTestEnvironment.cs @@ -12,16 +12,25 @@ namespace Azure.Communication.CallingServer.Tests /// public class CallingServerTestEnvironment : CommunicationTestEnvironment { + public const string AlternateCallerId = "ALTERNATE_CALLERID"; + + public const string ResourceId = "COMMUNICATION_LIVETEST_STATIC_RESOURCE_IDENTIFIER"; + /// - /// The phone number associated with the source. + /// The phone number required to make a pstn call. /// - public string SourcePhoneNumber => GetRecordedVariable(AzurePhoneNumber, options => options.IsSecret()); + public string SourcePhoneNumber => GetRecordedVariable(AlternateCallerId, options => options.IsSecret()); /// /// The phone number associated with the source. /// public string TargetPhoneNumber => GetRecordedVariable(AzurePhoneNumber, options => options.IsSecret()); + /// + /// The resource identifier associated with the Azure Communication Service. + /// + public string ResourceIdentifier => GetRecordedVariable(ResourceId, options => options.IsSecret()); + /// /// The audio file name of the play prompt. /// diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallLiveTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallLiveTests.cs new file mode 100644 index 0000000000000..a704c082f8ad5 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallLiveTests.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests +{ + /// + /// The suite of tests for the class. + /// + /// + /// These tests have a dependency on live Azure services and may incur costs for the associated + /// Azure subscription. + /// + public class ServerCallLiveTests : CallingServerLiveTestBase + { + /// + /// Initializes a new instance of the class. + /// + /// A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods. + public ServerCallLiveTests(bool isAsync) : base(isAsync) + { + } + + [Test] + public async Task RunAllRecordingFunctionsScenarioTests() + { + CallingServerClient callingServerClient = CreateInstrumentedCallingServerClient(); + var groupId = GetGroupId(); + try + { + // Establish a Call + var callConnections = await CreateGroupCallOperation(callingServerClient, groupId, GetFromUserId(), GetToUserId(), TestEnvironment.AppCallbackUrl).ConfigureAwait(false); + var serverCall = callingServerClient.InitializeServerCall(groupId); + + // Start Recording + StartCallRecordingResult startCallRecordingResult = await serverCall.StartRecordingAsync(new Uri(TestEnvironment.AppCallbackUrl)).ConfigureAwait(false); + var recordingId = startCallRecordingResult.RecordingId; + await ValidateCallRecordingStateAsync(serverCall, recordingId, CallRecordingState.Active).ConfigureAwait(false); + + // Pause Recording + await serverCall.PauseRecordingAsync(recordingId).ConfigureAwait(false); + await ValidateCallRecordingStateAsync(serverCall, recordingId, CallRecordingState.Inactive).ConfigureAwait(false); + + // Resume Recording + await serverCall.ResumeRecordingAsync(recordingId).ConfigureAwait(false); + await ValidateCallRecordingStateAsync(serverCall, recordingId, CallRecordingState.Active).ConfigureAwait(false); + + // Stop Recording + await serverCall.StopRecordingAsync(recordingId).ConfigureAwait(false); + + // Get Recording StateAsync + Assert.ThrowsAsync(async () => await serverCall.GetRecordingStateAsync(recordingId).ConfigureAwait(false)); + + // Hang up the Call, there is one call leg in this test case, hangup the call will also delete the call as the result. + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await CleanUpConnectionsAsync(callConnections).ConfigureAwait(false); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task RunCreatePlayCancelHangupScenarioTests() + { + CallingServerClient callingServerClient = CreateInstrumentedCallingServerClient(); + var groupId = GetGroupId(); + try + { + // Establish a Call + var callConnections = await CreateGroupCallOperation(callingServerClient, groupId, GetFromUserId(), GetToUserId(), TestEnvironment.AppCallbackUrl).ConfigureAwait(false); + var serverCall = callingServerClient.InitializeServerCall(groupId); + + // Play Prompt Audio + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await PlayAudioOperation(serverCall).ConfigureAwait(false); + + // Cancel Prompt Audio + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await CancelAllMediaOperationsOperation(callConnections).ConfigureAwait(false); + + // Hang up the Call, there is one call leg in this test case, hangup the call will also delete the call as the result. + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await CleanUpConnectionsAsync(callConnections).ConfigureAwait(false); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + + [Test] + public async Task RunCreateAddRemoveHangupScenarioTests() + { + if (SkipCallingServerInteractionLiveTests) + Assert.Ignore("Skip callingserver interaction live tests flag is on."); + + CallingServerClient callingServerClient = CreateInstrumentedCallingServerClient(); + var groupId = GetGroupId(); + try + { + // Establish a Call + var callConnections = await CreateGroupCallOperation(callingServerClient, groupId, GetFromUserId(), GetToUserId(), TestEnvironment.AppCallbackUrl).ConfigureAwait(false); + var serverCall = callingServerClient.InitializeServerCall(groupId); + + // Add Participant + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + var participantId = await AddParticipantOperation(serverCall).ConfigureAwait(false); + + // Remove Participant + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await RemoveParticipantOperation(serverCall, participantId).ConfigureAwait(false); + + // Hang up the Call, there is one call leg in this test case, hangup the call will also delete the call as the result. + await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); + await CleanUpConnectionsAsync(callConnections).ConfigureAwait(false); + } + catch (RequestFailedException ex) + { + Console.WriteLine(ex.Message); + Assert.Fail($"Unexpected error: {ex}"); + } + catch (Exception ex) + { + Assert.Fail($"Unexpected error: {ex}"); + } + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallTests.cs new file mode 100644 index 0000000000000..090693c64f56a --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCall/ServerCallTests.cs @@ -0,0 +1,450 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Azure.Communication.CallingServer.Tests +{ + public class ServerCallTests : CallingServerTestBase + { + private const string DummyStartRecordingResponse = "{" + + "\"recordingId\": \"dummyRecordingId\"" + + "}"; + private const string DummyRecordingStateResponse = "{" + + "\"recordingState\": \"active\"" + + "}"; + + private const string DummyPlayAudioResponse = "{" + + "\"operationId\": \"dummyId\"," + + "\"status\": \"running\"," + + "\"operationContext\": \"dummyOperationContext\"," + + "\"resultInfo\": {" + + "\"code\": 200," + + "\"subcode\": 200," + + "\"message\": \"dummyMessage\"" + + "}" + + "}"; + + private const string AddParticipantResultPayload = "{" + + "\"participantId\": \"dummyparticipantid\"" + + "}"; + + [TestCaseSource(nameof(TestData_StartRecording))] + public async Task StartRecordingAsync_Returns200Ok(Uri sampleCallBackUri) + { + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyStartRecordingResponse); + + Response result = await serverCall.StartRecordingAsync(sampleCallBackUri); + Assert.AreEqual("dummyRecordingId", result.Value.RecordingId); + } + + [TestCaseSource(nameof(TestData_StartRecording))] + public void StartRecording_Returns200Ok(Uri sampleCallBackUri) + { + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyStartRecordingResponse); + + StartCallRecordingResult result = serverCall.StartRecording(sampleCallBackUri); + Assert.AreEqual("dummyRecordingId", result.RecordingId); + } + + [TestCaseSource(nameof(TestData_StartRecording))] + public void StartRecordingAsync_Returns404NotFound(Uri sampleCallBackUri) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.StartRecordingAsync(sampleCallBackUri).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_StartRecording))] + public void StartRecording_Returns404NotFound(Uri sampleCallBackUri) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.StartRecording(sampleCallBackUri)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_StopRecording))] + public async Task StopRecordingAsync_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = await serverCall.StopRecordingAsync(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_StopRecording))] + public void StopRecording_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = serverCall.StopRecording(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_StopRecording))] + public void StopRecordingAsync_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.StopRecordingAsync(sampleRecordingId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_StopRecording))] + public void StopRecording_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.StopRecording(sampleRecordingId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PauseRecording))] + public async Task PauseRecordingAsync_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = await serverCall.PauseRecordingAsync(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_PauseRecording))] + public void PauseRecording_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = serverCall.PauseRecording(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_PauseRecording))] + public void PauseRecordingAsync_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.PauseRecordingAsync(sampleRecordingId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PauseRecording))] + public void PauseRecording_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.PauseRecording(sampleRecordingId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ResumeRecording))] + public async Task ResumeRecordingAsync_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = await serverCall.ResumeRecordingAsync(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_ResumeRecording))] + public void ResumeRecording_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200); + + Response response = serverCall.ResumeRecording(sampleRecordingId); + Assert.AreEqual((int)HttpStatusCode.OK, response.Status); + } + + [TestCaseSource(nameof(TestData_ResumeRecording))] + public void ResumeRecordingAsync_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.ResumeRecordingAsync(sampleRecordingId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ResumeRecording))] + public void ResumeRecording_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.ResumeRecording(sampleRecordingId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_GetRecordingState))] + public async Task GetRecordingStateAsync_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyRecordingStateResponse); + + Response result = await serverCall.GetRecordingStateAsync(sampleRecordingId); + Assert.AreEqual(CallRecordingState.Active, result.Value.RecordingState); + } + + [TestCaseSource(nameof(TestData_GetRecordingState))] + public void GetRecordingState_Return200Ok(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyRecordingStateResponse); + + CallRecordingProperties result = serverCall.GetRecordingState(sampleRecordingId); + Assert.AreEqual(CallRecordingState.Active, result.RecordingState); + } + + [TestCaseSource(nameof(TestData_GetRecordingState))] + public void GetRecordingStateAsync_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.GetRecordingStateAsync(sampleRecordingId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_GetRecordingState))] + public void GetRecordingState_Returns404NotFound(string sampleRecordingId) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.GetRecordingState(sampleRecordingId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public async Task PlayAudioAsync_Return202Accepted(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + ServerCall serverCall = CreateMockServerCall(202, responseContent: DummyPlayAudioResponse); + + Response result = await serverCall.PlayAudioAsync(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudio_Return202Accepted(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + ServerCall serverCall = CreateMockServerCall(202, responseContent: DummyPlayAudioResponse); + + PlayAudioResult result = serverCall.PlayAudio(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + VerifyPlayAudioResult(result); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudioAsync_Returns404NotFound(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.PlayAudioAsync(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_PlayAudio))] + public void PlayAudio_Returns404NotFound(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + { + ServerCall serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.PlayAudio(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public async Task AddParticipantsAsync_Return202Accepted(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + { + var serverCall = CreateMockServerCall(202, AddParticipantResultPayload); + + var response = await serverCall.AddParticipantAsync(participant, callBack, alternateCallerId, operationContext).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipants_Return202Accepted(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + { + var serverCall = CreateMockServerCall(202, AddParticipantResultPayload); + + var response = serverCall.AddParticipant(participant, callBack, alternateCallerId, operationContext); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status); + Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipantsAsync_Returns404NotFound(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + { + var serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.AddParticipantAsync(participant, callBack, alternateCallerId, operationContext).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_AddParticipant))] + public void AddParticipants_Returns404NotFound(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + { + var serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.AddParticipant(participant, callBack, alternateCallerId, operationContext)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public async Task RemoveParticipantsAsync_Return202Accepted(string participantId) + { + var serverCall = CreateMockServerCall(202); + + var response = await serverCall.RemoveParticipantAsync(participantId).ConfigureAwait(false); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipants_Return202Accepted(string participantId) + { + var serverCall = CreateMockServerCall(202); + + var response = serverCall.RemoveParticipant(participantId); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipantsAsync_Returns404NotFound(string participantId) + { + var serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.ThrowsAsync(async () => await serverCall.RemoveParticipantAsync(participantId).ConfigureAwait(false)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + [TestCaseSource(nameof(TestData_ParticipantId))] + public void RemoveParticipants_Returns404NotFound(string participantId) + { + var serverCall = CreateMockServerCall(404); + + RequestFailedException? ex = Assert.Throws(() => serverCall.RemoveParticipant(participantId)); + Assert.NotNull(ex); + Assert.AreEqual(ex?.Status, 404); + } + + private void VerifyPlayAudioResult(PlayAudioResult response) + { + Assert.AreEqual("dummyId", response.OperationId); + Assert.AreEqual(OperationStatus.Running, response.Status); + Assert.AreEqual("dummyOperationContext", response.OperationContext); + Assert.AreEqual(200, response.ResultInfo.Code); + Assert.AreEqual("dummyMessage", response.ResultInfo.Message); + } + + private static IEnumerable TestData_StartRecording() + { + return new[] + { + new object?[] + { + new Uri("https://somecallbackurl"), + }, + }; + } + + private static IEnumerable TestData_StopRecording() + { + return new[] + { + new object?[] + { + "sampleRecordingId", + }, + }; + } + + private static IEnumerable TestData_PauseRecording() + { + return new[] + { + new object?[] + { + "sampleRecordingId", + }, + }; + } + + private static IEnumerable TestData_ResumeRecording() + { + return new[] + { + new object?[] + { + "sampleRecordingId", + }, + }; + } + + private static IEnumerable TestData_GetRecordingState() + { + return new[] + { + new object?[] + { + "sampleRecordingId", + }, + }; + } + + private static IEnumerable TestData_PlayAudio() + { + return new[] + { + new object?[] + { + new Uri("https://av.ngrok.io/audio/sample-message.wav"), + "sampleAudioFileId", + new Uri("https://av.ngrok.io/someCallbackUri"), + "sampleOperationContext", + } + }; + } + + private static IEnumerable TestData_AddParticipant() + { + return new[] + { + new object?[] + { + new CommunicationUserIdentifier("8:acs:acsuserid"), + new Uri("https://bot.contoso.com/callback"), + "+14250000000", + "dummycontext" + }, + }; + } + + private static IEnumerable TestData_ParticipantId() + { + return new[] + { + new object?[] + { + "66c76529-3e58-45bf-9592-84eadd52bc81" + }, + }; + } + + private ServerCall CreateMockServerCall(int responseCode, string? responseContent = null, string serverCallId = "sampleServerCallId") + { + return CreateMockCallingServerClient(responseCode, responseContent).InitializeServerCall(serverCallId); + } + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsLiveTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsLiveTests.cs deleted file mode 100644 index 7d411cb0844f0..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsLiveTests.cs +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#region Snippet:Azure_Communication_ServerCalling_Tests_UsingStatements -using System; -using System.Collections.Generic; -//@@ using Azure.Communication.CallingServer; -#endregion Snippet:Azure_Communication_ServerCalling_Tests_UsingStatements -using Azure.Communication.Identity; - -using Azure.Core.TestFramework; -using NUnit.Framework; -using System.Threading.Tasks; - -namespace Azure.Communication.CallingServer.Tests -{ - /// - /// The suite of tests for the class. - /// - /// - /// These tests have a dependency on live Azure services and may incur costs for the associated - /// Azure subscription. - /// - public class CallingServerClientsLiveTests : CallingServerLiveTestBase - { - /// - /// Initializes a new instance of the class. - /// - /// A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods. - public CallingServerClientsLiveTests(bool isAsync) : base(isAsync) - { - } - - [Test] - public async Task CreateCallTest() - { - CallClient client = CreateInstrumentedCallingServerClient(); - try - { - await CreateCallOperation(client).ConfigureAwait(false); - } - catch (RequestFailedException ex) - { - Console.WriteLine(ex.Message); - Assert.Fail($"Unexpected error: {ex}"); - } - catch (Exception ex) - { - Assert.Fail($"Unexpected error: {ex}"); - } - } - - [Test] - public async Task DeteleCallTest() - { - CallClient client = CreateInstrumentedCallingServerClient(); - try - { - var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); - var callLegId = createCallResponse.Value.CallLegId; - - await DeteleCallOperation(client, callLegId).ConfigureAwait(false); - } - catch (RequestFailedException ex) - { - Console.WriteLine(ex.Message); - Assert.Fail($"Unexpected error: {ex}"); - } - catch (Exception ex) - { - Assert.Fail($"Unexpected error: {ex}"); - } - } - - [Test] - public async Task PlayAudioTest() - { - CallClient client = CreateInstrumentedCallingServerClient(); - try - { - var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); - var callLegId = createCallResponse.Value.CallLegId; - - await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); - await PlayAudioOperation(client, callLegId).ConfigureAwait(false); - - await DeteleCallOperation(client, callLegId).ConfigureAwait(false); - } - catch (RequestFailedException ex) - { - Console.WriteLine(ex.Message); - Assert.Fail($"Unexpected error: {ex}"); - } - catch (Exception ex) - { - Assert.Fail($"Unexpected error: {ex}"); - } - } - - [Test] - public async Task HangupCallTest() - { - CallClient client = CreateInstrumentedCallingServerClient(); - try - { - var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); - var callLegId = createCallResponse.Value.CallLegId; - - // There is one call leg in this test case, hangup the call will also delete the call as the result. - await HangupOperation(client, callLegId).ConfigureAwait(false); - } - catch (RequestFailedException ex) - { - Console.WriteLine(ex.Message); - Assert.Fail($"Unexpected error: {ex}"); - } - catch (Exception ex) - { - Assert.Fail($"Unexpected error: {ex}"); - } - } - - [Test] - public async Task CancelAllMediaOperationsTest() - { - CallClient client = CreateInstrumentedCallingServerClient(); - try - { - var createCallResponse = await CreateCallOperation(client).ConfigureAwait(false); - var callLegId = createCallResponse.Value.CallLegId; - - await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); - await PlayAudioOperation(client, callLegId).ConfigureAwait(false); - - await SleepIfNotInPlaybackModeAsync().ConfigureAwait(false); - await CancelAllMediaOperationsOperation(client, callLegId).ConfigureAwait(false); - - await DeteleCallOperation(client, callLegId).ConfigureAwait(false); - } - catch (RequestFailedException ex) - { - Console.WriteLine(ex.Message); - Assert.Fail($"Unexpected error: {ex}"); - } - catch (Exception ex) - { - Assert.Fail($"Unexpected error: {ex}"); - } - } - - #region Support functions - #region Snippet:Azure_Communication_ServerCalling_Tests_CreateCallOperation - private async Task> CreateCallOperation(CallClient client) - { - CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient(); - var source = await CreateUserAsync(communicationIdentityClient).ConfigureAwait(false); - - var targets = new List() { new PhoneNumberIdentifier(TestEnvironment.TargetPhoneNumber) }; - var createCallOption = new CreateCallOptions( - new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); - createCallOption.AlternateCallerId = new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber); - - Console.WriteLine("Performing CreateCall operation"); - - var createCallResponse = await client.CreateCallAsync(source: source, targets: targets, options: createCallOption).ConfigureAwait(false); - - Console.WriteLine("Call initiated with Call Leg id: {0}", createCallResponse.Value.CallLegId); - - Assert.IsFalse(string.IsNullOrWhiteSpace(createCallResponse.Value.CallLegId)); - return createCallResponse; - } - #endregion Snippet:Azure_Communication_ServerCalling_Tests_CreateCallOperation - - #region Snippet:Azure_Communication_ServerCalling_Tests_DeteleCallOperation - private async Task DeteleCallOperation(CallClient client, string callLegId) - { - var response = await client.DeleteCallAsync(callLegId: callLegId).ConfigureAwait(false); - - Console.WriteLine("Delete Call with Call Leg id: {0}", callLegId); - - Assert.AreEqual(202, response.Status); - Assert.IsFalse(string.IsNullOrWhiteSpace(response.ClientRequestId)); - } - #endregion Snippet:Azure_Communication_ServerCalling_Tests_DeteleCallOperation - - #region Snippet:Azure_Communication_ServerCalling_Tests_PlayAudioOperation - private async Task PlayAudioOperation(CallClient client, string callLegId) - { - var playAudioOptions = new PlayAudioOptions() - { - AudioFileUri = new Uri(TestEnvironment.AudioFileUrl), - OperationContext = "de346f03-7f8d-41ab-a232-cc5e14990769", - Loop = true, - AudioFileId = "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" - }; - - Console.WriteLine("Performing PlayAudio operation"); - - var response = await client.PlayAudioAsync(callLegId, playAudioOptions).ConfigureAwait(false); - - Assert.AreEqual(response.Value.Status, OperationStatus.Running); - } - #endregion Snippet:Azure_Communication_ServerCalling_Tests_PlayAudioOperation - - #region Snippet:Azure_Communication_ServerCalling_Tests_HangupCallOperation - private async Task HangupOperation(CallClient client, string callLegId) - { - Console.WriteLine("Performing Hangup operation"); - - var response = await client.HangupCallAsync(callLegId).ConfigureAwait(false); - - Assert.AreEqual(202, response.Status); - } - #endregion Snippet:Azure_Communication_ServerCalling_Tests_HangupCallOperation - - #region Snippet:Azure_Communication_ServerCalling_Tests_CancelMediaOperationsOperation - private async Task CancelAllMediaOperationsOperation(CallClient client, string callLegId) - { - Console.WriteLine("Performing cancel media processing operation to stop playing audio"); - - var response = await client.CancelAllMediaOperationsAsync(callLegId).ConfigureAwait(false); - - Assert.AreEqual(OperationStatus.Completed, response.Value.Status); - } - #endregion Snippet:Azure_Communication_ServerCalling_Tests_CancelMediaOperationsOperation - - #endregion - - #region Support functions - private CommunicationUserIdentifier CreateUser(CommunicationIdentityClient communicationIdentityClient) - { - // reserve for living test, expect adding more content in the future. - return communicationIdentityClient.CreateUser(); - } - - private async Task CreateUserAsync(CommunicationIdentityClient communicationIdentityClient) - { - // reserve for living test, expect adding more content in the future. - return await communicationIdentityClient.CreateUserAsync(); - } - #endregion Support functions - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsTests.cs deleted file mode 100644 index dd8d4d8bb522b..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/ServerCallingClients/CallingServerClientsTests.cs +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; -using Moq; -using NUnit.Framework; - -namespace Azure.Communication.CallingServer.Tests -{ - public class CallingServerClientsTests - { - [TestCaseSource(nameof(TestData_CreateCall))] - public async Task CreateCallAsyncOverload_Passes(CommunicationIdentifier expectedSource, IEnumerable expectedTargets, CreateCallOptions expectedOptions) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.CreateCallAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((CommunicationIdentifier source, IEnumerable targets, CreateCallOptions options, CancellationToken token) => - { - Assert.AreEqual(expectedSource, source); - Assert.AreEqual(expectedTargets, targets); - Assert.AreEqual(expectedOptions, options); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock>().Object; - }); - - Response actualResponse = await mockClient.Object.CreateCallAsync(expectedSource, expectedTargets, expectedOptions, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_CommonOperationWithCallId))] - public async Task DeleteCallAsyncOverload_Passes(string expectedCallLegId) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.DeleteCallAsync(It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock().Object; - }); - - Response actualResponse = await mockClient.Object.DeleteCallAsync(expectedCallLegId, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_CommonOperationWithCallId))] - public async Task HangupCallAsyncOverload_Passes(string expectedCallLegId) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.HangupCallAsync(It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock().Object; - }); - - Response actualResponse = await mockClient.Object.HangupCallAsync(expectedCallLegId, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_CancelAllMediaOperations))] - public async Task CancelMediaOperationsAsyncOverload_Passes(string expectedCallLegId, string expectedOperationContext) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.CancelAllMediaOperationsAsync(It.IsAny(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, string operationContext, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(expectedOperationContext, operationContext); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock>().Object; - }); - - Response actualResponse = await mockClient.Object.CancelAllMediaOperationsAsync(expectedCallLegId, expectedOperationContext, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_PlayAudioWithRequest))] - public async Task PlayAudioAsyncOverload_Passes(string expectedCallLegId, PlayAudioOptions expectedRequest) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.PlayAudioAsync(It.IsAny(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, PlayAudioOptions request, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(expectedRequest, request); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock>().Object; - }); - - Response actualResponse = await mockClient.Object.PlayAudioAsync(expectedCallLegId, expectedRequest, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_PlayAudioWithoutRequest))] - public async Task PlayAudioAsyncOverload_Passes(string expectedCallLegId, Uri expectedAudioFileUri, bool expectedLoop, string expectedAudioFileId, Uri expectedCallbackUri, string expectedOperationContext) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.PlayAudioAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, Uri audioFileUri, bool loop, string audioFileId, Uri callbackUri, string operationContext, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(expectedAudioFileUri, audioFileUri); - Assert.AreEqual(expectedLoop, loop); - Assert.AreEqual(expectedAudioFileId, audioFileId); - Assert.AreEqual(expectedCallbackUri, callbackUri); - Assert.AreEqual(expectedOperationContext, operationContext); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock>().Object; - }); - - Response actualResponse = await mockClient.Object.PlayAudioAsync(expectedCallLegId, expectedAudioFileUri, expectedLoop, expectedAudioFileId, expectedCallbackUri, expectedOperationContext, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_InviteParticipants))] - public async Task InviteParticipantsAsyncOverload_Passes(string expectedCallLegId, CommunicationIdentifier expectedParticipant, string expectedAlternateCallerId, string expectedOperationContext) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.AddParticipantAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, CommunicationIdentifier participants, string operationContext, string alternateCallerId, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(expectedParticipant, participants); - Assert.AreEqual(expectedOperationContext, operationContext); - Assert.AreEqual(expectedAlternateCallerId, alternateCallerId); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock().Object; - }); - - Response actualResponse = await mockClient.Object.AddParticipantAsync(expectedCallLegId, expectedParticipant, expectedOperationContext, expectedAlternateCallerId, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - [TestCaseSource(nameof(TestData_RemoveParticipant))] - public async Task RemoveParticipantAsyncOverload_Passes(string expectedCallLegId, string expectedParticipantId) - { - Mock mockClient = new Mock() { CallBase = true }; - Response? expectedResponse = default; - CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.RemoveParticipantAsync(It.IsAny(), It.IsAny(), It.IsAny())); - - mockClient - .Setup(callExpression) - .ReturnsAsync((string callLegId, string participantId, CancellationToken token) => - { - Assert.AreEqual(expectedCallLegId, callLegId); - Assert.AreEqual(expectedParticipantId, participantId); - Assert.AreEqual(cancellationToken, token); - return expectedResponse = new Mock().Object; - }); - - Response actualResponse = await mockClient.Object.RemoveParticipantAsync(expectedCallLegId, expectedParticipantId, cancellationToken); - - mockClient.Verify(callExpression, Times.Once()); - Assert.AreEqual(expectedResponse, actualResponse); - } - - private static IEnumerable TestData_CreateCall() - { - return new List(){ - new object?[] { - new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), - new List() { new PhoneNumberIdentifier("+14052882361") }, - new CreateCallOptions(new Uri($"https://dummy.ngrok.io/api/incident/callback?secret=h3llowW0rld"), new List { CallModality.Audio }, new List { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }) - }, - }; - } - - private static IEnumerable TestData_CancelAllMediaOperations() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - "af82480b-6df3-4f4c-a58c-a6a78b614b36" - }, - }; - } - - private static IEnumerable TestData_PlayAudioWithRequest() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new PlayAudioOptions() - { - AudioFileUri = new Uri("https://av.ngrok.io/audio/sample-message.wav"), - Loop = true, - AudioFileId = Guid.NewGuid().ToString(), - CallbackUri = new Uri("https://av.ngrok.io/someCallbackUri"), - OperationContext = Guid.NewGuid().ToString(), - } - } - }; - } - - private static IEnumerable TestData_PlayAudioWithoutRequest() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new Uri("https://av.ngrok.io/audio/sample-message.wav"), - true, - "b76993e4-1906-4967-9a9b-feecbbccc60e", - new Uri("http://foo.com/bar"), - "af82480b-6df3-4f4c-a58c-a6a78b614b36" - } - }; - } - - private static IEnumerable TestData_CommonOperationWithCallId() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - }, - }; - } - - private static IEnumerable TestData_InviteParticipants() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), - "+14052882362", - "af82480b-6df3-4f4c-a58c-a6a78b614b36" - }, - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), - null, - "af82480b-6df3-4f4c-a58c-a6a78b614b36" - }, - }; - } - - private static IEnumerable TestData_RemoveParticipant() - { - return new List(){ - new object?[] { - "4ab31d78-a189-4e50-afaa-f9610975b6cb", - "bb00cdef-9f34-408d-ae95-81bce082fff5" - } - }; - } - - private static Expression> BuildExpression(Expression> expression) - => expression; - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTests.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTests.json new file mode 100644 index 0000000000000..922dc8c71ebab --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTests.json @@ -0,0 +1,190 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:52:24 GMT", + "traceparent": "00-ad453446efd144458f4030f69a85ca7b-f33ad15e795bbb4a-00", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "500420ef7b1dbfd0659302bbf1a9c676", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:52:24 GMT" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:52:24 GMT", + "MS-CV": "162iTJ1JQUmpagjs6HDu9A.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0SEvJYAAAAABms56xYdZDS4KQbjqWKe9LV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "x-ms-client-request-id": "500420ef7b1dbfd0659302bbf1a9c676", + "X-Processing-Time": "24ms" + }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b22f-b8c5-99c6-593a0d001c83" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "388", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:52:25 GMT", + "traceparent": "00-e252cf67ca16c94999031824c913497d-0226fb31e8f2a14a-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "0c5cd4cbca7f230b8038e86378222800", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:52:25 GMT" + }, + "RequestBody": { + "alternateCallerId": { + "value": "Sanitized" + }, + "targets": [ + { + "phoneNumber": { + "value": "Sanitized" + } + } + ], + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b22f-b8c5-99c6-593a0d001c83" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated", + "dtmfReceived" + ] + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:52:27 GMT", + "X-Azure-Ref": "0SUvJYAAAAABvPeAqait7QpnfZXwtymYSV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "14440d76-7512-4130-bacb-d558427658ab", + "x-ms-client-request-id": "0c5cd4cbca7f230b8038e86378222800" + }, + "ResponseBody": { + "callLegId": "b21f1300-058d-40e5-88e6-fb85f42be0c7", + "callConnectionId": "b21f1300-058d-40e5-88e6-fb85f42be0c7" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/b21f1300-058d-40e5-88e6-fb85f42be0c7/participants?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "126", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:52:43 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "37617bbd369c3124106ee1120009be04", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:52:43 GMT" + }, + "RequestBody": { + "participant": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b200-7a0d-570c-113a0d00288d" + } + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "56", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:52:43 GMT", + "X-Azure-Ref": "0W0vJYAAAAADA2hxujqGcRpofblFZl1IyV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "85234923-92c5-4e72-b593-880098baf571", + "x-ms-client-request-id": "37617bbd369c3124106ee1120009be04" + }, + "ResponseBody": { + "participantId": "ec6509bf-4263-4e92-ac07-7d08aaa2cb57" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/b21f1300-058d-40e5-88e6-fb85f42be0c7/participants/ec6509bf-4263-4e92-ac07-7d08aaa2cb57?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 00:53:07 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "e1973e776e8a253114e1d0e5936c4642", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:53:07 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 00:53:07 GMT", + "X-Azure-Ref": "0c0vJYAAAAADqN7JST0F9RL5k\u002BHfjcV1yV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "c5f65d20-c723-4f82-9fa3-226ac4183418", + "x-ms-client-request-id": "e1973e776e8a253114e1d0e5936c4642" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/b21f1300-058d-40e5-88e6-fb85f42be0c7/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 00:53:19 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "75fe026a8e4894dab02bfb10e8f82276", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:53:19 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 00:53:19 GMT", + "X-Azure-Ref": "0f0vJYAAAAAAo6ey4cUg7RpiGNenwL8PcV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "961ad1bd-531c-4316-9332-3b88b5252ab6", + "x-ms-client-request-id": "75fe026a8e4894dab02bfb10e8f82276" + }, + "ResponseBody": [] + } + ], + "Variables": { + "ALTERNATE_CALLERID": "Sanitized", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "423820033" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json new file mode 100644 index 0000000000000..f1e3483b56cd6 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json @@ -0,0 +1,190 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:47:03 GMT", + "traceparent": "00-292e0b1b32cc41429f3db26ae9429d80-ed5aa23c0bd10f4e-00", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "422c3910d41ce5e257913753e6baa3e8", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Mon, 16 Jun 2021 00:52:24 GMT" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:47:03 GMT", + "MS-CV": "MPQMjXEhKEejHY13Eo8/rw.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0J2bJYAAAAABlu4TdTO22QZLXM7FyyTcWV1NURURHRTA4MTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "x-ms-client-request-id": "422c3910d41ce5e257913753e6baa3e8", + "X-Processing-Time": "94ms" + }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b298-aea0-51b9-a43a0d009a4f" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "388", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:47:03 GMT", + "traceparent": "00-ba51f047e1f15e429b9be83dacc29835-0f2abd848170664a-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "fc233447fe1ab89e33898d8d73fc9858", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:47:03 GMT" + }, + "RequestBody": { + "alternateCallerId": { + "value": "Sanitized" + }, + "targets": [ + { + "phoneNumber": { + "value": "Sanitized" + } + } + ], + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b298-aea0-51b9-a43a0d009a4f" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated", + "dtmfReceived" + ] + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:47:03 GMT", + "X-Azure-Ref": "0J2bJYAAAAAAcip9JfhFJR7bItClkkSSTV1NURURHRTA4MTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "11c19dc6-753f-4e13-8448-6d594fae0ab9", + "x-ms-client-request-id": "fc233447fe1ab89e33898d8d73fc9858" + }, + "ResponseBody": { + "callLegId": "761f1300-7d9c-4f8b-9a12-89c8b8941063", + "callConnectionId": "761f1300-7d9c-4f8b-9a12-89c8b8941063" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/761f1300-7d9c-4f8b-9a12-89c8b8941063/participants?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "126", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:47:13 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "cb47f7341133b4af5a8fc2eb57796400", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:47:13 GMT" + }, + "RequestBody": { + "participant": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b200-7a0d-570c-113a0d00288d" + } + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "56", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:47:13 GMT", + "X-Azure-Ref": "0MWbJYAAAAAD3SA2ix3FTRK1EAxOwMLpeV1NURURHRTA4MTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "393391fb-6811-4b6b-bfbc-6c481760f8cc", + "x-ms-client-request-id": "cb47f7341133b4af5a8fc2eb57796400" + }, + "ResponseBody": { + "participantId": "905aac00-45df-4869-8da7-23c3d86db1c4" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/761f1300-7d9c-4f8b-9a12-89c8b8941063/participants/905aac00-45df-4869-8da7-23c3d86db1c4?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 02:47:24 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "02eebb81a11712169b730f934755715b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:47:24 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 02:47:23 GMT", + "X-Azure-Ref": "0PGbJYAAAAAB0vjmsevIhQ6rY3dTzcjJ\u002BV1NURURHRTA4MTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "7a7b3abc-9c90-4c51-9df6-833ea213a53a", + "x-ms-client-request-id": "02eebb81a11712169b730f934755715b" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/761f1300-7d9c-4f8b-9a12-89c8b8941063/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 02:47:34 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "ef1fdef8d77335b5856fa18b3cb360b9", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:47:34 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 02:47:33 GMT", + "X-Azure-Ref": "0RmbJYAAAAAClHElVugeoSprumTu1r80NV1NURURHRTA4MTkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "532007e9-5790-4c08-8442-fa39e73c85f7", + "x-ms-client-request-id": "ef1fdef8d77335b5856fa18b3cb360b9" + }, + "ResponseBody": [] + } + ], + "Variables": { + "ALTERNATE_CALLERID": "Sanitized", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "398231748" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTests.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTests.json new file mode 100644 index 0000000000000..0f50673525916 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTests.json @@ -0,0 +1,197 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:50:24 GMT", + "traceparent": "00-a4935b7252145545817d1680c4827e3a-87bf3e667c68be4c-00", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "fbc68bc12c3dc3845fed5c7c01ffddd1", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:50:24 GMT" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:50:23 GMT", + "MS-CV": "ekKTkoxIGUSgHaoVZHgOqQ.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "08GbJYAAAAABPf\u002BM1t1HRTIK54vGzT1XXV1NURURHRTA4MTYAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "x-ms-client-request-id": "fbc68bc12c3dc3845fed5c7c01ffddd1", + "X-Processing-Time": "79ms" + }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b29b-bde8-71bf-a43a0d00aaf1" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "388", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:50:24 GMT", + "traceparent": "00-7a3f51d045d5a34ab9d82eae94b639db-fc2e806a88a7f144-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "51e8db5f086fd2d835fbe7ff672bf037", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:50:24 GMT" + }, + "RequestBody": { + "alternateCallerId": { + "value": "Sanitized" + }, + "targets": [ + { + "phoneNumber": { + "value": "Sanitized" + } + } + ], + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b29b-bde8-71bf-a43a0d00aaf1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated", + "dtmfReceived" + ] + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:50:23 GMT", + "X-Azure-Ref": "08GbJYAAAAADtwZp4\u002BpgqQYHlj5z6/mJLV1NURURHRTA4MTYAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "09ee466e-f5c7-4654-aebc-f11bfcf30e2b", + "x-ms-client-request-id": "51e8db5f086fd2d835fbe7ff672bf037" + }, + "ResponseBody": { + "callLegId": "01201300-3da1-4b5a-a4a9-8a91311037b7", + "callConnectionId": "01201300-3da1-4b5a-a4a9-8a91311037b7" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/01201300-3da1-4b5a-a4a9-8a91311037b7/:playAudio?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "190", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:50:34 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "3f82b20ca43688f39cc5acb3d7942525", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:50:34 GMT" + }, + "RequestBody": { + "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", + "loop": false, + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", + "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "131", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:50:35 GMT", + "X-Azure-Ref": "0\u002BmbJYAAAAABJVJ32wLyhTJFAasbbuTSoV1NURURHRTA4MTYAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "f4f5a7e9-4240-4a0c-b510-e30c27fbc358", + "x-ms-client-request-id": "3f82b20ca43688f39cc5acb3d7942525" + }, + "ResponseBody": { + "operationId": "c2123c45-5032-425a-9883-4742f8d74722", + "status": "running", + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/01201300-3da1-4b5a-a4a9-8a91311037b7/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 02:50:46 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "bf654c2b80fbb95ab2f4c64144855b34", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:50:46 GMT" + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 02:50:46 GMT", + "X-Azure-Ref": "0BmfJYAAAAADT6QQ\u002BcnYoSb4vevUypgooV1NURURHRTA4MTYAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "323a1e39-8413-4e5b-9363-25f9e9add274", + "x-ms-client-request-id": "bf654c2b80fbb95ab2f4c64144855b34" + }, + "ResponseBody": { + "operationId": "819edd7b-e769-4f4f-a1de-084beb66d8fe", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/01201300-3da1-4b5a-a4a9-8a91311037b7/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 02:50:56 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "4f7024fc9e7cbb9be85fb4a95c25faa0", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 02:50:56 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 02:50:56 GMT", + "X-Azure-Ref": "0EGfJYAAAAABIbhsKhzktR6b/JJVfRDuZV1NURURHRTA4MTYAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "a08d69d9-faf1-4e30-997e-7894ba55d133", + "x-ms-client-request-id": "4f7024fc9e7cbb9be85fb4a95c25faa0" + }, + "ResponseBody": [] + } + ], + "Variables": { + "ALTERNATE_CALLERID": "Sanitized", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1479243591" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json new file mode 100644 index 0000000000000..9a5b6ea567e48 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallConnectionLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json @@ -0,0 +1,197 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:48:45 GMT", + "traceparent": "00-082a9606c14f804386d10d505e1bbb6f-ff8156e41829e04d-00", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "d76df114f6a29e3f08e7928c322e3631", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:48:45 GMT" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:48:45 GMT", + "MS-CV": "JrXBhw0XDkSH7sNgh1pzUQ.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0bUrJYAAAAACG7bx3iv/rS6uGrS2DaQt7V1NURURHRTA4MDcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "x-ms-client-request-id": "d76df114f6a29e3f08e7928c322e3631", + "X-Processing-Time": "88ms" + }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b22c-6155-290c-113a0d00f7de" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "388", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:48:46 GMT", + "traceparent": "00-7570b7647491ec4c878a4ad91b88e96a-639e2d7a439d2847-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "568790ef80ccc0ab5f53da2e8862529c", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:48:46 GMT" + }, + "RequestBody": { + "alternateCallerId": { + "value": "Sanitized" + }, + "targets": [ + { + "phoneNumber": { + "value": "Sanitized" + } + } + ], + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b22c-6155-290c-113a0d00f7de" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated", + "dtmfReceived" + ] + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:48:45 GMT", + "X-Azure-Ref": "0bkrJYAAAAAC6kVNv7ge0T5Io7lDRMarfV1NURURHRTA4MDcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "73cc08e4-cbd1-4f8f-950e-913e2aa0ad8a", + "x-ms-client-request-id": "568790ef80ccc0ab5f53da2e8862529c" + }, + "ResponseBody": { + "callLegId": "f11f1300-160b-444e-af99-af3e7bfcadf7", + "callConnectionId": "f11f1300-160b-444e-af99-af3e7bfcadf7" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/f11f1300-160b-444e-af99-af3e7bfcadf7/:playAudio?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "190", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:48:56 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "0afd87e15d5ca65dc5d31a3c3dc1e896", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:48:56 GMT" + }, + "RequestBody": { + "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", + "loop": false, + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", + "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "131", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:48:55 GMT", + "X-Azure-Ref": "0eErJYAAAAABt8OZpB3puTbyofhiChNM0V1NURURHRTA4MDcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "eb19972f-dccd-4197-9b44-1a1cd278bda3", + "x-ms-client-request-id": "0afd87e15d5ca65dc5d31a3c3dc1e896" + }, + "ResponseBody": { + "operationId": "5ea3c453-7706-4aee-95c7-1e2ea0af1d36", + "status": "running", + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/f11f1300-160b-444e-af99-af3e7bfcadf7/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 00:49:06 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "2245966dbd2794b646ad774f1c1116a6", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:49:06 GMT" + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 00:49:05 GMT", + "X-Azure-Ref": "0gkrJYAAAAADunrHo2PRzSKFESx\u002BIqirkV1NURURHRTA4MDcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "fa85a42d-0f62-4a44-8383-6dd852591cce", + "x-ms-client-request-id": "2245966dbd2794b646ad774f1c1116a6" + }, + "ResponseBody": { + "operationId": "cc81a010-55da-4ecf-9fce-5cc417a43aec", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/f11f1300-160b-444e-af99-af3e7bfcadf7/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 00:49:16 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "abaaf5952c3191d533e191f8666e829d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 00:49:16 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 00:49:15 GMT", + "X-Azure-Ref": "0jErJYAAAAACoR7Y/VapuTKF5Zc/bW/v3V1NURURHRTA4MDcAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "8f74d0c6-ba85-4c79-8255-9c5c541d01a1", + "x-ms-client-request-id": "abaaf5952c3191d533e191f8666e829d" + }, + "ResponseBody": [] + } + ], + "Variables": { + "ALTERNATE_CALLERID": "Sanitized", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "34829153" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTest.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTest.json deleted file mode 100644 index f6d58f5a85f19..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTest.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://acstestbot3.communication.azure.com/identities?api-version=2021-03-07", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "2", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:33:14 GMT", - "traceparent": "00-70ff82b91389e640b5cc378941aa7278-034203f41a895c40-00", - "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "3a91045fc3b28947c3bc6bb38d011636", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:33:14 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": {}, - "StatusCode": 201, - "ResponseHeaders": { - "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:33:14 GMT", - "MS-CV": "O6Rhb9vQlUaWuTXIuX9kPA.0", - "Request-Context": "appId=", - "Strict-Transport-Security": "max-age=2592000", - "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0m5C\u002BYAAAAACgUupLjIauQrtNt/7YYfruV1NURURHRTA4MjAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "x-ms-client-request-id": "3a91045fc3b28947c3bc6bb38d011636", - "X-Processing-Time": "89ms" - }, - "ResponseBody": { - "identity": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-8846-8408-3ef0-8b3a0d002505" - } - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "394", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:33:16 GMT", - "traceparent": "00-25fd9d696df13644ae8cea5f2afda2f3-f58afde3f311ad4c-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "16f888f3262fb3425888af43511f9865", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:33:16 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "sourceAlternateIdentity": { - "value": "Sanitized" - }, - "targets": [ - { - "phoneNumber": { - "value": "Sanitized" - } - } - ], - "source": { - "communicationUser": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-8846-8408-3ef0-8b3a0d002505" - } - }, - "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", - "requestedModalities": [ - "audio" - ], - "requestedCallEvents": [ - "participantsUpdated", - "dtmfReceived" - ] - }, - "StatusCode": 201, - "ResponseHeaders": { - "Client-Request-Id": "270077c7-7660-46ab-bc41-c2dc2e53d946", - "Content-Length": "52", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:33:15 GMT", - "X-Azure-Ref": "0nJC\u002BYAAAAABPo1lpCog6T7fwfYRzWtJGV1NURURHRTA4MjAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "72273267-4def-43fc-8c34-3586fc69e2f4" - }, - "ResponseBody": { - "callLegId": "00000b80-b462-4411-b32a-c704e059f1c7" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/00000b80-b462-4411-b32a-c704e059f1c7/PlayAudio?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "189", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:33:26 GMT", - "traceparent": "00-c2efbd308de11b47a827b3326bf1b27d-5e29db60a7534e46-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "d7a070c88562db1df7a3fef86f0a778d", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:33:26 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", - "loop": true, - "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", - "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" - }, - "StatusCode": 202, - "ResponseHeaders": { - "Client-Request-Id": "d6422823-e979-414c-b22d-a903821bd769", - "Content-Length": "122", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:33:26 GMT", - "X-Azure-Ref": "0ppC\u002BYAAAAACfwgh7MHw6Sqw\u002BRtn3pz6HV1NURURHRTA4MjAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "f79370ff-9595-420b-ac80-3d773f898579" - }, - "ResponseBody": { - "id": "d32ac4dd-800f-4703-ac9e-cb2eba999b24", - "status": "running", - "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/00000b80-b462-4411-b32a-c704e059f1c7/CancelMediaProcessing?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "2", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:33:32 GMT", - "traceparent": "00-a11ec20337b7184f945d622a464e3456-914744677d3e7849-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "cd82999b133838b5c2dde129130437a3", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:33:32 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": {}, - "StatusCode": 200, - "ResponseHeaders": { - "Client-Request-Id": "34145f63-32be-406c-837d-08f45da19ee6", - "Content-Length": "66", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:33:31 GMT", - "X-Azure-Ref": "0rJC\u002BYAAAAAAb8GLZxK31RoIddYT9ETjnV1NURURHRTA4MjAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "d6794596-646c-4457-8265-f56185996d41" - }, - "ResponseBody": { - "id": "9caedaea-d129-4875-8b32-403754f9bfd8", - "status": "completed" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/00000b80-b462-4411-b32a-c704e059f1c7?api-version=2021-04-15-preview1", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Date": "Mon, 07 Jun 2021 21:33:40 GMT", - "traceparent": "00-06fd3b3b9a6965499644b273b94b3003-190d7b8c3ae5dd46-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "1deb06243e606ed36a1d1f8c2749434e", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:33:40 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": null, - "StatusCode": 202, - "ResponseHeaders": { - "Client-Request-Id": "2be0c098-78a9-4b9c-aa40-83432b10c2ce", - "Content-Length": "0", - "Date": "Mon, 07 Jun 2021 21:33:39 GMT", - "X-Azure-Ref": "0tJC\u002BYAAAAADL\u002BNa0hATnQJK\u002BaaxYAoXAV1NURURHRTA4MjAAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "d7647a97-8419-488b-b930-c858c7b20c78" - }, - "ResponseBody": [] - } - ], - "Variables": { - "AZURE_PHONE_NUMBER": "Sanitized", - "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "RandomSeed": "1959684932" - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTestAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTestAsync.json deleted file mode 100644 index b44372c6c07a0..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CancelAllMediaOperationsTestAsync.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://acstestbot3.communication.azure.com/identities?api-version=2021-03-07", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "2", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:32:06 GMT", - "traceparent": "00-c851b7e5ed46814f9f81e9412452280e-33b734496067e247-00", - "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "85386b3453516484d0b733876273b734", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:32:06 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": {}, - "StatusCode": 201, - "ResponseHeaders": { - "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:32:06 GMT", - "MS-CV": "JOokOoj9w0aGYpJgvb2m5w.0", - "Request-Context": "appId=", - "Strict-Transport-Security": "max-age=2592000", - "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0V5C\u002BYAAAAACamtRHYCRkRpfR9ZiEMchbV1NURURHRTA4MjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "x-ms-client-request-id": "85386b3453516484d0b733876273b734", - "X-Processing-Time": "30ms" - }, - "ResponseBody": { - "identity": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-8845-793b-0e04-343a0d0050cf" - } - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "394", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:32:07 GMT", - "traceparent": "00-351cb0e323dcd743802a8088377ef236-c403d8318d4e244b-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "a7a015657f3a707ebeab76079b5db180", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:32:07 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "sourceAlternateIdentity": { - "value": "Sanitized" - }, - "targets": [ - { - "phoneNumber": { - "value": "Sanitized" - } - } - ], - "source": { - "communicationUser": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-8845-793b-0e04-343a0d0050cf" - } - }, - "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", - "requestedModalities": [ - "audio" - ], - "requestedCallEvents": [ - "participantsUpdated", - "dtmfReceived" - ] - }, - "StatusCode": 201, - "ResponseHeaders": { - "Client-Request-Id": "41453c0c-905f-466c-80e7-d8b00aeca5f0", - "Content-Length": "52", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:32:07 GMT", - "X-Azure-Ref": "0V5C\u002BYAAAAABq4uRWokpsRo67nRS/bVVFV1NURURHRTA4MjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "c3b4f31a-b467-4cf7-b0ef-73360e149208" - }, - "ResponseBody": { - "callLegId": "04000b80-d37e-440a-b08a-5b0d3862bbfb" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/04000b80-d37e-440a-b08a-5b0d3862bbfb/PlayAudio?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "189", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:32:18 GMT", - "traceparent": "00-f5d984ce0caa9548aa2c58f4262ae534-7f34d64a7dabf949-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "99014c3a65871596c72d30c2313cdd74", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:32:18 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", - "loop": true, - "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", - "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c" - }, - "StatusCode": 202, - "ResponseHeaders": { - "Client-Request-Id": "d86ba053-cc2b-4ba6-a721-933d28c14ba3", - "Content-Length": "122", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:32:17 GMT", - "X-Azure-Ref": "0YpC\u002BYAAAAAByhppb6Du0SpXmImkL6QujV1NURURHRTA4MjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "9bda2bd2-9465-47e3-8778-dd98f1997d29" - }, - "ResponseBody": { - "id": "6257383a-1966-42b0-9509-2f66164744e8", - "status": "running", - "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/04000b80-d37e-440a-b08a-5b0d3862bbfb/CancelMediaProcessing?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "2", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 21:32:23 GMT", - "traceparent": "00-d71e866bb505f941808d1993c8af5b25-df76a380f902c647-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "83991d694137b407edc7c7a5dd7cc973", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:32:23 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": {}, - "StatusCode": 200, - "ResponseHeaders": { - "Client-Request-Id": "6ddcd3cf-7a3c-4291-8881-c3ba1f6739ce", - "Content-Length": "66", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 21:32:23 GMT", - "X-Azure-Ref": "0Z5C\u002BYAAAAAAnBjtZVIp9R5a4HGN3WHFLV1NURURHRTA4MjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "1a2e20c2-41c1-4a3f-bd94-8d5cc85fe1c7" - }, - "ResponseBody": { - "id": "bb2b8889-df0e-44ad-9513-4f3d1e698f37", - "status": "completed" - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls/04000b80-d37e-440a-b08a-5b0d3862bbfb?api-version=2021-04-15-preview1", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Date": "Mon, 07 Jun 2021 21:32:32 GMT", - "traceparent": "00-7a42cdf4ebc9fe488d25de98f25b382e-51f3d6facc1a2345-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "154cb2061e71ffad7e8bdf0c4ebb3e81", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 21:32:32 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": null, - "StatusCode": 202, - "ResponseHeaders": { - "Client-Request-Id": "a33479a1-fce1-49fe-8819-80a6eb270aaf", - "Content-Length": "0", - "Date": "Mon, 07 Jun 2021 21:32:31 GMT", - "X-Azure-Ref": "0b5C\u002BYAAAAAByvzMkFgeXRLhuW637U54FV1NURURHRTA4MjEAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "8384df1a-783f-43c3-a393-1a725582cfdc" - }, - "ResponseBody": [] - } - ], - "Variables": { - "AZURE_PHONE_NUMBER": "Sanitized", - "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "RandomSeed": "1859146728" - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CreateCallTest.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CreateCallTest.json deleted file mode 100644 index 83f11d75e0f30..0000000000000 --- a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/CallingServerClientsLiveTests/CreateCallTest.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://acstestbot3.communication.azure.com/identities?api-version=2021-03-07", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "2", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 18:11:47 GMT", - "traceparent": "00-dce5ab2dd9f9294da83c23c04c4b93a0-e5dfeb27fff23546-00", - "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "e96333c2a95914ae53be009620a86591", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 18:11:47 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": {}, - "StatusCode": 201, - "ResponseHeaders": { - "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 18:11:47 GMT", - "MS-CV": "U/fWzwghYESANtfT9fKQsw.0", - "Request-Context": "appId=", - "Strict-Transport-Security": "max-age=2592000", - "Transfer-Encoding": "chunked", - "X-Azure-Ref": "0ZGG\u002BYAAAAADBIiegi3spSa4qj6gzzMgsV1NURURHRTA4MTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "x-ms-client-request-id": "e96333c2a95914ae53be009620a86591", - "X-Processing-Time": "22ms" - }, - "ResponseBody": { - "identity": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-878e-1315-ac00-343a0d006216" - } - } - }, - { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls?api-version=2021-04-15-preview1", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "394", - "Content-Type": "application/json", - "Date": "Mon, 07 Jun 2021 18:11:48 GMT", - "traceparent": "00-1dd237a56fee6f46bd5451fd1b1615ea-9488b0af5c842e4c-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210607.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", - "x-ms-client-request-id": "a0a79d28c93a0d02342bb4975468973d", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Mon, 07 Jun 2021 18:11:48 GMT", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "sourceAlternateIdentity": { - "value": "Sanitized" - }, - "targets": [ - { - "phoneNumber": { - "value": "Sanitized" - } - } - ], - "source": { - "communicationUser": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-878e-1315-ac00-343a0d006216" - } - }, - "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", - "requestedModalities": [ - "audio" - ], - "requestedCallEvents": [ - "participantsUpdated", - "dtmfReceived" - ] - }, - "StatusCode": 201, - "ResponseHeaders": { - "Client-Request-Id": "c074b88e-804a-4ba7-85b8-197f25f415a5", - "Content-Length": "52", - "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 07 Jun 2021 18:11:48 GMT", - "X-Azure-Ref": "0ZGG\u002BYAAAAAB5blUKyCDlRrbcwUnWy8ZUV1NURURHRTA4MTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", - "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "ba9797a5-a5a3-4c2d-aa4c-e9ba84a2b38b" - }, - "ResponseBody": { - "callLegId": "01000b80-2fb2-4fc3-b9dd-56bb53310817" - } - } - ], - "Variables": { - "AZURE_PHONE_NUMBER": "Sanitized", - "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "RandomSeed": "220983724" - } -} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCall.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCall.json index 77a9872eeae26..2380f85b0202b 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCall.json +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCall.json @@ -1,35 +1,71 @@ { "Entries": [ { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls?api-version=2021-04-15-preview1", + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "354", - "Content-Type": "application/json", - "Date": "Wed, 02 Jun 2021 21:28:27 GMT", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210602.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 17:01:53 GMT", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210616.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f7c8910f9c6fa503ddd8b7582e6d4d17", + "x-ms-content-sha256": "Sanitized", + "x-ms-date": "Wed, 16 Jun 2021 17:01:53 GMT", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 17:01:54 GMT", + "MS-CV": "Waia\u002BH\u002BoTkSaqGl671wvsQ.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0gy7KYAAAAADwMwiEWDQYRLKBnAnlHKJOV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", "x-ms-client-request-id": "f7c8910f9c6fa503ddd8b7582e6d4d17", - "x-ms-content-sha256": "Sanitized", - "x-ms-date": "Wed, 02 Jun 2021 21:28:27 GMT", - "x-ms-return-client-request-id": "true" + "X-Processing-Time": "103ms" }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b5a7-54a0-e3c7-593a0d008912" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "346", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 17:01:55 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210616.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "a585200bb309794fd62f46729d5801ec", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 17:01:55 GMT" + }, "RequestBody": { "targets": [ { "phoneNumber": { - "value": "\u002B15129104698" + "value": "Sanitized" } } ], "source": { "communicationUser": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-6e82-5005-63b2-a43a0d00393c" + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b5a7-54a0-e3c7-593a0d008912" } }, "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", - "requestedModalities": [ + "requestedMediaTypes": [ "audio" ], "requestedCallEvents": [ @@ -39,23 +75,24 @@ }, "StatusCode": 201, "ResponseHeaders": { - "Client-Request-Id": "c4d55e4e-e491-434b-a9f1-37a9234d4f51", - "Content-Length": "52", + "Content-Length": "110", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 02 Jun 2021 21:28:27 GMT", - "X-Azure-Ref": "0\u002B/e3YAAAAAD7jnJZgiP4TKurZwfRajDbV1NURURHRTA4MTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "Date": "Wed, 16 Jun 2021 17:01:55 GMT", + "X-Azure-Ref": "0gy7KYAAAAAA\u002BA4K9iGDhTZnNyh0Y6O5ZV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "03025d96-60d3-4ff7-843b-3a4023911570" + "X-Microsoft-Skype-Chain-ID": "51e5fb62-e6b5-4656-9f21-95ab83fa83d1", + "x-ms-client-request-id": "a585200bb309794fd62f46729d5801ec" }, "ResponseBody": { - "callLegId": "6c1f6900-1fbd-4ee0-a4b9-2aa0b5f40ad1" + "callLegId": "4c201300-43e4-4471-9b5e-7988ff001cdd", + "callConnectionId": "4c201300-43e4-4471-9b5e-7988ff001cdd" } } ], "Variables": { - "AZURE_PHONE_NUMBER": "\u002B15129104698", - "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", "RandomSeed": "54266852" } } diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCallAsyncAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCallAsyncAsync.json index 678367f9951b2..14e3cab2d9b35 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCallAsyncAsync.json +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/Sample1_CallClient/CreateCallAsyncAsync.json @@ -1,35 +1,73 @@ { "Entries": [ { - "RequestUri": "https://acstestbot3.communication.azure.com/calling/calls?api-version=2021-04-15-preview1", + "RequestUri": "https://acstestbot1.communication.azure.com/identities?api-version=2021-03-07", "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json", - "Authorization": "Sanitized", - "Content-Length": "354", - "Content-Type": "application/json", - "Date": "Wed, 02 Jun 2021 21:28:29 GMT", - "traceparent": "00-f03b3c0995adc24882d0cb3f6d4ef016-32e1ef3fa4d5b94d-00", - "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210602.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 17:01:57 GMT", + "traceparent": "00-563d4f660fb30b4ba0fdfc0025f17506-50f5c17400915e4e-00", + "User-Agent": "azsdk-net-Communication.Identity/1.1.0-alpha.20210616.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "750c6da09b80fc970cd7aa322fd6b1c9", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 17:01:57 GMT" + }, + "RequestBody": {}, + "StatusCode": 201, + "ResponseHeaders": { + "api-supported-versions": "2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 17:01:56 GMT", + "MS-CV": "fbWazVRcpkOcx5Y2NiwPMw.0", + "Request-Context": "appId=", + "Strict-Transport-Security": "max-age=2592000", + "Transfer-Encoding": "chunked", + "X-Azure-Ref": "0hS7KYAAAAAB\u002B/YJWZ6O4RJSV\u002B9QJ2nt9V1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", "x-ms-client-request-id": "750c6da09b80fc970cd7aa322fd6b1c9", - "x-ms-content-sha256": "Sanitized", - "x-ms-return-client-request-id": "true" + "X-Processing-Time": "22ms" }, + "ResponseBody": { + "identity": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b5a7-5d10-e3c7-593a0d008917" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "346", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 17:01:58 GMT", + "traceparent": "00-47ba21026d51af43b3b276bb9fb8fcb6-b915fd9d37c14f49-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210616.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f65700430c203efc039afdad51d467bb", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 17:01:58 GMT" + }, "RequestBody": { "targets": [ { "phoneNumber": { - "value": "\u002B15129104698" + "value": "Sanitized" } } ], "source": { "communicationUser": { - "id": "8:acs:02665c56-277e-4c59-bab4-c475caa3ee80_0000000a-6e82-5627-54b7-a43a0d00395f" + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b5a7-5d10-e3c7-593a0d008917" } }, "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", - "requestedModalities": [ + "requestedMediaTypes": [ "audio" ], "requestedCallEvents": [ @@ -39,23 +77,24 @@ }, "StatusCode": 201, "ResponseHeaders": { - "Client-Request-Id": "77074750-189c-4615-843f-b357d68fa3b5", - "Content-Length": "52", + "Content-Length": "110", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 02 Jun 2021 21:28:28 GMT", - "X-Azure-Ref": "0/Pe3YAAAAADZL\u002B\u002BDA03YQangI05vTMI1V1NURURHRTA4MTQAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "Date": "Wed, 16 Jun 2021 17:01:57 GMT", + "X-Azure-Ref": "0hS7KYAAAAAD0hiiC1T7aRJrZmS4CLBuoV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", "X-Cache": "CONFIG_NOCACHE", - "X-Microsoft-Skype-Chain-ID": "80b47d16-ed1f-4c8b-88b9-3f6d1de9b3f5" + "X-Microsoft-Skype-Chain-ID": "8cbc8bfe-863e-476e-85c8-a77b67a93cc4", + "x-ms-client-request-id": "f65700430c203efc039afdad51d467bb" }, "ResponseBody": { - "callLegId": "6c1f6900-5681-4271-9cf6-f5c1a3a64bc3" + "callLegId": "4c201300-eb1e-4e9f-8a0a-6aaf623fc9f3", + "callConnectionId": "4c201300-eb1e-4e9f-8a0a-6aaf623fc9f3" } } ], "Variables": { - "AZURE_PHONE_NUMBER": "\u002B15129104698", - "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot3.communication.azure.com/;accesskey=Kg==", + "AZURE_PHONE_NUMBER": "Sanitized", + "COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", "RandomSeed": "303477573" } -} \ No newline at end of file +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTests.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTests.json new file mode 100644 index 0000000000000..28d97a9c09f8e --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTests.json @@ -0,0 +1,370 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:39 GMT", + "traceparent": "00-616dfbbf36772a46864bf7c08755624d-bcc64f263cee0042-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f49f5f0bf1da113c53240a529cfffbef", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:39 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:40 GMT", + "X-Azure-Ref": "00JbJYAAAAABoXEnj\u002B/jNT6h9T9oEgjZlV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "63fffae3-74c2-4c76-bd52-d7e03c99814c", + "x-ms-client-request-id": "f49f5f0bf1da113c53240a529cfffbef" + }, + "ResponseBody": { + "callLegId": "1f201300-bfb0-4767-9e79-78154c5f075d", + "callConnectionId": "1f201300-bfb0-4767-9e79-78154c5f075d" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:41 GMT", + "traceparent": "00-97b6c6b7e5d89e41a1954f50a2583670-b9ea8c9ae34aa643-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "37b43a95a006dde1b43b017473e2d7de", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:41 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:41 GMT", + "X-Azure-Ref": "00ZbJYAAAAAAWWBFl\u002BUa4Q4pAQfn83SdiV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "afd18997-36d8-4ea5-aaca-6fe5534394e0", + "x-ms-client-request-id": "37b43a95a006dde1b43b017473e2d7de" + }, + "ResponseBody": { + "callLegId": "1f201300-c64b-4d56-8b13-d2d249d66e51", + "callConnectionId": "1f201300-c64b-4d56-8b13-d2d249d66e51" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "97", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:43 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "c9e4c88cc186738e15632a50b497a3fc", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:43 GMT" + }, + "RequestBody": { + "recordingStateCallbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "180", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:47 GMT", + "X-Azure-Ref": "005bJYAAAAAA1himOYEmwRKGBxioDEEsFV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "36fe1b85-d99c-4558-8f2e-82ce686480bb", + "x-ms-client-request-id": "c9e4c88cc186738e15632a50b497a3fc" + }, + "ResponseBody": { + "recordingId": "eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "729d170df0726a9b7dc2409ff0c89e70", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:54 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "27", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:53 GMT", + "X-Azure-Ref": "03ZbJYAAAAAAgJG8VtzO1TrwwB9BOK5y1V1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "d10931d4-a019-450b-ba8c-7c12b69abfa5", + "x-ms-client-request-id": "729d170df0726a9b7dc2409ff0c89e70" + }, + "ResponseBody": { + "recordingState": "active" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ/:pause?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "d3c52c4d311ad369ab4121a37691281d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:54 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "X-Azure-Ref": "03pbJYAAAAABp62/ClNLRSKXU67cpwhpTV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "4794c1cc-8455-40f9-9376-18b6fff4565e", + "x-ms-client-request-id": "d3c52c4d311ad369ab4121a37691281d" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5b67059864459b6c2d794bc481ef834d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:00 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "29", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "X-Azure-Ref": "05JbJYAAAAACM6rwId1HSQLYyd1v2JmBPV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "aa9d90af-19a5-4b68-b398-b4e1297babf6", + "x-ms-client-request-id": "5b67059864459b6c2d794bc481ef834d" + }, + "ResponseBody": { + "recordingState": "inactive" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ/:resume?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "8803bac5d0d2dbe1aec9c730cff8f4eb", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:00 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "X-Azure-Ref": "05JbJYAAAAABe2s0EGy9XRaajwOIaoIGIV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "70b8fd92-9762-4252-8113-5ab171bd0fa1", + "x-ms-client-request-id": "8803bac5d0d2dbe1aec9c730cff8f4eb" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "ea0623994260e82abf29a6a1e5a552bc", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:06 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "27", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "06pbJYAAAAAAMilSk8NYKQI/3lphUmEdQV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "49208aef-1fdc-4dd2-aa6c-8673377f8e1d", + "x-ms-client-request-id": "ea0623994260e82abf29a6a1e5a552bc" + }, + "ResponseBody": { + "recordingState": "active" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:07 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "bbddd4be9f8ec84b238cad7c9d3bcc34", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:07 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "06pbJYAAAAADt\u002Bvd3Ym54Tqz0ZriqLeKfV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "b07f60d0-be10-4c91-bd93-4a540be0d6a5", + "x-ms-client-request-id": "bbddd4be9f8ec84b238cad7c9d3bcc34" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:07 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5e2a5f8598e882ec8f1ac9a82940f508", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:06 GMT" + }, + "RequestBody": null, + "StatusCode": 400, + "ResponseHeaders": { + "Content-Length": "93", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "065bJYAAAAAC5fPwjZF8zQJTaqoIJiI\u002BbV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "b91d8469-13ed-4220-bd56-745e7b1d5e87", + "x-ms-client-request-id": "5e2a5f8598e882ec8f1ac9a82940f508" + }, + "ResponseBody": { + "error": { + "code": "8501", + "message": "Action is invalid when call is not in Established state" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/1f201300-bfb0-4767-9e79-78154c5f075d/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "fb720b77381af95dd83ec7d495ae4a83", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:17 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "X-Azure-Ref": "09ZbJYAAAAABvakfTfriAR41VW7CnhDyvV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "6d7fb8b8-f118-4157-b315-cb785079c3c2", + "x-ms-client-request-id": "fb720b77381af95dd83ec7d495ae4a83" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/1f201300-c64b-4d56-8b13-d2d249d66e51/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "851b715df47a25d3e75b2c73d6a29ee3", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:17 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "X-Azure-Ref": "09ZbJYAAAAADMPDfgdmFDRpl/2PhlOTFNV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "98c8b906-d978-4b79-9ef4-ca0537cdc539", + "x-ms-client-request-id": "851b715df47a25d3e75b2c73d6a29ee3" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "502582709" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTestsAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTestsAsync.json new file mode 100644 index 0000000000000..c28d5053f636c --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunAllRecordingFunctionsScenarioTestsAsync.json @@ -0,0 +1,370 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:39 GMT", + "traceparent": "00-616dfbbf36772a46864bf7c08755624d-bcc64f263cee0042-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f49f5f0bf1da113c53240a529cfffbef", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:39 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:40 GMT", + "X-Azure-Ref": "00JbJYAAAAABoXEnj\u002B/jNT6h9T9oEgjZlV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "63fffae3-74c2-4c76-bd52-d7e03c99814c", + "x-ms-client-request-id": "f49f5f0bf1da113c53240a529cfffbef" + }, + "ResponseBody": { + "callLegId": "1f201300-bfb0-4767-9e79-78154c5f075d", + "callConnectionId": "1f201300-bfb0-4767-9e79-78154c5f075d" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:41 GMT", + "traceparent": "00-97b6c6b7e5d89e41a1954f50a2583670-b9ea8c9ae34aa643-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "37b43a95a006dde1b43b017473e2d7de", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:41 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:41 GMT", + "X-Azure-Ref": "00ZbJYAAAAAAWWBFl\u002BUa4Q4pAQfn83SdiV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "afd18997-36d8-4ea5-aaca-6fe5534394e0", + "x-ms-client-request-id": "37b43a95a006dde1b43b017473e2d7de" + }, + "ResponseBody": { + "callLegId": "1f201300-c64b-4d56-8b13-d2d249d66e51", + "callConnectionId": "1f201300-c64b-4d56-8b13-d2d249d66e51" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "97", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:14:43 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "c9e4c88cc186738e15632a50b497a3fc", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:43 GMT" + }, + "RequestBody": { + "recordingStateCallbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "180", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:47 GMT", + "X-Azure-Ref": "005bJYAAAAAA1himOYEmwRKGBxioDEEsFV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "36fe1b85-d99c-4558-8f2e-82ce686480bb", + "x-ms-client-request-id": "c9e4c88cc186738e15632a50b497a3fc" + }, + "ResponseBody": { + "recordingId": "eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "729d170df0726a9b7dc2409ff0c89e70", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:54 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "27", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:14:53 GMT", + "X-Azure-Ref": "03ZbJYAAAAAAgJG8VtzO1TrwwB9BOK5y1V1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "d10931d4-a019-450b-ba8c-7c12b69abfa5", + "x-ms-client-request-id": "729d170df0726a9b7dc2409ff0c89e70" + }, + "ResponseBody": { + "recordingState": "active" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ/:pause?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "d3c52c4d311ad369ab4121a37691281d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:14:54 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:14:54 GMT", + "X-Azure-Ref": "03pbJYAAAAABp62/ClNLRSKXU67cpwhpTV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "4794c1cc-8455-40f9-9376-18b6fff4565e", + "x-ms-client-request-id": "d3c52c4d311ad369ab4121a37691281d" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5b67059864459b6c2d794bc481ef834d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:00 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "29", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "X-Azure-Ref": "05JbJYAAAAACM6rwId1HSQLYyd1v2JmBPV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "aa9d90af-19a5-4b68-b398-b4e1297babf6", + "x-ms-client-request-id": "5b67059864459b6c2d794bc481ef834d" + }, + "ResponseBody": { + "recordingState": "inactive" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ/:resume?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "8803bac5d0d2dbe1aec9c730cff8f4eb", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:00 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:00 GMT", + "X-Azure-Ref": "05JbJYAAAAABe2s0EGy9XRaajwOIaoIGIV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "70b8fd92-9762-4252-8113-5ab171bd0fa1", + "x-ms-client-request-id": "8803bac5d0d2dbe1aec9c730cff8f4eb" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "ea0623994260e82abf29a6a1e5a552bc", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:06 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "27", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "06pbJYAAAAAAMilSk8NYKQI/3lphUmEdQV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "49208aef-1fdc-4dd2-aa6c-8673377f8e1d", + "x-ms-client-request-id": "ea0623994260e82abf29a6a1e5a552bc" + }, + "ResponseBody": { + "recordingState": "active" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:07 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "bbddd4be9f8ec84b238cad7c9d3bcc34", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:07 GMT" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "06pbJYAAAAADt\u002Bvd3Ym54Tqz0ZriqLeKfV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "b07f60d0-be10-4c91-bd93-4a540be0d6a5", + "x-ms-client-request-id": "bbddd4be9f8ec84b238cad7c9d3bcc34" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/recordings/eyJQbGF0Zm9ybUVuZHBvaW50SWQiOiIxZjIwMTMwMC1kNDQ0LTRmODItOTNkNS1iMjFjMGI0N2Q0NGYiLCJSZXNvdXJjZVNwZWNpZmljSWQiOiI3ODg1ZGNhYy0zOTU1LTRmNTEtODM1OC01MDNkZmYyZjZkZWIifQ?api-version=2021-06-15-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:07 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5e2a5f8598e882ec8f1ac9a82940f508", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:06 GMT" + }, + "RequestBody": null, + "StatusCode": 400, + "ResponseHeaders": { + "Content-Length": "93", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:15:06 GMT", + "X-Azure-Ref": "065bJYAAAAAC5fPwjZF8zQJTaqoIJiI\u002BbV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "b91d8469-13ed-4220-bd56-745e7b1d5e87", + "x-ms-client-request-id": "5e2a5f8598e882ec8f1ac9a82940f508" + }, + "ResponseBody": { + "error": { + "code": "8501", + "message": "Action is invalid when call is not in Established state" + } + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/1f201300-bfb0-4767-9e79-78154c5f075d/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "fb720b77381af95dd83ec7d495ae4a83", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:17 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "X-Azure-Ref": "09ZbJYAAAAABvakfTfriAR41VW7CnhDyvV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "6d7fb8b8-f118-4157-b315-cb785079c3c2", + "x-ms-client-request-id": "fb720b77381af95dd83ec7d495ae4a83" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/1f201300-c64b-4d56-8b13-d2d249d66e51/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "851b715df47a25d3e75b2c73d6a29ee3", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:15:17 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:15:17 GMT", + "X-Azure-Ref": "09ZbJYAAAAADMPDfgdmFDRpl/2PhlOTFNV1NURURHRTA4MTMAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "98c8b906-d978-4b79-9ef4-ca0537cdc539", + "x-ms-client-request-id": "851b715df47a25d3e75b2c73d6a29ee3" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "502582709" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTests.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTests.json new file mode 100644 index 0000000000000..fc6295976b30e --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTests.json @@ -0,0 +1,210 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:19:57 GMT", + "traceparent": "00-0cb5b4526f16344dabc81f983bdd33f8-c6457baa3ffaa342-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5b1c21631872ba7c6eab805565cd5455", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:19:57 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:19:57 GMT", + "X-Azure-Ref": "0DpjJYAAAAACsNdkW0upQTL\u002BwrOJMzDCHV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "5a3dc9d6-3a58-4a91-a32b-aae81af84c36", + "x-ms-client-request-id": "5b1c21631872ba7c6eab805565cd5455" + }, + "ResponseBody": { + "callLegId": "86201300-42cd-440d-8c0c-9536b501ae43", + "callConnectionId": "86201300-42cd-440d-8c0c-9536b501ae43" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:19:59 GMT", + "traceparent": "00-5220e669df7b314da391bac86927fdbe-1a9483565a5e7544-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "dc3c427de05f9908815bf920d2c33b02", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:19:59 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:19:59 GMT", + "X-Azure-Ref": "0D5jJYAAAAACAjX3iTmssRqXtdBC05sNSV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "39a374e5-fd55-48a3-ad47-71290dfd6ee7", + "x-ms-client-request-id": "dc3c427de05f9908815bf920d2c33b02" + }, + "ResponseBody": { + "callLegId": "86201300-2cfb-4d0e-8db8-2e11a994b2ed", + "callConnectionId": "86201300-2cfb-4d0e-8db8-2e11a994b2ed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/participants?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "208", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:20:11 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "903aec5eab806bc4938f9e74ab45934c", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:11 GMT" + }, + "RequestBody": { + "participant": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b200-7a0d-570c-113a0d00288d" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "56", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:20:11 GMT", + "X-Azure-Ref": "0GpjJYAAAAADYA3qHM1aORan7rt3Q0JGTV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "f2914421-4a9c-40c8-af49-c26181d7b1ec", + "x-ms-client-request-id": "903aec5eab806bc4938f9e74ab45934c" + }, + "ResponseBody": { + "participantId": "458cd853-3a2a-4cba-bb73-e86570c59f92" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/participants/458cd853-3a2a-4cba-bb73-e86570c59f92?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:20:22 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "13e2df785e4883d71883da171f5ce8aa", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:22 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:20:23 GMT", + "X-Azure-Ref": "0JpjJYAAAAACZN8SExMrNQpJifKyXZ37TV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "ac90b417-6b79-4f25-8082-187cef31bfc1", + "x-ms-client-request-id": "13e2df785e4883d71883da171f5ce8aa" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/86201300-42cd-440d-8c0c-9536b501ae43/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:20:34 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "79f77e6fc393d1d57ed049cf4193ee3b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:34 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:20:33 GMT", + "X-Azure-Ref": "0MpjJYAAAAAAjctD2KR8GQpby4gRy3IPBV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "e0e90ba5-2f82-4e21-baf6-825be0611d19", + "x-ms-client-request-id": "79f77e6fc393d1d57ed049cf4193ee3b" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/86201300-2cfb-4d0e-8db8-2e11a994b2ed/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:20:34 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f2a7acc728e1ffb914b777fdd1ad4c36", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:34 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:20:33 GMT", + "X-Azure-Ref": "0MpjJYAAAAABunbzxQG1rSq7EN/GQmG3ZV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "ec709066-aef6-41c1-9764-3bafa857452d", + "x-ms-client-request-id": "f2a7acc728e1ffb914b777fdd1ad4c36" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1522827907" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json new file mode 100644 index 0000000000000..44af6db5a4a3e --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreateAddRemoveHangupScenarioTestsAsync.json @@ -0,0 +1,210 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:20:35 GMT", + "traceparent": "00-f5557c794173be4a800f3f8e5e51f6f5-26cb1b99b9cb9348-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "1cdb28d9a82f6a18a79aa8ce818fde86", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:35 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:20:34 GMT", + "X-Azure-Ref": "0MpjJYAAAAABhEubOs9Y9SqXxYwfuovZNV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "d190e51d-23a8-4a17-a741-0a2c8ea30d12", + "x-ms-client-request-id": "1cdb28d9a82f6a18a79aa8ce818fde86" + }, + "ResponseBody": { + "callLegId": "86201300-2d08-48c7-bdcf-af606c040f6d", + "callConnectionId": "86201300-2d08-48c7-bdcf-af606c040f6d" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:20:36 GMT", + "traceparent": "00-72e30145c827ee4e9cb04cd030f8399d-c93bc30c2786a44b-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "c578aad863a3538dd12a8af51b75ea12", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:36 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:20:35 GMT", + "X-Azure-Ref": "0NJjJYAAAAABvqdnHxPu3RJEF6dgjpsWhV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "d4b4695d-26e1-487b-bd7a-f1b7d848176a", + "x-ms-client-request-id": "c578aad863a3538dd12a8af51b75ea12" + }, + "ResponseBody": { + "callLegId": "86201300-879b-4661-9077-38685652597f", + "callConnectionId": "86201300-879b-4661-9077-38685652597f" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/participants?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "208", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:20:47 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "a31a89405456b2bdaf8b092b273fd2c1", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:47 GMT" + }, + "RequestBody": { + "participant": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000a-b200-7a0d-570c-113a0d00288d" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "56", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:20:48 GMT", + "X-Azure-Ref": "0P5jJYAAAAAB1/E0yb6yRSJ6c/Ui8e57IV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "6a2130ee-3730-435e-beae-e0cdb9c61025", + "x-ms-client-request-id": "a31a89405456b2bdaf8b092b273fd2c1" + }, + "ResponseBody": { + "participantId": "15b87b6d-5e0b-421e-b5ad-9dd2e389eb8d" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/participants/15b87b6d-5e0b-421e-b5ad-9dd2e389eb8d?api-version=2021-06-15-preview", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:20:59 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "5de5d95fe3a475459b874b041d234e31", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:20:59 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:21:00 GMT", + "X-Azure-Ref": "0S5jJYAAAAAAAB7iunIIuQJ\u002B7ddnx4nfvV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "1fa79fa2-68ee-40ea-b2f7-a7a3a7f7f631", + "x-ms-client-request-id": "5de5d95fe3a475459b874b041d234e31" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/86201300-2d08-48c7-bdcf-af606c040f6d/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:21:12 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "f88d96af3b748330ecc6161759612c91", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:21:12 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:21:12 GMT", + "X-Azure-Ref": "0WJjJYAAAAACpoBkeTocASY2zUGtq21ioV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "626f001c-a86b-4a74-84f0-e8c4fc81774d", + "x-ms-client-request-id": "f88d96af3b748330ecc6161759612c91" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/86201300-879b-4661-9077-38685652597f/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:21:12 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "4296c9588d8f5d6e43a508ce08b9948c", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:21:12 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:21:12 GMT", + "X-Azure-Ref": "0WJjJYAAAAAAgESxYLSQBQ6hXzOnXabtoV1NURURHRTA4MDkAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "b61c4230-eaa0-4b96-86e8-915c92bc6e3b", + "x-ms-client-request-id": "4296c9588d8f5d6e43a508ce08b9948c" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "38775367" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTests.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTests.json new file mode 100644 index 0000000000000..968caf9814d31 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTests.json @@ -0,0 +1,249 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:47 GMT", + "traceparent": "00-8be82162454b314698037a2f1bffffef-5f4432689b885c4e-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "3eb76071115360cd27c4c26d83b4f8b4", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:47 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:46 GMT", + "X-Azure-Ref": "0T5fJYAAAAAB3DWWnUVthQpm/9ECHREOJV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "eee23c88-b4c7-427b-a442-339e4b0f90df", + "x-ms-client-request-id": "3eb76071115360cd27c4c26d83b4f8b4" + }, + "ResponseBody": { + "callLegId": "cd1f1300-00e2-4622-a7a4-7a12d92409fb", + "callConnectionId": "cd1f1300-00e2-4622-a7a4-7a12d92409fb" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:48 GMT", + "traceparent": "00-5fd283bbed687e45b0f37243d26b191a-0d540710af6f9248-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "7f29f5ce3a7b2111dd86b053335b9b2b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:48 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:48 GMT", + "X-Azure-Ref": "0UJfJYAAAAAD34t/8WEepT7hELT6lf6j5V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "01f7653d-f6b3-43e4-9e99-3cd144b802b8", + "x-ms-client-request-id": "7f29f5ce3a7b2111dd86b053335b9b2b" + }, + "ResponseBody": { + "callLegId": "cd1f1300-6e70-47db-9150-db14bc073cd9", + "callConnectionId": "cd1f1300-6e70-47db-9150-db14bc073cd9" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:playAudio?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "272", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:59 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "eed6d7747d179189096d4eee34e9d72d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:59 GMT" + }, + "RequestBody": { + "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", + "loop": false, + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", + "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c", + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "131", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:59 GMT", + "X-Azure-Ref": "0W5fJYAAAAACcNRW1MFJqRLstwg8m7FDRV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "58361be6-6845-48bb-b935-c0d7bbbd8db1", + "x-ms-client-request-id": "eed6d7747d179189096d4eee34e9d72d" + }, + "ResponseBody": { + "operationId": "cd1f1300-590a-4aaf-a4ef-94e82a361403", + "status": "running", + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-00e2-4622-a7a4-7a12d92409fb/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:17:11 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "72afde20e9a137734f9561cc61792ccb", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:11 GMT" + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:17:10 GMT", + "X-Azure-Ref": "0ZpfJYAAAAAD4xZGe86puRomNI0C/dJghV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "2da50efa-a0ea-47b5-af11-d5f19041c59a", + "x-ms-client-request-id": "72afde20e9a137734f9561cc61792ccb" + }, + "ResponseBody": { + "operationId": "27d17843-a7aa-48e3-9150-1cbb7161f95a", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-6e70-47db-9150-db14bc073cd9/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:17:11 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "acf9972809de519c6c98760eeb23edf3", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:11 GMT" + + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:17:10 GMT", + "X-Azure-Ref": "0Z5fJYAAAAACsLZ9zs/TOTbGMkqANyzYAV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "fb45eace-0a3f-46e1-8325-6fd28d6e906c", + "x-ms-client-request-id": "acf9972809de519c6c98760eeb23edf3" + }, + "ResponseBody": { + "operationId": "19e87892-9e86-48e9-9fbe-7eec9cd87b08", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-00e2-4622-a7a4-7a12d92409fb/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:17:21 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "553382af29ab8a89649e9f811bbc308f", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:21 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:17:20 GMT", + "X-Azure-Ref": "0cZfJYAAAAAB0roZUcRQ9Q4Dx\u002BxyJI/f2V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "1a9b14d0-061a-4c60-9faa-74f4c18d31ac", + "x-ms-client-request-id": "553382af29ab8a89649e9f811bbc308f" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-6e70-47db-9150-db14bc073cd9/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:17:21 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "9cc583412bef164f415e050973644c2b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:21 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:17:20 GMT", + "X-Azure-Ref": "0cZfJYAAAAABguzaZMdnPTZ77QW9PdIk3V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "252dba3f-afd9-403c-9026-5f1b093a166d", + "x-ms-client-request-id": "9cc583412bef164f415e050973644c2b" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1656122379" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json new file mode 100644 index 0000000000000..968caf9814d31 --- /dev/null +++ b/sdk/communication/Azure.Communication.CallingServer/tests/SessionRecords/ServerCallLiveTests/RunCreatePlayCancelHangupScenarioTestsAsync.json @@ -0,0 +1,249 @@ +{ + "Entries": [ + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:47 GMT", + "traceparent": "00-8be82162454b314698037a2f1bffffef-5f4432689b885c4e-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "3eb76071115360cd27c4c26d83b4f8b4", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:47 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2f23" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:46 GMT", + "X-Azure-Ref": "0T5fJYAAAAAB3DWWnUVthQpm/9ECHREOJV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "eee23c88-b4c7-427b-a442-339e4b0f90df", + "x-ms-client-request-id": "3eb76071115360cd27c4c26d83b4f8b4" + }, + "ResponseBody": { + "callLegId": "cd1f1300-00e2-4622-a7a4-7a12d92409fb", + "callConnectionId": "cd1f1300-00e2-4622-a7a4-7a12d92409fb" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:join?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "281", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:48 GMT", + "traceparent": "00-5fd283bbed687e45b0f37243d26b191a-0d540710af6f9248-00", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "7f29f5ce3a7b2111dd86b053335b9b2b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:48 GMT" + }, + "RequestBody": { + "source": { + "communicationUser": { + "id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_e3560385-776f-41d1-bf04-07ef738f2fc1" + } + }, + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld", + "requestedMediaTypes": [ + "audio" + ], + "requestedCallEvents": [ + "participantsUpdated" + ] + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "110", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:48 GMT", + "X-Azure-Ref": "0UJfJYAAAAAD34t/8WEepT7hELT6lf6j5V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "01f7653d-f6b3-43e4-9e99-3cd144b802b8", + "x-ms-client-request-id": "7f29f5ce3a7b2111dd86b053335b9b2b" + }, + "ResponseBody": { + "callLegId": "cd1f1300-6e70-47db-9150-db14bc073cd9", + "callConnectionId": "cd1f1300-6e70-47db-9150-db14bc073cd9" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/serverCalls/3500789f-e11b-4ceb-85cb-bc8df2a01768/:playAudio?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "272", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:16:59 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "eed6d7747d179189096d4eee34e9d72d", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:16:59 GMT" + }, + "RequestBody": { + "audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", + "loop": false, + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769", + "audioFileId": "ebb1d98d-fd86-4204-800c-f7bdfc2e515c", + "callbackUri": "https://dummy.ngrok.io/api/incident/callback?SecretKey=helloworld" + }, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "131", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:16:59 GMT", + "X-Azure-Ref": "0W5fJYAAAAACcNRW1MFJqRLstwg8m7FDRV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "58361be6-6845-48bb-b935-c0d7bbbd8db1", + "x-ms-client-request-id": "eed6d7747d179189096d4eee34e9d72d" + }, + "ResponseBody": { + "operationId": "cd1f1300-590a-4aaf-a4ef-94e82a361403", + "status": "running", + "operationContext": "de346f03-7f8d-41ab-a232-cc5e14990769" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-00e2-4622-a7a4-7a12d92409fb/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:17:11 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "72afde20e9a137734f9561cc61792ccb", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:11 GMT" + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:17:10 GMT", + "X-Azure-Ref": "0ZpfJYAAAAAD4xZGe86puRomNI0C/dJghV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "2da50efa-a0ea-47b5-af11-d5f19041c59a", + "x-ms-client-request-id": "72afde20e9a137734f9561cc61792ccb" + }, + "ResponseBody": { + "operationId": "27d17843-a7aa-48e3-9150-1cbb7161f95a", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-6e70-47db-9150-db14bc073cd9/:cancelAllMediaOperations?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "2", + "Content-Type": "application/json", + "Date": "Wed, 16 Jun 2021 06:17:11 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "acf9972809de519c6c98760eeb23edf3", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:11 GMT" + + }, + "RequestBody": {}, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "75", + "Content-Type": "application/json; charset=utf-8", + "Date": "Wed, 16 Jun 2021 06:17:10 GMT", + "X-Azure-Ref": "0Z5fJYAAAAACsLZ9zs/TOTbGMkqANyzYAV1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "fb45eace-0a3f-46e1-8325-6fd28d6e906c", + "x-ms-client-request-id": "acf9972809de519c6c98760eeb23edf3" + }, + "ResponseBody": { + "operationId": "19e87892-9e86-48e9-9fbe-7eec9cd87b08", + "status": "completed" + } + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-00e2-4622-a7a4-7a12d92409fb/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:17:21 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "553382af29ab8a89649e9f811bbc308f", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:21 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:17:20 GMT", + "X-Azure-Ref": "0cZfJYAAAAAB0roZUcRQ9Q4Dx\u002BxyJI/f2V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "1a9b14d0-061a-4c60-9faa-74f4c18d31ac", + "x-ms-client-request-id": "553382af29ab8a89649e9f811bbc308f" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://acstestbot1.communication.azure.com/calling/callConnections/cd1f1300-6e70-47db-9150-db14bc073cd9/:hangup?api-version=2021-06-15-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Date": "Wed, 16 Jun 2021 06:17:21 GMT", + "User-Agent": "azsdk-net-Communication.CallingServer/1.0.0-alpha.20210615.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19043 )", + "x-ms-client-request-id": "9cc583412bef164f415e050973644c2b", + "x-ms-content-sha256": "Sanitized", + "x-ms-return-client-request-id": "true", + "x-ms-date": "Wed, 16 Jun 2021 06:17:21 GMT" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 16 Jun 2021 06:17:20 GMT", + "X-Azure-Ref": "0cZfJYAAAAABguzaZMdnPTZ77QW9PdIk3V1NURURHRTA4MDgAOWZjN2I1MTktYThjYy00Zjg5LTkzNWUtYzkxNDhhZTA5ZTgx", + "X-Cache": "CONFIG_NOCACHE", + "X-Microsoft-Skype-Chain-ID": "252dba3f-afd9-403c-9026-5f1b093a166d", + "x-ms-client-request-id": "9cc583412bef164f415e050973644c2b" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING": "endpoint=https://acstestbot1.communication.azure.com/;accesskey=Kg==", + "RandomSeed": "1656122379" + } +} diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/samples/Sample1_CallClient.cs b/sdk/communication/Azure.Communication.CallingServer/tests/samples/Sample1_CallClient.cs index 34f38b4eebee0..900129d47850a 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/samples/Sample1_CallClient.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/samples/Sample1_CallClient.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Communication.Identity; using Azure.Core.TestFramework; @@ -21,26 +20,25 @@ public Sample1_CallClient(bool isAsync) : base(isAsync) [Test] [AsyncOnly] - [Ignore("Ignore for now as we get build errors that block checkingin.")] public async Task CreateCallAsync() { - CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.LiveTestDynamicConnectionString); + CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient(); var source = await communicationIdentityClient.CreateUserAsync(); - var targets = new List() { new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber) }; + var targets = new[] { new PhoneNumberIdentifier(TestEnvironment.TargetPhoneNumber) }; #region Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); #endregion Snippet:Azure_Communication_Call_Tests_CreateCallOptions - CallClient callClient = CreateInstrumentedCallingServerClient(); - Console.WriteLine("Performing CreateCall operation"); + CallingServerClient callingServerClient = CreateInstrumentedCallingServerClient(); + Console.WriteLine("Performing CreateCallConnection operation"); #region Snippet:Azure_Communication_Call_Tests_CreateCallAsync - CreateCallResponse createCallResponse = await callClient.CreateCallAsync( + var callConnection = await callingServerClient.CreateCallConnectionAsync( //@@ source: new CommunicationUserIdentifier(""), // Your Azure Communication Resource Guid Id used to make a Call //@@ targets: new List() { new PhoneNumberIdentifier("") }, // E.164 formatted recipient phone number //@@ options: createCallOption // The options for creating a call. @@ -48,29 +46,28 @@ public async Task CreateCallAsync() /*@@*/ targets: targets, /*@@*/ options: createCallOption ); - Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); + Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}"); #endregion Snippet:Azure_Communication_Call_Tests_CreateCallAsync } [Test] [SyncOnly] - [Ignore("Ignore for now as we get build errors that block checkingin.")] public void CreateCall() { - CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClient(TestEnvironment.LiveTestDynamicConnectionString); + CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient(); var source = communicationIdentityClient.CreateUser(); - var targets = new List() { new PhoneNumberIdentifier(TestEnvironment.SourcePhoneNumber) }; + var targets = new[] { new PhoneNumberIdentifier(TestEnvironment.TargetPhoneNumber) }; var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List { + new[] { MediaType.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived }); - CallClient callClient = CreateInstrumentedCallingServerClient(); - Console.WriteLine("Performing CreateCall operation"); + CallingServerClient callingServerClient = CreateInstrumentedCallingServerClient(); + Console.WriteLine("Performing CreateCallConnection operation"); #region Snippet:Azure_Communication_Call_Tests_CreateCall - CreateCallResponse createCallResponse = callClient.CreateCall( + var callConnection = callingServerClient.CreateCallConnection( //@@ source: new CommunicationUserIdentifier(""), // Your Azure Communication Resource Guid Id used to make a Call //@@ targets: new List() { new PhoneNumberIdentifier("") }, // E.164 formatted recipient phone number //@@ options: createCallOption // The options for creating a call. @@ -78,7 +75,7 @@ public void CreateCall() /*@@*/ targets: targets, /*@@*/ options: createCallOption ); - Console.WriteLine($"Call Leg id: {createCallResponse.CallLegId}"); + Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}"); #endregion Snippet:Azure_Communication_Call_Tests_CreateCall } }