Skip to content

Commit

Permalink
Change order of role definition methods
Browse files Browse the repository at this point in the history
Partly fixes Azure#20926
  • Loading branch information
heaths committed May 11, 2021
1 parent 1297823 commit bb7f7b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking Changes

- Changed parameter order in `KeyVaultAccessControlClient.DeleteRoleDefinition` and `KeyVaultAccessControlClient.DeleteRoleDefinitionAsync`.
- Changed parameter order in `KeyVaultAccessControlClient.GetRoleDefinition` and `KeyVaultAccessControlClient.GetRoleDefinitionAsync`.
- Moved all classes from the `Azure.Security.KeyVault.Administration.Models` namespace to `Azure.Security.KeyVault.Administration`.
- Renamed `BackupOperation` to `KeyVaultBackupOperation`.
- Renamed `RestoreOperation` to `KeyVaultRestoreOperation`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ public virtual AsyncPageable<KeyVaultRoleDefinition> GetRoleDefinitionsAsync(Key
/// <summary>
/// Get a specific role definition.
/// </summary>
/// <param name="roleDefinitionName">The role definition name.</param>
/// <param name="roleScope"> The scope of the role assignments. </param>
/// <param name="roleDefinitionName">The role definition name.</param>
/// <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>
/// <exception cref="ArgumentNullException"><paramref name="roleScope"/> is null.</exception>
public virtual Response<KeyVaultRoleDefinition> GetRoleDefinition(Guid roleDefinitionName, KeyVaultRoleScope roleScope, CancellationToken cancellationToken = default)
public virtual Response<KeyVaultRoleDefinition> GetRoleDefinition(KeyVaultRoleScope roleScope, Guid roleDefinitionName, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(KeyVaultAccessControlClient)}.{nameof(GetRoleDefinition)}");
scope.Start();
Expand All @@ -177,12 +177,12 @@ public virtual Response<KeyVaultRoleDefinition> GetRoleDefinition(Guid roleDefin
/// <summary>
/// Get a specific role definition.
/// </summary>
/// <param name="roleDefinitionName">The role definition name.</param>
/// <param name="roleScope"> The scope of the role definition. </param>
/// <param name="roleDefinitionName">The role definition name.</param>
/// <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>
/// <exception cref="ArgumentNullException"><paramref name="roleScope"/> is null.</exception>
public virtual async Task<Response<KeyVaultRoleDefinition>> GetRoleDefinitionAsync(Guid roleDefinitionName, KeyVaultRoleScope roleScope, CancellationToken cancellationToken = default)
public virtual async Task<Response<KeyVaultRoleDefinition>> GetRoleDefinitionAsync(KeyVaultRoleScope roleScope, Guid roleDefinitionName, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(KeyVaultAccessControlClient)}.{nameof(GetRoleDefinition)}");
scope.Start();
Expand Down Expand Up @@ -283,11 +283,11 @@ public virtual Response<KeyVaultRoleDefinition> CreateOrUpdateRoleDefinition(str
/// <summary>
/// Deletes a role definition.
/// </summary>
/// <param name="roleDefinitionName">The name used of the role definition to delete.</param>
/// <param name="roleScope">The scope of the role to delete.</param>
/// <param name="roleDefinitionName">The name used of the role definition to delete.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public virtual async Task<Response<KeyVaultRoleDefinition>> DeleteRoleDefinitionAsync(Guid roleDefinitionName, KeyVaultRoleScope roleScope, CancellationToken cancellationToken = default)
public virtual async Task<Response<KeyVaultRoleDefinition>> DeleteRoleDefinitionAsync(KeyVaultRoleScope roleScope, Guid roleDefinitionName, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(KeyVaultAccessControlClient)}.{nameof(DeleteRoleDefinition)}");
scope.Start();
Expand All @@ -305,11 +305,11 @@ public virtual async Task<Response<KeyVaultRoleDefinition>> DeleteRoleDefinition
/// <summary>
/// Deletes a role definition.
/// </summary>
/// <param name="roleDefinitionName"></param>
/// <param name="roleScope"></param>
/// <param name="roleDefinitionName"></param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>A <see cref="Response{TResult}"/> containing the result of the operation.</returns>
public virtual Response<KeyVaultRoleDefinition> DeleteRoleDefinition(Guid roleDefinitionName, KeyVaultRoleScope roleScope, CancellationToken cancellationToken = default)
public virtual Response<KeyVaultRoleDefinition> DeleteRoleDefinition(KeyVaultRoleScope roleScope, Guid roleDefinitionName, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(KeyVaultAccessControlClient)}.{nameof(DeleteRoleDefinition)}");
scope.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task GetRoleDefinition()

RegisterForCleanup(createdDefinition);

KeyVaultRoleDefinition fetchedRoleDefinition = await Client.GetRoleDefinitionAsync(name, KeyVaultRoleScope.Global);
KeyVaultRoleDefinition fetchedRoleDefinition = await Client.GetRoleDefinitionAsync(KeyVaultRoleScope.Global, name);

Assert.That(fetchedRoleDefinition.AssignableScopes, Is.EqualTo(new[] { KeyVaultRoleScope.Global }));
Assert.That(fetchedRoleDefinition.Description, Is.EqualTo(description));
Expand Down Expand Up @@ -92,7 +92,7 @@ public async Task DeleteRoleDefinition()
originalPermissions.DataActions.Add(KeyVaultDataAction.BackupHsmKeys);

KeyVaultRoleDefinition createdDefinition = await Client.CreateOrUpdateRoleDefinitionAsync(description, originalPermissions, KeyVaultRoleScope.Global, name);
await Client.DeleteRoleDefinitionAsync(name, KeyVaultRoleScope.Global);
await Client.DeleteRoleDefinitionAsync(KeyVaultRoleScope.Global, name);

List<KeyVaultRoleDefinition> results = await Client.GetRoleDefinitionsAsync(KeyVaultRoleScope.Global).ToEnumerableAsync().ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected async Task DeleteRoleDefinition((string Name, KeyVaultRoleScope? Scope
{
using (Recording.DisableRecording())
{
await Client.DeleteRoleDefinitionAsync(new Guid(assignment.Name), assignment.Scope.Value).ConfigureAwait(false);
await Client.DeleteRoleDefinitionAsync(assignment.Scope.Value, new Guid(assignment.Name)).ConfigureAwait(false);
}
}
catch (RequestFailedException ex) when (ex.Status == 404)
Expand Down

0 comments on commit bb7f7b7

Please sign in to comment.