public virtual AsyncPageable <ProductFamily> GetProductFamiliesAsync(ProductFamiliesRequest productFamiliesRequest, string expand = null, string skipToken = null, CancellationToken cancellationToken = default)
        {
            if (productFamiliesRequest == null)
            {
                throw new ArgumentNullException(nameof(productFamiliesRequest));
            }

            async Task <Page <ProductFamily> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetProductFamilies");
                scope.Start();
                try
                {
                    var response = await DefaultRestClient.ListProductFamiliesAsync(Id.SubscriptionId, productFamiliesRequest, expand, skipToken, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <ProductFamily> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetProductFamilies");
                scope.Start();
                try
                {
                    var response = await DefaultRestClient.ListProductFamiliesNextPageAsync(nextLink, Id.SubscriptionId, productFamiliesRequest, expand, skipToken, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Пример #2
0
        public virtual Pageable <ProductFamily> GetProductFamilies(ProductFamiliesRequest productFamiliesRequest, string expand = null, string skipToken = null, CancellationToken cancellationToken = default)
        {
            Page <ProductFamily> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetProductFamilies");
                scope.Start();
                try
                {
                    var response = DefaultRestClient.ListProductFamilies(Id.SubscriptionId, productFamiliesRequest, expand, skipToken, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <ProductFamily> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetProductFamilies");
                scope.Start();
                try
                {
                    var response = DefaultRestClient.ListProductFamiliesNextPage(nextLink, Id.SubscriptionId, productFamiliesRequest, expand, skipToken, 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));
        }
Пример #3
0
 public static Pageable <ProductFamily> GetProductFamilies(this Subscription subscription, ProductFamiliesRequest productFamiliesRequest, string expand = null, string skipToken = null, CancellationToken cancellationToken = default)
 {
     return(GetExtensionClient(subscription).GetProductFamilies(productFamiliesRequest, expand, skipToken, cancellationToken));
 }
        public static Pageable <ProductFamily> GetProductFamilies(this SubscriptionResource subscriptionResource, ProductFamiliesRequest productFamiliesRequest, string expand = null, string skipToken = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(productFamiliesRequest, nameof(productFamiliesRequest));

            return(GetExtensionClient(subscriptionResource).GetProductFamilies(productFamiliesRequest, expand, skipToken, cancellationToken));
        }