Skip to content

Commit

Permalink
Zihzhan/fix (#21905)
Browse files Browse the repository at this point in the history
* Update Snippet and Export-API.

* remove calloption override in servercall client.

* Nit for params and arguments handling.

* Merge Downloader updates.

* Merge Downloader updates test cases.

* Update AutoGen Content.

* Nit clean on Unit Tests.

* Updating and renaming.

* Test update.

* Add Call Connection Live Tests.

* Add ServerCall Live Tests

* Increase Test Coverage.

* Reenable sample tests.
  • Loading branch information
zihzhan-msft authored Jun 16, 2021
1 parent 58ffcc3 commit 2e163e6
Show file tree
Hide file tree
Showing 35 changed files with 3,727 additions and 1,771 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ protected CallingServerClient() { }
public CallingServerClient(string connectionString, Azure.Communication.CallingServer.CallingServerClientOptions options = null) { }
public virtual Azure.Response<Azure.Communication.CallingServer.CallConnection> CreateCallConnection(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable<Azure.Communication.CommunicationIdentifier> targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CallingServer.CallConnection>> CreateCallConnectionAsync(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable<Azure.Communication.CommunicationIdentifier> targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<System.IO.Stream> 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<Azure.Response<System.IO.Stream>> 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<Azure.Response> 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<Azure.Response> 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<Azure.Communication.CallingServer.CallConnection> JoinCall(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down Expand Up @@ -204,15 +210,6 @@ public partial class CreateCallResult
internal CreateCallResult() { }
public string CallConnectionId { get { throw null; } }
}
public static partial class DownloadExtentions
{
public static Azure.Response<System.IO.Stream> DownloadStreaming(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task<Azure.Response<System.IO.Stream>> DownloadStreamingAsync(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, System.Uri sourceEndpoint, Azure.HttpRange range = default(Azure.HttpRange), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static Azure.Response DownloadTo(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, 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 static Azure.Response DownloadTo(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, 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 static System.Threading.Tasks.Task<Azure.Response> DownloadToAsync(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, 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 static System.Threading.Tasks.Task<Azure.Response> DownloadToAsync(this Azure.Communication.CallingServer.CallingServerClient callingServerClient, 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; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct EventSubscriptionType : System.IEquatable<Azure.Communication.CallingServer.EventSubscriptionType>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -44,14 +45,6 @@ private CallingServerClient(ConnectionString connectionString, CallingServerClie
: this(connectionString.GetRequired("endpoint"), options.BuildHttpPipeline(connectionString), options)
{ }

private CallingServerClient(string endpoint, TokenCredential tokenCredential, CallingServerClientOptions options)
: this(endpoint, options.BuildHttpPipeline(tokenCredential), options)
{ }

private CallingServerClient(string endpoint, AzureKeyCredential keyCredential, CallingServerClientOptions options)
: this(endpoint, options.BuildHttpPipeline(keyCredential), options)
{ }

private CallingServerClient(string endpoint, HttpPipeline httpPipeline, CallingServerClientOptions options)
{
_pipeline = httpPipeline;
Expand Down Expand Up @@ -275,5 +268,202 @@ public virtual ServerCall InitializeServerCall(string serverCallId)
throw;
}
}

/// <summary>
/// The <see cref="DownloadStreamingAsync(Uri, HttpRange, CancellationToken)"/>
/// operation downloads the recording's content.
///
/// </summary>
/// <param name="sourceEndpoint">
/// Recording's content's url location.
/// </param>
/// <param name="range">
/// If provided, only download the bytes of the content in the specified range.
/// If not provided, download the entire content.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response{Stream}"/> containing the
/// downloaded content.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
public virtual async Task<Response<Stream>> DownloadStreamingAsync(
Uri sourceEndpoint,
HttpRange range = default,
CancellationToken cancellationToken = default) =>
await _contentDownloader.DownloadStreamingInternal(
sourceEndpoint,
range,
async: true,
cancellationToken)
.ConfigureAwait(false);

/// <summary>
/// The <see cref="DownloadStreaming(Uri, HttpRange, CancellationToken)"/>
/// operation downloads the recording's content.
///
/// </summary>
/// <param name="sourceEndpoint">
/// Recording's content's url location.
/// </param>
/// <param name="range">
/// If provided, only download the bytes of the content in the specified range.
/// If not provided, download the entire content.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response{Stream}"/> containing the
/// downloaded content.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
public virtual Response<Stream> DownloadStreaming(
Uri sourceEndpoint,
HttpRange range = default,
CancellationToken cancellationToken = default) =>
_contentDownloader.DownloadStreamingInternal(
sourceEndpoint,
range,
async: false,
cancellationToken)
.EnsureCompleted();

/// <summary>
/// The <see cref="DownloadTo(Uri, Stream, ContentTransferOptions, CancellationToken)"/>
/// operation downloads the specified content using parallel requests,
/// and writes the content to <paramref name="destinationStream"/>.
/// </summary>
/// <param name="sourceEndpoint">
/// A <see cref="Uri"/> with the Recording's content's url location.
/// </param>
/// <param name="destinationStream">
/// A <see cref="Stream"/> to write the downloaded content to.
/// </param>
/// <param name="transferOptions">
/// Optional <see cref="ContentTransferOptions"/> to configure
/// parallel transfer behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response"/> describing the operation.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
public virtual Response DownloadTo(Uri sourceEndpoint, Stream destinationStream,
ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) =>
_contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: false, cancellationToken: cancellationToken).EnsureCompleted();

/// <summary>
/// The <see cref="DownloadToAsync(Uri, Stream, ContentTransferOptions, CancellationToken)"/>
/// operation downloads the specified content using parallel requests,
/// and writes the content to <paramref name="destinationStream"/>.
/// </summary>
/// <param name="sourceEndpoint">
/// A <see cref="Uri"/> with the Recording's content's url location.
/// </param>
/// <param name="destinationStream">
/// A <see cref="Stream"/> to write the downloaded content to.
/// </param>
/// <param name="transferOptions">
/// Optional <see cref="ContentTransferOptions"/> to configure
/// parallel transfer behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response"/> describing the operation.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
public virtual async Task<Response> DownloadToAsync(Uri sourceEndpoint, Stream destinationStream, ContentTransferOptions transferOptions = default, CancellationToken cancellationToken = default) =>
await _contentDownloader.StagedDownloadAsync(sourceEndpoint, destinationStream, transferOptions, async: true, cancellationToken: cancellationToken).ConfigureAwait(false);

/// <summary>
/// The <see cref="DownloadTo(Uri, string, ContentTransferOptions, CancellationToken)"/>
/// operation downloads the specified content using parallel requests,
/// and writes the content to <paramref name="destinationPath"/>.
/// </summary>
/// <param name="sourceEndpoint">
/// A <see cref="Uri"/> with the Recording's content's url location.
/// </param>
/// <param name="destinationPath">
/// A file path to write the downloaded content to.
/// </param>
/// <param name="transferOptions">
/// Optional <see cref="ContentTransferOptions"/> to configure
/// parallel transfer behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response"/> describing the operation.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
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();
}

/// <summary>
/// The <see cref="DownloadToAsync(Uri, string, ContentTransferOptions, CancellationToken)"/>
/// operation downloads the specified content using parallel requests,
/// and writes the content to <paramref name="destinationPath"/>.
/// </summary>
/// <param name="sourceEndpoint">
/// A <see cref="Uri"/> with the Recording's content's url location.
/// </param>
/// <param name="destinationPath">
/// A file path to write the downloaded content to.
/// </param>
/// <param name="transferOptions">
/// Optional <see cref="ContentTransferOptions"/> to configure
/// parallel transfer behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>
/// A <see cref="Response"/> describing the operation.
/// </returns>
/// <remarks>
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
public virtual async Task<Response> 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);
}
}
}
Loading

0 comments on commit 2e163e6

Please sign in to comment.