@databricks/sdk-lakeview 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/v1/client.d.ts +57 -53
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +484 -643
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +3 -7
- package/dist/v1/index.js +4 -7
- package/dist/v1/model.d.ts +431 -432
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +240 -384
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +21 -17
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +60 -69
- package/dist/v1/transport.js.map +1 -1
- package/dist/v1/utils.d.ts +18 -14
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +76 -103
- package/dist/v1/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/v1/index.d.ts.map +0 -1
- package/dist/v1/index.js.map +0 -1
package/dist/v1/client.js
CHANGED
|
@@ -1,646 +1,487 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { resolveClientConfig } from "./transport.js";
|
|
2
|
+
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
|
|
3
|
+
import { name, version } from "../package.js";
|
|
4
|
+
import { marshalDashboardSchema, marshalMigrateDashboardRequestSchema, marshalPublishDashboardRequestSchema, marshalRevertDashboardRequestSchema, marshalScheduleSchema, marshalSubscriptionSchema, unmarshalDashboardSchema, unmarshalGetPublishedDashboardTokenInfoResponseSchema, unmarshalListDashboardsResponseSchema, unmarshalListSchedulesResponseSchema, unmarshalListSubscriptionsResponseSchema, unmarshalPublishedDashboardSchema, unmarshalRevertDashboardResponseSchema, unmarshalScheduleSchema, unmarshalSubscriptionSchema, unmarshalTrashDashboardResponseSchema, unmarshalUnpublishDashboardResponseSchema } from "./model.js";
|
|
5
|
+
import { VERSION } from "@databricks/sdk-auth";
|
|
6
|
+
import { createDefault } from "@databricks/sdk-core/clientinfo";
|
|
7
|
+
import { NoOpLogger } from "@databricks/sdk-core/logger";
|
|
8
|
+
|
|
9
|
+
//#region src/v1/client.ts
|
|
10
10
|
const PACKAGE_SEGMENT = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
|
|
12
|
+
value: version
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
let resp;
|
|
488
|
-
const call = async (callSignal) => {
|
|
489
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
490
|
-
if (workspaceId !== undefined) {
|
|
491
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
492
|
-
}
|
|
493
|
-
headers.set('User-Agent', this.userAgent);
|
|
494
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
495
|
-
const respBody = await executeHttpCall({
|
|
496
|
-
request: httpReq,
|
|
497
|
-
httpClient,
|
|
498
|
-
logger: this.logger,
|
|
499
|
-
});
|
|
500
|
-
resp = parseResponse(respBody, unmarshalPublishedDashboardSchema);
|
|
501
|
-
};
|
|
502
|
-
await executeCall(call, options);
|
|
503
|
-
if (resp === undefined) {
|
|
504
|
-
throw new Error('operation completed without a result.');
|
|
505
|
-
}
|
|
506
|
-
return resp;
|
|
507
|
-
}
|
|
508
|
-
/** Revert a dashboard's definition in draft mode to the last published version. */
|
|
509
|
-
async revertDashboard(req, options) {
|
|
510
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
511
|
-
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/revert`;
|
|
512
|
-
const body = marshalRequest(req, marshalRevertDashboardRequestSchema);
|
|
513
|
-
let resp;
|
|
514
|
-
const call = async (callSignal) => {
|
|
515
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
516
|
-
if (workspaceId !== undefined) {
|
|
517
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
518
|
-
}
|
|
519
|
-
headers.set('User-Agent', this.userAgent);
|
|
520
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
521
|
-
const respBody = await executeHttpCall({
|
|
522
|
-
request: httpReq,
|
|
523
|
-
httpClient,
|
|
524
|
-
logger: this.logger,
|
|
525
|
-
});
|
|
526
|
-
resp = parseResponse(respBody, unmarshalRevertDashboardResponseSchema);
|
|
527
|
-
};
|
|
528
|
-
await executeCall(call, options);
|
|
529
|
-
if (resp === undefined) {
|
|
530
|
-
throw new Error('operation completed without a result.');
|
|
531
|
-
}
|
|
532
|
-
return resp;
|
|
533
|
-
}
|
|
534
|
-
/** Trash a dashboard. */
|
|
535
|
-
async trashDashboard(req, options) {
|
|
536
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
537
|
-
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}`;
|
|
538
|
-
let resp;
|
|
539
|
-
const call = async (callSignal) => {
|
|
540
|
-
const headers = new Headers();
|
|
541
|
-
if (workspaceId !== undefined) {
|
|
542
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
543
|
-
}
|
|
544
|
-
headers.set('User-Agent', this.userAgent);
|
|
545
|
-
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
546
|
-
const respBody = await executeHttpCall({
|
|
547
|
-
request: httpReq,
|
|
548
|
-
httpClient,
|
|
549
|
-
logger: this.logger,
|
|
550
|
-
});
|
|
551
|
-
resp = parseResponse(respBody, unmarshalTrashDashboardResponseSchema);
|
|
552
|
-
};
|
|
553
|
-
await executeCall(call, options);
|
|
554
|
-
if (resp === undefined) {
|
|
555
|
-
throw new Error('operation completed without a result.');
|
|
556
|
-
}
|
|
557
|
-
return resp;
|
|
558
|
-
}
|
|
559
|
-
/** Unpublish the dashboard. */
|
|
560
|
-
async unpublishDashboard(req, options) {
|
|
561
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
562
|
-
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
|
|
563
|
-
let resp;
|
|
564
|
-
const call = async (callSignal) => {
|
|
565
|
-
const headers = new Headers();
|
|
566
|
-
if (workspaceId !== undefined) {
|
|
567
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
568
|
-
}
|
|
569
|
-
headers.set('User-Agent', this.userAgent);
|
|
570
|
-
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
571
|
-
const respBody = await executeHttpCall({
|
|
572
|
-
request: httpReq,
|
|
573
|
-
httpClient,
|
|
574
|
-
logger: this.logger,
|
|
575
|
-
});
|
|
576
|
-
resp = parseResponse(respBody, unmarshalUnpublishDashboardResponseSchema);
|
|
577
|
-
};
|
|
578
|
-
await executeCall(call, options);
|
|
579
|
-
if (resp === undefined) {
|
|
580
|
-
throw new Error('operation completed without a result.');
|
|
581
|
-
}
|
|
582
|
-
return resp;
|
|
583
|
-
}
|
|
584
|
-
/** Update a draft dashboard. */
|
|
585
|
-
async updateDashboard(req, options) {
|
|
586
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
587
|
-
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboard?.dashboardId ?? ''}`;
|
|
588
|
-
const params = new URLSearchParams();
|
|
589
|
-
if (req.datasetCatalog !== undefined) {
|
|
590
|
-
params.append('dataset_catalog', req.datasetCatalog);
|
|
591
|
-
}
|
|
592
|
-
if (req.datasetSchema !== undefined) {
|
|
593
|
-
params.append('dataset_schema', req.datasetSchema);
|
|
594
|
-
}
|
|
595
|
-
const query = params.toString();
|
|
596
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
597
|
-
const body = marshalRequest(req.dashboard, marshalDashboardSchema);
|
|
598
|
-
let resp;
|
|
599
|
-
const call = async (callSignal) => {
|
|
600
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
601
|
-
if (workspaceId !== undefined) {
|
|
602
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
603
|
-
}
|
|
604
|
-
headers.set('User-Agent', this.userAgent);
|
|
605
|
-
const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
|
|
606
|
-
const respBody = await executeHttpCall({
|
|
607
|
-
request: httpReq,
|
|
608
|
-
httpClient,
|
|
609
|
-
logger: this.logger,
|
|
610
|
-
});
|
|
611
|
-
resp = parseResponse(respBody, unmarshalDashboardSchema);
|
|
612
|
-
};
|
|
613
|
-
await executeCall(call, options);
|
|
614
|
-
if (resp === undefined) {
|
|
615
|
-
throw new Error('operation completed without a result.');
|
|
616
|
-
}
|
|
617
|
-
return resp;
|
|
618
|
-
}
|
|
619
|
-
/** Update dashboard schedule. */
|
|
620
|
-
async updateSchedule(req, options) {
|
|
621
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
622
|
-
const url = `${host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ''}/schedules/${req.schedule?.scheduleId ?? ''}`;
|
|
623
|
-
const body = marshalRequest(req.schedule, marshalScheduleSchema);
|
|
624
|
-
let resp;
|
|
625
|
-
const call = async (callSignal) => {
|
|
626
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
627
|
-
if (workspaceId !== undefined) {
|
|
628
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
629
|
-
}
|
|
630
|
-
headers.set('User-Agent', this.userAgent);
|
|
631
|
-
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
632
|
-
const respBody = await executeHttpCall({
|
|
633
|
-
request: httpReq,
|
|
634
|
-
httpClient,
|
|
635
|
-
logger: this.logger,
|
|
636
|
-
});
|
|
637
|
-
resp = parseResponse(respBody, unmarshalScheduleSchema);
|
|
638
|
-
};
|
|
639
|
-
await executeCall(call, options);
|
|
640
|
-
if (resp === undefined) {
|
|
641
|
-
throw new Error('operation completed without a result.');
|
|
642
|
-
}
|
|
643
|
-
return resp;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
14
|
+
var LakeviewClient = class {
|
|
15
|
+
options;
|
|
16
|
+
logger;
|
|
17
|
+
userAgent;
|
|
18
|
+
config;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
22
|
+
this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
|
|
23
|
+
key: "sdk-js-auth",
|
|
24
|
+
value: VERSION
|
|
25
|
+
}).with({
|
|
26
|
+
key: "auth",
|
|
27
|
+
value: options.credentials?.name() ?? "default"
|
|
28
|
+
}).toString();
|
|
29
|
+
}
|
|
30
|
+
resolveConfig() {
|
|
31
|
+
this.config ??= resolveClientConfig(this.options);
|
|
32
|
+
return this.config;
|
|
33
|
+
}
|
|
34
|
+
/** Create a draft dashboard. */
|
|
35
|
+
async createDashboard(req, options) {
|
|
36
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
37
|
+
const url = `${host}/api/2.0/lakeview/dashboards`;
|
|
38
|
+
const params = new URLSearchParams();
|
|
39
|
+
if (req.datasetCatalog !== void 0) params.append("dataset_catalog", req.datasetCatalog);
|
|
40
|
+
if (req.datasetSchema !== void 0) params.append("dataset_schema", req.datasetSchema);
|
|
41
|
+
const query = params.toString();
|
|
42
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
43
|
+
const body = marshalRequest(req.dashboard, marshalDashboardSchema);
|
|
44
|
+
let resp;
|
|
45
|
+
const call = async (callSignal) => {
|
|
46
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
47
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
48
|
+
headers.set("User-Agent", this.userAgent);
|
|
49
|
+
resp = parseResponse(await executeHttpCall({
|
|
50
|
+
request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
|
|
51
|
+
httpClient,
|
|
52
|
+
logger: this.logger
|
|
53
|
+
}), unmarshalDashboardSchema);
|
|
54
|
+
};
|
|
55
|
+
await executeCall(call, options);
|
|
56
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
57
|
+
return resp;
|
|
58
|
+
}
|
|
59
|
+
/** Create dashboard schedule. */
|
|
60
|
+
async createSchedule(req, options) {
|
|
61
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
62
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ""}/schedules`;
|
|
63
|
+
const body = marshalRequest(req.schedule, marshalScheduleSchema);
|
|
64
|
+
let resp;
|
|
65
|
+
const call = async (callSignal) => {
|
|
66
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
67
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
68
|
+
headers.set("User-Agent", this.userAgent);
|
|
69
|
+
resp = parseResponse(await executeHttpCall({
|
|
70
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
71
|
+
httpClient,
|
|
72
|
+
logger: this.logger
|
|
73
|
+
}), unmarshalScheduleSchema);
|
|
74
|
+
};
|
|
75
|
+
await executeCall(call, options);
|
|
76
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
77
|
+
return resp;
|
|
78
|
+
}
|
|
79
|
+
/** Create schedule subscription. */
|
|
80
|
+
async createSubscription(req, options) {
|
|
81
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
82
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.subscription?.dashboardId ?? ""}/schedules/${req.subscription?.scheduleId ?? ""}/subscriptions`;
|
|
83
|
+
const body = marshalRequest(req.subscription, marshalSubscriptionSchema);
|
|
84
|
+
let resp;
|
|
85
|
+
const call = async (callSignal) => {
|
|
86
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
87
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
88
|
+
headers.set("User-Agent", this.userAgent);
|
|
89
|
+
resp = parseResponse(await executeHttpCall({
|
|
90
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
91
|
+
httpClient,
|
|
92
|
+
logger: this.logger
|
|
93
|
+
}), unmarshalSubscriptionSchema);
|
|
94
|
+
};
|
|
95
|
+
await executeCall(call, options);
|
|
96
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
97
|
+
return resp;
|
|
98
|
+
}
|
|
99
|
+
/** Delete dashboard schedule. */
|
|
100
|
+
async deleteSchedule(req, options) {
|
|
101
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
102
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules/${req.scheduleId ?? ""}`;
|
|
103
|
+
const params = new URLSearchParams();
|
|
104
|
+
if (req.etag !== void 0) params.append("etag", req.etag);
|
|
105
|
+
const query = params.toString();
|
|
106
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
107
|
+
const call = async (callSignal) => {
|
|
108
|
+
const headers = new Headers();
|
|
109
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
110
|
+
headers.set("User-Agent", this.userAgent);
|
|
111
|
+
await executeHttpCall({
|
|
112
|
+
request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
|
|
113
|
+
httpClient,
|
|
114
|
+
logger: this.logger
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
await executeCall(call, options);
|
|
118
|
+
}
|
|
119
|
+
/** Delete schedule subscription. */
|
|
120
|
+
async deleteSubscription(req, options) {
|
|
121
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
122
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules/${req.scheduleId ?? ""}/subscriptions/${req.subscriptionId ?? ""}`;
|
|
123
|
+
const params = new URLSearchParams();
|
|
124
|
+
if (req.etag !== void 0) params.append("etag", req.etag);
|
|
125
|
+
const query = params.toString();
|
|
126
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
127
|
+
const call = async (callSignal) => {
|
|
128
|
+
const headers = new Headers();
|
|
129
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
130
|
+
headers.set("User-Agent", this.userAgent);
|
|
131
|
+
await executeHttpCall({
|
|
132
|
+
request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
|
|
133
|
+
httpClient,
|
|
134
|
+
logger: this.logger
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
await executeCall(call, options);
|
|
138
|
+
}
|
|
139
|
+
/** Get a draft dashboard. */
|
|
140
|
+
async getDashboard(req, options) {
|
|
141
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
142
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}`;
|
|
143
|
+
let resp;
|
|
144
|
+
const call = async (callSignal) => {
|
|
145
|
+
const headers = new Headers();
|
|
146
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
147
|
+
headers.set("User-Agent", this.userAgent);
|
|
148
|
+
resp = parseResponse(await executeHttpCall({
|
|
149
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
150
|
+
httpClient,
|
|
151
|
+
logger: this.logger
|
|
152
|
+
}), unmarshalDashboardSchema);
|
|
153
|
+
};
|
|
154
|
+
await executeCall(call, options);
|
|
155
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
156
|
+
return resp;
|
|
157
|
+
}
|
|
158
|
+
/** Get the current published dashboard. */
|
|
159
|
+
async getPublishedDashboard(req, options) {
|
|
160
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
161
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/published`;
|
|
162
|
+
let resp;
|
|
163
|
+
const call = async (callSignal) => {
|
|
164
|
+
const headers = new Headers();
|
|
165
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
166
|
+
headers.set("User-Agent", this.userAgent);
|
|
167
|
+
resp = parseResponse(await executeHttpCall({
|
|
168
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
169
|
+
httpClient,
|
|
170
|
+
logger: this.logger
|
|
171
|
+
}), unmarshalPublishedDashboardSchema);
|
|
172
|
+
};
|
|
173
|
+
await executeCall(call, options);
|
|
174
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
175
|
+
return resp;
|
|
176
|
+
}
|
|
177
|
+
/** Get a required authorization details and scopes of a published dashboard to mint an OAuth token. */
|
|
178
|
+
async getPublishedDashboardTokenInfo(req, options) {
|
|
179
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
180
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/published/tokeninfo`;
|
|
181
|
+
const params = new URLSearchParams();
|
|
182
|
+
if (req.externalValue !== void 0) params.append("external_value", req.externalValue);
|
|
183
|
+
if (req.externalViewerId !== void 0) params.append("external_viewer_id", req.externalViewerId);
|
|
184
|
+
const query = params.toString();
|
|
185
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
186
|
+
let resp;
|
|
187
|
+
const call = async (callSignal) => {
|
|
188
|
+
const headers = new Headers();
|
|
189
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
190
|
+
headers.set("User-Agent", this.userAgent);
|
|
191
|
+
resp = parseResponse(await executeHttpCall({
|
|
192
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
193
|
+
httpClient,
|
|
194
|
+
logger: this.logger
|
|
195
|
+
}), unmarshalGetPublishedDashboardTokenInfoResponseSchema);
|
|
196
|
+
};
|
|
197
|
+
await executeCall(call, options);
|
|
198
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
199
|
+
return resp;
|
|
200
|
+
}
|
|
201
|
+
/** Get dashboard schedule. */
|
|
202
|
+
async getSchedule(req, options) {
|
|
203
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
204
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules/${req.scheduleId ?? ""}`;
|
|
205
|
+
let resp;
|
|
206
|
+
const call = async (callSignal) => {
|
|
207
|
+
const headers = new Headers();
|
|
208
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
209
|
+
headers.set("User-Agent", this.userAgent);
|
|
210
|
+
resp = parseResponse(await executeHttpCall({
|
|
211
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
212
|
+
httpClient,
|
|
213
|
+
logger: this.logger
|
|
214
|
+
}), unmarshalScheduleSchema);
|
|
215
|
+
};
|
|
216
|
+
await executeCall(call, options);
|
|
217
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
218
|
+
return resp;
|
|
219
|
+
}
|
|
220
|
+
/** Get schedule subscription. */
|
|
221
|
+
async getSubscription(req, options) {
|
|
222
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
223
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules/${req.scheduleId ?? ""}/subscriptions/${req.subscriptionId ?? ""}`;
|
|
224
|
+
let resp;
|
|
225
|
+
const call = async (callSignal) => {
|
|
226
|
+
const headers = new Headers();
|
|
227
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
228
|
+
headers.set("User-Agent", this.userAgent);
|
|
229
|
+
resp = parseResponse(await executeHttpCall({
|
|
230
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
231
|
+
httpClient,
|
|
232
|
+
logger: this.logger
|
|
233
|
+
}), unmarshalSubscriptionSchema);
|
|
234
|
+
};
|
|
235
|
+
await executeCall(call, options);
|
|
236
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
237
|
+
return resp;
|
|
238
|
+
}
|
|
239
|
+
/** List dashboards. */
|
|
240
|
+
async listDashboards(req, options) {
|
|
241
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
242
|
+
const url = `${host}/api/2.0/lakeview/dashboards`;
|
|
243
|
+
const params = new URLSearchParams();
|
|
244
|
+
if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
|
|
245
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
246
|
+
if (req.showTrashed !== void 0) params.append("show_trashed", String(req.showTrashed));
|
|
247
|
+
if (req.view !== void 0) params.append("view", req.view);
|
|
248
|
+
const query = params.toString();
|
|
249
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
250
|
+
let resp;
|
|
251
|
+
const call = async (callSignal) => {
|
|
252
|
+
const headers = new Headers();
|
|
253
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
254
|
+
headers.set("User-Agent", this.userAgent);
|
|
255
|
+
resp = parseResponse(await executeHttpCall({
|
|
256
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
257
|
+
httpClient,
|
|
258
|
+
logger: this.logger
|
|
259
|
+
}), unmarshalListDashboardsResponseSchema);
|
|
260
|
+
};
|
|
261
|
+
await executeCall(call, options);
|
|
262
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
263
|
+
return resp;
|
|
264
|
+
}
|
|
265
|
+
async *listDashboardsIter(req, options) {
|
|
266
|
+
const pageReq = { ...req };
|
|
267
|
+
for (;;) {
|
|
268
|
+
const resp = await this.listDashboards(pageReq, options);
|
|
269
|
+
for (const item of resp.dashboards ?? []) yield item;
|
|
270
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
271
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** List dashboard schedules. */
|
|
275
|
+
async listSchedules(req, options) {
|
|
276
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
277
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules`;
|
|
278
|
+
const params = new URLSearchParams();
|
|
279
|
+
if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
|
|
280
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
281
|
+
const query = params.toString();
|
|
282
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
283
|
+
let resp;
|
|
284
|
+
const call = async (callSignal) => {
|
|
285
|
+
const headers = new Headers();
|
|
286
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
287
|
+
headers.set("User-Agent", this.userAgent);
|
|
288
|
+
resp = parseResponse(await executeHttpCall({
|
|
289
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
290
|
+
httpClient,
|
|
291
|
+
logger: this.logger
|
|
292
|
+
}), unmarshalListSchedulesResponseSchema);
|
|
293
|
+
};
|
|
294
|
+
await executeCall(call, options);
|
|
295
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
296
|
+
return resp;
|
|
297
|
+
}
|
|
298
|
+
async *listSchedulesIter(req, options) {
|
|
299
|
+
const pageReq = { ...req };
|
|
300
|
+
for (;;) {
|
|
301
|
+
const resp = await this.listSchedules(pageReq, options);
|
|
302
|
+
for (const item of resp.schedules ?? []) yield item;
|
|
303
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
304
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/** List schedule subscriptions. */
|
|
308
|
+
async listSubscriptions(req, options) {
|
|
309
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
310
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/schedules/${req.scheduleId ?? ""}/subscriptions`;
|
|
311
|
+
const params = new URLSearchParams();
|
|
312
|
+
if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
|
|
313
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
314
|
+
const query = params.toString();
|
|
315
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
316
|
+
let resp;
|
|
317
|
+
const call = async (callSignal) => {
|
|
318
|
+
const headers = new Headers();
|
|
319
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
320
|
+
headers.set("User-Agent", this.userAgent);
|
|
321
|
+
resp = parseResponse(await executeHttpCall({
|
|
322
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
323
|
+
httpClient,
|
|
324
|
+
logger: this.logger
|
|
325
|
+
}), unmarshalListSubscriptionsResponseSchema);
|
|
326
|
+
};
|
|
327
|
+
await executeCall(call, options);
|
|
328
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
329
|
+
return resp;
|
|
330
|
+
}
|
|
331
|
+
async *listSubscriptionsIter(req, options) {
|
|
332
|
+
const pageReq = { ...req };
|
|
333
|
+
for (;;) {
|
|
334
|
+
const resp = await this.listSubscriptions(pageReq, options);
|
|
335
|
+
for (const item of resp.subscriptions ?? []) yield item;
|
|
336
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
337
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** Migrates a classic SQL dashboard to Lakeview. */
|
|
341
|
+
async migrateDashboard(req, options) {
|
|
342
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
343
|
+
const url = `${host}/api/2.0/lakeview/dashboards/migrate`;
|
|
344
|
+
const body = marshalRequest(req, marshalMigrateDashboardRequestSchema);
|
|
345
|
+
let resp;
|
|
346
|
+
const call = async (callSignal) => {
|
|
347
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
348
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
349
|
+
headers.set("User-Agent", this.userAgent);
|
|
350
|
+
resp = parseResponse(await executeHttpCall({
|
|
351
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
352
|
+
httpClient,
|
|
353
|
+
logger: this.logger
|
|
354
|
+
}), unmarshalDashboardSchema);
|
|
355
|
+
};
|
|
356
|
+
await executeCall(call, options);
|
|
357
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
358
|
+
return resp;
|
|
359
|
+
}
|
|
360
|
+
/** Publish the current draft dashboard. */
|
|
361
|
+
async publishDashboard(req, options) {
|
|
362
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
363
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/published`;
|
|
364
|
+
const body = marshalRequest(req, marshalPublishDashboardRequestSchema);
|
|
365
|
+
let resp;
|
|
366
|
+
const call = async (callSignal) => {
|
|
367
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
368
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
369
|
+
headers.set("User-Agent", this.userAgent);
|
|
370
|
+
resp = parseResponse(await executeHttpCall({
|
|
371
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
372
|
+
httpClient,
|
|
373
|
+
logger: this.logger
|
|
374
|
+
}), unmarshalPublishedDashboardSchema);
|
|
375
|
+
};
|
|
376
|
+
await executeCall(call, options);
|
|
377
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
378
|
+
return resp;
|
|
379
|
+
}
|
|
380
|
+
/** Revert a dashboard's definition in draft mode to the last published version. */
|
|
381
|
+
async revertDashboard(req, options) {
|
|
382
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
383
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/revert`;
|
|
384
|
+
const body = marshalRequest(req, marshalRevertDashboardRequestSchema);
|
|
385
|
+
let resp;
|
|
386
|
+
const call = async (callSignal) => {
|
|
387
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
388
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
389
|
+
headers.set("User-Agent", this.userAgent);
|
|
390
|
+
resp = parseResponse(await executeHttpCall({
|
|
391
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
392
|
+
httpClient,
|
|
393
|
+
logger: this.logger
|
|
394
|
+
}), unmarshalRevertDashboardResponseSchema);
|
|
395
|
+
};
|
|
396
|
+
await executeCall(call, options);
|
|
397
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
398
|
+
return resp;
|
|
399
|
+
}
|
|
400
|
+
/** Trash a dashboard. */
|
|
401
|
+
async trashDashboard(req, options) {
|
|
402
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
403
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}`;
|
|
404
|
+
let resp;
|
|
405
|
+
const call = async (callSignal) => {
|
|
406
|
+
const headers = new Headers();
|
|
407
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
408
|
+
headers.set("User-Agent", this.userAgent);
|
|
409
|
+
resp = parseResponse(await executeHttpCall({
|
|
410
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
411
|
+
httpClient,
|
|
412
|
+
logger: this.logger
|
|
413
|
+
}), unmarshalTrashDashboardResponseSchema);
|
|
414
|
+
};
|
|
415
|
+
await executeCall(call, options);
|
|
416
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
417
|
+
return resp;
|
|
418
|
+
}
|
|
419
|
+
/** Unpublish the dashboard. */
|
|
420
|
+
async unpublishDashboard(req, options) {
|
|
421
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
422
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ""}/published`;
|
|
423
|
+
let resp;
|
|
424
|
+
const call = async (callSignal) => {
|
|
425
|
+
const headers = new Headers();
|
|
426
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
427
|
+
headers.set("User-Agent", this.userAgent);
|
|
428
|
+
resp = parseResponse(await executeHttpCall({
|
|
429
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
430
|
+
httpClient,
|
|
431
|
+
logger: this.logger
|
|
432
|
+
}), unmarshalUnpublishDashboardResponseSchema);
|
|
433
|
+
};
|
|
434
|
+
await executeCall(call, options);
|
|
435
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
436
|
+
return resp;
|
|
437
|
+
}
|
|
438
|
+
/** Update a draft dashboard. */
|
|
439
|
+
async updateDashboard(req, options) {
|
|
440
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
441
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboard?.dashboardId ?? ""}`;
|
|
442
|
+
const params = new URLSearchParams();
|
|
443
|
+
if (req.datasetCatalog !== void 0) params.append("dataset_catalog", req.datasetCatalog);
|
|
444
|
+
if (req.datasetSchema !== void 0) params.append("dataset_schema", req.datasetSchema);
|
|
445
|
+
const query = params.toString();
|
|
446
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
447
|
+
const body = marshalRequest(req.dashboard, marshalDashboardSchema);
|
|
448
|
+
let resp;
|
|
449
|
+
const call = async (callSignal) => {
|
|
450
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
451
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
452
|
+
headers.set("User-Agent", this.userAgent);
|
|
453
|
+
resp = parseResponse(await executeHttpCall({
|
|
454
|
+
request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
|
|
455
|
+
httpClient,
|
|
456
|
+
logger: this.logger
|
|
457
|
+
}), unmarshalDashboardSchema);
|
|
458
|
+
};
|
|
459
|
+
await executeCall(call, options);
|
|
460
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
461
|
+
return resp;
|
|
462
|
+
}
|
|
463
|
+
/** Update dashboard schedule. */
|
|
464
|
+
async updateSchedule(req, options) {
|
|
465
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
466
|
+
const url = `${host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ""}/schedules/${req.schedule?.scheduleId ?? ""}`;
|
|
467
|
+
const body = marshalRequest(req.schedule, marshalScheduleSchema);
|
|
468
|
+
let resp;
|
|
469
|
+
const call = async (callSignal) => {
|
|
470
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
471
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
472
|
+
headers.set("User-Agent", this.userAgent);
|
|
473
|
+
resp = parseResponse(await executeHttpCall({
|
|
474
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
475
|
+
httpClient,
|
|
476
|
+
logger: this.logger
|
|
477
|
+
}), unmarshalScheduleSchema);
|
|
478
|
+
};
|
|
479
|
+
await executeCall(call, options);
|
|
480
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
481
|
+
return resp;
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
export { LakeviewClient };
|
|
646
487
|
//# sourceMappingURL=client.js.map
|