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