Beispiel #1
0
        public virtual Pageable <SubscriptionLongTermRetentionBackup> GetAll(string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, bool?onlyLatestPerDatabase = null, DatabaseState?databaseState = null, CancellationToken cancellationToken = default)
        {
            if (locationName == null)
            {
                throw new ArgumentNullException(nameof(locationName));
            }
            if (longTermRetentionServerName == null)
            {
                throw new ArgumentNullException(nameof(longTermRetentionServerName));
            }
            if (longTermRetentionDatabaseName == null)
            {
                throw new ArgumentNullException(nameof(longTermRetentionDatabaseName));
            }

            Page <SubscriptionLongTermRetentionBackup> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("SubscriptionLongTermRetentionBackupCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _longTermRetentionBackupsRestClient.ListByDatabase(Id.SubscriptionId, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new SubscriptionLongTermRetentionBackup(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <SubscriptionLongTermRetentionBackup> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("SubscriptionLongTermRetentionBackupCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _longTermRetentionBackupsRestClient.ListByDatabaseNextPage(nextLink, Id.SubscriptionId, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new SubscriptionLongTermRetentionBackup(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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