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