This commit is contained in:
Pavel Krymets 2020-05-04 16:03:25 -07:00 коммит произвёл GitHub
Родитель 0b6a85dcb0
Коммит a5cce37553
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
116 изменённых файлов: 8221 добавлений и 4241 удалений

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.AI.FormRecognizer
{
/// <summary> Extract text and layout information from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
public partial class ServiceAnalyzeLayoutAsyncOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal ServiceAnalyzeLayoutAsyncOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServiceAnalyzeLayoutAsyncOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.AI.FormRecognizer
{
/// <summary> Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
public partial class ServiceAnalyzeReceiptAsyncOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal ServiceAnalyzeReceiptAsyncOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServiceAnalyzeReceiptAsyncOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.AI.FormRecognizer
{
/// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
public partial class ServiceAnalyzeWithCustomModelOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal ServiceAnalyzeWithCustomModelOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServiceAnalyzeWithCustomModelOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -434,30 +434,13 @@ namespace Azure.AI.FormRecognizer
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
}
/// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateAnalyzeWithCustomModel(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "ServiceClient.StartAnalyzeWithCustomModel", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Extract key-value pairs, tables, and semantic values from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="modelId"> Model identifier. </param>
/// <param name="contentType"> Upload file type. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeWithCustomModelAsync(Guid modelId, ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeWithCustomModelOperation> StartAnalyzeWithCustomModelAsync(Guid modelId, ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -469,7 +452,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = await RestClient.AnalyzeWithCustomModelAsync(modelId, contentType, fileStream, includeTextDetails, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeWithCustomModel(originalResponse, () => RestClient.CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails));
return new ServiceAnalyzeWithCustomModelOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails).Request, originalResponse);
}
catch (Exception e)
{
@ -484,7 +467,7 @@ namespace Azure.AI.FormRecognizer
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeWithCustomModel(Guid modelId, ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeWithCustomModelOperation StartAnalyzeWithCustomModel(Guid modelId, ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -496,7 +479,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = RestClient.AnalyzeWithCustomModel(modelId, contentType, fileStream, includeTextDetails, cancellationToken);
return CreateAnalyzeWithCustomModel(originalResponse, () => RestClient.CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails));
return new ServiceAnalyzeWithCustomModelOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeWithCustomModelRequest(modelId, contentType, fileStream, includeTextDetails).Request, originalResponse);
}
catch (Exception e)
{
@ -510,14 +493,14 @@ namespace Azure.AI.FormRecognizer
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeWithCustomModelAsync(Guid modelId, bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeWithCustomModelOperation> StartAnalyzeWithCustomModelAsync(Guid modelId, bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeWithCustomModel");
scope.Start();
try
{
var originalResponse = await RestClient.AnalyzeWithCustomModelAsync(modelId, includeTextDetails, fileStream, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeWithCustomModel(originalResponse, () => RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream));
return new ServiceAnalyzeWithCustomModelOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -531,14 +514,14 @@ namespace Azure.AI.FormRecognizer
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeWithCustomModel(Guid modelId, bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeWithCustomModelOperation StartAnalyzeWithCustomModel(Guid modelId, bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeWithCustomModel");
scope.Start();
try
{
var originalResponse = RestClient.AnalyzeWithCustomModel(modelId, includeTextDetails, fileStream, cancellationToken);
return CreateAnalyzeWithCustomModel(originalResponse, () => RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream));
return new ServiceAnalyzeWithCustomModelOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeWithCustomModelRequest(modelId, includeTextDetails, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -614,29 +597,12 @@ namespace Azure.AI.FormRecognizer
}
}
/// <summary> Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateAnalyzeReceiptAsync(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "ServiceClient.StartAnalyzeReceiptAsync", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Extract field text and semantic values from a given receipt document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="contentType"> Upload file type. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeReceiptAsyncAsync(ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeReceiptAsyncOperation> StartAnalyzeReceiptAsyncAsync(ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -648,7 +614,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = await RestClient.AnalyzeReceiptAsyncAsync(contentType, fileStream, includeTextDetails, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeReceiptAsync(originalResponse, () => RestClient.CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails));
return new ServiceAnalyzeReceiptAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails).Request, originalResponse);
}
catch (Exception e)
{
@ -662,7 +628,7 @@ namespace Azure.AI.FormRecognizer
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeReceiptAsync(ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeReceiptAsyncOperation StartAnalyzeReceiptAsync(ContentType contentType, Stream fileStream, bool? includeTextDetails = null, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -674,7 +640,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = RestClient.AnalyzeReceiptAsync(contentType, fileStream, includeTextDetails, cancellationToken);
return CreateAnalyzeReceiptAsync(originalResponse, () => RestClient.CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails));
return new ServiceAnalyzeReceiptAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeReceiptAsyncRequest(contentType, fileStream, includeTextDetails).Request, originalResponse);
}
catch (Exception e)
{
@ -687,14 +653,14 @@ namespace Azure.AI.FormRecognizer
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeReceiptAsyncAsync(bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeReceiptAsyncOperation> StartAnalyzeReceiptAsyncAsync(bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeReceiptAsync");
scope.Start();
try
{
var originalResponse = await RestClient.AnalyzeReceiptAsyncAsync(includeTextDetails, fileStream, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeReceiptAsync(originalResponse, () => RestClient.CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream));
return new ServiceAnalyzeReceiptAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -707,14 +673,14 @@ namespace Azure.AI.FormRecognizer
/// <param name="includeTextDetails"> Include text lines and element references in the result. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeReceiptAsync(bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeReceiptAsyncOperation StartAnalyzeReceiptAsync(bool? includeTextDetails = null, SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeReceiptAsync");
scope.Start();
try
{
var originalResponse = RestClient.AnalyzeReceiptAsync(includeTextDetails, fileStream, cancellationToken);
return CreateAnalyzeReceiptAsync(originalResponse, () => RestClient.CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream));
return new ServiceAnalyzeReceiptAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeReceiptAsyncRequest(includeTextDetails, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -723,28 +689,11 @@ namespace Azure.AI.FormRecognizer
}
}
/// <summary> Extract text and layout information from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateAnalyzeLayoutAsync(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "ServiceClient.StartAnalyzeLayoutAsync", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Extract text and layout information from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="contentType"> Upload file type. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeLayoutAsyncAsync(ContentType contentType, Stream fileStream, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeLayoutAsyncOperation> StartAnalyzeLayoutAsyncAsync(ContentType contentType, Stream fileStream, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -756,7 +705,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = await RestClient.AnalyzeLayoutAsyncAsync(contentType, fileStream, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeLayoutAsync(originalResponse, () => RestClient.CreateAnalyzeLayoutAsyncRequest(contentType, fileStream));
return new ServiceAnalyzeLayoutAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeLayoutAsyncRequest(contentType, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -769,7 +718,7 @@ namespace Azure.AI.FormRecognizer
/// <param name="contentType"> Upload file type. </param>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeLayoutAsync(ContentType contentType, Stream fileStream, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeLayoutAsyncOperation StartAnalyzeLayoutAsync(ContentType contentType, Stream fileStream, CancellationToken cancellationToken = default)
{
if (fileStream == null)
{
@ -781,7 +730,7 @@ namespace Azure.AI.FormRecognizer
try
{
var originalResponse = RestClient.AnalyzeLayoutAsync(contentType, fileStream, cancellationToken);
return CreateAnalyzeLayoutAsync(originalResponse, () => RestClient.CreateAnalyzeLayoutAsyncRequest(contentType, fileStream));
return new ServiceAnalyzeLayoutAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeLayoutAsyncRequest(contentType, fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -793,14 +742,14 @@ namespace Azure.AI.FormRecognizer
/// <summary> Extract text and layout information from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeLayoutAsyncAsync(SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeLayoutAsyncOperation> StartAnalyzeLayoutAsyncAsync(SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeLayoutAsync");
scope.Start();
try
{
var originalResponse = await RestClient.AnalyzeLayoutAsyncAsync(fileStream, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeLayoutAsync(originalResponse, () => RestClient.CreateAnalyzeLayoutAsyncRequest(fileStream));
return new ServiceAnalyzeLayoutAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeLayoutAsyncRequest(fileStream).Request, originalResponse);
}
catch (Exception e)
{
@ -812,14 +761,14 @@ namespace Azure.AI.FormRecognizer
/// <summary> Extract text and layout information from a given document. The input document must be of one of the supported content types - &apos;application/pdf&apos;, &apos;image/jpeg&apos;, &apos;image/png&apos; or &apos;image/tiff&apos;. Alternatively, use &apos;application/json&apos; type to specify the location (Uri or local path) of the document to be analyzed. </summary>
/// <param name="fileStream"> .json, .pdf, .jpg, .png or .tiff type file stream. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeLayoutAsync(SourcePath fileStream = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeLayoutAsyncOperation StartAnalyzeLayoutAsync(SourcePath fileStream = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeLayoutAsync");
scope.Start();
try
{
var originalResponse = RestClient.AnalyzeLayoutAsync(fileStream, cancellationToken);
return CreateAnalyzeLayoutAsync(originalResponse, () => RestClient.CreateAnalyzeLayoutAsyncRequest(fileStream));
return new ServiceAnalyzeLayoutAsyncOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeLayoutAsyncRequest(fileStream).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
@ -519,53 +518,12 @@ namespace Azure.Management.Storage
return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
}
/// <summary> Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<StorageAccount> CreateCreate(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "StorageAccountsClient.StartCreate", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return StorageAccount.DeserializeStorageAccount(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return StorageAccount.DeserializeStorageAccount(document.RootElement);
}
});
}
/// <summary> Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. </summary>
/// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The name is case insensitive. </param>
/// <param name="accountName"> The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. </param>
/// <param name="parameters"> The parameters to provide for the created account. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<StorageAccount>> StartCreateAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default)
public virtual async ValueTask<StorageAccountsCreateOperation> StartCreateAsync(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -585,7 +543,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = await RestClient.CreateAsync(resourceGroupName, accountName, parameters, cancellationToken).ConfigureAwait(false);
return CreateCreate(originalResponse, () => RestClient.CreateCreateRequest(resourceGroupName, accountName, parameters));
return new StorageAccountsCreateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateRequest(resourceGroupName, accountName, parameters).Request, originalResponse);
}
catch (Exception e)
{
@ -599,7 +557,7 @@ namespace Azure.Management.Storage
/// <param name="accountName"> The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. </param>
/// <param name="parameters"> The parameters to provide for the created account. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<StorageAccount> StartCreate(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default)
public virtual StorageAccountsCreateOperation StartCreate(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -619,7 +577,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = RestClient.Create(resourceGroupName, accountName, parameters, cancellationToken);
return CreateCreate(originalResponse, () => RestClient.CreateCreateRequest(resourceGroupName, accountName, parameters));
return new StorageAccountsCreateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateRequest(resourceGroupName, accountName, parameters).Request, originalResponse);
}
catch (Exception e)
{
@ -628,28 +586,11 @@ namespace Azure.Management.Storage
}
}
/// <summary> Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account&apos;s primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateFailover(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "StorageAccountsClient.StartFailover", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account&apos;s primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. </summary>
/// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The name is case insensitive. </param>
/// <param name="accountName"> The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartFailoverAsync(string resourceGroupName, string accountName, CancellationToken cancellationToken = default)
public virtual async ValueTask<StorageAccountsFailoverOperation> StartFailoverAsync(string resourceGroupName, string accountName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -665,7 +606,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = await RestClient.FailoverAsync(resourceGroupName, accountName, cancellationToken).ConfigureAwait(false);
return CreateFailover(originalResponse, () => RestClient.CreateFailoverRequest(resourceGroupName, accountName));
return new StorageAccountsFailoverOperation(_clientDiagnostics, _pipeline, RestClient.CreateFailoverRequest(resourceGroupName, accountName).Request, originalResponse);
}
catch (Exception e)
{
@ -678,7 +619,7 @@ namespace Azure.Management.Storage
/// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The name is case insensitive. </param>
/// <param name="accountName"> The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartFailover(string resourceGroupName, string accountName, CancellationToken cancellationToken = default)
public virtual StorageAccountsFailoverOperation StartFailover(string resourceGroupName, string accountName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -694,7 +635,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = RestClient.Failover(resourceGroupName, accountName, cancellationToken);
return CreateFailover(originalResponse, () => RestClient.CreateFailoverRequest(resourceGroupName, accountName));
return new StorageAccountsFailoverOperation(_clientDiagnostics, _pipeline, RestClient.CreateFailoverRequest(resourceGroupName, accountName).Request, originalResponse);
}
catch (Exception e)
{
@ -703,54 +644,13 @@ namespace Azure.Management.Storage
}
}
/// <summary> Restore blobs in the specified blob ranges. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<BlobRestoreStatus> CreateRestoreBlobRanges(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "StorageAccountsClient.StartRestoreBlobRanges", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return BlobRestoreStatus.DeserializeBlobRestoreStatus(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return BlobRestoreStatus.DeserializeBlobRestoreStatus(document.RootElement);
}
});
}
/// <summary> Restore blobs in the specified blob ranges. </summary>
/// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The name is case insensitive. </param>
/// <param name="accountName"> The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. </param>
/// <param name="timeToRestore"> Restore blob to the specified time. </param>
/// <param name="blobRanges"> Blob ranges to restore. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<BlobRestoreStatus>> StartRestoreBlobRangesAsync(string resourceGroupName, string accountName, DateTimeOffset timeToRestore, IEnumerable<BlobRestoreRange> blobRanges, CancellationToken cancellationToken = default)
public virtual async ValueTask<StorageAccountsRestoreBlobRangesOperation> StartRestoreBlobRangesAsync(string resourceGroupName, string accountName, DateTimeOffset timeToRestore, IEnumerable<BlobRestoreRange> blobRanges, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -770,7 +670,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = await RestClient.RestoreBlobRangesAsync(resourceGroupName, accountName, timeToRestore, blobRanges, cancellationToken).ConfigureAwait(false);
return CreateRestoreBlobRanges(originalResponse, () => RestClient.CreateRestoreBlobRangesRequest(resourceGroupName, accountName, timeToRestore, blobRanges));
return new StorageAccountsRestoreBlobRangesOperation(_clientDiagnostics, _pipeline, RestClient.CreateRestoreBlobRangesRequest(resourceGroupName, accountName, timeToRestore, blobRanges).Request, originalResponse);
}
catch (Exception e)
{
@ -785,7 +685,7 @@ namespace Azure.Management.Storage
/// <param name="timeToRestore"> Restore blob to the specified time. </param>
/// <param name="blobRanges"> Blob ranges to restore. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<BlobRestoreStatus> StartRestoreBlobRanges(string resourceGroupName, string accountName, DateTimeOffset timeToRestore, IEnumerable<BlobRestoreRange> blobRanges, CancellationToken cancellationToken = default)
public virtual StorageAccountsRestoreBlobRangesOperation StartRestoreBlobRanges(string resourceGroupName, string accountName, DateTimeOffset timeToRestore, IEnumerable<BlobRestoreRange> blobRanges, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -805,7 +705,7 @@ namespace Azure.Management.Storage
try
{
var originalResponse = RestClient.RestoreBlobRanges(resourceGroupName, accountName, timeToRestore, blobRanges, cancellationToken);
return CreateRestoreBlobRanges(originalResponse, () => RestClient.CreateRestoreBlobRangesRequest(resourceGroupName, accountName, timeToRestore, blobRanges));
return new StorageAccountsRestoreBlobRangesOperation(_clientDiagnostics, _pipeline, RestClient.CreateRestoreBlobRangesRequest(resourceGroupName, accountName, timeToRestore, blobRanges).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Management.Storage.Models;
namespace Azure.Management.Storage
{
/// <summary> Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. </summary>
public partial class StorageAccountsCreateOperation : Operation<StorageAccount>, IOperationSource<StorageAccount>
{
private readonly ArmOperationHelpers<StorageAccount> _operation;
internal StorageAccountsCreateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<StorageAccount>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "StorageAccountsCreateOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override StorageAccount Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<StorageAccount>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<StorageAccount>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
StorageAccount IOperationSource<StorageAccount>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return StorageAccount.DeserializeStorageAccount(document.RootElement);
}
}
async ValueTask<StorageAccount> IOperationSource<StorageAccount>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return StorageAccount.DeserializeStorageAccount(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.Management.Storage
{
/// <summary> Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account&apos;s primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. </summary>
public partial class StorageAccountsFailoverOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal StorageAccountsFailoverOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "StorageAccountsFailoverOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Management.Storage.Models;
namespace Azure.Management.Storage
{
/// <summary> Restore blobs in the specified blob ranges. </summary>
public partial class StorageAccountsRestoreBlobRangesOperation : Operation<BlobRestoreStatus>, IOperationSource<BlobRestoreStatus>
{
private readonly ArmOperationHelpers<BlobRestoreStatus> _operation;
internal StorageAccountsRestoreBlobRangesOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<BlobRestoreStatus>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "StorageAccountsRestoreBlobRangesOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override BlobRestoreStatus Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<BlobRestoreStatus>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<BlobRestoreStatus>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
BlobRestoreStatus IOperationSource<BlobRestoreStatus>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return BlobRestoreStatus.DeserializeBlobRestoreStatus(document.RootElement);
}
}
async ValueTask<BlobRestoreStatus> IOperationSource<BlobRestoreStatus>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return BlobRestoreStatus.DeserializeBlobRestoreStatus(document.RootElement);
}
}
}
}

Просмотреть файл

@ -6,7 +6,6 @@
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
@ -170,29 +169,12 @@ namespace Azure.Network.Management.Interface
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
}
/// <summary> Deletes the specified tap configuration from the NetworkInterface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateDelete(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Delete, "NetworkInterfaceTapConfigurationsClient.StartDelete", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Deletes the specified tap configuration from the NetworkInterface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="tapConfigurationName"> The name of the tap configuration. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartDeleteAsync(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfaceTapConfigurationsDeleteOperation> StartDeleteAsync(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -212,7 +194,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.DeleteAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, cancellationToken).ConfigureAwait(false);
return CreateDelete(originalResponse, () => RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName, tapConfigurationName));
return new NetworkInterfaceTapConfigurationsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName, tapConfigurationName).Request, originalResponse);
}
catch (Exception e)
{
@ -226,7 +208,7 @@ namespace Azure.Network.Management.Interface
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="tapConfigurationName"> The name of the tap configuration. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartDelete(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, CancellationToken cancellationToken = default)
public virtual NetworkInterfaceTapConfigurationsDeleteOperation StartDelete(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -246,7 +228,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.Delete(resourceGroupName, networkInterfaceName, tapConfigurationName, cancellationToken);
return CreateDelete(originalResponse, () => RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName, tapConfigurationName));
return new NetworkInterfaceTapConfigurationsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName, tapConfigurationName).Request, originalResponse);
}
catch (Exception e)
{
@ -255,54 +237,13 @@ namespace Azure.Network.Management.Interface
}
}
/// <summary> Creates or updates a Tap configuration in the specified NetworkInterface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<NetworkInterfaceTapConfiguration> CreateCreateOrUpdate(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "NetworkInterfaceTapConfigurationsClient.StartCreateOrUpdate", OperationFinalStateVia.AzureAsyncOperation, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterfaceTapConfiguration.DeserializeNetworkInterfaceTapConfiguration(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterfaceTapConfiguration.DeserializeNetworkInterfaceTapConfiguration(document.RootElement);
}
});
}
/// <summary> Creates or updates a Tap configuration in the specified NetworkInterface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="tapConfigurationName"> The name of the tap configuration. </param>
/// <param name="tapConfigurationParameters"> Parameters supplied to the create or update tap configuration operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<NetworkInterfaceTapConfiguration>> StartCreateOrUpdateAsync(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, NetworkInterfaceTapConfiguration tapConfigurationParameters, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfaceTapConfigurationsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, NetworkInterfaceTapConfiguration tapConfigurationParameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -326,7 +267,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters, cancellationToken).ConfigureAwait(false);
return CreateCreateOrUpdate(originalResponse, () => RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters));
return new NetworkInterfaceTapConfigurationsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).Request, originalResponse);
}
catch (Exception e)
{
@ -341,7 +282,7 @@ namespace Azure.Network.Management.Interface
/// <param name="tapConfigurationName"> The name of the tap configuration. </param>
/// <param name="tapConfigurationParameters"> Parameters supplied to the create or update tap configuration operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<NetworkInterfaceTapConfiguration> StartCreateOrUpdate(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, NetworkInterfaceTapConfiguration tapConfigurationParameters, CancellationToken cancellationToken = default)
public virtual NetworkInterfaceTapConfigurationsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string networkInterfaceName, string tapConfigurationName, NetworkInterfaceTapConfiguration tapConfigurationParameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -365,7 +306,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters, cancellationToken);
return CreateCreateOrUpdate(originalResponse, () => RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters));
return new NetworkInterfaceTapConfigurationsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, tapConfigurationName, tapConfigurationParameters).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Network.Management.Interface.Models;
namespace Azure.Network.Management.Interface
{
/// <summary> Creates or updates a Tap configuration in the specified NetworkInterface. </summary>
public partial class NetworkInterfaceTapConfigurationsCreateOrUpdateOperation : Operation<NetworkInterfaceTapConfiguration>, IOperationSource<NetworkInterfaceTapConfiguration>
{
private readonly ArmOperationHelpers<NetworkInterfaceTapConfiguration> _operation;
internal NetworkInterfaceTapConfigurationsCreateOrUpdateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<NetworkInterfaceTapConfiguration>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.AzureAsyncOperation, "NetworkInterfaceTapConfigurationsCreateOrUpdateOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override NetworkInterfaceTapConfiguration Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<NetworkInterfaceTapConfiguration>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<NetworkInterfaceTapConfiguration>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
NetworkInterfaceTapConfiguration IOperationSource<NetworkInterfaceTapConfiguration>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterfaceTapConfiguration.DeserializeNetworkInterfaceTapConfiguration(document.RootElement);
}
}
async ValueTask<NetworkInterfaceTapConfiguration> IOperationSource<NetworkInterfaceTapConfiguration>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterfaceTapConfiguration.DeserializeNetworkInterfaceTapConfiguration(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.Network.Management.Interface
{
/// <summary> Deletes the specified tap configuration from the NetworkInterface. </summary>
public partial class NetworkInterfaceTapConfigurationsDeleteOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal NetworkInterfaceTapConfigurationsDeleteOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "NetworkInterfaceTapConfigurationsDeleteOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -6,7 +6,6 @@
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
@ -274,28 +273,11 @@ namespace Azure.Network.Management.Interface
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
}
/// <summary> Deletes the specified network interface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateDelete(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Delete, "NetworkInterfacesClient.StartDelete", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Deletes the specified network interface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartDeleteAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfacesDeleteOperation> StartDeleteAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -311,7 +293,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.DeleteAsync(resourceGroupName, networkInterfaceName, cancellationToken).ConfigureAwait(false);
return CreateDelete(originalResponse, () => RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{
@ -324,7 +306,7 @@ namespace Azure.Network.Management.Interface
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartDelete(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual NetworkInterfacesDeleteOperation StartDelete(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -340,7 +322,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.Delete(resourceGroupName, networkInterfaceName, cancellationToken);
return CreateDelete(originalResponse, () => RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{
@ -349,53 +331,12 @@ namespace Azure.Network.Management.Interface
}
}
/// <summary> Creates or updates a network interface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<NetworkInterface> CreateCreateOrUpdate(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "NetworkInterfacesClient.StartCreateOrUpdate", OperationFinalStateVia.AzureAsyncOperation, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterface.DeserializeNetworkInterface(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterface.DeserializeNetworkInterface(document.RootElement);
}
});
}
/// <summary> Creates or updates a network interface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="parameters"> Parameters supplied to the create or update network interface operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<NetworkInterface>> StartCreateOrUpdateAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfacesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -415,7 +356,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, networkInterfaceName, parameters, cancellationToken).ConfigureAwait(false);
return CreateCreateOrUpdate(originalResponse, () => RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, parameters));
return new NetworkInterfacesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, parameters).Request, originalResponse);
}
catch (Exception e)
{
@ -429,7 +370,7 @@ namespace Azure.Network.Management.Interface
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="parameters"> Parameters supplied to the create or update network interface operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<NetworkInterface> StartCreateOrUpdate(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default)
public virtual NetworkInterfacesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string networkInterfaceName, NetworkInterface parameters, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -449,7 +390,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkInterfaceName, parameters, cancellationToken);
return CreateCreateOrUpdate(originalResponse, () => RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, parameters));
return new NetworkInterfacesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, networkInterfaceName, parameters).Request, originalResponse);
}
catch (Exception e)
{
@ -458,52 +399,11 @@ namespace Azure.Network.Management.Interface
}
}
/// <summary> Gets all route tables applied to a network interface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<EffectiveRouteListResult> CreateGetEffectiveRouteTable(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "NetworkInterfacesClient.StartGetEffectiveRouteTable", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveRouteListResult.DeserializeEffectiveRouteListResult(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveRouteListResult.DeserializeEffectiveRouteListResult(document.RootElement);
}
});
}
/// <summary> Gets all route tables applied to a network interface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<EffectiveRouteListResult>> StartGetEffectiveRouteTableAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfacesGetEffectiveRouteTableOperation> StartGetEffectiveRouteTableAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -519,7 +419,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.GetEffectiveRouteTableAsync(resourceGroupName, networkInterfaceName, cancellationToken).ConfigureAwait(false);
return CreateGetEffectiveRouteTable(originalResponse, () => RestClient.CreateGetEffectiveRouteTableRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesGetEffectiveRouteTableOperation(_clientDiagnostics, _pipeline, RestClient.CreateGetEffectiveRouteTableRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{
@ -532,7 +432,7 @@ namespace Azure.Network.Management.Interface
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<EffectiveRouteListResult> StartGetEffectiveRouteTable(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual NetworkInterfacesGetEffectiveRouteTableOperation StartGetEffectiveRouteTable(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -548,7 +448,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.GetEffectiveRouteTable(resourceGroupName, networkInterfaceName, cancellationToken);
return CreateGetEffectiveRouteTable(originalResponse, () => RestClient.CreateGetEffectiveRouteTableRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesGetEffectiveRouteTableOperation(_clientDiagnostics, _pipeline, RestClient.CreateGetEffectiveRouteTableRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{
@ -557,52 +457,11 @@ namespace Azure.Network.Management.Interface
}
}
/// <summary> Gets all network security groups applied to a network interface. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<EffectiveNetworkSecurityGroupListResult> CreateListEffectiveNetworkSecurityGroups(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "NetworkInterfacesClient.StartListEffectiveNetworkSecurityGroups", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveNetworkSecurityGroupListResult.DeserializeEffectiveNetworkSecurityGroupListResult(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveNetworkSecurityGroupListResult.DeserializeEffectiveNetworkSecurityGroupListResult(document.RootElement);
}
});
}
/// <summary> Gets all network security groups applied to a network interface. </summary>
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<EffectiveNetworkSecurityGroupListResult>> StartListEffectiveNetworkSecurityGroupsAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual async ValueTask<NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation> StartListEffectiveNetworkSecurityGroupsAsync(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -618,7 +477,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = await RestClient.ListEffectiveNetworkSecurityGroupsAsync(resourceGroupName, networkInterfaceName, cancellationToken).ConfigureAwait(false);
return CreateListEffectiveNetworkSecurityGroups(originalResponse, () => RestClient.CreateListEffectiveNetworkSecurityGroupsRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation(_clientDiagnostics, _pipeline, RestClient.CreateListEffectiveNetworkSecurityGroupsRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{
@ -631,7 +490,7 @@ namespace Azure.Network.Management.Interface
/// <param name="resourceGroupName"> The name of the resource group. </param>
/// <param name="networkInterfaceName"> The name of the network interface. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<EffectiveNetworkSecurityGroupListResult> StartListEffectiveNetworkSecurityGroups(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
public virtual NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation StartListEffectiveNetworkSecurityGroups(string resourceGroupName, string networkInterfaceName, CancellationToken cancellationToken = default)
{
if (resourceGroupName == null)
{
@ -647,7 +506,7 @@ namespace Azure.Network.Management.Interface
try
{
var originalResponse = RestClient.ListEffectiveNetworkSecurityGroups(resourceGroupName, networkInterfaceName, cancellationToken);
return CreateListEffectiveNetworkSecurityGroups(originalResponse, () => RestClient.CreateListEffectiveNetworkSecurityGroupsRequest(resourceGroupName, networkInterfaceName));
return new NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation(_clientDiagnostics, _pipeline, RestClient.CreateListEffectiveNetworkSecurityGroupsRequest(resourceGroupName, networkInterfaceName).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Network.Management.Interface.Models;
namespace Azure.Network.Management.Interface
{
/// <summary> Creates or updates a network interface. </summary>
public partial class NetworkInterfacesCreateOrUpdateOperation : Operation<NetworkInterface>, IOperationSource<NetworkInterface>
{
private readonly ArmOperationHelpers<NetworkInterface> _operation;
internal NetworkInterfacesCreateOrUpdateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<NetworkInterface>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.AzureAsyncOperation, "NetworkInterfacesCreateOrUpdateOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override NetworkInterface Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<NetworkInterface>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<NetworkInterface>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
NetworkInterface IOperationSource<NetworkInterface>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterface.DeserializeNetworkInterface(document.RootElement);
}
}
async ValueTask<NetworkInterface> IOperationSource<NetworkInterface>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return NetworkInterface.DeserializeNetworkInterface(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace Azure.Network.Management.Interface
{
/// <summary> Deletes the specified network interface. </summary>
public partial class NetworkInterfacesDeleteOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal NetworkInterfacesDeleteOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "NetworkInterfacesDeleteOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Network.Management.Interface.Models;
namespace Azure.Network.Management.Interface
{
/// <summary> Gets all route tables applied to a network interface. </summary>
public partial class NetworkInterfacesGetEffectiveRouteTableOperation : Operation<EffectiveRouteListResult>, IOperationSource<EffectiveRouteListResult>
{
private readonly ArmOperationHelpers<EffectiveRouteListResult> _operation;
internal NetworkInterfacesGetEffectiveRouteTableOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<EffectiveRouteListResult>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "NetworkInterfacesGetEffectiveRouteTableOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override EffectiveRouteListResult Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<EffectiveRouteListResult>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<EffectiveRouteListResult>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
EffectiveRouteListResult IOperationSource<EffectiveRouteListResult>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveRouteListResult.DeserializeEffectiveRouteListResult(document.RootElement);
}
}
async ValueTask<EffectiveRouteListResult> IOperationSource<EffectiveRouteListResult>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveRouteListResult.DeserializeEffectiveRouteListResult(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Network.Management.Interface.Models;
namespace Azure.Network.Management.Interface
{
/// <summary> Gets all network security groups applied to a network interface. </summary>
public partial class NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation : Operation<EffectiveNetworkSecurityGroupListResult>, IOperationSource<EffectiveNetworkSecurityGroupListResult>
{
private readonly ArmOperationHelpers<EffectiveNetworkSecurityGroupListResult> _operation;
internal NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<EffectiveNetworkSecurityGroupListResult>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "NetworkInterfacesListEffectiveNetworkSecurityGroupsOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override EffectiveNetworkSecurityGroupListResult Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<EffectiveNetworkSecurityGroupListResult>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<EffectiveNetworkSecurityGroupListResult>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
EffectiveNetworkSecurityGroupListResult IOperationSource<EffectiveNetworkSecurityGroupListResult>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveNetworkSecurityGroupListResult.DeserializeEffectiveNetworkSecurityGroupListResult(document.RootElement);
}
}
async ValueTask<EffectiveNetworkSecurityGroupListResult> IOperationSource<EffectiveNetworkSecurityGroupListResult>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return EffectiveNetworkSecurityGroupListResult.DeserializeEffectiveNetworkSecurityGroupListResult(document.RootElement);
}
}
}
}

Просмотреть файл

@ -61,15 +61,14 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
restClientWriter.WriteClient(restCodeWriter, client);
project.AddGeneratedFile($"{client.Type.Name}.cs", restCodeWriter.ToString());
}
var headerModels = client.Methods.Select(m => m.HeaderModel).OfType<ResponseHeaderGroupType>().Distinct();
foreach (ResponseHeaderGroupType responseHeaderModel in headerModels)
{
var headerModelCodeWriter = new CodeWriter();
headerModelModelWriter.WriteHeaderModel(headerModelCodeWriter, responseHeaderModel);
foreach (ResponseHeaderGroupType responseHeaderModel in context.Library.HeaderModels)
{
var headerModelCodeWriter = new CodeWriter();
headerModelModelWriter.WriteHeaderModel(headerModelCodeWriter, responseHeaderModel);
project.AddGeneratedFile($"{responseHeaderModel.Type.Name}.cs", headerModelCodeWriter.ToString());
}
project.AddGeneratedFile($"{responseHeaderModel.Type.Name}.cs", headerModelCodeWriter.ToString());
}
foreach (var client in context.Library.Clients)
@ -80,6 +79,14 @@ namespace AutoRest.CSharp.V3.AutoRest.Plugins
project.AddGeneratedFile($"{client.Type.Name}.cs", codeWriter.ToString());
}
foreach (var operation in context.Library.LongRunningOperations)
{
var codeWriter = new CodeWriter();
LongRunningOperationWriter.Write(codeWriter, operation);
project.AddGeneratedFile($"{operation.Type.Name}.cs", codeWriter.ToString());
}
if (context.Configuration.AzureArm)
{
var codeWriter = new CodeWriter();

Просмотреть файл

@ -3,24 +3,16 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using AutoRest.CSharp.V3.AutoRest.Plugins;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Output.Models;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Serialization;
using AutoRest.CSharp.V3.Output.Models.Serialization.Json;
using AutoRest.CSharp.V3.Output.Models.Serialization.Xml;
using AutoRest.CSharp.V3.Output.Models.Shared;
using AutoRest.CSharp.V3.Utilities;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Microsoft.CodeAnalysis.Operations;
using Response = Azure.Response;
namespace AutoRest.CSharp.V3.Generation.Writers
@ -34,7 +26,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
using (writer.Namespace(@namespace))
{
writer.WriteXmlDocumentationSummary(client.Description);
using (writer.Scope($"{client.DeclaredType.Accessibility} partial class {cs.Name}"))
using (writer.Scope($"{client.Declaration.Accessibility} partial class {cs.Name}"))
{
WriteClientFields(writer, client);
@ -59,15 +51,8 @@ namespace AutoRest.CSharp.V3.Generation.Writers
WritePagingOperation(writer, pagingMethod, false);
}
// We only need one CreateOperation method per overload group
HashSet<string> createOperations = new HashSet<string>();
foreach (var longRunningOperation in client.LongRunningOperationMethods)
{
if (createOperations.Add(longRunningOperation.Name))
{
WriteCreateOperationOperation(writer, longRunningOperation);
}
WriteStartOperationOperation(writer, longRunningOperation, true);
WriteStartOperationOperation(writer, longRunningOperation, false);
}
@ -194,8 +179,6 @@ namespace AutoRest.CSharp.V3.Generation.Writers
private string CreateRequestMethodName(string name) => $"Create{name}Request";
private string CreateCreateOperationName(string name) => $"Create{name}";
private string CreateStartOperationName(string name, bool async) => $"Start{name}{(async ? "Async" : string.Empty)}";
private string CreateMethodName(string name, bool async) => $"{name}{(async ? "Async" : string.Empty)}";
@ -313,71 +296,6 @@ namespace AutoRest.CSharp.V3.Generation.Writers
writer.Line();
}
private void WriteCreateOperationOperation(CodeWriter writer, LongRunningOperation lroMethod)
{
RestClientMethod originalMethod = lroMethod.OriginalMethod;
CSharpType? responseBodyType = lroMethod.OriginalResponse.ResponseBody?.Type;
CSharpType responseType = new CSharpType(typeof(Operation<>), responseBodyType ?? new CSharpType(typeof(Response)));
Parameter[] parameters = lroMethod.CreateParameters;
writer.WriteXmlDocumentationSummary(originalMethod.Description);
foreach (Parameter parameter in parameters)
{
writer.WriteXmlDocumentationParameter(parameter.Name, parameter.Description);
}
writer.Append($"internal {responseType} {CreateCreateOperationName(lroMethod.Name)}(");
foreach (Parameter parameter in parameters)
{
writer.WriteParameter(parameter);
}
writer.RemoveTrailingComma();
writer.Line($")");
using (writer.Scope())
{
writer.WriteParameterNullChecks(parameters);
writer.Append($"return {typeof(ArmOperationHelpers)}.Create(");
writer.Append($"_pipeline, _clientDiagnostics, originalResponse, {typeof(RequestMethod)}.{originalMethod.Request.HttpMethod.ToRequestMethodName()}, {lroMethod.Diagnostics.ScopeName:L}, {typeof(OperationFinalStateVia)}.{lroMethod.FinalStateVia}, createOriginalHttpMessage");
if (responseBodyType != null)
{
writer.Line($", ");
string responseVariable = "response";
if (lroMethod.OriginalResponse.ResponseBody is ObjectResponseBody objectResponseBody)
{
using (writer.Scope($"({responseVariable:D}, cancellationToken) =>", "{", "},"))
{
writer.WriteDeserializationForMethods(
objectResponseBody.Serialization,
async: false,
(w, v) => w.Line($"return {v};")
, responseVariable);
}
using (writer.Scope($"async ({responseVariable:D}, cancellationToken) =>", newLine: false))
{
writer.WriteDeserializationForMethods(
objectResponseBody.Serialization,
async: true,
(w, v) => w.Line($"return {v};")
, responseVariable);
}
}
else if (lroMethod.OriginalResponse.ResponseBody is StreamResponseBody)
{
//TODO: https://github.com/Azure/autorest.csharp/issues/523
throw new NotSupportedException("Binary is not supported as message (not response) is required for ExtractResponseContent() call.");
}
}
writer.Line($");");
}
writer.Line();
}
private void WriteDiagnosticScope(CodeWriter writer, Diagnostic diagnostic, CodeWriterDelegate inner)
{
var scopeVariable = new CodeWriterDeclaration("scope");
@ -404,11 +322,10 @@ namespace AutoRest.CSharp.V3.Generation.Writers
}
}
private void WriteStartOperationOperation(CodeWriter writer, LongRunningOperation lroMethod, bool async)
private void WriteStartOperationOperation(CodeWriter writer, LongRunningOperationMethod lroMethod, bool async)
{
RestClientMethod originalMethod = lroMethod.OriginalMethod;
CSharpType responseType = new CSharpType(typeof(Operation<>), lroMethod.OriginalResponse.ResponseBody?.Type ?? typeof(Response));
responseType = async ? new CSharpType(typeof(ValueTask<>), responseType) : responseType;
RestClientMethod originalMethod = lroMethod.StartMethod;
CSharpType returnType = async ? new CSharpType(typeof(ValueTask<>), lroMethod.Operation.Type) : lroMethod.Operation.Type;
Parameter[] parameters = originalMethod.Parameters;
writer.WriteXmlDocumentationSummary(originalMethod.Description);
@ -420,7 +337,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
writer.WriteXmlDocumentationParameter("cancellationToken", "The cancellation token to use.");
string asyncText = async ? "async " : string.Empty;
writer.Append($"public virtual {asyncText}{responseType} {CreateStartOperationName(lroMethod.Name, async)}(");
writer.Append($"public virtual {asyncText}{returnType} {CreateStartOperationName(lroMethod.Name, async)}(");
foreach (Parameter parameter in parameters)
{
writer.WriteParameter(parameter);
@ -443,13 +360,13 @@ namespace AutoRest.CSharp.V3.Generation.Writers
writer.Line($"cancellationToken){configureText};");
writer.Append($"return {CreateCreateOperationName(lroMethod.Name)}(originalResponse, () => RestClient.{CreateRequestMethodName(originalMethod.Name)}(");
writer.Append($"return new {lroMethod.Operation.Type}(_clientDiagnostics, _pipeline, RestClient.{CreateRequestMethodName(originalMethod.Name)}(");
foreach (Parameter parameter in parameters)
{
writer.Append($"{parameter.Name}, ");
}
writer.RemoveTrailingComma();
writer.Line($"));");
writer.Line($").Request, originalResponse);");
});
}

Просмотреть файл

@ -100,7 +100,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
Append(d);
break;
case Type t:
AppendType(new CSharpType(t, false));
AppendType(new CSharpType(t));
break;
case CSharpType t:
AppendType(t);

Просмотреть файл

@ -0,0 +1,115 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Threading;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Serialization;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Request = Azure.Core.Request;
namespace AutoRest.CSharp.V3.Generation.Writers
{
internal class LongRunningOperationWriter
{
public static void Write(CodeWriter writer, LongRunningOperation operation)
{
var responseVariable = "response";
void WriteResultFunction(bool async)
{
if (operation.ResultSerialization != null)
{
writer.WriteDeserializationForMethods(
operation.ResultSerialization,
async: async,
(w, v) => w.Line($"return {v};"),
responseVariable);
}
else
{
if (async)
{
writer.Line($"return await new {typeof(ValueTask<Response>)}({responseVariable});");
}
else
{
writer.Line($"return {responseVariable};");
}
}
}
var cs = operation.Type;
var @namespace = cs.Namespace;
using (writer.Namespace(@namespace))
{
writer.WriteXmlDocumentationSummary(operation.Description);
var interfaceType = new CSharpType(typeof(IOperationSource<>), operation.ResultType);
var baseType = new CSharpType(typeof(Operation<>), operation.ResultType);
var waitForCompletionType = new CSharpType(typeof(ValueTask<>), new CSharpType(typeof(Response<>), operation.ResultType));
var helperType = new CSharpType(typeof(ArmOperationHelpers<>), operation.ResultType);
using (writer.Scope($"{operation.DeclaredType.Accessibility} partial class {cs.Name}: {baseType}, {interfaceType}"))
{
writer.Line($"private readonly {helperType} _operation;");
using (writer.Scope($"internal {cs.Name}({typeof(ClientDiagnostics)} clientDiagnostics, {typeof(HttpPipeline)} pipeline, {typeof(Request)} request, {typeof(Response)} response)"))
{
writer.Line($"_operation = new {helperType}(this, clientDiagnostics, pipeline, request, response, {typeof(OperationFinalStateVia)}.{operation.FinalStateVia}, {operation.Diagnostics.ScopeName:L});");
}
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override string Id => _operation.Id;");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {operation.ResultType} Value => _operation.Value;");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override bool HasCompleted => _operation.HasCompleted;");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override bool HasValue => _operation.HasValue;");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {typeof(Response)} GetRawResponse() => _operation.GetRawResponse();");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {typeof(Response)} UpdateStatus({typeof(CancellationToken)} cancellationToken = default) => _operation.UpdateStatus(cancellationToken);");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {typeof(ValueTask<Response>)} UpdateStatusAsync({typeof(CancellationToken)} cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {waitForCompletionType} WaitForCompletionAsync({typeof(CancellationToken)} cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);");
writer.Line();
writer.WriteXmlDocumentationInheritDoc();
writer.Line($"public override {waitForCompletionType} WaitForCompletionAsync({typeof(TimeSpan)} pollingInterval, {typeof(CancellationToken)} cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);");
writer.Line();
using (writer.Scope($"{operation.ResultType} {interfaceType}.CreateResult({typeof(Response)} {responseVariable:D}, {typeof(CancellationToken)} cancellationToken)"))
{
WriteResultFunction(false);
}
writer.Line();
using (writer.Scope($"async {new CSharpType(typeof(ValueTask<>), operation.ResultType)} {interfaceType}.CreateResultAsync({typeof(Response)} {responseVariable:D}, {typeof(CancellationToken)} cancellationToken)"))
{
WriteResultFunction(true);
}
}
}
}
}
}

Просмотреть файл

@ -34,7 +34,7 @@ namespace AutoRest.CSharp.V3.Generation.Writers
using (writer.Namespace(@namespace))
{
writer.WriteXmlDocumentationSummary(restClient.Description);
using (writer.Scope($"{restClient.DeclaredType.Accessibility} partial class {cs.Name}"))
using (writer.Scope($"{restClient.Declaration.Accessibility} partial class {cs.Name}"))
{
WriteClientFields(writer, restClient);

Просмотреть файл

@ -66,6 +66,7 @@ namespace AutoRest.CSharp.V3.Input
internal partial class ServiceResponse
{
public HttpResponse HttpResponse => Protocol.Http as HttpResponse ?? throw new InvalidOperationException($"Expected an HTTP response");
public Schema? ResponseSchema => (this as SchemaResponse)?.Schema;
}
internal partial class HttpResponse

Просмотреть файл

@ -1,646 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Models;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Serialization;
using AutoRest.CSharp.V3.Output.Models.Shared;
using AutoRest.CSharp.V3.Output.Models.Types;
using AutoRest.CSharp.V3.Utilities;
using Azure.Core;
using AzureResponse = Azure.Response;
using Diagnostic = AutoRest.CSharp.V3.Output.Models.Requests.Diagnostic;
using Request = AutoRest.CSharp.V3.Output.Models.Requests.Request;
namespace AutoRest.CSharp.V3.Output.Builders
{
internal class ClientBuilder
{
private const string _clientSuffix = "Client";
private static string[] _knownResponseHeaders = new[]
{
"Date",
"ETag",
"x-ms-client-request-id",
"x-ms-request-id"
};
private readonly BuildContext _context;
private readonly SerializationBuilder _serializationBuilder;
private readonly TypeFactory _typeFactory;
public ClientBuilder(BuildContext context)
{
_context = context;
_serializationBuilder = new SerializationBuilder();
_typeFactory = _context.TypeFactory;
}
public (Client Client, RestClient RestClient) BuildClient(OperationGroup operationGroup)
{
var clientPrefix = GetClientPrefix(operationGroup.Language.Default.Name);
var clientName = clientPrefix + _clientSuffix;
var existingClient = _context.SourceInputModel.FindForClient(_context.DefaultNamespace, clientName);
// Update the client name and prefix based on the existing type is available
clientName = existingClient?.ExistingType.Name ?? clientName;
clientPrefix = GetClientPrefix(clientName);
var clientParameters = operationGroup.Operations
.SelectMany(op => op.Parameters.Concat(op.Requests.SelectMany(r => r.Parameters)))
.Where(p => p.Implementation == ImplementationLocation.Client)
.Distinct()
.ToDictionary(p => p.Language.Default.Name, BuildParameter);
List<OperationMethod> operationMethods = new List<OperationMethod>();
foreach (Operation operation in operationGroup.Operations)
{
var responseHeaderModel = BuildResponseHeaderModel(clientPrefix, operation);
foreach (ServiceRequest serviceRequest in operation.Requests)
{
HttpRequest? httpRequest = serviceRequest.Protocol.Http as HttpRequest;
if (httpRequest == null)
{
// Only handles HTTP requests
continue;
}
RestClientMethod method = BuildMethod(operation, clientName, clientParameters, httpRequest, serviceRequest.Parameters.ToArray(), responseHeaderModel);
operationMethods.Add(new OperationMethod(operation, method));
}
}
List<RestClientMethod> nextPageMethods = new List<RestClientMethod>();
List<PagingMethod> pagingMethods = new List<PagingMethod>();
List<LongRunningOperation> longRunningOperationMethods = new List<LongRunningOperation>();
List<ClientMethod> clientMethods = new List<ClientMethod>();
foreach ((Operation operation, RestClientMethod method) in operationMethods)
{
if (operation.IsLongRunning)
{
longRunningOperationMethods.Add(BuildLongRunningOperation(clientName, operation, method));
continue;
}
Paging? paging = operation.Language.Default.Paging;
if (paging != null)
{
RestClientMethod? next = null;
if (paging.NextLinkOperation != null)
{
OperationMethod? nextOperationMethod = operationMethods.SingleOrDefault(m => m.Operation == paging.NextLinkOperation);
if (nextOperationMethod == null)
{
throw new Exception($"The x-ms-pageable operationName \"{paging.Group}_{paging.Member}\" for operation {operationGroup.Key}_{operation.Language.Default.Name} was not found.");
}
next = nextOperationMethod.Method;
}
// If there is no operationName or we didn't find an existing operation, we use the original method to construct the nextPageMethod.
RestClientMethod? nextPageMethod = next;
// Only create and add a method if it didn't previously exist and we have a NextLinkName
if (next == null && paging.NextLinkName != null)
{
nextPageMethod = BuildNextPageMethod(method);
nextPageMethods.Add(nextPageMethod);
}
if (!(method.Responses.Single(r => r.ResponseBody != null).ResponseBody is ObjectResponseBody objectResponseBody))
{
throw new InvalidOperationException($"Method {method.Name} has to have a return value");
}
ITypeProvider implementation = objectResponseBody.Type.Implementation;
if (!(implementation is ObjectType objectType))
{
throw new InvalidOperationException($"The return type of {method.Name} has to be an object schema to be used in paging");
}
PagingMethod pagingMethod = GetPagingMethod(clientName, method, nextPageMethod, paging, objectType);
pagingMethods.Add(pagingMethod);
continue;
}
var operationName = operation.CSharpName();
clientMethods.Add(new ClientMethod(
operationName,
method,
BuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description),
new Diagnostic($"{clientName}.{operationName}", Array.Empty<DiagnosticAttribute>())));
}
RestClientMethod[] methods = operationMethods.Select(om => om.Method).Concat(nextPageMethods).ToArray();
var restClient = new RestClient(
BuilderHelpers.CreateTypeAttributes(clientPrefix + "RestClient", _context.DefaultNamespace, "internal"),
operationGroup.Language.Default.Description,
OrderParameters(clientParameters.Values),
methods);
var client = new Client(
BuilderHelpers.CreateTypeAttributes(clientName, _context.DefaultNamespace, "public", existingClient?.ExistingType),
BuilderHelpers.EscapeXmlDescription(CreateDescription(operationGroup, clientPrefix)),
restClient,
clientMethods.ToArray(),
pagingMethods.ToArray(),
longRunningOperationMethods.ToArray());
return (client, restClient);
}
private string GetClientPrefix(string name)
{
name = string.IsNullOrEmpty(name) ? "Service" : name.ToCleanName();
var operationsSuffix = "Operations";
if (name.EndsWith(operationsSuffix) && name.Length > operationsSuffix.Length)
{
name = name.Substring(0, name.Length - operationsSuffix.Length);
}
var clientSuffix = _clientSuffix;
if (name.EndsWith(clientSuffix) && name.Length > clientSuffix.Length)
{
name = name.Substring(0, name.Length - clientSuffix.Length);
}
return name;
}
private class OperationMethod
{
public OperationMethod(Operation operation, RestClientMethod method)
{
Operation = operation;
Method = method;
}
public void Deconstruct(out Operation operation, out RestClientMethod method)
{
operation = Operation;
method = Method;
}
public Operation Operation { get; }
public RestClientMethod Method { get; }
}
private static Parameter[] OrderParameters(IEnumerable<Parameter> parameters) => parameters.OrderBy(p => p.DefaultValue != null).ToArray();
private RestClientMethod BuildMethod(Operation operation, string clientName, IReadOnlyDictionary<string, Parameter> clientParameters, HttpRequest httpRequest, RequestParameter[] requestParameters, ResponseHeaderGroupType? responseHeaderModel)
{
HttpWithBodyRequest? httpRequestWithBody = httpRequest as HttpWithBodyRequest;
Dictionary<string, PathSegment> uriParameters = new Dictionary<string, PathSegment>();
Dictionary<string, PathSegment> pathParameters = new Dictionary<string, PathSegment>();
List<QueryParameter> query = new List<QueryParameter>();
List<RequestHeader> headers = new List<RequestHeader>();
Dictionary<RequestParameter, ReferenceOrConstant> allParameters = new Dictionary<RequestParameter, ReferenceOrConstant>();
Dictionary<RequestParameter, Parameter> methodParameters = new Dictionary<RequestParameter, Parameter>();
RequestBody? body = null;
(RequestParameter, ReferenceOrConstant)? bodyParameter = null;
RequestParameter[] parameters = operation.Parameters.Concat(requestParameters).ToArray();
foreach (RequestParameter requestParameter in parameters)
{
string defaultName = requestParameter.Language.Default.Name;
string serializedName = requestParameter.Language.Default.SerializedName ?? defaultName;
ReferenceOrConstant constantOrReference;
Schema valueSchema = requestParameter.Schema;
if (requestParameter.Implementation == ImplementationLocation.Method)
{
Parameter? parameter = null;
// TODO: always generate virtual parameters
if (!(requestParameter is VirtualParameter) &&
requestParameter.Schema is ConstantSchema constant)
{
constantOrReference = ParseConstant(constant);
valueSchema = constant.ValueType;
}
else
{
parameter = BuildParameter(requestParameter);
if (requestParameter.GroupedBy is RequestParameter groupedByParameter)
{
var groupModel = (ObjectType)_typeFactory.CreateType(groupedByParameter.Schema, false).Implementation;
var property = groupModel.GetPropertyForGroupedParameter(requestParameter);
constantOrReference = new Reference($"{groupedByParameter.CSharpName()}.{property.Declaration.Name}", property.Declaration.Type);
}
else
{
constantOrReference = parameter;
}
}
allParameters.Add(requestParameter, constantOrReference);
if (parameter != null &&
requestParameter.Flattened != true &&
requestParameter.GroupedBy == null)
{
methodParameters.Add(requestParameter, parameter);
}
}
else
{
constantOrReference = clientParameters[requestParameter.Language.Default.Name];
}
if (requestParameter.Protocol.Http is HttpParameter httpParameter)
{
SerializationFormat serializationFormat = BuilderHelpers.GetSerializationFormat(valueSchema);
bool skipEncoding = requestParameter.Extensions!.TryGetValue("x-ms-skip-url-encoding", out var value) && Convert.ToBoolean(value);
switch (httpParameter.In)
{
case ParameterLocation.Header:
headers.Add(new RequestHeader(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), serializationFormat));
break;
case ParameterLocation.Query:
query.Add(new QueryParameter(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), !skipEncoding, serializationFormat));
break;
case ParameterLocation.Path:
pathParameters.Add(serializedName, new PathSegment(constantOrReference, !skipEncoding, serializationFormat));
break;
case ParameterLocation.Body:
bodyParameter = (requestParameter, constantOrReference);
break;
case ParameterLocation.Uri:
uriParameters.Add(serializedName, new PathSegment(constantOrReference, !skipEncoding, serializationFormat, isRaw: true));
break;
}
}
}
if (bodyParameter is var (bodyRequestParameter, bodyParameterValue))
{
Debug.Assert(httpRequestWithBody != null);
if (httpRequestWithBody.KnownMediaType == KnownMediaType.Binary)
{
body = new BinaryRequestBody(bodyParameterValue);
}
else if (httpRequestWithBody.KnownMediaType == KnownMediaType.Text)
{
body = new TextRequestBody(bodyParameterValue);
}
else
{
var serialization = _serializationBuilder.Build(
httpRequestWithBody.KnownMediaType,
bodyRequestParameter.Schema,
bodyParameterValue.Type);
// This method has a flattened body
if (bodyRequestParameter.Flattened == true)
{
var objectType = (ObjectType)_context.Library.FindTypeForSchema(bodyRequestParameter.Schema);
var virtualParameters = requestParameters.OfType<VirtualParameter>().ToArray();
List<ObjectPropertyInitializer> initializationMap = new List<ObjectPropertyInitializer>();
foreach (var virtualParameter in virtualParameters)
{
var actualParameter = allParameters[virtualParameter];
initializationMap.Add(new ObjectPropertyInitializer(
objectType.GetPropertyForSchemaProperty(virtualParameter.TargetProperty, true),
actualParameter));
}
body = new FlattenedSchemaRequestBody(objectType, initializationMap.ToArray(), serialization);
}
else
{
body = new SchemaRequestBody(bodyParameterValue, serialization);
}
}
}
PathSegment[] pathSegments = GetPathSegments(httpRequest.Uri, uriParameters, isRaw: true)
.Concat(GetPathSegments(httpRequest.Path, pathParameters))
.ToArray();
Request request = new Request(
httpRequest.Method.ToCoreRequestMethod() ?? RequestMethod.Get,
pathSegments,
query.ToArray(),
headers.ToArray(),
body
);
string operationName = operation.CSharpName();
List<Response> clientResponse = new List<Response>();
if (operation.IsLongRunning)
{
// If operation is a long-running operation than we're generating an initial call here so find a response with non 200/204 code
// Ignore response body and headers for LROs as the ArmOperationHelpers figures out them dynamically
// Long running operations can respond with both initial or final status code
clientResponse.Add(new Response(
null,
operation.LongRunningInitialResponse.HttpResponse.IntStatusCodes.ToArray()
));
clientResponse.Add(new Response(
null,
operation.LongRunningFinalResponse.HttpResponse.IntStatusCodes.ToArray()
));
responseHeaderModel = null;
}
else
{
foreach (var response in operation.Responses)
{
clientResponse.Add(new Response(
BuildResponseBody(response),
response.HttpResponse.IntStatusCodes.ToArray()
));
}
}
var responseType = ReduceResponses(clientResponse);
return new RestClientMethod(
operationName,
BuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description),
responseType,
request,
OrderParameters(methodParameters.Values),
clientResponse.ToArray(),
responseHeaderModel
);
}
// Merges operations without response types types together
private CSharpType? ReduceResponses(List<Response> responses)
{
foreach (var typeGroup in responses.GroupBy(r=> r.ResponseBody))
{
foreach (var individualResponse in typeGroup)
{
responses.Remove(individualResponse);
}
responses.Add(new Response(
typeGroup.Key,
typeGroup.SelectMany(r=>r.StatusCodes).Distinct().ToArray()));
}
var bodyTypes = responses.Select(r => r.ResponseBody?.Type)
.OfType<CSharpType>()
.Distinct()
.ToArray();
return bodyTypes.Length switch
{
0 => null,
1 => bodyTypes[0],
_ => typeof(object)
};
}
private ResponseBody? BuildResponseBody(ServiceResponse response)
{
ResponseBody? responseBody = null;
if (response is SchemaResponse schemaResponse)
{
Schema schema = schemaResponse.Schema is ConstantSchema constantSchema ? constantSchema.ValueType : schemaResponse.Schema;
CSharpType responseType = TypeFactory.GetOutputType(_typeFactory.CreateType(schema, isNullable: false));
ObjectSerialization serialization = _serializationBuilder.Build(response.HttpResponse.KnownMediaType, schema, responseType);
responseBody = new ObjectResponseBody(responseType, serialization);
}
else if (response is BinaryResponse)
{
responseBody = new StreamResponseBody();
}
return responseBody;
}
private static RestClientMethod BuildNextPageMethod(RestClientMethod method)
{
var nextPageUrlParameter = new Parameter(
"nextLink",
"The URL to the next page of results.",
typeof(string),
defaultValue: null,
isRequired: true);
PathSegment[] pathSegments = method.Request.PathSegments
.Where(ps => ps.IsRaw)
.Append(new PathSegment(nextPageUrlParameter, false, SerializationFormat.Default, isRaw: true))
.ToArray();
var request = new Request(
method.Request.HttpMethod,
pathSegments,
Array.Empty<QueryParameter>(),
method.Request.Headers,
null
);
Parameter[] parameters = method.Parameters.Where(p => p.Name != nextPageUrlParameter.Name)
.Prepend(nextPageUrlParameter)
.ToArray();
return new RestClientMethod(
$"{method.Name}NextPage",
method.Description,
method.ReturnType,
request,
parameters,
method.Responses,
method.HeaderModel);
}
private PagingMethod GetPagingMethod(string clientName, RestClientMethod method, RestClientMethod? nextPageMethod, Paging paging, ObjectType type)
{
string? nextLinkName = paging.NextLinkName;
string itemName = paging.ItemName ?? "value";
ObjectTypeProperty itemProperty = type.GetPropertyBySerializedName(itemName);
ObjectTypeProperty? nextLinkProperty = null;
if (!string.IsNullOrWhiteSpace(nextLinkName))
{
nextLinkProperty = type.GetPropertyBySerializedName(nextLinkName);
}
if (itemProperty.SchemaProperty?.Schema is ArraySchema arraySchema)
{
CSharpType itemType = _typeFactory.CreateType(arraySchema.ElementType, false);
return new PagingMethod(
method,
nextPageMethod,
method.Name,
nextLinkProperty?.Declaration.Name,
itemProperty.Declaration.Name,
itemType,
new Diagnostic($"{clientName}.{method.Name}"));
}
throw new InvalidOperationException($"{itemName} property has to be an array schema, actual {itemProperty.SchemaProperty}");
}
private LongRunningOperation BuildLongRunningOperation(string clientName, Operation operation, RestClientMethod startMethod)
{
var originalResponseParameter = new Parameter(
"originalResponse",
"The original response from starting the operation.",
typeof(AzureResponse),
null,
true);
var httpMessageParameter = new Parameter(
"createOriginalHttpMessage",
"Creates the HTTP message used for the original request.",
typeof(Func<HttpMessage>),
null,
true);
string name = operation.CSharpName();
var finalStateVia = operation.LongRunningFinalStateVia switch
{
"azure-async-operation" => OperationFinalStateVia.AzureAsyncOperation,
"location" => OperationFinalStateVia.Location,
"original-uri" => OperationFinalStateVia.OriginalUri,
null => OperationFinalStateVia.Location,
_ => throw new ArgumentException($"Unknown final-state-via value: {operation.LongRunningFinalStateVia}")
};
ServiceResponse finalResponse = operation.LongRunningFinalResponse;
return new LongRunningOperation(
startMethod,
new Response(BuildResponseBody(finalResponse),
finalResponse.HttpResponse.IntStatusCodes),
name,
new[] { originalResponseParameter, httpMessageParameter },
finalStateVia,
new Diagnostic($"{clientName}.Start{name}"));
}
private Parameter BuildParameter(RequestParameter requestParameter)
{
var type = _typeFactory.CreateType(requestParameter.Schema, requestParameter.IsNullable());
var isRequired = requestParameter.Required == true;
var defaultValue = ParseConstant(requestParameter);
if (!isRequired && defaultValue == null)
{
defaultValue = Constant.Default(type);
}
return new Parameter(
requestParameter.CSharpName(),
CreateDescription(requestParameter),
TypeFactory.GetInputType(type),
defaultValue,
isRequired);
}
private ResponseHeaderGroupType? BuildResponseHeaderModel(string clientName, Operation operation)
{
var httpResponseHeaders = operation.Responses.SelectMany(r => r.HttpResponse.Headers)
.Where(h => !_knownResponseHeaders.Contains(h.Header, StringComparer.InvariantCultureIgnoreCase))
.GroupBy(h => h.Header)
// Take first header definition with any particular name
.Select(h => h.First())
.ToArray();
if (!httpResponseHeaders.Any())
{
return null;
}
ResponseHeader CreateResponseHeader(HttpResponseHeader header) =>
new ResponseHeader(header.Header.ToCleanName(), header.Header, _typeFactory.CreateType(header.Schema, true));
string operationName = operation.CSharpName();
return new ResponseHeaderGroupType(
BuilderHelpers.CreateTypeAttributes(clientName + operationName + "Headers", _context.DefaultNamespace, "internal"),
$"Header model for {operationName}",
httpResponseHeaders.Select(CreateResponseHeader).ToArray()
);
}
private static RequestParameterSerializationStyle GetSerializationStyle(HttpParameter httpParameter, Schema valueSchema)
{
Debug.Assert(httpParameter.In == ParameterLocation.Query || httpParameter.In == ParameterLocation.Header);
switch (httpParameter.Style)
{
case null:
case SerializationStyle.Form:
case SerializationStyle.Simple:
return valueSchema is ArraySchema ? RequestParameterSerializationStyle.CommaDelimited : RequestParameterSerializationStyle.Simple;
case SerializationStyle.PipeDelimited:
return RequestParameterSerializationStyle.PipeDelimited;
case SerializationStyle.SpaceDelimited:
return RequestParameterSerializationStyle.SpaceDelimited;
case SerializationStyle.TabDelimited:
return RequestParameterSerializationStyle.TabDelimited;
default:
throw new ArgumentOutOfRangeException();
}
}
private static IEnumerable<PathSegment> GetPathSegments(string httpRequestUri, Dictionary<string, PathSegment> parameters, bool isRaw = false)
{
PathSegment TextSegment(string text)
{
return new PathSegment(BuilderHelpers.StringConstant(text), false, SerializationFormat.Default, isRaw);
}
foreach ((string text, bool isLiteral) in StringExtensions.GetPathParts(httpRequestUri))
{
yield return isLiteral ? TextSegment(text) : parameters[text];
}
}
private Constant ParseConstant(ConstantSchema constant) =>
BuilderHelpers.ParseConstant(constant.Value.Value, _typeFactory.CreateType(constant.ValueType, constant.Value.Value == null));
private Constant? ParseConstant(RequestParameter parameter)
{
if (parameter.ClientDefaultValue != null)
{
CSharpType constantTypeReference = _typeFactory.CreateType(parameter.Schema, parameter.IsNullable());
return BuilderHelpers.ParseConstant(parameter.ClientDefaultValue, constantTypeReference);
}
if (parameter.Schema is ConstantSchema constantSchema)
{
return ParseConstant(constantSchema);
}
return null;
}
private static string CreateDescription(OperationGroup operationGroup, string clientPrefix)
{
return string.IsNullOrWhiteSpace(operationGroup.Language.Default.Description) ?
$"The {clientPrefix} service client." :
BuilderHelpers.EscapeXmlDescription(operationGroup.Language.Default.Description);
}
private static string CreateDescription(RequestParameter requestParameter)
{
return string.IsNullOrWhiteSpace(requestParameter.Language.Default.Description) ?
$"The {requestParameter.Schema.Name} to use." :
BuilderHelpers.EscapeXmlDescription(requestParameter.Language.Default.Description);
}
}
}

Просмотреть файл

@ -1,30 +1,151 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Linq;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Types;
namespace AutoRest.CSharp.V3.Output.Models
{
internal class Client: ITypeProvider
internal class Client: ClientBase, ITypeProvider
{
public Client(TypeDeclarationOptions declaredType, string description, RestClient restClient, ClientMethod[] methods, PagingMethod[] pagingMethods, LongRunningOperation[] longRunningOperationMethods)
private readonly OperationGroup _operationGroup;
private readonly BuildContext _context;
private PagingMethod[]? _pagingMethods;
private ClientMethod[]? _methods;
private LongRunningOperationMethod[]? _longRunningOperationMethods;
private RestClient? _restClient;
public Client(OperationGroup operationGroup, BuildContext context): base(context)
{
DeclaredType = declaredType;
Description = description;
RestClient = restClient;
Methods = methods;
PagingMethods = pagingMethods;
LongRunningOperationMethods = longRunningOperationMethods;
_operationGroup = operationGroup;
_context = context;
var clientPrefix = GetClientPrefix(operationGroup.Language.Default.Name);
var clientName = clientPrefix + ClientSuffix;
var existingClient = _context.SourceInputModel.FindForClient(_context.DefaultNamespace, clientName);
// Update the client name and prefix based on the existing type is available
clientName = existingClient?.ExistingType.Name ?? clientName;
clientPrefix = GetClientPrefix(clientName);
Declaration = BuilderHelpers.CreateTypeAttributes(clientName, _context.DefaultNamespace, "public", existingClient?.ExistingType);
Description = BuilderHelpers.EscapeXmlDescription(CreateDescription(operationGroup, clientPrefix));
}
public TypeDeclarationOptions DeclaredType { get; }
public TypeDeclarationOptions Declaration { get; }
public string Description { get; }
public RestClient RestClient { get; }
public ClientMethod[] Methods { get; }
public PagingMethod[] PagingMethods { get; }
public LongRunningOperation[] LongRunningOperationMethods { get; }
public CSharpType Type => new CSharpType(this, DeclaredType.Namespace, DeclaredType.Name);
public RestClient RestClient => _restClient ??= _context.Library.FindRestClient(_operationGroup);
public ClientMethod[] Methods => _methods ??= BuildMethods().ToArray();
public PagingMethod[] PagingMethods => _pagingMethods ??= BuildPagingMethods().ToArray();
public LongRunningOperationMethod[] LongRunningOperationMethods => _longRunningOperationMethods ??= BuildLongRunningOperationMethods().ToArray();
public CSharpType Type => new CSharpType(this, Declaration.Namespace, Declaration.Name);
private IEnumerable<PagingMethod> BuildPagingMethods()
{
foreach (var operation in _operationGroup.Operations)
{
Paging? paging = operation.Language.Default.Paging;
if (paging == null || operation.IsLongRunning)
{
continue;
}
foreach (var serviceRequest in operation.Requests)
{
RestClientMethod method = RestClient.GetOperationMethod(serviceRequest);
RestClientMethod? nextPageMethod = RestClient.GetNextOperationMethod(serviceRequest);
if (!(method.Responses.SingleOrDefault(r => r.ResponseBody != null)?.ResponseBody is ObjectResponseBody objectResponseBody))
{
throw new InvalidOperationException($"Method {method.Name} has to have a return value");
}
ITypeProvider implementation = objectResponseBody.Type.Implementation;
if (!(implementation is ObjectType type))
{
throw new InvalidOperationException($"The return type of {method.Name} has to be an object schema to be used in paging");
}
string? nextLinkName = paging.NextLinkName;
string itemName = paging.ItemName ?? "value";
ObjectTypeProperty itemProperty = type.GetPropertyBySerializedName(itemName);
ObjectTypeProperty? nextLinkProperty = null;
if (!string.IsNullOrWhiteSpace(nextLinkName))
{
nextLinkProperty = type.GetPropertyBySerializedName(nextLinkName);
}
if (!(itemProperty.SchemaProperty?.Schema is ArraySchema arraySchema))
{
throw new InvalidOperationException($"{itemName} property has to be an array schema, actual {itemProperty.SchemaProperty?.Schema}");
}
CSharpType itemType = _context.TypeFactory.CreateType(arraySchema.ElementType, false);
yield return new PagingMethod(
method,
nextPageMethod,
method.Name,
nextLinkProperty?.Declaration.Name,
itemProperty.Declaration.Name,
itemType,
new Diagnostic($"{Declaration.Name}.{method.Name}"));
}
}
}
private IEnumerable<LongRunningOperationMethod> BuildLongRunningOperationMethods()
{
foreach (var operation in _operationGroup.Operations)
{
if (operation.IsLongRunning)
{
foreach (var serviceRequest in operation.Requests)
{
var name = operation.CSharpName();
RestClientMethod startMethod = RestClient.GetOperationMethod(serviceRequest);
yield return new LongRunningOperationMethod(
name,
_context.Library.FindLongRunningOperation(operation),
startMethod,
new Diagnostic($"{Declaration.Name}.Start{name}")
);
}
}
}
}
private IEnumerable<ClientMethod> BuildMethods()
{
foreach (var operation in _operationGroup.Operations)
{
if (operation.IsLongRunning || operation.Language.Default.Paging != null)
{
continue;
}
foreach (var request in operation.Requests)
{
var name = operation.CSharpName();
RestClientMethod startMethod = RestClient.GetOperationMethod(request);
yield return new ClientMethod(
name,
startMethod,
BuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description),
new Diagnostic($"{Declaration.Name}.{name}", Array.Empty<DiagnosticAttribute>()));
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Shared;
using AutoRest.CSharp.V3.Output.Models.Types;
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.Output.Models
{
internal abstract class ClientBase
{
protected const string ClientSuffix = "Client";
private readonly BuildContext _context;
private readonly TypeFactory _typeFactory;
public ClientBase(BuildContext context)
{
_typeFactory = context.TypeFactory;
_context = context;
}
protected Parameter BuildParameter(RequestParameter requestParameter)
{
var type = _typeFactory.CreateType(requestParameter.Schema, requestParameter.IsNullable());
var isRequired = requestParameter.Required == true;
var defaultValue = ParseConstant(requestParameter);
if (!isRequired && defaultValue == null)
{
defaultValue = Constant.Default(type);
}
return new Parameter(
requestParameter.CSharpName(),
CreateDescription(requestParameter),
TypeFactory.GetInputType(type),
defaultValue,
isRequired);
}
protected Constant ParseConstant(ConstantSchema constant) =>
BuilderHelpers.ParseConstant(constant.Value.Value, _context.TypeFactory.CreateType(constant.ValueType, constant.Value.Value == null));
private Constant? ParseConstant(RequestParameter parameter)
{
if (parameter.ClientDefaultValue != null)
{
CSharpType constantTypeReference = _context.TypeFactory.CreateType(parameter.Schema, parameter.IsNullable());
return BuilderHelpers.ParseConstant(parameter.ClientDefaultValue, constantTypeReference);
}
if (parameter.Schema is ConstantSchema constantSchema)
{
return ParseConstant(constantSchema);
}
return null;
}
protected static string CreateDescription(OperationGroup operationGroup, string clientPrefix)
{
return string.IsNullOrWhiteSpace(operationGroup.Language.Default.Description) ?
$"The {clientPrefix} service client." :
BuilderHelpers.EscapeXmlDescription(operationGroup.Language.Default.Description);
}
private static string CreateDescription(RequestParameter requestParameter)
{
return string.IsNullOrWhiteSpace(requestParameter.Language.Default.Description) ?
$"The {requestParameter.Schema.Name} to use." :
BuilderHelpers.EscapeXmlDescription(requestParameter.Language.Default.Description);
}
protected string GetClientPrefix(string name)
{
name = string.IsNullOrEmpty(name) ? "Service" : name.ToCleanName();
var operationsSuffix = "Operations";
if (name.EndsWith(operationsSuffix) && name.Length > operationsSuffix.Length)
{
name = name.Substring(0, name.Length - operationsSuffix.Length);
}
var clientSuffix = ClientSuffix;
if (name.EndsWith(clientSuffix) && name.Length > clientSuffix.Length)
{
name = name.Substring(0, name.Length - clientSuffix.Length);
}
return name;
}
}
}

Просмотреть файл

@ -1,29 +1,66 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Shared;
using System;
using System.Diagnostics;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Serialization;
using AutoRest.CSharp.V3.Output.Models.Types;
using Azure;
using Azure.Core;
namespace AutoRest.CSharp.V3.Output.Models.Requests
{
internal class LongRunningOperation
internal class LongRunningOperation: ITypeProvider
{
public LongRunningOperation(RestClientMethod originalMethod, Response originalResponse, string name, Parameter[] createParameters, OperationFinalStateVia finalStateVia, Diagnostic diagnostics)
private readonly BuildContext _context;
public LongRunningOperation(OperationGroup operationGroup, Operation operation, BuildContext context)
{
OriginalMethod = originalMethod;
OriginalResponse = originalResponse;
Name = name;
CreateParameters = createParameters;
FinalStateVia = finalStateVia;
Diagnostics = diagnostics;
Debug.Assert(operation.IsLongRunning);
_context = context;
var clientClass = _context.Library.FindClient(operationGroup);
Name = clientClass.RestClient.ClientPrefix + operation.CSharpName() + "Operation";
Diagnostics = new Diagnostic(Name);
FinalStateVia = operation.LongRunningFinalStateVia switch
{
"azure-async-operation" => OperationFinalStateVia.AzureAsyncOperation,
"location" => OperationFinalStateVia.Location,
"original-uri" => OperationFinalStateVia.OriginalUri,
null => OperationFinalStateVia.Location,
_ => throw new ArgumentException($"Unknown final-state-via value: {operation.LongRunningFinalStateVia}")
};
var finalResponse = operation.LongRunningFinalResponse;
Schema? finalResponseSchema = finalResponse.ResponseSchema;
if (finalResponseSchema != null)
{
ResultType = context.TypeFactory.CreateType(finalResponseSchema, false);
ResultSerialization = new SerializationBuilder().Build(finalResponse.HttpResponse.KnownMediaType, finalResponseSchema, ResultType);
}
else
{
ResultType = typeof(Response);
}
Description = BuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description);
// Inherit accessibility from the client
DeclaredType = BuilderHelpers.CreateTypeAttributes(Name, _context.DefaultNamespace, clientClass.Declaration.Accessibility);
}
public string Name { get; }
public RestClientMethod OriginalMethod { get; }
public Response OriginalResponse { get; }
public Parameter[] CreateParameters { get; }
public CSharpType ResultType { get; }
public OperationFinalStateVia FinalStateVia { get; }
public Diagnostic Diagnostics { get; set; }
public Diagnostic Diagnostics { get; }
public CSharpType Type => new CSharpType(this,DeclaredType.Namespace, DeclaredType.Name);
public TypeDeclarationOptions DeclaredType { get; }
public ObjectSerialization? ResultSerialization { get; }
public string Description { get; }
}
}

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using AutoRest.CSharp.V3.Output.Models.Shared;
namespace AutoRest.CSharp.V3.Output.Models.Requests
{
internal class LongRunningOperationMethod
{
public LongRunningOperationMethod(string name, LongRunningOperation operation, RestClientMethod startMethod, Diagnostic diagnostics)
{
Operation = operation;
StartMethod = startMethod;
Diagnostics = diagnostics;
Name = name;
}
public string Name { get; }
public LongRunningOperation Operation { get; }
public RestClientMethod StartMethod { get; }
public Diagnostic Diagnostics { get; set; }
}
}

Просмотреть файл

@ -1,23 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Linq;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Types;
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.Output.Models.Responses
{
internal class ResponseHeaderGroupType: ITypeProvider
{
public ResponseHeaderGroupType(TypeDeclarationOptions declaration, string description, ResponseHeader[] headers)
private static string[] _knownResponseHeaders = new[]
{
Declaration = declaration;
Headers = headers;
Description = description;
"Date",
"ETag",
"x-ms-client-request-id",
"x-ms-request-id"
};
public ResponseHeaderGroupType(OperationGroup operationGroup, Operation operation, HttpResponseHeader[] httpResponseHeaders, BuildContext context)
{
ResponseHeader CreateResponseHeader(HttpResponseHeader header) =>
new ResponseHeader(header.Header.ToCleanName(), header.Header, context.TypeFactory.CreateType(header.Schema, true));
string operationName = operation.CSharpName();
var clientName = context.Library.FindRestClient(operationGroup).ClientPrefix;
Declaration = BuilderHelpers.CreateTypeAttributes(clientName + operationName + "Headers", context.DefaultNamespace, "internal");
Description = $"Header model for {operationName}";
Headers = httpResponseHeaders.Select(CreateResponseHeader).ToArray();
}
public string Description { get; }
public TypeDeclarationOptions Declaration { get; }
public ResponseHeader[] Headers { get; }
public CSharpType Type => new CSharpType(this, Declaration.Namespace, Declaration.Name);
public static ResponseHeaderGroupType? TryCreate(OperationGroup operationGroup, Operation operation, BuildContext context)
{
var httpResponseHeaders = operation.Responses.SelectMany(r => r.HttpResponse.Headers)
.Where(h => !_knownResponseHeaders.Contains(h.Header, StringComparer.InvariantCultureIgnoreCase))
.GroupBy(h => h.Header)
// Take first header definition with any particular name
.Select(h => h.First())
.ToArray();
if (!httpResponseHeaders.Any() || operation.IsLongRunning)
{
return null;
}
return new ResponseHeaderGroupType(operationGroup, operation, httpResponseHeaders, context);
}
}
}

Просмотреть файл

@ -1,27 +1,472 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using AutoRest.CSharp.V3.Generation.Types;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Responses;
using AutoRest.CSharp.V3.Output.Models.Serialization;
using AutoRest.CSharp.V3.Output.Models.Shared;
using AutoRest.CSharp.V3.Output.Models.Types;
using AutoRest.CSharp.V3.Utilities;
using Azure.Core;
using Request = AutoRest.CSharp.V3.Output.Models.Requests.Request;
namespace AutoRest.CSharp.V3.Output.Models
{
internal class RestClient: ITypeProvider
internal class RestClient: ClientBase, ITypeProvider
{
public RestClient(TypeDeclarationOptions declaredType, string description, Parameter[] parameters, RestClientMethod[] methods)
protected const string RestClientSuffix = "RestClient";
private readonly OperationGroup _operationGroup;
private readonly BuildContext _context;
private readonly Dictionary<string, Parameter> _parameters;
private readonly SerializationBuilder _serializationBuilder;
private Dictionary<ServiceRequest, RestClientMethod>? _requestMethods;
private Dictionary<ServiceRequest, RestClientMethod>? _nextPageMethods;
private RestClientMethod[]? _allMethods;
public RestClient(OperationGroup operationGroup, BuildContext context) : base(context)
{
DeclaredType = declaredType;
Parameters = parameters;
Methods = methods;
Description = description;
_operationGroup = operationGroup;
_context = context;
_parameters = operationGroup.Operations
.SelectMany(op => op.Parameters.Concat(op.Requests.SelectMany(r => r.Parameters)))
.Where(p => p.Implementation == ImplementationLocation.Client)
.Distinct()
.ToDictionary(p => p.Language.Default.Name, BuildParameter);
_serializationBuilder = new SerializationBuilder();
Parameters = OrderParameters(_parameters.Values);
var mainClient = context.Library.FindClient(operationGroup);
ClientPrefix = GetClientPrefix(mainClient.Declaration.Name);
var clientName = ClientPrefix + RestClientSuffix;
Declaration = BuilderHelpers.CreateTypeAttributes(clientName, _context.DefaultNamespace, "internal");
Description = "";
}
public string Description { get; }
public RestClientMethod[] Methods { get; }
public TypeDeclarationOptions DeclaredType { get; }
public Parameter[] Parameters { get; }
public CSharpType Type => new CSharpType(this, DeclaredType.Namespace, DeclaredType.Name);
public string Description { get; }
public TypeDeclarationOptions Declaration { get; }
public RestClientMethod[] Methods => _allMethods ??= BuildAllMethods().ToArray();
public string ClientPrefix { get; }
public CSharpType Type => new CSharpType(this, Declaration.Namespace, Declaration.Name);
private IEnumerable<RestClientMethod> BuildAllMethods()
{
foreach (var operation in _operationGroup.Operations)
{
foreach (var serviceRequest in operation.Requests)
{
RestClientMethod method = GetOperationMethod(serviceRequest);
yield return method;
}
}
foreach (var operation in _operationGroup.Operations)
{
foreach (var serviceRequest in operation.Requests)
{
// remove duplicates when GetNextPage method is not autogenerated
if (GetNextOperationMethod(serviceRequest) is {} nextOperationMethod &&
operation.Language.Default.Paging?.NextLinkOperation == null)
{
yield return nextOperationMethod;
}
}
}
}
private Dictionary<ServiceRequest, RestClientMethod> EnsureNormalMethods()
{
if (_requestMethods != null)
{
return _requestMethods;
}
_requestMethods = new Dictionary<ServiceRequest, RestClientMethod>();
foreach (var operation in _operationGroup.Operations)
{
foreach (var serviceRequest in operation.Requests)
{
if (!(serviceRequest.Protocol.Http is HttpRequest httpRequest))
{
continue;
}
var headerModel = _context.Library.FindHeaderModel(operation);
_requestMethods.Add(serviceRequest, BuildMethod(operation, httpRequest, serviceRequest.Parameters, headerModel));
}
}
return _requestMethods;
}
private Dictionary<ServiceRequest, RestClientMethod> EnsureGetNextPageMethods()
{
if (_nextPageMethods != null)
{
return _nextPageMethods;
}
_nextPageMethods = new Dictionary<ServiceRequest, RestClientMethod>();
foreach (var operation in _operationGroup.Operations)
{
var paging = operation.Language.Default.Paging;
if (paging == null || operation.IsLongRunning)
{
continue;
}
foreach (var serviceRequest in operation.Requests)
{
RestClientMethod? nextMethod = null;
if (paging.NextLinkOperation != null)
{
nextMethod = GetOperationMethod(paging.NextLinkOperation.Requests.Single());
}
else if (paging.NextLinkName != null)
{
var method = GetOperationMethod(serviceRequest);
nextMethod = BuildNextPageMethod(method);
}
if (nextMethod != null)
{
_nextPageMethods.Add(serviceRequest, nextMethod);
}
}
}
return _nextPageMethods;
}
private RestClientMethod BuildMethod(Operation operation, HttpRequest httpRequest, ICollection<RequestParameter> requestParameters, ResponseHeaderGroupType? responseHeaderModel)
{
HttpWithBodyRequest? httpRequestWithBody = httpRequest as HttpWithBodyRequest;
Dictionary<string, PathSegment> uriParameters = new Dictionary<string, PathSegment>();
Dictionary<string, PathSegment> pathParameters = new Dictionary<string, PathSegment>();
List<QueryParameter> query = new List<QueryParameter>();
List<RequestHeader> headers = new List<RequestHeader>();
Dictionary<RequestParameter, ReferenceOrConstant> allParameters = new Dictionary<RequestParameter, ReferenceOrConstant>();
Dictionary<RequestParameter, Parameter> methodParameters = new Dictionary<RequestParameter, Parameter>();
RequestBody? body = null;
(RequestParameter, ReferenceOrConstant)? bodyParameter = null;
RequestParameter[] parameters = operation.Parameters.Concat(requestParameters).ToArray();
foreach (RequestParameter requestParameter in parameters)
{
string defaultName = requestParameter.Language.Default.Name;
string serializedName = requestParameter.Language.Default.SerializedName ?? defaultName;
ReferenceOrConstant constantOrReference;
Schema valueSchema = requestParameter.Schema;
if (requestParameter.Implementation == ImplementationLocation.Method)
{
Parameter? parameter = null;
// TODO: always generate virtual parameters
if (!(requestParameter is VirtualParameter) &&
requestParameter.Schema is ConstantSchema constant)
{
constantOrReference = ParseConstant(constant);
valueSchema = constant.ValueType;
}
else
{
parameter = BuildParameter(requestParameter);
if (requestParameter.GroupedBy is RequestParameter groupedByParameter)
{
var groupModel = (ObjectType)_context.TypeFactory.CreateType(groupedByParameter.Schema, false).Implementation;
var property = groupModel.GetPropertyForGroupedParameter(requestParameter);
constantOrReference = new Reference($"{groupedByParameter.CSharpName()}.{property.Declaration.Name}", property.Declaration.Type);
}
else
{
constantOrReference = parameter;
}
}
allParameters.Add(requestParameter, constantOrReference);
if (parameter != null &&
requestParameter.Flattened != true &&
requestParameter.GroupedBy == null)
{
methodParameters.Add(requestParameter, parameter);
}
}
else
{
constantOrReference = _parameters[requestParameter.Language.Default.Name];
}
if (requestParameter.Protocol.Http is HttpParameter httpParameter)
{
SerializationFormat serializationFormat = BuilderHelpers.GetSerializationFormat(valueSchema);
bool skipEncoding = requestParameter.Extensions!.TryGetValue("x-ms-skip-url-encoding", out var value) && Convert.ToBoolean(value);
switch (httpParameter.In)
{
case ParameterLocation.Header:
headers.Add(new RequestHeader(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), serializationFormat));
break;
case ParameterLocation.Query:
query.Add(new QueryParameter(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), !skipEncoding, serializationFormat));
break;
case ParameterLocation.Path:
pathParameters.Add(serializedName, new PathSegment(constantOrReference, !skipEncoding, serializationFormat));
break;
case ParameterLocation.Body:
bodyParameter = (requestParameter, constantOrReference);
break;
case ParameterLocation.Uri:
uriParameters.Add(serializedName, new PathSegment(constantOrReference, !skipEncoding, serializationFormat, isRaw: true));
break;
}
}
}
if (bodyParameter is var (bodyRequestParameter, bodyParameterValue))
{
Debug.Assert(httpRequestWithBody != null);
if (httpRequestWithBody.KnownMediaType == KnownMediaType.Binary)
{
body = new BinaryRequestBody(bodyParameterValue);
}
else if (httpRequestWithBody.KnownMediaType == KnownMediaType.Text)
{
body = new TextRequestBody(bodyParameterValue);
}
else
{
var serialization = _serializationBuilder.Build(
httpRequestWithBody.KnownMediaType,
bodyRequestParameter.Schema,
bodyParameterValue.Type);
// This method has a flattened body
if (bodyRequestParameter.Flattened == true)
{
var objectType = (ObjectType)_context.Library.FindTypeForSchema(bodyRequestParameter.Schema);
var virtualParameters = requestParameters.OfType<VirtualParameter>().ToArray();
List<ObjectPropertyInitializer> initializationMap = new List<ObjectPropertyInitializer>();
foreach (var virtualParameter in virtualParameters)
{
var actualParameter = allParameters[virtualParameter];
initializationMap.Add(new ObjectPropertyInitializer(
objectType.GetPropertyForSchemaProperty(virtualParameter.TargetProperty, true),
actualParameter));
}
body = new FlattenedSchemaRequestBody(objectType, initializationMap.ToArray(), serialization);
}
else
{
body = new SchemaRequestBody(bodyParameterValue, serialization);
}
}
}
PathSegment[] pathSegments = GetPathSegments(httpRequest.Uri, uriParameters, isRaw: true)
.Concat(GetPathSegments(httpRequest.Path, pathParameters))
.ToArray();
Request request = new Request(
httpRequest.Method.ToCoreRequestMethod() ?? RequestMethod.Get,
pathSegments,
query.ToArray(),
headers.ToArray(),
body
);
string operationName = operation.CSharpName();
List<Response> clientResponse = new List<Response>();
if (operation.IsLongRunning)
{
// If operation is a long-running operation than we're generating an initial call here so find a response with non 200/204 code
// Ignore response body and headers for LROs as the ArmOperationHelpers figures out them dynamically
// Long running operations can respond with both initial or final status code
clientResponse.Add(new Response(
null,
operation.LongRunningInitialResponse.HttpResponse.IntStatusCodes.ToArray()
));
clientResponse.Add(new Response(
null,
operation.LongRunningFinalResponse.HttpResponse.IntStatusCodes.ToArray()
));
responseHeaderModel = null;
}
else
{
foreach (var response in operation.Responses)
{
clientResponse.Add(new Response(
BuildResponseBody(response),
response.HttpResponse.IntStatusCodes.ToArray()
));
}
}
var responseType = ReduceResponses(clientResponse);
return new RestClientMethod(
operationName,
BuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description),
responseType,
request,
OrderParameters(methodParameters.Values),
clientResponse.ToArray(),
responseHeaderModel
);
}
private ResponseBody? BuildResponseBody(ServiceResponse response)
{
ResponseBody? responseBody = null;
if (response is SchemaResponse schemaResponse)
{
Schema schema = schemaResponse.Schema is ConstantSchema constantSchema ? constantSchema.ValueType : schemaResponse.Schema;
CSharpType responseType = TypeFactory.GetOutputType(_context.TypeFactory.CreateType(schema, isNullable: false));
ObjectSerialization serialization = _serializationBuilder.Build(response.HttpResponse.KnownMediaType, schema, responseType);
responseBody = new ObjectResponseBody(responseType, serialization);
}
else if (response is BinaryResponse)
{
responseBody = new StreamResponseBody();
}
return responseBody;
}
private static RequestParameterSerializationStyle GetSerializationStyle(HttpParameter httpParameter, Schema valueSchema)
{
Debug.Assert(httpParameter.In == ParameterLocation.Query || httpParameter.In == ParameterLocation.Header);
switch (httpParameter.Style)
{
case null:
case SerializationStyle.Form:
case SerializationStyle.Simple:
return valueSchema is ArraySchema ? RequestParameterSerializationStyle.CommaDelimited : RequestParameterSerializationStyle.Simple;
case SerializationStyle.PipeDelimited:
return RequestParameterSerializationStyle.PipeDelimited;
case SerializationStyle.SpaceDelimited:
return RequestParameterSerializationStyle.SpaceDelimited;
case SerializationStyle.TabDelimited:
return RequestParameterSerializationStyle.TabDelimited;
default:
throw new ArgumentOutOfRangeException();
}
}
private static IEnumerable<PathSegment> GetPathSegments(string httpRequestUri, Dictionary<string, PathSegment> parameters, bool isRaw = false)
{
PathSegment TextSegment(string text)
{
return new PathSegment(BuilderHelpers.StringConstant(text), false, SerializationFormat.Default, isRaw);
}
foreach ((string text, bool isLiteral) in StringExtensions.GetPathParts(httpRequestUri))
{
yield return isLiteral ? TextSegment(text) : parameters[text];
}
}
private static Parameter[] OrderParameters(IEnumerable<Parameter> parameters) => parameters.OrderBy(p => p.DefaultValue != null).ToArray();
// Merges operations without response types types together
private CSharpType? ReduceResponses(List<Response> responses)
{
foreach (var typeGroup in responses.GroupBy(r=> r.ResponseBody))
{
foreach (var individualResponse in typeGroup)
{
responses.Remove(individualResponse);
}
responses.Add(new Response(
typeGroup.Key,
typeGroup.SelectMany(r=>r.StatusCodes).Distinct().ToArray()));
}
var bodyTypes = responses.Select(r => r.ResponseBody?.Type)
.OfType<CSharpType>()
.Distinct()
.ToArray();
return bodyTypes.Length switch
{
0 => null,
1 => bodyTypes[0],
_ => typeof(object)
};
}
private static RestClientMethod BuildNextPageMethod(RestClientMethod method)
{
var nextPageUrlParameter = new Parameter(
"nextLink",
"The URL to the next page of results.",
typeof(string),
defaultValue: null,
isRequired: true);
PathSegment[] pathSegments = method.Request.PathSegments
.Where(ps => ps.IsRaw)
.Append(new PathSegment(nextPageUrlParameter, false, SerializationFormat.Default, isRaw: true))
.ToArray();
var request = new Request(
method.Request.HttpMethod,
pathSegments,
Array.Empty<QueryParameter>(),
method.Request.Headers,
null
);
Parameter[] parameters = method.Parameters.Where(p => p.Name != nextPageUrlParameter.Name)
.Prepend(nextPageUrlParameter)
.ToArray();
return new RestClientMethod(
$"{method.Name}NextPage",
method.Description,
method.ReturnType,
request,
parameters,
method.Responses,
method.HeaderModel);
}
public RestClientMethod? GetNextOperationMethod(ServiceRequest request)
{
EnsureGetNextPageMethods().TryGetValue(request, out RestClientMethod? value);
return value;
}
public RestClientMethod GetOperationMethod(ServiceRequest request)
{
return EnsureNormalMethods()[request];
}
}
}

Просмотреть файл

@ -3,9 +3,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using AutoRest.CSharp.V3.Input;
using AutoRest.CSharp.V3.Output.Builders;
using AutoRest.CSharp.V3.Output.Models.Requests;
using AutoRest.CSharp.V3.Output.Models.Responses;
namespace AutoRest.CSharp.V3.Output.Models.Types
{
@ -14,8 +16,10 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
private readonly CodeModel _codeModel;
private readonly BuildContext _context;
private Dictionary<Schema, ISchemaType>? _models;
private Client[]? _clients;
private RestClient[]? _restClients;
private Dictionary<OperationGroup, Client>? _clients;
private Dictionary<OperationGroup, RestClient>? _restClients;
private Dictionary<Operation, LongRunningOperation>? _operations;
private Dictionary<Operation, ResponseHeaderGroupType>? _headerModels;
public OutputLibrary(CodeModel codeModel, BuildContext context)
{
@ -25,22 +29,89 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
public IEnumerable<ISchemaType> Models => SchemaMap.Values;
public RestClient[] RestClients
public IEnumerable<RestClient> RestClients => EnsureRestClients().Values;
public IEnumerable<Client> Clients => EnsureClients().Values;
public IEnumerable<LongRunningOperation> LongRunningOperations => EnsureLongRunningOperations().Values;
public IEnumerable<ResponseHeaderGroupType> HeaderModels => (_headerModels ??= EnsureHeaderModels()).Values;
private Dictionary<Operation, ResponseHeaderGroupType> EnsureHeaderModels()
{
get
if (_headerModels != null)
{
EnsureClients();
return _restClients!;
return _headerModels;
}
_headerModels = new Dictionary<Operation, ResponseHeaderGroupType>();
foreach (var operationGroup in _codeModel.OperationGroups)
{
foreach (var operation in operationGroup.Operations)
{
var headers = ResponseHeaderGroupType.TryCreate(operationGroup, operation, _context);
if (headers != null)
{
_headerModels.Add(operation, headers);
}
}
}
return _headerModels;
}
public Client[] Clients
private Dictionary<Operation, LongRunningOperation> EnsureLongRunningOperations()
{
get
if (_operations != null)
{
EnsureClients();
return _clients!;
return _operations;
}
_operations = new Dictionary<Operation, LongRunningOperation>();
foreach (var operationGroup in _codeModel.OperationGroups)
{
foreach (var operation in operationGroup.Operations)
{
if (operation.IsLongRunning)
{
_operations.Add(operation, new LongRunningOperation(operationGroup, operation, _context));
}
}
}
return _operations;
}
private Dictionary<OperationGroup, Client> EnsureClients()
{
if (_clients != null)
{
return _clients;
}
_clients = new Dictionary<OperationGroup, Client>();
foreach (var operationGroup in _codeModel.OperationGroups)
{
_clients.Add(operationGroup, new Client(operationGroup, _context));
}
return _clients;
}
private Dictionary<OperationGroup, RestClient> EnsureRestClients()
{
if (_restClients != null)
{
return _restClients;
}
_restClients = new Dictionary<OperationGroup, RestClient>();
foreach (var operationGroup in _codeModel.OperationGroups)
{
_restClients.Add(operationGroup, new RestClient(operationGroup, _context));
}
return _restClients;
}
public ISchemaType FindTypeForSchema(Schema schema)
@ -50,16 +121,6 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
private Dictionary<Schema, ISchemaType> SchemaMap => _models ??= BuildModels();
private void EnsureClients()
{
var clientBuilder = new ClientBuilder(_context);
var allClients = _codeModel.OperationGroups.Select(clientBuilder.BuildClient).ToArray();
_clients = allClients.Select(c => c.Client).ToArray();
_restClients = allClients.Select(c => c.RestClient).ToArray();
}
private Dictionary<Schema, ISchemaType> BuildModels()
{
var allSchemas = _codeModel.Schemas.Choices.Cast<Schema>()
@ -77,5 +138,28 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
ObjectSchema objectSchema => new ObjectType(objectSchema, _context),
_ => throw new NotImplementedException()
};
public LongRunningOperation FindLongRunningOperation(Operation operation)
{
Debug.Assert(operation.IsLongRunning);
return EnsureLongRunningOperations()[operation];
}
public Client FindClient(OperationGroup operationGroup)
{
return EnsureClients()[operationGroup];
}
public RestClient FindRestClient(OperationGroup operationGroup)
{
return EnsureRestClients()[operationGroup];
}
public ResponseHeaderGroupType? FindHeaderModel(Operation operation)
{
EnsureHeaderModels().TryGetValue(operation, out var model);
return model;
}
}
}

Просмотреть файл

@ -13,344 +13,344 @@ using Azure.Core.Pipeline;
namespace Azure.Core
{
/// <summary>
/// Helper methods for ARM long-running operations.
/// This implements the ARM scenarios for LROs. It is highly recommended to read the ARM spec prior to modifying this code:
/// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations
/// Other reference documents include:
/// https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md#x-ms-long-running-operation
/// https://github.com/Azure/adx-documentation-pr/blob/master/sdks/LRO/LRO_AzureSDK.md
/// </summary>
internal static class ArmOperationHelpers
/// <typeparam name="T">The final result of the LRO.</typeparam>
internal class ArmOperationHelpers<T>
{
internal static Operation<Response> Create(HttpPipeline pipeline, ClientDiagnostics clientDiagnostics, Response originalResponse, RequestMethod requestMethod, string scopeName, OperationFinalStateVia finalStateVia, Func<HttpMessage> createOriginalHttpMessage)
public static TimeSpan DefaultPollingInterval { get; } = TimeSpan.FromSeconds(1);
private static readonly string[] s_failureStates = {"failed", "canceled"};
private static readonly string[] s_terminalStates = {"succeeded", "failed", "canceled"};
private readonly HttpPipeline _pipeline;
private readonly ClientDiagnostics _clientDiagnostics;
private readonly string _scopeName;
private readonly RequestMethod _requestMethod;
private readonly string _originalUri;
private readonly OperationFinalStateVia _finalStateVia;
private HeaderFrom _headerFrom;
private string _pollUri = default!;
private bool _originalHasLocation;
private string? _lastKnownLocation;
private readonly IOperationSource<T> _source;
private Response _rawResponse;
private T _value = default!;
private bool _hasValue;
private bool _hasCompleted;
private bool _shouldPoll;
public ArmOperationHelpers(
IOperationSource<T> source,
ClientDiagnostics clientDiagnostics,
HttpPipeline pipeline,
Request originalRequest,
Response originalResponse,
OperationFinalStateVia finalStateVia,
string scopeName)
{
return Create(pipeline, clientDiagnostics, originalResponse, requestMethod, scopeName, finalStateVia, createOriginalHttpMessage,
(response, token) => response,
(response, token) => new ValueTask<Response>(response));
_source = source;
_rawResponse = originalResponse;
_requestMethod = originalRequest.Method;
_originalUri = originalRequest.Uri.ToString();
_finalStateVia = finalStateVia;
InitializeScenarioInfo();
_pipeline = pipeline;
_clientDiagnostics = clientDiagnostics;
_scopeName = scopeName;
// When the original response has no headers, we do not start polling immediately.
_shouldPoll = _headerFrom != HeaderFrom.None;
}
internal static Operation<T> Create<T>(HttpPipeline pipeline, ClientDiagnostics clientDiagnostics, Response originalResponse, RequestMethod requestMethod, string scopeName, OperationFinalStateVia finalStateVia,
Func<HttpMessage> createOriginalHttpMessage, Func<Response, CancellationToken, T> createFinalResponse, Func<Response, CancellationToken, ValueTask<T>> createFinalResponseAsync) where T : notnull
public Response GetRawResponse() => _rawResponse;
public ValueTask<Response<T>> WaitForCompletionAsync(CancellationToken cancellationToken = default)
{
using HttpMessage originalHttpMethod = createOriginalHttpMessage();
string originalUri = originalHttpMethod.Request.Uri.ToString();
return new ArmOperation<T>(pipeline, clientDiagnostics, originalResponse, originalUri, requestMethod, finalStateVia, scopeName, createFinalResponse, createFinalResponseAsync);
return WaitForCompletionAsync(DefaultPollingInterval, cancellationToken);
}
private static readonly string[] s_failureStates = { "failed", "canceled" };
private static readonly string[] s_terminalStates = { "succeeded", "failed", "canceled" };
/// <summary>
/// This implements the ARM scenarios for LROs. It is highly recommended to read the ARM spec prior to modifying this code:
/// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations
/// Other reference documents include:
/// https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md#x-ms-long-running-operation
/// https://github.com/Azure/adx-documentation-pr/blob/master/sdks/LRO/LRO_AzureSDK.md
/// </summary>
/// <typeparam name="T">The final result of the LRO.</typeparam>
private class ArmOperation<T> : Operation<T> where T : notnull
public async ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken)
{
private readonly HttpPipeline _pipeline;
private readonly ClientDiagnostics _clientDiagnostics;
private readonly string _scopeName;
private readonly Func<Response, CancellationToken, T> _createFinalResponse;
private readonly Func<Response, CancellationToken, ValueTask<T>> _createFinalResponseAsync;
private readonly RequestMethod _requestMethod;
private readonly string _originalUri;
private readonly OperationFinalStateVia _finalStateVia;
private HeaderFrom _headerFrom;
private string _pollUri = default!;
private bool _originalHasLocation;
private string? _lastKnownLocation;
private Response _rawResponse;
private T _value = default!;
private bool _hasValue;
private bool _hasCompleted;
private bool _shouldPoll;
public ArmOperation(HttpPipeline pipeline, ClientDiagnostics clientDiagnostics, Response originalResponse,
string originalUri, RequestMethod requestMethod, OperationFinalStateVia finalStateVia, string scopeName,
Func<Response, CancellationToken, T> createFinalResponse, Func<Response, CancellationToken, ValueTask<T>> createFinalResponseAsync)
while (true)
{
_rawResponse = originalResponse;
_requestMethod = requestMethod;
_originalUri = originalUri;
_finalStateVia = finalStateVia;
InitializeScenarioInfo();
await UpdateStatusAsync(cancellationToken).ConfigureAwait(false);
if (HasCompleted)
{
return Response.FromValue(Value, GetRawResponse());
}
_pipeline = pipeline;
_clientDiagnostics = clientDiagnostics;
_scopeName = scopeName;
_createFinalResponse = createFinalResponse;
_createFinalResponseAsync = createFinalResponseAsync;
// When the original response has no headers, we do not start polling immediately.
_shouldPoll = _headerFrom != HeaderFrom.None;
await Task.Delay(pollingInterval, cancellationToken).ConfigureAwait(false);
}
}
public override Response GetRawResponse() => _rawResponse;
public override ValueTask<Response<T>> WaitForCompletionAsync(CancellationToken cancellationToken = default) =>
this.DefaultWaitForCompletionAsync(OperationHelpers.DefaultPollingInterval, cancellationToken);
public override ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) =>
this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken);
private async ValueTask<Response> UpdateStatusAsync(bool async, CancellationToken cancellationToken)
private async ValueTask<Response> UpdateStatusAsync(bool async, CancellationToken cancellationToken)
{
if (_hasCompleted)
{
if (_hasCompleted)
{
return GetRawResponse();
}
if (_shouldPoll)
{
UpdatePollUri();
_rawResponse = async
? await GetResponseAsync(_pollUri, cancellationToken).ConfigureAwait(false)
: GetResponse(_pollUri, cancellationToken);
}
_shouldPoll = true;
_hasCompleted = IsTerminalState(out string state);
if (_hasCompleted)
{
Response finalResponse = GetRawResponse();
if (s_failureStates.Contains(state))
{
throw _clientDiagnostics.CreateRequestFailedException(finalResponse);
}
string? finalUri = GetFinalUri();
if (finalUri != null)
{
finalResponse = async
? await GetResponseAsync(finalUri, cancellationToken).ConfigureAwait(false)
: GetResponse(finalUri, cancellationToken);
}
switch (finalResponse.Status)
{
case 200:
case 204 when !(_requestMethod == RequestMethod.Put || _requestMethod == RequestMethod.Patch):
{
_value = async
? await _createFinalResponseAsync(finalResponse, cancellationToken).ConfigureAwait(false)
: _createFinalResponse(finalResponse, cancellationToken);
_rawResponse = finalResponse;
_hasValue = true;
break;
}
default:
throw _clientDiagnostics.CreateRequestFailedException(finalResponse);
}
}
return GetRawResponse();
}
public override async ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => await UpdateStatusAsync(async: true, cancellationToken).ConfigureAwait(false);
public override Response UpdateStatus(CancellationToken cancellationToken = default) => UpdateStatusAsync(async: false, cancellationToken).EnsureCompleted();
//TODO: This is currently unused.
public override string Id { get; } = Guid.NewGuid().ToString();
public override T Value
if (_shouldPoll)
{
get
UpdatePollUri();
_rawResponse = async
? await GetResponseAsync(_pollUri, cancellationToken).ConfigureAwait(false)
: GetResponse(_pollUri, cancellationToken);
}
_shouldPoll = true;
_hasCompleted = IsTerminalState(out string state);
if (_hasCompleted)
{
Response finalResponse = GetRawResponse();
if (s_failureStates.Contains(state))
{
if (!HasValue)
throw _clientDiagnostics.CreateRequestFailedException(finalResponse);
}
string? finalUri = GetFinalUri();
if (finalUri != null)
{
finalResponse = async
? await GetResponseAsync(finalUri, cancellationToken).ConfigureAwait(false)
: GetResponse(finalUri, cancellationToken);
}
switch (finalResponse.Status)
{
case 200:
case 204 when !(_requestMethod == RequestMethod.Put || _requestMethod == RequestMethod.Patch):
{
throw new InvalidOperationException("The operation has not completed yet.");
_value = async
? await _source.CreateResultAsync(finalResponse, cancellationToken).ConfigureAwait(false)
: _source.CreateResult(finalResponse, cancellationToken);
_rawResponse = finalResponse;
_hasValue = true;
break;
}
return _value;
}
}
public override bool HasCompleted => _hasCompleted;
public override bool HasValue => _hasValue;
private HttpMessage CreateRequest(string link)
{
HttpMessage message = _pipeline.CreateMessage();
Request request = message.Request;
request.Method = RequestMethod.Get;
request.Uri.Reset(new Uri(link));
return message;
}
private async ValueTask<Response> GetResponseAsync(string link, CancellationToken cancellationToken = default)
{
if (link == null)
{
throw new ArgumentNullException(nameof(link));
}
using DiagnosticScope scope = _clientDiagnostics.CreateScope(_scopeName);
scope.Start();
try
{
using HttpMessage message = CreateRequest(link);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
return message.Response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
default:
throw _clientDiagnostics.CreateRequestFailedException(finalResponse);
}
}
private Response GetResponse(string link, CancellationToken cancellationToken = default)
return GetRawResponse();
}
public async ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => await UpdateStatusAsync(async: true, cancellationToken).ConfigureAwait(false);
public Response UpdateStatus(CancellationToken cancellationToken = default) => UpdateStatusAsync(async: false, cancellationToken).EnsureCompleted();
//TODO: This is currently unused.
public string Id => throw new NotImplementedException();
public T Value
{
get
{
if (link == null)
if (!HasValue)
{
throw new ArgumentNullException(nameof(link));
throw new InvalidOperationException("The operation has not completed yet.");
}
using DiagnosticScope scope = _clientDiagnostics.CreateScope(_scopeName);
scope.Start();
try
{
using HttpMessage message = CreateRequest(link);
_pipeline.Send(message, cancellationToken);
return message.Response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
return _value;
}
}
public bool HasCompleted => _hasCompleted;
public bool HasValue => _hasValue;
private HttpMessage CreateRequest(string link)
{
HttpMessage message = _pipeline.CreateMessage();
Request request = message.Request;
request.Method = RequestMethod.Get;
request.Uri.Reset(new Uri(link));
return message;
}
private async ValueTask<Response> GetResponseAsync(string link, CancellationToken cancellationToken = default)
{
if (link == null)
{
throw new ArgumentNullException(nameof(link));
}
private bool IsTerminalState(out string state)
using DiagnosticScope scope = _clientDiagnostics.CreateScope(_scopeName);
scope.Start();
try
{
Response response = GetRawResponse();
state = string.Empty;
if (_headerFrom == HeaderFrom.Location)
{
return response.Status != 202;
}
using HttpMessage message = CreateRequest(link);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
return message.Response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
if (response.Status >= 200 && response.Status <= 204)
private Response GetResponse(string link, CancellationToken cancellationToken = default)
{
if (link == null)
{
throw new ArgumentNullException(nameof(link));
}
using DiagnosticScope scope = _clientDiagnostics.CreateScope(_scopeName);
scope.Start();
try
{
using HttpMessage message = CreateRequest(link);
_pipeline.Send(message, cancellationToken);
return message.Response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
private bool IsTerminalState(out string state)
{
Response response = GetRawResponse();
state = string.Empty;
if (_headerFrom == HeaderFrom.Location)
{
return response.Status != 202;
}
if (response.Status >= 200 && response.Status <= 204)
{
if (response.ContentStream?.Length > 0)
{
if (response.ContentStream?.Length > 0)
try
{
try
using JsonDocument document = JsonDocument.Parse(response.ContentStream);
foreach (JsonProperty property in document.RootElement.EnumerateObject())
{
using JsonDocument document = JsonDocument.Parse(response.ContentStream);
foreach (JsonProperty property in document.RootElement.EnumerateObject())
if ((_headerFrom == HeaderFrom.OperationLocation ||
_headerFrom == HeaderFrom.AzureAsyncOperation) &&
property.NameEquals("status"))
{
if ((_headerFrom == HeaderFrom.OperationLocation ||
_headerFrom == HeaderFrom.AzureAsyncOperation) &&
property.NameEquals("status"))
{
state = property.Value.GetString().ToLowerInvariant();
return s_terminalStates.Contains(state);
}
state = property.Value.GetString().ToLowerInvariant();
return s_terminalStates.Contains(state);
}
if (_headerFrom == HeaderFrom.None && property.NameEquals("properties"))
if (_headerFrom == HeaderFrom.None && property.NameEquals("properties"))
{
foreach (JsonProperty innerProperty in property.Value.EnumerateObject())
{
foreach (JsonProperty innerProperty in property.Value.EnumerateObject())
if (innerProperty.NameEquals("provisioningState"))
{
if (innerProperty.NameEquals("provisioningState"))
{
state = innerProperty.Value.GetString().ToLowerInvariant();
return s_terminalStates.Contains(state);
}
state = innerProperty.Value.GetString().ToLowerInvariant();
return s_terminalStates.Contains(state);
}
}
}
}
finally
{
// It is required to reset the position of the content after reading as this response may be used for deserialization.
response.ContentStream.Position = 0;
}
}
// If provisioningState was not found, it defaults to Succeeded.
if (_headerFrom == HeaderFrom.None)
finally
{
return true;
// It is required to reset the position of the content after reading as this response may be used for deserialization.
response.ContentStream.Position = 0;
}
}
throw _clientDiagnostics.CreateRequestFailedException(response);
}
private enum HeaderFrom
{
None,
OperationLocation,
AzureAsyncOperation,
Location
}
private void InitializeScenarioInfo()
{
_originalHasLocation = _rawResponse.Headers.Contains("Location");
if (_rawResponse.Headers.Contains("Operation-Location"))
// If provisioningState was not found, it defaults to Succeeded.
if (_headerFrom == HeaderFrom.None)
{
_headerFrom = HeaderFrom.OperationLocation;
return true;
}
}
throw _clientDiagnostics.CreateRequestFailedException(response);
}
private enum HeaderFrom
{
None,
OperationLocation,
AzureAsyncOperation,
Location
}
private void InitializeScenarioInfo()
{
_originalHasLocation = _rawResponse.Headers.Contains("Location");
if (_rawResponse.Headers.Contains("Operation-Location"))
{
_headerFrom = HeaderFrom.OperationLocation;
return;
}
if (_rawResponse.Headers.Contains("Azure-AsyncOperation"))
{
_headerFrom = HeaderFrom.AzureAsyncOperation;
return;
}
if (_originalHasLocation)
{
_headerFrom = HeaderFrom.Location;
return;
}
_pollUri = _originalUri;
_headerFrom = HeaderFrom.None;
}
private void UpdatePollUri()
{
var hasLocation = _rawResponse.Headers.TryGetValue("Location", out string? location);
if (hasLocation)
{
_lastKnownLocation = location;
}
switch (_headerFrom)
{
case HeaderFrom.OperationLocation when _rawResponse.Headers.TryGetValue("Operation-Location", out string? operationLocation):
_pollUri = operationLocation;
return;
}
if (_rawResponse.Headers.Contains("Azure-AsyncOperation"))
{
_headerFrom = HeaderFrom.AzureAsyncOperation;
case HeaderFrom.AzureAsyncOperation when _rawResponse.Headers.TryGetValue("Azure-AsyncOperation", out string? azureAsyncOperation):
_pollUri = azureAsyncOperation;
return;
}
if (_originalHasLocation)
{
_headerFrom = HeaderFrom.Location;
case HeaderFrom.Location when hasLocation:
_pollUri = location!;
return;
}
_pollUri = _originalUri;
_headerFrom = HeaderFrom.None;
}
private void UpdatePollUri()
{
var hasLocation = _rawResponse.Headers.TryGetValue("Location", out string? location);
if (hasLocation)
{
_lastKnownLocation = location;
}
switch (_headerFrom)
{
case HeaderFrom.OperationLocation when _rawResponse.Headers.TryGetValue("Operation-Location", out string? operationLocation):
_pollUri = operationLocation;
return;
case HeaderFrom.AzureAsyncOperation when _rawResponse.Headers.TryGetValue("Azure-AsyncOperation", out string? azureAsyncOperation):
_pollUri = azureAsyncOperation;
return;
case HeaderFrom.Location when hasLocation:
_pollUri = location!;
return;
}
}
private string? GetFinalUri()
{
if (_headerFrom == HeaderFrom.OperationLocation || _headerFrom == HeaderFrom.AzureAsyncOperation)
{
if (_requestMethod == RequestMethod.Delete)
{
return null;
}
if (_requestMethod == RequestMethod.Put || (_originalHasLocation && _finalStateVia == OperationFinalStateVia.OriginalUri))
{
return _originalUri;
}
if (_originalHasLocation && _finalStateVia == OperationFinalStateVia.Location)
{
return _lastKnownLocation;
}
}
return null;
}
}
private string? GetFinalUri()
{
if (_headerFrom == HeaderFrom.OperationLocation || _headerFrom == HeaderFrom.AzureAsyncOperation)
{
if (_requestMethod == RequestMethod.Delete)
{
return null;
}
if (_requestMethod == RequestMethod.Put || (_originalHasLocation && _finalStateVia == OperationFinalStateVia.OriginalUri))
{
return _originalUri;
}
if (_originalHasLocation && _finalStateVia == OperationFinalStateVia.Location)
{
return _lastKnownLocation;
}
}
return null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Core
{
internal interface IOperationSource<T>
{
T CreateResult(Response response, CancellationToken cancellationToken);
ValueTask<T> CreateResultAsync(Response response, CancellationToken cancellationToken);
}
}

62
test/TestProjects/NameConflicts/Generated/ServiceAnalyzeBodyOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace NameConflicts
{
/// <summary> Analyze body, that could be different media types. </summary>
public partial class ServiceAnalyzeBodyOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal ServiceAnalyzeBodyOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServiceAnalyzeBodyOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -10,7 +10,6 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using NameConflicts.Models;
@ -80,27 +79,10 @@ namespace NameConflicts
}
}
/// <summary> Analyze body, that could be different media types. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateAnalyzeBody(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "ServiceClient.StartAnalyzeBody", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Analyze body, that could be different media types. </summary>
/// <param name="stringBody"> The binary to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeBodyAsync(Stream stringBody, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeBodyOperation> StartAnalyzeBodyAsync(Stream stringBody, CancellationToken cancellationToken = default)
{
if (stringBody == null)
{
@ -112,7 +94,7 @@ namespace NameConflicts
try
{
var originalResponse = await RestClient.AnalyzeBodyAsync(stringBody, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeBody(originalResponse, () => RestClient.CreateAnalyzeBodyRequest(stringBody));
return new ServiceAnalyzeBodyOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeBodyRequest(stringBody).Request, originalResponse);
}
catch (Exception e)
{
@ -124,7 +106,7 @@ namespace NameConflicts
/// <summary> Analyze body, that could be different media types. </summary>
/// <param name="stringBody"> The binary to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeBody(Stream stringBody, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeBodyOperation StartAnalyzeBody(Stream stringBody, CancellationToken cancellationToken = default)
{
if (stringBody == null)
{
@ -136,7 +118,7 @@ namespace NameConflicts
try
{
var originalResponse = RestClient.AnalyzeBody(stringBody, cancellationToken);
return CreateAnalyzeBody(originalResponse, () => RestClient.CreateAnalyzeBodyRequest(stringBody));
return new ServiceAnalyzeBodyOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeBodyRequest(stringBody).Request, originalResponse);
}
catch (Exception e)
{
@ -148,14 +130,14 @@ namespace NameConflicts
/// <summary> Analyze body, that could be different media types. </summary>
/// <param name="stringBody"> The String to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartAnalyzeBodyAsync(string stringBody = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<ServiceAnalyzeBodyOperation> StartAnalyzeBodyAsync(string stringBody = null, CancellationToken cancellationToken = default)
{
using var scope0 = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeBody");
scope0.Start();
try
{
var originalResponse = await RestClient.AnalyzeBodyAsync(stringBody, cancellationToken).ConfigureAwait(false);
return CreateAnalyzeBody(originalResponse, () => RestClient.CreateAnalyzeBodyRequest(stringBody));
return new ServiceAnalyzeBodyOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeBodyRequest(stringBody).Request, originalResponse);
}
catch (Exception e)
{
@ -167,14 +149,14 @@ namespace NameConflicts
/// <summary> Analyze body, that could be different media types. </summary>
/// <param name="stringBody"> The String to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartAnalyzeBody(string stringBody = null, CancellationToken cancellationToken = default)
public virtual ServiceAnalyzeBodyOperation StartAnalyzeBody(string stringBody = null, CancellationToken cancellationToken = default)
{
using var scope0 = _clientDiagnostics.CreateScope("ServiceClient.StartAnalyzeBody");
scope0.Start();
try
{
var originalResponse = RestClient.AnalyzeBody(stringBody, cancellationToken);
return CreateAnalyzeBody(originalResponse, () => RestClient.CreateAnalyzeBodyRequest(stringBody));
return new ServiceAnalyzeBodyOperation(_clientDiagnostics, _pipeline, RestClient.CreateAnalyzeBodyRequest(stringBody).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -6,11 +6,8 @@
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
@ -34,58 +31,17 @@ namespace lro
_pipeline = pipeline;
}
/// <summary> Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Product> CreatePut201CreatingSucceeded200(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "LRORetrysClient.StartPut201CreatingSucceeded200", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
});
}
/// <summary> Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Product>> StartPut201CreatingSucceeded200Async(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysPut201CreatingSucceeded200Operation> StartPut201CreatingSucceeded200Async(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPut201CreatingSucceeded200");
scope.Start();
try
{
var originalResponse = await RestClient.Put201CreatingSucceeded200Async(product, cancellationToken).ConfigureAwait(false);
return CreatePut201CreatingSucceeded200(originalResponse, () => RestClient.CreatePut201CreatingSucceeded200Request(product));
return new LRORetrysPut201CreatingSucceeded200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePut201CreatingSucceeded200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -97,14 +53,14 @@ namespace lro
/// <summary> Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Product> StartPut201CreatingSucceeded200(Product product = null, CancellationToken cancellationToken = default)
public virtual LRORetrysPut201CreatingSucceeded200Operation StartPut201CreatingSucceeded200(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPut201CreatingSucceeded200");
scope.Start();
try
{
var originalResponse = RestClient.Put201CreatingSucceeded200(product, cancellationToken);
return CreatePut201CreatingSucceeded200(originalResponse, () => RestClient.CreatePut201CreatingSucceeded200Request(product));
return new LRORetrysPut201CreatingSucceeded200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePut201CreatingSucceeded200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -113,58 +69,17 @@ namespace lro
}
}
/// <summary> Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Product> CreatePutAsyncRelativeRetrySucceeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "LRORetrysClient.StartPutAsyncRelativeRetrySucceeded", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
});
}
/// <summary> Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Product>> StartPutAsyncRelativeRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysPutAsyncRelativeRetrySucceededOperation> StartPutAsyncRelativeRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPutAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = await RestClient.PutAsyncRelativeRetrySucceededAsync(product, cancellationToken).ConfigureAwait(false);
return CreatePutAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreatePutAsyncRelativeRetrySucceededRequest(product));
return new LRORetrysPutAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePutAsyncRelativeRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -176,14 +91,14 @@ namespace lro
/// <summary> Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Product> StartPutAsyncRelativeRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
public virtual LRORetrysPutAsyncRelativeRetrySucceededOperation StartPutAsyncRelativeRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPutAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = RestClient.PutAsyncRelativeRetrySucceeded(product, cancellationToken);
return CreatePutAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreatePutAsyncRelativeRetrySucceededRequest(product));
return new LRORetrysPutAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePutAsyncRelativeRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -192,57 +107,16 @@ namespace lro
}
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Accepted. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Product> CreateDeleteProvisioning202Accepted200Succeeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Delete, "LRORetrysClient.StartDeleteProvisioning202Accepted200Succeeded", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
});
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Accepted. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Product>> StartDeleteProvisioning202Accepted200SucceededAsync(CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysDeleteProvisioning202Accepted200SucceededOperation> StartDeleteProvisioning202Accepted200SucceededAsync(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDeleteProvisioning202Accepted200Succeeded");
scope.Start();
try
{
var originalResponse = await RestClient.DeleteProvisioning202Accepted200SucceededAsync(cancellationToken).ConfigureAwait(false);
return CreateDeleteProvisioning202Accepted200Succeeded(originalResponse, () => RestClient.CreateDeleteProvisioning202Accepted200SucceededRequest());
return new LRORetrysDeleteProvisioning202Accepted200SucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteProvisioning202Accepted200SucceededRequest().Request, originalResponse);
}
catch (Exception e)
{
@ -253,14 +127,14 @@ namespace lro
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Accepted. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Product> StartDeleteProvisioning202Accepted200Succeeded(CancellationToken cancellationToken = default)
public virtual LRORetrysDeleteProvisioning202Accepted200SucceededOperation StartDeleteProvisioning202Accepted200Succeeded(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDeleteProvisioning202Accepted200Succeeded");
scope.Start();
try
{
var originalResponse = RestClient.DeleteProvisioning202Accepted200Succeeded(cancellationToken);
return CreateDeleteProvisioning202Accepted200Succeeded(originalResponse, () => RestClient.CreateDeleteProvisioning202Accepted200SucceededRequest());
return new LRORetrysDeleteProvisioning202Accepted200SucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteProvisioning202Accepted200SucceededRequest().Request, originalResponse);
}
catch (Exception e)
{
@ -269,33 +143,16 @@ namespace lro
}
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateDelete202Retry200(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Delete, "LRORetrysClient.StartDelete202Retry200", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartDelete202Retry200Async(CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysDelete202Retry200Operation> StartDelete202Retry200Async(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDelete202Retry200");
scope.Start();
try
{
var originalResponse = await RestClient.Delete202Retry200Async(cancellationToken).ConfigureAwait(false);
return CreateDelete202Retry200(originalResponse, () => RestClient.CreateDelete202Retry200Request());
return new LRORetrysDelete202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreateDelete202Retry200Request().Request, originalResponse);
}
catch (Exception e)
{
@ -306,14 +163,14 @@ namespace lro
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartDelete202Retry200(CancellationToken cancellationToken = default)
public virtual LRORetrysDelete202Retry200Operation StartDelete202Retry200(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDelete202Retry200");
scope.Start();
try
{
var originalResponse = RestClient.Delete202Retry200(cancellationToken);
return CreateDelete202Retry200(originalResponse, () => RestClient.CreateDelete202Retry200Request());
return new LRORetrysDelete202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreateDelete202Retry200Request().Request, originalResponse);
}
catch (Exception e)
{
@ -322,33 +179,16 @@ namespace lro
}
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreateDeleteAsyncRelativeRetrySucceeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Delete, "LRORetrysClient.StartDeleteAsyncRelativeRetrySucceeded", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartDeleteAsyncRelativeRetrySucceededAsync(CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysDeleteAsyncRelativeRetrySucceededOperation> StartDeleteAsyncRelativeRetrySucceededAsync(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDeleteAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = await RestClient.DeleteAsyncRelativeRetrySucceededAsync(cancellationToken).ConfigureAwait(false);
return CreateDeleteAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreateDeleteAsyncRelativeRetrySucceededRequest());
return new LRORetrysDeleteAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteAsyncRelativeRetrySucceededRequest().Request, originalResponse);
}
catch (Exception e)
{
@ -359,14 +199,14 @@ namespace lro
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartDeleteAsyncRelativeRetrySucceeded(CancellationToken cancellationToken = default)
public virtual LRORetrysDeleteAsyncRelativeRetrySucceededOperation StartDeleteAsyncRelativeRetrySucceeded(CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartDeleteAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = RestClient.DeleteAsyncRelativeRetrySucceeded(cancellationToken);
return CreateDeleteAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreateDeleteAsyncRelativeRetrySucceededRequest());
return new LRORetrysDeleteAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteAsyncRelativeRetrySucceededRequest().Request, originalResponse);
}
catch (Exception e)
{
@ -375,34 +215,17 @@ namespace lro
}
}
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreatePost202Retry200(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "LRORetrysClient.StartPost202Retry200", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartPost202Retry200Async(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysPost202Retry200Operation> StartPost202Retry200Async(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPost202Retry200");
scope.Start();
try
{
var originalResponse = await RestClient.Post202Retry200Async(product, cancellationToken).ConfigureAwait(false);
return CreatePost202Retry200(originalResponse, () => RestClient.CreatePost202Retry200Request(product));
return new LRORetrysPost202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePost202Retry200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -414,14 +237,14 @@ namespace lro
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartPost202Retry200(Product product = null, CancellationToken cancellationToken = default)
public virtual LRORetrysPost202Retry200Operation StartPost202Retry200(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPost202Retry200");
scope.Start();
try
{
var originalResponse = RestClient.Post202Retry200(product, cancellationToken);
return CreatePost202Retry200(originalResponse, () => RestClient.CreatePost202Retry200Request(product));
return new LRORetrysPost202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePost202Retry200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -430,34 +253,17 @@ namespace lro
}
}
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreatePostAsyncRelativeRetrySucceeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "LRORetrysClient.StartPostAsyncRelativeRetrySucceeded", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartPostAsyncRelativeRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LRORetrysPostAsyncRelativeRetrySucceededOperation> StartPostAsyncRelativeRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPostAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = await RestClient.PostAsyncRelativeRetrySucceededAsync(product, cancellationToken).ConfigureAwait(false);
return CreatePostAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreatePostAsyncRelativeRetrySucceededRequest(product));
return new LRORetrysPostAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePostAsyncRelativeRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -469,14 +275,14 @@ namespace lro
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartPostAsyncRelativeRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
public virtual LRORetrysPostAsyncRelativeRetrySucceededOperation StartPostAsyncRelativeRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LRORetrysClient.StartPostAsyncRelativeRetrySucceeded");
scope.Start();
try
{
var originalResponse = RestClient.PostAsyncRelativeRetrySucceeded(product, cancellationToken);
return CreatePostAsyncRelativeRetrySucceeded(originalResponse, () => RestClient.CreatePostAsyncRelativeRetrySucceededRequest(product));
return new LRORetrysPostAsyncRelativeRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePostAsyncRelativeRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LRORetrysDelete202Retry200Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LRORetrysDelete202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysDelete202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LRORetrysDeleteAsyncRelativeRetrySucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LRORetrysDeleteAsyncRelativeRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysDeleteAsyncRelativeRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Accepted. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LRORetrysDeleteProvisioning202Accepted200SucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LRORetrysDeleteProvisioning202Accepted200SucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysDeleteProvisioning202Accepted200SucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
public partial class LRORetrysPost202Retry200Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LRORetrysPost202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysPost202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LRORetrysPostAsyncRelativeRetrySucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LRORetrysPostAsyncRelativeRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysPostAsyncRelativeRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LRORetrysPut201CreatingSucceeded200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LRORetrysPut201CreatingSucceeded200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysPut201CreatingSucceeded200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LRORetrysPutAsyncRelativeRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LRORetrysPutAsyncRelativeRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LRORetrysPutAsyncRelativeRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

1674
test/TestServerProjects/lro/Generated/LROsClient.cs сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -6,11 +6,8 @@
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
@ -34,58 +31,17 @@ namespace lro
_pipeline = pipeline;
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Product> CreatePutAsyncRetrySucceeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "LROsCustomHeaderClient.StartPutAsyncRetrySucceeded", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
});
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Product>> StartPutAsyncRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LROsCustomHeaderPutAsyncRetrySucceededOperation> StartPutAsyncRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPutAsyncRetrySucceeded");
scope.Start();
try
{
var originalResponse = await RestClient.PutAsyncRetrySucceededAsync(product, cancellationToken).ConfigureAwait(false);
return CreatePutAsyncRetrySucceeded(originalResponse, () => RestClient.CreatePutAsyncRetrySucceededRequest(product));
return new LROsCustomHeaderPutAsyncRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePutAsyncRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -97,14 +53,14 @@ namespace lro
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Product> StartPutAsyncRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
public virtual LROsCustomHeaderPutAsyncRetrySucceededOperation StartPutAsyncRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPutAsyncRetrySucceeded");
scope.Start();
try
{
var originalResponse = RestClient.PutAsyncRetrySucceeded(product, cancellationToken);
return CreatePutAsyncRetrySucceeded(originalResponse, () => RestClient.CreatePutAsyncRetrySucceededRequest(product));
return new LROsCustomHeaderPutAsyncRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePutAsyncRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -113,58 +69,17 @@ namespace lro
}
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Product> CreatePut201CreatingSucceeded200(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Put, "LROsCustomHeaderClient.StartPut201CreatingSucceeded200", OperationFinalStateVia.Location, createOriginalHttpMessage,
(response, cancellationToken) =>
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
},
async (response, cancellationToken) =>
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
});
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Product>> StartPut201CreatingSucceeded200Async(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LROsCustomHeaderPut201CreatingSucceeded200Operation> StartPut201CreatingSucceeded200Async(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPut201CreatingSucceeded200");
scope.Start();
try
{
var originalResponse = await RestClient.Put201CreatingSucceeded200Async(product, cancellationToken).ConfigureAwait(false);
return CreatePut201CreatingSucceeded200(originalResponse, () => RestClient.CreatePut201CreatingSucceeded200Request(product));
return new LROsCustomHeaderPut201CreatingSucceeded200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePut201CreatingSucceeded200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -176,14 +91,14 @@ namespace lro
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Product> StartPut201CreatingSucceeded200(Product product = null, CancellationToken cancellationToken = default)
public virtual LROsCustomHeaderPut201CreatingSucceeded200Operation StartPut201CreatingSucceeded200(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPut201CreatingSucceeded200");
scope.Start();
try
{
var originalResponse = RestClient.Put201CreatingSucceeded200(product, cancellationToken);
return CreatePut201CreatingSucceeded200(originalResponse, () => RestClient.CreatePut201CreatingSucceeded200Request(product));
return new LROsCustomHeaderPut201CreatingSucceeded200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePut201CreatingSucceeded200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -192,34 +107,17 @@ namespace lro
}
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreatePost202Retry200(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "LROsCustomHeaderClient.StartPost202Retry200", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartPost202Retry200Async(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LROsCustomHeaderPost202Retry200Operation> StartPost202Retry200Async(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPost202Retry200");
scope.Start();
try
{
var originalResponse = await RestClient.Post202Retry200Async(product, cancellationToken).ConfigureAwait(false);
return CreatePost202Retry200(originalResponse, () => RestClient.CreatePost202Retry200Request(product));
return new LROsCustomHeaderPost202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePost202Retry200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -231,14 +129,14 @@ namespace lro
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartPost202Retry200(Product product = null, CancellationToken cancellationToken = default)
public virtual LROsCustomHeaderPost202Retry200Operation StartPost202Retry200(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPost202Retry200");
scope.Start();
try
{
var originalResponse = RestClient.Post202Retry200(product, cancellationToken);
return CreatePost202Retry200(originalResponse, () => RestClient.CreatePost202Retry200Request(product));
return new LROsCustomHeaderPost202Retry200Operation(_clientDiagnostics, _pipeline, RestClient.CreatePost202Retry200Request(product).Request, originalResponse);
}
catch (Exception e)
{
@ -247,34 +145,17 @@ namespace lro
}
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="originalResponse"> The original response from starting the operation. </param>
/// <param name="createOriginalHttpMessage"> Creates the HTTP message used for the original request. </param>
internal Operation<Response> CreatePostAsyncRetrySucceeded(Response originalResponse, Func<HttpMessage> createOriginalHttpMessage)
{
if (originalResponse == null)
{
throw new ArgumentNullException(nameof(originalResponse));
}
if (createOriginalHttpMessage == null)
{
throw new ArgumentNullException(nameof(createOriginalHttpMessage));
}
return ArmOperationHelpers.Create(_pipeline, _clientDiagnostics, originalResponse, RequestMethod.Post, "LROsCustomHeaderClient.StartPostAsyncRetrySucceeded", OperationFinalStateVia.Location, createOriginalHttpMessage);
}
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async ValueTask<Operation<Response>> StartPostAsyncRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
public virtual async ValueTask<LROsCustomHeaderPostAsyncRetrySucceededOperation> StartPostAsyncRetrySucceededAsync(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPostAsyncRetrySucceeded");
scope.Start();
try
{
var originalResponse = await RestClient.PostAsyncRetrySucceededAsync(product, cancellationToken).ConfigureAwait(false);
return CreatePostAsyncRetrySucceeded(originalResponse, () => RestClient.CreatePostAsyncRetrySucceededRequest(product));
return new LROsCustomHeaderPostAsyncRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePostAsyncRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{
@ -286,14 +167,14 @@ namespace lro
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
/// <param name="product"> Product to put. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Operation<Response> StartPostAsyncRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
public virtual LROsCustomHeaderPostAsyncRetrySucceededOperation StartPostAsyncRetrySucceeded(Product product = null, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("LROsCustomHeaderClient.StartPostAsyncRetrySucceeded");
scope.Start();
try
{
var originalResponse = RestClient.PostAsyncRetrySucceeded(product, cancellationToken);
return CreatePostAsyncRetrySucceeded(originalResponse, () => RestClient.CreatePostAsyncRetrySucceededRequest(product));
return new LROsCustomHeaderPostAsyncRetrySucceededOperation(_clientDiagnostics, _pipeline, RestClient.CreatePostAsyncRetrySucceededRequest(product).Request, originalResponse);
}
catch (Exception e)
{

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
public partial class LROsCustomHeaderPost202Retry200Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsCustomHeaderPost202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsCustomHeaderPost202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsCustomHeaderPostAsyncRetrySucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsCustomHeaderPostAsyncRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsCustomHeaderPostAsyncRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsCustomHeaderPut201CreatingSucceeded200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsCustomHeaderPut201CreatingSucceeded200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsCustomHeaderPut201CreatingSucceeded200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsCustomHeaderPutAsyncRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsCustomHeaderPutAsyncRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsCustomHeaderPutAsyncRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsDelete202NoRetry204Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsDelete202NoRetry204Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDelete202NoRetry204Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsDelete202Retry200Operation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsDelete202Retry200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsDelete202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDelete202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

62
test/TestServerProjects/lro/Generated/LROsDelete204SucceededOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete succeeds and returns right away. </summary>
public partial class LROsDelete204SucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDelete204SucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDelete204SucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns an Azure-AsyncOperation header in the initial request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. </summary>
public partial class LROsDeleteAsyncNoHeaderInRetryOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteAsyncNoHeaderInRetryOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteAsyncNoHeaderInRetryOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsDeleteAsyncNoRetrySucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteAsyncNoRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteAsyncNoRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsDeleteAsyncRetryFailedOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteAsyncRetryFailedOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteAsyncRetryFailedOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsDeleteAsyncRetrySucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteAsyncRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteAsyncRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsDeleteAsyncRetrycanceledOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteAsyncRetrycanceledOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteAsyncRetrycanceledOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a location header in the initial request. Subsequent calls to operation status do not contain location header. </summary>
public partial class LROsDeleteNoHeaderInRetryOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsDeleteNoHeaderInRetryOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteNoHeaderInRetryOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Accepted. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsDeleteProvisioning202Accepted200SucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsDeleteProvisioning202Accepted200SucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteProvisioning202Accepted200SucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Failed. </summary>
public partial class LROsDeleteProvisioning202DeletingFailed200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsDeleteProvisioning202DeletingFailed200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteProvisioning202DeletingFailed200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Canceled. </summary>
public partial class LROsDeleteProvisioning202Deletingcanceled200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsDeleteProvisioning202Deletingcanceled200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsDeleteProvisioning202Deletingcanceled200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPost200WithPayloadOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; header. Poll returns a 200 with a response body after success. </summary>
public partial class LROsPost200WithPayloadOperation : Operation<Sku>, IOperationSource<Sku>
{
private readonly ArmOperationHelpers<Sku> _operation;
internal LROsPost200WithPayloadOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Sku>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPost200WithPayloadOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Sku Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Sku IOperationSource<Sku>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
async ValueTask<Sku> IOperationSource<Sku>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPost202NoRetry204Operation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; header, 204 with noresponse body after success. </summary>
public partial class LROsPost202NoRetry204Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPost202NoRetry204Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPost202NoRetry204Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

62
test/TestServerProjects/lro/Generated/LROsPost202Retry200Operation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with &apos;Location&apos; and &apos;Retry-After&apos; headers, Polls return a 200 with a response body after success. </summary>
public partial class LROsPost202Retry200Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsPost202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPost202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPostAsyncNoRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPostAsyncNoRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostAsyncNoRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPostAsyncRetryFailedOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsPostAsyncRetryFailedOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostAsyncRetryFailedOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPostAsyncRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPostAsyncRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostAsyncRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPostAsyncRetrycanceledOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LROsPostAsyncRetrycanceledOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostAsyncRetrycanceledOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it&apos;s success. Should NOT poll Location to get the final object if you support initial Autorest behavior. </summary>
public partial class LROsPostDoubleHeadersFinalAzureHeaderGetDefaultOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPostDoubleHeadersFinalAzureHeaderGetDefaultOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostDoubleHeadersFinalAzureHeaderGetDefaultOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it&apos;s success. Should NOT poll Location to get the final object. </summary>
public partial class LROsPostDoubleHeadersFinalAzureHeaderGetOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPostDoubleHeadersFinalAzureHeaderGetOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.AzureAsyncOperation, "LROsPostDoubleHeadersFinalAzureHeaderGetOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it&apos;s success. Should poll Location to get the final object. </summary>
public partial class LROsPostDoubleHeadersFinalLocationGetOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPostDoubleHeadersFinalLocationGetOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPostDoubleHeadersFinalLocationGetOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Canceled. </summary>
public partial class LROsPut200Acceptedcanceled200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut200Acceptedcanceled200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut200Acceptedcanceled200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that does not contain ProvisioningState=Succeeded. </summary>
public partial class LROsPut200SucceededNoStateOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut200SucceededNoStateOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut200SucceededNoStateOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPut200SucceededOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Succeeded. </summary>
public partial class LROsPut200SucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut200SucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut200SucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Updating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsPut200UpdatingSucceeded204Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut200UpdatingSucceeded204Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut200UpdatingSucceeded204Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Created. Polls return this value until the last poll returns a 200 with ProvisioningState=Failed. </summary>
public partial class LROsPut201CreatingFailed200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut201CreatingFailed200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut201CreatingFailed200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=Creating. Polls return this value until the last poll returns a 200 with ProvisioningState=Succeeded. </summary>
public partial class LROsPut201CreatingSucceeded200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut201CreatingSucceeded200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut201CreatingSucceeded200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPut202Retry200Operation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 202 to the initial request, with a location header that points to a polling URL that returns a 200 and an entity that doesn&apos;t contains ProvisioningState. </summary>
public partial class LROsPut202Retry200Operation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPut202Retry200Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPut202Retry200Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 202 to the initial request with Azure-AsyncOperation header. Subsequent calls to operation status do not contain Azure-AsyncOperation header. </summary>
public partial class LROsPutAsyncNoHeaderInRetryOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutAsyncNoHeaderInRetryOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncNoHeaderInRetryOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPutAsyncNoRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutAsyncNoRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncNoRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPutAsyncNoRetrycanceledOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutAsyncNoRetrycanceledOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncNoRetrycanceledOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request with non resource. </summary>
public partial class LROsPutAsyncNonResourceOperation : Operation<Sku>, IOperationSource<Sku>
{
private readonly ArmOperationHelpers<Sku> _operation;
internal LROsPutAsyncNonResourceOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Sku>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncNonResourceOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Sku Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Sku IOperationSource<Sku>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
async ValueTask<Sku> IOperationSource<Sku>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPutAsyncRetryFailedOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutAsyncRetryFailedOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncRetryFailedOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=Creating. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LROsPutAsyncRetrySucceededOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutAsyncRetrySucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncRetrySucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request with sub resource. </summary>
public partial class LROsPutAsyncSubResourceOperation : Operation<SubProduct>, IOperationSource<SubProduct>
{
private readonly ArmOperationHelpers<SubProduct> _operation;
internal LROsPutAsyncSubResourceOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<SubProduct>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutAsyncSubResourceOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override SubProduct Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<SubProduct>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<SubProduct>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
SubProduct IOperationSource<SubProduct>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return SubProduct.DeserializeSubProduct(document.RootElement);
}
}
async ValueTask<SubProduct> IOperationSource<SubProduct>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return SubProduct.DeserializeSubProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPutNoHeaderInRetryOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request, service returns a 202 to the initial request with location header. Subsequent calls to operation status do not contain location header. </summary>
public partial class LROsPutNoHeaderInRetryOperation : Operation<Product>, IOperationSource<Product>
{
private readonly ArmOperationHelpers<Product> _operation;
internal LROsPutNoHeaderInRetryOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Product>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutNoHeaderInRetryOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Product Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Product>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Product IOperationSource<Product>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
async ValueTask<Product> IOperationSource<Product>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Product.DeserializeProduct(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPutNonResourceOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request with non resource. </summary>
public partial class LROsPutNonResourceOperation : Operation<Sku>, IOperationSource<Sku>
{
private readonly ArmOperationHelpers<Sku> _operation;
internal LROsPutNonResourceOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Sku>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutNonResourceOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Sku Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Sku>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Sku IOperationSource<Sku>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
async ValueTask<Sku> IOperationSource<Sku>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return Sku.DeserializeSku(document.RootElement);
}
}
}
}

80
test/TestServerProjects/lro/Generated/LROsPutSubResourceOperation.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using lro.Models;
namespace lro
{
/// <summary> Long running put request with sub resource. </summary>
public partial class LROsPutSubResourceOperation : Operation<SubProduct>, IOperationSource<SubProduct>
{
private readonly ArmOperationHelpers<SubProduct> _operation;
internal LROsPutSubResourceOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<SubProduct>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LROsPutSubResourceOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override SubProduct Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<SubProduct>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<SubProduct>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
SubProduct IOperationSource<SubProduct>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return SubProduct.DeserializeSubProduct(document.RootElement);
}
}
async ValueTask<SubProduct> IOperationSource<SubProduct>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
if (document.RootElement.ValueKind == JsonValueKind.Null)
{
return null;
}
else
{
return SubProduct.DeserializeSubProduct(document.RootElement);
}
}
}
}

893
test/TestServerProjects/lro/Generated/LrosaDsClient.cs сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 with a location header. </summary>
public partial class LrosaDsDelete202NonRetry400Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDelete202NonRetry400Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDelete202NonRetry400Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request receing a reponse with an invalid &apos;Location&apos; and &apos;Retry-After&apos; headers. </summary>
public partial class LrosaDsDelete202RetryInvalidHeaderOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDelete202RetryInvalidHeaderOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDelete202RetryInvalidHeaderOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 204 to the initial request, indicating success. </summary>
public partial class LrosaDsDelete204SucceededOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDelete204SucceededOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDelete204SucceededOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LrosaDsDeleteAsyncRelativeRetry400Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDeleteAsyncRelativeRetry400Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDeleteAsyncRelativeRetry400Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. The endpoint indicated in the Azure-AsyncOperation header is invalid. </summary>
public partial class LrosaDsDeleteAsyncRelativeRetryInvalidHeaderOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDeleteAsyncRelativeRetryInvalidHeaderOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDeleteAsyncRelativeRetryInvalidHeaderOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDeleteAsyncRelativeRetryInvalidJsonPollingOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LrosaDsDeleteAsyncRelativeRetryNoStatusOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDeleteAsyncRelativeRetryNoStatusOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDeleteAsyncRelativeRetryNoStatusOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running delete request, service returns a 400 with an error body. </summary>
public partial class LrosaDsDeleteNonRetry400Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsDeleteNonRetry400Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsDeleteNonRetry400Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, without a location header. </summary>
public partial class LrosaDsPost202NoLocationOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsPost202NoLocationOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsPost202NoLocationOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 with a location header. </summary>
public partial class LrosaDsPost202NonRetry400Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsPost202NonRetry400Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsPost202NonRetry400Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request, with invalid &apos;Location&apos; and &apos;Retry-After&apos; headers. </summary>
public partial class LrosaDsPost202RetryInvalidHeaderOperation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsPost202RetryInvalidHeaderOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsPost202RetryInvalidHeaderOperation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace lro
{
/// <summary> Long running post request, service returns a 202 to the initial request Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. </summary>
public partial class LrosaDsPostAsyncRelativeRetry400Operation : Operation<Response>, IOperationSource<Response>
{
private readonly ArmOperationHelpers<Response> _operation;
internal LrosaDsPostAsyncRelativeRetry400Operation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new ArmOperationHelpers<Response>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "LrosaDsPostAsyncRelativeRetry400Operation");
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override Response Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<Response>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
Response IOperationSource<Response>.CreateResult(Response response, CancellationToken cancellationToken)
{
return response;
}
async ValueTask<Response> IOperationSource<Response>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
return await new ValueTask<Response>(response);
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше