@databricks/sdk-lakeview 0.34.0 → 0.36.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/v1/client.js CHANGED
@@ -1,646 +1,487 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
- import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
3
- import { createDefault } from '@databricks/sdk-core/clientinfo';
4
- import { NoOpLogger } from '@databricks/sdk-core/logger';
5
- import { resolveClientConfig } from './transport';
6
- import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
7
- import pkgJson from '../../package.json' with { type: 'json' };
8
- import { marshalDashboardSchema, marshalMigrateDashboardRequestSchema, marshalPublishDashboardRequestSchema, marshalRevertDashboardRequestSchema, marshalScheduleSchema, marshalSubscriptionSchema, unmarshalDashboardSchema, unmarshalGetPublishedDashboardTokenInfoResponseSchema, unmarshalListDashboardsResponseSchema, unmarshalListSchedulesResponseSchema, unmarshalListSubscriptionsResponseSchema, unmarshalPublishedDashboardSchema, unmarshalRevertDashboardResponseSchema, unmarshalScheduleSchema, unmarshalSubscriptionSchema, unmarshalTrashDashboardResponseSchema, unmarshalUnpublishDashboardResponseSchema, } from './model';
9
- // Package identity segment for this client to be used in the User-Agent header.
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
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
12
- value: pkgJson.version,
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
13
  };
