Exemplo n.º 1
0
        public virtual Pageable <DiskPool> GetAll(CancellationToken cancellationToken = default)
        {
            Page <DiskPool> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _diskPoolClientDiagnostics.CreateScope("DiskPoolCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _diskPoolRestClient.ListByResourceGroup(Id.SubscriptionId, Id.ResourceGroupName, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new DiskPool(ArmClient, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <DiskPool> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _diskPoolClientDiagnostics.CreateScope("DiskPoolCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _diskPoolRestClient.ListByResourceGroupNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new DiskPool(ArmClient, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }