public virtual Pageable <OSFamily> GetAll(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            Page <OSFamily> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("OSFamilyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _cloudServiceOperatingSystemsRestClient.ListOSFamilies(Id.SubscriptionId, location, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new OSFamily(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <OSFamily> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("OSFamilyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _cloudServiceOperatingSystemsRestClient.ListOSFamiliesNextPage(nextLink, Id.SubscriptionId, location, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new OSFamily(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }
Esempio n. 2
0
        public virtual Pageable <CloudServiceOSFamilyResource> GetAll(CancellationToken cancellationToken = default)
        {
            Page <CloudServiceOSFamilyResource> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _cloudServiceOSFamilyCloudServiceOperatingSystemsClientDiagnostics.CreateScope("CloudServiceOSFamilyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _cloudServiceOSFamilyCloudServiceOperatingSystemsRestClient.ListOSFamilies(Id.SubscriptionId, new AzureLocation(_location), cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new CloudServiceOSFamilyResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <CloudServiceOSFamilyResource> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _cloudServiceOSFamilyCloudServiceOperatingSystemsClientDiagnostics.CreateScope("CloudServiceOSFamilyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _cloudServiceOSFamilyCloudServiceOperatingSystemsRestClient.ListOSFamiliesNextPage(nextLink, Id.SubscriptionId, new AzureLocation(_location), cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new CloudServiceOSFamilyResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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