14
- export class LakeviewClient {
15
- options;
16
- logger;
17
- // User-Agent header value. Composed once at construction from
18
- // createDefault() merged with this package's identity and the active
19
- // credential's name.
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;
25
- constructor(options) {
26
- this.options = options;
27
- this.logger = options.logger ?? new NoOpLogger();
28
- const info = createDefault()
29
- .with(PACKAGE_SEGMENT)
30
- .with({ key: 'sdk-js-auth', value: AUTH_VERSION })
31
- .with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
32
- this.userAgent = info.toString();
33
- }
34
- resolveConfig() {
35
- this.config ??= resolveClientConfig(this.options);
36
- return this.config;
37
- }
38
- /** Create a draft dashboard. */
39
- async createDashboard(req, options) {
40
- const { host, workspaceId, httpClient } = await this.resolveConfig();
41
- const url = `${host}/api/2.0/lakeview/dashboards`;
42
- const params = new URLSearchParams();
43
- if (req.datasetCatalog !== undefined) {
44
- params.append('dataset_catalog', req.datasetCatalog);
45
- }
46
- if (req.datasetSchema !== undefined) {
47
- params.append('dataset_schema', req.datasetSchema);
48
- }
49
- const query = params.toString();
50
- const fullUrl = query !== '' ? `${url}?${query}` : url;
51
- const body = marshalRequest(req.dashboard, marshalDashboardSchema);
52
- let resp;
53
- const call = async (callSignal) => {
54
- const headers = new Headers({ 'Content-Type': 'application/json' });
55
- if (workspaceId !== undefined) {
56
- headers.set('X-Databricks-Workspace-Id', workspaceId);
57
- }
58
- headers.set('User-Agent', this.userAgent);
59
- const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
60
- const respBody = await executeHttpCall({
61
- request: httpReq,
62
- httpClient,
63
- logger: this.logger,
64
- });
65
- resp = parseResponse(respBody, unmarshalDashboardSchema);
66
- };
67
- await executeCall(call, options);
68
- if (resp === undefined) {
69
- throw new Error('operation completed without a result.');
70
- }
71
- return resp;
72
- }
73
- /** Create dashboard schedule. */
74
- async createSchedule(req, options) {
75
- const { host, workspaceId, httpClient } = await this.resolveConfig();
76
- const url = `${host}/api/2.0/lakeview/dashboards/${req.schedule?.dashboardId ?? ''}/schedules`;
77
- const body = marshalRequest(req.schedule, marshalScheduleSchema);
78
- let resp;
79
- const call = async (callSignal) => {
80
- const headers = new Headers({ 'Content-Type': 'application/json' });
81
- if (workspaceId !== undefined) {
82
- headers.set('X-Databricks-Workspace-Id', workspaceId);
83
- }
84
- headers.set('User-Agent', this.userAgent);
85
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
86
- const respBody = await executeHttpCall({
87
- request: httpReq,
88
- httpClient,
89
- logger: this.logger,
90
- });
91
- resp = parseResponse(respBody, unmarshalScheduleSchema);
92
- };
93
- await executeCall(call, options);
94
- if (resp === undefined) {
95
- throw new Error('operation completed without a result.');
96
- }
97
- return resp;
98
- }
99
- /** Create schedule subscription. */
100
- async createSubscription(req, options) {
101
- const { host, workspaceId, httpClient } = await this.resolveConfig();
102
- const url = `${host}/api/2.0/lakeview/dashboards/${req.subscription?.dashboardId ?? ''}/schedules/${req.subscription?.scheduleId ?? ''}/subscriptions`;
103
- const body = marshalRequest(req.subscription, marshalSubscriptionSchema);
104
- let resp;
105
- const call = async (callSignal) => {
106
- const headers = new Headers({ 'Content-Type': 'application/json' });
107
- if (workspaceId !== undefined) {
108
- headers.set('X-Databricks-Workspace-Id', workspaceId);
109
- }
110
- headers.set('User-Agent', this.userAgent);
111
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
112
- const respBody = await executeHttpCall({
113
- request: httpReq,
114
- httpClient,
115
- logger: this.logger,
116
- });
117
- resp = parseResponse(respBody, unmarshalSubscriptionSchema);
118
- };
119
- await executeCall(call, options);
120
- if (resp === undefined) {
121
- throw new Error('operation completed without a result.');
122
- }
123
- return resp;
124
- }
125
- /** Delete dashboard schedule. */
126
- async deleteSchedule(req, options) {
127
- const { host, workspaceId, httpClient } = await this.resolveConfig();
128
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}`;
129
- const params = new URLSearchParams();
130
- if (req.etag !== undefined) {
131
- params.append('etag', req.etag);
132
- }
133
- const query = params.toString();
134
- const fullUrl = query !== '' ? `${url}?${query}` : url;
135
- const call = async (callSignal) => {
136
- const headers = new Headers();
137
- if (workspaceId !== undefined) {
138
- headers.set('X-Databricks-Workspace-Id', workspaceId);
139
- }
140
- headers.set('User-Agent', this.userAgent);
141
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
142
- await executeHttpCall({
143
- request: httpReq,
144
- httpClient,
145
- logger: this.logger,
146
- });
147
- };
148
- await executeCall(call, options);
149
- }
150
- /** Delete schedule subscription. */
151
- async deleteSubscription(req, options) {
152
- const { host, workspaceId, httpClient } = await this.resolveConfig();
153
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions/${req.subscriptionId ?? ''}`;
154
- const params = new URLSearchParams();
155
- if (req.etag !== undefined) {
156
- params.append('etag', req.etag);
157
- }
158
- const query = params.toString();
159
- const fullUrl = query !== '' ? `${url}?${query}` : url;
160
- const call = async (callSignal) => {
161
- const headers = new Headers();
162
- if (workspaceId !== undefined) {
163
- headers.set('X-Databricks-Workspace-Id', workspaceId);
164
- }
165
- headers.set('User-Agent', this.userAgent);
166
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
167
- await executeHttpCall({
168
- request: httpReq,
169
- httpClient,
170
- logger: this.logger,
171
- });
172
- };
173
- await executeCall(call, options);
174
- }
175
- /** Get a draft dashboard. */
176
- async getDashboard(req, options) {
177
- const { host, workspaceId, httpClient } = await this.resolveConfig();
178
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}`;
179
- let resp;
180
- const call = async (callSignal) => {
181
- const headers = new Headers();
182
- if (workspaceId !== undefined) {
183
- headers.set('X-Databricks-Workspace-Id', workspaceId);
184
- }
185
- headers.set('User-Agent', this.userAgent);
186
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
187
- const respBody = await executeHttpCall({
188
- request: httpReq,
189
- httpClient,
190
- logger: this.logger,
191
- });
192
- resp = parseResponse(respBody, unmarshalDashboardSchema);
193
- };
194
- await executeCall(call, options);
195
- if (resp === undefined) {
196
- throw new Error('operation completed without a result.');
197
- }
198
- return resp;
199
- }
200
- /** Get the current published dashboard. */
201
- async getPublishedDashboard(req, options) {
202
- const { host, workspaceId, httpClient } = await this.resolveConfig();
203
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
204
- let resp;
205
- const call = async (callSignal) => {
206
- const headers = new Headers();
207
- if (workspaceId !== undefined) {
208
- headers.set('X-Databricks-Workspace-Id', workspaceId);
209
- }
210
- headers.set('User-Agent', this.userAgent);
211
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
212
- const respBody = await executeHttpCall({
213
- request: httpReq,
214
- httpClient,
215
- logger: this.logger,
216
- });
217
- resp = parseResponse(respBody, unmarshalPublishedDashboardSchema);
218
- };
219
- await executeCall(call, options);
220
- if (resp === undefined) {
221
- throw new Error('operation completed without a result.');
222
- }
223
- return resp;
224
- }
225
- /** Get a required authorization details and scopes of a published dashboard to mint an OAuth token. */
226
- async getPublishedDashboardTokenInfo(req, options) {
227
- const { host, workspaceId, httpClient } = await this.resolveConfig();
228
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published/tokeninfo`;
229
- const params = new URLSearchParams();
230
- if (req.externalValue !== undefined) {
231
- params.append('external_value', req.externalValue);
232
- }
233
- if (req.externalViewerId !== undefined) {
234
- params.append('external_viewer_id', req.externalViewerId);
235
- }
236
- const query = params.toString();
237
- const fullUrl = query !== '' ? `${url}?${query}` : url;
238
- let resp;
239
- const call = async (callSignal) => {
240
- const headers = new Headers();
241
- if (workspaceId !== undefined) {
242
- headers.set('X-Databricks-Workspace-Id', workspaceId);
243
- }
244
- headers.set('User-Agent', this.userAgent);
245
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
246
- const respBody = await executeHttpCall({
247
- request: httpReq,
248
- httpClient,
249
- logger: this.logger,
250
- });
251
- resp = parseResponse(respBody, unmarshalGetPublishedDashboardTokenInfoResponseSchema);
252
- };
253
- await executeCall(call, options);
254
- if (resp === undefined) {
255
- throw new Error('operation completed without a result.');
256
- }
257
- return resp;
258
- }
259
- /** Get dashboard schedule. */
260
- async getSchedule(req, options) {
261
- const { host, workspaceId, httpClient } = await this.resolveConfig();
262
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}`;
263
- let resp;
264
- const call = async (callSignal) => {
265
- const headers = new Headers();
266
- if (workspaceId !== undefined) {
267
- headers.set('X-Databricks-Workspace-Id', workspaceId);
268
- }
269
- headers.set('User-Agent', this.userAgent);
270
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
271
- const respBody = await executeHttpCall({
272
- request: httpReq,
273
- httpClient,
274
- logger: this.logger,
275
- });
276
- resp = parseResponse(respBody, unmarshalScheduleSchema);
277
- };
278
- await executeCall(call, options);
279
- if (resp === undefined) {
280
- throw new Error('operation completed without a result.');
281
- }
282
- return resp;
283
- }
284
- /** Get schedule subscription. */
285
- async getSubscription(req, options) {
286
- const { host, workspaceId, httpClient } = await this.resolveConfig();
287
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions/${req.subscriptionId ?? ''}`;
288
- let resp;
289
- const call = async (callSignal) => {
290
- const headers = new Headers();
291
- if (workspaceId !== undefined) {
292
- headers.set('X-Databricks-Workspace-Id', workspaceId);
293
- }
294
- headers.set('User-Agent', this.userAgent);
295
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
296
- const respBody = await executeHttpCall({
297
- request: httpReq,
298
- httpClient,
299
- logger: this.logger,
300
- });
301
- resp = parseResponse(respBody, unmarshalSubscriptionSchema);
302
- };
303
- await executeCall(call, options);
304
- if (resp === undefined) {
305
- throw new Error('operation completed without a result.');
306
- }
307
- return resp;
308
- }
309
- /** List dashboards. */
310
- async listDashboards(req, options) {
311
- const { host, workspaceId, httpClient } = await this.resolveConfig();
312
- const url = `${host}/api/2.0/lakeview/dashboards`;
313
- const params = new URLSearchParams();
314
- if (req.pageSize !== undefined) {
315
- params.append('page_size', String(req.pageSize));
316
- }
317
- if (req.pageToken !== undefined) {
318
- params.append('page_token', req.pageToken);
319
- }
320
- if (req.showTrashed !== undefined) {
321
- params.append('show_trashed', String(req.showTrashed));
322
- }
323
- if (req.view !== undefined) {
324
- params.append('view', req.view);
325
- }
326
- const query = params.toString();
327
- const fullUrl = query !== '' ? `${url}?${query}` : url;
328
- let resp;
329
- const call = async (callSignal) => {
330
- const headers = new Headers();
331
- if (workspaceId !== undefined) {
332
- headers.set('X-Databricks-Workspace-Id', workspaceId);
333
- }
334
- headers.set('User-Agent', this.userAgent);
335
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
336
- const respBody = await executeHttpCall({
337
- request: httpReq,
338
- httpClient,
339
- logger: this.logger,
340
- });
341
- resp = parseResponse(respBody, unmarshalListDashboardsResponseSchema);
342
- };
343
- await executeCall(call, options);
344
- if (resp === undefined) {
345
- throw new Error('operation completed without a result.');
346
- }
347
- return resp;
348
- }
349
- async *listDashboardsIter(req, options) {
350
- const pageReq = { ...req };
351
- for (;;) {
352
- const resp = await this.listDashboards(pageReq, options);
353
- for (const item of resp.dashboards ?? []) {
354
- yield item;
355
- }
356
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
357
- return;
358
- }
359
- pageReq.pageToken = resp.nextPageToken;
360
- }
361
- }
362
- /** List dashboard schedules. */
363
- async listSchedules(req, options) {
364
- const { host, workspaceId, httpClient } = await this.resolveConfig();
365
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules`;
366
- const params = new URLSearchParams();
367
- if (req.pageSize !== undefined) {
368
- params.append('page_size', String(req.pageSize));
369
- }
370
- if (req.pageToken !== undefined) {
371
- params.append('page_token', req.pageToken);
372
- }
373
- const query = params.toString();
374
- const fullUrl = query !== '' ? `${url}?${query}` : url;
375
- let resp;
376
- const call = async (callSignal) => {
377
- const headers = new Headers();
378
- if (workspaceId !== undefined) {
379
- headers.set('X-Databricks-Workspace-Id', workspaceId);
380
- }
381
- headers.set('User-Agent', this.userAgent);
382
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
383
- const respBody = await executeHttpCall({
384
- request: httpReq,
385
- httpClient,
386
- logger: this.logger,
387
- });
388
- resp = parseResponse(respBody, unmarshalListSchedulesResponseSchema);
389
- };
390
- await executeCall(call, options);
391
- if (resp === undefined) {
392
- throw new Error('operation completed without a result.');
393
- }
394
- return resp;
395
- }
396
- async *listSchedulesIter(req, options) {
397
- const pageReq = { ...req };
398
- for (;;) {
399
- const resp = await this.listSchedules(pageReq, options);
400
- for (const item of resp.schedules ?? []) {
401
- yield item;
402
- }
403
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
404
- return;
405
- }
406
- pageReq.pageToken = resp.nextPageToken;
407
- }
408
- }
409
- /** List schedule subscriptions. */
410
- async listSubscriptions(req, options) {
411
- const { host, workspaceId, httpClient } = await this.resolveConfig();
412
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/schedules/${req.scheduleId ?? ''}/subscriptions`;
413
- const params = new URLSearchParams();
414
- if (req.pageSize !== undefined) {
415
- params.append('page_size', String(req.pageSize));
416
- }
417
- if (req.pageToken !== undefined) {
418
- params.append('page_token', req.pageToken);
419
- }
420
- const query = params.toString();
421
- const fullUrl = query !== '' ? `${url}?${query}` : url;
422
- let resp;
423
- const call = async (callSignal) => {
424
- const headers = new Headers();
425
- if (workspaceId !== undefined) {
426
- headers.set('X-Databricks-Workspace-Id', workspaceId);
427
- }
428
- headers.set('User-Agent', this.userAgent);
429
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
430
- const respBody = await executeHttpCall({
431
- request: httpReq,
432
- httpClient,
433
- logger: this.logger,
434
- });
435
- resp = parseResponse(respBody, unmarshalListSubscriptionsResponseSchema);
436
- };
437
- await executeCall(call, options);
438
- if (resp === undefined) {
439
- throw new Error('operation completed without a result.');
440
- }
441
- return resp;
442
- }
443
- async *listSubscriptionsIter(req, options) {
444
- const pageReq = { ...req };
445
- for (;;) {
446
- const resp = await this.listSubscriptions(pageReq, options);
447
- for (const item of resp.subscriptions ?? []) {
448
- yield item;
449
- }
450
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
451
- return;
452
- }
453
- pageReq.pageToken = resp.nextPageToken;
454
- }
455
- }
456
- /** Migrates a classic SQL dashboard to Lakeview. */
457
- async migrateDashboard(req, options) {
458
- const { host, workspaceId, httpClient } = await this.resolveConfig();
459
- const url = `${host}/api/2.0/lakeview/dashboards/migrate`;
460
- const body = marshalRequest(req, marshalMigrateDashboardRequestSchema);
461
- let resp;
462
- const call = async (callSignal) => {
463
- const headers = new Headers({ 'Content-Type': 'application/json' });
464
- if (workspaceId !== undefined) {
465
- headers.set('X-Databricks-Workspace-Id', workspaceId);
466
- }
467
- headers.set('User-Agent', this.userAgent);
468
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
469
- const respBody = await executeHttpCall({
470
- request: httpReq,
471
- httpClient,
472
- logger: this.logger,
473
- });
474
- resp = parseResponse(respBody, unmarshalDashboardSchema);
475
- };
476
- await executeCall(call, options);
477
- if (resp === undefined) {
478
- throw new Error('operation completed without a result.');
479
- }
480
- return resp;
481
- }
482
- /** Publish the current draft dashboard. */
483
- async publishDashboard(req, options) {
484
- const { host, workspaceId, httpClient } = await this.resolveConfig();
485
- const url = `${host}/api/2.0/lakeview/dashboards/${req.dashboardId ?? ''}/published`;
486
- const body = marshalRequest(req, marshalPublishDashboardRequestSchema);
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