@databricks/sdk-accessmanagement 0.34.0 → 0.36.0
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/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/v1/client.d.ts +62 -58
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +365 -455
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +3 -7
- package/dist/v1/index.js +4 -7
- package/dist/v1/model.d.ts +336 -343
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +239 -345
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +21 -17
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +60 -69
- package/dist/v1/transport.js.map +1 -1
- package/dist/v1/utils.d.ts +18 -14
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +76 -103
- package/dist/v1/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/v1/index.d.ts.map +0 -1
- package/dist/v1/index.js.map +0 -1
package/dist/v1/client.js
CHANGED
|
@@ -1,458 +1,368 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { resolveClientConfig } from "./transport.js";
|
|
2
|
+
import { buildHttpRequest, executeCall, executeHttpCall, flattenQueryParams, marshalRequest, parseResponse } from "./utils.js";
|
|
3
|
+
import { name, version } from "../package.js";
|
|
4
|
+
import { marshalActorSchema, marshalConsistencyTokenSchema, marshalResourceInfoSchema, marshalSetObjectPermissionsRequestSchema, marshalUpdateObjectPermissionsRequestSchema, marshalUpdateRuleSetRequestSchema, marshalUpdateWorkspacePermissionAssignmentRequestSchema, unmarshalCheckPolicyResponseSchema, unmarshalDeleteWorkspacePermissionAssignmentResponseSchema, unmarshalListAssignableRolesForResourceResponseSchema, unmarshalListPermissionLevelsResponseSchema, unmarshalListWorkspacePermissionAssignmentsResponseSchema, unmarshalListWorkspacePermissionsResponseSchema, unmarshalPermissionsResponseSchema, unmarshalRuleSetSchema, unmarshalWorkspacePermissionAssignmentOutputSchema } from "./model.js";
|
|
5
|
+
import { VERSION } from "@databricks/sdk-auth";
|
|
6
|
+
import { createDefault } from "@databricks/sdk-core/clientinfo";
|
|
7
|
+
import { NoOpLogger } from "@databricks/sdk-core/logger";
|
|
8
|
+
|
|
9
|
+
//#region src/v1/client.ts
|
|
10
10
|
const PACKAGE_SEGMENT = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
|
|
12
|
+
value: version
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
369
|
-
}
|
|
370
|
-
headers.set('User-Agent', this.userAgent);
|
|
371
|
-
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
372
|
-
const respBody = await executeHttpCall({
|
|
373
|
-
request: httpReq,
|
|
374
|
-
httpClient,
|
|
375
|
-
logger: this.logger,
|
|
376
|
-
});
|
|
377
|
-
resp = parseResponse(respBody, unmarshalPermissionsResponseSchema);
|
|
378
|
-
};
|
|
379
|
-
await executeCall(call, options);
|
|
380
|
-
if (resp === undefined) {
|
|
381
|
-
throw new Error('operation completed without a result.');
|
|
382
|
-
}
|
|
383
|
-
return resp;
|
|
384
|
-
}
|
|
385
|
-
/** Updates the permissions on an object. Objects can inherit permissions from their parent objects or root object. */
|
|
386
|
-
async updateObjectPermissions(req, options) {
|
|
387
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
388
|
-
const url = `${host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`;
|
|
389
|
-
const body = marshalRequest(req, marshalUpdateObjectPermissionsRequestSchema);
|
|
390
|
-
let resp;
|
|
391
|
-
const call = async (callSignal) => {
|
|
392
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
393
|
-
if (workspaceId !== undefined) {
|
|
394
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
395
|
-
}
|
|
396
|
-
headers.set('User-Agent', this.userAgent);
|
|
397
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
398
|
-
const respBody = await executeHttpCall({
|
|
399
|
-
request: httpReq,
|
|
400
|
-
httpClient,
|
|
401
|
-
logger: this.logger,
|
|
402
|
-
});
|
|
403
|
-
resp = parseResponse(respBody, unmarshalPermissionsResponseSchema);
|
|
404
|
-
};
|
|
405
|
-
await executeCall(call, options);
|
|
406
|
-
if (resp === undefined) {
|
|
407
|
-
throw new Error('operation completed without a result.');
|
|
408
|
-
}
|
|
409
|
-
return resp;
|
|
410
|
-
}
|
|
411
|
-
/** Check access policy to a resource. */
|
|
412
|
-
async checkPolicy(req, options) {
|
|
413
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
414
|
-
const url = `${host}/api/2.0/access-control/check-policy-v2`;
|
|
415
|
-
const params = new URLSearchParams();
|
|
416
|
-
if (req.actor !== undefined) {
|
|
417
|
-
flattenQueryParams('actor', marshalActorSchema.parse(req.actor), params);
|
|
418
|
-
}
|
|
419
|
-
if (req.permission !== undefined) {
|
|
420
|
-
params.append('permission', req.permission);
|
|
421
|
-
}
|
|
422
|
-
if (req.resource !== undefined) {
|
|
423
|
-
params.append('resource', req.resource);
|
|
424
|
-
}
|
|
425
|
-
if (req.consistencyToken !== undefined) {
|
|
426
|
-
flattenQueryParams('consistency_token', marshalConsistencyTokenSchema.parse(req.consistencyToken), params);
|
|
427
|
-
}
|
|
428
|
-
if (req.authzIdentity !== undefined) {
|
|
429
|
-
params.append('authz_identity', req.authzIdentity);
|
|
430
|
-
}
|
|
431
|
-
if (req.resourceInfo !== undefined) {
|
|
432
|
-
flattenQueryParams('resource_info', marshalResourceInfoSchema.parse(req.resourceInfo), params);
|
|
433
|
-
}
|
|
434
|
-
const query = params.toString();
|
|
435
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
436
|
-
let resp;
|
|
437
|
-
const call = async (callSignal) => {
|
|
438
|
-
const headers = new Headers();
|
|
439
|
-
if (workspaceId !== undefined) {
|
|
440
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
441
|
-
}
|
|
442
|
-
headers.set('User-Agent', this.userAgent);
|
|
443
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
444
|
-
const respBody = await executeHttpCall({
|
|
445
|
-
request: httpReq,
|
|
446
|
-
httpClient,
|
|
447
|
-
logger: this.logger,
|
|
448
|
-
});
|
|
449
|
-
resp = parseResponse(respBody, unmarshalCheckPolicyResponseSchema);
|
|
450
|
-
};
|
|
451
|
-
await executeCall(call, options);
|
|
452
|
-
if (resp === undefined) {
|
|
453
|
-
throw new Error('operation completed without a result.');
|
|
454
|
-
}
|
|
455
|
-
return resp;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
14
|
+
var AccessManagementClient = class {
|
|
15
|
+
options;
|
|
16
|
+
logger;
|
|
17
|
+
userAgent;
|
|
18
|
+
config;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
22
|
+
this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
|
|
23
|
+
key: "sdk-js-auth",
|
|
24
|
+
value: VERSION
|
|
25
|
+
}).with({
|
|
26
|
+
key: "auth",
|
|
27
|
+
value: options.credentials?.name() ?? "default"
|
|
28
|
+
}).toString();
|
|
29
|
+
}
|
|
30
|
+
resolveConfig() {
|
|
31
|
+
this.config ??= resolveClientConfig(this.options);
|
|
32
|
+
return this.config;
|
|
33
|
+
}
|
|
34
|
+
/** Deletes the workspace permissions assignment in a given account and workspace for the specified principal. */
|
|
35
|
+
async deleteWorkspacePermissionAssignment(req, options) {
|
|
36
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
37
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/permissionassignments/principals/${String(req.principalId ?? "")}`;
|
|
38
|
+
let resp;
|
|
39
|
+
const call = async (callSignal) => {
|
|
40
|
+
const headers = new Headers();
|
|
41
|
+
headers.set("User-Agent", this.userAgent);
|
|
42
|
+
resp = parseResponse(await executeHttpCall({
|
|
43
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
44
|
+
httpClient,
|
|
45
|
+
logger: this.logger
|
|
46
|
+
}), unmarshalDeleteWorkspacePermissionAssignmentResponseSchema);
|
|
47
|
+
};
|
|
48
|
+
await executeCall(call, options);
|
|
49
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
50
|
+
return resp;
|
|
51
|
+
}
|
|
52
|
+
/** Get the permission assignments for the specified <Account> and <Workspace>. */
|
|
53
|
+
async listWorkspacePermissionAssignments(req, options) {
|
|
54
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
55
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/permissionassignments`;
|
|
56
|
+
let resp;
|
|
57
|
+
const call = async (callSignal) => {
|
|
58
|
+
const headers = new Headers();
|
|
59
|
+
headers.set("User-Agent", this.userAgent);
|
|
60
|
+
resp = parseResponse(await executeHttpCall({
|
|
61
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
62
|
+
httpClient,
|
|
63
|
+
logger: this.logger
|
|
64
|
+
}), unmarshalListWorkspacePermissionAssignmentsResponseSchema);
|
|
65
|
+
};
|
|
66
|
+
await executeCall(call, options);
|
|
67
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
68
|
+
return resp;
|
|
69
|
+
}
|
|
70
|
+
/** Get an array of workspace permissions for the specified account and workspace. */
|
|
71
|
+
async listWorkspacePermissions(req, options) {
|
|
72
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
73
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/permissionassignments/permissions`;
|
|
74
|
+
let resp;
|
|
75
|
+
const call = async (callSignal) => {
|
|
76
|
+
const headers = new Headers();
|
|
77
|
+
headers.set("User-Agent", this.userAgent);
|
|
78
|
+
resp = parseResponse(await executeHttpCall({
|
|
79
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
80
|
+
httpClient,
|
|
81
|
+
logger: this.logger
|
|
82
|
+
}), unmarshalListWorkspacePermissionsResponseSchema);
|
|
83
|
+
};
|
|
84
|
+
await executeCall(call, options);
|
|
85
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
86
|
+
return resp;
|
|
87
|
+
}
|
|
88
|
+
/** Creates or updates the workspace permissions assignment in a given account and workspace for the specified principal. */
|
|
89
|
+
async updateWorkspacePermissionAssignment(req, options) {
|
|
90
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
91
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/permissionassignments/principals/${String(req.principalId ?? "")}`;
|
|
92
|
+
const body = marshalRequest(req, marshalUpdateWorkspacePermissionAssignmentRequestSchema);
|
|
93
|
+
let resp;
|
|
94
|
+
const call = async (callSignal) => {
|
|
95
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
96
|
+
headers.set("User-Agent", this.userAgent);
|
|
97
|
+
resp = parseResponse(await executeHttpCall({
|
|
98
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
99
|
+
httpClient,
|
|
100
|
+
logger: this.logger
|
|
101
|
+
}), unmarshalWorkspacePermissionAssignmentOutputSchema);
|
|
102
|
+
};
|
|
103
|
+
await executeCall(call, options);
|
|
104
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
105
|
+
return resp;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get a rule set by its name. A rule set is always attached to a resource and contains a list of access rules on the
|
|
109
|
+
* said resource. Currently only a default rule set for each resource is supported.
|
|
110
|
+
*/
|
|
111
|
+
async getRuleSet(req, options) {
|
|
112
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
113
|
+
const url = `${host}/api/2.0/preview/accounts/${req.accountId ?? accountId ?? ""}/access-control/rule-sets`;
|
|
114
|
+
const params = new URLSearchParams();
|
|
115
|
+
if (req.name !== void 0) params.append("name", req.name);
|
|
116
|
+
if (req.etag !== void 0) params.append("etag", req.etag);
|
|
117
|
+
const query = params.toString();
|
|
118
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
119
|
+
let resp;
|
|
120
|
+
const call = async (callSignal) => {
|
|
121
|
+
const headers = new Headers();
|
|
122
|
+
headers.set("User-Agent", this.userAgent);
|
|
123
|
+
resp = parseResponse(await executeHttpCall({
|
|
124
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
125
|
+
httpClient,
|
|
126
|
+
logger: this.logger
|
|
127
|
+
}), unmarshalRuleSetSchema);
|
|
128
|
+
};
|
|
129
|
+
await executeCall(call, options);
|
|
130
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
131
|
+
return resp;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get a rule set by its name. A rule set is always attached to a resource and contains a list of access rules on the
|
|
135
|
+
* said resource. Currently only a default rule set for each resource is supported.
|
|
136
|
+
*/
|
|
137
|
+
async getRuleSetProxy(req, options) {
|
|
138
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
139
|
+
const url = `${host}/api/2.0/preview/accounts/access-control/rule-sets`;
|
|
140
|
+
const params = new URLSearchParams();
|
|
141
|
+
if (req.accountId !== void 0) params.append("account_id", req.accountId);
|
|
142
|
+
if (req.name !== void 0) params.append("name", req.name);
|
|
143
|
+
if (req.etag !== void 0) params.append("etag", req.etag);
|
|
144
|
+
const query = params.toString();
|
|
145
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
146
|
+
let resp;
|
|
147
|
+
const call = async (callSignal) => {
|
|
148
|
+
const headers = new Headers();
|
|
149
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
150
|
+
headers.set("User-Agent", this.userAgent);
|
|
151
|
+
resp = parseResponse(await executeHttpCall({
|
|
152
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
153
|
+
httpClient,
|
|
154
|
+
logger: this.logger
|
|
155
|
+
}), unmarshalRuleSetSchema);
|
|
156
|
+
};
|
|
157
|
+
await executeCall(call, options);
|
|
158
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
159
|
+
return resp;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the
|
|
163
|
+
* resource can contain an access rule of the role.
|
|
164
|
+
*/
|
|
165
|
+
async listAssignableRolesForResource(req, options) {
|
|
166
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
167
|
+
const url = `${host}/api/2.0/preview/accounts/${req.accountId ?? accountId ?? ""}/access-control/assignable-roles`;
|
|
168
|
+
const params = new URLSearchParams();
|
|
169
|
+
if (req.resource !== void 0) params.append("resource", req.resource);
|
|
170
|
+
const query = params.toString();
|
|
171
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
172
|
+
let resp;
|
|
173
|
+
const call = async (callSignal) => {
|
|
174
|
+
const headers = new Headers();
|
|
175
|
+
headers.set("User-Agent", this.userAgent);
|
|
176
|
+
resp = parseResponse(await executeHttpCall({
|
|
177
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
178
|
+
httpClient,
|
|
179
|
+
logger: this.logger
|
|
180
|
+
}), unmarshalListAssignableRolesForResourceResponseSchema);
|
|
181
|
+
};
|
|
182
|
+
await executeCall(call, options);
|
|
183
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
184
|
+
return resp;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the
|
|
188
|
+
* resource can contain an access rule of the role.
|
|
189
|
+
*/
|
|
190
|
+
async listAssignableRolesForResourceProxy(req, options) {
|
|
191
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
192
|
+
const url = `${host}/api/2.0/preview/accounts/access-control/assignable-roles`;
|
|
193
|
+
const params = new URLSearchParams();
|
|
194
|
+
if (req.accountId !== void 0) params.append("account_id", req.accountId);
|
|
195
|
+
if (req.resource !== void 0) params.append("resource", req.resource);
|
|
196
|
+
const query = params.toString();
|
|
197
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
198
|
+
let resp;
|
|
199
|
+
const call = async (callSignal) => {
|
|
200
|
+
const headers = new Headers();
|
|
201
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
202
|
+
headers.set("User-Agent", this.userAgent);
|
|
203
|
+
resp = parseResponse(await executeHttpCall({
|
|
204
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
205
|
+
httpClient,
|
|
206
|
+
logger: this.logger
|
|
207
|
+
}), unmarshalListAssignableRolesForResourceResponseSchema);
|
|
208
|
+
};
|
|
209
|
+
await executeCall(call, options);
|
|
210
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
211
|
+
return resp;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it.
|
|
215
|
+
* This pattern helps prevent conflicts between concurrent updates.
|
|
216
|
+
*/
|
|
217
|
+
async updateRuleSet(req, options) {
|
|
218
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
219
|
+
const url = `${host}/api/2.0/preview/accounts/${req.accountId ?? accountId ?? ""}/access-control/rule-sets`;
|
|
220
|
+
const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema);
|
|
221
|
+
let resp;
|
|
222
|
+
const call = async (callSignal) => {
|
|
223
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
224
|
+
headers.set("User-Agent", this.userAgent);
|
|
225
|
+
resp = parseResponse(await executeHttpCall({
|
|
226
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
227
|
+
httpClient,
|
|
228
|
+
logger: this.logger
|
|
229
|
+
}), unmarshalRuleSetSchema);
|
|
230
|
+
};
|
|
231
|
+
await executeCall(call, options);
|
|
232
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
233
|
+
return resp;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it.
|
|
237
|
+
* This pattern helps prevent conflicts between concurrent updates.
|
|
238
|
+
*/
|
|
239
|
+
async updateRuleSetProxy(req, options) {
|
|
240
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
241
|
+
const url = `${host}/api/2.0/preview/accounts/access-control/rule-sets`;
|
|
242
|
+
const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema);
|
|
243
|
+
let resp;
|
|
244
|
+
const call = async (callSignal) => {
|
|
245
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
246
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
247
|
+
headers.set("User-Agent", this.userAgent);
|
|
248
|
+
resp = parseResponse(await executeHttpCall({
|
|
249
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
250
|
+
httpClient,
|
|
251
|
+
logger: this.logger
|
|
252
|
+
}), unmarshalRuleSetSchema);
|
|
253
|
+
};
|
|
254
|
+
await executeCall(call, options);
|
|
255
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
256
|
+
return resp;
|
|
257
|
+
}
|
|
258
|
+
/** Gets the permissions of an object. Objects can inherit permissions from their parent objects or root object. */
|
|
259
|
+
async getObjectPermissions(req, options) {
|
|
260
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
261
|
+
const url = `${host}/api/2.0/permissions/${req.requestObjectType ?? ""}/${req.requestObjectId ?? ""}`;
|
|
262
|
+
let resp;
|
|
263
|
+
const call = async (callSignal) => {
|
|
264
|
+
const headers = new Headers();
|
|
265
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
266
|
+
headers.set("User-Agent", this.userAgent);
|
|
267
|
+
resp = parseResponse(await executeHttpCall({
|
|
268
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
269
|
+
httpClient,
|
|
270
|
+
logger: this.logger
|
|
271
|
+
}), unmarshalPermissionsResponseSchema);
|
|
272
|
+
};
|
|
273
|
+
await executeCall(call, options);
|
|
274
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
275
|
+
return resp;
|
|
276
|
+
}
|
|
277
|
+
/** Gets the permission levels that a user can have on an object. */
|
|
278
|
+
async listPermissionLevels(req, options) {
|
|
279
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
280
|
+
const url = `${host}/api/2.0/permissions/${req.requestObjectType ?? ""}/${req.requestObjectId ?? ""}/permissionLevels`;
|
|
281
|
+
let resp;
|
|
282
|
+
const call = async (callSignal) => {
|
|
283
|
+
const headers = new Headers();
|
|
284
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
285
|
+
headers.set("User-Agent", this.userAgent);
|
|
286
|
+
resp = parseResponse(await executeHttpCall({
|
|
287
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
288
|
+
httpClient,
|
|
289
|
+
logger: this.logger
|
|
290
|
+
}), unmarshalListPermissionLevelsResponseSchema);
|
|
291
|
+
};
|
|
292
|
+
await executeCall(call, options);
|
|
293
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
294
|
+
return resp;
|
|
295
|
+
}
|
|
296
|
+
/** Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct permissions if none are specified. Objects can inherit permissions from their parent objects or root object. */
|
|
297
|
+
async setObjectPermissions(req, options) {
|
|
298
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
299
|
+
const url = `${host}/api/2.0/permissions/${req.requestObjectType ?? ""}/${req.requestObjectId ?? ""}`;
|
|
300
|
+
const body = marshalRequest(req, marshalSetObjectPermissionsRequestSchema);
|
|
301
|
+
let resp;
|
|
302
|
+
const call = async (callSignal) => {
|
|
303
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
304
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
305
|
+
headers.set("User-Agent", this.userAgent);
|
|
306
|
+
resp = parseResponse(await executeHttpCall({
|
|
307
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
308
|
+
httpClient,
|
|
309
|
+
logger: this.logger
|
|
310
|
+
}), unmarshalPermissionsResponseSchema);
|
|
311
|
+
};
|
|
312
|
+
await executeCall(call, options);
|
|
313
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
314
|
+
return resp;
|
|
315
|
+
}
|
|
316
|
+
/** Updates the permissions on an object. Objects can inherit permissions from their parent objects or root object. */
|
|
317
|
+
async updateObjectPermissions(req, options) {
|
|
318
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
319
|
+
const url = `${host}/api/2.0/permissions/${req.requestObjectType ?? ""}/${req.requestObjectId ?? ""}`;
|
|
320
|
+
const body = marshalRequest(req, marshalUpdateObjectPermissionsRequestSchema);
|
|
321
|
+
let resp;
|
|
322
|
+
const call = async (callSignal) => {
|
|
323
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
324
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
325
|
+
headers.set("User-Agent", this.userAgent);
|
|
326
|
+
resp = parseResponse(await executeHttpCall({
|
|
327
|
+
request: buildHttpRequest("PATCH", url, headers, callSignal, body),
|
|
328
|
+
httpClient,
|
|
329
|
+
logger: this.logger
|
|
330
|
+
}), unmarshalPermissionsResponseSchema);
|
|
331
|
+
};
|
|
332
|
+
await executeCall(call, options);
|
|
333
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
334
|
+
return resp;
|
|
335
|
+
}
|
|
336
|
+
/** Check access policy to a resource. */
|
|
337
|
+
async checkPolicy(req, options) {
|
|
338
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
339
|
+
const url = `${host}/api/2.0/access-control/check-policy-v2`;
|
|
340
|
+
const params = new URLSearchParams();
|
|
341
|
+
if (req.actor !== void 0) flattenQueryParams("actor", marshalActorSchema.parse(req.actor), params);
|
|
342
|
+
if (req.permission !== void 0) params.append("permission", req.permission);
|
|
343
|
+
if (req.resource !== void 0) params.append("resource", req.resource);
|
|
344
|
+
if (req.consistencyToken !== void 0) flattenQueryParams("consistency_token", marshalConsistencyTokenSchema.parse(req.consistencyToken), params);
|
|
345
|
+
if (req.authzIdentity !== void 0) params.append("authz_identity", req.authzIdentity);
|
|
346
|
+
if (req.resourceInfo !== void 0) flattenQueryParams("resource_info", marshalResourceInfoSchema.parse(req.resourceInfo), params);
|
|
347
|
+
const query = params.toString();
|
|
348
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
349
|
+
let resp;
|
|
350
|
+
const call = async (callSignal) => {
|
|
351
|
+
const headers = new Headers();
|
|
352
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
353
|
+
headers.set("User-Agent", this.userAgent);
|
|
354
|
+
resp = parseResponse(await executeHttpCall({
|
|
355
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
356
|
+
httpClient,
|
|
357
|
+
logger: this.logger
|
|
358
|
+
}), unmarshalCheckPolicyResponseSchema);
|
|
359
|
+
};
|
|
360
|
+
await executeCall(call, options);
|
|
361
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
362
|
+
return resp;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
//#endregion
|
|
367
|
+
export { AccessManagementClient };
|
|
458
368
|
//# sourceMappingURL=client.js.map
|