@databricks/sdk-sharing 0.1.0-dev.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/v1/client.d.ts +5 -5
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +146 -121
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/model.d.ts +1 -5
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +30 -2
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +33 -16
- package/dist/v1/transport.js.map +1 -1
- package/package.json +9 -4
package/dist/v1/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
3
|
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
4
4
|
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
5
|
-
import {
|
|
5
|
+
import { resolveClientConfig } from './transport';
|
|
6
6
|
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
|
|
7
7
|
import pkgJson from '../../package.json' with { type: 'json' };
|
|
8
8
|
import { marshalCreateProviderRequestSchema, marshalCreateRecipientRequestSchema, marshalCreateShareRequestSchema, marshalFederationPolicySchema, marshalRotateRecipientTokenRequestSchema, marshalUpdateProviderRequestSchema, marshalUpdateRecipientRequestSchema, marshalUpdateSharePermissionsRequestSchema, marshalUpdateShareRequestSchema, unmarshalDeleteProviderResponseSchema, unmarshalDeleteRecipientResponseSchema, unmarshalDeleteShareResponseSchema, unmarshalFederationPolicySchema, unmarshalGetActivationUrlInfoResponseSchema, unmarshalGetRecipientSharePermissionsResponseSchema, unmarshalGetSharePermissionsResponseSchema, unmarshalListFederationPoliciesResponseSchema, unmarshalListProviderShareAssetsResponseSchema, unmarshalListProviderSharesResponseSchema, unmarshalListProvidersResponseSchema, unmarshalListRecipientsResponseSchema, unmarshalListSharesResponseSchema, unmarshalProviderInfoSchema, unmarshalRecipientInfoSchema, unmarshalRetrieveTokenResponseSchema, unmarshalShareInfoSchema, unmarshalUpdateSharePermissionsResponseSchema, } from './model';
|
|
@@ -12,30 +12,28 @@ const PACKAGE_SEGMENT = {
|
|
|
12
12
|
value: pkgJson.version,
|
|
13
13
|
};
|
|
14
14
|
export class SharingClient {
|
|
15
|
-
|
|
16
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
17
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
18
|
-
// request.
|
|
19
|
-
workspaceId;
|
|
20
|
-
httpClient;
|
|
15
|
+
options;
|
|
21
16
|
logger;
|
|
22
17
|
// User-Agent header value. Composed once at construction from
|
|
23
18
|
// createDefault() merged with this package's identity and the active
|
|
24
19
|
// credential's name.
|
|
25
20
|
userAgent;
|
|
21
|
+
// Memoized configuration. The profile is resolved once, lazily, on the first
|
|
22
|
+
// request, then reused; host, workspaceId/accountId, and credentials are
|
|
23
|
+
// filled from it when not set explicitly on the options.
|
|
24
|
+
config;
|
|
26
25
|
constructor(options) {
|
|
27
|
-
|
|
28
|
-
throw new Error('Host is required.');
|
|
29
|
-
}
|
|
30
|
-
this.host = options.host.replace(/\/$/, '');
|
|
31
|
-
this.workspaceId = options.workspaceId;
|
|
26
|
+
this.options = options;
|
|
32
27
|
this.logger = options.logger ?? new NoOpLogger();
|
|
33
28
|
const info = createDefault()
|
|
34
29
|
.with(PACKAGE_SEGMENT)
|
|
35
30
|
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
36
31
|
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
37
32
|
this.userAgent = info.toString();
|
|
38
|
-
|
|
33
|
+
}
|
|
34
|
+
resolveConfig() {
|
|
35
|
+
this.config ??= resolveClientConfig(this.options);
|
|
36
|
+
return this.config;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* Create a federation policy for an OIDC_FEDERATION recipient for sharing data from <Databricks> to non-<Databricks> recipients.
|
|
@@ -59,19 +57,20 @@ export class SharingClient {
|
|
|
59
57
|
* - Configuration and usage for User-to-Machine (U2M) applications (e.g., PowerBI): https://docs.databricks.com/aws/en/delta-sharing/sharing-over-oidc-u2m
|
|
60
58
|
*/
|
|
61
59
|
async createFederationPolicy(req, options) {
|
|
62
|
-
const
|
|
60
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
61
|
+
const url = `${host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies`;
|
|
63
62
|
const body = marshalRequest(req.policy, marshalFederationPolicySchema);
|
|
64
63
|
let resp;
|
|
65
64
|
const call = async (callSignal) => {
|
|
66
65
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
67
|
-
if (
|
|
68
|
-
headers.set('X-Databricks-Org-Id',
|
|
66
|
+
if (workspaceId !== undefined) {
|
|
67
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
69
68
|
}
|
|
70
69
|
headers.set('User-Agent', this.userAgent);
|
|
71
70
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
72
71
|
const respBody = await executeHttpCall({
|
|
73
72
|
request: httpReq,
|
|
74
|
-
httpClient
|
|
73
|
+
httpClient,
|
|
75
74
|
logger: this.logger,
|
|
76
75
|
});
|
|
77
76
|
resp = parseResponse(respBody, unmarshalFederationPolicySchema);
|
|
@@ -87,19 +86,20 @@ export class SharingClient {
|
|
|
87
86
|
* The caller must be an admin on the metastore.
|
|
88
87
|
*/
|
|
89
88
|
async createProvider(req, options) {
|
|
90
|
-
const
|
|
89
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
90
|
+
const url = `${host}/api/2.1/unity-catalog/providers`;
|
|
91
91
|
const body = marshalRequest(req, marshalCreateProviderRequestSchema);
|
|
92
92
|
let resp;
|
|
93
93
|
const call = async (callSignal) => {
|
|
94
94
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
95
|
-
if (
|
|
96
|
-
headers.set('X-Databricks-Org-Id',
|
|
95
|
+
if (workspaceId !== undefined) {
|
|
96
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
97
97
|
}
|
|
98
98
|
headers.set('User-Agent', this.userAgent);
|
|
99
99
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
100
100
|
const respBody = await executeHttpCall({
|
|
101
101
|
request: httpReq,
|
|
102
|
-
httpClient
|
|
102
|
+
httpClient,
|
|
103
103
|
logger: this.logger,
|
|
104
104
|
});
|
|
105
105
|
resp = parseResponse(respBody, unmarshalProviderInfoSchema);
|
|
@@ -115,19 +115,20 @@ export class SharingClient {
|
|
|
115
115
|
* The caller must be a metastore admin or have the **CREATE_RECIPIENT** privilege on the metastore.
|
|
116
116
|
*/
|
|
117
117
|
async createRecipient(req, options) {
|
|
118
|
-
const
|
|
118
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
119
|
+
const url = `${host}/api/2.1/unity-catalog/recipients`;
|
|
119
120
|
const body = marshalRequest(req, marshalCreateRecipientRequestSchema);
|
|
120
121
|
let resp;
|
|
121
122
|
const call = async (callSignal) => {
|
|
122
123
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
123
|
-
if (
|
|
124
|
-
headers.set('X-Databricks-Org-Id',
|
|
124
|
+
if (workspaceId !== undefined) {
|
|
125
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
125
126
|
}
|
|
126
127
|
headers.set('User-Agent', this.userAgent);
|
|
127
128
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
128
129
|
const respBody = await executeHttpCall({
|
|
129
130
|
request: httpReq,
|
|
130
|
-
httpClient
|
|
131
|
+
httpClient,
|
|
131
132
|
logger: this.logger,
|
|
132
133
|
});
|
|
133
134
|
resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
|
|
@@ -143,19 +144,20 @@ export class SharingClient {
|
|
|
143
144
|
* The caller must be a metastore admin or have the **CREATE_SHARE** privilege on the metastore.
|
|
144
145
|
*/
|
|
145
146
|
async createShare(req, options) {
|
|
146
|
-
const
|
|
147
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
148
|
+
const url = `${host}/api/2.1/unity-catalog/shares`;
|
|
147
149
|
const body = marshalRequest(req, marshalCreateShareRequestSchema);
|
|
148
150
|
let resp;
|
|
149
151
|
const call = async (callSignal) => {
|
|
150
152
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
151
|
-
if (
|
|
152
|
-
headers.set('X-Databricks-Org-Id',
|
|
153
|
+
if (workspaceId !== undefined) {
|
|
154
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
153
155
|
}
|
|
154
156
|
headers.set('User-Agent', this.userAgent);
|
|
155
157
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
156
158
|
const respBody = await executeHttpCall({
|
|
157
159
|
request: httpReq,
|
|
158
|
-
httpClient
|
|
160
|
+
httpClient,
|
|
159
161
|
logger: this.logger,
|
|
160
162
|
});
|
|
161
163
|
resp = parseResponse(respBody, unmarshalShareInfoSchema);
|
|
@@ -171,17 +173,18 @@ export class SharingClient {
|
|
|
171
173
|
* The caller must be the owner of the recipient.
|
|
172
174
|
*/
|
|
173
175
|
async deleteFederationPolicy(req, options) {
|
|
174
|
-
const
|
|
176
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
177
|
+
const url = `${host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies/${req.name ?? ''}`;
|
|
175
178
|
const call = async (callSignal) => {
|
|
176
179
|
const headers = new Headers();
|
|
177
|
-
if (
|
|
178
|
-
headers.set('X-Databricks-Org-Id',
|
|
180
|
+
if (workspaceId !== undefined) {
|
|
181
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
179
182
|
}
|
|
180
183
|
headers.set('User-Agent', this.userAgent);
|
|
181
184
|
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
182
185
|
await executeHttpCall({
|
|
183
186
|
request: httpReq,
|
|
184
|
-
httpClient
|
|
187
|
+
httpClient,
|
|
185
188
|
logger: this.logger,
|
|
186
189
|
});
|
|
187
190
|
};
|
|
@@ -189,18 +192,19 @@ export class SharingClient {
|
|
|
189
192
|
}
|
|
190
193
|
/** Deletes an authentication provider, if the caller is a metastore admin or is the owner of the provider. */
|
|
191
194
|
async deleteProvider(req, options) {
|
|
192
|
-
const
|
|
195
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
196
|
+
const url = `${host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
|
|
193
197
|
let resp;
|
|
194
198
|
const call = async (callSignal) => {
|
|
195
199
|
const headers = new Headers();
|
|
196
|
-
if (
|
|
197
|
-
headers.set('X-Databricks-Org-Id',
|
|
200
|
+
if (workspaceId !== undefined) {
|
|
201
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
198
202
|
}
|
|
199
203
|
headers.set('User-Agent', this.userAgent);
|
|
200
204
|
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
201
205
|
const respBody = await executeHttpCall({
|
|
202
206
|
request: httpReq,
|
|
203
|
-
httpClient
|
|
207
|
+
httpClient,
|
|
204
208
|
logger: this.logger,
|
|
205
209
|
});
|
|
206
210
|
resp = parseResponse(respBody, unmarshalDeleteProviderResponseSchema);
|
|
@@ -213,18 +217,19 @@ export class SharingClient {
|
|
|
213
217
|
}
|
|
214
218
|
/** Deletes the specified recipient from the metastore. The caller must be the owner of the recipient. */
|
|
215
219
|
async deleteRecipient(req, options) {
|
|
216
|
-
const
|
|
220
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
221
|
+
const url = `${host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}`;
|
|
217
222
|
let resp;
|
|
218
223
|
const call = async (callSignal) => {
|
|
219
224
|
const headers = new Headers();
|
|
220
|
-
if (
|
|
221
|
-
headers.set('X-Databricks-Org-Id',
|
|
225
|
+
if (workspaceId !== undefined) {
|
|
226
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
222
227
|
}
|
|
223
228
|
headers.set('User-Agent', this.userAgent);
|
|
224
229
|
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
225
230
|
const respBody = await executeHttpCall({
|
|
226
231
|
request: httpReq,
|
|
227
|
-
httpClient
|
|
232
|
+
httpClient,
|
|
228
233
|
logger: this.logger,
|
|
229
234
|
});
|
|
230
235
|
resp = parseResponse(respBody, unmarshalDeleteRecipientResponseSchema);
|
|
@@ -237,18 +242,19 @@ export class SharingClient {
|
|
|
237
242
|
}
|
|
238
243
|
/** Deletes a data object share from the metastore. The caller must be an owner of the share. */
|
|
239
244
|
async deleteShare(req, options) {
|
|
240
|
-
const
|
|
245
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
246
|
+
const url = `${host}/api/2.1/unity-catalog/shares/${req.name ?? ''}`;
|
|
241
247
|
let resp;
|
|
242
248
|
const call = async (callSignal) => {
|
|
243
249
|
const headers = new Headers();
|
|
244
|
-
if (
|
|
245
|
-
headers.set('X-Databricks-Org-Id',
|
|
250
|
+
if (workspaceId !== undefined) {
|
|
251
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
246
252
|
}
|
|
247
253
|
headers.set('User-Agent', this.userAgent);
|
|
248
254
|
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
249
255
|
const respBody = await executeHttpCall({
|
|
250
256
|
request: httpReq,
|
|
251
|
-
httpClient
|
|
257
|
+
httpClient,
|
|
252
258
|
logger: this.logger,
|
|
253
259
|
});
|
|
254
260
|
resp = parseResponse(respBody, unmarshalDeleteShareResponseSchema);
|
|
@@ -261,18 +267,19 @@ export class SharingClient {
|
|
|
261
267
|
}
|
|
262
268
|
/** Gets an activation URL for a share. */
|
|
263
269
|
async getActivationUrlInfo(req, options) {
|
|
264
|
-
const
|
|
270
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
271
|
+
const url = `${host}/api/2.1/unity-catalog/public/data_sharing_activation_info/${req.activationUrl ?? ''}`;
|
|
265
272
|
let resp;
|
|
266
273
|
const call = async (callSignal) => {
|
|
267
274
|
const headers = new Headers();
|
|
268
|
-
if (
|
|
269
|
-
headers.set('X-Databricks-Org-Id',
|
|
275
|
+
if (workspaceId !== undefined) {
|
|
276
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
270
277
|
}
|
|
271
278
|
headers.set('User-Agent', this.userAgent);
|
|
272
279
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
273
280
|
const respBody = await executeHttpCall({
|
|
274
281
|
request: httpReq,
|
|
275
|
-
httpClient
|
|
282
|
+
httpClient,
|
|
276
283
|
logger: this.logger,
|
|
277
284
|
});
|
|
278
285
|
resp = parseResponse(respBody, unmarshalGetActivationUrlInfoResponseSchema);
|
|
@@ -288,18 +295,19 @@ export class SharingClient {
|
|
|
288
295
|
* The caller must have read access to the recipient.
|
|
289
296
|
*/
|
|
290
297
|
async getFederationPolicy(req, options) {
|
|
291
|
-
const
|
|
298
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
299
|
+
const url = `${host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies/${req.name ?? ''}`;
|
|
292
300
|
let resp;
|
|
293
301
|
const call = async (callSignal) => {
|
|
294
302
|
const headers = new Headers();
|
|
295
|
-
if (
|
|
296
|
-
headers.set('X-Databricks-Org-Id',
|
|
303
|
+
if (workspaceId !== undefined) {
|
|
304
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
297
305
|
}
|
|
298
306
|
headers.set('User-Agent', this.userAgent);
|
|
299
307
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
300
308
|
const respBody = await executeHttpCall({
|
|
301
309
|
request: httpReq,
|
|
302
|
-
httpClient
|
|
310
|
+
httpClient,
|
|
303
311
|
logger: this.logger,
|
|
304
312
|
});
|
|
305
313
|
resp = parseResponse(respBody, unmarshalFederationPolicySchema);
|
|
@@ -315,18 +323,19 @@ export class SharingClient {
|
|
|
315
323
|
* The caller must supply the name of the provider, and must either be a metastore admin or the owner of the provider.
|
|
316
324
|
*/
|
|
317
325
|
async getProvider(req, options) {
|
|
318
|
-
const
|
|
326
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
327
|
+
const url = `${host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
|
|
319
328
|
let resp;
|
|
320
329
|
const call = async (callSignal) => {
|
|
321
330
|
const headers = new Headers();
|
|
322
|
-
if (
|
|
323
|
-
headers.set('X-Databricks-Org-Id',
|
|
331
|
+
if (workspaceId !== undefined) {
|
|
332
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
324
333
|
}
|
|
325
334
|
headers.set('User-Agent', this.userAgent);
|
|
326
335
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
327
336
|
const respBody = await executeHttpCall({
|
|
328
337
|
request: httpReq,
|
|
329
|
-
httpClient
|
|
338
|
+
httpClient,
|
|
330
339
|
logger: this.logger,
|
|
331
340
|
});
|
|
332
341
|
resp = parseResponse(respBody, unmarshalProviderInfoSchema);
|
|
@@ -344,18 +353,19 @@ export class SharingClient {
|
|
|
344
353
|
* * A metastore admin
|
|
345
354
|
*/
|
|
346
355
|
async getRecipient(req, options) {
|
|
347
|
-
const
|
|
356
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
357
|
+
const url = `${host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}`;
|
|
348
358
|
let resp;
|
|
349
359
|
const call = async (callSignal) => {
|
|
350
360
|
const headers = new Headers();
|
|
351
|
-
if (
|
|
352
|
-
headers.set('X-Databricks-Org-Id',
|
|
361
|
+
if (workspaceId !== undefined) {
|
|
362
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
353
363
|
}
|
|
354
364
|
headers.set('User-Agent', this.userAgent);
|
|
355
365
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
356
366
|
const respBody = await executeHttpCall({
|
|
357
367
|
request: httpReq,
|
|
358
|
-
httpClient
|
|
368
|
+
httpClient,
|
|
359
369
|
logger: this.logger,
|
|
360
370
|
});
|
|
361
371
|
resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
|
|
@@ -368,7 +378,8 @@ export class SharingClient {
|
|
|
368
378
|
}
|
|
369
379
|
/** 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. */
|
|
370
380
|
async getShare(req, options) {
|
|
371
|
-
const
|
|
381
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
382
|
+
const url = `${host}/api/2.1/unity-catalog/shares/${req.name ?? ''}`;
|
|
372
383
|
const params = new URLSearchParams();
|
|
373
384
|
if (req.includeSharedData !== undefined) {
|
|
374
385
|
params.append('include_shared_data', String(req.includeSharedData));
|
|
@@ -378,14 +389,14 @@ export class SharingClient {
|
|
|
378
389
|
let resp;
|
|
379
390
|
const call = async (callSignal) => {
|
|
380
391
|
const headers = new Headers();
|
|
381
|
-
if (
|
|
382
|
-
headers.set('X-Databricks-Org-Id',
|
|
392
|
+
if (workspaceId !== undefined) {
|
|
393
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
383
394
|
}
|
|
384
395
|
headers.set('User-Agent', this.userAgent);
|
|
385
396
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
386
397
|
const respBody = await executeHttpCall({
|
|
387
398
|
request: httpReq,
|
|
388
|
-
httpClient
|
|
399
|
+
httpClient,
|
|
389
400
|
logger: this.logger,
|
|
390
401
|
});
|
|
391
402
|
resp = parseResponse(respBody, unmarshalShareInfoSchema);
|
|
@@ -401,7 +412,8 @@ export class SharingClient {
|
|
|
401
412
|
* The caller must have read access to the recipient.
|
|
402
413
|
*/
|
|
403
414
|
async listFederationPolicies(req, options) {
|
|
404
|
-
const
|
|
415
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
416
|
+
const url = `${host}/api/2.0/data-sharing/recipients/${req.recipientName ?? ''}/federation-policies`;
|
|
405
417
|
const params = new URLSearchParams();
|
|
406
418
|
if (req.maxResults !== undefined) {
|
|
407
419
|
params.append('max_results', String(req.maxResults));
|
|
@@ -414,14 +426,14 @@ export class SharingClient {
|
|
|
414
426
|
let resp;
|
|
415
427
|
const call = async (callSignal) => {
|
|
416
428
|
const headers = new Headers();
|
|
417
|
-
if (
|
|
418
|
-
headers.set('X-Databricks-Org-Id',
|
|
429
|
+
if (workspaceId !== undefined) {
|
|
430
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
419
431
|
}
|
|
420
432
|
headers.set('User-Agent', this.userAgent);
|
|
421
433
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
422
434
|
const respBody = await executeHttpCall({
|
|
423
435
|
request: httpReq,
|
|
424
|
-
httpClient
|
|
436
|
+
httpClient,
|
|
425
437
|
logger: this.logger,
|
|
426
438
|
});
|
|
427
439
|
resp = parseResponse(respBody, unmarshalListFederationPoliciesResponseSchema);
|
|
@@ -450,7 +462,8 @@ export class SharingClient {
|
|
|
450
462
|
* The caller is the recipient of the share.
|
|
451
463
|
*/
|
|
452
464
|
async listProviderShareAssets(req, options) {
|
|
453
|
-
const
|
|
465
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
466
|
+
const url = `${host}/api/2.1/data-sharing/providers/${req.providerNameArg ?? ''}/shares/${req.shareNameArg ?? ''}`;
|
|
454
467
|
const params = new URLSearchParams();
|
|
455
468
|
if (req.tableMaxResults !== undefined) {
|
|
456
469
|
params.append('table_max_results', String(req.tableMaxResults));
|
|
@@ -469,14 +482,14 @@ export class SharingClient {
|
|
|
469
482
|
let resp;
|
|
470
483
|
const call = async (callSignal) => {
|
|
471
484
|
const headers = new Headers();
|
|
472
|
-
if (
|
|
473
|
-
headers.set('X-Databricks-Org-Id',
|
|
485
|
+
if (workspaceId !== undefined) {
|
|
486
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
474
487
|
}
|
|
475
488
|
headers.set('User-Agent', this.userAgent);
|
|
476
489
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
477
490
|
const respBody = await executeHttpCall({
|
|
478
491
|
request: httpReq,
|
|
479
|
-
httpClient
|
|
492
|
+
httpClient,
|
|
480
493
|
logger: this.logger,
|
|
481
494
|
});
|
|
482
495
|
resp = parseResponse(respBody, unmarshalListProviderShareAssetsResponseSchema);
|
|
@@ -494,7 +507,8 @@ export class SharingClient {
|
|
|
494
507
|
* * the caller is the owner.
|
|
495
508
|
*/
|
|
496
509
|
async listProviderShares(req, options) {
|
|
497
|
-
const
|
|
510
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
511
|
+
const url = `${host}/api/2.1/unity-catalog/providers/${req.providerNameArg ?? ''}/shares`;
|
|
498
512
|
const params = new URLSearchParams();
|
|
499
513
|
if (req.maxResults !== undefined) {
|
|
500
514
|
params.append('max_results', String(req.maxResults));
|
|
@@ -507,14 +521,14 @@ export class SharingClient {
|
|
|
507
521
|
let resp;
|
|
508
522
|
const call = async (callSignal) => {
|
|
509
523
|
const headers = new Headers();
|
|
510
|
-
if (
|
|
511
|
-
headers.set('X-Databricks-Org-Id',
|
|
524
|
+
if (workspaceId !== undefined) {
|
|
525
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
512
526
|
}
|
|
513
527
|
headers.set('User-Agent', this.userAgent);
|
|
514
528
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
515
529
|
const respBody = await executeHttpCall({
|
|
516
530
|
request: httpReq,
|
|
517
|
-
httpClient
|
|
531
|
+
httpClient,
|
|
518
532
|
logger: this.logger,
|
|
519
533
|
});
|
|
520
534
|
resp = parseResponse(respBody, unmarshalListProviderSharesResponseSchema);
|
|
@@ -546,7 +560,8 @@ export class SharingClient {
|
|
|
546
560
|
* There is no guarantee of a specific ordering of the elements in the array.
|
|
547
561
|
*/
|
|
548
562
|
async listProviders(req, options) {
|
|
549
|
-
const
|
|
563
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
564
|
+
const url = `${host}/api/2.1/unity-catalog/providers`;
|
|
550
565
|
const params = new URLSearchParams();
|
|
551
566
|
if (req.dataProviderGlobalMetastoreId !== undefined) {
|
|
552
567
|
params.append('data_provider_global_metastore_id', req.dataProviderGlobalMetastoreId);
|
|
@@ -562,14 +577,14 @@ export class SharingClient {
|
|
|
562
577
|
let resp;
|
|
563
578
|
const call = async (callSignal) => {
|
|
564
579
|
const headers = new Headers();
|
|
565
|
-
if (
|
|
566
|
-
headers.set('X-Databricks-Org-Id',
|
|
580
|
+
if (workspaceId !== undefined) {
|
|
581
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
567
582
|
}
|
|
568
583
|
headers.set('User-Agent', this.userAgent);
|
|
569
584
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
570
585
|
const respBody = await executeHttpCall({
|
|
571
586
|
request: httpReq,
|
|
572
|
-
httpClient
|
|
587
|
+
httpClient,
|
|
573
588
|
logger: this.logger,
|
|
574
589
|
});
|
|
575
590
|
resp = parseResponse(respBody, unmarshalListProvidersResponseSchema);
|
|
@@ -595,7 +610,8 @@ export class SharingClient {
|
|
|
595
610
|
}
|
|
596
611
|
/** 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. */
|
|
597
612
|
async listRecipientSharePermissions(req, options) {
|
|
598
|
-
const
|
|
613
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
614
|
+
const url = `${host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}/share-permissions`;
|
|
599
615
|
const params = new URLSearchParams();
|
|
600
616
|
if (req.maxResults !== undefined) {
|
|
601
617
|
params.append('max_results', String(req.maxResults));
|
|
@@ -608,14 +624,14 @@ export class SharingClient {
|
|
|
608
624
|
let resp;
|
|
609
625
|
const call = async (callSignal) => {
|
|
610
626
|
const headers = new Headers();
|
|
611
|
-
if (
|
|
612
|
-
headers.set('X-Databricks-Org-Id',
|
|
627
|
+
if (workspaceId !== undefined) {
|
|
628
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
613
629
|
}
|
|
614
630
|
headers.set('User-Agent', this.userAgent);
|
|
615
631
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
616
632
|
const respBody = await executeHttpCall({
|
|
617
633
|
request: httpReq,
|
|
618
|
-
httpClient
|
|
634
|
+
httpClient,
|
|
619
635
|
logger: this.logger,
|
|
620
636
|
});
|
|
621
637
|
resp = parseResponse(respBody, unmarshalGetRecipientSharePermissionsResponseSchema);
|
|
@@ -634,7 +650,8 @@ export class SharingClient {
|
|
|
634
650
|
* There is no guarantee of a specific ordering of the elements in the array.
|
|
635
651
|
*/
|
|
636
652
|
async listRecipients(req, options) {
|
|
637
|
-
const
|
|
653
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
654
|
+
const url = `${host}/api/2.1/unity-catalog/recipients`;
|
|
638
655
|
const params = new URLSearchParams();
|
|
639
656
|
if (req.dataRecipientGlobalMetastoreId !== undefined) {
|
|
640
657
|
params.append('data_recipient_global_metastore_id', req.dataRecipientGlobalMetastoreId);
|
|
@@ -650,14 +667,14 @@ export class SharingClient {
|
|
|
650
667
|
let resp;
|
|
651
668
|
const call = async (callSignal) => {
|
|
652
669
|
const headers = new Headers();
|
|
653
|
-
if (
|
|
654
|
-
headers.set('X-Databricks-Org-Id',
|
|
670
|
+
if (workspaceId !== undefined) {
|
|
671
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
655
672
|
}
|
|
656
673
|
headers.set('User-Agent', this.userAgent);
|
|
657
674
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
658
675
|
const respBody = await executeHttpCall({
|
|
659
676
|
request: httpReq,
|
|
660
|
-
httpClient
|
|
677
|
+
httpClient,
|
|
661
678
|
logger: this.logger,
|
|
662
679
|
});
|
|
663
680
|
resp = parseResponse(respBody, unmarshalListRecipientsResponseSchema);
|
|
@@ -686,7 +703,8 @@ export class SharingClient {
|
|
|
686
703
|
* The caller must have the USE_SHARE privilege on the metastore or be the owner of the share.
|
|
687
704
|
*/
|
|
688
705
|
async listSharePermissions(req, options) {
|
|
689
|
-
const
|
|
706
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
707
|
+
const url = `${host}/api/2.1/unity-catalog/shares/${req.name ?? ''}/permissions`;
|
|
690
708
|
const params = new URLSearchParams();
|
|
691
709
|
if (req.maxResults !== undefined) {
|
|
692
710
|
params.append('max_results', String(req.maxResults));
|
|
@@ -699,14 +717,14 @@ export class SharingClient {
|
|
|
699
717
|
let resp;
|
|
700
718
|
const call = async (callSignal) => {
|
|
701
719
|
const headers = new Headers();
|
|
702
|
-
if (
|
|
703
|
-
headers.set('X-Databricks-Org-Id',
|
|
720
|
+
if (workspaceId !== undefined) {
|
|
721
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
704
722
|
}
|
|
705
723
|
headers.set('User-Agent', this.userAgent);
|
|
706
724
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
707
725
|
const respBody = await executeHttpCall({
|
|
708
726
|
request: httpReq,
|
|
709
|
-
httpClient
|
|
727
|
+
httpClient,
|
|
710
728
|
logger: this.logger,
|
|
711
729
|
});
|
|
712
730
|
resp = parseResponse(respBody, unmarshalGetSharePermissionsResponseSchema);
|
|
@@ -722,7 +740,8 @@ export class SharingClient {
|
|
|
722
740
|
* There is no guarantee of a specific ordering of the elements in the array.
|
|
723
741
|
*/
|
|
724
742
|
async listShares(req, options) {
|
|
725
|
-
const
|
|
743
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
744
|
+
const url = `${host}/api/2.1/unity-catalog/shares`;
|
|
726
745
|
const params = new URLSearchParams();
|
|
727
746
|
if (req.maxResults !== undefined) {
|
|
728
747
|
params.append('max_results', String(req.maxResults));
|
|
@@ -735,14 +754,14 @@ export class SharingClient {
|
|
|
735
754
|
let resp;
|
|
736
755
|
const call = async (callSignal) => {
|
|
737
756
|
const headers = new Headers();
|
|
738
|
-
if (
|
|
739
|
-
headers.set('X-Databricks-Org-Id',
|
|
757
|
+
if (workspaceId !== undefined) {
|
|
758
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
740
759
|
}
|
|
741
760
|
headers.set('User-Agent', this.userAgent);
|
|
742
761
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
743
762
|
const respBody = await executeHttpCall({
|
|
744
763
|
request: httpReq,
|
|
745
|
-
httpClient
|
|
764
|
+
httpClient,
|
|
746
765
|
logger: this.logger,
|
|
747
766
|
});
|
|
748
767
|
resp = parseResponse(respBody, unmarshalListSharesResponseSchema);
|
|
@@ -771,18 +790,19 @@ export class SharingClient {
|
|
|
771
790
|
* This is a public API without any authentication.
|
|
772
791
|
*/
|
|
773
792
|
async retrieveAccessToken(req, options) {
|
|
774
|
-
const
|
|
793
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
794
|
+
const url = `${host}/api/2.1/unity-catalog/public/data_sharing_activation/${req.activationUrl ?? ''}`;
|
|
775
795
|
let resp;
|
|
776
796
|
const call = async (callSignal) => {
|
|
777
797
|
const headers = new Headers();
|
|
778
|
-
if (
|
|
779
|
-
headers.set('X-Databricks-Org-Id',
|
|
798
|
+
if (workspaceId !== undefined) {
|
|
799
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
780
800
|
}
|
|
781
801
|
headers.set('User-Agent', this.userAgent);
|
|
782
802
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
783
803
|
const respBody = await executeHttpCall({
|
|
784
804
|
request: httpReq,
|
|
785
|
-
httpClient
|
|
805
|
+
httpClient,
|
|
786
806
|
logger: this.logger,
|
|
787
807
|
});
|
|
788
808
|
resp = parseResponse(respBody, unmarshalRetrieveTokenResponseSchema);
|
|
@@ -798,19 +818,20 @@ export class SharingClient {
|
|
|
798
818
|
* The caller must be the owner of the recipient.
|
|
799
819
|
*/
|
|
800
820
|
async rotateRecipientToken(req, options) {
|
|
801
|
-
const
|
|
821
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
822
|
+
const url = `${host}/api/2.1/unity-catalog/recipients/${req.name ?? ''}/rotate-token`;
|
|
802
823
|
const body = marshalRequest(req, marshalRotateRecipientTokenRequestSchema);
|
|
803
824
|
let resp;
|
|
804
825
|
const call = async (callSignal) => {
|
|
805
826
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
806
|
-
if (
|
|
807
|
-
headers.set('X-Databricks-Org-Id',
|
|
827
|
+
if (workspaceId !== undefined) {
|
|
828
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
808
829
|
}
|
|
809
830
|
headers.set('User-Agent', this.userAgent);
|
|
810
831
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
811
832
|
const respBody = await executeHttpCall({
|
|
812
833
|
request: httpReq,
|
|
813
|
-
httpClient
|
|
834
|
+
httpClient,
|
|
814
835
|
logger: this.logger,
|
|
815
836
|
});
|
|
816
837
|
resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
|
|
@@ -826,19 +847,20 @@ export class SharingClient {
|
|
|
826
847
|
* If the update changes the provider name, the caller must be both a metastore admin and the owner of the provider.
|
|
827
848
|
*/
|
|
828
849
|
async updateProvider(req, options) {
|
|
829
|
-
const
|
|
850
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
851
|
+
const url = `${host}/api/2.1/unity-catalog/providers/${req.nameArg ?? ''}`;
|
|
830
852
|
const body = marshalRequest(req, marshalUpdateProviderRequestSchema);
|
|
831
853
|
let resp;
|
|
832
854
|
const call = async (callSignal) => {
|
|
833
855
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
834
|
-
if (
|
|
835
|
-
headers.set('X-Databricks-Org-Id',
|
|
856
|
+
if (workspaceId !== undefined) {
|
|
857
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
836
858
|
}
|
|
837
859
|
headers.set('User-Agent', this.userAgent);
|
|
838
860
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
839
861
|
const respBody = await executeHttpCall({
|
|
840
862
|
request: httpReq,
|
|
841
|
-
httpClient
|
|
863
|
+
httpClient,
|
|
842
864
|
logger: this.logger,
|
|
843
865
|
});
|
|
844
866
|
resp = parseResponse(respBody, unmarshalProviderInfoSchema);
|
|
@@ -854,19 +876,20 @@ export class SharingClient {
|
|
|
854
876
|
* If the recipient name will be updated, the user must be both a metastore admin and the owner of the recipient.
|
|
855
877
|
*/
|
|
856
878
|
async updateRecipient(req, options) {
|
|
857
|
-
const
|
|
879
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
880
|
+
const url = `${host}/api/2.1/unity-catalog/recipients/${req.nameArg ?? ''}`;
|
|
858
881
|
const body = marshalRequest(req, marshalUpdateRecipientRequestSchema);
|
|
859
882
|
let resp;
|
|
860
883
|
const call = async (callSignal) => {
|
|
861
884
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
862
|
-
if (
|
|
863
|
-
headers.set('X-Databricks-Org-Id',
|
|
885
|
+
if (workspaceId !== undefined) {
|
|
886
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
864
887
|
}
|
|
865
888
|
headers.set('User-Agent', this.userAgent);
|
|
866
889
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
867
890
|
const respBody = await executeHttpCall({
|
|
868
891
|
request: httpReq,
|
|
869
|
-
httpClient
|
|
892
|
+
httpClient,
|
|
870
893
|
logger: this.logger,
|
|
871
894
|
});
|
|
872
895
|
resp = parseResponse(respBody, unmarshalRecipientInfoSchema);
|
|
@@ -895,19 +918,20 @@ export class SharingClient {
|
|
|
895
918
|
* Table removals through **update** do not require additional privileges.
|
|
896
919
|
*/
|
|
897
920
|
async updateShare(req, options) {
|
|
898
|
-
const
|
|
921
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
922
|
+
const url = `${host}/api/2.1/unity-catalog/shares/${req.nameArg ?? ''}`;
|
|
899
923
|
const body = marshalRequest(req, marshalUpdateShareRequestSchema);
|
|
900
924
|
let resp;
|
|
901
925
|
const call = async (callSignal) => {
|
|
902
926
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
903
|
-
if (
|
|
904
|
-
headers.set('X-Databricks-Org-Id',
|
|
927
|
+
if (workspaceId !== undefined) {
|
|
928
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
905
929
|
}
|
|
906
930
|
headers.set('User-Agent', this.userAgent);
|
|
907
931
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
908
932
|
const respBody = await executeHttpCall({
|
|
909
933
|
request: httpReq,
|
|
910
|
-
httpClient
|
|
934
|
+
httpClient,
|
|
911
935
|
logger: this.logger,
|
|
912
936
|
});
|
|
913
937
|
resp = parseResponse(respBody, unmarshalShareInfoSchema);
|
|
@@ -927,19 +951,20 @@ export class SharingClient {
|
|
|
927
951
|
* recipient revocations do not require additional privileges.
|
|
928
952
|
*/
|
|
929
953
|
async updateSharePermissions(req, options) {
|
|
930
|
-
const
|
|
954
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
955
|
+
const url = `${host}/api/2.1/unity-catalog/shares/${req.name ?? ''}/permissions`;
|
|
931
956
|
const body = marshalRequest(req, marshalUpdateSharePermissionsRequestSchema);
|
|
932
957
|
let resp;
|
|
933
958
|
const call = async (callSignal) => {
|
|
934
959
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
935
|
-
if (
|
|
936
|
-
headers.set('X-Databricks-Org-Id',
|
|
960
|
+
if (workspaceId !== undefined) {
|
|
961
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
937
962
|
}
|
|
938
963
|
headers.set('User-Agent', this.userAgent);
|
|
939
964
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
940
965
|
const respBody = await executeHttpCall({
|
|
941
966
|
request: httpReq,
|
|
942
|
-
httpClient
|
|
967
|
+
httpClient,
|
|
943
968
|
logger: this.logger,
|
|
944
969
|
});
|
|
945
970
|
resp = parseResponse(respBody, unmarshalUpdateSharePermissionsResponseSchema);
|