Example #1
0
        public virtual Pageable <AppDeploymentResource> GetAll(IEnumerable <string> version = null, CancellationToken cancellationToken = default)
        {
            Page <AppDeploymentResource> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _appDeploymentResourceDeploymentsClientDiagnostics.CreateScope("AppDeploymentResourceCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _appDeploymentResourceDeploymentsRestClient.List(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, version, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new AppDeploymentResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <AppDeploymentResource> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _appDeploymentResourceDeploymentsClientDiagnostics.CreateScope("AppDeploymentResourceCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _appDeploymentResourceDeploymentsRestClient.ListNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, version, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new AppDeploymentResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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