Exemple #1
0
        public virtual Pageable <VaultKeyVersion> GetAll(CancellationToken cancellationToken = default)
        {
            Page <VaultKeyVersion> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _vaultKeyVersionKeysClientDiagnostics.CreateScope("VaultKeyVersionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _vaultKeyVersionKeysRestClient.ListVersions(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new VaultKeyVersion(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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

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