-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Expand file tree
/
Copy pathManagedClustersGetFaultSimulationAsyncCollectionResultOfT.cs
More file actions
87 lines (80 loc) · 4.49 KB
/
ManagedClustersGetFaultSimulationAsyncCollectionResultOfT.cs
File metadata and controls
87 lines (80 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.ResourceManager.ServiceFabricManagedClusters.Models;
namespace Azure.ResourceManager.ServiceFabricManagedClusters
{
internal partial class ManagedClustersGetFaultSimulationAsyncCollectionResultOfT : AsyncPageable<FaultSimulation>
{
private readonly ManagedClusters _client;
private readonly string _subscriptionId;
private readonly string _resourceGroupName;
private readonly string _clusterName;
private readonly RequestContext _context;
private readonly string _diagnosticScope;
/// <summary> Initializes a new instance of ManagedClustersGetFaultSimulationAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. </summary>
/// <param name="client"> The ManagedClusters client used to send requests. </param>
/// <param name="subscriptionId"> The ID of the target subscription. The value must be an UUID. </param>
/// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
/// <param name="clusterName"> The name of the cluster resource. </param>
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
/// <param name="diagnosticScope"> The diagnostic scope name. </param>
public ManagedClustersGetFaultSimulationAsyncCollectionResultOfT(ManagedClusters client, string subscriptionId, string resourceGroupName, string clusterName, RequestContext context, string diagnosticScope) : base(context?.CancellationToken ?? default)
{
_client = client;
_subscriptionId = subscriptionId;
_resourceGroupName = resourceGroupName;
_clusterName = clusterName;
_context = context;
_diagnosticScope = diagnosticScope;
}
/// <summary> Gets the pages of ManagedClustersGetFaultSimulationAsyncCollectionResultOfT as an enumerable collection. </summary>
/// <param name="continuationToken"> A continuation token indicating where to resume paging. </param>
/// <param name="pageSizeHint"> The number of items per page. </param>
/// <returns> The pages of ManagedClustersGetFaultSimulationAsyncCollectionResultOfT as an enumerable collection. </returns>
public override async IAsyncEnumerable<Page<FaultSimulation>> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
while (true)
{
Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
if (response is null)
{
yield break;
}
FaultSimulationListResult result = FaultSimulationListResult.FromResponse(response);
yield return Page<FaultSimulation>.FromValues((IReadOnlyList<FaultSimulation>)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response);
nextPage = result.NextLink;
if (nextPage == null)
{
yield break;
}
}
}
/// <summary> Get next page. </summary>
/// <param name="pageSizeHint"> The number of items per page. </param>
/// <param name="nextLink"> The next link to use for the next page of results. </param>
private async ValueTask<Response> GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
{
HttpMessage message = nextLink != null ? _client.CreateNextGetFaultSimulationRequest(nextLink, _subscriptionId, _resourceGroupName, _clusterName, _context) : _client.CreateGetFaultSimulationRequest(_subscriptionId, _resourceGroupName, _clusterName, _context);
using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope(_diagnosticScope);
scope.Start();
try
{
return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
}
}