@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.
- package/dist/commonjs/accessControlClient.js +369 -320
- package/dist/commonjs/accessControlClient.js.map +7 -1
- package/dist/commonjs/accessControlModels.js +29 -9
- package/dist/commonjs/accessControlModels.js.map +7 -1
- package/dist/commonjs/api/index.js +50 -20
- package/dist/commonjs/api/index.js.map +7 -1
- package/dist/commonjs/api/keyVaultContext.js +54 -39
- package/dist/commonjs/api/keyVaultContext.js.map +7 -1
- package/dist/commonjs/api/operations.js +408 -323
- package/dist/commonjs/api/operations.js.map +7 -1
- package/dist/commonjs/api/options.js +15 -5
- package/dist/commonjs/api/options.js.map +7 -1
- package/dist/commonjs/api/roleAssignments/index.js +33 -11
- package/dist/commonjs/api/roleAssignments/index.js.map +7 -1
- package/dist/commonjs/api/roleAssignments/operations.js +167 -123
- package/dist/commonjs/api/roleAssignments/operations.js.map +7 -1
- package/dist/commonjs/api/roleAssignments/options.js +15 -5
- package/dist/commonjs/api/roleAssignments/options.js.map +7 -1
- package/dist/commonjs/api/roleDefinitions/index.js +33 -11
- package/dist/commonjs/api/roleDefinitions/index.js.map +7 -1
- package/dist/commonjs/api/roleDefinitions/operations.js +167 -123
- package/dist/commonjs/api/roleDefinitions/operations.js.map +7 -1
- package/dist/commonjs/api/roleDefinitions/options.js +15 -5
- package/dist/commonjs/api/roleDefinitions/options.js.map +7 -1
- package/dist/commonjs/backupClient.js +232 -193
- package/dist/commonjs/backupClient.js.map +7 -1
- package/dist/commonjs/backupClientModels.js +15 -5
- package/dist/commonjs/backupClientModels.js.map +7 -1
- package/dist/commonjs/classic/index.js +15 -5
- package/dist/commonjs/classic/index.js.map +7 -1
- package/dist/commonjs/classic/roleAssignments/index.js +36 -16
- package/dist/commonjs/classic/roleAssignments/index.js.map +7 -1
- package/dist/commonjs/classic/roleDefinitions/index.js +36 -16
- package/dist/commonjs/classic/roleDefinitions/index.js.map +7 -1
- package/dist/commonjs/constants.js +30 -14
- package/dist/commonjs/constants.js.map +7 -1
- package/dist/commonjs/createKeyVaultClient.js +59 -40
- package/dist/commonjs/createKeyVaultClient.js.map +7 -1
- package/dist/commonjs/index.js +38 -14
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/keyVaultClient.js +95 -78
- package/dist/commonjs/keyVaultClient.js.map +7 -1
- package/dist/commonjs/logger.js +28 -8
- package/dist/commonjs/logger.js.map +7 -1
- package/dist/commonjs/lro/models.js +15 -5
- package/dist/commonjs/lro/models.js.map +7 -1
- package/dist/commonjs/lro/shim.js +105 -89
- package/dist/commonjs/lro/shim.js.map +7 -1
- package/dist/commonjs/mappings.js +94 -81
- package/dist/commonjs/mappings.js.map +7 -1
- package/dist/commonjs/models/index.js +39 -14
- package/dist/commonjs/models/index.js.map +7 -1
- package/dist/commonjs/models/models.js +322 -346
- package/dist/commonjs/models/models.js.map +7 -1
- package/dist/commonjs/restorePollerHelpers.js +108 -99
- package/dist/commonjs/restorePollerHelpers.js.map +7 -1
- package/dist/commonjs/settingsClient.js +102 -88
- package/dist/commonjs/settingsClient.js.map +7 -1
- package/dist/commonjs/settingsClientModels.js +15 -5
- package/dist/commonjs/settingsClientModels.js.map +7 -1
- package/dist/commonjs/static-helpers/pagingHelpers.js +109 -103
- package/dist/commonjs/static-helpers/pagingHelpers.js.map +7 -1
- package/dist/commonjs/static-helpers/pollingHelpers.js +86 -76
- package/dist/commonjs/static-helpers/pollingHelpers.js.map +7 -1
- package/dist/commonjs/static-helpers/urlTemplate.js +146 -145
- package/dist/commonjs/static-helpers/urlTemplate.js.map +7 -1
- package/dist/commonjs/tracing.js +32 -12
- package/dist/commonjs/tracing.js.map +7 -1
- package/package.json +4 -17
|
@@ -1,324 +1,373 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
324
|
-
|
|
370
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
371
|
+
0 && (module.exports = {
|
|
372
|
+
KeyVaultAccessControlClient
|
|
373
|
+
});
|