Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Model name updates (Suffix for responses models now has Result), other fixes based on comments #21790

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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 `ServerCallingClient`

Server Calling clients can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
Expand Down Expand Up @@ -84,7 +83,7 @@ public virtual Response Hangup(CancellationToken cancellationToken = default)
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual async Task<Response<CancelAllMediaOperationsResponse>> CancelAllMediaOperationsAsync(string operationContext = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<CancelAllMediaOperationsResult>> CancelAllMediaOperationsAsync(string operationContext = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(CancelAllMediaOperations)}");
scope.Start();
Expand All @@ -107,7 +106,7 @@ public virtual async Task<Response<CancelAllMediaOperationsResponse>> CancelAllM
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual Response<CancelAllMediaOperationsResponse> CancelAllMediaOperations(string operationContext = null, CancellationToken cancellationToken = default)
public virtual Response<CancelAllMediaOperationsResult> CancelAllMediaOperations(string operationContext = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(CancelAllMediaOperations)}");
scope.Start();
Expand All @@ -134,7 +133,7 @@ public virtual Response<CancelAllMediaOperationsResponse> CancelAllMediaOperatio
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<PlayAudioResult>> PlayAudioAsync(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
=> await PlayAudioAsync(
options: new PlayAudioOptions {
AudioFileUri = audioFileUri,
Expand All @@ -151,7 +150,7 @@ public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(Uri audioF
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(PlayAudioOptions options, CancellationToken cancellationToken = default)
public virtual async Task<Response<PlayAudioResult>> PlayAudioAsync(PlayAudioOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(PlayAudio)}");
scope.Start();
Expand Down Expand Up @@ -184,7 +183,7 @@ public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(PlayAudioO
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual Response<PlayAudioResponse> PlayAudio(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
public virtual Response<PlayAudioResult> PlayAudio(Uri audioFileUri, bool? loop, string audioFileId, Uri callbackUri, string operationContext = null, CancellationToken cancellationToken = default)
=> PlayAudio(
options: new PlayAudioOptions {
AudioFileUri = audioFileUri,
Expand All @@ -201,7 +200,7 @@ public virtual Response<PlayAudioResponse> PlayAudio(Uri audioFileUri, bool? loo
/// <param name="cancellationToken"> The cancellation token. </param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <exception cref="ArgumentNullException"> <paramref name="options"/> is null. </exception>
public virtual Response<PlayAudioResponse> PlayAudio(PlayAudioOptions options, CancellationToken cancellationToken = default)
public virtual Response<PlayAudioResult> PlayAudio(PlayAudioOptions options, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(PlayAudio)}");
scope.Start();
Expand Down Expand Up @@ -243,7 +242,7 @@ public virtual async Task<Response> AddParticipantAsync(CommunicationIdentifier

return await RestClient.InviteParticipantsAsync(
callConnectionId: CallConnectionId,
participants: new List<CommunicationIdentifierModel>() { CommunicationIdentifierSerializer.Serialize(participant) },
participants: new[] { CommunicationIdentifierSerializer.Serialize(participant) },
alternateCallerId: alternateCallerId == null ? null : new PhoneNumberIdentifierModel(alternateCallerId),
operationContext: operationContext,
callbackUri: null,
Expand Down Expand Up @@ -274,7 +273,7 @@ public virtual Response AddParticipant(CommunicationIdentifier participant, stri

return RestClient.InviteParticipants(
callConnectionId: CallConnectionId,
participants: new List<CommunicationIdentifierModel>() { CommunicationIdentifierSerializer.Serialize(participant) },
participants: new[] { CommunicationIdentifierSerializer.Serialize(participant) },
alternateCallerId: alternateCallerId == null ? null : new PhoneNumberIdentifierModel(alternateCallerId),
operationContext: operationContext,
callbackUri: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CallingServerClient
internal CallConnectionRestClient CallConnectionRestClient { get; }
internal ServerCallRestClient ServerCallRestClient { get; }

#region public constructors - all arguments need null check
#region public constructors

/// <summary> Initializes a new instance of <see cref="CallingServerClient"/>.</summary>
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
Expand All @@ -36,28 +36,6 @@ public CallingServerClient(string connectionString, CallingServerClientOptions o
options ?? new CallingServerClientOptions())
{ }

/// <summary> Initializes a new instance of <see cref="CallingServerClient"/>.</summary>
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
/// <param name="keyCredential">The <see cref="AzureKeyCredential"/> used to authenticate requests.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
public CallingServerClient(Uri endpoint, AzureKeyCredential keyCredential, CallingServerClientOptions options = default)
: this(
Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri,
Argument.CheckNotNull(keyCredential, nameof(keyCredential)),
options ?? new CallingServerClientOptions())
{ }

/// <summary> Initializes a new instance of <see cref="CallingServerClient"/>.</summary>
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
/// <param name="tokenCredential">The TokenCredential used to authenticate requests, such as DefaultAzureCredential.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
public CallingServerClient(Uri endpoint, TokenCredential tokenCredential, CallingServerClientOptions options = default)
: this(
Argument.CheckNotNull(endpoint, nameof(endpoint)).AbsoluteUri,
Argument.CheckNotNull(tokenCredential, nameof(tokenCredential)),
options ?? new CallingServerClientOptions())
{ }

#endregion

#region private constructors
Expand Down Expand Up @@ -188,9 +166,9 @@ public virtual Response<CallConnection> CreateCallConnection(CommunicationIdenti
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="serverCallId"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
public virtual async Task<Response<CallConnection>> JoinCallConnectionAsync(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
public virtual async Task<Response<CallConnection>> JoinCallAsync(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCallConnection)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCall)}");
scope.Start();
try
{
Expand Down Expand Up @@ -227,9 +205,9 @@ public virtual async Task<Response<CallConnection>> JoinCallConnectionAsync(stri
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="serverCallId"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
public virtual Response<CallConnection> JoinCallConnection(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
public virtual Response<CallConnection> JoinCall(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCallConnection)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCall)}");
scope.Start();
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CallingServerClientOptions : ClientOptions
/// <summary>
/// The latest version of the CallingServer service.
/// </summary>
public const ServiceVersion LatestVersion = ServiceVersion.V2021_06_15_Preview;
internal const ServiceVersion LatestVersion = ServiceVersion.V2021_06_15_Preview;

internal string ApiVersion { get; }

Expand Down
Loading