| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Network.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Network |
| | 18 | | { |
| | 19 | | /// <summary> Creates a Bastion Shareable Links for all the VMs specified in the request. </summary> |
| | 20 | | public partial class ServicePutBastionShareableLinkOperation : Operation<AsyncPageable<BastionShareableLink>>, IOper |
| | 21 | | { |
| | 22 | | private readonly ArmOperationHelpers<AsyncPageable<BastionShareableLink>> _operation; |
| | 23 | | private readonly Func<string, Task<Response>> _nextPageFunc; |
| 0 | 24 | | internal ServicePutBastionShareableLinkOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Req |
| | 25 | | { |
| 0 | 26 | | _operation = new ArmOperationHelpers<AsyncPageable<BastionShareableLink>>(this, clientDiagnostics, pipeline, |
| 0 | 27 | | _nextPageFunc = nextPageFunc; |
| 0 | 28 | | } |
| | 29 | | /// <inheritdoc /> |
| 0 | 30 | | public override string Id => _operation.Id; |
| | 31 | |
|
| | 32 | | /// <inheritdoc /> |
| 0 | 33 | | public override AsyncPageable<BastionShareableLink> Value => _operation.Value; |
| | 34 | |
|
| | 35 | | /// <inheritdoc /> |
| 0 | 36 | | public override bool HasCompleted => _operation.HasCompleted; |
| | 37 | |
|
| | 38 | | /// <inheritdoc /> |
| 0 | 39 | | public override bool HasValue => _operation.HasValue; |
| | 40 | |
|
| | 41 | | /// <inheritdoc /> |
| 0 | 42 | | public override Response GetRawResponse() => _operation.GetRawResponse(); |
| | 43 | |
|
| | 44 | | /// <inheritdoc /> |
| 0 | 45 | | public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus( |
| | 46 | |
|
| | 47 | | /// <inheritdoc /> |
| 0 | 48 | | public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operati |
| | 49 | |
|
| | 50 | | /// <inheritdoc /> |
| 0 | 51 | | public override ValueTask<Response<AsyncPageable<BastionShareableLink>>> WaitForCompletionAsync(CancellationToke |
| | 52 | |
|
| | 53 | | /// <inheritdoc /> |
| 0 | 54 | | public override ValueTask<Response<AsyncPageable<BastionShareableLink>>> WaitForCompletionAsync(TimeSpan polling |
| | 55 | |
|
| | 56 | | AsyncPageable<BastionShareableLink> IOperationSource<AsyncPageable<BastionShareableLink>>.CreateResult(Response |
| | 57 | | { |
| | 58 | | BastionShareableLinkListResult firstPageResult; |
| 0 | 59 | | using var document = JsonDocument.Parse(response.ContentStream); |
| 0 | 60 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| 0 | 62 | | firstPageResult = null; |
| | 63 | | } |
| | 64 | | else |
| | 65 | | { |
| 0 | 66 | | firstPageResult = BastionShareableLinkListResult.DeserializeBastionShareableLinkListResult(document.Root |
| | 67 | | } |
| 0 | 68 | | Page<BastionShareableLink> firstPage = Page.FromValues(firstPageResult.Value, firstPageResult.NextLink, resp |
| | 69 | |
|
| 0 | 70 | | return PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(firstPage), (nextLink, _) => GetNextPage(n |
| 0 | 71 | | } |
| | 72 | |
|
| | 73 | | async ValueTask<AsyncPageable<BastionShareableLink>> IOperationSource<AsyncPageable<BastionShareableLink>>.Creat |
| | 74 | | { |
| | 75 | | BastionShareableLinkListResult firstPageResult; |
| 0 | 76 | | using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).Confi |
| 0 | 77 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 78 | | { |
| 0 | 79 | | firstPageResult = null; |
| | 80 | | } |
| | 81 | | else |
| | 82 | | { |
| 0 | 83 | | firstPageResult = BastionShareableLinkListResult.DeserializeBastionShareableLinkListResult(document.Root |
| | 84 | | } |
| 0 | 85 | | Page<BastionShareableLink> firstPage = Page.FromValues(firstPageResult.Value, firstPageResult.NextLink, resp |
| | 86 | |
|
| 0 | 87 | | return PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(firstPage), (nextLink, _) => GetNextPage(n |
| 0 | 88 | | } |
| | 89 | |
|
| | 90 | | private async Task<Page<BastionShareableLink>> GetNextPage(string nextLink, CancellationToken cancellationToken) |
| | 91 | | { |
| 0 | 92 | | Response response = await _nextPageFunc(nextLink).ConfigureAwait(false); |
| | 93 | | BastionShareableLinkListResult nextPageResult; |
| 0 | 94 | | using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).Confi |
| 0 | 95 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| 0 | 97 | | nextPageResult = null; |
| | 98 | | } |
| | 99 | | else |
| | 100 | | { |
| 0 | 101 | | nextPageResult = BastionShareableLinkListResult.DeserializeBastionShareableLinkListResult(document.RootE |
| | 102 | | } |
| 0 | 103 | | return Page.FromValues(nextPageResult.Value, nextPageResult.NextLink, response); |
| 0 | 104 | | } |
| | 105 | | } |
| | 106 | | } |