public virtual Pageable <VaultResource> GetAll(int?top = null, CancellationToken cancellationToken = default) { Page <VaultResource> FirstPageFunc(int?pageSizeHint) { using var scope = _vaultClientDiagnostics.CreateScope("VaultCollection.GetAll"); scope.Start(); try { var response = _vaultRestClient.ListByResourceGroup(Id.SubscriptionId, Id.ResourceGroupName, top, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new VaultResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <VaultResource> NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _vaultClientDiagnostics.CreateScope("VaultCollection.GetAll"); scope.Start(); try { var response = _vaultRestClient.ListByResourceGroupNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, top, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new VaultResource(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }