Merge pull request #708 from MiYanni/lro-fix-CustomHeaderPostAsyncSucceded
LRO test fix and new Paging test
This commit is contained in:
Коммит
7a2f6d5d48
|
@ -9,9 +9,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"@microsoft.azure/autorest.testserver": {
|
||||
"version": "2.10.29",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft.azure/autorest.testserver/-/autorest.testserver-2.10.29.tgz",
|
||||
"integrity": "sha512-VHbbPZ7K+18nNtu+MqVwYTm5tQA+sd8y/dKvDlNPLLlnRBLjbzWzC3UK8JbU/G0RtU6K7QNoSu9n4BnJnOB+BQ==",
|
||||
"version": "2.10.31",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft.azure/autorest.testserver/-/autorest.testserver-2.10.31.tgz",
|
||||
"integrity": "sha512-PCkvkLvx3AzPKtvvjyaxZiILTE6Xqk2bkL1YjoVCjfT6nbzbX5K4/6EhqicIdKTNssHg6NZSsjPgdo+sM/jO7w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"azure-storage": "^2.4.0",
|
||||
|
@ -95,9 +95,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.12.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz",
|
||||
"integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==",
|
||||
"version": "6.12.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz",
|
||||
"integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
|
@ -1112,9 +1112,9 @@
|
|||
}
|
||||
},
|
||||
"is-promise": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
|
||||
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
||||
"integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"is-regex": {
|
||||
|
@ -1273,18 +1273,18 @@
|
|||
"dev": true
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.43.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
|
||||
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==",
|
||||
"version": "1.44.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
||||
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
|
||||
"dev": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.26",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
|
||||
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
|
||||
"version": "2.1.27",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
|
||||
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.43.0"
|
||||
"mime-db": "1.44.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
|
@ -1699,9 +1699,9 @@
|
|||
}
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.16.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.0.tgz",
|
||||
"integrity": "sha512-LarL/PIKJvc09k1jaeT4kQb/8/7P+qV4qSnN2K80AES+OHdfZELAKVOBjxsvtToT/uLOfFbvYvKfZmV8cee7nA==",
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
|
||||
"integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
|
@ -2227,9 +2227,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"ws": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
|
||||
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
|
||||
"version": "7.2.5",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.5.tgz",
|
||||
"integrity": "sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA==",
|
||||
"dev": true
|
||||
},
|
||||
"xml2js": {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "package.json intended for in-repo use only, package.json used for publishing is located in src/AutoRest.CSharp.V3/package.json",
|
||||
"devDependencies": {
|
||||
"@autorest/autorest": "https://github.com/Azure/autorest/releases/download/autorest-3.0.6222/autorest-autorest-3.0.6222.tgz",
|
||||
"@microsoft.azure/autorest.testserver": "^2.10.29"
|
||||
"@microsoft.azure/autorest.testserver": "^2.10.31"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace AutoRest.TestServer.Tests
|
|||
public LroTest(TestServerVersion version) : base(version, "lros") { }
|
||||
|
||||
[Test]
|
||||
[Ignore("https://github.com/Azure/autorest.csharp/issues/683")]
|
||||
public Task CustomHeaderPostAsyncSucceded() => TestStatus(async (host, pipeline) =>
|
||||
{
|
||||
using var _ = ClientRequestIdScope.Start("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0");
|
||||
|
@ -30,7 +29,6 @@ namespace AutoRest.TestServer.Tests
|
|||
});
|
||||
|
||||
[Test]
|
||||
[Ignore("https://github.com/Azure/autorest.csharp/issues/683")]
|
||||
public Task CustomHeaderPostAsyncSucceded_Sync() => TestStatus((host, pipeline) =>
|
||||
{
|
||||
using var _ = ClientRequestIdScope.Start("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0");
|
||||
|
|
|
@ -256,6 +256,65 @@ namespace AutoRest.TestServer.Tests
|
|||
Assert.AreEqual(10, id);
|
||||
}, true);
|
||||
|
||||
[Test]
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "Refused connection.")]
|
||||
public Task PagingMultipleWithQueryParameters() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = 100;
|
||||
var id = 1;
|
||||
var product = "Product";
|
||||
var linkPart = "/paging/multiple/nextOperationWithQueryParams";
|
||||
var result = await new PagingClient(ClientDiagnostics, pipeline, host).RestClient.GetWithQueryParamsAsync(value);
|
||||
var resultPage = Page.FromValues(result.Value.Values, result.Value.NextLink, result.GetRawResponse());
|
||||
while (resultPage.ContinuationToken != null)
|
||||
{
|
||||
Assert.AreEqual(id++, resultPage.Values.First().Properties.Id);
|
||||
Assert.AreEqual(product, resultPage.Values.First().Properties.Name);
|
||||
StringAssert.EndsWith(linkPart, resultPage.ContinuationToken);
|
||||
result = await new PagingClient(ClientDiagnostics, pipeline, host).RestClient.NextOperationWithQueryParamsAsync();
|
||||
resultPage = Page.FromValues(result.Value.Values, result.Value.NextLink, result.GetRawResponse());
|
||||
}
|
||||
Assert.AreEqual(2, id);
|
||||
Assert.AreEqual(id, resultPage.Values.First().Properties.Id);
|
||||
Assert.AreEqual(product, resultPage.Values.First().Properties.Name);
|
||||
|
||||
id = 1;
|
||||
var pageableAsync = new PagingClient(ClientDiagnostics, pipeline, host).GetWithQueryParamsAsync(value);
|
||||
await foreach (var page in pageableAsync.AsPages())
|
||||
{
|
||||
Assert.AreEqual(id, page.Values.First().Properties.Id);
|
||||
Assert.AreEqual(product, page.Values.First().Properties.Name);
|
||||
if (id == 2)
|
||||
{
|
||||
Assert.IsNull(page.ContinuationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringAssert.EndsWith(linkPart, page.ContinuationToken);
|
||||
id++;
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(2, id);
|
||||
|
||||
id = 1;
|
||||
var pageable = new PagingClient(ClientDiagnostics, pipeline, host).GetWithQueryParams(value);
|
||||
foreach (var page in pageable.AsPages())
|
||||
{
|
||||
Assert.AreEqual(id, page.Values.First().Properties.Id);
|
||||
Assert.AreEqual(product, page.Values.First().Properties.Name);
|
||||
if (id == 2)
|
||||
{
|
||||
Assert.IsNull(page.ContinuationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringAssert.EndsWith(linkPart, page.ContinuationToken);
|
||||
id++;
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(2, id);
|
||||
}, true);
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleFailure() => Test(async (host, pipeline) =>
|
||||
{
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -174,6 +174,76 @@ namespace paging
|
|||
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
|
||||
}
|
||||
|
||||
/// <summary> A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. </summary>
|
||||
/// <param name="requiredQueryParameter"> A required integer query parameter. Put in value '100' to pass test. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual AsyncPageable<Product> GetWithQueryParamsAsync(int requiredQueryParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
async Task<Page<Product>> FirstPageFunc(int? pageSizeHint)
|
||||
{
|
||||
var response = await RestClient.GetWithQueryParamsAsync(requiredQueryParameter, cancellationToken).ConfigureAwait(false);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
async Task<Page<Product>> NextPageFunc(string nextLink, int? pageSizeHint)
|
||||
{
|
||||
var response = await RestClient.NextOperationWithQueryParamsAsync(cancellationToken).ConfigureAwait(false);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
|
||||
}
|
||||
|
||||
/// <summary> A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. </summary>
|
||||
/// <param name="requiredQueryParameter"> A required integer query parameter. Put in value '100' to pass test. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Pageable<Product> GetWithQueryParams(int requiredQueryParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Page<Product> FirstPageFunc(int? pageSizeHint)
|
||||
{
|
||||
var response = RestClient.GetWithQueryParams(requiredQueryParameter, cancellationToken);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
Page<Product> NextPageFunc(string nextLink, int? pageSizeHint)
|
||||
{
|
||||
var response = RestClient.NextOperationWithQueryParams(cancellationToken);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual AsyncPageable<Product> NextOperationWithQueryParamsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
async Task<Page<Product>> FirstPageFunc(int? pageSizeHint)
|
||||
{
|
||||
var response = await RestClient.NextOperationWithQueryParamsAsync(cancellationToken).ConfigureAwait(false);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
async Task<Page<Product>> NextPageFunc(string nextLink, int? pageSizeHint)
|
||||
{
|
||||
var response = await RestClient.NextOperationWithQueryParamsNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Pageable<Product> NextOperationWithQueryParams(CancellationToken cancellationToken = default)
|
||||
{
|
||||
Page<Product> FirstPageFunc(int? pageSizeHint)
|
||||
{
|
||||
var response = RestClient.NextOperationWithQueryParams(cancellationToken);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
Page<Product> NextPageFunc(string nextLink, int? pageSizeHint)
|
||||
{
|
||||
var response = RestClient.NextOperationWithQueryParamsNextPage(nextLink, cancellationToken);
|
||||
return Page.FromValues(response.Value.Values, response.Value.NextLink, response.GetRawResponse());
|
||||
}
|
||||
return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
|
||||
}
|
||||
|
||||
/// <summary> A paging operation that includes a nextLink in odata format that has 10 pages. </summary>
|
||||
/// <param name="clientRequestId"> The String to use. </param>
|
||||
/// <param name="pagingGetOdataMultiplePagesOptions"> Parameter group. </param>
|
||||
|
|
|
@ -395,6 +395,183 @@ namespace paging
|
|||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetWithQueryParamsRequest(int requiredQueryParameter)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/paging/multiple/getWithQueryParams", false);
|
||||
uri.AppendQuery("requiredQueryParameter", requiredQueryParameter, true);
|
||||
uri.AppendQuery("queryConstant", true, true);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. </summary>
|
||||
/// <param name="requiredQueryParameter"> A required integer query parameter. Put in value '100' to pass test. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<ProductResult>> GetWithQueryParamsAsync(int requiredQueryParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.GetWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetWithQueryParamsRequest(requiredQueryParameter);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> A paging operation that includes a next operation. It has a different query parameter from it's next operation nextOperationWithQueryParams. Returns a ProductResult. </summary>
|
||||
/// <param name="requiredQueryParameter"> A required integer query parameter. Put in value '100' to pass test. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<ProductResult> GetWithQueryParams(int requiredQueryParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.GetWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetWithQueryParamsRequest(requiredQueryParameter);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateNextOperationWithQueryParamsRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/paging/multiple/nextOperationWithQueryParams", false);
|
||||
uri.AppendQuery("queryConstant", true, true);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<ProductResult>> NextOperationWithQueryParamsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateNextOperationWithQueryParamsRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<ProductResult> NextOperationWithQueryParams(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateNextOperationWithQueryParamsRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetOdataMultiplePagesRequest(string clientRequestId, PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
|
@ -1970,6 +2147,104 @@ namespace paging
|
|||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateNextOperationWithQueryParamsNextPageRequest(string nextLink)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendRawNextLink(nextLink, false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="nextLink"> The URL to the next page of results. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<ProductResult>> NextOperationWithQueryParamsNextPageAsync(string nextLink, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (nextLink == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(nextLink));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateNextOperationWithQueryParamsNextPageRequest(nextLink);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Next operation for getWithQueryParams. Pass in next=True to pass test. Returns a ProductResult. </summary>
|
||||
/// <param name="nextLink"> The URL to the next page of results. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<ProductResult> NextOperationWithQueryParamsNextPage(string nextLink, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (nextLink == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(nextLink));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("PagingClient.NextOperationWithQueryParams");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateNextOperationWithQueryParamsNextPageRequest(nextLink);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
ProductResult value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ProductResult.DeserializeProductResult(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetOdataMultiplePagesNextPageRequest(string nextLink, string clientRequestId, PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
|
|
Загрузка…
Ссылка в новой задаче