@databricks/sdk-accessmanagement 0.0.0-dev → 0.1.0-dev.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.
@@ -0,0 +1,598 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
5
+ import type {Logger} from '@databricks/sdk-core/logger';
6
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
7
+ import type {CallOptions} from '@databricks/sdk-options/call';
8
+ import type {ClientOptions} from '@databricks/sdk-options/client';
9
+ import type {HttpClient} from '@databricks/sdk-core/http';
10
+ import {newHttpClient} from './transport';
11
+ import {
12
+ buildHttpRequest,
13
+ executeCall,
14
+ executeHttpCall,
15
+ marshalRequest,
16
+ parseResponse,
17
+ flattenQueryParams,
18
+ } from './utils';
19
+ import pkgJson from '../../package.json' with {type: 'json'};
20
+ import type {
21
+ CheckPolicyRequest,
22
+ CheckPolicyResponse,
23
+ DeleteWorkspacePermissionAssignmentRequest,
24
+ DeleteWorkspacePermissionAssignmentRequest_Response,
25
+ GetObjectPermissionsRequest,
26
+ GetRuleSetRequest,
27
+ ListAssignableRolesForResourceRequest,
28
+ ListAssignableRolesForResourceResponse,
29
+ ListPermissionLevelsRequest,
30
+ ListPermissionLevelsRequest_Response,
31
+ ListWorkspacePermissionAssignmentsRequest,
32
+ ListWorkspacePermissionAssignmentsRequest_Response,
33
+ ListWorkspacePermissionsRequest,
34
+ ListWorkspacePermissionsRequest_Response,
35
+ PermissionsResponse,
36
+ RuleSet,
37
+ SetObjectPermissionsRequest,
38
+ UpdateObjectPermissionsRequest,
39
+ UpdateRuleSetRequest,
40
+ UpdateWorkspacePermissionAssignmentRequest,
41
+ WorkspacePermissionAssignmentOutput,
42
+ } from './model';
43
+ import {
44
+ marshalActorSchema,
45
+ marshalConsistencyTokenSchema,
46
+ marshalResourceInfoSchema,
47
+ marshalSetObjectPermissionsRequestSchema,
48
+ marshalUpdateObjectPermissionsRequestSchema,
49
+ marshalUpdateRuleSetRequestSchema,
50
+ marshalUpdateWorkspacePermissionAssignmentRequestSchema,
51
+ unmarshalCheckPolicyResponseSchema,
52
+ unmarshalDeleteWorkspacePermissionAssignmentRequest_ResponseSchema,
53
+ unmarshalListAssignableRolesForResourceResponseSchema,
54
+ unmarshalListPermissionLevelsRequest_ResponseSchema,
55
+ unmarshalListWorkspacePermissionAssignmentsRequest_ResponseSchema,
56
+ unmarshalListWorkspacePermissionsRequest_ResponseSchema,
57
+ unmarshalPermissionsResponseSchema,
58
+ unmarshalRuleSetSchema,
59
+ unmarshalWorkspacePermissionAssignmentOutputSchema,
60
+ } from './model';
61
+
62
+ // Package identity segment for this client to be used in the User-Agent header.
63
+ const PACKAGE_SEGMENT = {
64
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
65
+ value: pkgJson.version,
66
+ };
67
+
68
+ export class AccessManagementClient {
69
+ private readonly host: string;
70
+ // Fallback for endpoints whose path contains {account_id}. If the request
71
+ // already carries an accountId, that value wins.
72
+ private readonly accountId: string | undefined;
73
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
74
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
75
+ // request.
76
+ private readonly workspaceId: string | undefined;
77
+ private readonly httpClient: HttpClient;
78
+ private readonly logger: Logger;
79
+ // User-Agent header value. Composed once at construction from
80
+ // createDefault() merged with this package's identity and the active
81
+ // credential's name.
82
+ private readonly userAgent: string;
83
+
84
+ constructor(options: ClientOptions) {
85
+ if (options.host === undefined) {
86
+ throw new Error('Host is required.');
87
+ }
88
+ this.host = options.host.replace(/\/$/, '');
89
+ this.accountId = options.accountId;
90
+ this.workspaceId = options.workspaceId;
91
+ this.logger = options.logger ?? new NoOpLogger();
92
+ const info = createDefault()
93
+ .with(PACKAGE_SEGMENT)
94
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
95
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
96
+ this.userAgent = info.toString();
97
+ this.httpClient = newHttpClient(options);
98
+ }
99
+
100
+ /** Deletes the workspace permissions assignment in a given account and workspace for the specified principal. */
101
+ async deleteWorkspacePermissionAssignment(
102
+ req: DeleteWorkspacePermissionAssignmentRequest,
103
+ options?: CallOptions
104
+ ): Promise<DeleteWorkspacePermissionAssignmentRequest_Response> {
105
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/permissionassignments/principals/${String(req.principalId ?? '')}`;
106
+ let resp: DeleteWorkspacePermissionAssignmentRequest_Response | undefined;
107
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
108
+ const headers = new Headers();
109
+ headers.set('User-Agent', this.userAgent);
110
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
111
+ const respBody = await executeHttpCall({
112
+ request: httpReq,
113
+ httpClient: this.httpClient,
114
+ logger: this.logger,
115
+ });
116
+ resp = parseResponse(
117
+ respBody,
118
+ unmarshalDeleteWorkspacePermissionAssignmentRequest_ResponseSchema
119
+ );
120
+ };
121
+ await executeCall(call, options);
122
+ if (resp === undefined) {
123
+ throw new Error('operation completed without a result.');
124
+ }
125
+ return resp;
126
+ }
127
+
128
+ /** Get the permission assignments for the specified <Account> and <Workspace>. */
129
+ async listWorkspacePermissionAssignments(
130
+ req: ListWorkspacePermissionAssignmentsRequest,
131
+ options?: CallOptions
132
+ ): Promise<ListWorkspacePermissionAssignmentsRequest_Response> {
133
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/permissionassignments`;
134
+ let resp: ListWorkspacePermissionAssignmentsRequest_Response | undefined;
135
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
136
+ const headers = new Headers();
137
+ headers.set('User-Agent', this.userAgent);
138
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
139
+ const respBody = await executeHttpCall({
140
+ request: httpReq,
141
+ httpClient: this.httpClient,
142
+ logger: this.logger,
143
+ });
144
+ resp = parseResponse(
145
+ respBody,
146
+ unmarshalListWorkspacePermissionAssignmentsRequest_ResponseSchema
147
+ );
148
+ };
149
+ await executeCall(call, options);
150
+ if (resp === undefined) {
151
+ throw new Error('operation completed without a result.');
152
+ }
153
+ return resp;
154
+ }
155
+
156
+ /** Get an array of workspace permissions for the specified account and workspace. */
157
+ async listWorkspacePermissions(
158
+ req: ListWorkspacePermissionsRequest,
159
+ options?: CallOptions
160
+ ): Promise<ListWorkspacePermissionsRequest_Response> {
161
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/permissionassignments/permissions`;
162
+ let resp: ListWorkspacePermissionsRequest_Response | undefined;
163
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
164
+ const headers = new Headers();
165
+ headers.set('User-Agent', this.userAgent);
166
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
167
+ const respBody = await executeHttpCall({
168
+ request: httpReq,
169
+ httpClient: this.httpClient,
170
+ logger: this.logger,
171
+ });
172
+ resp = parseResponse(
173
+ respBody,
174
+ unmarshalListWorkspacePermissionsRequest_ResponseSchema
175
+ );
176
+ };
177
+ await executeCall(call, options);
178
+ if (resp === undefined) {
179
+ throw new Error('operation completed without a result.');
180
+ }
181
+ return resp;
182
+ }
183
+
184
+ /** Creates or updates the workspace permissions assignment in a given account and workspace for the specified principal. */
185
+ async updateWorkspacePermissionAssignment(
186
+ req: UpdateWorkspacePermissionAssignmentRequest,
187
+ options?: CallOptions
188
+ ): Promise<WorkspacePermissionAssignmentOutput> {
189
+ const url = `${this.host}/api/2.0/accounts/${req.accountId ?? this.accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/permissionassignments/principals/${String(req.principalId ?? '')}`;
190
+ const body = marshalRequest(
191
+ req,
192
+ marshalUpdateWorkspacePermissionAssignmentRequestSchema
193
+ );
194
+ let resp: WorkspacePermissionAssignmentOutput | undefined;
195
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
196
+ const headers = new Headers({'Content-Type': 'application/json'});
197
+ headers.set('User-Agent', this.userAgent);
198
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
199
+ const respBody = await executeHttpCall({
200
+ request: httpReq,
201
+ httpClient: this.httpClient,
202
+ logger: this.logger,
203
+ });
204
+ resp = parseResponse(
205
+ respBody,
206
+ unmarshalWorkspacePermissionAssignmentOutputSchema
207
+ );
208
+ };
209
+ await executeCall(call, options);
210
+ if (resp === undefined) {
211
+ throw new Error('operation completed without a result.');
212
+ }
213
+ return resp;
214
+ }
215
+
216
+ /**
217
+ * 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
218
+ * said resource. Currently only a default rule set for each resource is supported.
219
+ */
220
+ async getRuleSet(
221
+ req: GetRuleSetRequest,
222
+ options?: CallOptions
223
+ ): Promise<RuleSet> {
224
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/rule-sets`;
225
+ const params = new URLSearchParams();
226
+ if (req.name !== undefined) {
227
+ params.append('name', req.name);
228
+ }
229
+ if (req.etag !== undefined) {
230
+ params.append('etag', req.etag);
231
+ }
232
+ const query = params.toString();
233
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
234
+ let resp: RuleSet | undefined;
235
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
236
+ const headers = new Headers();
237
+ headers.set('User-Agent', this.userAgent);
238
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
239
+ const respBody = await executeHttpCall({
240
+ request: httpReq,
241
+ httpClient: this.httpClient,
242
+ logger: this.logger,
243
+ });
244
+ resp = parseResponse(respBody, unmarshalRuleSetSchema);
245
+ };
246
+ await executeCall(call, options);
247
+ if (resp === undefined) {
248
+ throw new Error('operation completed without a result.');
249
+ }
250
+ return resp;
251
+ }
252
+
253
+ /**
254
+ * 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
255
+ * said resource. Currently only a default rule set for each resource is supported.
256
+ */
257
+ async getRuleSetProxy(
258
+ req: GetRuleSetRequest,
259
+ options?: CallOptions
260
+ ): Promise<RuleSet> {
261
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/rule-sets`;
262
+ const params = new URLSearchParams();
263
+ if (req.name !== undefined) {
264
+ params.append('name', req.name);
265
+ }
266
+ if (req.etag !== undefined) {
267
+ params.append('etag', req.etag);
268
+ }
269
+ const query = params.toString();
270
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
271
+ let resp: RuleSet | undefined;
272
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
273
+ const headers = new Headers();
274
+ headers.set('User-Agent', this.userAgent);
275
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
276
+ const respBody = await executeHttpCall({
277
+ request: httpReq,
278
+ httpClient: this.httpClient,
279
+ logger: this.logger,
280
+ });
281
+ resp = parseResponse(respBody, unmarshalRuleSetSchema);
282
+ };
283
+ await executeCall(call, options);
284
+ if (resp === undefined) {
285
+ throw new Error('operation completed without a result.');
286
+ }
287
+ return resp;
288
+ }
289
+
290
+ /**
291
+ * Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the
292
+ * resource can contain an access rule of the role.
293
+ */
294
+ async listAssignableRolesForResource(
295
+ req: ListAssignableRolesForResourceRequest,
296
+ options?: CallOptions
297
+ ): Promise<ListAssignableRolesForResourceResponse> {
298
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/assignable-roles`;
299
+ const params = new URLSearchParams();
300
+ if (req.resource !== undefined) {
301
+ params.append('resource', req.resource);
302
+ }
303
+ const query = params.toString();
304
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
305
+ let resp: ListAssignableRolesForResourceResponse | undefined;
306
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
307
+ const headers = new Headers();
308
+ headers.set('User-Agent', this.userAgent);
309
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
310
+ const respBody = await executeHttpCall({
311
+ request: httpReq,
312
+ httpClient: this.httpClient,
313
+ logger: this.logger,
314
+ });
315
+ resp = parseResponse(
316
+ respBody,
317
+ unmarshalListAssignableRolesForResourceResponseSchema
318
+ );
319
+ };
320
+ await executeCall(call, options);
321
+ if (resp === undefined) {
322
+ throw new Error('operation completed without a result.');
323
+ }
324
+ return resp;
325
+ }
326
+
327
+ /**
328
+ * Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the
329
+ * resource can contain an access rule of the role.
330
+ */
331
+ async listAssignableRolesForResourceProxy(
332
+ req: ListAssignableRolesForResourceRequest,
333
+ options?: CallOptions
334
+ ): Promise<ListAssignableRolesForResourceResponse> {
335
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/assignable-roles`;
336
+ const params = new URLSearchParams();
337
+ if (req.resource !== undefined) {
338
+ params.append('resource', req.resource);
339
+ }
340
+ const query = params.toString();
341
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
342
+ let resp: ListAssignableRolesForResourceResponse | undefined;
343
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
344
+ const headers = new Headers();
345
+ headers.set('User-Agent', this.userAgent);
346
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
347
+ const respBody = await executeHttpCall({
348
+ request: httpReq,
349
+ httpClient: this.httpClient,
350
+ logger: this.logger,
351
+ });
352
+ resp = parseResponse(
353
+ respBody,
354
+ unmarshalListAssignableRolesForResourceResponseSchema
355
+ );
356
+ };
357
+ await executeCall(call, options);
358
+ if (resp === undefined) {
359
+ throw new Error('operation completed without a result.');
360
+ }
361
+ return resp;
362
+ }
363
+
364
+ /**
365
+ * Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it.
366
+ * This pattern helps prevent conflicts between concurrent updates.
367
+ */
368
+ async updateRuleSet(
369
+ req: UpdateRuleSetRequest,
370
+ options?: CallOptions
371
+ ): Promise<RuleSet> {
372
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/rule-sets`;
373
+ const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema);
374
+ let resp: RuleSet | undefined;
375
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
376
+ const headers = new Headers({'Content-Type': 'application/json'});
377
+ headers.set('User-Agent', this.userAgent);
378
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
379
+ const respBody = await executeHttpCall({
380
+ request: httpReq,
381
+ httpClient: this.httpClient,
382
+ logger: this.logger,
383
+ });
384
+ resp = parseResponse(respBody, unmarshalRuleSetSchema);
385
+ };
386
+ await executeCall(call, options);
387
+ if (resp === undefined) {
388
+ throw new Error('operation completed without a result.');
389
+ }
390
+ return resp;
391
+ }
392
+
393
+ /**
394
+ * Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it.
395
+ * This pattern helps prevent conflicts between concurrent updates.
396
+ */
397
+ async updateRuleSetProxy(
398
+ req: UpdateRuleSetRequest,
399
+ options?: CallOptions
400
+ ): Promise<RuleSet> {
401
+ const url = `${this.host}/api/2.0/preview/accounts/${req.accountId ?? this.accountId ?? ''}/access-control/rule-sets`;
402
+ const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema);
403
+ let resp: RuleSet | undefined;
404
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
405
+ const headers = new Headers({'Content-Type': 'application/json'});
406
+ headers.set('User-Agent', this.userAgent);
407
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
408
+ const respBody = await executeHttpCall({
409
+ request: httpReq,
410
+ httpClient: this.httpClient,
411
+ logger: this.logger,
412
+ });
413
+ resp = parseResponse(respBody, unmarshalRuleSetSchema);
414
+ };
415
+ await executeCall(call, options);
416
+ if (resp === undefined) {
417
+ throw new Error('operation completed without a result.');
418
+ }
419
+ return resp;
420
+ }
421
+
422
+ /** Gets the permissions of an object. Objects can inherit permissions from their parent objects or root object. */
423
+ async getObjectPermissions(
424
+ req: GetObjectPermissionsRequest,
425
+ options?: CallOptions
426
+ ): Promise<PermissionsResponse> {
427
+ const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`;
428
+ let resp: PermissionsResponse | undefined;
429
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
430
+ const headers = new Headers();
431
+ if (this.workspaceId !== undefined) {
432
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
433
+ }
434
+ headers.set('User-Agent', this.userAgent);
435
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
436
+ const respBody = await executeHttpCall({
437
+ request: httpReq,
438
+ httpClient: this.httpClient,
439
+ logger: this.logger,
440
+ });
441
+ resp = parseResponse(respBody, unmarshalPermissionsResponseSchema);
442
+ };
443
+ await executeCall(call, options);
444
+ if (resp === undefined) {
445
+ throw new Error('operation completed without a result.');
446
+ }
447
+ return resp;
448
+ }
449
+
450
+ /** Gets the permission levels that a user can have on an object. */
451
+ async listPermissionLevels(
452
+ req: ListPermissionLevelsRequest,
453
+ options?: CallOptions
454
+ ): Promise<ListPermissionLevelsRequest_Response> {
455
+ const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}/permissionLevels`;
456
+ let resp: ListPermissionLevelsRequest_Response | undefined;
457
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
458
+ const headers = new Headers();
459
+ if (this.workspaceId !== undefined) {
460
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
461
+ }
462
+ headers.set('User-Agent', this.userAgent);
463
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
464
+ const respBody = await executeHttpCall({
465
+ request: httpReq,
466
+ httpClient: this.httpClient,
467
+ logger: this.logger,
468
+ });
469
+ resp = parseResponse(
470
+ respBody,
471
+ unmarshalListPermissionLevelsRequest_ResponseSchema
472
+ );
473
+ };
474
+ await executeCall(call, options);
475
+ if (resp === undefined) {
476
+ throw new Error('operation completed without a result.');
477
+ }
478
+ return resp;
479
+ }
480
+
481
+ /** 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. */
482
+ async setObjectPermissions(
483
+ req: SetObjectPermissionsRequest,
484
+ options?: CallOptions
485
+ ): Promise<PermissionsResponse> {
486
+ const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`;
487
+ const body = marshalRequest(req, marshalSetObjectPermissionsRequestSchema);
488
+ let resp: PermissionsResponse | undefined;
489
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
490
+ const headers = new Headers({'Content-Type': 'application/json'});
491
+ if (this.workspaceId !== undefined) {
492
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
493
+ }
494
+ headers.set('User-Agent', this.userAgent);
495
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
496
+ const respBody = await executeHttpCall({
497
+ request: httpReq,
498
+ httpClient: this.httpClient,
499
+ logger: this.logger,
500
+ });
501
+ resp = parseResponse(respBody, unmarshalPermissionsResponseSchema);
502
+ };
503
+ await executeCall(call, options);
504
+ if (resp === undefined) {
505
+ throw new Error('operation completed without a result.');
506
+ }
507
+ return resp;
508
+ }
509
+
510
+ /** Updates the permissions on an object. Objects can inherit permissions from their parent objects or root object. */
511
+ async updateObjectPermissions(
512
+ req: UpdateObjectPermissionsRequest,
513
+ options?: CallOptions
514
+ ): Promise<PermissionsResponse> {
515
+ const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`;
516
+ const body = marshalRequest(
517
+ req,
518
+ marshalUpdateObjectPermissionsRequestSchema
519
+ );
520
+ let resp: PermissionsResponse | undefined;
521
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
522
+ const headers = new Headers({'Content-Type': 'application/json'});
523
+ if (this.workspaceId !== undefined) {
524
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
525
+ }
526
+ headers.set('User-Agent', this.userAgent);
527
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
528
+ const respBody = await executeHttpCall({
529
+ request: httpReq,
530
+ httpClient: this.httpClient,
531
+ logger: this.logger,
532
+ });
533
+ resp = parseResponse(respBody, unmarshalPermissionsResponseSchema);
534
+ };
535
+ await executeCall(call, options);
536
+ if (resp === undefined) {
537
+ throw new Error('operation completed without a result.');
538
+ }
539
+ return resp;
540
+ }
541
+
542
+ /** Check access policy to a resource. */
543
+ async checkPolicy(
544
+ req: CheckPolicyRequest,
545
+ options?: CallOptions
546
+ ): Promise<CheckPolicyResponse> {
547
+ const url = `${this.host}/api/2.0/access-control/check-policy-v2`;
548
+ const params = new URLSearchParams();
549
+ if (req.actor !== undefined) {
550
+ flattenQueryParams('actor', marshalActorSchema.parse(req.actor), params);
551
+ }
552
+ if (req.permission !== undefined) {
553
+ params.append('permission', req.permission);
554
+ }
555
+ if (req.resource !== undefined) {
556
+ params.append('resource', req.resource);
557
+ }
558
+ if (req.consistencyToken !== undefined) {
559
+ flattenQueryParams(
560
+ 'consistency_token',
561
+ marshalConsistencyTokenSchema.parse(req.consistencyToken),
562
+ params
563
+ );
564
+ }
565
+ if (req.authzIdentity !== undefined) {
566
+ params.append('authz_identity', req.authzIdentity);
567
+ }
568
+ if (req.resourceInfo !== undefined) {
569
+ flattenQueryParams(
570
+ 'resource_info',
571
+ marshalResourceInfoSchema.parse(req.resourceInfo),
572
+ params
573
+ );
574
+ }
575
+ const query = params.toString();
576
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
577
+ let resp: CheckPolicyResponse | undefined;
578
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
579
+ const headers = new Headers();
580
+ if (this.workspaceId !== undefined) {
581
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
582
+ }
583
+ headers.set('User-Agent', this.userAgent);
584
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
585
+ const respBody = await executeHttpCall({
586
+ request: httpReq,
587
+ httpClient: this.httpClient,
588
+ logger: this.logger,
589
+ });
590
+ resp = parseResponse(respBody, unmarshalCheckPolicyResponseSchema);
591
+ };
592
+ await executeCall(call, options);
593
+ if (resp === undefined) {
594
+ throw new Error('operation completed without a result.');
595
+ }
596
+ return resp;
597
+ }
598
+ }
@@ -0,0 +1,45 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {AccessManagementClient} from './client';
4
+
5
+ export {
6
+ PermissionLevel,
7
+ RequestAuthzIdentity,
8
+ WorkspacePermission,
9
+ } from './model';
10
+
11
+ export type {
12
+ AccessControlRequest,
13
+ AccessControlResponse,
14
+ Actor,
15
+ CheckPolicyRequest,
16
+ CheckPolicyResponse,
17
+ ConsistencyToken,
18
+ DeleteWorkspacePermissionAssignmentRequest,
19
+ DeleteWorkspacePermissionAssignmentRequest_Response,
20
+ GetObjectPermissionsRequest,
21
+ GetRuleSetRequest,
22
+ GrantRule,
23
+ ListAssignableRolesForResourceRequest,
24
+ ListAssignableRolesForResourceResponse,
25
+ ListPermissionLevelsRequest,
26
+ ListPermissionLevelsRequest_Response,
27
+ ListWorkspacePermissionAssignmentsRequest,
28
+ ListWorkspacePermissionAssignmentsRequest_Response,
29
+ ListWorkspacePermissionsRequest,
30
+ ListWorkspacePermissionsRequest_Response,
31
+ Permission,
32
+ PermissionOutput,
33
+ PermissionsDescription,
34
+ PermissionsResponse,
35
+ PrincipalOutput,
36
+ ResourceInfo,
37
+ Role,
38
+ RuleSet,
39
+ RuleSetUpdateRequest,
40
+ SetObjectPermissionsRequest,
41
+ UpdateObjectPermissionsRequest,
42
+ UpdateRuleSetRequest,
43
+ UpdateWorkspacePermissionAssignmentRequest,
44
+ WorkspacePermissionAssignmentOutput,
45
+ } from './model';