From 2da7111d4bef2bab4a638860039edf0c294a0728 Mon Sep 17 00:00:00 2001 From: Michael Yanni Date: Mon, 9 Mar 2020 14:13:19 -0700 Subject: [PATCH] Fixed appending name information for non-overloads. Full regeneration. --- .../Generated/Operations/ServiceClient.cs | 48 ++++ .../Generated/Operations/ServiceRestClient.cs | 220 ++++++++++++++++++ .../Output/Builders/ClientBuilder.cs | 6 +- .../Generated/Operations/ServiceClient.cs | 4 +- 4 files changed, 274 insertions(+), 4 deletions(-) diff --git a/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceClient.cs b/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceClient.cs index 44e4c0ac..de0d2079 100644 --- a/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceClient.cs +++ b/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceClient.cs @@ -89,6 +89,24 @@ namespace Azure.AI.FormRecognizer { return RestClient.AnalyzeWithCustomModel(modelId, includeTextDetails, contentType, cancellationToken).GetRawResponse(); } + /// Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Model identifier. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual async Task AnalyzeWithCustomModelAsync(Guid modelId, bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + return (await RestClient.AnalyzeWithCustomModelAsync(modelId, includeTextDetails, fileStream, cancellationToken).ConfigureAwait(false)).GetRawResponse(); + } + /// Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Model identifier. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual Response AnalyzeWithCustomModel(Guid modelId, bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + return RestClient.AnalyzeWithCustomModel(modelId, includeTextDetails, fileStream, cancellationToken).GetRawResponse(); + } /// Obtain current status and the result of the analyze form operation. /// Model identifier. /// Analyze operation result identifier. @@ -121,6 +139,22 @@ namespace Azure.AI.FormRecognizer { return RestClient.AnalyzeReceiptAsync(includeTextDetails, contentType, cancellationToken).GetRawResponse(); } + /// Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual async Task AnalyzeReceiptAsyncAsync(bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + return (await RestClient.AnalyzeReceiptAsyncAsync(includeTextDetails, fileStream, cancellationToken).ConfigureAwait(false)).GetRawResponse(); + } + /// Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual Response AnalyzeReceiptAsync(bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + return RestClient.AnalyzeReceiptAsync(includeTextDetails, fileStream, cancellationToken).GetRawResponse(); + } /// Track the progress and obtain the result of the analyze receipt operation. /// Analyze operation result identifier. /// The cancellation token to use. @@ -149,6 +183,20 @@ namespace Azure.AI.FormRecognizer { return RestClient.AnalyzeLayoutAsync(contentType, cancellationToken).GetRawResponse(); } + /// Extract text and layout information from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual async Task AnalyzeLayoutAsyncAsync(SourcePath fileStream, CancellationToken cancellationToken = default) + { + return (await RestClient.AnalyzeLayoutAsyncAsync(fileStream, cancellationToken).ConfigureAwait(false)).GetRawResponse(); + } + /// Extract text and layout information from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public virtual Response AnalyzeLayoutAsync(SourcePath fileStream, CancellationToken cancellationToken = default) + { + return RestClient.AnalyzeLayoutAsync(fileStream, cancellationToken).GetRawResponse(); + } /// Track the progress and obtain the result of the analyze layout operation. /// Analyze operation result identifier. /// The cancellation token to use. diff --git a/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceRestClient.cs b/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceRestClient.cs index 30a52a00..f06ac653 100644 --- a/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceRestClient.cs +++ b/samples/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer/Generated/Operations/ServiceRestClient.cs @@ -403,6 +403,84 @@ namespace Azure.AI.FormRecognizer throw; } } + internal HttpMessage CreateAnalyzeWithCustomModelRequest(Guid modelId, bool? includeTextDetails, SourcePath fileStream) + { + var message = pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/formrecognizer/v2.0-preview", false); + uri.AppendPath("/custom/models/", false); + uri.AppendPath(modelId, true); + uri.AppendPath("/analyze", false); + if (includeTextDetails != null) + { + uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true); + } + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + using var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(fileStream); + request.Content = content; + return message; + } + /// Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Model identifier. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public async ValueTask> AnalyzeWithCustomModelAsync(Guid modelId, bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeWithCustomModel"); + scope.Start(); + try + { + using var message = CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream); + await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeWithCustomModelHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Model identifier. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public ResponseWithHeaders AnalyzeWithCustomModel(Guid modelId, bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeWithCustomModel"); + scope.Start(); + try + { + using var message = CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream); + pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeWithCustomModelHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } internal HttpMessage CreateGetAnalyzeFormResultRequest(Guid modelId, Guid resultId) { var message = pipeline.CreateMessage(); @@ -552,6 +630,80 @@ namespace Azure.AI.FormRecognizer throw; } } + internal HttpMessage CreateAnalyzeReceiptAsyncRequest(bool? includeTextDetails, SourcePath fileStream) + { + var message = pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/formrecognizer/v2.0-preview", false); + uri.AppendPath("/prebuilt/receipt/analyze", false); + if (includeTextDetails != null) + { + uri.AppendQuery("includeTextDetails", includeTextDetails.Value, true); + } + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + using var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(fileStream); + request.Content = content; + return message; + } + /// Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public async ValueTask> AnalyzeReceiptAsyncAsync(bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeReceiptAsync"); + scope.Start(); + try + { + using var message = CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream); + await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeReceiptAsyncHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// Include text lines and element references in the result. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public ResponseWithHeaders AnalyzeReceiptAsync(bool? includeTextDetails, SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeReceiptAsync"); + scope.Start(); + try + { + using var message = CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream); + pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeReceiptAsyncHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } internal HttpMessage CreateGetAnalyzeReceiptResultRequest(Guid resultId) { var message = pipeline.CreateMessage(); @@ -691,6 +843,74 @@ namespace Azure.AI.FormRecognizer throw; } } + internal HttpMessage CreateAnalyzeLayoutAsyncRequest(SourcePath fileStream) + { + var message = pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw(endpoint, false); + uri.AppendRaw("/formrecognizer/v2.0-preview", false); + uri.AppendPath("/layout/analyze", false); + request.Uri = uri; + request.Headers.Add("Content-Type", "application/json"); + using var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(fileStream); + request.Content = content; + return message; + } + /// Extract text and layout information from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public async ValueTask> AnalyzeLayoutAsyncAsync(SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeLayoutAsync"); + scope.Start(); + try + { + using var message = CreateAnalyzeLayoutAsyncRequest(fileStream); + await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeLayoutAsyncHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// Extract text and layout information from a given document. The input document must be of one of the supported content types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. Alternatively, use 'application/json' type to specify the location (Uri or local path) of the document to be analyzed. + /// .json, .pdf, .jpg, .png or .tiff type file stream. + /// The cancellation token to use. + public ResponseWithHeaders AnalyzeLayoutAsync(SourcePath fileStream, CancellationToken cancellationToken = default) + { + using var scope = clientDiagnostics.CreateScope("ServiceClient.AnalyzeLayoutAsync"); + scope.Start(); + try + { + using var message = CreateAnalyzeLayoutAsyncRequest(fileStream); + pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + var headers = new AnalyzeLayoutAsyncHeaders(message.Response); + return ResponseWithHeaders.FromValue(headers, message.Response); + default: + throw clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } internal HttpMessage CreateGetAnalyzeLayoutResultRequest(Guid resultId) { var message = pipeline.CreateMessage(); diff --git a/src/AutoRest.CSharp.V3/Output/Builders/ClientBuilder.cs b/src/AutoRest.CSharp.V3/Output/Builders/ClientBuilder.cs index d5b52f7f..b8a95edd 100644 --- a/src/AutoRest.CSharp.V3/Output/Builders/ClientBuilder.cs +++ b/src/AutoRest.CSharp.V3/Output/Builders/ClientBuilder.cs @@ -60,7 +60,7 @@ namespace AutoRest.CSharp.V3.Output.Builders Dictionary operationMethods = new Dictionary(StringComparer.InvariantCultureIgnoreCase); foreach (Operation operation in operationGroup.Operations) { - int overloadCount = 0; + int overloadSuffix = 0; foreach (ServiceRequest serviceRequest in operation.Requests) { HttpRequest? httpRequest = serviceRequest.Protocol.Http as HttpRequest; @@ -71,7 +71,9 @@ namespace AutoRest.CSharp.V3.Output.Builders } RestClientMethod method = BuildMethod(operation, clientName, clientParameters, httpRequest, serviceRequest.Parameters); - operationMethods.Add($"{operation.Language.Default.Name}{overloadCount++}", new OperationMethod(operation, method)); + string suffix = overloadSuffix > 0 ? $"{overloadSuffix}" : String.Empty; + overloadSuffix++; + operationMethods.Add($"{operation.Language.Default.Name}{suffix}", new OperationMethod(operation, method)); } } diff --git a/test/TestServerProjects/media_types/Generated/Operations/ServiceClient.cs b/test/TestServerProjects/media_types/Generated/Operations/ServiceClient.cs index bdf5da8c..a9c5e080 100644 --- a/test/TestServerProjects/media_types/Generated/Operations/ServiceClient.cs +++ b/test/TestServerProjects/media_types/Generated/Operations/ServiceClient.cs @@ -28,7 +28,7 @@ namespace media_types /// Analyze body, that could be different media types. /// Upload file type. /// The cancellation token to use. - public virtual async ValueTask> AnalyzeBodyAsync(ContentType? contentType, CancellationToken cancellationToken = default) + public virtual async Task> AnalyzeBodyAsync(ContentType? contentType, CancellationToken cancellationToken = default) { return await RestClient.AnalyzeBodyAsync(contentType, cancellationToken).ConfigureAwait(false); } @@ -42,7 +42,7 @@ namespace media_types /// Analyze body, that could be different media types. /// Input parameter. /// The cancellation token to use. - public virtual async ValueTask> AnalyzeBodyAsync(SourcePath input, CancellationToken cancellationToken = default) + public virtual async Task> AnalyzeBodyAsync(SourcePath input, CancellationToken cancellationToken = default) { return await RestClient.AnalyzeBodyAsync(input, cancellationToken).ConfigureAwait(false); }