@databricks/sdk-accessmanagement 0.0.0-dev → 0.1.0-dev.1

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