@databricks/sdk-sharing 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,1217 @@
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
+ } from './utils';
19
+ import pkgJson from '../../package.json' with {type: 'json'};
20
+ import type {
21
+ CreateFederationPolicyRequest,
22
+ CreateProviderRequest,
23
+ CreateRecipientRequest,
24
+ CreateShareRequest,
25
+ DeleteFederationPolicyRequest,
26
+ DeleteProviderRequest,
27
+ DeleteProviderRequest_Response,
28
+ DeleteRecipientRequest,
29
+ DeleteRecipientRequest_Response,
30
+ DeleteShareRequest,
31
+ DeleteShareRequest_Response,
32
+ FederationPolicy,
33
+ GetActivationUrlInfoRequest,
34
+ GetActivationUrlInfoRequest_Response,
35
+ GetFederationPolicyRequest,
36
+ GetProviderRequest,
37
+ GetRecipientRequest,
38
+ GetRecipientSharePermissionsRequest,
39
+ GetRecipientSharePermissionsRequest_Response,
40
+ GetSharePermissionsRequest,
41
+ GetSharePermissionsRequest_Response,
42
+ GetShareRequest,
43
+ ListFederationPoliciesRequest,
44
+ ListFederationPoliciesResponse,
45
+ ListProviderShareAssetsRequest,
46
+ ListProviderShareAssetsResponse,
47
+ ListProviderSharesRequest,
48
+ ListProviderSharesRequest_Response,
49
+ ListProvidersRequest,
50
+ ListProvidersRequest_Response,
51
+ ListRecipientsRequest,
52
+ ListRecipientsRequest_Response,
53
+ ListSharesRequest,
54
+ ListSharesRequest_Response,
55
+ ProviderInfo,
56
+ ProviderShare,
57
+ RecipientInfo,
58
+ RetrieveToken,
59
+ RetrieveToken_Response,
60
+ RotateRecipientTokenRequest,
61
+ ShareInfo,
62
+ UpdateProviderRequest,
63
+ UpdateRecipientRequest,
64
+ UpdateSharePermissionsRequest,
65
+ UpdateSharePermissionsRequest_Response,
66
+ UpdateShareRequest,
67
+ } from './model';
68
+ import {
69
+ marshalCreateProviderRequestSchema,
70
+ marshalCreateRecipientRequestSchema,
71
+ marshalCreateShareRequestSchema,
72
+ marshalFederationPolicySchema,
73
+ marshalRotateRecipientTokenRequestSchema,
74
+ marshalUpdateProviderRequestSchema,
75
+ marshalUpdateRecipientRequestSchema,
76
+ marshalUpdateSharePermissionsRequestSchema,
77
+ marshalUpdateShareRequestSchema,
78
+ unmarshalDeleteProviderRequest_ResponseSchema,
79
+ unmarshalDeleteRecipientRequest_ResponseSchema,
80
+ unmarshalDeleteShareRequest_ResponseSchema,
81
+ unmarshalFederationPolicySchema,
82
+ unmarshalGetActivationUrlInfoRequest_ResponseSchema,
83
+ unmarshalGetRecipientSharePermissionsRequest_ResponseSchema,
84
+ unmarshalGetSharePermissionsRequest_ResponseSchema,
85
+ unmarshalListFederationPoliciesResponseSchema,
86
+ unmarshalListProviderShareAssetsResponseSchema,
87
+ unmarshalListProviderSharesRequest_ResponseSchema,
88
+ unmarshalListProvidersRequest_ResponseSchema,
89
+ unmarshalListRecipientsRequest_ResponseSchema,
90
+ unmarshalListSharesRequest_ResponseSchema,
91
+ unmarshalProviderInfoSchema,
92
+ unmarshalRecipientInfoSchema,
93
+ unmarshalRetrieveToken_ResponseSchema,
94
+ unmarshalShareInfoSchema,
95
+ unmarshalUpdateSharePermissionsRequest_ResponseSchema,
96
+ } from './model';
97
+
98
+ // Package identity segment for this client to be used in the User-Agent header.
99
+ const PACKAGE_SEGMENT = {
100
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
101
+ value: pkgJson.version,
102
+ };
103
+
104
+ export class SharingClient {
105
+ private readonly host: string;
106
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
107
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
108
+ // request.
109
+ private readonly workspaceId: string | undefined;
110
+ private readonly httpClient: HttpClient;
111
+ private readonly logger: Logger;
112
+ // User-Agent header value. Composed once at construction from
113
+ // createDefault() merged with this package's identity and the active
114
+ // credential's name.
115
+ private readonly userAgent: string;
116
+
117
+ constructor(options: ClientOptions) {
118
+ if (options.host === undefined) {
119
+ throw new Error('Host is required.');
120
+ }
121
+ this.host = options.host.replace(/\/$/, '');
122
+ this.workspaceId = options.workspaceId;
123
+ this.logger = options.logger ?? new NoOpLogger();
124
+ const info = createDefault()
125
+ .with(PACKAGE_SEGMENT)
126
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
127
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
128
+ this.userAgent = info.toString();
129
+ this.httpClient = newHttpClient(options);
130
+ }
131
+
132
+ /**
133
+ * Create a federation policy for an OIDC_FEDERATION recipient for sharing data from <Databricks> to non-<Databricks> recipients.
134
+ * The caller must be the owner of the recipient.
135
+ * When sharing data from <Databricks> to non-<Databricks> clients,
136
+ * you can define a federation policy to authenticate non-<Databricks> recipients.
137
+ * The federation policy validates OIDC claims in federated tokens and is defined at the recipient level.
138
+ * This enables secretless sharing clients to authenticate using OIDC tokens.
139
+ *
140
+ * Supported scenarios for federation policies:
141
+ * 1. **User-to-Machine (U2M) flow** (e.g., PowerBI): A user accesses a resource using their own identity.
142
+ * 2. **Machine-to-Machine (M2M) flow** (e.g., OAuth App): An OAuth App accesses a resource using its own identity,
143
+ * typically for tasks like running nightly jobs.
144
+ *
145
+ * For an overview, refer to:
146
+ * - Blog post: Overview of feature: https://www.databricks.com/blog/announcing-oidc-token-federation-enhanced-delta-sharing-security
147
+ *
148
+ * For detailed configuration guides based on your use case:
149
+ * - Creating a Federation Policy as a provider: https://docs.databricks.com/en/delta-sharing/create-recipient-oidc-fed
150
+ * - Configuration and usage for Machine-to-Machine (M2M) applications (e.g., Python Delta Sharing Client): https://docs.databricks.com/aws/en/delta-sharing/sharing-over-oidc-m2m
151
+ * - Configuration and usage for User-to-Machine (U2M) applications (e.g., PowerBI): https://docs.databricks.com/aws/en/delta-sharing/sharing-over-oidc-u2m
152
+ */
153
+ async createFederationPolicy(
154
+ req: CreateFederationPolicyRequest,
155
+ options?: CallOptions
156
+ ): Promise<FederationPolicy> {
157
+ const url = `${this.host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies`;
158
+ const body = marshalRequest(req.policy, marshalFederationPolicySchema);
159
+ let resp: FederationPolicy | undefined;
160
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
161
+ const headers = new Headers({'Content-Type': 'application/json'});
162
+ if (this.workspaceId !== undefined) {
163
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
164
+ }
165
+ headers.set('User-Agent', this.userAgent);
166
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
167
+ const respBody = await executeHttpCall({
168
+ request: httpReq,
169
+ httpClient: this.httpClient,
170
+ logger: this.logger,
171
+ });
172
+ resp = parseResponse(respBody, unmarshalFederationPolicySchema);
173
+ };
174
+ await executeCall(call, options);
175
+ if (resp === undefined) {
176
+ throw new Error('API call completed without a result.');
177
+ }
178
+ return resp;
179
+ }
180
+
181
+ /**
182
+ * Creates a new authentication provider minimally based on a name and authentication type.
183
+ * The caller must be an admin on the metastore.
184
+ */
185
+ async createProvider(
186
+ req: CreateProviderRequest,
187
+ options?: CallOptions
188
+ ): Promise<ProviderInfo> {
189
+ const url = `${this.host}/api/2.1/unity-catalog/providers`;
190
+ const body = marshalRequest(req, marshalCreateProviderRequestSchema);
191
+ let resp: ProviderInfo | undefined;
192
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
193
+ const headers = new Headers({'Content-Type': 'application/json'});
194
+ if (this.workspaceId !== undefined) {
195
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
196
+ }
197
+ headers.set('User-Agent', this.userAgent);
198
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
199
+ const respBody = await executeHttpCall({
200
+ request: httpReq,
201
+ httpClient: this.httpClient,
202
+ logger: this.logger,
203
+ });
204
+ resp = parseResponse(respBody, unmarshalProviderInfoSchema);
205
+ };
206
+ await executeCall(call, options);
207
+ if (resp === undefined) {
208
+ throw new Error('API call completed without a result.');
209
+ }
210
+ return resp;
211
+ }
212
+
213
+ /**
214
+ * Creates a new recipient with the delta sharing authentication type in the metastore.
215
+ * The caller must be a metastore admin or have the **CREATE_RECIPIENT** privilege on the metastore.
216
+ */
217
+ async createRecipient(
218
+ req: CreateRecipientRequest,
219
+ options?: CallOptions
220
+ ): Promise<RecipientInfo> {
221
+ const url = `${this.host}/api/2.1/unity-catalog/recipients`;
222
+ const body = marshalRequest(req, marshalCreateRecipientRequestSchema);
223
+ let resp: RecipientInfo | undefined;
224
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
225
+ const headers = new Headers({'Content-Type': 'application/json'});
226
+ if (this.workspaceId !== undefined) {
227
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
228
+ }
229
+ headers.set('User-Agent', this.userAgent);
230
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
231
+ const respBody = await executeHttpCall({
232
+ request: httpReq,
233
+ httpClient: this.httpClient,
234
+ logger: this.logger,
235
+ });
236
+ resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
237
+ };
238
+ await executeCall(call, options);
239
+ if (resp === undefined) {
240
+ throw new Error('API call completed without a result.');
241
+ }
242
+ return resp;
243
+ }
244
+
245
+ /**
246
+ * Creates a new share for data objects. Data objects can be added after creation with **update**.
247
+ * The caller must be a metastore admin or have the **CREATE_SHARE** privilege on the metastore.
248
+ */
249
+ async createShare(
250
+ req: CreateShareRequest,
251
+ options?: CallOptions
252
+ ): Promise<ShareInfo> {
253
+ const url = `${this.host}/api/2.1/unity-catalog/shares`;
254
+ const body = marshalRequest(req, marshalCreateShareRequestSchema);
255
+ let resp: ShareInfo | undefined;
256
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
257
+ const headers = new Headers({'Content-Type': 'application/json'});
258
+ if (this.workspaceId !== undefined) {
259
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
260
+ }
261
+ headers.set('User-Agent', this.userAgent);
262
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
263
+ const respBody = await executeHttpCall({
264
+ request: httpReq,
265
+ httpClient: this.httpClient,
266
+ logger: this.logger,
267
+ });
268
+ resp = parseResponse(respBody, unmarshalShareInfoSchema);
269
+ };
270
+ await executeCall(call, options);
271
+ if (resp === undefined) {
272
+ throw new Error('API call completed without a result.');
273
+ }
274
+ return resp;
275
+ }
276
+
277
+ /**
278
+ * Deletes an existing federation policy for an OIDC_FEDERATION recipient.
279
+ * The caller must be the owner of the recipient.
280
+ */
281
+ async deleteFederationPolicy(
282
+ req: DeleteFederationPolicyRequest,
283
+ options?: CallOptions
284
+ ): Promise<void> {
285
+ const url = `${this.host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies/${req.name ?? ''}`;
286
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
287
+ const headers = new Headers();
288
+ if (this.workspaceId !== undefined) {
289
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
290
+ }
291
+ headers.set('User-Agent', this.userAgent);
292
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
293
+ await executeHttpCall({
294
+ request: httpReq,
295
+ httpClient: this.httpClient,
296
+ logger: this.logger,
297
+ });
298
+ };
299
+ await executeCall(call, options);
300
+ }
301
+
302
+ /** Deletes an authentication provider, if the caller is a metastore admin or is the owner of the provider. */
303
+ async deleteProvider(
304
+ req: DeleteProviderRequest,
305
+ options?: CallOptions
306
+ ): Promise<DeleteProviderRequest_Response> {
307
+ const url = `${this.host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
308
+ let resp: DeleteProviderRequest_Response | undefined;
309
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
310
+ const headers = new Headers();
311
+ if (this.workspaceId !== undefined) {
312
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
313
+ }
314
+ headers.set('User-Agent', this.userAgent);
315
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
316
+ const respBody = await executeHttpCall({
317
+ request: httpReq,
318
+ httpClient: this.httpClient,
319
+ logger: this.logger,
320
+ });
321
+ resp = parseResponse(
322
+ respBody,
323
+ unmarshalDeleteProviderRequest_ResponseSchema
324
+ );
325
+ };
326
+ await executeCall(call, options);
327
+ if (resp === undefined) {
328
+ throw new Error('API call completed without a result.');
329
+ }
330
+ return resp;
331
+ }
332
+
333
+ /** Deletes the specified recipient from the metastore. The caller must be the owner of the recipient. */
334
+ async deleteRecipient(
335
+ req: DeleteRecipientRequest,
336
+ options?: CallOptions
337
+ ): Promise<DeleteRecipientRequest_Response> {
338
+ const url = `${this.host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}`;
339
+ let resp: DeleteRecipientRequest_Response | undefined;
340
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
341
+ const headers = new Headers();
342
+ if (this.workspaceId !== undefined) {
343
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
344
+ }
345
+ headers.set('User-Agent', this.userAgent);
346
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
347
+ const respBody = await executeHttpCall({
348
+ request: httpReq,
349
+ httpClient: this.httpClient,
350
+ logger: this.logger,
351
+ });
352
+ resp = parseResponse(
353
+ respBody,
354
+ unmarshalDeleteRecipientRequest_ResponseSchema
355
+ );
356
+ };
357
+ await executeCall(call, options);
358
+ if (resp === undefined) {
359
+ throw new Error('API call completed without a result.');
360
+ }
361
+ return resp;
362
+ }
363
+
364
+ /** Deletes a data object share from the metastore. The caller must be an owner of the share. */
365
+ async deleteShare(
366
+ req: DeleteShareRequest,
367
+ options?: CallOptions
368
+ ): Promise<DeleteShareRequest_Response> {
369
+ const url = `${this.host}/api/2.1/unity-catalog/shares/${req.name ?? ''}`;
370
+ let resp: DeleteShareRequest_Response | undefined;
371
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
372
+ const headers = new Headers();
373
+ if (this.workspaceId !== undefined) {
374
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
375
+ }
376
+ headers.set('User-Agent', this.userAgent);
377
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
378
+ const respBody = await executeHttpCall({
379
+ request: httpReq,
380
+ httpClient: this.httpClient,
381
+ logger: this.logger,
382
+ });
383
+ resp = parseResponse(
384
+ respBody,
385
+ unmarshalDeleteShareRequest_ResponseSchema
386
+ );
387
+ };
388
+ await executeCall(call, options);
389
+ if (resp === undefined) {
390
+ throw new Error('API call completed without a result.');
391
+ }
392
+ return resp;
393
+ }
394
+
395
+ /** Gets an activation URL for a share. */
396
+ async getActivationUrlInfo(
397
+ req: GetActivationUrlInfoRequest,
398
+ options?: CallOptions
399
+ ): Promise<GetActivationUrlInfoRequest_Response> {
400
+ const url = `${this.host}/api/2.1/unity-catalog/public/data_sharing_activation_info/${req.activationUrl ?? ''}`;
401
+ let resp: GetActivationUrlInfoRequest_Response | undefined;
402
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
403
+ const headers = new Headers();
404
+ if (this.workspaceId !== undefined) {
405
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
406
+ }
407
+ headers.set('User-Agent', this.userAgent);
408
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
409
+ const respBody = await executeHttpCall({
410
+ request: httpReq,
411
+ httpClient: this.httpClient,
412
+ logger: this.logger,
413
+ });
414
+ resp = parseResponse(
415
+ respBody,
416
+ unmarshalGetActivationUrlInfoRequest_ResponseSchema
417
+ );
418
+ };
419
+ await executeCall(call, options);
420
+ if (resp === undefined) {
421
+ throw new Error('API call completed without a result.');
422
+ }
423
+ return resp;
424
+ }
425
+
426
+ /**
427
+ * Reads an existing federation policy for an OIDC_FEDERATION recipient for sharing data from <Databricks> to non-<Databricks> recipients.
428
+ * The caller must have read access to the recipient.
429
+ */
430
+ async getFederationPolicy(
431
+ req: GetFederationPolicyRequest,
432
+ options?: CallOptions
433
+ ): Promise<FederationPolicy> {
434
+ const url = `${this.host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies/${req.name ?? ''}`;
435
+ let resp: FederationPolicy | undefined;
436
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
437
+ const headers = new Headers();
438
+ if (this.workspaceId !== undefined) {
439
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
440
+ }
441
+ headers.set('User-Agent', this.userAgent);
442
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
443
+ const respBody = await executeHttpCall({
444
+ request: httpReq,
445
+ httpClient: this.httpClient,
446
+ logger: this.logger,
447
+ });
448
+ resp = parseResponse(respBody, unmarshalFederationPolicySchema);
449
+ };
450
+ await executeCall(call, options);
451
+ if (resp === undefined) {
452
+ throw new Error('API call completed without a result.');
453
+ }
454
+ return resp;
455
+ }
456
+
457
+ /**
458
+ * Gets a specific authentication provider.
459
+ * The caller must supply the name of the provider, and must either be a metastore admin or the owner of the provider.
460
+ */
461
+ async getProvider(
462
+ req: GetProviderRequest,
463
+ options?: CallOptions
464
+ ): Promise<ProviderInfo> {
465
+ const url = `${this.host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
466
+ let resp: ProviderInfo | undefined;
467
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
468
+ const headers = new Headers();
469
+ if (this.workspaceId !== undefined) {
470
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
471
+ }
472
+ headers.set('User-Agent', this.userAgent);
473
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
474
+ const respBody = await executeHttpCall({
475
+ request: httpReq,
476
+ httpClient: this.httpClient,
477
+ logger: this.logger,
478
+ });
479
+ resp = parseResponse(respBody, unmarshalProviderInfoSchema);
480
+ };
481
+ await executeCall(call, options);
482
+ if (resp === undefined) {
483
+ throw new Error('API call completed without a result.');
484
+ }
485
+ return resp;
486
+ }
487
+
488
+ /**
489
+ * Gets a share recipient from the metastore. The caller must be one of:
490
+ * * A user with **USE_RECIPIENT** privilege on the metastore
491
+ * * The owner of the share recipient
492
+ * * A metastore admin
493
+ */
494
+ async getRecipient(
495
+ req: GetRecipientRequest,
496
+ options?: CallOptions
497
+ ): Promise<RecipientInfo> {
498
+ const url = `${this.host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}`;
499
+ let resp: RecipientInfo | undefined;
500
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
501
+ const headers = new Headers();
502
+ if (this.workspaceId !== undefined) {
503
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
504
+ }
505
+ headers.set('User-Agent', this.userAgent);
506
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
507
+ const respBody = await executeHttpCall({
508
+ request: httpReq,
509
+ httpClient: this.httpClient,
510
+ logger: this.logger,
511
+ });
512
+ resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
513
+ };
514
+ await executeCall(call, options);
515
+ if (resp === undefined) {
516
+ throw new Error('API call completed without a result.');
517
+ }
518
+ return resp;
519
+ }
520
+
521
+ /** Gets the share permissions for the specified Recipient. The caller must have the **USE_RECIPIENT** privilege on the metastore or be the owner of the Recipient. */
522
+ async getRecipientSharePermissions(
523
+ req: GetRecipientSharePermissionsRequest,
524
+ options?: CallOptions
525
+ ): Promise<GetRecipientSharePermissionsRequest_Response> {
526
+ const url = `${this.host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}/share-permissions`;
527
+ const params = new URLSearchParams();
528
+ if (req.maxResults !== undefined) {
529
+ params.append('max_results', String(req.maxResults));
530
+ }
531
+ if (req.pageToken !== undefined) {
532
+ params.append('page_token', req.pageToken);
533
+ }
534
+ const query = params.toString();
535
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
536
+ let resp: GetRecipientSharePermissionsRequest_Response | undefined;
537
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
538
+ const headers = new Headers();
539
+ if (this.workspaceId !== undefined) {
540
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
541
+ }
542
+ headers.set('User-Agent', this.userAgent);
543
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
544
+ const respBody = await executeHttpCall({
545
+ request: httpReq,
546
+ httpClient: this.httpClient,
547
+ logger: this.logger,
548
+ });
549
+ resp = parseResponse(
550
+ respBody,
551
+ unmarshalGetRecipientSharePermissionsRequest_ResponseSchema
552
+ );
553
+ };
554
+ await executeCall(call, options);
555
+ if (resp === undefined) {
556
+ throw new Error('API call completed without a result.');
557
+ }
558
+ return resp;
559
+ }
560
+
561
+ /** Gets a data object share from the metastore. The caller must have the USE_SHARE privilege on the metastore or be the owner of the share. */
562
+ async getShare(
563
+ req: GetShareRequest,
564
+ options?: CallOptions
565
+ ): Promise<ShareInfo> {
566
+ const url = `${this.host}/api/2.1/unity-catalog/shares/${req.name ?? ''}`;
567
+ const params = new URLSearchParams();
568
+ if (req.includeSharedData !== undefined) {
569
+ params.append('include_shared_data', String(req.includeSharedData));
570
+ }
571
+ const query = params.toString();
572
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
573
+ let resp: ShareInfo | undefined;
574
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
575
+ const headers = new Headers();
576
+ if (this.workspaceId !== undefined) {
577
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
578
+ }
579
+ headers.set('User-Agent', this.userAgent);
580
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
581
+ const respBody = await executeHttpCall({
582
+ request: httpReq,
583
+ httpClient: this.httpClient,
584
+ logger: this.logger,
585
+ });
586
+ resp = parseResponse(respBody, unmarshalShareInfoSchema);
587
+ };
588
+ await executeCall(call, options);
589
+ if (resp === undefined) {
590
+ throw new Error('API call completed without a result.');
591
+ }
592
+ return resp;
593
+ }
594
+
595
+ /**
596
+ * Gets the permissions for a data share from the metastore.
597
+ * The caller must have the USE_SHARE privilege on the metastore or be the owner of the share.
598
+ */
599
+ async getSharePermissions(
600
+ req: GetSharePermissionsRequest,
601
+ options?: CallOptions
602
+ ): Promise<GetSharePermissionsRequest_Response> {
603
+ const url = `${this.host}/api/2.1/unity-catalog/shares/${req.name ?? ''}/permissions`;
604
+ const params = new URLSearchParams();
605
+ if (req.maxResults !== undefined) {
606
+ params.append('max_results', String(req.maxResults));
607
+ }
608
+ if (req.pageToken !== undefined) {
609
+ params.append('page_token', req.pageToken);
610
+ }
611
+ const query = params.toString();
612
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
613
+ let resp: GetSharePermissionsRequest_Response | undefined;
614
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
615
+ const headers = new Headers();
616
+ if (this.workspaceId !== undefined) {
617
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
618
+ }
619
+ headers.set('User-Agent', this.userAgent);
620
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
621
+ const respBody = await executeHttpCall({
622
+ request: httpReq,
623
+ httpClient: this.httpClient,
624
+ logger: this.logger,
625
+ });
626
+ resp = parseResponse(
627
+ respBody,
628
+ unmarshalGetSharePermissionsRequest_ResponseSchema
629
+ );
630
+ };
631
+ await executeCall(call, options);
632
+ if (resp === undefined) {
633
+ throw new Error('API call completed without a result.');
634
+ }
635
+ return resp;
636
+ }
637
+
638
+ /**
639
+ * Lists federation policies for an OIDC_FEDERATION recipient for sharing data from <Databricks> to non-<Databricks> recipients.
640
+ * The caller must have read access to the recipient.
641
+ */
642
+ async listFederationPolicies(
643
+ req: ListFederationPoliciesRequest,
644
+ options?: CallOptions
645
+ ): Promise<ListFederationPoliciesResponse> {
646
+ const url = `${this.host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies`;
647
+ const params = new URLSearchParams();
648
+ if (req.maxResults !== undefined) {
649
+ params.append('max_results', String(req.maxResults));
650
+ }
651
+ if (req.pageToken !== undefined) {
652
+ params.append('page_token', req.pageToken);
653
+ }
654
+ const query = params.toString();
655
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
656
+ let resp: ListFederationPoliciesResponse | undefined;
657
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
658
+ const headers = new Headers();
659
+ if (this.workspaceId !== undefined) {
660
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
661
+ }
662
+ headers.set('User-Agent', this.userAgent);
663
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
664
+ const respBody = await executeHttpCall({
665
+ request: httpReq,
666
+ httpClient: this.httpClient,
667
+ logger: this.logger,
668
+ });
669
+ resp = parseResponse(
670
+ respBody,
671
+ unmarshalListFederationPoliciesResponseSchema
672
+ );
673
+ };
674
+ await executeCall(call, options);
675
+ if (resp === undefined) {
676
+ throw new Error('API call completed without a result.');
677
+ }
678
+ return resp;
679
+ }
680
+
681
+ async *listFederationPoliciesIter(
682
+ req: ListFederationPoliciesRequest,
683
+ options?: CallOptions
684
+ ): AsyncGenerator<FederationPolicy> {
685
+ const pageReq: ListFederationPoliciesRequest = {...req};
686
+ for (;;) {
687
+ const resp = await this.listFederationPolicies(pageReq, options);
688
+ for (const item of resp.policies ?? []) {
689
+ yield item;
690
+ }
691
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
692
+ return;
693
+ }
694
+ pageReq.pageToken = resp.nextPageToken;
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Get arrays of assets associated with a specified provider's share.
700
+ * The caller is the recipient of the share.
701
+ */
702
+ async listProviderShareAssets(
703
+ req: ListProviderShareAssetsRequest,
704
+ options?: CallOptions
705
+ ): Promise<ListProviderShareAssetsResponse> {
706
+ const url = `${this.host}/api/2.1/data-sharing/providers/${req.providerNameArg ?? ''}/shares/${req.shareNameArg ?? ''}`;
707
+ const params = new URLSearchParams();
708
+ if (req.tableMaxResults !== undefined) {
709
+ params.append('table_max_results', String(req.tableMaxResults));
710
+ }
711
+ if (req.functionMaxResults !== undefined) {
712
+ params.append('function_max_results', String(req.functionMaxResults));
713
+ }
714
+ if (req.volumeMaxResults !== undefined) {
715
+ params.append('volume_max_results', String(req.volumeMaxResults));
716
+ }
717
+ if (req.notebookMaxResults !== undefined) {
718
+ params.append('notebook_max_results', String(req.notebookMaxResults));
719
+ }
720
+ const query = params.toString();
721
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
722
+ let resp: ListProviderShareAssetsResponse | undefined;
723
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
724
+ const headers = new Headers();
725
+ if (this.workspaceId !== undefined) {
726
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
727
+ }
728
+ headers.set('User-Agent', this.userAgent);
729
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
730
+ const respBody = await executeHttpCall({
731
+ request: httpReq,
732
+ httpClient: this.httpClient,
733
+ logger: this.logger,
734
+ });
735
+ resp = parseResponse(
736
+ respBody,
737
+ unmarshalListProviderShareAssetsResponseSchema
738
+ );
739
+ };
740
+ await executeCall(call, options);
741
+ if (resp === undefined) {
742
+ throw new Error('API call completed without a result.');
743
+ }
744
+ return resp;
745
+ }
746
+
747
+ /**
748
+ * Gets an array of a specified provider's shares within the metastore where:
749
+ *
750
+ * * the caller is a metastore admin, or
751
+ * * the caller is the owner.
752
+ */
753
+ async listProviderShares(
754
+ req: ListProviderSharesRequest,
755
+ options?: CallOptions
756
+ ): Promise<ListProviderSharesRequest_Response> {
757
+ const url = `${this.host}/api/2.1/unity-catalog/providers/${req.providerNameArg ?? ''}/shares`;
758
+ const params = new URLSearchParams();
759
+ if (req.maxResults !== undefined) {
760
+ params.append('max_results', String(req.maxResults));
761
+ }
762
+ if (req.pageToken !== undefined) {
763
+ params.append('page_token', req.pageToken);
764
+ }
765
+ const query = params.toString();
766
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
767
+ let resp: ListProviderSharesRequest_Response | undefined;
768
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
769
+ const headers = new Headers();
770
+ if (this.workspaceId !== undefined) {
771
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
772
+ }
773
+ headers.set('User-Agent', this.userAgent);
774
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
775
+ const respBody = await executeHttpCall({
776
+ request: httpReq,
777
+ httpClient: this.httpClient,
778
+ logger: this.logger,
779
+ });
780
+ resp = parseResponse(
781
+ respBody,
782
+ unmarshalListProviderSharesRequest_ResponseSchema
783
+ );
784
+ };
785
+ await executeCall(call, options);
786
+ if (resp === undefined) {
787
+ throw new Error('API call completed without a result.');
788
+ }
789
+ return resp;
790
+ }
791
+
792
+ async *listProviderSharesIter(
793
+ req: ListProviderSharesRequest,
794
+ options?: CallOptions
795
+ ): AsyncGenerator<ProviderShare> {
796
+ const pageReq: ListProviderSharesRequest = {...req};
797
+ for (;;) {
798
+ const resp = await this.listProviderShares(pageReq, options);
799
+ for (const item of resp.shares ?? []) {
800
+ yield item;
801
+ }
802
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
803
+ return;
804
+ }
805
+ pageReq.pageToken = resp.nextPageToken;
806
+ }
807
+ }
808
+
809
+ /**
810
+ * Gets an array of available authentication providers.
811
+ * The caller must either be a metastore admin, have the **USE_PROVIDER** privilege on the providers,
812
+ * or be the owner of the providers. Providers not owned by the caller and for which the caller does
813
+ * not have the **USE_PROVIDER** privilege are not included in the response.
814
+ * There is no guarantee of a specific ordering of the elements in the array.
815
+ */
816
+ async listProviders(
817
+ req: ListProvidersRequest,
818
+ options?: CallOptions
819
+ ): Promise<ListProvidersRequest_Response> {
820
+ const url = `${this.host}/api/2.1/unity-catalog/providers`;
821
+ const params = new URLSearchParams();
822
+ if (req.dataProviderGlobalMetastoreId !== undefined) {
823
+ params.append(
824
+ 'data_provider_global_metastore_id',
825
+ req.dataProviderGlobalMetastoreId
826
+ );
827
+ }
828
+ if (req.maxResults !== undefined) {
829
+ params.append('max_results', String(req.maxResults));
830
+ }
831
+ if (req.pageToken !== undefined) {
832
+ params.append('page_token', req.pageToken);
833
+ }
834
+ const query = params.toString();
835
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
836
+ let resp: ListProvidersRequest_Response | undefined;
837
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
838
+ const headers = new Headers();
839
+ if (this.workspaceId !== undefined) {
840
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
841
+ }
842
+ headers.set('User-Agent', this.userAgent);
843
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
844
+ const respBody = await executeHttpCall({
845
+ request: httpReq,
846
+ httpClient: this.httpClient,
847
+ logger: this.logger,
848
+ });
849
+ resp = parseResponse(
850
+ respBody,
851
+ unmarshalListProvidersRequest_ResponseSchema
852
+ );
853
+ };
854
+ await executeCall(call, options);
855
+ if (resp === undefined) {
856
+ throw new Error('API call completed without a result.');
857
+ }
858
+ return resp;
859
+ }
860
+
861
+ async *listProvidersIter(
862
+ req: ListProvidersRequest,
863
+ options?: CallOptions
864
+ ): AsyncGenerator<ProviderInfo> {
865
+ const pageReq: ListProvidersRequest = {...req};
866
+ for (;;) {
867
+ const resp = await this.listProviders(pageReq, options);
868
+ for (const item of resp.providers ?? []) {
869
+ yield item;
870
+ }
871
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
872
+ return;
873
+ }
874
+ pageReq.pageToken = resp.nextPageToken;
875
+ }
876
+ }
877
+
878
+ /**
879
+ * Gets an array of all share recipients within the current metastore where:
880
+ *
881
+ * * the caller is a metastore admin, or
882
+ * * the caller is the owner.
883
+ * There is no guarantee of a specific ordering of the elements in the array.
884
+ */
885
+ async listRecipients(
886
+ req: ListRecipientsRequest,
887
+ options?: CallOptions
888
+ ): Promise<ListRecipientsRequest_Response> {
889
+ const url = `${this.host}/api/2.1/unity-catalog/recipients`;
890
+ const params = new URLSearchParams();
891
+ if (req.dataRecipientGlobalMetastoreId !== undefined) {
892
+ params.append(
893
+ 'data_recipient_global_metastore_id',
894
+ req.dataRecipientGlobalMetastoreId
895
+ );
896
+ }
897
+ if (req.maxResults !== undefined) {
898
+ params.append('max_results', String(req.maxResults));
899
+ }
900
+ if (req.pageToken !== undefined) {
901
+ params.append('page_token', req.pageToken);
902
+ }
903
+ const query = params.toString();
904
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
905
+ let resp: ListRecipientsRequest_Response | undefined;
906
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
907
+ const headers = new Headers();
908
+ if (this.workspaceId !== undefined) {
909
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
910
+ }
911
+ headers.set('User-Agent', this.userAgent);
912
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
913
+ const respBody = await executeHttpCall({
914
+ request: httpReq,
915
+ httpClient: this.httpClient,
916
+ logger: this.logger,
917
+ });
918
+ resp = parseResponse(
919
+ respBody,
920
+ unmarshalListRecipientsRequest_ResponseSchema
921
+ );
922
+ };
923
+ await executeCall(call, options);
924
+ if (resp === undefined) {
925
+ throw new Error('API call completed without a result.');
926
+ }
927
+ return resp;
928
+ }
929
+
930
+ async *listRecipientsIter(
931
+ req: ListRecipientsRequest,
932
+ options?: CallOptions
933
+ ): AsyncGenerator<RecipientInfo> {
934
+ const pageReq: ListRecipientsRequest = {...req};
935
+ for (;;) {
936
+ const resp = await this.listRecipients(pageReq, options);
937
+ for (const item of resp.recipients ?? []) {
938
+ yield item;
939
+ }
940
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
941
+ return;
942
+ }
943
+ pageReq.pageToken = resp.nextPageToken;
944
+ }
945
+ }
946
+
947
+ /**
948
+ * Gets an array of data object shares from the metastore. If the caller has the USE_SHARE privilege on the metastore, all shares are returned. Otherwise, only shares owned by the caller are returned.
949
+ * There is no guarantee of a specific ordering of the elements in the array.
950
+ */
951
+ async listShares(
952
+ req: ListSharesRequest,
953
+ options?: CallOptions
954
+ ): Promise<ListSharesRequest_Response> {
955
+ const url = `${this.host}/api/2.1/unity-catalog/shares`;
956
+ const params = new URLSearchParams();
957
+ if (req.maxResults !== undefined) {
958
+ params.append('max_results', String(req.maxResults));
959
+ }
960
+ if (req.pageToken !== undefined) {
961
+ params.append('page_token', req.pageToken);
962
+ }
963
+ const query = params.toString();
964
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
965
+ let resp: ListSharesRequest_Response | undefined;
966
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
967
+ const headers = new Headers();
968
+ if (this.workspaceId !== undefined) {
969
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
970
+ }
971
+ headers.set('User-Agent', this.userAgent);
972
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
973
+ const respBody = await executeHttpCall({
974
+ request: httpReq,
975
+ httpClient: this.httpClient,
976
+ logger: this.logger,
977
+ });
978
+ resp = parseResponse(respBody, unmarshalListSharesRequest_ResponseSchema);
979
+ };
980
+ await executeCall(call, options);
981
+ if (resp === undefined) {
982
+ throw new Error('API call completed without a result.');
983
+ }
984
+ return resp;
985
+ }
986
+
987
+ async *listSharesIter(
988
+ req: ListSharesRequest,
989
+ options?: CallOptions
990
+ ): AsyncGenerator<ShareInfo> {
991
+ const pageReq: ListSharesRequest = {...req};
992
+ for (;;) {
993
+ const resp = await this.listShares(pageReq, options);
994
+ for (const item of resp.shares ?? []) {
995
+ yield item;
996
+ }
997
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
998
+ return;
999
+ }
1000
+ pageReq.pageToken = resp.nextPageToken;
1001
+ }
1002
+ }
1003
+
1004
+ /**
1005
+ * Retrieve access token with an activation url.
1006
+ * This is a public API without any authentication.
1007
+ */
1008
+ async retrieveAccessToken(
1009
+ req: RetrieveToken,
1010
+ options?: CallOptions
1011
+ ): Promise<RetrieveToken_Response> {
1012
+ const url = `${this.host}/api/2.1/unity-catalog/public/data_sharing_activation/${req.activationUrl ?? ''}`;
1013
+ let resp: RetrieveToken_Response | undefined;
1014
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1015
+ const headers = new Headers();
1016
+ if (this.workspaceId !== undefined) {
1017
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1018
+ }
1019
+ headers.set('User-Agent', this.userAgent);
1020
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
1021
+ const respBody = await executeHttpCall({
1022
+ request: httpReq,
1023
+ httpClient: this.httpClient,
1024
+ logger: this.logger,
1025
+ });
1026
+ resp = parseResponse(respBody, unmarshalRetrieveToken_ResponseSchema);
1027
+ };
1028
+ await executeCall(call, options);
1029
+ if (resp === undefined) {
1030
+ throw new Error('API call completed without a result.');
1031
+ }
1032
+ return resp;
1033
+ }
1034
+
1035
+ /**
1036
+ * Refreshes the specified recipient's delta sharing authentication token with the provided token info.
1037
+ * The caller must be the owner of the recipient.
1038
+ */
1039
+ async rotateRecipientToken(
1040
+ req: RotateRecipientTokenRequest,
1041
+ options?: CallOptions
1042
+ ): Promise<RecipientInfo> {
1043
+ const url = `${this.host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}/rotate-token`;
1044
+ const body = marshalRequest(req, marshalRotateRecipientTokenRequestSchema);
1045
+ let resp: RecipientInfo | undefined;
1046
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1047
+ const headers = new Headers({'Content-Type': 'application/json'});
1048
+ if (this.workspaceId !== undefined) {
1049
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1050
+ }
1051
+ headers.set('User-Agent', this.userAgent);
1052
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1053
+ const respBody = await executeHttpCall({
1054
+ request: httpReq,
1055
+ httpClient: this.httpClient,
1056
+ logger: this.logger,
1057
+ });
1058
+ resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
1059
+ };
1060
+ await executeCall(call, options);
1061
+ if (resp === undefined) {
1062
+ throw new Error('API call completed without a result.');
1063
+ }
1064
+ return resp;
1065
+ }
1066
+
1067
+ /**
1068
+ * Updates the information for an authentication provider, if the caller is a metastore admin or is the owner of the provider.
1069
+ * If the update changes the provider name, the caller must be both a metastore admin and the owner of the provider.
1070
+ */
1071
+ async updateProvider(
1072
+ req: UpdateProviderRequest,
1073
+ options?: CallOptions
1074
+ ): Promise<ProviderInfo> {
1075
+ const url = `${this.host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
1076
+ const body = marshalRequest(req, marshalUpdateProviderRequestSchema);
1077
+ let resp: ProviderInfo | undefined;
1078
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1079
+ const headers = new Headers({'Content-Type': 'application/json'});
1080
+ if (this.workspaceId !== undefined) {
1081
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1082
+ }
1083
+ headers.set('User-Agent', this.userAgent);
1084
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1085
+ const respBody = await executeHttpCall({
1086
+ request: httpReq,
1087
+ httpClient: this.httpClient,
1088
+ logger: this.logger,
1089
+ });
1090
+ resp = parseResponse(respBody, unmarshalProviderInfoSchema);
1091
+ };
1092
+ await executeCall(call, options);
1093
+ if (resp === undefined) {
1094
+ throw new Error('API call completed without a result.');
1095
+ }
1096
+ return resp;
1097
+ }
1098
+
1099
+ /**
1100
+ * Updates an existing recipient in the metastore. The caller must be a metastore admin or the owner of the recipient.
1101
+ * If the recipient name will be updated, the user must be both a metastore admin and the owner of the recipient.
1102
+ */
1103
+ async updateRecipient(
1104
+ req: UpdateRecipientRequest,
1105
+ options?: CallOptions
1106
+ ): Promise<RecipientInfo> {
1107
+ const url = `${this.host}/api/2.1/unity-catalog/recipients/${req.nameArg ?? ''}`;
1108
+ const body = marshalRequest(req, marshalUpdateRecipientRequestSchema);
1109
+ let resp: RecipientInfo | undefined;
1110
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1111
+ const headers = new Headers({'Content-Type': 'application/json'});
1112
+ if (this.workspaceId !== undefined) {
1113
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1114
+ }
1115
+ headers.set('User-Agent', this.userAgent);
1116
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1117
+ const respBody = await executeHttpCall({
1118
+ request: httpReq,
1119
+ httpClient: this.httpClient,
1120
+ logger: this.logger,
1121
+ });
1122
+ resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
1123
+ };
1124
+ await executeCall(call, options);
1125
+ if (resp === undefined) {
1126
+ throw new Error('API call completed without a result.');
1127
+ }
1128
+ return resp;
1129
+ }
1130
+
1131
+ /**
1132
+ * Updates the share with the changes and data objects in the request.
1133
+ * The caller must be the owner of the share or a metastore admin.
1134
+ *
1135
+ * When the caller is a metastore admin, only the __owner__ field can be updated.
1136
+ *
1137
+ * In the case the share name is changed, **updateShare** requires that the caller is the owner of the share
1138
+ * and has the CREATE_SHARE privilege.
1139
+ *
1140
+ * If there are notebook files in the share, the __storage_root__ field cannot be updated.
1141
+ *
1142
+ * For each table that is added through this method, the share owner must also have **SELECT** privilege on the table.
1143
+ * This privilege must be maintained indefinitely for recipients to be able to access the table.
1144
+ * Typically, you should use a group as the share owner.
1145
+ *
1146
+ * Table removals through **update** do not require additional privileges.
1147
+ */
1148
+ async updateShare(
1149
+ req: UpdateShareRequest,
1150
+ options?: CallOptions
1151
+ ): Promise<ShareInfo> {
1152
+ const url = `${this.host}/api/2.1/unity-catalog/shares/${req.nameArg ?? ''}`;
1153
+ const body = marshalRequest(req, marshalUpdateShareRequestSchema);
1154
+ let resp: ShareInfo | undefined;
1155
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1156
+ const headers = new Headers({'Content-Type': 'application/json'});
1157
+ if (this.workspaceId !== undefined) {
1158
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1159
+ }
1160
+ headers.set('User-Agent', this.userAgent);
1161
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1162
+ const respBody = await executeHttpCall({
1163
+ request: httpReq,
1164
+ httpClient: this.httpClient,
1165
+ logger: this.logger,
1166
+ });
1167
+ resp = parseResponse(respBody, unmarshalShareInfoSchema);
1168
+ };
1169
+ await executeCall(call, options);
1170
+ if (resp === undefined) {
1171
+ throw new Error('API call completed without a result.');
1172
+ }
1173
+ return resp;
1174
+ }
1175
+
1176
+ /**
1177
+ * Updates the permissions for a data share in the metastore.
1178
+ * The caller must have both the USE_SHARE and SET_SHARE_PERMISSION privileges on the metastore,
1179
+ * or be the owner of the share.
1180
+ *
1181
+ * For new recipient grants, the user must also be the owner of the recipients.
1182
+ * recipient revocations do not require additional privileges.
1183
+ */
1184
+ async updateSharePermissions(
1185
+ req: UpdateSharePermissionsRequest,
1186
+ options?: CallOptions
1187
+ ): Promise<UpdateSharePermissionsRequest_Response> {
1188
+ const url = `${this.host}/api/2.1/unity-catalog/shares/${req.name ?? ''}/permissions`;
1189
+ const body = marshalRequest(
1190
+ req,
1191
+ marshalUpdateSharePermissionsRequestSchema
1192
+ );
1193
+ let resp: UpdateSharePermissionsRequest_Response | undefined;
1194
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
1195
+ const headers = new Headers({'Content-Type': 'application/json'});
1196
+ if (this.workspaceId !== undefined) {
1197
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
1198
+ }
1199
+ headers.set('User-Agent', this.userAgent);
1200
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1201
+ const respBody = await executeHttpCall({
1202
+ request: httpReq,
1203
+ httpClient: this.httpClient,
1204
+ logger: this.logger,
1205
+ });
1206
+ resp = parseResponse(
1207
+ respBody,
1208
+ unmarshalUpdateSharePermissionsRequest_ResponseSchema
1209
+ );
1210
+ };
1211
+ await executeCall(call, options);
1212
+ if (resp === undefined) {
1213
+ throw new Error('API call completed without a result.');
1214
+ }
1215
+ return resp;
1216
+ }
1217
+ }