@databricks/sdk-sharing 0.0.0-dev → 0.1.0-dev.2

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