Skip to content

Commit

Permalink
return RestResponse from delete operations
Browse files Browse the repository at this point in the history
  • Loading branch information
maorleger committed Jun 8, 2021
1 parent e8667cb commit 3588e23
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
4 changes: 1 addition & 3 deletions sdk/keyvault/keyvault-admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
- Renamed `KeyVaultBeginSelectiveRestoreOptions` to `KeyVaultBeginSelectiveKeyRestoreOptions`.
- Renamed `KeyVaultSelectiveRestoreOperationState` to `KeyVaultSelectiveKeyRestoreOperationState`.
- Renamed `KeyVaultSelectiveRestoreResult` to `KeyVaultSelectiveKeyRestoreResult`.
- `deleteRoleAssignment` and `deleteRoleDefinition` no longer return the deleted role assignment / role definition, returning void instead.
- `deleteRoleAssignment` and `deleteRoleDefinition` will no longer throw an exception when the resource no longer exist.
- This ensures that the operations can be called multiple times.
- `deleteRoleAssignment` and `deleteRoleDefinition` will no longer throw an exception when the resource no longer exist, and will return the raw response of the operation.

## 4.0.0-beta.3 (2021-04-06)

Expand Down
5 changes: 3 additions & 2 deletions sdk/keyvault/keyvault-admin/review/keyvault-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as coreHttp from '@azure/core-http';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { PollerLike } from '@azure/core-lro';
import { PollOperationState } from '@azure/core-lro';
import { RestResponse } from '@azure/core-http';
import { TokenCredential } from '@azure/core-http';

// @public
Expand Down Expand Up @@ -39,8 +40,8 @@ export interface GetRoleDefinitionOptions extends coreHttp.OperationOptions {
export class KeyVaultAccessControlClient {
constructor(vaultUrl: string, credential: TokenCredential, options?: AccessControlClientOptions);
createRoleAssignment(roleScope: KeyVaultRoleScope, name: string, roleDefinitionId: string, principalId: string, options?: CreateRoleAssignmentOptions): Promise<KeyVaultRoleAssignment>;
deleteRoleAssignment(roleScope: KeyVaultRoleScope, name: string, options?: DeleteRoleAssignmentOptions): Promise<void>;
deleteRoleDefinition(roleScope: KeyVaultRoleScope, name: string, options?: DeleteRoleDefinitionOptions): Promise<void>;
deleteRoleAssignment(roleScope: KeyVaultRoleScope, name: string, options?: DeleteRoleAssignmentOptions): Promise<RestResponse>;
deleteRoleDefinition(roleScope: KeyVaultRoleScope, name: string, options?: DeleteRoleDefinitionOptions): Promise<RestResponse>;
getRoleAssignment(roleScope: KeyVaultRoleScope, name: string, options?: GetRoleAssignmentOptions): Promise<KeyVaultRoleAssignment>;
getRoleDefinition(roleScope: KeyVaultRoleScope, name: string, options?: GetRoleDefinitionOptions): Promise<KeyVaultRoleDefinition>;
listRoleAssignments(roleScope: KeyVaultRoleScope, options?: ListRoleAssignmentsOptions): PagedAsyncIterableIterator<KeyVaultRoleAssignment>;
Expand Down
19 changes: 10 additions & 9 deletions sdk/keyvault/keyvault-admin/src/accessControlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
isTokenCredential,
signingPolicy,
createPipelineFromOptions,
InternalPipelineOptions
InternalPipelineOptions,
RestResponse
} from "@azure/core-http";
import { PagedAsyncIterableIterator } from "@azure/core-paging";

Expand Down Expand Up @@ -177,10 +178,10 @@ export class KeyVaultAccessControlClient {
roleScope: KeyVaultRoleScope,
name: string,
options: DeleteRoleAssignmentOptions = {}
): Promise<void> {
return withTrace("deleteRoleAssignment", options, async (updatedOptions) => {
await this.client.roleAssignments.delete(this.vaultUrl, roleScope, name, updatedOptions);
});
): Promise<RestResponse> {
return withTrace("deleteRoleAssignment", options, (updatedOptions) =>
this.client.roleAssignments.delete(this.vaultUrl, roleScope, name, updatedOptions)
);
}

/**
Expand Down Expand Up @@ -486,9 +487,9 @@ export class KeyVaultAccessControlClient {
roleScope: KeyVaultRoleScope,
name: string,
options: DeleteRoleDefinitionOptions = {}
): Promise<void> {
return withTrace("deleteRoleDefinition", options, async (updatedOptions) => {
await this.client.roleDefinitions.delete(this.vaultUrl, roleScope, name, updatedOptions);
});
): Promise<RestResponse> {
return withTrace("deleteRoleDefinition", options, (updatedOptions) =>
this.client.roleDefinitions.delete(this.vaultUrl, roleScope, name, updatedOptions)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ describe("KeyVaultAccessControlClient", () => {
});

it("succeeds when deleting a non-existent role definition", async function() {
await assert.isFulfilled(
client.deleteRoleDefinition(globalScope, "foobar"),
"delete should ignore 404s"
);
const response = await client.deleteRoleDefinition(globalScope, "foobar");
assert.equal(404, response._response.status);
});
});

Expand Down Expand Up @@ -279,10 +277,8 @@ describe("KeyVaultAccessControlClient", () => {
});

it("succeeds when deleting a role assignment that doesn't exist", async () => {
await assert.isFulfilled(
client.deleteRoleAssignment(globalScope, generateFakeUUID()),
"delete should ignore 404s"
);
const response = await client.deleteRoleAssignment(globalScope, generateFakeUUID());
assert.equal(404, response._response.status);
});

it("supports tracing", async function() {
Expand Down

0 comments on commit 3588e23

Please sign in to comment.