Skip to content

Commit

Permalink
mssql reall all roles api
Browse files Browse the repository at this point in the history
  • Loading branch information
rajanadar committed May 9, 2016
1 parent 33b66e9 commit b89d635
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
Expand Up @@ -14,8 +14,8 @@ public class CredentialLeaseSettings
/// <value>
/// The duration of the lease.
/// </value>
[JsonProperty("lease")]
public string LeaseDuration { get; set; }
[JsonProperty("ttl")]
public string TimeToLive { get; set; }

/// <summary>
/// <para>[required]</para>
Expand All @@ -24,7 +24,7 @@ public class CredentialLeaseSettings
/// <value>
/// The maximum duration of the lease.
/// </value>
[JsonProperty("lease_max")]
public string MaximumLeaseDuration { get; set; }
[JsonProperty("ttl_max")]
public string MaximumTimeToLive { get; set; }
}
}
20 changes: 20 additions & 0 deletions src/VaultSharp/Backends/Secret/Models/ListInfo.cs
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace VaultSharp.Backends.Secret.Models
{
/// <summary>
/// Represents the list of keys.
/// </summary>
public class ListInfo
{
/// <summary>
/// Gets or sets the keys.
/// </summary>
/// <value>
/// The keys.
/// </value>
[JsonProperty("keys")]
public List<string> Keys { get; set; }
}
}
13 changes: 12 additions & 1 deletion src/VaultSharp/IVaultClient.cs
Expand Up @@ -902,7 +902,7 @@ public interface IVaultClient
Task GenericDeleteSecretAsync(string locationPath, string genericBackendMountPoint = SecretBackendDefaultMountPoints.Generic);

/// <summary>
/// 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.
/// </summary>
/// <param name="microsoftSqlConnectionInfo"><para>[required]</para>
Expand Down Expand Up @@ -957,6 +957,17 @@ public interface IVaultClient
/// </returns>
Task<Secret<MicrosoftSqlRoleDefinition>> MicrosoftSqlReadNamedRoleAsync(string microsoftSqlRoleName, string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql);

/// <summary>
/// Returns a list of available roles. Only the role names are returned, not any values.
/// </summary>
/// <param name="microsoftSqlBackendMountPoint"><para>[optional]</para>
/// The mount point for the MicrosoftSql backend. Defaults to <see cref="SecretBackendType.MicrosoftSql" />
/// Provide a value only if you have customized the MicrosoftSql mount point.</param>
/// <returns>
/// A list of available roles. Only the role names are returned, not any values.
/// </returns>
Task<Secret<ListInfo>> MicrosoftSqlReadAllRolesAsync(string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql);

/// <summary>
/// Deletes a named MicrosoftSql role definition
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/VaultSharp/VaultClient.cs
Expand Up @@ -771,6 +771,14 @@ public async Task<Secret<MicrosoftSqlRoleDefinition>> MicrosoftSqlReadNamedRoleA
return result;
}

public async Task<Secret<ListInfo>> MicrosoftSqlReadAllRolesAsync(string microsoftSqlBackendMountPoint = SecretBackendDefaultMountPoints.MicrosoftSql)
{
Checker.NotNull(microsoftSqlBackendMountPoint, "microsoftSqlBackendMountPoint");

var result = await MakeVaultApiRequest<Secret<ListInfo>>(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");
Expand Down
1 change: 1 addition & 0 deletions src/VaultSharp/VaultSharp.csproj
Expand Up @@ -62,6 +62,7 @@
<Compile Include="Backends\Secret\Models\Consul\ConsulCredentials.cs" />
<Compile Include="Backends\Secret\Models\Consul\ConsulRoleDefinition.cs" />
<Compile Include="Backends\Secret\Models\Consul\ConsulTokenType.cs" />
<Compile Include="Backends\Secret\Models\ListInfo.cs" />
<Compile Include="Backends\Secret\Models\CredentialLeaseSettings.cs" />
<Compile Include="Backends\Secret\Models\MicrosoftSql\MicrosoftSqlConnectionInfo.cs" />
<Compile Include="Backends\Secret\Models\MicrosoftSql\MicrosoftSqlRoleDefinition.cs" />
Expand Down
4 changes: 2 additions & 2 deletions test/VaultSharp.UnitTests/End2End/VaultClientEnd2EndTests.cs
Expand Up @@ -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()
Expand Down

1 comment on commit b89d635

@rajanadar
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mssql - strongly typed apis.

addresses hashicorp/vault#374 and hashicorp/vault#998

Please sign in to comment.