public virtual IEnumerable <Response <SecretBase> > GetAllVersions(string name, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } Uri firstPageUri = new Uri(_vaultUri, $"{SecretsPath}{name}/versions?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new SecretBase(), cancellationToken))); }
public virtual IEnumerable <Response <KeyBase> > GetKeyVersions(string name, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException($"{nameof(name)} can't be empty or null"); } Uri firstPageUri = CreateFirstPageUri($"{KeysPath}{name}/versions"); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new KeyBase(), cancellationToken))); }
/// <summary> /// List all versions of the specified secret. /// </summary> /// <remarks> /// The full secret identifier and attributes are provided in the response. No /// values are returned for the secrets. This operations requires the /// secrets/list permission. /// </remarks> /// <param name="name">The name of the secret.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual IEnumerable <Response <SecretBase> > GetSecretVersions(string name, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException($"{nameof(name)} must not be null or empty", nameof(name)); } Uri firstPageUri = new Uri(_vaultUri, $"{SecretsPath}{name}/versions?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new SecretBase(), "Azure.Security.KeyVault.Secrets.SecretClient.GetSecretVersions", cancellationToken))); }
public virtual Pageable <int> GetPageableValidScopes() { return(PageResponseEnumerator.CreateEnumerable(s => { CreateAndFireScope(nameof(GetPageableValidScopes)); if (s == null) { return Page <int> .FromValues(new[] { 1, 2, 3 }, "1", new MockResponse(200)); } return Page <int> .FromValues(new[] { 4, 5, 6 }, null, new MockResponse(200)); })); }
public virtual AsyncPageable <int> GetPageableNoPageableScopesAsync() { CreateAndFireScope(nameof(GetPageableNoPageableScopesAsync)); return(PageResponseEnumerator.CreateAsyncEnumerable(s => { if (s == null) { return Task.FromResult(Page <int> .FromValues(new[] { 1, 2, 3 }, "1", new MockResponse(200))); } return Task.FromResult(Page <int> .FromValues(new[] { 4, 5, 6 }, null, new MockResponse(200))); })); }
public void EnumerateSyncPages() { var enumerable = PageResponseEnumerator.CreateEnumerable(s => s == null ? Page <int> .FromValues(new[] { 1, 2, 3 }, "next", new MockResponse(200)): Page <int> .FromValues(new[] { 4, 5, 6 }, null, new MockResponse(200))); Assert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, enumerable.ToArray()); int pageCount = 0; foreach (var page in enumerable.AsPages()) { Assert.AreEqual(3, page.Values.Count); pageCount++; } Assert.AreEqual(2, pageCount); }
public async Task EnumerateAsyncPages() { var enumerable = PageResponseEnumerator.CreateAsyncEnumerable(async s => { await Task.CompletedTask; return(s == null ? Page <int> .FromValues(new[] { 1, 2, 3 }, "next", new MockResponse(200)) : Page <int> .FromValues(new[] { 4, 5, 6 }, null, new MockResponse(200))); }); Assert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, await enumerable.ToEnumerableAsync()); int pageCount = 0; await foreach (var page in enumerable.AsPages()) { Assert.AreEqual(3, page.Values.Count); pageCount++; } Assert.AreEqual(2, pageCount); }
public async Task GetCursor() { // Arrange string shardPath = "shardPath"; long chunkIndex = 2; long blockOffset = 100; long eventIndex = 200; ShardCursor shardCursor = new ShardCursor( chunkIndex, blockOffset, eventIndex); Mock <BlobContainerClient> containerClient = new Mock <BlobContainerClient>(MockBehavior.Strict); Mock <ChunkFactory> chunkFactory = new Mock <ChunkFactory>(MockBehavior.Strict); Mock <Chunk> chunk = new Mock <Chunk>(MockBehavior.Strict); if (IsAsync) { AsyncPageable <BlobHierarchyItem> asyncPageable = PageResponseEnumerator.CreateAsyncEnumerable(GetChunkPagesFuncAsync); containerClient.Setup(r => r.GetBlobsByHierarchyAsync(
public virtual IAsyncEnumerable <Response <DeletedKey> > GetDeletedKeysAsync(CancellationToken cancellationToken = default) { Uri firstPageUri = CreateFirstPageUri(DeletedKeysPath); return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => GetPageAsync(firstPageUri, nextLink, () => new DeletedKey(), cancellationToken))); }
/// <summary> /// List secrets in a specified key vault. /// </summary> /// <remarks> /// The Get Secrets operation is applicable to the entire vault. However, only /// the base secret identifier and its attributes are provided in the response. /// Individual secret versions are not listed in the response. This operation /// requires the secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual IAsyncEnumerable <Response <SecretBase> > GetSecretsAsync(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(_vaultUri, SecretsPath + $"?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => GetPageAsync(firstPageUri, nextLink, () => new SecretBase(), cancellationToken))); }
public virtual IEnumerable <Response <KeyBase> > GetKeys(CancellationToken cancellationToken = default) { Uri firstPageUri = CreateFirstPageUri(KeysPath); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new KeyBase(), cancellationToken))); }
/// <summary> Get provider status. </summary> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual Pageable <ProviderStatus> GetProviderStatus(CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _providers.GetStatus() : _providers.GetStatusNextPage(cont)))); }
/// <summary> Get quota status. </summary> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual Pageable <QuantumJobQuota> GetQuotas(CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _quotas.List() : _quotas.ListNextPage(cont)))); }
/// <summary> Get provider status. </summary> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual AsyncPageable <ProviderStatus> GetProviderStatusAsync(CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _providers.GetStatusAsync().ConfigureAwait(false) : await _providers.GetStatusNextPageAsync(cont).ConfigureAwait(false)))); }
/// <summary> /// Retrieves the different revisions of specific <see cref="ConfigurationSetting"/> that satisfies the options of the <see cref="SettingSelector"/> /// </summary> /// <param name="selector">Set of options for selecting <see cref="ConfigurationSetting"/> from the configuration store.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual AsyncCollection <ConfigurationSetting> GetRevisionsAsync(SettingSelector selector, CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => GetRevisionsPageAsync(selector, nextLink, cancellationToken))); }
/// <summary> /// Retrieves the different revisions of specific <see cref="ConfigurationSetting"/> that satisfies the options of the <see cref="SettingSelector"/> /// </summary> /// <param name="selector">Set of options for selecting <see cref="ConfigurationSetting"/> from the configuration store.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual IEnumerable <Response <ConfigurationSetting> > GetRevisions(SettingSelector selector, CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateEnumerable(nextLink => GetRevisionsPage(selector, nextLink, cancellationToken))); }
/// <summary> /// Lists deleted secrets for the specified vault. /// </summary> /// <remarks> /// The Get Deleted Secrets operation returns the secrets that have been /// deleted for a vault enabled for soft-delete. This operation requires the /// secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual Pageable <DeletedSecret> GetDeletedSecrets(CancellationToken cancellationToken = default) { Uri firstPageUri = _pipeline.CreateFirstPageUri(DeletedSecretsPath); return(PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => new DeletedSecret(), "SecretClient.GetDeletedSecrets", cancellationToken))); }
/// <summary> /// List secrets in a specified key vault. /// </summary> /// <remarks> /// The Get Secrets operation is applicable to the entire vault. However, only /// the base secret identifier and its attributes are provided in the response. /// Individual secret versions are not listed in the response. This operation /// requires the secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual AsyncPageable <SecretProperties> GetPropertiesOfSecretsAsync(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(VaultUri, SecretsPath + $"?api-version={_pipeline.ApiVersion}"); return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLink, () => new SecretProperties(), "Azure.Security.KeyVault.Secrets.SecretClient.GetPropertiesOfSecrets", cancellationToken))); }
/// <summary> /// Lists deleted secrets for the specified vault. /// </summary> /// <remarks> /// The Get Deleted Secrets operation returns the secrets that have been /// deleted for a vault enabled for soft-delete. This operation requires the /// secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual IEnumerable <Response <DeletedSecret> > GetDeletedSecrets(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(_vaultUri, DeletedSecretsPath + $"?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new DeletedSecret(), cancellationToken))); }
/// <summary> Return list of jobs. </summary> public virtual Pageable <JobDetails> GetJobs(CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateEnumerable(cont => ToPage(string.IsNullOrEmpty(cont) ? _jobs.List() : _jobs.ListNextPage(cont)))); }
/// <summary> Return list of jobs. </summary> public virtual AsyncPageable <JobDetails> GetJobsAsync(CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateAsyncEnumerable(async cont => ToPage(string.IsNullOrEmpty(cont) ? await _jobs.ListAsync().ConfigureAwait(false) : await _jobs.ListNextPageAsync(cont).ConfigureAwait(false)))); }
/// <summary> /// List secrets in a specified key vault. /// </summary> /// <remarks> /// The Get Secrets operation is applicable to the entire vault. However, only /// the base secret identifier and its attributes are provided in the response. /// Individual secret versions are not listed in the response. This operation /// requires the secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual IEnumerable <Response <SecretBase> > GetSecrets(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(_vaultUri, SecretsPath + $"?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateEnumerable(nextLink => GetPage(firstPageUri, nextLink, () => new SecretBase(), "Azure.Security.KeyVault.Secrets.SecretClient.GetSecrets", cancellationToken))); }
/// <summary> /// Lists deleted secrets for the specified vault. /// </summary> /// <remarks> /// The Get Deleted Secrets operation returns the secrets that have been /// deleted for a vault enabled for soft-delete. This operation requires the /// secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual AsyncCollection <DeletedSecret> GetDeletedSecretsAsync(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(_vaultUri, DeletedSecretsPath + $"?api-version={ApiVersion}"); return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => GetPageAsync(firstPageUri, nextLink, () => new DeletedSecret(), "Azure.Security.KeyVault.Secrets.SecretClient.GetDeletedSecrets", cancellationToken))); }
/// <summary> /// Lists deleted secrets for the specified vault. /// </summary> /// <remarks> /// The Get Deleted Secrets operation returns the secrets that have been /// deleted for a vault enabled for soft-delete. This operation requires the /// secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual Pageable <DeletedSecret> GetDeletedSecrets(CancellationToken cancellationToken = default) { Uri firstPageUri = new Uri(VaultUri, DeletedSecretsPath + $"?api-version={_pipeline.ApiVersion}"); return(PageResponseEnumerator.CreateEnumerable(nextLink => _pipeline.GetPage(firstPageUri, nextLink, () => new DeletedSecret(), "Azure.Security.KeyVault.Secrets.SecretClient.GetDeletedSecrets", cancellationToken))); }
/// <summary> /// Lists the properties of all enabled and disabled secrets in the specified vault. You can use the returned <see cref="SecretProperties.Name"/> in subsequent calls to <see cref="GetSecretAsync"/>. /// </summary> /// <remarks> /// The Get Secrets operation is applicable to the entire vault. However, only /// the base secret identifier and its attributes are provided in the response. /// Individual secret versions are not listed in the response. This operation /// requires the secrets/list permission. /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual AsyncPageable <SecretProperties> GetPropertiesOfSecretsAsync(CancellationToken cancellationToken = default) { Uri firstPageUri = _pipeline.CreateFirstPageUri(SecretsPath); return(PageResponseEnumerator.CreateAsyncEnumerable(nextLink => _pipeline.GetPageAsync(firstPageUri, nextLink, () => new SecretProperties(), "SecretClient.GetPropertiesOfSecrets", cancellationToken))); }