@databricks/sdk-pipelines 0.1.0-dev.2 → 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/dist/v2/client.d.ts +13 -13
- package/dist/v2/client.d.ts.map +1 -1
- package/dist/v2/client.js +13 -13
- package/dist/v2/client.js.map +1 -1
- package/dist/v2/index.d.ts +1 -1
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/model.d.ts +281 -247
- package/dist/v2/model.d.ts.map +1 -1
- package/dist/v2/model.js +289 -306
- package/dist/v2/model.js.map +1 -1
- package/dist/v2/utils.d.ts.map +1 -1
- package/dist/v2/utils.js +2 -1
- package/dist/v2/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/v2/client.ts +0 -663
- package/src/v2/index.ts +0 -154
- package/src/v2/model.ts +0 -5508
- package/src/v2/transport.ts +0 -73
- package/src/v2/utils.ts +0 -180
package/src/v2/client.ts
DELETED
|
@@ -1,663 +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 {LroOptions} from '@databricks/sdk-options/lro';
|
|
10
|
-
import type {HttpClient} from '@databricks/sdk-core/http';
|
|
11
|
-
import {newHttpClient} from './transport';
|
|
12
|
-
import {
|
|
13
|
-
buildHttpRequest,
|
|
14
|
-
executeCall,
|
|
15
|
-
executeHttpCall,
|
|
16
|
-
marshalRequest,
|
|
17
|
-
parseResponse,
|
|
18
|
-
executeWait,
|
|
19
|
-
StillRunningError,
|
|
20
|
-
} from './utils';
|
|
21
|
-
import pkgJson from '../../package.json' with {type: 'json'};
|
|
22
|
-
import type {
|
|
23
|
-
ApplyEnvironmentRequest,
|
|
24
|
-
ApplyEnvironmentRequest_Response,
|
|
25
|
-
ClonePipelineRequest,
|
|
26
|
-
ClonePipelineRequest_Response,
|
|
27
|
-
CreatePipelineRequest,
|
|
28
|
-
CreatePipelineRequest_Response,
|
|
29
|
-
DeletePipelineRequest,
|
|
30
|
-
DeletePipelineRequest_Response,
|
|
31
|
-
EditPipelineRequest,
|
|
32
|
-
EditPipelineRequest_Response,
|
|
33
|
-
GetPipelineRequest,
|
|
34
|
-
GetPipelineRequest_Response,
|
|
35
|
-
GetUpdateRequest,
|
|
36
|
-
GetUpdateRequest_Response,
|
|
37
|
-
ListPipelineEventsRequest,
|
|
38
|
-
ListPipelineEventsRequest_Response,
|
|
39
|
-
ListPipelinesRequest,
|
|
40
|
-
ListPipelinesRequest_Response,
|
|
41
|
-
ListUpdatesRequest,
|
|
42
|
-
ListUpdatesRequest_Response,
|
|
43
|
-
PipelineEvent,
|
|
44
|
-
PipelineStateInfo,
|
|
45
|
-
StartUpdateRequest,
|
|
46
|
-
StartUpdateRequest_Response,
|
|
47
|
-
StopPipelineRequest,
|
|
48
|
-
StopPipelineRequest_Response,
|
|
49
|
-
} from './model';
|
|
50
|
-
import {
|
|
51
|
-
PipelineState_PipelineState,
|
|
52
|
-
marshalApplyEnvironmentRequestSchema,
|
|
53
|
-
marshalClonePipelineRequestSchema,
|
|
54
|
-
marshalCreatePipelineRequestSchema,
|
|
55
|
-
marshalEditPipelineRequestSchema,
|
|
56
|
-
marshalStartUpdateRequestSchema,
|
|
57
|
-
marshalStopPipelineRequestSchema,
|
|
58
|
-
unmarshalApplyEnvironmentRequest_ResponseSchema,
|
|
59
|
-
unmarshalClonePipelineRequest_ResponseSchema,
|
|
60
|
-
unmarshalCreatePipelineRequest_ResponseSchema,
|
|
61
|
-
unmarshalDeletePipelineRequest_ResponseSchema,
|
|
62
|
-
unmarshalEditPipelineRequest_ResponseSchema,
|
|
63
|
-
unmarshalGetPipelineRequest_ResponseSchema,
|
|
64
|
-
unmarshalGetUpdateRequest_ResponseSchema,
|
|
65
|
-
unmarshalListPipelineEventsRequest_ResponseSchema,
|
|
66
|
-
unmarshalListPipelinesRequest_ResponseSchema,
|
|
67
|
-
unmarshalListUpdatesRequest_ResponseSchema,
|
|
68
|
-
unmarshalStartUpdateRequest_ResponseSchema,
|
|
69
|
-
unmarshalStopPipelineRequest_ResponseSchema,
|
|
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 PipelinesClient {
|
|
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
|
-
/**
|
|
107
|
-
* *
|
|
108
|
-
* Applies the current pipeline environment onto the pipeline compute. The environment applied can be used by subsequent
|
|
109
|
-
* dev-mode updates.
|
|
110
|
-
*/
|
|
111
|
-
async applyEnvironment(
|
|
112
|
-
req: ApplyEnvironmentRequest,
|
|
113
|
-
options?: CallOptions
|
|
114
|
-
): Promise<ApplyEnvironmentRequest_Response> {
|
|
115
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/environment/apply`;
|
|
116
|
-
const body = marshalRequest(req, marshalApplyEnvironmentRequestSchema);
|
|
117
|
-
let resp: ApplyEnvironmentRequest_Response | undefined;
|
|
118
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
119
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
120
|
-
if (this.workspaceId !== undefined) {
|
|
121
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
122
|
-
}
|
|
123
|
-
headers.set('User-Agent', this.userAgent);
|
|
124
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
125
|
-
const respBody = await executeHttpCall({
|
|
126
|
-
request: httpReq,
|
|
127
|
-
httpClient: this.httpClient,
|
|
128
|
-
logger: this.logger,
|
|
129
|
-
});
|
|
130
|
-
resp = parseResponse(
|
|
131
|
-
respBody,
|
|
132
|
-
unmarshalApplyEnvironmentRequest_ResponseSchema
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
await executeCall(call, options);
|
|
136
|
-
if (resp === undefined) {
|
|
137
|
-
throw new Error('operation completed without a result.');
|
|
138
|
-
}
|
|
139
|
-
return resp;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Creates a new pipeline using Unity Catalog from a pipeline using Hive Metastore.
|
|
144
|
-
* This method returns the ID of the newly created clone.
|
|
145
|
-
* Additionally, this method starts an update for the newly created pipeline.
|
|
146
|
-
*/
|
|
147
|
-
async clone(
|
|
148
|
-
req: ClonePipelineRequest,
|
|
149
|
-
options?: CallOptions
|
|
150
|
-
): Promise<ClonePipelineRequest_Response> {
|
|
151
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/clone`;
|
|
152
|
-
const body = marshalRequest(req, marshalClonePipelineRequestSchema);
|
|
153
|
-
let resp: ClonePipelineRequest_Response | undefined;
|
|
154
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
155
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
156
|
-
if (this.workspaceId !== undefined) {
|
|
157
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
158
|
-
}
|
|
159
|
-
headers.set('User-Agent', this.userAgent);
|
|
160
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
161
|
-
const respBody = await executeHttpCall({
|
|
162
|
-
request: httpReq,
|
|
163
|
-
httpClient: this.httpClient,
|
|
164
|
-
logger: this.logger,
|
|
165
|
-
});
|
|
166
|
-
resp = parseResponse(
|
|
167
|
-
respBody,
|
|
168
|
-
unmarshalClonePipelineRequest_ResponseSchema
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
await executeCall(call, options);
|
|
172
|
-
if (resp === undefined) {
|
|
173
|
-
throw new Error('operation completed without a result.');
|
|
174
|
-
}
|
|
175
|
-
return resp;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Creates a new data processing pipeline based on the requested configuration. If successful, this method returns
|
|
180
|
-
* the ID of the new pipeline.
|
|
181
|
-
*/
|
|
182
|
-
async create(
|
|
183
|
-
req: CreatePipelineRequest,
|
|
184
|
-
options?: CallOptions
|
|
185
|
-
): Promise<CreatePipelineRequest_Response> {
|
|
186
|
-
const url = `${this.host}/api/2.0/pipelines`;
|
|
187
|
-
const body = marshalRequest(req, marshalCreatePipelineRequestSchema);
|
|
188
|
-
let resp: CreatePipelineRequest_Response | undefined;
|
|
189
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
190
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
191
|
-
if (this.workspaceId !== undefined) {
|
|
192
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
193
|
-
}
|
|
194
|
-
headers.set('User-Agent', this.userAgent);
|
|
195
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
196
|
-
const respBody = await executeHttpCall({
|
|
197
|
-
request: httpReq,
|
|
198
|
-
httpClient: this.httpClient,
|
|
199
|
-
logger: this.logger,
|
|
200
|
-
});
|
|
201
|
-
resp = parseResponse(
|
|
202
|
-
respBody,
|
|
203
|
-
unmarshalCreatePipelineRequest_ResponseSchema
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
await executeCall(call, options);
|
|
207
|
-
if (resp === undefined) {
|
|
208
|
-
throw new Error('operation completed without a result.');
|
|
209
|
-
}
|
|
210
|
-
return resp;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Deletes a pipeline. If the pipeline publishes to Unity Catalog, pipeline deletion will cascade to
|
|
215
|
-
* all pipeline tables. Please reach out to <Databricks> support for assistance to undo this action.
|
|
216
|
-
*/
|
|
217
|
-
async delete(
|
|
218
|
-
req: DeletePipelineRequest,
|
|
219
|
-
options?: CallOptions
|
|
220
|
-
): Promise<DeletePipelineRequest_Response> {
|
|
221
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}`;
|
|
222
|
-
const params = new URLSearchParams();
|
|
223
|
-
if (req.force !== undefined) {
|
|
224
|
-
params.append('force', String(req.force));
|
|
225
|
-
}
|
|
226
|
-
if (req.cascade !== undefined) {
|
|
227
|
-
params.append('cascade', String(req.cascade));
|
|
228
|
-
}
|
|
229
|
-
const query = params.toString();
|
|
230
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
231
|
-
let resp: DeletePipelineRequest_Response | undefined;
|
|
232
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
233
|
-
const headers = new Headers();
|
|
234
|
-
if (this.workspaceId !== undefined) {
|
|
235
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
236
|
-
}
|
|
237
|
-
headers.set('User-Agent', this.userAgent);
|
|
238
|
-
const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
|
|
239
|
-
const respBody = await executeHttpCall({
|
|
240
|
-
request: httpReq,
|
|
241
|
-
httpClient: this.httpClient,
|
|
242
|
-
logger: this.logger,
|
|
243
|
-
});
|
|
244
|
-
resp = parseResponse(
|
|
245
|
-
respBody,
|
|
246
|
-
unmarshalDeletePipelineRequest_ResponseSchema
|
|
247
|
-
);
|
|
248
|
-
};
|
|
249
|
-
await executeCall(call, options);
|
|
250
|
-
if (resp === undefined) {
|
|
251
|
-
throw new Error('operation completed without a result.');
|
|
252
|
-
}
|
|
253
|
-
return resp;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/** Updates a pipeline with the supplied configuration. */
|
|
257
|
-
async edit(
|
|
258
|
-
req: EditPipelineRequest,
|
|
259
|
-
options?: CallOptions
|
|
260
|
-
): Promise<EditPipelineRequest_Response> {
|
|
261
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}`;
|
|
262
|
-
const body = marshalRequest(req, marshalEditPipelineRequestSchema);
|
|
263
|
-
let resp: EditPipelineRequest_Response | undefined;
|
|
264
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
265
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
266
|
-
if (this.workspaceId !== undefined) {
|
|
267
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
268
|
-
}
|
|
269
|
-
headers.set('User-Agent', this.userAgent);
|
|
270
|
-
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
271
|
-
const respBody = await executeHttpCall({
|
|
272
|
-
request: httpReq,
|
|
273
|
-
httpClient: this.httpClient,
|
|
274
|
-
logger: this.logger,
|
|
275
|
-
});
|
|
276
|
-
resp = parseResponse(
|
|
277
|
-
respBody,
|
|
278
|
-
unmarshalEditPipelineRequest_ResponseSchema
|
|
279
|
-
);
|
|
280
|
-
};
|
|
281
|
-
await executeCall(call, options);
|
|
282
|
-
if (resp === undefined) {
|
|
283
|
-
throw new Error('operation completed without a result.');
|
|
284
|
-
}
|
|
285
|
-
return resp;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** Retrieves events for a pipeline. */
|
|
289
|
-
async events(
|
|
290
|
-
req: ListPipelineEventsRequest,
|
|
291
|
-
options?: CallOptions
|
|
292
|
-
): Promise<ListPipelineEventsRequest_Response> {
|
|
293
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/events`;
|
|
294
|
-
const params = new URLSearchParams();
|
|
295
|
-
if (req.pageToken !== undefined) {
|
|
296
|
-
params.append('page_token', req.pageToken);
|
|
297
|
-
}
|
|
298
|
-
if (req.maxResults !== undefined) {
|
|
299
|
-
params.append('max_results', String(req.maxResults));
|
|
300
|
-
}
|
|
301
|
-
if (req.orderBy !== undefined) {
|
|
302
|
-
params.append('order_by', String(req.orderBy));
|
|
303
|
-
}
|
|
304
|
-
if (req.filter !== undefined) {
|
|
305
|
-
params.append('filter', req.filter);
|
|
306
|
-
}
|
|
307
|
-
const query = params.toString();
|
|
308
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
309
|
-
let resp: ListPipelineEventsRequest_Response | undefined;
|
|
310
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
311
|
-
const headers = new Headers();
|
|
312
|
-
if (this.workspaceId !== undefined) {
|
|
313
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
314
|
-
}
|
|
315
|
-
headers.set('User-Agent', this.userAgent);
|
|
316
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
317
|
-
const respBody = await executeHttpCall({
|
|
318
|
-
request: httpReq,
|
|
319
|
-
httpClient: this.httpClient,
|
|
320
|
-
logger: this.logger,
|
|
321
|
-
});
|
|
322
|
-
resp = parseResponse(
|
|
323
|
-
respBody,
|
|
324
|
-
unmarshalListPipelineEventsRequest_ResponseSchema
|
|
325
|
-
);
|
|
326
|
-
};
|
|
327
|
-
await executeCall(call, options);
|
|
328
|
-
if (resp === undefined) {
|
|
329
|
-
throw new Error('operation completed without a result.');
|
|
330
|
-
}
|
|
331
|
-
return resp;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async *eventsIter(
|
|
335
|
-
req: ListPipelineEventsRequest,
|
|
336
|
-
options?: CallOptions
|
|
337
|
-
): AsyncGenerator<PipelineEvent> {
|
|
338
|
-
const pageReq: ListPipelineEventsRequest = {...req};
|
|
339
|
-
for (;;) {
|
|
340
|
-
const resp = await this.events(pageReq, options);
|
|
341
|
-
for (const item of resp.events ?? []) {
|
|
342
|
-
yield item;
|
|
343
|
-
}
|
|
344
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/** Get a pipeline. */
|
|
352
|
-
async get(
|
|
353
|
-
req: GetPipelineRequest,
|
|
354
|
-
options?: CallOptions
|
|
355
|
-
): Promise<GetPipelineRequest_Response> {
|
|
356
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}`;
|
|
357
|
-
let resp: GetPipelineRequest_Response | undefined;
|
|
358
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
359
|
-
const headers = new Headers();
|
|
360
|
-
if (this.workspaceId !== undefined) {
|
|
361
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
362
|
-
}
|
|
363
|
-
headers.set('User-Agent', this.userAgent);
|
|
364
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
365
|
-
const respBody = await executeHttpCall({
|
|
366
|
-
request: httpReq,
|
|
367
|
-
httpClient: this.httpClient,
|
|
368
|
-
logger: this.logger,
|
|
369
|
-
});
|
|
370
|
-
resp = parseResponse(
|
|
371
|
-
respBody,
|
|
372
|
-
unmarshalGetPipelineRequest_ResponseSchema
|
|
373
|
-
);
|
|
374
|
-
};
|
|
375
|
-
await executeCall(call, options);
|
|
376
|
-
if (resp === undefined) {
|
|
377
|
-
throw new Error('operation completed without a result.');
|
|
378
|
-
}
|
|
379
|
-
return resp;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/** Gets an update from an active pipeline. */
|
|
383
|
-
async getUpdate(
|
|
384
|
-
req: GetUpdateRequest,
|
|
385
|
-
options?: CallOptions
|
|
386
|
-
): Promise<GetUpdateRequest_Response> {
|
|
387
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/updates/${req.updateId ?? ''}`;
|
|
388
|
-
let resp: GetUpdateRequest_Response | undefined;
|
|
389
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
390
|
-
const headers = new Headers();
|
|
391
|
-
if (this.workspaceId !== undefined) {
|
|
392
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
393
|
-
}
|
|
394
|
-
headers.set('User-Agent', this.userAgent);
|
|
395
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
396
|
-
const respBody = await executeHttpCall({
|
|
397
|
-
request: httpReq,
|
|
398
|
-
httpClient: this.httpClient,
|
|
399
|
-
logger: this.logger,
|
|
400
|
-
});
|
|
401
|
-
resp = parseResponse(respBody, unmarshalGetUpdateRequest_ResponseSchema);
|
|
402
|
-
};
|
|
403
|
-
await executeCall(call, options);
|
|
404
|
-
if (resp === undefined) {
|
|
405
|
-
throw new Error('operation completed without a result.');
|
|
406
|
-
}
|
|
407
|
-
return resp;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** Lists pipelines defined in the Spark Declarative Pipelines system. */
|
|
411
|
-
async list(
|
|
412
|
-
req: ListPipelinesRequest,
|
|
413
|
-
options?: CallOptions
|
|
414
|
-
): Promise<ListPipelinesRequest_Response> {
|
|
415
|
-
const url = `${this.host}/api/2.0/pipelines`;
|
|
416
|
-
const params = new URLSearchParams();
|
|
417
|
-
if (req.pageToken !== undefined) {
|
|
418
|
-
params.append('page_token', req.pageToken);
|
|
419
|
-
}
|
|
420
|
-
if (req.maxResults !== undefined) {
|
|
421
|
-
params.append('max_results', String(req.maxResults));
|
|
422
|
-
}
|
|
423
|
-
if (req.orderBy !== undefined) {
|
|
424
|
-
params.append('order_by', String(req.orderBy));
|
|
425
|
-
}
|
|
426
|
-
if (req.filter !== undefined) {
|
|
427
|
-
params.append('filter', req.filter);
|
|
428
|
-
}
|
|
429
|
-
const query = params.toString();
|
|
430
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
431
|
-
let resp: ListPipelinesRequest_Response | undefined;
|
|
432
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
433
|
-
const headers = new Headers();
|
|
434
|
-
if (this.workspaceId !== undefined) {
|
|
435
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
436
|
-
}
|
|
437
|
-
headers.set('User-Agent', this.userAgent);
|
|
438
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
439
|
-
const respBody = await executeHttpCall({
|
|
440
|
-
request: httpReq,
|
|
441
|
-
httpClient: this.httpClient,
|
|
442
|
-
logger: this.logger,
|
|
443
|
-
});
|
|
444
|
-
resp = parseResponse(
|
|
445
|
-
respBody,
|
|
446
|
-
unmarshalListPipelinesRequest_ResponseSchema
|
|
447
|
-
);
|
|
448
|
-
};
|
|
449
|
-
await executeCall(call, options);
|
|
450
|
-
if (resp === undefined) {
|
|
451
|
-
throw new Error('operation completed without a result.');
|
|
452
|
-
}
|
|
453
|
-
return resp;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
async *listIter(
|
|
457
|
-
req: ListPipelinesRequest,
|
|
458
|
-
options?: CallOptions
|
|
459
|
-
): AsyncGenerator<PipelineStateInfo> {
|
|
460
|
-
const pageReq: ListPipelinesRequest = {...req};
|
|
461
|
-
for (;;) {
|
|
462
|
-
const resp = await this.list(pageReq, options);
|
|
463
|
-
for (const item of resp.statuses ?? []) {
|
|
464
|
-
yield item;
|
|
465
|
-
}
|
|
466
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/** List updates for an active pipeline. */
|
|
474
|
-
async listUpdates(
|
|
475
|
-
req: ListUpdatesRequest,
|
|
476
|
-
options?: CallOptions
|
|
477
|
-
): Promise<ListUpdatesRequest_Response> {
|
|
478
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/updates`;
|
|
479
|
-
const params = new URLSearchParams();
|
|
480
|
-
if (req.pageToken !== undefined) {
|
|
481
|
-
params.append('page_token', req.pageToken);
|
|
482
|
-
}
|
|
483
|
-
if (req.maxResults !== undefined) {
|
|
484
|
-
params.append('max_results', String(req.maxResults));
|
|
485
|
-
}
|
|
486
|
-
if (req.untilUpdateId !== undefined) {
|
|
487
|
-
params.append('until_update_id', req.untilUpdateId);
|
|
488
|
-
}
|
|
489
|
-
const query = params.toString();
|
|
490
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
491
|
-
let resp: ListUpdatesRequest_Response | 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(
|
|
505
|
-
respBody,
|
|
506
|
-
unmarshalListUpdatesRequest_ResponseSchema
|
|
507
|
-
);
|
|
508
|
-
};
|
|
509
|
-
await executeCall(call, options);
|
|
510
|
-
if (resp === undefined) {
|
|
511
|
-
throw new Error('operation completed without a result.');
|
|
512
|
-
}
|
|
513
|
-
return resp;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/** Starts a new update for the pipeline. If there is already an active update for the pipeline, the request will fail and the active update will remain running. */
|
|
517
|
-
async start(
|
|
518
|
-
req: StartUpdateRequest,
|
|
519
|
-
options?: CallOptions
|
|
520
|
-
): Promise<StartUpdateRequest_Response> {
|
|
521
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/updates`;
|
|
522
|
-
const body = marshalRequest(req, marshalStartUpdateRequestSchema);
|
|
523
|
-
let resp: StartUpdateRequest_Response | undefined;
|
|
524
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
525
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
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('POST', url, headers, callSignal, body);
|
|
531
|
-
const respBody = await executeHttpCall({
|
|
532
|
-
request: httpReq,
|
|
533
|
-
httpClient: this.httpClient,
|
|
534
|
-
logger: this.logger,
|
|
535
|
-
});
|
|
536
|
-
resp = parseResponse(
|
|
537
|
-
respBody,
|
|
538
|
-
unmarshalStartUpdateRequest_ResponseSchema
|
|
539
|
-
);
|
|
540
|
-
};
|
|
541
|
-
await executeCall(call, options);
|
|
542
|
-
if (resp === undefined) {
|
|
543
|
-
throw new Error('operation completed without a result.');
|
|
544
|
-
}
|
|
545
|
-
return resp;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/** Stops the pipeline by canceling the active update. If there is no active update for the pipeline, this request is a no-op. */
|
|
549
|
-
private async stop(
|
|
550
|
-
req: StopPipelineRequest,
|
|
551
|
-
options?: CallOptions
|
|
552
|
-
): Promise<StopPipelineRequest_Response> {
|
|
553
|
-
const url = `${this.host}/api/2.0/pipelines/${req.pipelineId ?? ''}/stop`;
|
|
554
|
-
const body = marshalRequest(req, marshalStopPipelineRequestSchema);
|
|
555
|
-
let resp: StopPipelineRequest_Response | undefined;
|
|
556
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
557
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
558
|
-
if (this.workspaceId !== undefined) {
|
|
559
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
560
|
-
}
|
|
561
|
-
headers.set('User-Agent', this.userAgent);
|
|
562
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
563
|
-
const respBody = await executeHttpCall({
|
|
564
|
-
request: httpReq,
|
|
565
|
-
httpClient: this.httpClient,
|
|
566
|
-
logger: this.logger,
|
|
567
|
-
});
|
|
568
|
-
resp = parseResponse(
|
|
569
|
-
respBody,
|
|
570
|
-
unmarshalStopPipelineRequest_ResponseSchema
|
|
571
|
-
);
|
|
572
|
-
};
|
|
573
|
-
await executeCall(call, options);
|
|
574
|
-
if (resp === undefined) {
|
|
575
|
-
throw new Error('operation completed without a result.');
|
|
576
|
-
}
|
|
577
|
-
return resp;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
async stopWaiter(
|
|
581
|
-
req: StopPipelineRequest,
|
|
582
|
-
options?: CallOptions
|
|
583
|
-
): Promise<StopWaiter> {
|
|
584
|
-
await this.stop(req, options);
|
|
585
|
-
if (req.pipelineId === undefined) {
|
|
586
|
-
throw new Error(
|
|
587
|
-
'request field pipelineId required for polling is missing'
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
return new StopWaiter(this, req.pipelineId);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
export class StopWaiter {
|
|
595
|
-
constructor(
|
|
596
|
-
private readonly client: PipelinesClient,
|
|
597
|
-
readonly pipelineId: string
|
|
598
|
-
) {}
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Polls until the operation reaches a terminal state.
|
|
602
|
-
*
|
|
603
|
-
* Throws if a failure state is reached.
|
|
604
|
-
*/
|
|
605
|
-
async wait(options?: LroOptions): Promise<GetPipelineRequest_Response> {
|
|
606
|
-
let result: GetPipelineRequest_Response | undefined;
|
|
607
|
-
|
|
608
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
609
|
-
const pollResp = await this.client.get(
|
|
610
|
-
{
|
|
611
|
-
pipelineId: this.pipelineId,
|
|
612
|
-
},
|
|
613
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
614
|
-
);
|
|
615
|
-
|
|
616
|
-
const status = pollResp.state;
|
|
617
|
-
if (status === undefined) {
|
|
618
|
-
throw new Error('response missing required status field');
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
switch (status) {
|
|
622
|
-
case PipelineState_PipelineState.IDLE:
|
|
623
|
-
result = pollResp;
|
|
624
|
-
return;
|
|
625
|
-
case PipelineState_PipelineState.FAILED: {
|
|
626
|
-
const msg = pollResp.cause ?? '(no message)';
|
|
627
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
628
|
-
}
|
|
629
|
-
default:
|
|
630
|
-
throw new StillRunningError();
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
await executeWait(call, options);
|
|
635
|
-
if (result === undefined) {
|
|
636
|
-
throw new Error('operation completed without a result.');
|
|
637
|
-
}
|
|
638
|
-
return result;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
642
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
643
|
-
const pollResp = await this.client.get(
|
|
644
|
-
{
|
|
645
|
-
pipelineId: this.pipelineId,
|
|
646
|
-
},
|
|
647
|
-
options
|
|
648
|
-
);
|
|
649
|
-
|
|
650
|
-
const status = pollResp.state;
|
|
651
|
-
if (status === undefined) {
|
|
652
|
-
throw new Error('response missing required status field');
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
switch (status) {
|
|
656
|
-
case PipelineState_PipelineState.IDLE:
|
|
657
|
-
case PipelineState_PipelineState.FAILED:
|
|
658
|
-
return true;
|
|
659
|
-
default:
|
|
660
|
-
return false;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|