@azure/keyvault-admin 4.7.2-alpha.20260302.2 → 4.7.2-alpha.20260304.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/commonjs/accessControlClient.js +369 -320
  2. package/dist/commonjs/accessControlClient.js.map +7 -1
  3. package/dist/commonjs/accessControlModels.js +29 -9
  4. package/dist/commonjs/accessControlModels.js.map +7 -1
  5. package/dist/commonjs/api/index.js +50 -20
  6. package/dist/commonjs/api/index.js.map +7 -1
  7. package/dist/commonjs/api/keyVaultContext.js +54 -39
  8. package/dist/commonjs/api/keyVaultContext.js.map +7 -1
  9. package/dist/commonjs/api/operations.js +408 -323
  10. package/dist/commonjs/api/operations.js.map +7 -1
  11. package/dist/commonjs/api/options.js +15 -5
  12. package/dist/commonjs/api/options.js.map +7 -1
  13. package/dist/commonjs/api/roleAssignments/index.js +33 -11
  14. package/dist/commonjs/api/roleAssignments/index.js.map +7 -1
  15. package/dist/commonjs/api/roleAssignments/operations.js +167 -123
  16. package/dist/commonjs/api/roleAssignments/operations.js.map +7 -1
  17. package/dist/commonjs/api/roleAssignments/options.js +15 -5
  18. package/dist/commonjs/api/roleAssignments/options.js.map +7 -1
  19. package/dist/commonjs/api/roleDefinitions/index.js +33 -11
  20. package/dist/commonjs/api/roleDefinitions/index.js.map +7 -1
  21. package/dist/commonjs/api/roleDefinitions/operations.js +167 -123
  22. package/dist/commonjs/api/roleDefinitions/operations.js.map +7 -1
  23. package/dist/commonjs/api/roleDefinitions/options.js +15 -5
  24. package/dist/commonjs/api/roleDefinitions/options.js.map +7 -1
  25. package/dist/commonjs/backupClient.js +232 -193
  26. package/dist/commonjs/backupClient.js.map +7 -1
  27. package/dist/commonjs/backupClientModels.js +15 -5
  28. package/dist/commonjs/backupClientModels.js.map +7 -1
  29. package/dist/commonjs/classic/index.js +15 -5
  30. package/dist/commonjs/classic/index.js.map +7 -1
  31. package/dist/commonjs/classic/roleAssignments/index.js +36 -16
  32. package/dist/commonjs/classic/roleAssignments/index.js.map +7 -1
  33. package/dist/commonjs/classic/roleDefinitions/index.js +36 -16
  34. package/dist/commonjs/classic/roleDefinitions/index.js.map +7 -1
  35. package/dist/commonjs/constants.js +30 -14
  36. package/dist/commonjs/constants.js.map +7 -1
  37. package/dist/commonjs/createKeyVaultClient.js +59 -40
  38. package/dist/commonjs/createKeyVaultClient.js.map +7 -1
  39. package/dist/commonjs/index.js +38 -14
  40. package/dist/commonjs/index.js.map +7 -1
  41. package/dist/commonjs/keyVaultClient.js +95 -78
  42. package/dist/commonjs/keyVaultClient.js.map +7 -1
  43. package/dist/commonjs/logger.js +28 -8
  44. package/dist/commonjs/logger.js.map +7 -1
  45. package/dist/commonjs/lro/models.js +15 -5
  46. package/dist/commonjs/lro/models.js.map +7 -1
  47. package/dist/commonjs/lro/shim.js +105 -89
  48. package/dist/commonjs/lro/shim.js.map +7 -1
  49. package/dist/commonjs/mappings.js +94 -81
  50. package/dist/commonjs/mappings.js.map +7 -1
  51. package/dist/commonjs/models/index.js +39 -14
  52. package/dist/commonjs/models/index.js.map +7 -1
  53. package/dist/commonjs/models/models.js +322 -346
  54. package/dist/commonjs/models/models.js.map +7 -1
  55. package/dist/commonjs/restorePollerHelpers.js +108 -99
  56. package/dist/commonjs/restorePollerHelpers.js.map +7 -1
  57. package/dist/commonjs/settingsClient.js +102 -88
  58. package/dist/commonjs/settingsClient.js.map +7 -1
  59. package/dist/commonjs/settingsClientModels.js +15 -5
  60. package/dist/commonjs/settingsClientModels.js.map +7 -1
  61. package/dist/commonjs/static-helpers/pagingHelpers.js +109 -103
  62. package/dist/commonjs/static-helpers/pagingHelpers.js.map +7 -1
  63. package/dist/commonjs/static-helpers/pollingHelpers.js +86 -76
  64. package/dist/commonjs/static-helpers/pollingHelpers.js.map +7 -1
  65. package/dist/commonjs/static-helpers/urlTemplate.js +146 -145
  66. package/dist/commonjs/static-helpers/urlTemplate.js.map +7 -1
  67. package/dist/commonjs/tracing.js +32 -12
  68. package/dist/commonjs/tracing.js.map +7 -1
  69. package/package.json +4 -17
@@ -1,324 +1,373 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- /// <reference lib="esnext.asynciterable" />
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KeyVaultAccessControlClient = void 0;
7
- const mappings_js_1 = require("./mappings.js");
8
- const tracing_js_1 = require("./tracing.js");
9
- const core_util_1 = require("@azure/core-util");
10
- const createKeyVaultClient_js_1 = require("./createKeyVaultClient.js");
11
- /**
12
- * The KeyVaultAccessControlClient provides methods to manage
13
- * access control and role assignments in any given Azure Key Vault instance.
14
- * The client supports creating, retrieving and deleting roles.
15
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var accessControlClient_exports = {};
19
+ __export(accessControlClient_exports, {
20
+ KeyVaultAccessControlClient: () => KeyVaultAccessControlClient
21
+ });
22
+ module.exports = __toCommonJS(accessControlClient_exports);
23
+ var import_mappings = require("./mappings.js");
24
+ var import_tracing = require("./tracing.js");
25
+ var import_core_util = require("@azure/core-util");
26
+ var import_createKeyVaultClient = require("./createKeyVaultClient.js");
16
27
  class KeyVaultAccessControlClient {
17
- /**
18
- * The base URL to the vault
19
- */
20
- vaultUrl;
21
- /**
22
- * A reference to the auto-generated Key Vault HTTP client.
23
- */
24
- client;
25
- /**
26
- * Creates an instance of the KeyVaultAccessControlClient.
27
- *
28
- * Example usage:
29
- * ```ts snippet:ReadmeSampleCreateAccessControlClient
30
- * import { DefaultAzureCredential } from "@azure/identity";
31
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
32
- *
33
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
34
- * const credentials = new DefaultAzureCredential();
35
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
36
- * ```
37
- * @param vaultUrl - the URL of the Key Vault. It should have this shape: `https://${your-key-vault-name}.vault.azure.net`. You should validate that this URL references a valid Key Vault or Managed HSM resource. See https://aka.ms/azsdk/blog/vault-uri for details.
38
- * @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
39
- * @param options - Options used to configure Key Vault API requests. Omit this parameter to use the default configuration.
40
- */
41
- constructor(vaultUrl, credential,
42
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
43
- options = {}) {
44
- this.vaultUrl = vaultUrl;
45
- this.client = (0, createKeyVaultClient_js_1.createKeyVaultClient)(vaultUrl, credential, options);
46
- }
47
- /**
48
- * Creates a role assignment in an Azure Key Vault.
49
- *
50
- * Example usage:
51
- * ```ts snippet:ReadmeSampleCreateRoleAssignment
52
- * import { DefaultAzureCredential } from "@azure/identity";
53
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
54
- *
55
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
56
- * const credentials = new DefaultAzureCredential();
57
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
58
- *
59
- * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
60
- *
61
- * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
62
- * const result = await client.createRoleAssignment(
63
- * "/",
64
- * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
65
- * roleDefinition.id,
66
- * principalId,
67
- * );
68
- * ```
69
- * Creates a new role assignment.
70
- * @param roleScope - The scope of the role assignment.
71
- * @param name - The name of the role assignment. Must be a UUID.
72
- * @param roleDefinitionId - The role definition ID used in the role assignment.
73
- * @param principalId - The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group.
74
- * @param options - The optional parameters.
75
- */
76
- createRoleAssignment(roleScope, name, roleDefinitionId, principalId, options = {}) {
77
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.createRoleAssignment", options, async (updatedOptions) => {
78
- const response = await this.client.roleAssignments.create(roleScope, name, {
79
- properties: {
80
- roleDefinitionId,
81
- principalId,
82
- },
83
- }, updatedOptions);
84
- return mappings_js_1.mappings.roleAssignment.generatedToPublic(response);
85
- });
86
- }
87
- /**
88
- * Deletes role assignments previously created in an Azure Key Vault.
89
- *
90
- * Example usage:
91
- * ```ts snippet:ReadmeSampleDeleteRoleAssignment
92
- * import { DefaultAzureCredential } from "@azure/identity";
93
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
94
- *
95
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
96
- * const credentials = new DefaultAzureCredential();
97
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
98
- *
99
- * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
100
- * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
101
- *
102
- * const roleAssignment = await client.createRoleAssignment(
103
- * "/",
104
- * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
105
- * roleDefinition.id,
106
- * principalId,
107
- * );
108
- *
109
- * await client.deleteRoleAssignment(roleAssignment.properties.scope, roleAssignment.name);
110
- * ```
111
- * Deletes an existing role assignment.
112
- * @param roleScope - The scope of the role assignment.
113
- * @param name - The name of the role assignment.
114
- * @param options - The optional parameters.
115
- */
116
- deleteRoleAssignment(roleScope, name, options = {}) {
117
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.deleteRoleAssignment", options, async (updatedOptions) => {
118
- try {
119
- await this.client.roleAssignments.delete(roleScope, name, updatedOptions);
28
+ /**
29
+ * The base URL to the vault
30
+ */
31
+ vaultUrl;
32
+ /**
33
+ * A reference to the auto-generated Key Vault HTTP client.
34
+ */
35
+ client;
36
+ /**
37
+ * Creates an instance of the KeyVaultAccessControlClient.
38
+ *
39
+ * Example usage:
40
+ * ```ts snippet:ReadmeSampleCreateAccessControlClient
41
+ * import { DefaultAzureCredential } from "@azure/identity";
42
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
43
+ *
44
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
45
+ * const credentials = new DefaultAzureCredential();
46
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
47
+ * ```
48
+ * @param vaultUrl - the URL of the Key Vault. It should have this shape: `https://${your-key-vault-name}.vault.azure.net`. You should validate that this URL references a valid Key Vault or Managed HSM resource. See https://aka.ms/azsdk/blog/vault-uri for details.
49
+ * @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
50
+ * @param options - Options used to configure Key Vault API requests. Omit this parameter to use the default configuration.
51
+ */
52
+ constructor(vaultUrl, credential, options = {}) {
53
+ this.vaultUrl = vaultUrl;
54
+ this.client = (0, import_createKeyVaultClient.createKeyVaultClient)(vaultUrl, credential, options);
55
+ }
56
+ /**
57
+ * Creates a role assignment in an Azure Key Vault.
58
+ *
59
+ * Example usage:
60
+ * ```ts snippet:ReadmeSampleCreateRoleAssignment
61
+ * import { DefaultAzureCredential } from "@azure/identity";
62
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
63
+ *
64
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
65
+ * const credentials = new DefaultAzureCredential();
66
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
67
+ *
68
+ * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
69
+ *
70
+ * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
71
+ * const result = await client.createRoleAssignment(
72
+ * "/",
73
+ * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
74
+ * roleDefinition.id,
75
+ * principalId,
76
+ * );
77
+ * ```
78
+ * Creates a new role assignment.
79
+ * @param roleScope - The scope of the role assignment.
80
+ * @param name - The name of the role assignment. Must be a UUID.
81
+ * @param roleDefinitionId - The role definition ID used in the role assignment.
82
+ * @param principalId - The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group.
83
+ * @param options - The optional parameters.
84
+ */
85
+ createRoleAssignment(roleScope, name, roleDefinitionId, principalId, options = {}) {
86
+ return import_tracing.tracingClient.withSpan(
87
+ "KeyVaultAccessControlClient.createRoleAssignment",
88
+ options,
89
+ async (updatedOptions) => {
90
+ const response = await this.client.roleAssignments.create(
91
+ roleScope,
92
+ name,
93
+ {
94
+ properties: {
95
+ roleDefinitionId,
96
+ principalId
120
97
  }
121
- catch (err) {
122
- // If the role assignment doesn't exist, we can consider it deleted.
123
- if (err.statusCode !== 404) {
124
- throw err;
125
- }
98
+ },
99
+ updatedOptions
100
+ );
101
+ return import_mappings.mappings.roleAssignment.generatedToPublic(response);
102
+ }
103
+ );
104
+ }
105
+ /**
106
+ * Deletes role assignments previously created in an Azure Key Vault.
107
+ *
108
+ * Example usage:
109
+ * ```ts snippet:ReadmeSampleDeleteRoleAssignment
110
+ * import { DefaultAzureCredential } from "@azure/identity";
111
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
112
+ *
113
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
114
+ * const credentials = new DefaultAzureCredential();
115
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
116
+ *
117
+ * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
118
+ * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
119
+ *
120
+ * const roleAssignment = await client.createRoleAssignment(
121
+ * "/",
122
+ * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
123
+ * roleDefinition.id,
124
+ * principalId,
125
+ * );
126
+ *
127
+ * await client.deleteRoleAssignment(roleAssignment.properties.scope, roleAssignment.name);
128
+ * ```
129
+ * Deletes an existing role assignment.
130
+ * @param roleScope - The scope of the role assignment.
131
+ * @param name - The name of the role assignment.
132
+ * @param options - The optional parameters.
133
+ */
134
+ deleteRoleAssignment(roleScope, name, options = {}) {
135
+ return import_tracing.tracingClient.withSpan(
136
+ "KeyVaultAccessControlClient.deleteRoleAssignment",
137
+ options,
138
+ async (updatedOptions) => {
139
+ try {
140
+ await this.client.roleAssignments.delete(roleScope, name, updatedOptions);
141
+ } catch (err) {
142
+ if (err.statusCode !== 404) {
143
+ throw err;
144
+ }
145
+ }
146
+ }
147
+ );
148
+ }
149
+ /**
150
+ * Gets a role assignments previously created in an Azure Key Vault.
151
+ *
152
+ * Example usage:
153
+ * ```ts snippet:ReadmeSampleGetRoleAssignment
154
+ * import { DefaultAzureCredential } from "@azure/identity";
155
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
156
+ *
157
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
158
+ * const credentials = new DefaultAzureCredential();
159
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
160
+ *
161
+ * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
162
+ * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
163
+ *
164
+ * let roleAssignment = await client.createRoleAssignment(
165
+ * "/",
166
+ * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
167
+ * roleDefinition.id,
168
+ * principalId,
169
+ * );
170
+ *
171
+ * roleAssignment = await client.getRoleAssignment(
172
+ * roleAssignment.properties.scope,
173
+ * roleAssignment.name,
174
+ * );
175
+ * console.log(roleAssignment);
176
+ * ```
177
+ * Gets an existing role assignment.
178
+ * @param roleScope - The scope of the role assignment.
179
+ * @param name - The name of the role assignment.
180
+ * @param options - The optional parameters.
181
+ */
182
+ getRoleAssignment(roleScope, name, options = {}) {
183
+ return import_tracing.tracingClient.withSpan(
184
+ "KeyVaultAccessControlClient.getRoleAssignment",
185
+ options,
186
+ async (updatedOptions) => {
187
+ const response = await this.client.roleAssignments.get(roleScope, name, updatedOptions);
188
+ return import_mappings.mappings.roleAssignment.generatedToPublic(response);
189
+ }
190
+ );
191
+ }
192
+ /**
193
+ * Iterates over all of the available role assignments in an Azure Key Vault.
194
+ *
195
+ * Example usage:
196
+ * ```ts snippet:ReadmeSampleListRoleAssignments
197
+ * import { DefaultAzureCredential } from "@azure/identity";
198
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
199
+ *
200
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
201
+ * const credentials = new DefaultAzureCredential();
202
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
203
+ *
204
+ * for await (const roleAssignment of client.listRoleAssignments("/")) {
205
+ * console.log("Role assignment: ", roleAssignment);
206
+ * }
207
+ * ```
208
+ * Lists all of the role assignments in a given scope.
209
+ * @param roleScope - The scope of the role assignments.
210
+ * @param options - The optional parameters.
211
+ */
212
+ listRoleAssignments(roleScope, options = {}) {
213
+ return (0, import_mappings.mapPagedAsyncIterable)(
214
+ options,
215
+ (mappedOptions) => this.client.roleAssignments.listForScope(roleScope, mappedOptions),
216
+ import_mappings.mappings.roleAssignment.generatedToPublic
217
+ );
218
+ }
219
+ /**
220
+ * Iterates over all of the available role definitions in an Azure Key Vault.
221
+ *
222
+ * Example usage:
223
+ * ```ts snippet:ReadmeSampleListRoleDefinitions
224
+ * import { DefaultAzureCredential } from "@azure/identity";
225
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
226
+ *
227
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
228
+ * const credentials = new DefaultAzureCredential();
229
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
230
+ *
231
+ * for await (const roleDefinitions of client.listRoleDefinitions("/")) {
232
+ * console.log("Role definition: ", roleDefinitions);
233
+ * }
234
+ * ```
235
+ * Lists all of the role definition in a given scope.
236
+ * @param roleScope - The scope of the role definition.
237
+ * @param options - The optional parameters.
238
+ */
239
+ listRoleDefinitions(roleScope, options = {}) {
240
+ return (0, import_mappings.mapPagedAsyncIterable)(
241
+ options,
242
+ (mappedOptions) => this.client.roleDefinitions.list(roleScope, mappedOptions),
243
+ import_mappings.mappings.roleDefinition.generatedToPublic
244
+ );
245
+ }
246
+ /**
247
+ * Gets a role definition from Azure Key Vault.
248
+ *
249
+ * Example usage:
250
+ * ```ts snippet:ReadmeSampleGetRoleDefinition
251
+ * import { DefaultAzureCredential } from "@azure/identity";
252
+ * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
253
+ *
254
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
255
+ * const credentials = new DefaultAzureCredential();
256
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
257
+ *
258
+ * const roleDefinition = await client.getRoleDefinition("/", "b86a8fe4-44ce-4948-aee5-eccb2c155cd7");
259
+ * console.log(roleDefinition);
260
+ * ```
261
+ * @param roleScope - The scope of the role definition.
262
+ * @param name - The name of the role definition.
263
+ * @param options - The optional parameters.
264
+ */
265
+ getRoleDefinition(roleScope, name, options = {}) {
266
+ return import_tracing.tracingClient.withSpan(
267
+ "KeyVaultAccessControlClient.getRoleDefinition",
268
+ options,
269
+ async (updatedOptions) => {
270
+ const response = await this.client.roleDefinitions.get(roleScope, name, updatedOptions);
271
+ return import_mappings.mappings.roleDefinition.generatedToPublic(response);
272
+ }
273
+ );
274
+ }
275
+ /**
276
+ * Creates or updates a role definition in an Azure Key Vault.
277
+ *
278
+ * Example usage:
279
+ * ```ts snippet:ReadmeSampleSetRoleDefinition
280
+ * import { DefaultAzureCredential } from "@azure/identity";
281
+ * import {
282
+ * KeyVaultAccessControlClient,
283
+ * KnownKeyVaultDataAction,
284
+ * KnownKeyVaultRoleScope,
285
+ * } from "@azure/keyvault-admin";
286
+ *
287
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
288
+ * const credentials = new DefaultAzureCredential();
289
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
290
+ *
291
+ * const permissions = [{ dataActions: [KnownKeyVaultDataAction.BackupHsmKeys] }];
292
+ * const roleDefinitionName = "23b8bb1a-39c0-4c89-a85b-dd3c99273a8a";
293
+ * const roleDefinition = await client.setRoleDefinition(KnownKeyVaultRoleScope.Global, {
294
+ * permissions,
295
+ * roleDefinitionName,
296
+ * });
297
+ * console.log(roleDefinition);
298
+ * ```
299
+ * @param roleScope - The scope of the role definition.
300
+ * @param options - The optional parameters.
301
+ */
302
+ setRoleDefinition(roleScope, options = {}) {
303
+ return import_tracing.tracingClient.withSpan(
304
+ "KeyVaultAccessControlClient.setRoleDefinition",
305
+ options,
306
+ async (updatedOptions) => {
307
+ const response = await this.client.roleDefinitions.createOrUpdate(
308
+ roleScope,
309
+ options.roleDefinitionName || (0, import_core_util.randomUUID)(),
310
+ {
311
+ properties: {
312
+ description: options.description,
313
+ permissions: options.permissions,
314
+ assignableScopes: [roleScope],
315
+ roleName: options.roleName,
316
+ roleType: "CustomRole"
126
317
  }
127
- });
128
- }
129
- /**
130
- * Gets a role assignments previously created in an Azure Key Vault.
131
- *
132
- * Example usage:
133
- * ```ts snippet:ReadmeSampleGetRoleAssignment
134
- * import { DefaultAzureCredential } from "@azure/identity";
135
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
136
- *
137
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
138
- * const credentials = new DefaultAzureCredential();
139
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
140
- *
141
- * const { value: roleDefinition } = await client.listRoleDefinitions("/").next();
142
- * const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
143
- *
144
- * let roleAssignment = await client.createRoleAssignment(
145
- * "/",
146
- * "295c179b-9ad3-4117-99cd-b1aa66cf4517",
147
- * roleDefinition.id,
148
- * principalId,
149
- * );
150
- *
151
- * roleAssignment = await client.getRoleAssignment(
152
- * roleAssignment.properties.scope,
153
- * roleAssignment.name,
154
- * );
155
- * console.log(roleAssignment);
156
- * ```
157
- * Gets an existing role assignment.
158
- * @param roleScope - The scope of the role assignment.
159
- * @param name - The name of the role assignment.
160
- * @param options - The optional parameters.
161
- */
162
- getRoleAssignment(roleScope, name, options = {}) {
163
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.getRoleAssignment", options, async (updatedOptions) => {
164
- const response = await this.client.roleAssignments.get(roleScope, name, updatedOptions);
165
- return mappings_js_1.mappings.roleAssignment.generatedToPublic(response);
166
- });
167
- }
168
- /**
169
- * Iterates over all of the available role assignments in an Azure Key Vault.
170
- *
171
- * Example usage:
172
- * ```ts snippet:ReadmeSampleListRoleAssignments
173
- * import { DefaultAzureCredential } from "@azure/identity";
174
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
175
- *
176
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
177
- * const credentials = new DefaultAzureCredential();
178
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
179
- *
180
- * for await (const roleAssignment of client.listRoleAssignments("/")) {
181
- * console.log("Role assignment: ", roleAssignment);
182
- * }
183
- * ```
184
- * Lists all of the role assignments in a given scope.
185
- * @param roleScope - The scope of the role assignments.
186
- * @param options - The optional parameters.
187
- */
188
- listRoleAssignments(roleScope, options = {}) {
189
- return (0, mappings_js_1.mapPagedAsyncIterable)(options, (mappedOptions) => this.client.roleAssignments.listForScope(roleScope, mappedOptions), mappings_js_1.mappings.roleAssignment.generatedToPublic);
190
- }
191
- /**
192
- * Iterates over all of the available role definitions in an Azure Key Vault.
193
- *
194
- * Example usage:
195
- * ```ts snippet:ReadmeSampleListRoleDefinitions
196
- * import { DefaultAzureCredential } from "@azure/identity";
197
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
198
- *
199
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
200
- * const credentials = new DefaultAzureCredential();
201
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
202
- *
203
- * for await (const roleDefinitions of client.listRoleDefinitions("/")) {
204
- * console.log("Role definition: ", roleDefinitions);
205
- * }
206
- * ```
207
- * Lists all of the role definition in a given scope.
208
- * @param roleScope - The scope of the role definition.
209
- * @param options - The optional parameters.
210
- */
211
- listRoleDefinitions(roleScope, options = {}) {
212
- return (0, mappings_js_1.mapPagedAsyncIterable)(options, (mappedOptions) => this.client.roleDefinitions.list(roleScope, mappedOptions), mappings_js_1.mappings.roleDefinition.generatedToPublic);
213
- }
214
- /**
215
- * Gets a role definition from Azure Key Vault.
216
- *
217
- * Example usage:
218
- * ```ts snippet:ReadmeSampleGetRoleDefinition
219
- * import { DefaultAzureCredential } from "@azure/identity";
220
- * import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
221
- *
222
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
223
- * const credentials = new DefaultAzureCredential();
224
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
225
- *
226
- * const roleDefinition = await client.getRoleDefinition("/", "b86a8fe4-44ce-4948-aee5-eccb2c155cd7");
227
- * console.log(roleDefinition);
228
- * ```
229
- * @param roleScope - The scope of the role definition.
230
- * @param name - The name of the role definition.
231
- * @param options - The optional parameters.
232
- */
233
- getRoleDefinition(roleScope, name, options = {}) {
234
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.getRoleDefinition", options, async (updatedOptions) => {
235
- const response = await this.client.roleDefinitions.get(roleScope, name, updatedOptions);
236
- return mappings_js_1.mappings.roleDefinition.generatedToPublic(response);
237
- });
238
- }
239
- /**
240
- * Creates or updates a role definition in an Azure Key Vault.
241
- *
242
- * Example usage:
243
- * ```ts snippet:ReadmeSampleSetRoleDefinition
244
- * import { DefaultAzureCredential } from "@azure/identity";
245
- * import {
246
- * KeyVaultAccessControlClient,
247
- * KnownKeyVaultDataAction,
248
- * KnownKeyVaultRoleScope,
249
- * } from "@azure/keyvault-admin";
250
- *
251
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
252
- * const credentials = new DefaultAzureCredential();
253
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
254
- *
255
- * const permissions = [{ dataActions: [KnownKeyVaultDataAction.BackupHsmKeys] }];
256
- * const roleDefinitionName = "23b8bb1a-39c0-4c89-a85b-dd3c99273a8a";
257
- * const roleDefinition = await client.setRoleDefinition(KnownKeyVaultRoleScope.Global, {
258
- * permissions,
259
- * roleDefinitionName,
260
- * });
261
- * console.log(roleDefinition);
262
- * ```
263
- * @param roleScope - The scope of the role definition.
264
- * @param options - The optional parameters.
265
- */
266
- setRoleDefinition(roleScope, options = {}) {
267
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.setRoleDefinition", options, async (updatedOptions) => {
268
- const response = await this.client.roleDefinitions.createOrUpdate(roleScope, options.roleDefinitionName || (0, core_util_1.randomUUID)(), {
269
- properties: {
270
- description: options.description,
271
- permissions: options.permissions,
272
- assignableScopes: [roleScope],
273
- roleName: options.roleName,
274
- roleType: "CustomRole",
275
- },
276
- }, updatedOptions);
277
- return mappings_js_1.mappings.roleDefinition.generatedToPublic(response);
278
- });
279
- }
280
- /**
281
- * Deletes a custom role definition previously created in an Azure Key Vault.
282
- *
283
- * Example usage:
284
- * ```ts snippet:ReadmeSampleDeleteRoleDefinition
285
- * import { DefaultAzureCredential } from "@azure/identity";
286
- * import {
287
- * KeyVaultAccessControlClient,
288
- * KnownKeyVaultDataAction,
289
- * KnownKeyVaultRoleScope,
290
- * } from "@azure/keyvault-admin";
291
- *
292
- * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
293
- * const credentials = new DefaultAzureCredential();
294
- * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
295
- *
296
- * const permissions = [{ dataActions: [KnownKeyVaultDataAction.BackupHsmKeys] }];
297
- * const roleDefinitionName = "23b8bb1a-39c0-4c89-a85b-dd3c99273a8a";
298
- * const roleDefinition = await client.setRoleDefinition(KnownKeyVaultRoleScope.Global, {
299
- * permissions,
300
- * roleDefinitionName,
301
- * });
302
- *
303
- * await client.deleteRoleDefinition("/", roleDefinition.name);
304
- * ```
305
- * @param roleScope - The scope of the role definition.
306
- * @param name - The name of the role definition to delete.
307
- * @param options - The optional parameters.
308
- */
309
- deleteRoleDefinition(roleScope, name, options = {}) {
310
- return tracing_js_1.tracingClient.withSpan("KeyVaultAccessControlClient.deleteRoleDefinition", options, async (updatedOptions) => {
311
- try {
312
- await this.client.roleDefinitions.delete(roleScope, name, updatedOptions);
313
- }
314
- catch (err) {
315
- // If the role definition doesn't exist, we can consider it deleted.
316
- if (err.statusCode !== 404) {
317
- throw err;
318
- }
319
- }
320
- });
321
- }
318
+ },
319
+ updatedOptions
320
+ );
321
+ return import_mappings.mappings.roleDefinition.generatedToPublic(response);
322
+ }
323
+ );
324
+ }
325
+ /**
326
+ * Deletes a custom role definition previously created in an Azure Key Vault.
327
+ *
328
+ * Example usage:
329
+ * ```ts snippet:ReadmeSampleDeleteRoleDefinition
330
+ * import { DefaultAzureCredential } from "@azure/identity";
331
+ * import {
332
+ * KeyVaultAccessControlClient,
333
+ * KnownKeyVaultDataAction,
334
+ * KnownKeyVaultRoleScope,
335
+ * } from "@azure/keyvault-admin";
336
+ *
337
+ * const vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
338
+ * const credentials = new DefaultAzureCredential();
339
+ * const client = new KeyVaultAccessControlClient(vaultUrl, credentials);
340
+ *
341
+ * const permissions = [{ dataActions: [KnownKeyVaultDataAction.BackupHsmKeys] }];
342
+ * const roleDefinitionName = "23b8bb1a-39c0-4c89-a85b-dd3c99273a8a";
343
+ * const roleDefinition = await client.setRoleDefinition(KnownKeyVaultRoleScope.Global, {
344
+ * permissions,
345
+ * roleDefinitionName,
346
+ * });
347
+ *
348
+ * await client.deleteRoleDefinition("/", roleDefinition.name);
349
+ * ```
350
+ * @param roleScope - The scope of the role definition.
351
+ * @param name - The name of the role definition to delete.
352
+ * @param options - The optional parameters.
353
+ */
354
+ deleteRoleDefinition(roleScope, name, options = {}) {
355
+ return import_tracing.tracingClient.withSpan(
356
+ "KeyVaultAccessControlClient.deleteRoleDefinition",
357
+ options,
358
+ async (updatedOptions) => {
359
+ try {
360
+ await this.client.roleDefinitions.delete(roleScope, name, updatedOptions);
361
+ } catch (err) {
362
+ if (err.statusCode !== 404) {
363
+ throw err;
364
+ }
365
+ }
366
+ }
367
+ );
368
+ }
322
369
  }
323
- exports.KeyVaultAccessControlClient = KeyVaultAccessControlClient;
324
- //# sourceMappingURL=accessControlClient.js.map
370
+ // Annotate the CommonJS export names for ESM import in node:
371
+ 0 && (module.exports = {
372
+ KeyVaultAccessControlClient
373
+ });