From b89d6356f0d673eb8476c7e0f7daf2fb3d249eed Mon Sep 17 00:00:00 2001 From: Raja Nadar Date: Sun, 8 May 2016 21:14:11 -0700 Subject: [PATCH] mssql reall all roles api --- .../Secret/Models/CredentialLeaseSettings.cs | 8 ++++---- .../Backends/Secret/Models/ListInfo.cs | 20 +++++++++++++++++++ src/VaultSharp/IVaultClient.cs | 13 +++++++++++- src/VaultSharp/VaultClient.cs | 8 ++++++++ src/VaultSharp/VaultSharp.csproj | 1 + .../End2End/VaultClientEnd2EndTests.cs | 4 ++-- 6 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 src/VaultSharp/Backends/Secret/Models/ListInfo.cs diff --git a/src/VaultSharp/Backends/Secret/Models/CredentialLeaseSettings.cs b/src/VaultSharp/Backends/Secret/Models/CredentialLeaseSettings.cs index 63736ff6..96946f6d 100644 --- a/src/VaultSharp/Backends/Secret/Models/CredentialLeaseSettings.cs +++ b/src/VaultSharp/Backends/Secret/Models/CredentialLeaseSettings.cs @@ -14,8 +14,8 @@ public class CredentialLeaseSettings /// /// The duration of the lease. /// - [JsonProperty("lease")] - public string LeaseDuration { get; set; } + [JsonProperty("ttl")] + public string TimeToLive { get; set; } /// /// [required] @@ -24,7 +24,7 @@ public class CredentialLeaseSettings /// /// The maximum duration of the lease. /// - [JsonProperty("lease_max")] - public string MaximumLeaseDuration { get; set; } + [JsonProperty("ttl_max")] + public string MaximumTimeToLive { get; set; } } } \ No newline at end of file diff --git a/src/VaultSharp/Backends/Secret/Models/ListInfo.cs b/src/VaultSharp/Backends/Secret/Models/ListInfo.cs new file mode 100644 index 00000000..11c81796 --- /dev/null +++ b/src/VaultSharp/Backends/Secret/Models/ListInfo.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace VaultSharp.Backends.Secret.Models +{ + /// + /// Represents the list of keys. + /// + public class ListInfo + { + /// + /// Gets or sets the keys. + /// + /// + /// The keys. + /// + [JsonProperty("keys")] + public List Keys { get; set; } + } +} \ No newline at end of file diff --git a/src/VaultSharp/IVaultClient.cs b/src/VaultSharp/IVaultClient.cs index efec051b..aa5b4a9b 100644 --- a/src/VaultSharp/IVaultClient.cs +++ b/src/VaultSharp/IVaultClient.cs @@ -902,7 +902,7 @@ public interface IVaultClient Task GenericDeleteSecretAsync(string locationPath, string genericBackendMountPoint = SecretBackendDefaultMountPoints.Generic); /// - /// Configures the connection information used to communicate with Microsoft Sql. + /// Configures the connection information used to communicate with Microsoft Sql Server. /// This API is a root protected call. /// /// [required] @@ -957,6 +957,17 @@ public interface IVaultClient /// Task> MicrosoftSqlReadNamedRoleAsync(string microsoftSqlRoleName, string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql); + /// + /// Returns a list of available roles. Only the role names are returned, not any values. + /// + /// [optional] + /// The mount point for the MicrosoftSql backend. Defaults to + /// Provide a value only if you have customized the MicrosoftSql mount point. + /// + /// A list of available roles. Only the role names are returned, not any values. + /// + Task> MicrosoftSqlReadAllRolesAsync(string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql); + /// /// Deletes a named MicrosoftSql role definition /// diff --git a/src/VaultSharp/VaultClient.cs b/src/VaultSharp/VaultClient.cs index 5eb69aa1..09109e11 100644 --- a/src/VaultSharp/VaultClient.cs +++ b/src/VaultSharp/VaultClient.cs @@ -771,6 +771,14 @@ public async Task> MicrosoftSqlReadNamedRoleA return result; } + public async Task> MicrosoftSqlReadAllRolesAsync(string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql) + { + Checker.NotNull(microsoftSqlBackendMountPoint, "microsoftSqlBackendMountPoint"); + + var result = await MakeVaultApiRequest>(microsoftSqlBackendMountPoint.Trim('/') + "/roles/?list=true", HttpMethod.Get).ConfigureAwait(continueOnCapturedContext: _continueAsyncTasksOnCapturedContext); + return result; + } + public async Task MicrosoftSqlDeleteNamedRoleAsync(string microsoftSqlRoleName, string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql) { Checker.NotNull(microsoftSqlBackendMountPoint, "microsoftSqlBackendMountPoint"); diff --git a/src/VaultSharp/VaultSharp.csproj b/src/VaultSharp/VaultSharp.csproj index fb3e09dd..641759f2 100644 --- a/src/VaultSharp/VaultSharp.csproj +++ b/src/VaultSharp/VaultSharp.csproj @@ -62,6 +62,7 @@ + diff --git a/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs b/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs index a1e5299f..17513aa4 100644 --- a/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs +++ b/test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs @@ -1271,8 +1271,8 @@ await _authenticatedClient.MySqlConfigureConnectionAsync(new MySqlConnectionInfo await _authenticatedClient.MySqlConfigureCredentialLeaseSettingsAsync(new CredentialLeaseSettings() { - LeaseDuration = "1h", - MaximumLeaseDuration = "2h" + TimeToLive = "1h", + MaximumTimeToLive = "2h" }, mountPoint); await _authenticatedClient.MySqlWriteNamedRoleAsync(role, new MySqlRoleDefinition()