Пример #1
0
        public virtual Pageable <CsmUsageQuota> GetUsages(string filter = null, CancellationToken cancellationToken = default)
        {
            Page <CsmUsageQuota> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlan.GetUsages");
                scope.Start();
                try
                {
                    var response = _appServicePlanRestClient.ListUsages(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <CsmUsageQuota> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlan.GetUsages");
                scope.Start();
                try
                {
                    var response = _appServicePlanRestClient.ListUsagesNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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