< Summary

Class:Azure.AI.FormRecognizer.ServiceRestClient
Assembly:Azure.AI.FormRecognizer
File(s):C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\ServiceRestClient.cs
Covered lines:449
Uncovered lines:71
Coverable lines:520
Total lines:1126
Line coverage:86.3% (449 of 520)
Covered branches:73
Total branches:114
Branch coverage:64% (73 of 114)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-85.71%50%
CreateTrainCustomModelAsyncRequest(...)-100%100%
TrainCustomModelAsyncAsync()-77.78%50%
TrainCustomModelAsync(...)-77.78%50%
CreateGetCustomModelRequest(...)-100%100%
GetCustomModelAsync()-100%100%
GetCustomModel(...)-100%100%
CreateDeleteCustomModelRequest(...)-100%100%
DeleteCustomModelAsync()-100%100%
DeleteCustomModel(...)-100%100%
CreateAnalyzeWithCustomModelRequest(...)-100%100%
AnalyzeWithCustomModelAsync()-77.78%50%
AnalyzeWithCustomModel(...)-77.78%50%
CreateAnalyzeWithCustomModelRequest(...)-100%100%
AnalyzeWithCustomModelAsync()-85.71%50%
AnalyzeWithCustomModel(...)-85.71%50%
CreateGetAnalyzeFormResultRequest(...)-100%100%
GetAnalyzeFormResultAsync()-87.5%50%
GetAnalyzeFormResult(...)-0%0%
CreateCopyCustomModelRequest(...)-100%100%
CopyCustomModelAsync()-77.78%50%
CopyCustomModel(...)-77.78%50%
CreateGetCustomModelCopyResultRequest(...)-100%100%
GetCustomModelCopyResultAsync()-87.5%50%
GetCustomModelCopyResult(...)-0%0%
CreateGenerateModelCopyAuthorizationRequest()-100%100%
GenerateModelCopyAuthorizationAsync()-88.89%50%
GenerateModelCopyAuthorization(...)-88.89%50%
CreateAnalyzeReceiptAsyncRequest(...)-100%100%
AnalyzeReceiptAsyncAsync()-88.89%75%
AnalyzeReceiptAsync(...)-88.89%75%
CreateAnalyzeReceiptAsyncRequest(...)-100%100%
AnalyzeReceiptAsyncAsync()-100%100%
AnalyzeReceiptAsync(...)-100%100%
CreateGetAnalyzeReceiptResultRequest(...)-100%100%
GetAnalyzeReceiptResultAsync()-87.5%50%
GetAnalyzeReceiptResult(...)-0%0%
CreateAnalyzeLayoutAsyncRequest(...)-100%100%
AnalyzeLayoutAsyncAsync()-88.89%75%
AnalyzeLayoutAsync(...)-88.89%75%
CreateAnalyzeLayoutAsyncRequest(...)-100%100%
AnalyzeLayoutAsyncAsync()-100%100%
AnalyzeLayoutAsync(...)-100%100%
CreateGetAnalyzeLayoutResultRequest(...)-100%100%
GetAnalyzeLayoutResultAsync()-87.5%50%
GetAnalyzeLayoutResult(...)-0%0%
CreateListCustomModelsRequest()-100%100%
ListCustomModelsAsync()-87.5%50%
ListCustomModels(...)-87.5%50%
CreateGetCustomModelsRequest()-100%100%
GetCustomModelsAsync()-100%100%
GetCustomModels(...)-100%100%
CreateListCustomModelsNextPageRequest(...)-100%100%
ListCustomModelsNextPageAsync()-80%50%
ListCustomModelsNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\ServiceRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.IO;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.AI.FormRecognizer.Models;
 15using Azure.Core;
 16using Azure.Core.Pipeline;
 17
 18namespace Azure.AI.FormRecognizer
 19{
 20    internal partial class ServiceRestClient
 21    {
 22        private string endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of ServiceRestClient. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="endpoint"> Supported Cognitive Services endpoints (protocol and hostname, for example: https://
 30        /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> is null. </exception>
 52431        public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint)
 32        {
 52433            if (endpoint == null)
 34            {
 035                throw new ArgumentNullException(nameof(endpoint));
 36            }
 37
 52438            this.endpoint = endpoint;
 52439            _clientDiagnostics = clientDiagnostics;
 52440            _pipeline = pipeline;
 52441        }
 42
 43        internal HttpMessage CreateTrainCustomModelAsyncRequest(TrainRequest trainRequest)
 44        {
 14845            var message = _pipeline.CreateMessage();
 14846            var request = message.Request;
 14847            request.Method = RequestMethod.Post;
 14848            var uri = new RawRequestUriBuilder();
 14849            uri.AppendRaw(endpoint, false);
 14850            uri.AppendRaw("/formrecognizer/v2.0", false);
 14851            uri.AppendPath("/custom/models", false);
 14852            request.Uri = uri;
 14853            request.Headers.Add("Content-Type", "application/json");
 14854            var content = new Utf8JsonRequestContent();
 14855            content.JsonWriter.WriteObjectValue(trainRequest);
 14856            request.Content = content;
 14857            return message;
 58        }
 59
 60        /// <summary> Create and train a custom model. The request must include a source parameter that is either an ext
 61        /// <param name="trainRequest"> Training request parameters. </param>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        /// <exception cref="ArgumentNullException"> <paramref name="trainRequest"/> is null. </exception>
 64        public async Task<ResponseWithHeaders<ServiceTrainCustomModelAsyncHeaders>> TrainCustomModelAsyncAsync(TrainRequ
 65        {
 7666            if (trainRequest == null)
 67            {
 068                throw new ArgumentNullException(nameof(trainRequest));
 69            }
 70
 7671            using var message = CreateTrainCustomModelAsyncRequest(trainRequest);
 7672            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 7673            var headers = new ServiceTrainCustomModelAsyncHeaders(message.Response);
 7674            switch (message.Response.Status)
 75            {
 76                case 201:
 7677                    return ResponseWithHeaders.FromValue(headers, message.Response);
 78                default:
 079                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 80            }
 7681        }
 82
 83        /// <summary> Create and train a custom model. The request must include a source parameter that is either an ext
 84        /// <param name="trainRequest"> Training request parameters. </param>
 85        /// <param name="cancellationToken"> The cancellation token to use. </param>
 86        /// <exception cref="ArgumentNullException"> <paramref name="trainRequest"/> is null. </exception>
 87        public ResponseWithHeaders<ServiceTrainCustomModelAsyncHeaders> TrainCustomModelAsync(TrainRequest trainRequest,
 88        {
 7289            if (trainRequest == null)
 90            {
 091                throw new ArgumentNullException(nameof(trainRequest));
 92            }
 93
 7294            using var message = CreateTrainCustomModelAsyncRequest(trainRequest);
 7295            _pipeline.Send(message, cancellationToken);
 7296            var headers = new ServiceTrainCustomModelAsyncHeaders(message.Response);
 7297            switch (message.Response.Status)
 98            {
 99                case 201:
 72100                    return ResponseWithHeaders.FromValue(headers, message.Response);
 101                default:
 0102                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 103            }
 72104        }
 105
 106        internal HttpMessage CreateGetCustomModelRequest(Guid modelId, bool? includeKeys)
 107        {
 1074108            var message = _pipeline.CreateMessage();
 1074109            var request = message.Request;
 1074110            request.Method = RequestMethod.Get;
 1074111            var uri = new RawRequestUriBuilder();
 1074112            uri.AppendRaw(endpoint, false);
 1074113            uri.AppendRaw("/formrecognizer/v2.0", false);
 1074114            uri.AppendPath("/custom/models/", false);
 1074115            uri.AppendPath(modelId, true);
 1074116            if (includeKeys != null)
 117            {
 1074118                uri.AppendQuery("includeKeys", includeKeys.Value, true);
 119            }
 1074120            request.Uri = uri;
 1074121            return message;
 122        }
 123
 124        /// <summary> Get detailed information about a custom model. </summary>
 125        /// <param name="modelId"> Model identifier. </param>
 126        /// <param name="includeKeys"> Include list of extracted keys in model information. </param>
 127        /// <param name="cancellationToken"> The cancellation token to use. </param>
 128        public async Task<Response<Model>> GetCustomModelAsync(Guid modelId, bool? includeKeys = null, CancellationToken
 129        {
 1064130            using var message = CreateGetCustomModelRequest(modelId, includeKeys);
 1064131            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1064132            switch (message.Response.Status)
 133            {
 134                case 200:
 135                    {
 136                        Model value = default;
 1060137                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 1060138                        value = Model.DeserializeModel(document.RootElement);
 1060139                        return Response.FromValue(value, message.Response);
 140                    }
 141                default:
 4142                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 143            }
 1060144        }
 145
 146        /// <summary> Get detailed information about a custom model. </summary>
 147        /// <param name="modelId"> Model identifier. </param>
 148        /// <param name="includeKeys"> Include list of extracted keys in model information. </param>
 149        /// <param name="cancellationToken"> The cancellation token to use. </param>
 150        public Response<Model> GetCustomModel(Guid modelId, bool? includeKeys = null, CancellationToken cancellationToke
 151        {
 10152            using var message = CreateGetCustomModelRequest(modelId, includeKeys);
 10153            _pipeline.Send(message, cancellationToken);
 10154            switch (message.Response.Status)
 155            {
 156                case 200:
 157                    {
 158                        Model value = default;
 6159                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6160                        value = Model.DeserializeModel(document.RootElement);
 6161                        return Response.FromValue(value, message.Response);
 162                    }
 163                default:
 4164                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 165            }
 6166        }
 167
 168        internal HttpMessage CreateDeleteCustomModelRequest(Guid modelId)
 169        {
 108170            var message = _pipeline.CreateMessage();
 108171            var request = message.Request;
 108172            request.Method = RequestMethod.Delete;
 108173            var uri = new RawRequestUriBuilder();
 108174            uri.AppendRaw(endpoint, false);
 108175            uri.AppendRaw("/formrecognizer/v2.0", false);
 108176            uri.AppendPath("/custom/models/", false);
 108177            uri.AppendPath(modelId, true);
 108178            request.Uri = uri;
 108179            return message;
 180        }
 181
 182        /// <summary> Mark model for deletion. Model artifacts will be permanently removed within a predetermined period
 183        /// <param name="modelId"> Model identifier. </param>
 184        /// <param name="cancellationToken"> The cancellation token to use. </param>
 185        public async Task<Response> DeleteCustomModelAsync(Guid modelId, CancellationToken cancellationToken = default)
 186        {
 54187            using var message = CreateDeleteCustomModelRequest(modelId);
 54188            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 54189            switch (message.Response.Status)
 190            {
 191                case 204:
 52192                    return message.Response;
 193                default:
 2194                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 195            }
 52196        }
 197
 198        /// <summary> Mark model for deletion. Model artifacts will be permanently removed within a predetermined period
 199        /// <param name="modelId"> Model identifier. </param>
 200        /// <param name="cancellationToken"> The cancellation token to use. </param>
 201        public Response DeleteCustomModel(Guid modelId, CancellationToken cancellationToken = default)
 202        {
 54203            using var message = CreateDeleteCustomModelRequest(modelId);
 54204            _pipeline.Send(message, cancellationToken);
 54205            switch (message.Response.Status)
 206            {
 207                case 204:
 52208                    return message.Response;
 209                default:
 2210                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 211            }
 52212        }
 213
 214        internal HttpMessage CreateAnalyzeWithCustomModelRequest(Guid modelId, FormContentType contentType, Stream fileS
 215        {
 68216            var message = _pipeline.CreateMessage();
 68217            var request = message.Request;
 68218            request.Method = RequestMethod.Post;
 68219            var uri = new RawRequestUriBuilder();
 68220            uri.AppendRaw(endpoint, false);
 68221            uri.AppendRaw("/formrecognizer/v2.0", false);
 68222            uri.AppendPath("/custom/models/", false);
 68223            uri.AppendPath(modelId, true);
 68224            uri.AppendPath("/analyze", false);
 68225            if (includeTextDetails != null)
 226            {
 68227                uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true);
 228            }
 68229            request.Uri = uri;
 68230            request.Headers.Add("Content-Type", contentType.ToSerialString());
 68231            request.Content = RequestContent.Create(fileStream);
 68232            return message;
 233        }
 234
 235        /// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document mus
 236        /// <param name="modelId"> Model identifier. </param>
 237        /// <param name="contentType"> Upload file type. </param>
 238        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 239        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 240        /// <param name="cancellationToken"> The cancellation token to use. </param>
 241        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 242        public async Task<ResponseWithHeaders<ServiceAnalyzeWithCustomModelHeaders>> AnalyzeWithCustomModelAsync(Guid mo
 243        {
 36244            if (fileStream == null)
 245            {
 0246                throw new ArgumentNullException(nameof(fileStream));
 247            }
 248
 36249            using var message = CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails
 36250            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 34251            var headers = new ServiceAnalyzeWithCustomModelHeaders(message.Response);
 34252            switch (message.Response.Status)
 253            {
 254                case 202:
 34255                    return ResponseWithHeaders.FromValue(headers, message.Response);
 256                default:
 0257                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 258            }
 34259        }
 260
 261        /// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document mus
 262        /// <param name="modelId"> Model identifier. </param>
 263        /// <param name="contentType"> Upload file type. </param>
 264        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 265        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 266        /// <param name="cancellationToken"> The cancellation token to use. </param>
 267        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 268        public ResponseWithHeaders<ServiceAnalyzeWithCustomModelHeaders> AnalyzeWithCustomModel(Guid modelId, FormConten
 269        {
 32270            if (fileStream == null)
 271            {
 0272                throw new ArgumentNullException(nameof(fileStream));
 273            }
 274
 32275            using var message = CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails
 32276            _pipeline.Send(message, cancellationToken);
 30277            var headers = new ServiceAnalyzeWithCustomModelHeaders(message.Response);
 30278            switch (message.Response.Status)
 279            {
 280                case 202:
 30281                    return ResponseWithHeaders.FromValue(headers, message.Response);
 282                default:
 0283                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 284            }
 30285        }
 286
 287        internal HttpMessage CreateAnalyzeWithCustomModelRequest(Guid modelId, bool? includeTextDetails, SourcePath file
 288        {
 40289            var message = _pipeline.CreateMessage();
 40290            var request = message.Request;
 40291            request.Method = RequestMethod.Post;
 40292            var uri = new RawRequestUriBuilder();
 40293            uri.AppendRaw(endpoint, false);
 40294            uri.AppendRaw("/formrecognizer/v2.0", false);
 40295            uri.AppendPath("/custom/models/", false);
 40296            uri.AppendPath(modelId, true);
 40297            uri.AppendPath("/analyze", false);
 40298            if (includeTextDetails != null)
 299            {
 40300                uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true);
 301            }
 40302            request.Uri = uri;
 40303            request.Headers.Add("Content-Type", "application/json");
 40304            if (fileStream != null)
 305            {
 40306                var content = new Utf8JsonRequestContent();
 40307                content.JsonWriter.WriteObjectValue(fileStream);
 40308                request.Content = content;
 309            }
 40310            return message;
 311        }
 312
 313        /// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document mus
 314        /// <param name="modelId"> Model identifier. </param>
 315        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 316        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 317        /// <param name="cancellationToken"> The cancellation token to use. </param>
 318        public async Task<ResponseWithHeaders<ServiceAnalyzeWithCustomModelHeaders>> AnalyzeWithCustomModelAsync(Guid mo
 319        {
 20320            using var message = CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream);
 20321            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 18322            var headers = new ServiceAnalyzeWithCustomModelHeaders(message.Response);
 18323            switch (message.Response.Status)
 324            {
 325                case 202:
 18326                    return ResponseWithHeaders.FromValue(headers, message.Response);
 327                default:
 0328                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 329            }
 18330        }
 331
 332        /// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document mus
 333        /// <param name="modelId"> Model identifier. </param>
 334        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 335        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 336        /// <param name="cancellationToken"> The cancellation token to use. </param>
 337        public ResponseWithHeaders<ServiceAnalyzeWithCustomModelHeaders> AnalyzeWithCustomModel(Guid modelId, bool? incl
 338        {
 20339            using var message = CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream);
 20340            _pipeline.Send(message, cancellationToken);
 18341            var headers = new ServiceAnalyzeWithCustomModelHeaders(message.Response);
 18342            switch (message.Response.Status)
 343            {
 344                case 202:
 18345                    return ResponseWithHeaders.FromValue(headers, message.Response);
 346                default:
 0347                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 348            }
 18349        }
 350
 351        internal HttpMessage CreateGetAnalyzeFormResultRequest(Guid modelId, Guid resultId)
 352        {
 734353            var message = _pipeline.CreateMessage();
 734354            var request = message.Request;
 734355            request.Method = RequestMethod.Get;
 734356            var uri = new RawRequestUriBuilder();
 734357            uri.AppendRaw(endpoint, false);
 734358            uri.AppendRaw("/formrecognizer/v2.0", false);
 734359            uri.AppendPath("/custom/models/", false);
 734360            uri.AppendPath(modelId, true);
 734361            uri.AppendPath("/analyzeResults/", false);
 734362            uri.AppendPath(resultId, true);
 734363            request.Uri = uri;
 734364            return message;
 365        }
 366
 367        /// <summary> Obtain current status and the result of the analyze form operation. </summary>
 368        /// <param name="modelId"> Model identifier. </param>
 369        /// <param name="resultId"> Analyze operation result identifier. </param>
 370        /// <param name="cancellationToken"> The cancellation token to use. </param>
 371        public async Task<Response<AnalyzeOperationResult>> GetAnalyzeFormResultAsync(Guid modelId, Guid resultId, Cance
 372        {
 734373            using var message = CreateGetAnalyzeFormResultRequest(modelId, resultId);
 734374            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 734375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                    {
 379                        AnalyzeOperationResult value = default;
 734380                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 734381                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 734382                        return Response.FromValue(value, message.Response);
 383                    }
 384                default:
 0385                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 386            }
 734387        }
 388
 389        /// <summary> Obtain current status and the result of the analyze form operation. </summary>
 390        /// <param name="modelId"> Model identifier. </param>
 391        /// <param name="resultId"> Analyze operation result identifier. </param>
 392        /// <param name="cancellationToken"> The cancellation token to use. </param>
 393        public Response<AnalyzeOperationResult> GetAnalyzeFormResult(Guid modelId, Guid resultId, CancellationToken canc
 394        {
 0395            using var message = CreateGetAnalyzeFormResultRequest(modelId, resultId);
 0396            _pipeline.Send(message, cancellationToken);
 0397            switch (message.Response.Status)
 398            {
 399                case 200:
 400                    {
 401                        AnalyzeOperationResult value = default;
 0402                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0403                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 0404                        return Response.FromValue(value, message.Response);
 405                    }
 406                default:
 0407                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 408            }
 0409        }
 410
 411        internal HttpMessage CreateCopyCustomModelRequest(Guid modelId, CopyRequest copyRequest)
 412        {
 12413            var message = _pipeline.CreateMessage();
 12414            var request = message.Request;
 12415            request.Method = RequestMethod.Post;
 12416            var uri = new RawRequestUriBuilder();
 12417            uri.AppendRaw(endpoint, false);
 12418            uri.AppendRaw("/formrecognizer/v2.0", false);
 12419            uri.AppendPath("/custom/models/", false);
 12420            uri.AppendPath(modelId, true);
 12421            uri.AppendPath("/copy", false);
 12422            request.Uri = uri;
 12423            request.Headers.Add("Content-Type", "application/json");
 12424            var content = new Utf8JsonRequestContent();
 12425            content.JsonWriter.WriteObjectValue(copyRequest);
 12426            request.Content = content;
 12427            return message;
 428        }
 429
 430        /// <summary> Copy custom model stored in this resource (the source) to user specified target Form Recognizer re
 431        /// <param name="modelId"> Model identifier. </param>
 432        /// <param name="copyRequest"> Copy request parameters. </param>
 433        /// <param name="cancellationToken"> The cancellation token to use. </param>
 434        /// <exception cref="ArgumentNullException"> <paramref name="copyRequest"/> is null. </exception>
 435        public async Task<ResponseWithHeaders<ServiceCopyCustomModelHeaders>> CopyCustomModelAsync(Guid modelId, CopyReq
 436        {
 8437            if (copyRequest == null)
 438            {
 0439                throw new ArgumentNullException(nameof(copyRequest));
 440            }
 441
 8442            using var message = CreateCopyCustomModelRequest(modelId, copyRequest);
 8443            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8444            var headers = new ServiceCopyCustomModelHeaders(message.Response);
 8445            switch (message.Response.Status)
 446            {
 447                case 202:
 8448                    return ResponseWithHeaders.FromValue(headers, message.Response);
 449                default:
 0450                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 451            }
 8452        }
 453
 454        /// <summary> Copy custom model stored in this resource (the source) to user specified target Form Recognizer re
 455        /// <param name="modelId"> Model identifier. </param>
 456        /// <param name="copyRequest"> Copy request parameters. </param>
 457        /// <param name="cancellationToken"> The cancellation token to use. </param>
 458        /// <exception cref="ArgumentNullException"> <paramref name="copyRequest"/> is null. </exception>
 459        public ResponseWithHeaders<ServiceCopyCustomModelHeaders> CopyCustomModel(Guid modelId, CopyRequest copyRequest,
 460        {
 4461            if (copyRequest == null)
 462            {
 0463                throw new ArgumentNullException(nameof(copyRequest));
 464            }
 465
 4466            using var message = CreateCopyCustomModelRequest(modelId, copyRequest);
 4467            _pipeline.Send(message, cancellationToken);
 4468            var headers = new ServiceCopyCustomModelHeaders(message.Response);
 4469            switch (message.Response.Status)
 470            {
 471                case 202:
 4472                    return ResponseWithHeaders.FromValue(headers, message.Response);
 473                default:
 0474                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 475            }
 4476        }
 477
 478        internal HttpMessage CreateGetCustomModelCopyResultRequest(Guid modelId, Guid resultId)
 479        {
 186480            var message = _pipeline.CreateMessage();
 186481            var request = message.Request;
 186482            request.Method = RequestMethod.Get;
 186483            var uri = new RawRequestUriBuilder();
 186484            uri.AppendRaw(endpoint, false);
 186485            uri.AppendRaw("/formrecognizer/v2.0", false);
 186486            uri.AppendPath("/custom/models/", false);
 186487            uri.AppendPath(modelId, true);
 186488            uri.AppendPath("/copyResults/", false);
 186489            uri.AppendPath(resultId, true);
 186490            request.Uri = uri;
 186491            return message;
 492        }
 493
 494        /// <summary> Obtain current status and the result of a custom model copy operation. </summary>
 495        /// <param name="modelId"> Model identifier. </param>
 496        /// <param name="resultId"> Copy operation result identifier. </param>
 497        /// <param name="cancellationToken"> The cancellation token to use. </param>
 498        public async Task<Response<CopyOperationResult>> GetCustomModelCopyResultAsync(Guid modelId, Guid resultId, Canc
 499        {
 186500            using var message = CreateGetCustomModelCopyResultRequest(modelId, resultId);
 186501            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 186502            switch (message.Response.Status)
 503            {
 504                case 200:
 505                    {
 506                        CopyOperationResult value = default;
 186507                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 186508                        value = CopyOperationResult.DeserializeCopyOperationResult(document.RootElement);
 186509                        return Response.FromValue(value, message.Response);
 510                    }
 511                default:
 0512                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 513            }
 186514        }
 515
 516        /// <summary> Obtain current status and the result of a custom model copy operation. </summary>
 517        /// <param name="modelId"> Model identifier. </param>
 518        /// <param name="resultId"> Copy operation result identifier. </param>
 519        /// <param name="cancellationToken"> The cancellation token to use. </param>
 520        public Response<CopyOperationResult> GetCustomModelCopyResult(Guid modelId, Guid resultId, CancellationToken can
 521        {
 0522            using var message = CreateGetCustomModelCopyResultRequest(modelId, resultId);
 0523            _pipeline.Send(message, cancellationToken);
 0524            switch (message.Response.Status)
 525            {
 526                case 200:
 527                    {
 528                        CopyOperationResult value = default;
 0529                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0530                        value = CopyOperationResult.DeserializeCopyOperationResult(document.RootElement);
 0531                        return Response.FromValue(value, message.Response);
 532                    }
 533                default:
 0534                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 535            }
 0536        }
 537
 538        internal HttpMessage CreateGenerateModelCopyAuthorizationRequest()
 539        {
 20540            var message = _pipeline.CreateMessage();
 20541            var request = message.Request;
 20542            request.Method = RequestMethod.Post;
 20543            var uri = new RawRequestUriBuilder();
 20544            uri.AppendRaw(endpoint, false);
 20545            uri.AppendRaw("/formrecognizer/v2.0", false);
 20546            uri.AppendPath("/custom/models/copyAuthorization", false);
 20547            request.Uri = uri;
 20548            return message;
 549        }
 550
 551        /// <summary> Generate authorization to copy a model into the target Form Recognizer resource. </summary>
 552        /// <param name="cancellationToken"> The cancellation token to use. </param>
 553        public async Task<ResponseWithHeaders<CopyAuthorizationResult, ServiceGenerateModelCopyAuthorizationHeaders>> Ge
 554        {
 12555            using var message = CreateGenerateModelCopyAuthorizationRequest();
 12556            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 12557            var headers = new ServiceGenerateModelCopyAuthorizationHeaders(message.Response);
 12558            switch (message.Response.Status)
 559            {
 560                case 201:
 561                    {
 562                        CopyAuthorizationResult value = default;
 12563                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 12564                        value = CopyAuthorizationResult.DeserializeCopyAuthorizationResult(document.RootElement);
 12565                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 566                    }
 567                default:
 0568                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 569            }
 12570        }
 571
 572        /// <summary> Generate authorization to copy a model into the target Form Recognizer resource. </summary>
 573        /// <param name="cancellationToken"> The cancellation token to use. </param>
 574        public ResponseWithHeaders<CopyAuthorizationResult, ServiceGenerateModelCopyAuthorizationHeaders> GenerateModelC
 575        {
 8576            using var message = CreateGenerateModelCopyAuthorizationRequest();
 8577            _pipeline.Send(message, cancellationToken);
 8578            var headers = new ServiceGenerateModelCopyAuthorizationHeaders(message.Response);
 8579            switch (message.Response.Status)
 580            {
 581                case 201:
 582                    {
 583                        CopyAuthorizationResult value = default;
 8584                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8585                        value = CopyAuthorizationResult.DeserializeCopyAuthorizationResult(document.RootElement);
 8586                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 587                    }
 588                default:
 0589                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 590            }
 8591        }
 592
 593        internal HttpMessage CreateAnalyzeReceiptAsyncRequest(FormContentType contentType, Stream fileStream, bool? incl
 594        {
 36595            var message = _pipeline.CreateMessage();
 36596            var request = message.Request;
 36597            request.Method = RequestMethod.Post;
 36598            var uri = new RawRequestUriBuilder();
 36599            uri.AppendRaw(endpoint, false);
 36600            uri.AppendRaw("/formrecognizer/v2.0", false);
 36601            uri.AppendPath("/prebuilt/receipt/analyze", false);
 36602            if (includeTextDetails != null)
 603            {
 36604                uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true);
 605            }
 36606            request.Uri = uri;
 36607            request.Headers.Add("Content-Type", contentType.ToSerialString());
 36608            request.Content = RequestContent.Create(fileStream);
 36609            return message;
 610        }
 611
 612        /// <summary> Extract field text and semantic values from a given receipt document. The input document must be o
 613        /// <param name="contentType"> Upload file type. </param>
 614        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 615        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 616        /// <param name="cancellationToken"> The cancellation token to use. </param>
 617        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 618        public async Task<ResponseWithHeaders<ServiceAnalyzeReceiptAsyncHeaders>> AnalyzeReceiptAsyncAsync(FormContentTy
 619        {
 18620            if (fileStream == null)
 621            {
 0622                throw new ArgumentNullException(nameof(fileStream));
 623            }
 624
 18625            using var message = CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails);
 18626            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16627            var headers = new ServiceAnalyzeReceiptAsyncHeaders(message.Response);
 16628            switch (message.Response.Status)
 629            {
 630                case 202:
 14631                    return ResponseWithHeaders.FromValue(headers, message.Response);
 632                default:
 2633                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 634            }
 14635        }
 636
 637        /// <summary> Extract field text and semantic values from a given receipt document. The input document must be o
 638        /// <param name="contentType"> Upload file type. </param>
 639        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 640        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 641        /// <param name="cancellationToken"> The cancellation token to use. </param>
 642        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 643        public ResponseWithHeaders<ServiceAnalyzeReceiptAsyncHeaders> AnalyzeReceiptAsync(FormContentType contentType, S
 644        {
 18645            if (fileStream == null)
 646            {
 0647                throw new ArgumentNullException(nameof(fileStream));
 648            }
 649
 18650            using var message = CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails);
 18651            _pipeline.Send(message, cancellationToken);
 16652            var headers = new ServiceAnalyzeReceiptAsyncHeaders(message.Response);
 16653            switch (message.Response.Status)
 654            {
 655                case 202:
 14656                    return ResponseWithHeaders.FromValue(headers, message.Response);
 657                default:
 2658                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 659            }
 14660        }
 661
 662        internal HttpMessage CreateAnalyzeReceiptAsyncRequest(bool? includeTextDetails, SourcePath fileStream)
 663        {
 32664            var message = _pipeline.CreateMessage();
 32665            var request = message.Request;
 32666            request.Method = RequestMethod.Post;
 32667            var uri = new RawRequestUriBuilder();
 32668            uri.AppendRaw(endpoint, false);
 32669            uri.AppendRaw("/formrecognizer/v2.0", false);
 32670            uri.AppendPath("/prebuilt/receipt/analyze", false);
 32671            if (includeTextDetails != null)
 672            {
 32673                uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true);
 674            }
 32675            request.Uri = uri;
 32676            request.Headers.Add("Content-Type", "application/json");
 32677            if (fileStream != null)
 678            {
 32679                var content = new Utf8JsonRequestContent();
 32680                content.JsonWriter.WriteObjectValue(fileStream);
 32681                request.Content = content;
 682            }
 32683            return message;
 684        }
 685
 686        /// <summary> Extract field text and semantic values from a given receipt document. The input document must be o
 687        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 688        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 689        /// <param name="cancellationToken"> The cancellation token to use. </param>
 690        public async Task<ResponseWithHeaders<ServiceAnalyzeReceiptAsyncHeaders>> AnalyzeReceiptAsyncAsync(bool? include
 691        {
 18692            using var message = CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream);
 18693            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16694            var headers = new ServiceAnalyzeReceiptAsyncHeaders(message.Response);
 16695            switch (message.Response.Status)
 696            {
 697                case 202:
 14698                    return ResponseWithHeaders.FromValue(headers, message.Response);
 699                default:
 2700                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 701            }
 14702        }
 703
 704        /// <summary> Extract field text and semantic values from a given receipt document. The input document must be o
 705        /// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
 706        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 707        /// <param name="cancellationToken"> The cancellation token to use. </param>
 708        public ResponseWithHeaders<ServiceAnalyzeReceiptAsyncHeaders> AnalyzeReceiptAsync(bool? includeTextDetails = nul
 709        {
 14710            using var message = CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream);
 14711            _pipeline.Send(message, cancellationToken);
 12712            var headers = new ServiceAnalyzeReceiptAsyncHeaders(message.Response);
 12713            switch (message.Response.Status)
 714            {
 715                case 202:
 10716                    return ResponseWithHeaders.FromValue(headers, message.Response);
 717                default:
 2718                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 719            }
 10720        }
 721
 722        internal HttpMessage CreateGetAnalyzeReceiptResultRequest(Guid resultId)
 723        {
 144724            var message = _pipeline.CreateMessage();
 144725            var request = message.Request;
 144726            request.Method = RequestMethod.Get;
 144727            var uri = new RawRequestUriBuilder();
 144728            uri.AppendRaw(endpoint, false);
 144729            uri.AppendRaw("/formrecognizer/v2.0", false);
 144730            uri.AppendPath("/prebuilt/receipt/analyzeResults/", false);
 144731            uri.AppendPath(resultId, true);
 144732            request.Uri = uri;
 144733            return message;
 734        }
 735
 736        /// <summary> Track the progress and obtain the result of the analyze receipt operation. </summary>
 737        /// <param name="resultId"> Analyze operation result identifier. </param>
 738        /// <param name="cancellationToken"> The cancellation token to use. </param>
 739        public async Task<Response<AnalyzeOperationResult>> GetAnalyzeReceiptResultAsync(Guid resultId, CancellationToke
 740        {
 144741            using var message = CreateGetAnalyzeReceiptResultRequest(resultId);
 144742            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 144743            switch (message.Response.Status)
 744            {
 745                case 200:
 746                    {
 747                        AnalyzeOperationResult value = default;
 144748                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 144749                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 144750                        return Response.FromValue(value, message.Response);
 751                    }
 752                default:
 0753                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 754            }
 144755        }
 756
 757        /// <summary> Track the progress and obtain the result of the analyze receipt operation. </summary>
 758        /// <param name="resultId"> Analyze operation result identifier. </param>
 759        /// <param name="cancellationToken"> The cancellation token to use. </param>
 760        public Response<AnalyzeOperationResult> GetAnalyzeReceiptResult(Guid resultId, CancellationToken cancellationTok
 761        {
 0762            using var message = CreateGetAnalyzeReceiptResultRequest(resultId);
 0763            _pipeline.Send(message, cancellationToken);
 0764            switch (message.Response.Status)
 765            {
 766                case 200:
 767                    {
 768                        AnalyzeOperationResult value = default;
 0769                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0770                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 0771                        return Response.FromValue(value, message.Response);
 772                    }
 773                default:
 0774                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 775            }
 0776        }
 777
 778        internal HttpMessage CreateAnalyzeLayoutAsyncRequest(FormContentType contentType, Stream fileStream)
 779        {
 44780            var message = _pipeline.CreateMessage();
 44781            var request = message.Request;
 44782            request.Method = RequestMethod.Post;
 44783            var uri = new RawRequestUriBuilder();
 44784            uri.AppendRaw(endpoint, false);
 44785            uri.AppendRaw("/formrecognizer/v2.0", false);
 44786            uri.AppendPath("/layout/analyze", false);
 44787            request.Uri = uri;
 44788            request.Headers.Add("Content-Type", contentType.ToSerialString());
 44789            request.Content = RequestContent.Create(fileStream);
 44790            return message;
 791        }
 792
 793        /// <summary> Extract text and layout information from a given document. The input document must be of one of th
 794        /// <param name="contentType"> Upload file type. </param>
 795        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 796        /// <param name="cancellationToken"> The cancellation token to use. </param>
 797        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 798        public async Task<ResponseWithHeaders<ServiceAnalyzeLayoutAsyncHeaders>> AnalyzeLayoutAsyncAsync(FormContentType
 799        {
 22800            if (fileStream == null)
 801            {
 0802                throw new ArgumentNullException(nameof(fileStream));
 803            }
 804
 22805            using var message = CreateAnalyzeLayoutAsyncRequest(contentType, fileStream);
 22806            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 20807            var headers = new ServiceAnalyzeLayoutAsyncHeaders(message.Response);
 20808            switch (message.Response.Status)
 809            {
 810                case 202:
 16811                    return ResponseWithHeaders.FromValue(headers, message.Response);
 812                default:
 4813                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 814            }
 16815        }
 816
 817        /// <summary> Extract text and layout information from a given document. The input document must be of one of th
 818        /// <param name="contentType"> Upload file type. </param>
 819        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 820        /// <param name="cancellationToken"> The cancellation token to use. </param>
 821        /// <exception cref="ArgumentNullException"> <paramref name="fileStream"/> is null. </exception>
 822        public ResponseWithHeaders<ServiceAnalyzeLayoutAsyncHeaders> AnalyzeLayoutAsync(FormContentType contentType, Str
 823        {
 22824            if (fileStream == null)
 825            {
 0826                throw new ArgumentNullException(nameof(fileStream));
 827            }
 828
 22829            using var message = CreateAnalyzeLayoutAsyncRequest(contentType, fileStream);
 22830            _pipeline.Send(message, cancellationToken);
 20831            var headers = new ServiceAnalyzeLayoutAsyncHeaders(message.Response);
 20832            switch (message.Response.Status)
 833            {
 834                case 202:
 16835                    return ResponseWithHeaders.FromValue(headers, message.Response);
 836                default:
 4837                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 838            }
 16839        }
 840
 841        internal HttpMessage CreateAnalyzeLayoutAsyncRequest(SourcePath fileStream)
 842        {
 36843            var message = _pipeline.CreateMessage();
 36844            var request = message.Request;
 36845            request.Method = RequestMethod.Post;
 36846            var uri = new RawRequestUriBuilder();
 36847            uri.AppendRaw(endpoint, false);
 36848            uri.AppendRaw("/formrecognizer/v2.0", false);
 36849            uri.AppendPath("/layout/analyze", false);
 36850            request.Uri = uri;
 36851            request.Headers.Add("Content-Type", "application/json");
 36852            if (fileStream != null)
 853            {
 36854                var content = new Utf8JsonRequestContent();
 36855                content.JsonWriter.WriteObjectValue(fileStream);
 36856                request.Content = content;
 857            }
 36858            return message;
 859        }
 860
 861        /// <summary> Extract text and layout information from a given document. The input document must be of one of th
 862        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 863        /// <param name="cancellationToken"> The cancellation token to use. </param>
 864        public async Task<ResponseWithHeaders<ServiceAnalyzeLayoutAsyncHeaders>> AnalyzeLayoutAsyncAsync(SourcePath file
 865        {
 20866            using var message = CreateAnalyzeLayoutAsyncRequest(fileStream);
 20867            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16868            var headers = new ServiceAnalyzeLayoutAsyncHeaders(message.Response);
 16869            switch (message.Response.Status)
 870            {
 871                case 202:
 14872                    return ResponseWithHeaders.FromValue(headers, message.Response);
 873                default:
 2874                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 875            }
 14876        }
 877
 878        /// <summary> Extract text and layout information from a given document. The input document must be of one of th
 879        /// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
 880        /// <param name="cancellationToken"> The cancellation token to use. </param>
 881        public ResponseWithHeaders<ServiceAnalyzeLayoutAsyncHeaders> AnalyzeLayoutAsync(SourcePath fileStream = null, Ca
 882        {
 16883            using var message = CreateAnalyzeLayoutAsyncRequest(fileStream);
 16884            _pipeline.Send(message, cancellationToken);
 12885            var headers = new ServiceAnalyzeLayoutAsyncHeaders(message.Response);
 12886            switch (message.Response.Status)
 887            {
 888                case 202:
 10889                    return ResponseWithHeaders.FromValue(headers, message.Response);
 890                default:
 2891                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 892            }
 10893        }
 894
 895        internal HttpMessage CreateGetAnalyzeLayoutResultRequest(Guid resultId)
 896        {
 180897            var message = _pipeline.CreateMessage();
 180898            var request = message.Request;
 180899            request.Method = RequestMethod.Get;
 180900            var uri = new RawRequestUriBuilder();
 180901            uri.AppendRaw(endpoint, false);
 180902            uri.AppendRaw("/formrecognizer/v2.0", false);
 180903            uri.AppendPath("/layout/analyzeResults/", false);
 180904            uri.AppendPath(resultId, true);
 180905            request.Uri = uri;
 180906            return message;
 907        }
 908
 909        /// <summary> Track the progress and obtain the result of the analyze layout operation. </summary>
 910        /// <param name="resultId"> Analyze operation result identifier. </param>
 911        /// <param name="cancellationToken"> The cancellation token to use. </param>
 912        public async Task<Response<AnalyzeOperationResult>> GetAnalyzeLayoutResultAsync(Guid resultId, CancellationToken
 913        {
 180914            using var message = CreateGetAnalyzeLayoutResultRequest(resultId);
 180915            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 180916            switch (message.Response.Status)
 917            {
 918                case 200:
 919                    {
 920                        AnalyzeOperationResult value = default;
 180921                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 180922                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 180923                        return Response.FromValue(value, message.Response);
 924                    }
 925                default:
 0926                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 927            }
 180928        }
 929
 930        /// <summary> Track the progress and obtain the result of the analyze layout operation. </summary>
 931        /// <param name="resultId"> Analyze operation result identifier. </param>
 932        /// <param name="cancellationToken"> The cancellation token to use. </param>
 933        public Response<AnalyzeOperationResult> GetAnalyzeLayoutResult(Guid resultId, CancellationToken cancellationToke
 934        {
 0935            using var message = CreateGetAnalyzeLayoutResultRequest(resultId);
 0936            _pipeline.Send(message, cancellationToken);
 0937            switch (message.Response.Status)
 938            {
 939                case 200:
 940                    {
 941                        AnalyzeOperationResult value = default;
 0942                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0943                        value = AnalyzeOperationResult.DeserializeAnalyzeOperationResult(document.RootElement);
 0944                        return Response.FromValue(value, message.Response);
 945                    }
 946                default:
 0947                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 948            }
 0949        }
 950
 951        internal HttpMessage CreateListCustomModelsRequest()
 952        {
 8953            var message = _pipeline.CreateMessage();
 8954            var request = message.Request;
 8955            request.Method = RequestMethod.Get;
 8956            var uri = new RawRequestUriBuilder();
 8957            uri.AppendRaw(endpoint, false);
 8958            uri.AppendRaw("/formrecognizer/v2.0", false);
 8959            uri.AppendPath("/custom/models", false);
 8960            uri.AppendQuery("op", "full", true);
 8961            request.Uri = uri;
 8962            return message;
 963        }
 964
 965        /// <summary> Get information about all custom models. </summary>
 966        /// <param name="cancellationToken"> The cancellation token to use. </param>
 967        public async Task<Response<Models.Models>> ListCustomModelsAsync(CancellationToken cancellationToken = default)
 968        {
 4969            using var message = CreateListCustomModelsRequest();
 4970            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4971            switch (message.Response.Status)
 972            {
 973                case 200:
 974                    {
 975                        Models.Models value = default;
 4976                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4977                        value = Models.Models.DeserializeModels(document.RootElement);
 4978                        return Response.FromValue(value, message.Response);
 979                    }
 980                default:
 0981                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 982            }
 4983        }
 984
 985        /// <summary> Get information about all custom models. </summary>
 986        /// <param name="cancellationToken"> The cancellation token to use. </param>
 987        public Response<Models.Models> ListCustomModels(CancellationToken cancellationToken = default)
 988        {
 4989            using var message = CreateListCustomModelsRequest();
 4990            _pipeline.Send(message, cancellationToken);
 4991            switch (message.Response.Status)
 992            {
 993                case 200:
 994                    {
 995                        Models.Models value = default;
 4996                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4997                        value = Models.Models.DeserializeModels(document.RootElement);
 4998                        return Response.FromValue(value, message.Response);
 999                    }
 1000                default:
 01001                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1002            }
 41003        }
 1004
 1005        internal HttpMessage CreateGetCustomModelsRequest()
 1006        {
 161007            var message = _pipeline.CreateMessage();
 161008            var request = message.Request;
 161009            request.Method = RequestMethod.Get;
 161010            var uri = new RawRequestUriBuilder();
 161011            uri.AppendRaw(endpoint, false);
 161012            uri.AppendRaw("/formrecognizer/v2.0", false);
 161013            uri.AppendPath("/custom/models", false);
 161014            uri.AppendQuery("op", "summary", true);
 161015            request.Uri = uri;
 161016            return message;
 1017        }
 1018
 1019        /// <summary> Get information about all custom models. </summary>
 1020        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1021        public async Task<Response<Models.Models>> GetCustomModelsAsync(CancellationToken cancellationToken = default)
 1022        {
 81023            using var message = CreateGetCustomModelsRequest();
 81024            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 61025            switch (message.Response.Status)
 1026            {
 1027                case 200:
 1028                    {
 1029                        Models.Models value = default;
 41030                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 41031                        value = Models.Models.DeserializeModels(document.RootElement);
 41032                        return Response.FromValue(value, message.Response);
 1033                    }
 1034                default:
 21035                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1036            }
 41037        }
 1038
 1039        /// <summary> Get information about all custom models. </summary>
 1040        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1041        public Response<Models.Models> GetCustomModels(CancellationToken cancellationToken = default)
 1042        {
 81043            using var message = CreateGetCustomModelsRequest();
 81044            _pipeline.Send(message, cancellationToken);
 61045            switch (message.Response.Status)
 1046            {
 1047                case 200:
 1048                    {
 1049                        Models.Models value = default;
 41050                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 41051                        value = Models.Models.DeserializeModels(document.RootElement);
 41052                        return Response.FromValue(value, message.Response);
 1053                    }
 1054                default:
 21055                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1056            }
 41057        }
 1058
 1059        internal HttpMessage CreateListCustomModelsNextPageRequest(string nextLink)
 1060        {
 41061            var message = _pipeline.CreateMessage();
 41062            var request = message.Request;
 41063            request.Method = RequestMethod.Get;
 41064            var uri = new RawRequestUriBuilder();
 41065            uri.AppendRaw(endpoint, false);
 41066            uri.AppendRaw("/formrecognizer/v2.0", false);
 41067            uri.AppendRawNextLink(nextLink, false);
 41068            request.Uri = uri;
 41069            return message;
 1070        }
 1071
 1072        /// <summary> Get information about all custom models. </summary>
 1073        /// <param name="nextLink"> The URL to the next page of results. </param>
 1074        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1075        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 1076        public async Task<Response<Models.Models>> ListCustomModelsNextPageAsync(string nextLink, CancellationToken canc
 1077        {
 41078            if (nextLink == null)
 1079            {
 01080                throw new ArgumentNullException(nameof(nextLink));
 1081            }
 1082
 41083            using var message = CreateListCustomModelsNextPageRequest(nextLink);
 41084            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41085            switch (message.Response.Status)
 1086            {
 1087                case 200:
 1088                    {
 1089                        Models.Models value = default;
 41090                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 41091                        value = Models.Models.DeserializeModels(document.RootElement);
 41092                        return Response.FromValue(value, message.Response);
 1093                    }
 1094                default:
 01095                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1096            }
 41097        }
 1098
 1099        /// <summary> Get information about all custom models. </summary>
 1100        /// <param name="nextLink"> The URL to the next page of results. </param>
 1101        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1102        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 1103        public Response<Models.Models> ListCustomModelsNextPage(string nextLink, CancellationToken cancellationToken = d
 1104        {
 01105            if (nextLink == null)
 1106            {
 01107                throw new ArgumentNullException(nameof(nextLink));
 1108            }
 1109
 01110            using var message = CreateListCustomModelsNextPageRequest(nextLink);
 01111            _pipeline.Send(message, cancellationToken);
 01112            switch (message.Response.Status)
 1113            {
 1114                case 200:
 1115                    {
 1116                        Models.Models value = default;
 01117                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01118                        value = Models.Models.DeserializeModels(document.RootElement);
 01119                        return Response.FromValue(value, message.Response);
 1120                    }
 1121                default:
 01122                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1123            }
 01124        }
 1125    }
 1126}

Methods/Properties

.ctor(...)
CreateTrainCustomModelAsyncRequest(...)
TrainCustomModelAsyncAsync()
TrainCustomModelAsync(...)
CreateGetCustomModelRequest(...)
GetCustomModelAsync()
GetCustomModel(...)
CreateDeleteCustomModelRequest(...)
DeleteCustomModelAsync()
DeleteCustomModel(...)
CreateAnalyzeWithCustomModelRequest(...)
AnalyzeWithCustomModelAsync()
AnalyzeWithCustomModel(...)
CreateAnalyzeWithCustomModelRequest(...)
AnalyzeWithCustomModelAsync()
AnalyzeWithCustomModel(...)
CreateGetAnalyzeFormResultRequest(...)
GetAnalyzeFormResultAsync()
GetAnalyzeFormResult(...)
CreateCopyCustomModelRequest(...)
CopyCustomModelAsync()
CopyCustomModel(...)
CreateGetCustomModelCopyResultRequest(...)
GetCustomModelCopyResultAsync()
GetCustomModelCopyResult(...)
CreateGenerateModelCopyAuthorizationRequest()
GenerateModelCopyAuthorizationAsync()
GenerateModelCopyAuthorization(...)
CreateAnalyzeReceiptAsyncRequest(...)
AnalyzeReceiptAsyncAsync()
AnalyzeReceiptAsync(...)
CreateAnalyzeReceiptAsyncRequest(...)
AnalyzeReceiptAsyncAsync()
AnalyzeReceiptAsync(...)
CreateGetAnalyzeReceiptResultRequest(...)
GetAnalyzeReceiptResultAsync()
GetAnalyzeReceiptResult(...)
CreateAnalyzeLayoutAsyncRequest(...)
AnalyzeLayoutAsyncAsync()
AnalyzeLayoutAsync(...)
CreateAnalyzeLayoutAsyncRequest(...)
AnalyzeLayoutAsyncAsync()
AnalyzeLayoutAsync(...)
CreateGetAnalyzeLayoutResultRequest(...)
GetAnalyzeLayoutResultAsync()
GetAnalyzeLayoutResult(...)
CreateListCustomModelsRequest()
ListCustomModelsAsync()
ListCustomModels(...)
CreateGetCustomModelsRequest()
GetCustomModelsAsync()
GetCustomModels(...)
CreateListCustomModelsNextPageRequest(...)
ListCustomModelsNextPageAsync()
ListCustomModelsNextPage(...)