diff --git a/SDKs/_metadata/cognitiveservices_data-plane_FormRecognizer.txt b/SDKs/_metadata/cognitiveservices_data-plane_FormRecognizer.txt new file mode 100644 index 000000000000..4a450476275e --- /dev/null +++ b/SDKs/_metadata/cognitiveservices_data-plane_FormRecognizer.txt @@ -0,0 +1,14 @@ +Installing AutoRest version: latest +AutoRest installed successfully. +Commencing code generation +Generating CSharp code +Executing AutoRest command +cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/cognitiveservices/data-plane/FormRecognizer/readme.md --csharp --version=latest --reflect-api-versions --csharp.output-folder=D:\temp\cognitiveservices\Vision.FormRecognizer\src +2019-05-31 12:25:41 UTC +Azure-rest-api-specs repository information +GitHub fork: Azure +Branch: master +Commit: 1e497e5bc4f055f1e890001f254f4c9892f2287b +AutoRest information +Requested version: latest +Bootstrapper version: autorest@2.0.4283 diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/ElementReference.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/ElementReference.cs new file mode 100644 index 000000000000..eae28872f197 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/ElementReference.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class ElementReference { + private string _resolvedRefProperty = null; + private int _pageIndex; + private int _lineIndex; + private int _wordIndex; + + /// + /// Number of the page containing the element. + /// + public int Page { get { Resolve(); return _pageIndex + 1; } } + + /// + /// Index of the page containing the element (0-indexed). + /// + public int PageIndex { get { Resolve(); return _pageIndex; } } + + /// + /// Index of the line within the page containing the element (0-indexed). + /// + public int LineIndex { get { Resolve(); return _lineIndex; } } + + /// + /// Index of the word within the line containing the element (0-indexed). + /// + public int WordIndex { get { Resolve(); return _wordIndex; } } + + /// + /// Returns the word referenced by the JSON pointer element reference. + /// + public Word ResolveWord(ReadReceiptResult result) + { + try + { + return result.RecognitionResults[PageIndex].Lines[LineIndex].Words[WordIndex]; + } + catch (Exception e) + { + //throw new ArgumentException("Invalid element reference."); + throw new ArgumentException("Invalid element reference, {0}", e); + } + } + + private void Resolve() + { + if (_resolvedRefProperty != RefProperty) + { + var match = Regex.Match(RefProperty, @"^#/recognitionResults/(\d+)/lines/(\d+)/words/(\d+)$"); + if (!match.Success) + { + throw new ArgumentException("Invalid element reference."); + } + _pageIndex = int.Parse(match.Groups[1].Value); + _lineIndex = int.Parse(match.Groups[2].Value); + _wordIndex = int.Parse(match.Groups[3].Value); + _resolvedRefProperty = RefProperty; + } + } + } +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/FormRecognizerClient2.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/FormRecognizerClient2.cs index c5031ac4ad43..c3a00954e03f 100644 --- a/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/FormRecognizerClient2.cs +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Customizations/FormRecognizerClient2.cs @@ -31,6 +31,13 @@ public static partial class FormRecognizerClientExtensions public partial class FormRecognizerClient : ServiceClient, IFormRecognizerClient { + partial void CustomInitialize() + { + // Disable metadata property handling when de/serializing models so we can properly support "$ref" in ElementReference. + SerializationSettings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore; + DeserializationSettings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore; + } + public async Task> AnalyzeWithCustomModelWithHttpMessagesAsync2(System.Guid id, Stream formStream, IList keys = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken), string contentType = "application/pdf") { if (Endpoint == null) diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClient.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClient.cs index 7e2adf59e86e..e1e7a641eae6 100644 --- a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClient.cs +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClient.cs @@ -23,10 +23,6 @@ namespace Microsoft.Azure.CognitiveServices.FormRecognizer using System.Threading; using System.Threading.Tasks; - /// - /// Extracts information from forms and images into structured data based - /// on a model created by a set of representative training forms. - /// public partial class FormRecognizerClient : ServiceClient, IFormRecognizerClient { /// @@ -208,23 +204,27 @@ private void Initialize() new Iso8601TimeSpanConverter() } }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("valueType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("valueType")); CustomInitialize(); } /// /// Train Model /// /// - /// The train request must include a source parameter that is either an - /// externally accessible Azure Storage blob container Uri (preferably a Shared - /// Access Signature Uri) or valid path to a data folder in a locally mounted - /// drive. When local paths are specified, they must follow the Linux/Unix path - /// format and be an absolute path rooted to the input mount configuration + /// Create and train a custom model. The train request must include a source + /// parameter that is either an externally accessible Azure Storage blob + /// container Uri (preferably a Shared Access Signature Uri) or valid path to a + /// data folder in a locally mounted drive. When local paths are specified, + /// they must follow the Linux/Unix path format and be an absolute path rooted + /// to the input mount configuration /// setting value e.g., if '{Mounts:Input}' configuration setting value is /// '/input' then a valid source path would be '/input/contosodataset'. All - /// data to be trained are expected to be under the source. Models are trained - /// using documents that are of the following content type - 'application/pdf', - /// 'image/jpeg' and 'image/png'." - /// Other content is ignored when training a model. + /// data to be trained is expected to be directly under the source folder. + /// Subfolders are not supported. Models are trained using documents that are + /// of the following content type - 'application/pdf', 'image/jpeg' and + /// 'image/png'." + /// Other type of content is ignored. /// /// /// Request object for training. @@ -389,8 +389,8 @@ private void Initialize() /// Get Keys /// /// - /// Use the API to retrieve the keys that were - /// extracted by the specified model. + /// Retrieve the keys that were + /// extracted during the training of the specified model. /// /// /// Model identifier. @@ -542,7 +542,7 @@ private void Initialize() /// Get Models /// /// - /// Get information about all trained models + /// Get information about all trained custom models /// /// /// Headers that will be added to request. @@ -972,10 +972,9 @@ private void Initialize() /// Analyze Form /// /// - /// The document to analyze must be of a supported content type - - /// 'application/pdf', 'image/jpeg' or 'image/png'. The response contains not - /// just the extracted information of the analyzed form but also information - /// about content that was not extracted along with a reason. + /// Extract key-value pairs from a given document. The input document must be + /// of one of the supported content types - 'application/pdf', 'image/jpeg' or + /// 'image/png'. A success response is returned in JSON. /// /// /// Model Identifier to analyze the document with. @@ -1168,5 +1167,475 @@ private void Initialize() return _result; } + /// + /// Batch Read Receipt operation. The response contains a field called + /// 'Operation-Location', which contains the URL that you must use for your + /// 'Get Read Receipt Result' operation. + /// + /// + /// Publicly reachable URL of an image. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BatchReadReceiptWithHttpMessagesAsync(string url, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint"); + } + if (url == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "url"); + } + ImageUrl imageUrl = new ImageUrl(); + if (url != null) + { + imageUrl.Url = url; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("imageUrl", imageUrl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BatchReadReceipt", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "prebuilt/receipt/asyncBatchAnalyze"; + _url = _url.Replace("{Endpoint}", Endpoint); + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(imageUrl != null) + { + _requestContent = SafeJsonConvert.SerializeObject(imageUrl, SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202) + { + var ex = new ComputerVisionErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ComputerVisionError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// This interface is used for getting the analysis results of a 'Batch Read + /// Receipt' operation. The URL to this interface should be retrieved from the + /// 'Operation-Location' field returned from the 'Batch Read Receipt' + /// operation. + /// + /// + /// Id of read operation returned in the response of a 'Batch Read Receipt' + /// operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetReadReceiptResultWithHttpMessagesAsync(string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetReadReceiptResult", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "prebuilt/receipt/operations/{operationId}"; + _url = _url.Replace("{Endpoint}", Endpoint); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ComputerVisionErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ComputerVisionError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Read Receipt operation. When you use the 'Batch Read Receipt' interface, + /// the response contains a field called 'Operation-Location'. The + /// 'Operation-Location' field contains the URL that you must use for your 'Get + /// Read Receipt Result' operation. + /// + /// + /// An image stream. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BatchReadReceiptInStreamWithHttpMessagesAsync(Stream image, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint"); + } + if (image == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "image"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("image", image); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BatchReadReceiptInStream", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "prebuilt/receipt/asyncBatchAnalyze"; + _url = _url.Replace("{Endpoint}", Endpoint); + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(image == null) + { + throw new System.ArgumentNullException("image"); + } + if (image != null && image != Stream.Null) + { + _httpRequest.Content = new StreamContent(image); + _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/octet-stream"); + } + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202) + { + var ex = new ComputerVisionErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ComputerVisionError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClientExtensions.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClientExtensions.cs index 8b1b2e2c8498..9197c561a5bf 100644 --- a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClientExtensions.cs +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/FormRecognizerClientExtensions.cs @@ -26,17 +26,19 @@ public static partial class FormRecognizerClientExtensions /// Train Model /// /// - /// The train request must include a source parameter that is either an - /// externally accessible Azure Storage blob container Uri (preferably a Shared - /// Access Signature Uri) or valid path to a data folder in a locally mounted - /// drive. When local paths are specified, they must follow the Linux/Unix path - /// format and be an absolute path rooted to the input mount configuration + /// Create and train a custom model. The train request must include a source + /// parameter that is either an externally accessible Azure Storage blob + /// container Uri (preferably a Shared Access Signature Uri) or valid path to a + /// data folder in a locally mounted drive. When local paths are specified, + /// they must follow the Linux/Unix path format and be an absolute path rooted + /// to the input mount configuration /// setting value e.g., if '{Mounts:Input}' configuration setting value is /// '/input' then a valid source path would be '/input/contosodataset'. All - /// data to be trained are expected to be under the source. Models are trained - /// using documents that are of the following content type - 'application/pdf', - /// 'image/jpeg' and 'image/png'." - /// Other content is ignored when training a model. + /// data to be trained is expected to be directly under the source folder. + /// Subfolders are not supported. Models are trained using documents that are + /// of the following content type - 'application/pdf', 'image/jpeg' and + /// 'image/png'." + /// Other type of content is ignored. /// /// /// The operations group for this extension method. @@ -59,8 +61,8 @@ public static partial class FormRecognizerClientExtensions /// Get Keys /// /// - /// Use the API to retrieve the keys that were - /// extracted by the specified model. + /// Retrieve the keys that were + /// extracted during the training of the specified model. /// /// /// The operations group for this extension method. @@ -83,7 +85,7 @@ public static partial class FormRecognizerClientExtensions /// Get Models /// /// - /// Get information about all trained models + /// Get information about all trained custom models /// /// /// The operations group for this extension method. @@ -146,10 +148,9 @@ public static partial class FormRecognizerClientExtensions /// Analyze Form /// /// - /// The document to analyze must be of a supported content type - - /// 'application/pdf', 'image/jpeg' or 'image/png'. The response contains not - /// just the extracted information of the analyzed form but also information - /// about content that was not extracted along with a reason. + /// Extract key-value pairs from a given document. The input document must be + /// of one of the supported content types - 'application/pdf', 'image/jpeg' or + /// 'image/png'. A success response is returned in JSON. /// /// /// The operations group for this extension method. @@ -174,5 +175,74 @@ public static partial class FormRecognizerClientExtensions } } + /// + /// Batch Read Receipt operation. The response contains a field called + /// 'Operation-Location', which contains the URL that you must use for your + /// 'Get Read Receipt Result' operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Publicly reachable URL of an image. + /// + /// + /// The cancellation token. + /// + public static async Task BatchReadReceiptAsync(this IFormRecognizerClient operations, string url, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BatchReadReceiptWithHttpMessagesAsync(url, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// This interface is used for getting the analysis results of a 'Batch Read + /// Receipt' operation. The URL to this interface should be retrieved from the + /// 'Operation-Location' field returned from the 'Batch Read Receipt' + /// operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Id of read operation returned in the response of a 'Batch Read Receipt' + /// operation. + /// + /// + /// The cancellation token. + /// + public static async Task GetReadReceiptResultAsync(this IFormRecognizerClient operations, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetReadReceiptResultWithHttpMessagesAsync(operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Read Receipt operation. When you use the 'Batch Read Receipt' interface, + /// the response contains a field called 'Operation-Location'. The + /// 'Operation-Location' field contains the URL that you must use for your 'Get + /// Read Receipt Result' operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// An image stream. + /// + /// + /// The cancellation token. + /// + public static async Task BatchReadReceiptInStreamAsync(this IFormRecognizerClient operations, Stream image, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BatchReadReceiptInStreamWithHttpMessagesAsync(image, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + } } diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/IFormRecognizerClient.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/IFormRecognizerClient.cs index 80bb602c909d..977cec877cf6 100644 --- a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/IFormRecognizerClient.cs +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/IFormRecognizerClient.cs @@ -20,8 +20,6 @@ namespace Microsoft.Azure.CognitiveServices.FormRecognizer using System.Threading.Tasks; /// - /// Extracts information from forms and images into structured data based - /// on a model created by a set of representative training forms. /// public partial interface IFormRecognizerClient : System.IDisposable { @@ -56,19 +54,20 @@ public partial interface IFormRecognizerClient : System.IDisposable /// Train Model /// /// - /// The train request must include a source parameter that is either an - /// externally accessible Azure Storage blob container Uri (preferably - /// a Shared Access Signature Uri) or valid path to a data folder in a - /// locally mounted drive. When local paths are specified, they must - /// follow the Linux/Unix path format and be an absolute path rooted to - /// the input mount configuration + /// Create and train a custom model. The train request must include a + /// source parameter that is either an externally accessible Azure + /// Storage blob container Uri (preferably a Shared Access Signature + /// Uri) or valid path to a data folder in a locally mounted drive. + /// When local paths are specified, they must follow the Linux/Unix + /// path format and be an absolute path rooted to the input mount + /// configuration /// setting value e.g., if '{Mounts:Input}' configuration setting value /// is '/input' then a valid source path would be - /// '/input/contosodataset'. All data to be trained are expected to be - /// under the source. Models are trained using documents that are of - /// the following content type - 'application/pdf', 'image/jpeg' and - /// 'image/png'." - /// Other content is ignored when training a model. + /// '/input/contosodataset'. All data to be trained is expected to be + /// directly under the source folder. Subfolders are not supported. + /// Models are trained using documents that are of the following + /// content type - 'application/pdf', 'image/jpeg' and 'image/png'." + /// Other type of content is ignored. /// /// /// Request object for training. @@ -85,8 +84,8 @@ public partial interface IFormRecognizerClient : System.IDisposable /// Get Keys /// /// - /// Use the API to retrieve the keys that were - /// extracted by the specified model. + /// Retrieve the keys that were + /// extracted during the training of the specified model. /// /// /// Model identifier. @@ -103,7 +102,7 @@ public partial interface IFormRecognizerClient : System.IDisposable /// Get Models /// /// - /// Get information about all trained models + /// Get information about all trained custom models /// /// /// The headers that will be added to request. @@ -151,11 +150,10 @@ public partial interface IFormRecognizerClient : System.IDisposable /// Analyze Form /// /// - /// The document to analyze must be of a supported content type - - /// 'application/pdf', 'image/jpeg' or 'image/png'. The response - /// contains not just the extracted information of the analyzed form - /// but also information about content that was not extracted along - /// with a reason. + /// Extract key-value pairs from a given document. The input document + /// must be of one of the supported content types - 'application/pdf', + /// 'image/jpeg' or 'image/png'. A success response is returned in + /// JSON. /// /// /// Model Identifier to analyze the document with. @@ -174,5 +172,56 @@ public partial interface IFormRecognizerClient : System.IDisposable /// Task> AnalyzeWithCustomModelWithHttpMessagesAsync(System.Guid id, Stream formStream, IList keys = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Batch Read Receipt operation. The response contains a field called + /// 'Operation-Location', which contains the URL that you must use for + /// your 'Get Read Receipt Result' operation. + /// + /// + /// Publicly reachable URL of an image. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> BatchReadReceiptWithHttpMessagesAsync(string url, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// This interface is used for getting the analysis results of a 'Batch + /// Read Receipt' operation. The URL to this interface should be + /// retrieved from the 'Operation-Location' field returned from the + /// 'Batch Read Receipt' operation. + /// + /// + /// Id of read operation returned in the response of a 'Batch Read + /// Receipt' operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> GetReadReceiptResultWithHttpMessagesAsync(string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Read Receipt operation. When you use the 'Batch Read Receipt' + /// interface, the response contains a field called + /// 'Operation-Location'. The 'Operation-Location' field contains the + /// URL that you must use for your 'Get Read Receipt Result' operation. + /// + /// + /// An image stream. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> BatchReadReceiptInStreamWithHttpMessagesAsync(Stream image, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } } diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptHeaders.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptHeaders.cs new file mode 100644 index 000000000000..3b46ac991c22 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptHeaders.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for BatchReadReceipt operation. + /// + public partial class BatchReadReceiptHeaders + { + /// + /// Initializes a new instance of the BatchReadReceiptHeaders class. + /// + public BatchReadReceiptHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BatchReadReceiptHeaders class. + /// + /// URL to query for status of the + /// operation. The URL will expire in 48 hours. + public BatchReadReceiptHeaders(string operationLocation = default(string)) + { + OperationLocation = operationLocation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to query for status of the operation. The URL will + /// expire in 48 hours. + /// + [JsonProperty(PropertyName = "Operation-Location")] + public string OperationLocation { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptInStreamHeaders.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptInStreamHeaders.cs new file mode 100644 index 000000000000..dea20a9ee723 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/BatchReadReceiptInStreamHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for BatchReadReceiptInStream operation. + /// + public partial class BatchReadReceiptInStreamHeaders + { + /// + /// Initializes a new instance of the BatchReadReceiptInStreamHeaders + /// class. + /// + public BatchReadReceiptInStreamHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BatchReadReceiptInStreamHeaders + /// class. + /// + /// URL to query for status of the + /// operation. The URL will expire in 48 hours. + public BatchReadReceiptInStreamHeaders(string operationLocation = default(string)) + { + OperationLocation = operationLocation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to query for status of the operation. The URL will + /// expire in 48 hours. + /// + [JsonProperty(PropertyName = "Operation-Location")] + public string OperationLocation { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionError.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionError.cs new file mode 100644 index 000000000000..819bc9dd0be2 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionError.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details about the API request error. + /// + public partial class ComputerVisionError + { + /// + /// Initializes a new instance of the ComputerVisionError class. + /// + public ComputerVisionError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ComputerVisionError class. + /// + /// The error code. + /// A message explaining the error reported by + /// the service. + /// A unique request identifier. + public ComputerVisionError(object code, string message, string requestId = default(string)) + { + Code = code; + Message = message; + RequestId = requestId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error code. + /// + [JsonProperty(PropertyName = "code")] + public object Code { get; set; } + + /// + /// Gets or sets a message explaining the error reported by the + /// service. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets a unique request identifier. + /// + [JsonProperty(PropertyName = "requestId")] + public string RequestId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Code == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Code"); + } + if (Message == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); + } + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionErrorException.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionErrorException.cs new file mode 100644 index 000000000000..c33c5041defb --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ComputerVisionErrorException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ComputerVisionError + /// information. + /// + public partial class ComputerVisionErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ComputerVisionError Body { get; set; } + + /// + /// Initializes a new instance of the ComputerVisionErrorException class. + /// + public ComputerVisionErrorException() + { + } + + /// + /// Initializes a new instance of the ComputerVisionErrorException class. + /// + /// The exception message. + public ComputerVisionErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ComputerVisionErrorException class. + /// + /// The exception message. + /// Inner exception. + public ComputerVisionErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ElementReference.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ElementReference.cs new file mode 100644 index 000000000000..42edb850c68e --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ElementReference.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Reference to an OCR word. + /// + public partial class ElementReference + { + /// + /// Initializes a new instance of the ElementReference class. + /// + public ElementReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ElementReference class. + /// + public ElementReference(string refProperty = default(string)) + { + RefProperty = refProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "$ref")] + public string RefProperty { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/FieldValue.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/FieldValue.cs new file mode 100644 index 000000000000..2b4f12290bab --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/FieldValue.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Base class representing a recognized field value. + /// + [Newtonsoft.Json.JsonObject("fieldValue")] + public partial class FieldValue + { + /// + /// Initializes a new instance of the FieldValue class. + /// + public FieldValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FieldValue class. + /// + /// OCR text content of the recognized + /// field. + /// List of references to OCR words comprising + /// the recognized field value. + public FieldValue(string text = default(string), IList elements = default(IList)) + { + Text = text; + Elements = elements; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets OCR text content of the recognized field. + /// + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or sets list of references to OCR words comprising the + /// recognized field value. + /// + [JsonProperty(PropertyName = "elements")] + public IList Elements { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ImageUrl.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ImageUrl.cs new file mode 100644 index 000000000000..a181680e57a8 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ImageUrl.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class ImageUrl + { + /// + /// Initializes a new instance of the ImageUrl class. + /// + public ImageUrl() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ImageUrl class. + /// + /// Publicly reachable URL of an image. + public ImageUrl(string url) + { + Url = url; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets publicly reachable URL of an image. + /// + [JsonProperty(PropertyName = "url")] + public string Url { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Url == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Url"); + } + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Line.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Line.cs new file mode 100644 index 000000000000..49a0a5465ee8 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Line.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An object representing a recognized text line. + /// + public partial class Line + { + /// + /// Initializes a new instance of the Line class. + /// + public Line() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Line class. + /// + /// Bounding box of a recognized + /// line. + /// The text content of the line. + /// List of words in the text line. + public Line(IList boundingBox = default(IList), string text = default(string), IList words = default(IList)) + { + BoundingBox = boundingBox; + Text = text; + Words = words; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets bounding box of a recognized line. + /// + [JsonProperty(PropertyName = "boundingBox")] + public IList BoundingBox { get; set; } + + /// + /// Gets or sets the text content of the line. + /// + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or sets list of words in the text line. + /// + [JsonProperty(PropertyName = "words")] + public IList Words { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/NumberValue.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/NumberValue.cs new file mode 100644 index 000000000000..a98d9e209b2b --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/NumberValue.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Recognized numeric field value. + /// + [Newtonsoft.Json.JsonObject("numberValue")] + public partial class NumberValue : FieldValue + { + /// + /// Initializes a new instance of the NumberValue class. + /// + public NumberValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NumberValue class. + /// + /// OCR text content of the recognized + /// field. + /// List of references to OCR words comprising + /// the recognized field value. + /// Numeric value of the recognized field. + public NumberValue(string text = default(string), IList elements = default(IList), double? value = default(double?)) + : base(text, elements) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets numeric value of the recognized field. + /// + [JsonProperty(PropertyName = "value")] + public double? Value { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ReadReceiptResult.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ReadReceiptResult.cs new file mode 100644 index 000000000000..b9d080a3885e --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/ReadReceiptResult.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Analysis result of the 'Batch Read Receipt' operation. + /// + public partial class ReadReceiptResult + { + /// + /// Initializes a new instance of the ReadReceiptResult class. + /// + public ReadReceiptResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReadReceiptResult class. + /// + /// Status of the read operation. Possible values + /// include: 'Not Started', 'Running', 'Failed', 'Succeeded' + /// Text recognition result of the + /// 'Batch Read Receipt' operation. + /// Semantic understanding result of + /// the 'Batch Read Receipt' operation. + public ReadReceiptResult(TextOperationStatusCodes status = default(TextOperationStatusCodes), IList recognitionResults = default(IList), IList understandingResults = default(IList)) + { + Status = status; + RecognitionResults = recognitionResults; + UnderstandingResults = understandingResults; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets status of the read operation. Possible values include: + /// 'Not Started', 'Running', 'Failed', 'Succeeded' + /// + [JsonProperty(PropertyName = "status")] + public TextOperationStatusCodes Status { get; set; } + + /// + /// Gets or sets text recognition result of the 'Batch Read Receipt' + /// operation. + /// + [JsonProperty(PropertyName = "recognitionResults")] + public IList RecognitionResults { get; set; } + + /// + /// Gets or sets semantic understanding result of the 'Batch Read + /// Receipt' operation. + /// + [JsonProperty(PropertyName = "understandingResults")] + public IList UnderstandingResults { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/StringValue.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/StringValue.cs new file mode 100644 index 000000000000..7501583a8edc --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/StringValue.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Recognized string field value. + /// + [Newtonsoft.Json.JsonObject("stringValue")] + public partial class StringValue : FieldValue + { + /// + /// Initializes a new instance of the StringValue class. + /// + public StringValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StringValue class. + /// + /// OCR text content of the recognized + /// field. + /// List of references to OCR words comprising + /// the recognized field value. + /// String value of the recognized field. + public StringValue(string text = default(string), IList elements = default(IList), string value = default(string)) + : base(text, elements) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets string value of the recognized field. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextOperationStatusCodes.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextOperationStatusCodes.cs new file mode 100644 index 000000000000..b51770923758 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextOperationStatusCodes.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TextOperationStatusCodes. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TextOperationStatusCodes + { + [EnumMember(Value = "Not Started")] + NotStarted, + [EnumMember(Value = "Running")] + Running, + [EnumMember(Value = "Failed")] + Failed, + [EnumMember(Value = "Succeeded")] + Succeeded + } + internal static class TextOperationStatusCodesEnumExtension + { + internal static string ToSerializedValue(this TextOperationStatusCodes? value) + { + return value == null ? null : ((TextOperationStatusCodes)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TextOperationStatusCodes value) + { + switch( value ) + { + case TextOperationStatusCodes.NotStarted: + return "Not Started"; + case TextOperationStatusCodes.Running: + return "Running"; + case TextOperationStatusCodes.Failed: + return "Failed"; + case TextOperationStatusCodes.Succeeded: + return "Succeeded"; + } + return null; + } + + internal static TextOperationStatusCodes? ParseTextOperationStatusCodes(this string value) + { + switch( value ) + { + case "Not Started": + return TextOperationStatusCodes.NotStarted; + case "Running": + return TextOperationStatusCodes.Running; + case "Failed": + return TextOperationStatusCodes.Failed; + case "Succeeded": + return TextOperationStatusCodes.Succeeded; + } + return null; + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResult.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResult.cs new file mode 100644 index 000000000000..6d11f4694901 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResult.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An object representing a recognized text region + /// + public partial class TextRecognitionResult + { + /// + /// Initializes a new instance of the TextRecognitionResult class. + /// + public TextRecognitionResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TextRecognitionResult class. + /// + /// A list of recognized text lines. + /// The 1-based page number of the recognition + /// result. + /// The orientation of the image in + /// degrees in the clockwise direction. Range between [0, 360). + /// The width of the image in pixels or the PDF in + /// inches. + /// The height of the image in pixels or the PDF + /// in inches. + /// The unit used in the Width, Height and + /// BoundingBox. For images, the unit is 'pixel'. For PDF, the unit is + /// 'inch'. Possible values include: 'pixel', 'inch' + public TextRecognitionResult(IList lines, int? page = default(int?), double? clockwiseOrientation = default(double?), double? width = default(double?), double? height = default(double?), TextRecognitionResultDimensionUnit? unit = default(TextRecognitionResultDimensionUnit?)) + { + Page = page; + ClockwiseOrientation = clockwiseOrientation; + Width = width; + Height = height; + Unit = unit; + Lines = lines; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the 1-based page number of the recognition result. + /// + [JsonProperty(PropertyName = "page")] + public int? Page { get; set; } + + /// + /// Gets or sets the orientation of the image in degrees in the + /// clockwise direction. Range between [0, 360). + /// + [JsonProperty(PropertyName = "clockwiseOrientation")] + public double? ClockwiseOrientation { get; set; } + + /// + /// Gets or sets the width of the image in pixels or the PDF in inches. + /// + [JsonProperty(PropertyName = "width")] + public double? Width { get; set; } + + /// + /// Gets or sets the height of the image in pixels or the PDF in + /// inches. + /// + [JsonProperty(PropertyName = "height")] + public double? Height { get; set; } + + /// + /// Gets or sets the unit used in the Width, Height and BoundingBox. + /// For images, the unit is 'pixel'. For PDF, the unit is 'inch'. + /// Possible values include: 'pixel', 'inch' + /// + [JsonProperty(PropertyName = "unit")] + public TextRecognitionResultDimensionUnit? Unit { get; set; } + + /// + /// Gets or sets a list of recognized text lines. + /// + [JsonProperty(PropertyName = "lines")] + public IList Lines { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Lines == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Lines"); + } + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultConfidenceClass.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultConfidenceClass.cs new file mode 100644 index 000000000000..a9f09214a011 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultConfidenceClass.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TextRecognitionResultConfidenceClass. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TextRecognitionResultConfidenceClass + { + [EnumMember(Value = "High")] + High, + [EnumMember(Value = "Low")] + Low + } + internal static class TextRecognitionResultConfidenceClassEnumExtension + { + internal static string ToSerializedValue(this TextRecognitionResultConfidenceClass? value) + { + return value == null ? null : ((TextRecognitionResultConfidenceClass)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TextRecognitionResultConfidenceClass value) + { + switch( value ) + { + case TextRecognitionResultConfidenceClass.High: + return "High"; + case TextRecognitionResultConfidenceClass.Low: + return "Low"; + } + return null; + } + + internal static TextRecognitionResultConfidenceClass? ParseTextRecognitionResultConfidenceClass(this string value) + { + switch( value ) + { + case "High": + return TextRecognitionResultConfidenceClass.High; + case "Low": + return TextRecognitionResultConfidenceClass.Low; + } + return null; + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultDimensionUnit.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultDimensionUnit.cs new file mode 100644 index 000000000000..ee75e85e17eb --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/TextRecognitionResultDimensionUnit.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TextRecognitionResultDimensionUnit. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TextRecognitionResultDimensionUnit + { + [EnumMember(Value = "pixel")] + Pixel, + [EnumMember(Value = "inch")] + Inch + } + internal static class TextRecognitionResultDimensionUnitEnumExtension + { + internal static string ToSerializedValue(this TextRecognitionResultDimensionUnit? value) + { + return value == null ? null : ((TextRecognitionResultDimensionUnit)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TextRecognitionResultDimensionUnit value) + { + switch( value ) + { + case TextRecognitionResultDimensionUnit.Pixel: + return "pixel"; + case TextRecognitionResultDimensionUnit.Inch: + return "inch"; + } + return null; + } + + internal static TextRecognitionResultDimensionUnit? ParseTextRecognitionResultDimensionUnit(this string value) + { + switch( value ) + { + case "pixel": + return TextRecognitionResultDimensionUnit.Pixel; + case "inch": + return TextRecognitionResultDimensionUnit.Inch; + } + return null; + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/UnderstandingResult.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/UnderstandingResult.cs new file mode 100644 index 000000000000..a44f7f7edeb3 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/UnderstandingResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A set of extracted fields corresponding to a semantic object, such as a + /// receipt, in the input document. + /// + public partial class UnderstandingResult + { + /// + /// Initializes a new instance of the UnderstandingResult class. + /// + public UnderstandingResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UnderstandingResult class. + /// + /// List of pages where the document is + /// found. + /// Dictionary of recognized field values. + public UnderstandingResult(IList pages = default(IList), IDictionary fields = default(IDictionary)) + { + Pages = pages; + Fields = fields; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of pages where the document is found. + /// + [JsonProperty(PropertyName = "pages")] + public IList Pages { get; set; } + + /// + /// Gets or sets dictionary of recognized field values. + /// + [JsonProperty(PropertyName = "fields")] + public IDictionary Fields { get; set; } + + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Word.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Word.cs new file mode 100644 index 000000000000..a445c7884067 --- /dev/null +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/Models/Word.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.FormRecognizer.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An object representing a recognized word. + /// + public partial class Word + { + /// + /// Initializes a new instance of the Word class. + /// + public Word() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Word class. + /// + /// Bounding box of a recognized + /// word. + /// The text content of the word. + /// Qualitative confidence measure. Possible + /// values include: 'High', 'Low' + public Word(IList boundingBox, string text, TextRecognitionResultConfidenceClass? confidence = default(TextRecognitionResultConfidenceClass?)) + { + BoundingBox = boundingBox; + Text = text; + Confidence = confidence; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets bounding box of a recognized word. + /// + [JsonProperty(PropertyName = "boundingBox")] + public IList BoundingBox { get; set; } + + /// + /// Gets or sets the text content of the word. + /// + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or sets qualitative confidence measure. Possible values + /// include: 'High', 'Low' + /// + [JsonProperty(PropertyName = "confidence")] + public TextRecognitionResultConfidenceClass? Confidence { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (BoundingBox == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "BoundingBox"); + } + if (Text == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Text"); + } + } + } +} diff --git a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/SdkInfo_FormRecognizerClient.cs b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/SdkInfo_FormRecognizerClient.cs index e2f6a82f4462..984682f68f43 100644 --- a/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/SdkInfo_FormRecognizerClient.cs +++ b/sdk/cognitiveservices/Vision.FormRecognizer/src/Generated/SdkInfo_FormRecognizerClient.cs @@ -19,12 +19,15 @@ public static IEnumerable> ApiInfo_FormRecognizerC { return new Tuple[] { - new Tuple("FormRecognizerClient", "AnalyzeWithCustomModel", "v1.0-preview"), - new Tuple("FormRecognizerClient", "DeleteCustomModel", "v1.0-preview"), - new Tuple("FormRecognizerClient", "GetCustomModel", "v1.0-preview"), - new Tuple("FormRecognizerClient", "GetCustomModels", "v1.0-preview"), - new Tuple("FormRecognizerClient", "GetExtractedKeys", "v1.0-preview"), - new Tuple("FormRecognizerClient", "TrainCustomModel", "v1.0-preview"), + new Tuple("FormRecognizerClient", "AnalyzeWithCustomModel", "1.0-preview"), + new Tuple("FormRecognizerClient", "BatchReadReceipt", "1.0-preview"), + new Tuple("FormRecognizerClient", "BatchReadReceiptInStream", "1.0-preview"), + new Tuple("FormRecognizerClient", "DeleteCustomModel", "1.0-preview"), + new Tuple("FormRecognizerClient", "GetCustomModel", "1.0-preview"), + new Tuple("FormRecognizerClient", "GetCustomModels", "1.0-preview"), + new Tuple("FormRecognizerClient", "GetExtractedKeys", "1.0-preview"), + new Tuple("FormRecognizerClient", "GetReadReceiptResult", "1.0-preview"), + new Tuple("FormRecognizerClient", "TrainCustomModel", "1.0-preview"), }.AsEnumerable(); } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Vision/FormRecognizer/FormRecognizer/Microsoft.Azure.CognitiveServices.FormRecognizer.csproj b/src/SDKs/CognitiveServices/dataPlane/Vision/FormRecognizer/FormRecognizer/Microsoft.Azure.CognitiveServices.FormRecognizer.csproj new file mode 100644 index 000000000000..a7c4e45cf2cf --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Vision/FormRecognizer/FormRecognizer/Microsoft.Azure.CognitiveServices.FormRecognizer.csproj @@ -0,0 +1,34 @@ + + + + + + + Microsoft.Azure.CognitiveServices.FormRecognizer + This client library provides access to the Microsoft Cognitive Services Form Recognizer APIs. + 0.8.0-preview + Microsoft.Azure.CognitiveServices.FormRecognizer + FormRecognizer;Form Recognizer; + + + + + + + + + + + + + + + $(SdkTargetFx) + + + + + + \ No newline at end of file