@databricks/sdk-uc-grants 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ //#region package.json
2
+ var name = "@databricks/sdk-uc-grants";
3
+ var version = "0.36.0";
4
+
5
+ //#endregion
6
+ export { name, version };
7
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,44 +1,48 @@
1
- import type { CallOptions } from '@databricks/sdk-options/call';
2
- import type { ClientOptions } from '@databricks/sdk-options/client';
3
- import type { EffectivePrivilegeAssignment, GetEffectivePermissionsRequest, GetEffectivePermissionsResponse, GetPermissionsRequest, GetPermissionsResponse, ListEffectivePrivilegeAssignmentsRequest, ListEffectivePrivilegeAssignmentsResponse, ListPrivilegeAssignmentsRequest, ListPrivilegeAssignmentsResponse, PrivilegeAssignment, UpdatePermissionsRequest, UpdatePermissionsResponse } from './model';
4
- export declare class GrantsClient {
5
- private readonly options;
6
- private readonly logger;
7
- private readonly userAgent;
8
- private config;
9
- constructor(options: ClientOptions);
10
- private resolveConfig;
11
- /**
12
- * Gets the effective permissions for a securable. Includes inherited permissions from any parent securables.
13
- *
14
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
15
- *
16
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
17
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
18
- */
19
- getEffectivePermissions(req: GetEffectivePermissionsRequest, options?: CallOptions): Promise<GetEffectivePermissionsResponse>;
20
- /**
21
- * Gets the permissions for a securable. Does not include inherited permissions.
22
- *
23
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
24
- *
25
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
26
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
27
- */
28
- getPermissions(req: GetPermissionsRequest, options?: CallOptions): Promise<GetPermissionsResponse>;
29
- /**
30
- * Lists the effective privilege assignments for a securable. Includes inherited privileges.
31
- * Paginated version of Get Effective Permissions API.
32
- */
33
- listEffectivePrivilegeAssignments(req: ListEffectivePrivilegeAssignmentsRequest, options?: CallOptions): Promise<ListEffectivePrivilegeAssignmentsResponse>;
34
- listEffectivePrivilegeAssignmentsIter(req: ListEffectivePrivilegeAssignmentsRequest, options?: CallOptions): AsyncGenerator<EffectivePrivilegeAssignment>;
35
- /**
36
- * Lists the privilege assignments for a securable. Does not include inherited privileges.
37
- * Paginated version of Get Permissions API.
38
- */
39
- listPrivilegeAssignments(req: ListPrivilegeAssignmentsRequest, options?: CallOptions): Promise<ListPrivilegeAssignmentsResponse>;
40
- listPrivilegeAssignmentsIter(req: ListPrivilegeAssignmentsRequest, options?: CallOptions): AsyncGenerator<PrivilegeAssignment>;
41
- /** Updates the permissions for a securable. */
42
- updatePermissions(req: UpdatePermissionsRequest, options?: CallOptions): Promise<UpdatePermissionsResponse>;
1
+ import { EffectivePrivilegeAssignment, GetEffectivePermissionsRequest, GetEffectivePermissionsResponse, GetPermissionsRequest, GetPermissionsResponse, ListEffectivePrivilegeAssignmentsRequest, ListEffectivePrivilegeAssignmentsResponse, ListPrivilegeAssignmentsRequest, ListPrivilegeAssignmentsResponse, PrivilegeAssignment, UpdatePermissionsRequest, UpdatePermissionsResponse } from "./model.js";
2
+ import { CallOptions } from "@databricks/sdk-options/call";
3
+ import { ClientOptions } from "@databricks/sdk-options/client";
4
+
5
+ //#region src/v1/client.d.ts
6
+ declare class GrantsClient {
7
+ private readonly options;
8
+ private readonly logger;
9
+ private readonly userAgent;
10
+ private config;
11
+ constructor(options: ClientOptions);
12
+ private resolveConfig;
13
+ /**
14
+ * Gets the effective permissions for a securable. Includes inherited permissions from any parent securables.
15
+ *
16
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
17
+ *
18
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
19
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
20
+ */
21
+ getEffectivePermissions(req: GetEffectivePermissionsRequest, options?: CallOptions): Promise<GetEffectivePermissionsResponse>;
22
+ /**
23
+ * Gets the permissions for a securable. Does not include inherited permissions.
24
+ *
25
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
26
+ *
27
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
28
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
29
+ */
30
+ getPermissions(req: GetPermissionsRequest, options?: CallOptions): Promise<GetPermissionsResponse>;
31
+ /**
32
+ * Lists the effective privilege assignments for a securable. Includes inherited privileges.
33
+ * Paginated version of Get Effective Permissions API.
34
+ */
35
+ listEffectivePrivilegeAssignments(req: ListEffectivePrivilegeAssignmentsRequest, options?: CallOptions): Promise<ListEffectivePrivilegeAssignmentsResponse>;
36
+ listEffectivePrivilegeAssignmentsIter(req: ListEffectivePrivilegeAssignmentsRequest, options?: CallOptions): AsyncGenerator<EffectivePrivilegeAssignment>;
37
+ /**
38
+ * Lists the privilege assignments for a securable. Does not include inherited privileges.
39
+ * Paginated version of Get Permissions API.
40
+ */
41
+ listPrivilegeAssignments(req: ListPrivilegeAssignmentsRequest, options?: CallOptions): Promise<ListPrivilegeAssignmentsResponse>;
42
+ listPrivilegeAssignmentsIter(req: ListPrivilegeAssignmentsRequest, options?: CallOptions): AsyncGenerator<PrivilegeAssignment>;
43
+ /** Updates the permissions for a securable. */
44
+ updatePermissions(req: UpdatePermissionsRequest, options?: CallOptions): Promise<UpdatePermissionsResponse>;
43
45
  }
46
+ //#endregion
47
+ export { GrantsClient };
44
48
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAWlE,OAAO,KAAK,EACV,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,sBAAsB,EACtB,wCAAwC,EACxC,yCAAyC,EACzC,+BAA+B,EAC/B,gCAAgC,EAChC,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAgBjB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAInC,OAAO,CAAC,MAAM,CAA4C;gBAE9C,OAAO,EAAE,aAAa;IAUlC,OAAO,CAAC,aAAa;IAKrB;;;;;;;OAOG;IACG,uBAAuB,CAC3B,GAAG,EAAE,8BAA8B,EACnC,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,+BAA+B,CAAC;IAwC3C;;;;;;;OAOG;IACG,cAAc,CAClB,GAAG,EAAE,qBAAqB,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,sBAAsB,CAAC;IAqClC;;;OAGG;IACG,iCAAiC,CACrC,GAAG,EAAE,wCAAwC,EAC7C,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,yCAAyC,CAAC;IAwC9C,qCAAqC,CAC1C,GAAG,EAAE,wCAAwC,EAC7C,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,4BAA4B,CAAC;IAiB/C;;;OAGG;IACG,wBAAwB,CAC5B,GAAG,EAAE,+BAA+B,EACpC,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,gCAAgC,CAAC;IAwCrC,4BAA4B,CACjC,GAAG,EAAE,+BAA+B,EACpC,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,mBAAmB,CAAC;IActC,+CAA+C;IACzC,iBAAiB,CACrB,GAAG,EAAE,wBAAwB,EAC7B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,yBAAyB,CAAC;CAyBtC"}
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/v1/client.ts"],"mappings":";;;;;cA+Ca,YAAA;EAAA,iBACM,OAAA;EAAA,iBACA,MAAA;EAAA,iBAIA,SAAA;EAAA,QAIT,MAAA;cAEI,OAAA,EAAS,aAAA;EAAA,QAUb,aAAA;EAeI;;;;;;;;EAFN,uBAAA,CACJ,GAAA,EAAK,8BAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,+BAAA;EA+FA;;;;;;;;EA/CL,cAAA,CACJ,GAAA,EAAK,qBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,sBAAA;EA+GR;;;;EAtEG,iCAAA,CACJ,GAAA,EAAK,wCAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,yCAAA;EAwCJ,qCAAA,CACL,GAAA,EAAK,wCAAA,EACL,OAAA,GAAU,WAAA,GACT,cAAA,CAAe,4BAAA;EAoFN;;;;EA/DN,wBAAA,CACJ,GAAA,EAAK,+BAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,gCAAA;EAwCJ,4BAAA,CACL,GAAA,EAAK,+BAAA,EACL,OAAA,GAAU,WAAA,GACT,cAAA,CAAe,mBAAA;EAjPD;EAgQX,iBAAA,CACJ,GAAA,EAAK,wBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,yBAAA;AAAA"}
package/dist/v1/client.js CHANGED
@@ -1,259 +1,196 @@
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, } from './utils';
7
- import pkgJson from '../../package.json' with { type: 'json' };
8
- import { marshalUpdatePermissionsRequestSchema, unmarshalGetEffectivePermissionsResponseSchema, unmarshalGetPermissionsResponseSchema, unmarshalListEffectivePrivilegeAssignmentsResponseSchema, unmarshalListPrivilegeAssignmentsResponseSchema, unmarshalUpdatePermissionsResponseSchema, } 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, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalUpdatePermissionsRequestSchema, unmarshalGetEffectivePermissionsResponseSchema, unmarshalGetPermissionsResponseSchema, unmarshalListEffectivePrivilegeAssignmentsResponseSchema, unmarshalListPrivilegeAssignmentsResponseSchema, unmarshalUpdatePermissionsResponseSchema } 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 GrantsClient {
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
- /**
39
- * Gets the effective permissions for a securable. Includes inherited permissions from any parent securables.
40
- *
41
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
42
- *
43
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
44
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
45
- */
46
- async getEffectivePermissions(req, options) {
47
- const { host, workspaceId, httpClient } = await this.resolveConfig();
48
- const url = `${host}/api/2.1/unity-catalog/effective-permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`;
49
- const params = new URLSearchParams();
50
- if (req.principal !== undefined) {
51
- params.append('principal', req.principal);
52
- }
53
- if (req.maxResults !== undefined) {
54
- params.append('max_results', String(req.maxResults));
55
- }
56
- if (req.pageToken !== undefined) {
57
- params.append('page_token', req.pageToken);
58
- }
59
- const query = params.toString();
60
- const fullUrl = query !== '' ? `${url}?${query}` : url;
61
- let resp;
62
- const call = async (callSignal) => {
63
- const headers = new Headers();
64
- if (workspaceId !== undefined) {
65
- headers.set('X-Databricks-Workspace-Id', workspaceId);
66
- }
67
- headers.set('User-Agent', this.userAgent);
68
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
69
- const respBody = await executeHttpCall({
70
- request: httpReq,
71
- httpClient,
72
- logger: this.logger,
73
- });
74
- resp = parseResponse(respBody, unmarshalGetEffectivePermissionsResponseSchema);
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
- /**
83
- * Gets the permissions for a securable. Does not include inherited permissions.
84
- *
85
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
86
- *
87
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
88
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
89
- */
90
- async getPermissions(req, options) {
91
- const { host, workspaceId, httpClient } = await this.resolveConfig();
92
- const url = `${host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`;
93
- const params = new URLSearchParams();
94
- if (req.principal !== undefined) {
95
- params.append('principal', req.principal);
96
- }
97
- if (req.maxResults !== undefined) {
98
- params.append('max_results', String(req.maxResults));
99
- }
100
- if (req.pageToken !== undefined) {
101
- params.append('page_token', req.pageToken);
102
- }
103
- const query = params.toString();
104
- const fullUrl = query !== '' ? `${url}?${query}` : url;
105
- let resp;
106
- const call = async (callSignal) => {
107
- const headers = new Headers();
108
- if (workspaceId !== undefined) {
109
- headers.set('X-Databricks-Workspace-Id', workspaceId);
110
- }
111
- headers.set('User-Agent', this.userAgent);
112
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
113
- const respBody = await executeHttpCall({
114
- request: httpReq,
115
- httpClient,
116
- logger: this.logger,
117
- });
118
- resp = parseResponse(respBody, unmarshalGetPermissionsResponseSchema);
119
- };
120
- await executeCall(call, options);
121
- if (resp === undefined) {
122
- throw new Error('operation completed without a result.');
123
- }
124
- return resp;
125
- }
126
- /**
127
- * Lists the effective privilege assignments for a securable. Includes inherited privileges.
128
- * Paginated version of Get Effective Permissions API.
129
- */
130
- async listEffectivePrivilegeAssignments(req, options) {
131
- const { host, workspaceId, httpClient } = await this.resolveConfig();
132
- const url = `${host}/api/2.1/unity-catalog/effective-privilege-assignments/${req.securableType ?? ''}/${req.fullName ?? ''}`;
133
- const params = new URLSearchParams();
134
- if (req.principal !== undefined) {
135
- params.append('principal', req.principal);
136
- }
137
- if (req.pageSize !== undefined) {
138
- params.append('page_size', String(req.pageSize));
139
- }
140
- if (req.pageToken !== undefined) {
141
- params.append('page_token', req.pageToken);
142
- }
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
- if (workspaceId !== undefined) {
149
- headers.set('X-Databricks-Workspace-Id', workspaceId);
150
- }
151
- headers.set('User-Agent', this.userAgent);
152
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
153
- const respBody = await executeHttpCall({
154
- request: httpReq,
155
- httpClient,
156
- logger: this.logger,
157
- });
158
- resp = parseResponse(respBody, unmarshalListEffectivePrivilegeAssignmentsResponseSchema);
159
- };
160
- await executeCall(call, options);
161
- if (resp === undefined) {
162
- throw new Error('operation completed without a result.');
163
- }
164
- return resp;
165
- }
166
- async *listEffectivePrivilegeAssignmentsIter(req, options) {
167
- const pageReq = { ...req };
168
- for (;;) {
169
- const resp = await this.listEffectivePrivilegeAssignments(pageReq, options);
170
- for (const item of resp.effectivePrivilegeAssignments ?? []) {
171
- yield item;
172
- }
173
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
174
- return;
175
- }
176
- pageReq.pageToken = resp.nextPageToken;
177
- }
178
- }
179
- /**
180
- * Lists the privilege assignments for a securable. Does not include inherited privileges.
181
- * Paginated version of Get Permissions API.
182
- */
183
- async listPrivilegeAssignments(req, options) {
184
- const { host, workspaceId, httpClient } = await this.resolveConfig();
185
- const url = `${host}/api/2.1/unity-catalog/privilege-assignments/${req.securableType ?? ''}/${req.fullName ?? ''}`;
186
- const params = new URLSearchParams();
187
- if (req.principal !== undefined) {
188
- params.append('principal', req.principal);
189
- }
190
- if (req.pageSize !== undefined) {
191
- params.append('page_size', String(req.pageSize));
192
- }
193
- if (req.pageToken !== undefined) {
194
- params.append('page_token', req.pageToken);
195
- }
196
- const query = params.toString();
197
- const fullUrl = query !== '' ? `${url}?${query}` : url;
198
- let resp;
199
- const call = async (callSignal) => {
200
- const headers = new Headers();
201
- if (workspaceId !== undefined) {
202
- headers.set('X-Databricks-Workspace-Id', workspaceId);
203
- }
204
- headers.set('User-Agent', this.userAgent);
205
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
206
- const respBody = await executeHttpCall({
207
- request: httpReq,
208
- httpClient,
209
- logger: this.logger,
210
- });
211
- resp = parseResponse(respBody, unmarshalListPrivilegeAssignmentsResponseSchema);
212
- };
213
- await executeCall(call, options);
214
- if (resp === undefined) {
215
- throw new Error('operation completed without a result.');
216
- }
217
- return resp;
218
- }
219
- async *listPrivilegeAssignmentsIter(req, options) {
220
- const pageReq = { ...req };
221
- for (;;) {
222
- const resp = await this.listPrivilegeAssignments(pageReq, options);
223
- for (const item of resp.privilegeAssignments ?? []) {
224
- yield item;
225
- }
226
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
227
- return;
228
- }
229
- pageReq.pageToken = resp.nextPageToken;
230
- }
231
- }
232
- /** Updates the permissions for a securable. */
233
- async updatePermissions(req, options) {
234
- const { host, workspaceId, httpClient } = await this.resolveConfig();
235
- const url = `${host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`;
236
- const body = marshalRequest(req, marshalUpdatePermissionsRequestSchema);
237
- let resp;
238
- const call = async (callSignal) => {
239
- const headers = new Headers({ 'Content-Type': 'application/json' });
240
- if (workspaceId !== undefined) {
241
- headers.set('X-Databricks-Workspace-Id', workspaceId);
242
- }
243
- headers.set('User-Agent', this.userAgent);
244
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
245
- const respBody = await executeHttpCall({
246
- request: httpReq,
247
- httpClient,
248
- logger: this.logger,
249
- });
250
- resp = parseResponse(respBody, unmarshalUpdatePermissionsResponseSchema);
251
- };
252
- await executeCall(call, options);
253
- if (resp === undefined) {
254
- throw new Error('operation completed without a result.');
255
- }
256
- return resp;
257
- }
258
- }
14
+ var GrantsClient = 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
+ /**
35
+ * Gets the effective permissions for a securable. Includes inherited permissions from any parent securables.
36
+ *
37
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
38
+ *
39
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
40
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
41
+ */
42
+ async getEffectivePermissions(req, options) {
43
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
44
+ const url = `${host}/api/2.1/unity-catalog/effective-permissions/${req.securableType ?? ""}/${req.securableFullName ?? ""}`;
45
+ const params = new URLSearchParams();
46
+ if (req.principal !== void 0) params.append("principal", req.principal);
47
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
48
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
49
+ const query = params.toString();
50
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
51
+ let resp;
52
+ const call = async (callSignal) => {
53
+ const headers = new Headers();
54
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
55
+ headers.set("User-Agent", this.userAgent);
56
+ resp = parseResponse(await executeHttpCall({
57
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
58
+ httpClient,
59
+ logger: this.logger
60
+ }), unmarshalGetEffectivePermissionsResponseSchema);
61
+ };
62
+ await executeCall(call, options);
63
+ if (resp === void 0) throw new Error("operation completed without a result.");
64
+ return resp;
65
+ }
66
+ /**
67
+ * Gets the permissions for a securable. Does not include inherited permissions.
68
+ *
69
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
70
+ *
71
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
72
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
73
+ */
74
+ async getPermissions(req, options) {
75
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
76
+ const url = `${host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ""}/${req.securableFullName ?? ""}`;
77
+ const params = new URLSearchParams();
78
+ if (req.principal !== void 0) params.append("principal", req.principal);
79
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
80
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
81
+ const query = params.toString();
82
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
83
+ let resp;
84
+ const call = async (callSignal) => {
85
+ const headers = new Headers();
86
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
87
+ headers.set("User-Agent", this.userAgent);
88
+ resp = parseResponse(await executeHttpCall({
89
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
90
+ httpClient,
91
+ logger: this.logger
92
+ }), unmarshalGetPermissionsResponseSchema);
93
+ };
94
+ await executeCall(call, options);
95
+ if (resp === void 0) throw new Error("operation completed without a result.");
96
+ return resp;
97
+ }
98
+ /**
99
+ * Lists the effective privilege assignments for a securable. Includes inherited privileges.
100
+ * Paginated version of Get Effective Permissions API.
101
+ */
102
+ async listEffectivePrivilegeAssignments(req, options) {
103
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
104
+ const url = `${host}/api/2.1/unity-catalog/effective-privilege-assignments/${req.securableType ?? ""}/${req.fullName ?? ""}`;
105
+ const params = new URLSearchParams();
106
+ if (req.principal !== void 0) params.append("principal", req.principal);
107
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
108
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
109
+ const query = params.toString();
110
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
111
+ let resp;
112
+ const call = async (callSignal) => {
113
+ const headers = new Headers();
114
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
115
+ headers.set("User-Agent", this.userAgent);
116
+ resp = parseResponse(await executeHttpCall({
117
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
118
+ httpClient,
119
+ logger: this.logger
120
+ }), unmarshalListEffectivePrivilegeAssignmentsResponseSchema);
121
+ };
122
+ await executeCall(call, options);
123
+ if (resp === void 0) throw new Error("operation completed without a result.");
124
+ return resp;
125
+ }
126
+ async *listEffectivePrivilegeAssignmentsIter(req, options) {
127
+ const pageReq = { ...req };
128
+ for (;;) {
129
+ const resp = await this.listEffectivePrivilegeAssignments(pageReq, options);
130
+ for (const item of resp.effectivePrivilegeAssignments ?? []) yield item;
131
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
132
+ pageReq.pageToken = resp.nextPageToken;
133
+ }
134
+ }
135
+ /**
136
+ * Lists the privilege assignments for a securable. Does not include inherited privileges.
137
+ * Paginated version of Get Permissions API.
138
+ */
139
+ async listPrivilegeAssignments(req, options) {
140
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
141
+ const url = `${host}/api/2.1/unity-catalog/privilege-assignments/${req.securableType ?? ""}/${req.fullName ?? ""}`;
142
+ const params = new URLSearchParams();
143
+ if (req.principal !== void 0) params.append("principal", req.principal);
144
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
145
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
146
+ const query = params.toString();
147
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
148
+ let resp;
149
+ const call = async (callSignal) => {
150
+ const headers = new Headers();
151
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
152
+ headers.set("User-Agent", this.userAgent);
153
+ resp = parseResponse(await executeHttpCall({
154
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
155
+ httpClient,
156
+ logger: this.logger
157
+ }), unmarshalListPrivilegeAssignmentsResponseSchema);
158
+ };
159
+ await executeCall(call, options);
160
+ if (resp === void 0) throw new Error("operation completed without a result.");
161
+ return resp;
162
+ }
163
+ async *listPrivilegeAssignmentsIter(req, options) {
164
+ const pageReq = { ...req };
165
+ for (;;) {
166
+ const resp = await this.listPrivilegeAssignments(pageReq, options);
167
+ for (const item of resp.privilegeAssignments ?? []) yield item;
168
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
169
+ pageReq.pageToken = resp.nextPageToken;
170
+ }
171
+ }
172
+ /** Updates the permissions for a securable. */
173
+ async updatePermissions(req, options) {
174
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
175
+ const url = `${host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ""}/${req.securableFullName ?? ""}`;
176
+ const body = marshalRequest(req, marshalUpdatePermissionsRequestSchema);
177
+ let resp;
178
+ const call = async (callSignal) => {
179
+ const headers = new Headers({ "Content-Type": "application/json" });
180
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
181
+ headers.set("User-Agent", this.userAgent);
182
+ resp = parseResponse(await executeHttpCall({
183
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
184
+ httpClient,
185
+ logger: this.logger
186
+ }), unmarshalUpdatePermissionsResponseSchema);
187
+ };
188
+ await executeCall(call, options);
189
+ if (resp === void 0) throw new Error("operation completed without a result.");
190
+ return resp;
191
+ }
192
+ };
193
+
194
+ //#endregion
195
+ export { GrantsClient };
259
196
  //# sourceMappingURL=client.js.map