@databricks/sdk-lakeview 0.1.0-dev.3 → 0.1.0-dev.4

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/src/v1/client.ts DELETED
@@ -1,799 +0,0 @@
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
- CreateDashboardRequest,
21
- CreateScheduleRequest,
22
- CreateSubscriptionRequest,
23
- Dashboard,
24
- DeleteScheduleRequest,
25
- DeleteSubscriptionRequest,
26
- GetDashboardRequest,
27
- GetPublishedDashboardRequest,
28
- GetPublishedDashboardTokenInfoRequest,
29
- GetPublishedDashboardTokenInfoResponse,
30
- GetScheduleRequest,
31
- GetSubscriptionRequest,
32
- ListDashboardsRequest,
33
- ListDashboardsResponse,
34
- ListSchedulesRequest,
35
- ListSchedulesResponse,
36
- ListSubscriptionsRequest,
37
- ListSubscriptionsResponse,
38
- MigrateDashboardRequest,
39
- PublishDashboardRequest,
40
- PublishedDashboard,
41
- RevertDashboardRequest,
42
- RevertDashboardResponse,
43
- Schedule,
44
- Subscription,
45
- TrashDashboardRequest,
46
- TrashDashboardResponse,
47
- UnpublishDashboardRequest,
48
- UnpublishDashboardResponse,
49
- UpdateDashboardRequest,
50
- UpdateScheduleRequest,
51
- } from './model';
52
- import {
53
- marshalDashboardSchema,
54
- marshalMigrateDashboardRequestSchema,
55
- marshalPublishDashboardRequestSchema,
56
- marshalRevertDashboardRequestSchema,
57
- marshalScheduleSchema,
58
- marshalSubscriptionSchema,
59
- unmarshalDashboardSchema,
60
- unmarshalGetPublishedDashboardTokenInfoResponseSchema,
61
- unmarshalListDashboardsResponseSchema,
62
- unmarshalListSchedulesResponseSchema,
63
- unmarshalListSubscriptionsResponseSchema,
64
- unmarshalPublishedDashboardSchema,
65
- unmarshalRevertDashboardResponseSchema,
66
- unmarshalScheduleSchema,
67
- unmarshalSubscriptionSchema,
68
- unmarshalTrashDashboardResponseSchema,
69
- unmarshalUnpublishDashboardResponseSchema,
70
- } from './model';
71
-
72
- // Package identity segment for this client to be used in the User-Agent header.
73
- const PACKAGE_SEGMENT = {
74
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
75
- value: pkgJson.version,
76
- };
77
-
78
- export class LakeviewClient {
79
- private readonly host: string;
80
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
81
- // When set, workspace-level methods send X-Databricks-Org-Id on every
82
- // request.
83
- private readonly workspaceId: string | undefined;
84
- private readonly httpClient: HttpClient;
85
- private readonly logger: Logger;
86
- // User-Agent header value. Composed once at construction from
87
- // createDefault() merged with this package's identity and the active
88
- // credential's name.
89
- private readonly userAgent: string;
90
-
91
- constructor(options: ClientOptions) {
92
- if (options.host === undefined) {
93
- throw new Error('Host is required.');
94
- }
95
- this.host = options.host.replace(/\/$/, '');
96
- this.workspaceId = options.workspaceId;
97
- this.logger = options.logger ?? new NoOpLogger();
98
- const info = createDefault()
99
- .with(PACKAGE_SEGMENT)
100
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
101
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
102
- this.userAgent = info.toString();
103
- this.httpClient = newHttpClient(options);
104
- }
105
-
106
- /** Create a draft dashboard. */
107
- async createDashboard(
108
- req: CreateDashboardRequest,
109
- options?: CallOptions
110
- ): Promise<Dashboard> {
111
- const url = `${this.host}/api/2.0/lakeview/dashboards`;
112
- const params = new URLSearchParams();
113
- if (req.datasetCatalog !== undefined) {
114
- params.append('dataset_catalog', req.datasetCatalog);
115
- }
116
- if (req.datasetSchema !== undefined) {
117
- params.append('dataset_schema', req.datasetSchema);
118
- }
119
- const query = params.toString();
120
- const fullUrl = query !== '' ? `${url}?${query}` : url;
121
- const body = marshalRequest(req.dashboard, marshalDashboardSchema);
122
- let resp: Dashboard | undefined;
123
- const call = async (callSignal?: AbortSignal): Promise<void> => {
124
- const headers = new Headers({'Content-Type': 'application/json'});
125
- if (this.workspaceId !== undefined) {
126
- headers.set('X-Databricks-Org-Id', this.workspaceId);
127
- }
128
- headers.set('User-Agent', this.userAgent);
129
- const httpReq = buildHttpRequest(
130
- 'POST',
131
- fullUrl,
132
- headers,
133
- callSignal,
134
- body
135
- );
136
- const respBody = await executeHttpCall({
137
- request: httpReq,
138
- httpClient: this.httpClient,
139
- logger: this.logger,
140
- });
141
- resp = parseResponse(respBody, unmarshalDashboardSchema);
142
- };
143
- await executeCall(call, options);
144
- if (resp === undefined) {
145
- throw new Error('operation completed without a result.');
146
- }
147
- return resp;
148
- }
149
-
150
- /** Create dashboard schedule. */
151
- async createSchedule(
152
- req: CreateScheduleRequest,
153
- options?: CallOptions
154
- ): Promise<Schedule> {
155
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ''}/schedules`;
156
- const body = marshalRequest(req.schedule, marshalScheduleSchema);
157
- let resp: Schedule | undefined;
158
- const call = async (callSignal?: AbortSignal): Promise<void> => {
159
- const headers = new Headers({'Content-Type': 'application/json'});
160
- if (this.workspaceId !== undefined) {
161
- headers.set('X-Databricks-Org-Id', this.workspaceId);
162
- }
163
- headers.set('User-Agent', this.userAgent);
164
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
165
- const respBody = await executeHttpCall({
166
- request: httpReq,
167
- httpClient: this.httpClient,
168
- logger: this.logger,
169
- });
170
- resp = parseResponse(respBody, unmarshalScheduleSchema);
171
- };
172
- await executeCall(call, options);
173
- if (resp === undefined) {
174
- throw new Error('operation completed without a result.');
175
- }
176
- return resp;
177
- }
178
-
179
- /** Create schedule subscription. */
180
- async createSubscription(
181
- req: CreateSubscriptionRequest,
182
- options?: CallOptions
183
- ): Promise<Subscription> {
184
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.subscription?.dashboardId ?? ''}/schedules/${req.subscription?.scheduleId ?? ''}/subscriptions`;
185
- const body = marshalRequest(req.subscription, marshalSubscriptionSchema);
186
- let resp: Subscription | undefined;
187
- const call = async (callSignal?: AbortSignal): Promise<void> => {
188
- const headers = new Headers({'Content-Type': 'application/json'});
189
- if (this.workspaceId !== undefined) {
190
- headers.set('X-Databricks-Org-Id', this.workspaceId);
191
- }
192
- headers.set('User-Agent', this.userAgent);
193
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
194
- const respBody = await executeHttpCall({
195
- request: httpReq,
196
- httpClient: this.httpClient,
197
- logger: this.logger,
198
- });
199
- resp = parseResponse(respBody, unmarshalSubscriptionSchema);
200
- };
201
- await executeCall(call, options);
202
- if (resp === undefined) {
203
- throw new Error('operation completed without a result.');
204
- }
205
- return resp;
206
- }
207
-
208
- /** Delete dashboard schedule. */
209
- async deleteSchedule(
210
- req: DeleteScheduleRequest,
211
- options?: CallOptions
212
- ): Promise<void> {
213
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}`;
214
- const params = new URLSearchParams();
215
- if (req.etag !== undefined) {
216
- params.append('etag', req.etag);
217
- }
218
- const query = params.toString();
219
- const fullUrl = query !== '' ? `${url}?${query}` : url;
220
- const call = async (callSignal?: AbortSignal): Promise<void> => {
221
- const headers = new Headers();
222
- if (this.workspaceId !== undefined) {
223
- headers.set('X-Databricks-Org-Id', this.workspaceId);
224
- }
225
- headers.set('User-Agent', this.userAgent);
226
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
227
- await executeHttpCall({
228
- request: httpReq,
229
- httpClient: this.httpClient,
230
- logger: this.logger,
231
- });
232
- };
233
- await executeCall(call, options);
234
- }
235
-
236
- /** Delete schedule subscription. */
237
- async deleteSubscription(
238
- req: DeleteSubscriptionRequest,
239
- options?: CallOptions
240
- ): Promise<void> {
241
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions/${req.subscriptionId ?? ''}`;
242
- const params = new URLSearchParams();
243
- if (req.etag !== undefined) {
244
- params.append('etag', req.etag);
245
- }
246
- const query = params.toString();
247
- const fullUrl = query !== '' ? `${url}?${query}` : url;
248
- const call = async (callSignal?: AbortSignal): Promise<void> => {
249
- const headers = new Headers();
250
- if (this.workspaceId !== undefined) {
251
- headers.set('X-Databricks-Org-Id', this.workspaceId);
252
- }
253
- headers.set('User-Agent', this.userAgent);
254
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
255
- await executeHttpCall({
256
- request: httpReq,
257
- httpClient: this.httpClient,
258
- logger: this.logger,
259
- });
260
- };
261
- await executeCall(call, options);
262
- }
263
-
264
- /** Get a draft dashboard. */
265
- async getDashboard(
266
- req: GetDashboardRequest,
267
- options?: CallOptions
268
- ): Promise<Dashboard> {
269
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}`;
270
- let resp: Dashboard | undefined;
271
- const call = async (callSignal?: AbortSignal): Promise<void> => {
272
- const headers = new Headers();
273
- if (this.workspaceId !== undefined) {
274
- headers.set('X-Databricks-Org-Id', this.workspaceId);
275
- }
276
- headers.set('User-Agent', this.userAgent);
277
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
278
- const respBody = await executeHttpCall({
279
- request: httpReq,
280
- httpClient: this.httpClient,
281
- logger: this.logger,
282
- });
283
- resp = parseResponse(respBody, unmarshalDashboardSchema);
284
- };
285
- await executeCall(call, options);
286
- if (resp === undefined) {
287
- throw new Error('operation completed without a result.');
288
- }
289
- return resp;
290
- }
291
-
292
- /** Get the current published dashboard. */
293
- async getPublishedDashboard(
294
- req: GetPublishedDashboardRequest,
295
- options?: CallOptions
296
- ): Promise<PublishedDashboard> {
297
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
298
- let resp: PublishedDashboard | undefined;
299
- const call = async (callSignal?: AbortSignal): Promise<void> => {
300
- const headers = new Headers();
301
- if (this.workspaceId !== undefined) {
302
- headers.set('X-Databricks-Org-Id', this.workspaceId);
303
- }
304
- headers.set('User-Agent', this.userAgent);
305
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
306
- const respBody = await executeHttpCall({
307
- request: httpReq,
308
- httpClient: this.httpClient,
309
- logger: this.logger,
310
- });
311
- resp = parseResponse(respBody, unmarshalPublishedDashboardSchema);
312
- };
313
- await executeCall(call, options);
314
- if (resp === undefined) {
315
- throw new Error('operation completed without a result.');
316
- }
317
- return resp;
318
- }
319
-
320
- /** Get a required authorization details and scopes of a published dashboard to mint an OAuth token. */
321
- async getPublishedDashboardTokenInfo(
322
- req: GetPublishedDashboardTokenInfoRequest,
323
- options?: CallOptions
324
- ): Promise<GetPublishedDashboardTokenInfoResponse> {
325
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published/tokeninfo`;
326
- const params = new URLSearchParams();
327
- if (req.externalValue !== undefined) {
328
- params.append('external_value', req.externalValue);
329
- }
330
- if (req.externalViewerId !== undefined) {
331
- params.append('external_viewer_id', req.externalViewerId);
332
- }
333
- const query = params.toString();
334
- const fullUrl = query !== '' ? `${url}?${query}` : url;
335
- let resp: GetPublishedDashboardTokenInfoResponse | undefined;
336
- const call = async (callSignal?: AbortSignal): Promise<void> => {
337
- const headers = new Headers();
338
- if (this.workspaceId !== undefined) {
339
- headers.set('X-Databricks-Org-Id', this.workspaceId);
340
- }
341
- headers.set('User-Agent', this.userAgent);
342
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
343
- const respBody = await executeHttpCall({
344
- request: httpReq,
345
- httpClient: this.httpClient,
346
- logger: this.logger,
347
- });
348
- resp = parseResponse(
349
- respBody,
350
- unmarshalGetPublishedDashboardTokenInfoResponseSchema
351
- );
352
- };
353
- await executeCall(call, options);
354
- if (resp === undefined) {
355
- throw new Error('operation completed without a result.');
356
- }
357
- return resp;
358
- }
359
-
360
- /** Get dashboard schedule. */
361
- async getSchedule(
362
- req: GetScheduleRequest,
363
- options?: CallOptions
364
- ): Promise<Schedule> {
365
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}`;
366
- let resp: Schedule | undefined;
367
- const call = async (callSignal?: AbortSignal): Promise<void> => {
368
- const headers = new Headers();
369
- if (this.workspaceId !== undefined) {
370
- headers.set('X-Databricks-Org-Id', this.workspaceId);
371
- }
372
- headers.set('User-Agent', this.userAgent);
373
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
374
- const respBody = await executeHttpCall({
375
- request: httpReq,
376
- httpClient: this.httpClient,
377
- logger: this.logger,
378
- });
379
- resp = parseResponse(respBody, unmarshalScheduleSchema);
380
- };
381
- await executeCall(call, options);
382
- if (resp === undefined) {
383
- throw new Error('operation completed without a result.');
384
- }
385
- return resp;
386
- }
387
-
388
- /** Get schedule subscription. */
389
- async getSubscription(
390
- req: GetSubscriptionRequest,
391
- options?: CallOptions
392
- ): Promise<Subscription> {
393
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions/${req.subscriptionId ?? ''}`;
394
- let resp: Subscription | undefined;
395
- const call = async (callSignal?: AbortSignal): Promise<void> => {
396
- const headers = new Headers();
397
- if (this.workspaceId !== undefined) {
398
- headers.set('X-Databricks-Org-Id', this.workspaceId);
399
- }
400
- headers.set('User-Agent', this.userAgent);
401
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
402
- const respBody = await executeHttpCall({
403
- request: httpReq,
404
- httpClient: this.httpClient,
405
- logger: this.logger,
406
- });
407
- resp = parseResponse(respBody, unmarshalSubscriptionSchema);
408
- };
409
- await executeCall(call, options);
410
- if (resp === undefined) {
411
- throw new Error('operation completed without a result.');
412
- }
413
- return resp;
414
- }
415
-
416
- /** List dashboards. */
417
- async listDashboards(
418
- req: ListDashboardsRequest,
419
- options?: CallOptions
420
- ): Promise<ListDashboardsResponse> {
421
- const url = `${this.host}/api/2.0/lakeview/dashboards`;
422
- const params = new URLSearchParams();
423
- if (req.pageSize !== undefined) {
424
- params.append('page_size', String(req.pageSize));
425
- }
426
- if (req.pageToken !== undefined) {
427
- params.append('page_token', req.pageToken);
428
- }
429
- if (req.showTrashed !== undefined) {
430
- params.append('show_trashed', String(req.showTrashed));
431
- }
432
- if (req.view !== undefined) {
433
- params.append('view', req.view);
434
- }
435
- const query = params.toString();
436
- const fullUrl = query !== '' ? `${url}?${query}` : url;
437
- let resp: ListDashboardsResponse | undefined;
438
- const call = async (callSignal?: AbortSignal): Promise<void> => {
439
- const headers = new Headers();
440
- if (this.workspaceId !== undefined) {
441
- headers.set('X-Databricks-Org-Id', this.workspaceId);
442
- }
443
- headers.set('User-Agent', this.userAgent);
444
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
445
- const respBody = await executeHttpCall({
446
- request: httpReq,
447
- httpClient: this.httpClient,
448
- logger: this.logger,
449
- });
450
- resp = parseResponse(respBody, unmarshalListDashboardsResponseSchema);
451
- };
452
- await executeCall(call, options);
453
- if (resp === undefined) {
454
- throw new Error('operation completed without a result.');
455
- }
456
- return resp;
457
- }
458
-
459
- async *listDashboardsIter(
460
- req: ListDashboardsRequest,
461
- options?: CallOptions
462
- ): AsyncGenerator<Dashboard> {
463
- const pageReq: ListDashboardsRequest = {...req};
464
- for (;;) {
465
- const resp = await this.listDashboards(pageReq, options);
466
- for (const item of resp.dashboards ?? []) {
467
- yield item;
468
- }
469
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
470
- return;
471
- }
472
- pageReq.pageToken = resp.nextPageToken;
473
- }
474
- }
475
-
476
- /** List dashboard schedules. */
477
- async listSchedules(
478
- req: ListSchedulesRequest,
479
- options?: CallOptions
480
- ): Promise<ListSchedulesResponse> {
481
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules`;
482
- const params = new URLSearchParams();
483
- if (req.pageSize !== undefined) {
484
- params.append('page_size', String(req.pageSize));
485
- }
486
- if (req.pageToken !== undefined) {
487
- params.append('page_token', req.pageToken);
488
- }
489
- const query = params.toString();
490
- const fullUrl = query !== '' ? `${url}?${query}` : url;
491
- let resp: ListSchedulesResponse | undefined;
492
- const call = async (callSignal?: AbortSignal): Promise<void> => {
493
- const headers = new Headers();
494
- if (this.workspaceId !== undefined) {
495
- headers.set('X-Databricks-Org-Id', this.workspaceId);
496
- }
497
- headers.set('User-Agent', this.userAgent);
498
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
499
- const respBody = await executeHttpCall({
500
- request: httpReq,
501
- httpClient: this.httpClient,
502
- logger: this.logger,
503
- });
504
- resp = parseResponse(respBody, unmarshalListSchedulesResponseSchema);
505
- };
506
- await executeCall(call, options);
507
- if (resp === undefined) {
508
- throw new Error('operation completed without a result.');
509
- }
510
- return resp;
511
- }
512
-
513
- async *listSchedulesIter(
514
- req: ListSchedulesRequest,
515
- options?: CallOptions
516
- ): AsyncGenerator<Schedule> {
517
- const pageReq: ListSchedulesRequest = {...req};
518
- for (;;) {
519
- const resp = await this.listSchedules(pageReq, options);
520
- for (const item of resp.schedules ?? []) {
521
- yield item;
522
- }
523
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
524
- return;
525
- }
526
- pageReq.pageToken = resp.nextPageToken;
527
- }
528
- }
529
-
530
- /** List schedule subscriptions. */
531
- async listSubscriptions(
532
- req: ListSubscriptionsRequest,
533
- options?: CallOptions
534
- ): Promise<ListSubscriptionsResponse> {
535
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions`;
536
- const params = new URLSearchParams();
537
- if (req.pageSize !== undefined) {
538
- params.append('page_size', String(req.pageSize));
539
- }
540
- if (req.pageToken !== undefined) {
541
- params.append('page_token', req.pageToken);
542
- }
543
- const query = params.toString();
544
- const fullUrl = query !== '' ? `${url}?${query}` : url;
545
- let resp: ListSubscriptionsResponse | undefined;
546
- const call = async (callSignal?: AbortSignal): Promise<void> => {
547
- const headers = new Headers();
548
- if (this.workspaceId !== undefined) {
549
- headers.set('X-Databricks-Org-Id', this.workspaceId);
550
- }
551
- headers.set('User-Agent', this.userAgent);
552
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
553
- const respBody = await executeHttpCall({
554
- request: httpReq,
555
- httpClient: this.httpClient,
556
- logger: this.logger,
557
- });
558
- resp = parseResponse(respBody, unmarshalListSubscriptionsResponseSchema);
559
- };
560
- await executeCall(call, options);
561
- if (resp === undefined) {
562
- throw new Error('operation completed without a result.');
563
- }
564
- return resp;
565
- }
566
-
567
- async *listSubscriptionsIter(
568
- req: ListSubscriptionsRequest,
569
- options?: CallOptions
570
- ): AsyncGenerator<Subscription> {
571
- const pageReq: ListSubscriptionsRequest = {...req};
572
- for (;;) {
573
- const resp = await this.listSubscriptions(pageReq, options);
574
- for (const item of resp.subscriptions ?? []) {
575
- yield item;
576
- }
577
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
578
- return;
579
- }
580
- pageReq.pageToken = resp.nextPageToken;
581
- }
582
- }
583
-
584
- /** Migrates a classic SQL dashboard to Lakeview. */
585
- async migrateDashboard(
586
- req: MigrateDashboardRequest,
587
- options?: CallOptions
588
- ): Promise<Dashboard> {
589
- const url = `${this.host}/api/2.0/lakeview/dashboards/migrate`;
590
- const body = marshalRequest(req, marshalMigrateDashboardRequestSchema);
591
- let resp: Dashboard | undefined;
592
- const call = async (callSignal?: AbortSignal): Promise<void> => {
593
- const headers = new Headers({'Content-Type': 'application/json'});
594
- if (this.workspaceId !== undefined) {
595
- headers.set('X-Databricks-Org-Id', this.workspaceId);
596
- }
597
- headers.set('User-Agent', this.userAgent);
598
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
599
- const respBody = await executeHttpCall({
600
- request: httpReq,
601
- httpClient: this.httpClient,
602
- logger: this.logger,
603
- });
604
- resp = parseResponse(respBody, unmarshalDashboardSchema);
605
- };
606
- await executeCall(call, options);
607
- if (resp === undefined) {
608
- throw new Error('operation completed without a result.');
609
- }
610
- return resp;
611
- }
612
-
613
- /** Publish the current draft dashboard. */
614
- async publishDashboard(
615
- req: PublishDashboardRequest,
616
- options?: CallOptions
617
- ): Promise<PublishedDashboard> {
618
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
619
- const body = marshalRequest(req, marshalPublishDashboardRequestSchema);
620
- let resp: PublishedDashboard | undefined;
621
- const call = async (callSignal?: AbortSignal): Promise<void> => {
622
- const headers = new Headers({'Content-Type': 'application/json'});
623
- if (this.workspaceId !== undefined) {
624
- headers.set('X-Databricks-Org-Id', this.workspaceId);
625
- }
626
- headers.set('User-Agent', this.userAgent);
627
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
628
- const respBody = await executeHttpCall({
629
- request: httpReq,
630
- httpClient: this.httpClient,
631
- logger: this.logger,
632
- });
633
- resp = parseResponse(respBody, unmarshalPublishedDashboardSchema);
634
- };
635
- await executeCall(call, options);
636
- if (resp === undefined) {
637
- throw new Error('operation completed without a result.');
638
- }
639
- return resp;
640
- }
641
-
642
- /** Revert a dashboard's definition in draft mode to the last published version. */
643
- async revertDashboard(
644
- req: RevertDashboardRequest,
645
- options?: CallOptions
646
- ): Promise<RevertDashboardResponse> {
647
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/revert`;
648
- const body = marshalRequest(req, marshalRevertDashboardRequestSchema);
649
- let resp: RevertDashboardResponse | undefined;
650
- const call = async (callSignal?: AbortSignal): Promise<void> => {
651
- const headers = new Headers({'Content-Type': 'application/json'});
652
- if (this.workspaceId !== undefined) {
653
- headers.set('X-Databricks-Org-Id', this.workspaceId);
654
- }
655
- headers.set('User-Agent', this.userAgent);
656
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
657
- const respBody = await executeHttpCall({
658
- request: httpReq,
659
- httpClient: this.httpClient,
660
- logger: this.logger,
661
- });
662
- resp = parseResponse(respBody, unmarshalRevertDashboardResponseSchema);
663
- };
664
- await executeCall(call, options);
665
- if (resp === undefined) {
666
- throw new Error('operation completed without a result.');
667
- }
668
- return resp;
669
- }
670
-
671
- /** Trash a dashboard. */
672
- async trashDashboard(
673
- req: TrashDashboardRequest,
674
- options?: CallOptions
675
- ): Promise<TrashDashboardResponse> {
676
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}`;
677
- let resp: TrashDashboardResponse | undefined;
678
- const call = async (callSignal?: AbortSignal): Promise<void> => {
679
- const headers = new Headers();
680
- if (this.workspaceId !== undefined) {
681
- headers.set('X-Databricks-Org-Id', this.workspaceId);
682
- }
683
- headers.set('User-Agent', this.userAgent);
684
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
685
- const respBody = await executeHttpCall({
686
- request: httpReq,
687
- httpClient: this.httpClient,
688
- logger: this.logger,
689
- });
690
- resp = parseResponse(respBody, unmarshalTrashDashboardResponseSchema);
691
- };
692
- await executeCall(call, options);
693
- if (resp === undefined) {
694
- throw new Error('operation completed without a result.');
695
- }
696
- return resp;
697
- }
698
-
699
- /** Unpublish the dashboard. */
700
- async unpublishDashboard(
701
- req: UnpublishDashboardRequest,
702
- options?: CallOptions
703
- ): Promise<UnpublishDashboardResponse> {
704
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
705
- let resp: UnpublishDashboardResponse | undefined;
706
- const call = async (callSignal?: AbortSignal): Promise<void> => {
707
- const headers = new Headers();
708
- if (this.workspaceId !== undefined) {
709
- headers.set('X-Databricks-Org-Id', this.workspaceId);
710
- }
711
- headers.set('User-Agent', this.userAgent);
712
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
713
- const respBody = await executeHttpCall({
714
- request: httpReq,
715
- httpClient: this.httpClient,
716
- logger: this.logger,
717
- });
718
- resp = parseResponse(respBody, unmarshalUnpublishDashboardResponseSchema);
719
- };
720
- await executeCall(call, options);
721
- if (resp === undefined) {
722
- throw new Error('operation completed without a result.');
723
- }
724
- return resp;
725
- }
726
-
727
- /** Update a draft dashboard. */
728
- async updateDashboard(
729
- req: UpdateDashboardRequest,
730
- options?: CallOptions
731
- ): Promise<Dashboard> {
732
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.dashboard?.dashboardId ?? ''}`;
733
- const params = new URLSearchParams();
734
- if (req.datasetCatalog !== undefined) {
735
- params.append('dataset_catalog', req.datasetCatalog);
736
- }
737
- if (req.datasetSchema !== undefined) {
738
- params.append('dataset_schema', req.datasetSchema);
739
- }
740
- const query = params.toString();
741
- const fullUrl = query !== '' ? `${url}?${query}` : url;
742
- const body = marshalRequest(req.dashboard, marshalDashboardSchema);
743
- let resp: Dashboard | undefined;
744
- const call = async (callSignal?: AbortSignal): Promise<void> => {
745
- const headers = new Headers({'Content-Type': 'application/json'});
746
- if (this.workspaceId !== undefined) {
747
- headers.set('X-Databricks-Org-Id', this.workspaceId);
748
- }
749
- headers.set('User-Agent', this.userAgent);
750
- const httpReq = buildHttpRequest(
751
- 'PATCH',
752
- fullUrl,
753
- headers,
754
- callSignal,
755
- body
756
- );
757
- const respBody = await executeHttpCall({
758
- request: httpReq,
759
- httpClient: this.httpClient,
760
- logger: this.logger,
761
- });
762
- resp = parseResponse(respBody, unmarshalDashboardSchema);
763
- };
764
- await executeCall(call, options);
765
- if (resp === undefined) {
766
- throw new Error('operation completed without a result.');
767
- }
768
- return resp;
769
- }
770
-
771
- /** Update dashboard schedule. */
772
- async updateSchedule(
773
- req: UpdateScheduleRequest,
774
- options?: CallOptions
775
- ): Promise<Schedule> {
776
- const url = `${this.host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ''}/schedules/${req.schedule?.scheduleId ?? ''}`;
777
- const body = marshalRequest(req.schedule, marshalScheduleSchema);
778
- let resp: Schedule | undefined;
779
- const call = async (callSignal?: AbortSignal): Promise<void> => {
780
- const headers = new Headers({'Content-Type': 'application/json'});
781
- if (this.workspaceId !== undefined) {
782
- headers.set('X-Databricks-Org-Id', this.workspaceId);
783
- }
784
- headers.set('User-Agent', this.userAgent);
785
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
786
- const respBody = await executeHttpCall({
787
- request: httpReq,
788
- httpClient: this.httpClient,
789
- logger: this.logger,
790
- });
791
- resp = parseResponse(respBody, unmarshalScheduleSchema);
792
- };
793
- await executeCall(call, options);
794
- if (resp === undefined) {
795
- throw new Error('operation completed without a result.');
796
- }
797
- return resp;
798
- }
799
- }