Skip to content

Commit

Permalink
.NET SDK Resource Provider:'ComputerVision'
Browse files Browse the repository at this point in the history
REST Spec PR 'Azure/azure-rest-api-specs#5721'
REST Spec PR Author 'toothache'
REST Spec PR Last commit
  • Loading branch information
adxsdknet committed Apr 22, 2019
1 parent e85db9b commit 9991dbb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,10 @@ private void Initialize()
/// 'Operation-Location' field contains the URL that you must use for your
/// 'GetReadOperationResult' operation to access OCR results.​
/// </summary>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='url'>
/// Publicly reachable URL of an image.
/// </param>
Expand All @@ -2250,7 +2254,7 @@ private void Initialize()
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationHeaderResponse<BatchReadFileHeaders>> BatchReadFileWithHttpMessagesAsync(string url, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationHeaderResponse<BatchReadFileHeaders>> BatchReadFileWithHttpMessagesAsync(string url, TextRecognitionMode mode, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
Expand All @@ -2272,6 +2276,7 @@ private void Initialize()
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("mode", mode);
tracingParameters.Add("imageUrl", imageUrl);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "BatchReadFile", tracingParameters);
Expand All @@ -2280,6 +2285,12 @@ private void Initialize()
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "read/core/asyncBatchAnalyze";
_url = _url.Replace("{Endpoint}", Endpoint);
List<string> _queryParameters = new List<string>();
_queryParameters.Add(string.Format("mode={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(mode, SerializationSettings).Trim('"'))));
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
}
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down Expand Up @@ -4231,6 +4242,10 @@ private void Initialize()
/// <param name='image'>
/// An image stream.
/// </param>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -4249,7 +4264,7 @@ private void Initialize()
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationHeaderResponse<BatchReadFileInStreamHeaders>> BatchReadFileInStreamWithHttpMessagesAsync(Stream image, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationHeaderResponse<BatchReadFileInStreamHeaders>> BatchReadFileInStreamWithHttpMessagesAsync(Stream image, TextRecognitionMode mode, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
Expand All @@ -4267,13 +4282,20 @@ private void Initialize()
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("image", image);
tracingParameters.Add("mode", mode);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "BatchReadFileInStream", tracingParameters);
}
// Construct URL
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "read/core/asyncBatchAnalyze";
_url = _url.Replace("{Endpoint}", Endpoint);
List<string> _queryParameters = new List<string>();
_queryParameters.Add(string.Format("mode={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(mode, SerializationSettings).Trim('"'))));
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
}
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,19 @@ public static partial class ComputerVisionClientExtensions
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='url'>
/// Publicly reachable URL of an image.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<BatchReadFileHeaders> BatchReadFileAsync(this IComputerVisionClient operations, string url, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<BatchReadFileHeaders> BatchReadFileAsync(this IComputerVisionClient operations, string url, TextRecognitionMode mode, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.BatchReadFileWithHttpMessagesAsync(url, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.BatchReadFileWithHttpMessagesAsync(url, mode, null, cancellationToken).ConfigureAwait(false))
{
return _result.Headers;
}
Expand Down Expand Up @@ -796,12 +800,16 @@ public static partial class ComputerVisionClientExtensions
/// <param name='image'>
/// An image stream.
/// </param>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<BatchReadFileInStreamHeaders> BatchReadFileInStreamAsync(this IComputerVisionClient operations, Stream image, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<BatchReadFileInStreamHeaders> BatchReadFileInStreamAsync(this IComputerVisionClient operations, Stream image, TextRecognitionMode mode, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.BatchReadFileInStreamWithHttpMessagesAsync(image, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.BatchReadFileInStreamWithHttpMessagesAsync(image, mode, null, cancellationToken).ConfigureAwait(false))
{
return _result.Headers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ public partial interface IComputerVisionClient : System.IDisposable
/// URL that you must use for your 'GetReadOperationResult' operation
/// to access OCR results.​
/// </summary>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='url'>
/// Publicly reachable URL of an image.
/// </param>
Expand All @@ -397,7 +401,7 @@ public partial interface IComputerVisionClient : System.IDisposable
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationHeaderResponse<BatchReadFileHeaders>> BatchReadFileWithHttpMessagesAsync(string url, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationHeaderResponse<BatchReadFileHeaders>> BatchReadFileWithHttpMessagesAsync(string url, TextRecognitionMode mode, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// This interface is used for getting OCR results of Read operation.
Expand Down Expand Up @@ -716,13 +720,17 @@ public partial interface IComputerVisionClient : System.IDisposable
/// <param name='image'>
/// An image stream.
/// </param>
/// <param name='mode'>
/// Type of text to recognize. Possible values include: 'Handwritten',
/// 'Printed'
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationHeaderResponse<BatchReadFileInStreamHeaders>> BatchReadFileInStreamWithHttpMessagesAsync(Stream image, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationHeaderResponse<BatchReadFileInStreamHeaders>> BatchReadFileInStreamWithHttpMessagesAsync(Stream image, TextRecognitionMode mode, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));

}
}

0 comments on commit 9991dbb

Please sign in to comment.