示例#1
0
        public virtual Pageable <OSVersion> GetAll(string location, CancellationToken cancellationToken = default)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

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

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

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }
示例#2
0
        public virtual Pageable <CloudServiceOSVersionResource> GetAll(CancellationToken cancellationToken = default)
        {
            Page <CloudServiceOSVersionResource> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _cloudServiceOSVersionCloudServiceOperatingSystemsClientDiagnostics.CreateScope("CloudServiceOSVersionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _cloudServiceOSVersionCloudServiceOperatingSystemsRestClient.ListOSVersions(Id.SubscriptionId, new AzureLocation(_location), cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new CloudServiceOSVersionResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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

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