@databricks/sdk-jobs 0.1.0-dev.3 → 0.1.0-dev.5
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/README.md +28 -0
- package/dist/v2/client.d.ts +3 -3
- package/dist/v2/client.d.ts.map +1 -1
- package/dist/v2/client.js +106 -89
- 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 +345 -511
- package/dist/v2/model.d.ts.map +1 -1
- package/dist/v2/model.js +437 -474
- package/dist/v2/model.js.map +1 -1
- package/dist/v2/transport.d.ts +30 -2
- package/dist/v2/transport.d.ts.map +1 -1
- package/dist/v2/transport.js +33 -16
- package/dist/v2/transport.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 +9 -5
- package/src/v2/client.ts +0 -1249
- package/src/v2/index.ts +0 -284
- package/src/v2/model.ts +0 -10210
- package/src/v2/transport.ts +0 -73
- package/src/v2/utils.ts +0 -180
package/src/v2/client.ts
DELETED
|
@@ -1,1249 +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
|
-
BaseJob,
|
|
24
|
-
BaseRun,
|
|
25
|
-
CancelAllRunsRequest,
|
|
26
|
-
CancelAllRunsResponse,
|
|
27
|
-
CancelRunRequest,
|
|
28
|
-
CancelRunResponse,
|
|
29
|
-
CreateJobRequest,
|
|
30
|
-
CreateJobResponse,
|
|
31
|
-
DeleteJobRequest,
|
|
32
|
-
DeleteJobResponse,
|
|
33
|
-
DeleteRunRequest,
|
|
34
|
-
DeleteRunResponse,
|
|
35
|
-
EnforcePolicyComplianceForJob,
|
|
36
|
-
EnforcePolicyComplianceResponse,
|
|
37
|
-
ExportRunRequest,
|
|
38
|
-
ExportRunResponse,
|
|
39
|
-
GetJobRequest,
|
|
40
|
-
GetJobResponse,
|
|
41
|
-
GetPolicyComplianceForJob,
|
|
42
|
-
GetPolicyComplianceForJobResponse,
|
|
43
|
-
GetRunOutputRequest,
|
|
44
|
-
GetRunOutputResponse,
|
|
45
|
-
GetRunRequest,
|
|
46
|
-
GetRunResponse,
|
|
47
|
-
ListJobComplianceForPolicy,
|
|
48
|
-
ListJobComplianceForPolicy_JobCompliance,
|
|
49
|
-
ListJobComplianceResponse,
|
|
50
|
-
ListJobsRequest,
|
|
51
|
-
ListJobsResponse,
|
|
52
|
-
ListRunsRequest,
|
|
53
|
-
ListRunsResponse,
|
|
54
|
-
RepairRunRequest,
|
|
55
|
-
RepairRunResponse,
|
|
56
|
-
ResetJobRequest,
|
|
57
|
-
ResetJobResponse,
|
|
58
|
-
RunNowRequest,
|
|
59
|
-
RunNowResponse,
|
|
60
|
-
SubmitRunRequest,
|
|
61
|
-
SubmitRunResponse,
|
|
62
|
-
UpdateJobRequest,
|
|
63
|
-
UpdateJobResponse,
|
|
64
|
-
} from './model';
|
|
65
|
-
import {
|
|
66
|
-
RunLifeCycleState_RunLifeCycleState,
|
|
67
|
-
marshalCancelAllRunsRequestSchema,
|
|
68
|
-
marshalCancelRunRequestSchema,
|
|
69
|
-
marshalCreateJobRequestSchema,
|
|
70
|
-
marshalDeleteJobRequestSchema,
|
|
71
|
-
marshalDeleteRunRequestSchema,
|
|
72
|
-
marshalEnforcePolicyComplianceForJobSchema,
|
|
73
|
-
marshalRepairRunRequestSchema,
|
|
74
|
-
marshalResetJobRequestSchema,
|
|
75
|
-
marshalRunNowRequestSchema,
|
|
76
|
-
marshalSubmitRunRequestSchema,
|
|
77
|
-
marshalUpdateJobRequestSchema,
|
|
78
|
-
unmarshalCancelAllRunsResponseSchema,
|
|
79
|
-
unmarshalCancelRunResponseSchema,
|
|
80
|
-
unmarshalCreateJobResponseSchema,
|
|
81
|
-
unmarshalDeleteJobResponseSchema,
|
|
82
|
-
unmarshalDeleteRunResponseSchema,
|
|
83
|
-
unmarshalEnforcePolicyComplianceResponseSchema,
|
|
84
|
-
unmarshalExportRunResponseSchema,
|
|
85
|
-
unmarshalGetJobResponseSchema,
|
|
86
|
-
unmarshalGetPolicyComplianceForJobResponseSchema,
|
|
87
|
-
unmarshalGetRunOutputResponseSchema,
|
|
88
|
-
unmarshalGetRunResponseSchema,
|
|
89
|
-
unmarshalListJobComplianceResponseSchema,
|
|
90
|
-
unmarshalListJobsResponseSchema,
|
|
91
|
-
unmarshalListRunsResponseSchema,
|
|
92
|
-
unmarshalRepairRunResponseSchema,
|
|
93
|
-
unmarshalResetJobResponseSchema,
|
|
94
|
-
unmarshalRunNowResponseSchema,
|
|
95
|
-
unmarshalSubmitRunResponseSchema,
|
|
96
|
-
unmarshalUpdateJobResponseSchema,
|
|
97
|
-
} from './model';
|
|
98
|
-
|
|
99
|
-
// Package identity segment for this client to be used in the User-Agent header.
|
|
100
|
-
const PACKAGE_SEGMENT = {
|
|
101
|
-
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
102
|
-
value: pkgJson.version,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export class JobsClient {
|
|
106
|
-
private readonly host: string;
|
|
107
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
108
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
109
|
-
// request.
|
|
110
|
-
private readonly workspaceId: string | undefined;
|
|
111
|
-
private readonly httpClient: HttpClient;
|
|
112
|
-
private readonly logger: Logger;
|
|
113
|
-
// User-Agent header value. Composed once at construction from
|
|
114
|
-
// createDefault() merged with this package's identity and the active
|
|
115
|
-
// credential's name.
|
|
116
|
-
private readonly userAgent: string;
|
|
117
|
-
|
|
118
|
-
constructor(options: ClientOptions) {
|
|
119
|
-
if (options.host === undefined) {
|
|
120
|
-
throw new Error('Host is required.');
|
|
121
|
-
}
|
|
122
|
-
this.host = options.host.replace(/\/$/, '');
|
|
123
|
-
this.workspaceId = options.workspaceId;
|
|
124
|
-
this.logger = options.logger ?? new NoOpLogger();
|
|
125
|
-
const info = createDefault()
|
|
126
|
-
.with(PACKAGE_SEGMENT)
|
|
127
|
-
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
128
|
-
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
129
|
-
this.userAgent = info.toString();
|
|
130
|
-
this.httpClient = newHttpClient(options);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Updates a job so the job clusters that are created when running
|
|
135
|
-
* the job (specified in `new_cluster`) are compliant with the
|
|
136
|
-
* current versions of their respective cluster policies.
|
|
137
|
-
* All-purpose clusters used in the job will not be updated.
|
|
138
|
-
*/
|
|
139
|
-
async enforcePolicyComplianceForJob(
|
|
140
|
-
req: EnforcePolicyComplianceForJob,
|
|
141
|
-
options?: CallOptions
|
|
142
|
-
): Promise<EnforcePolicyComplianceResponse> {
|
|
143
|
-
const url = `${this.host}/api/2.0/policies/jobs/enforce-compliance`;
|
|
144
|
-
const body = marshalRequest(
|
|
145
|
-
req,
|
|
146
|
-
marshalEnforcePolicyComplianceForJobSchema
|
|
147
|
-
);
|
|
148
|
-
let resp: EnforcePolicyComplianceResponse | undefined;
|
|
149
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
150
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
151
|
-
if (this.workspaceId !== undefined) {
|
|
152
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
153
|
-
}
|
|
154
|
-
headers.set('User-Agent', this.userAgent);
|
|
155
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
156
|
-
const respBody = await executeHttpCall({
|
|
157
|
-
request: httpReq,
|
|
158
|
-
httpClient: this.httpClient,
|
|
159
|
-
logger: this.logger,
|
|
160
|
-
});
|
|
161
|
-
resp = parseResponse(
|
|
162
|
-
respBody,
|
|
163
|
-
unmarshalEnforcePolicyComplianceResponseSchema
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
await executeCall(call, options);
|
|
167
|
-
if (resp === undefined) {
|
|
168
|
-
throw new Error('operation completed without a result.');
|
|
169
|
-
}
|
|
170
|
-
return resp;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Returns the policy compliance status of a job. Jobs could be out of
|
|
175
|
-
* compliance if a cluster policy they use was updated after the job was
|
|
176
|
-
* last edited and some of its job clusters no longer comply with
|
|
177
|
-
* their updated policies.
|
|
178
|
-
*/
|
|
179
|
-
async getPolicyComplianceForJob(
|
|
180
|
-
req: GetPolicyComplianceForJob,
|
|
181
|
-
options?: CallOptions
|
|
182
|
-
): Promise<GetPolicyComplianceForJobResponse> {
|
|
183
|
-
const url = `${this.host}/api/2.0/policies/jobs/get-compliance`;
|
|
184
|
-
const params = new URLSearchParams();
|
|
185
|
-
if (req.jobId !== undefined) {
|
|
186
|
-
params.append('job_id', String(req.jobId));
|
|
187
|
-
}
|
|
188
|
-
const query = params.toString();
|
|
189
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
190
|
-
let resp: GetPolicyComplianceForJobResponse | undefined;
|
|
191
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
192
|
-
const headers = new Headers();
|
|
193
|
-
if (this.workspaceId !== undefined) {
|
|
194
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
195
|
-
}
|
|
196
|
-
headers.set('User-Agent', this.userAgent);
|
|
197
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
198
|
-
const respBody = await executeHttpCall({
|
|
199
|
-
request: httpReq,
|
|
200
|
-
httpClient: this.httpClient,
|
|
201
|
-
logger: this.logger,
|
|
202
|
-
});
|
|
203
|
-
resp = parseResponse(
|
|
204
|
-
respBody,
|
|
205
|
-
unmarshalGetPolicyComplianceForJobResponseSchema
|
|
206
|
-
);
|
|
207
|
-
};
|
|
208
|
-
await executeCall(call, options);
|
|
209
|
-
if (resp === undefined) {
|
|
210
|
-
throw new Error('operation completed without a result.');
|
|
211
|
-
}
|
|
212
|
-
return resp;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Returns the policy compliance status of all jobs that use a
|
|
217
|
-
* given policy. Jobs could be out of compliance if a cluster policy they
|
|
218
|
-
* use was updated after the job was last edited and its job
|
|
219
|
-
* clusters no longer comply with the updated policy.
|
|
220
|
-
*/
|
|
221
|
-
async listJobComplianceForPolicy(
|
|
222
|
-
req: ListJobComplianceForPolicy,
|
|
223
|
-
options?: CallOptions
|
|
224
|
-
): Promise<ListJobComplianceResponse> {
|
|
225
|
-
const url = `${this.host}/api/2.0/policies/jobs/list-compliance`;
|
|
226
|
-
const params = new URLSearchParams();
|
|
227
|
-
if (req.policyId !== undefined) {
|
|
228
|
-
params.append('policy_id', req.policyId);
|
|
229
|
-
}
|
|
230
|
-
if (req.pageToken !== undefined) {
|
|
231
|
-
params.append('page_token', req.pageToken);
|
|
232
|
-
}
|
|
233
|
-
if (req.pageSize !== undefined) {
|
|
234
|
-
params.append('page_size', String(req.pageSize));
|
|
235
|
-
}
|
|
236
|
-
const query = params.toString();
|
|
237
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
238
|
-
let resp: ListJobComplianceResponse | undefined;
|
|
239
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
240
|
-
const headers = new Headers();
|
|
241
|
-
if (this.workspaceId !== undefined) {
|
|
242
|
-
headers.set('X-Databricks-Org-Id', this.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: this.httpClient,
|
|
249
|
-
logger: this.logger,
|
|
250
|
-
});
|
|
251
|
-
resp = parseResponse(respBody, unmarshalListJobComplianceResponseSchema);
|
|
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
|
-
|
|
260
|
-
async *listJobComplianceForPolicyIter(
|
|
261
|
-
req: ListJobComplianceForPolicy,
|
|
262
|
-
options?: CallOptions
|
|
263
|
-
): AsyncGenerator<ListJobComplianceForPolicy_JobCompliance> {
|
|
264
|
-
const pageReq: ListJobComplianceForPolicy = {...req};
|
|
265
|
-
for (;;) {
|
|
266
|
-
const resp = await this.listJobComplianceForPolicy(pageReq, options);
|
|
267
|
-
for (const item of resp.jobs ?? []) {
|
|
268
|
-
yield item;
|
|
269
|
-
}
|
|
270
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Cancels all active runs of a job. The runs are canceled asynchronously, so it doesn't
|
|
279
|
-
* prevent new runs from being started.
|
|
280
|
-
*/
|
|
281
|
-
async cancelAllRuns(
|
|
282
|
-
req: CancelAllRunsRequest,
|
|
283
|
-
options?: CallOptions
|
|
284
|
-
): Promise<CancelAllRunsResponse> {
|
|
285
|
-
const url = `${this.host}/api/2.2/jobs/runs/cancel-all`;
|
|
286
|
-
const body = marshalRequest(req, marshalCancelAllRunsRequestSchema);
|
|
287
|
-
let resp: CancelAllRunsResponse | undefined;
|
|
288
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
289
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
290
|
-
if (this.workspaceId !== undefined) {
|
|
291
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
292
|
-
}
|
|
293
|
-
headers.set('User-Agent', this.userAgent);
|
|
294
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
295
|
-
const respBody = await executeHttpCall({
|
|
296
|
-
request: httpReq,
|
|
297
|
-
httpClient: this.httpClient,
|
|
298
|
-
logger: this.logger,
|
|
299
|
-
});
|
|
300
|
-
resp = parseResponse(respBody, unmarshalCancelAllRunsResponseSchema);
|
|
301
|
-
};
|
|
302
|
-
await executeCall(call, options);
|
|
303
|
-
if (resp === undefined) {
|
|
304
|
-
throw new Error('operation completed without a result.');
|
|
305
|
-
}
|
|
306
|
-
return resp;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Cancels a job run or a task run. The run is canceled asynchronously, so it may still be running when
|
|
311
|
-
* this request completes.
|
|
312
|
-
*/
|
|
313
|
-
private async cancelRun(
|
|
314
|
-
req: CancelRunRequest,
|
|
315
|
-
options?: CallOptions
|
|
316
|
-
): Promise<CancelRunResponse> {
|
|
317
|
-
const url = `${this.host}/api/2.2/jobs/runs/cancel`;
|
|
318
|
-
const body = marshalRequest(req, marshalCancelRunRequestSchema);
|
|
319
|
-
let resp: CancelRunResponse | undefined;
|
|
320
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
321
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
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('POST', url, headers, callSignal, body);
|
|
327
|
-
const respBody = await executeHttpCall({
|
|
328
|
-
request: httpReq,
|
|
329
|
-
httpClient: this.httpClient,
|
|
330
|
-
logger: this.logger,
|
|
331
|
-
});
|
|
332
|
-
resp = parseResponse(respBody, unmarshalCancelRunResponseSchema);
|
|
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
|
-
|
|
341
|
-
async cancelRunWaiter(
|
|
342
|
-
req: CancelRunRequest,
|
|
343
|
-
options?: CallOptions
|
|
344
|
-
): Promise<CancelRunWaiter> {
|
|
345
|
-
await this.cancelRun(req, options);
|
|
346
|
-
if (req.runId === undefined) {
|
|
347
|
-
throw new Error('request field runId required for polling is missing');
|
|
348
|
-
}
|
|
349
|
-
return new CancelRunWaiter(this, req.runId);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/** Create a new job. */
|
|
353
|
-
async createJob(
|
|
354
|
-
req: CreateJobRequest,
|
|
355
|
-
options?: CallOptions
|
|
356
|
-
): Promise<CreateJobResponse> {
|
|
357
|
-
const url = `${this.host}/api/2.2/jobs/create`;
|
|
358
|
-
const body = marshalRequest(req, marshalCreateJobRequestSchema);
|
|
359
|
-
let resp: CreateJobResponse | undefined;
|
|
360
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
361
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
362
|
-
if (this.workspaceId !== undefined) {
|
|
363
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
364
|
-
}
|
|
365
|
-
headers.set('User-Agent', this.userAgent);
|
|
366
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
367
|
-
const respBody = await executeHttpCall({
|
|
368
|
-
request: httpReq,
|
|
369
|
-
httpClient: this.httpClient,
|
|
370
|
-
logger: this.logger,
|
|
371
|
-
});
|
|
372
|
-
resp = parseResponse(respBody, unmarshalCreateJobResponseSchema);
|
|
373
|
-
};
|
|
374
|
-
await executeCall(call, options);
|
|
375
|
-
if (resp === undefined) {
|
|
376
|
-
throw new Error('operation completed without a result.');
|
|
377
|
-
}
|
|
378
|
-
return resp;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** Deletes a job. */
|
|
382
|
-
async deleteJob(
|
|
383
|
-
req: DeleteJobRequest,
|
|
384
|
-
options?: CallOptions
|
|
385
|
-
): Promise<DeleteJobResponse> {
|
|
386
|
-
const url = `${this.host}/api/2.2/jobs/delete`;
|
|
387
|
-
const body = marshalRequest(req, marshalDeleteJobRequestSchema);
|
|
388
|
-
let resp: DeleteJobResponse | undefined;
|
|
389
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
390
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
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('POST', url, headers, callSignal, body);
|
|
396
|
-
const respBody = await executeHttpCall({
|
|
397
|
-
request: httpReq,
|
|
398
|
-
httpClient: this.httpClient,
|
|
399
|
-
logger: this.logger,
|
|
400
|
-
});
|
|
401
|
-
resp = parseResponse(respBody, unmarshalDeleteJobResponseSchema);
|
|
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
|
-
/** Deletes a non-active run. Returns an error if the run is active. */
|
|
411
|
-
async deleteRun(
|
|
412
|
-
req: DeleteRunRequest,
|
|
413
|
-
options?: CallOptions
|
|
414
|
-
): Promise<DeleteRunResponse> {
|
|
415
|
-
const url = `${this.host}/api/2.2/jobs/runs/delete`;
|
|
416
|
-
const body = marshalRequest(req, marshalDeleteRunRequestSchema);
|
|
417
|
-
let resp: DeleteRunResponse | undefined;
|
|
418
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
419
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
420
|
-
if (this.workspaceId !== undefined) {
|
|
421
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
422
|
-
}
|
|
423
|
-
headers.set('User-Agent', this.userAgent);
|
|
424
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
425
|
-
const respBody = await executeHttpCall({
|
|
426
|
-
request: httpReq,
|
|
427
|
-
httpClient: this.httpClient,
|
|
428
|
-
logger: this.logger,
|
|
429
|
-
});
|
|
430
|
-
resp = parseResponse(respBody, unmarshalDeleteRunResponseSchema);
|
|
431
|
-
};
|
|
432
|
-
await executeCall(call, options);
|
|
433
|
-
if (resp === undefined) {
|
|
434
|
-
throw new Error('operation completed without a result.');
|
|
435
|
-
}
|
|
436
|
-
return resp;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/** Export and retrieve the job run task. */
|
|
440
|
-
async exportRun(
|
|
441
|
-
req: ExportRunRequest,
|
|
442
|
-
options?: CallOptions
|
|
443
|
-
): Promise<ExportRunResponse> {
|
|
444
|
-
const url = `${this.host}/api/2.2/jobs/runs/export`;
|
|
445
|
-
const params = new URLSearchParams();
|
|
446
|
-
if (req.runId !== undefined) {
|
|
447
|
-
params.append('run_id', String(req.runId));
|
|
448
|
-
}
|
|
449
|
-
if (req.viewsToExport !== undefined) {
|
|
450
|
-
params.append('views_to_export', req.viewsToExport);
|
|
451
|
-
}
|
|
452
|
-
const query = params.toString();
|
|
453
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
454
|
-
let resp: ExportRunResponse | undefined;
|
|
455
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
456
|
-
const headers = new Headers();
|
|
457
|
-
if (this.workspaceId !== undefined) {
|
|
458
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
459
|
-
}
|
|
460
|
-
headers.set('User-Agent', this.userAgent);
|
|
461
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
462
|
-
const respBody = await executeHttpCall({
|
|
463
|
-
request: httpReq,
|
|
464
|
-
httpClient: this.httpClient,
|
|
465
|
-
logger: this.logger,
|
|
466
|
-
});
|
|
467
|
-
resp = parseResponse(respBody, unmarshalExportRunResponseSchema);
|
|
468
|
-
};
|
|
469
|
-
await executeCall(call, options);
|
|
470
|
-
if (resp === undefined) {
|
|
471
|
-
throw new Error('operation completed without a result.');
|
|
472
|
-
}
|
|
473
|
-
return resp;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Retrieves the details for a single job.
|
|
478
|
-
*
|
|
479
|
-
* Large arrays in the results will be paginated when they exceed 100 elements.
|
|
480
|
-
* A request for a single job will return all properties for that job, and the first 100 elements of array properties (`tasks`, `job_clusters`, `environments` and `parameters`).
|
|
481
|
-
* Use the `next_page_token` field to check for more results and pass its value as the `page_token` in subsequent requests.
|
|
482
|
-
* If any array properties have more than 100 elements, additional results will be returned on subsequent requests. Arrays without additional results will be empty on later pages.
|
|
483
|
-
*/
|
|
484
|
-
async getJob(
|
|
485
|
-
req: GetJobRequest,
|
|
486
|
-
options?: CallOptions
|
|
487
|
-
): Promise<GetJobResponse> {
|
|
488
|
-
const url = `${this.host}/api/2.2/jobs/get`;
|
|
489
|
-
const params = new URLSearchParams();
|
|
490
|
-
if (req.jobId !== undefined) {
|
|
491
|
-
params.append('job_id', String(req.jobId));
|
|
492
|
-
}
|
|
493
|
-
if (req.includeTriggerState !== undefined) {
|
|
494
|
-
params.append('include_trigger_state', String(req.includeTriggerState));
|
|
495
|
-
}
|
|
496
|
-
if (req.pageToken !== undefined) {
|
|
497
|
-
params.append('page_token', req.pageToken);
|
|
498
|
-
}
|
|
499
|
-
const query = params.toString();
|
|
500
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
501
|
-
let resp: GetJobResponse | undefined;
|
|
502
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
503
|
-
const headers = new Headers();
|
|
504
|
-
if (this.workspaceId !== undefined) {
|
|
505
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
506
|
-
}
|
|
507
|
-
headers.set('User-Agent', this.userAgent);
|
|
508
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
509
|
-
const respBody = await executeHttpCall({
|
|
510
|
-
request: httpReq,
|
|
511
|
-
httpClient: this.httpClient,
|
|
512
|
-
logger: this.logger,
|
|
513
|
-
});
|
|
514
|
-
resp = parseResponse(respBody, unmarshalGetJobResponseSchema);
|
|
515
|
-
};
|
|
516
|
-
await executeCall(call, options);
|
|
517
|
-
if (resp === undefined) {
|
|
518
|
-
throw new Error('operation completed without a result.');
|
|
519
|
-
}
|
|
520
|
-
return resp;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Retrieves the metadata of a run.
|
|
525
|
-
*
|
|
526
|
-
* Large arrays in the results will be paginated when they exceed 100 elements.
|
|
527
|
-
* A request for a single run will return all properties for that run, and the first 100 elements of array properties (`tasks`, `job_clusters`, `job_parameters` and `repair_history`).
|
|
528
|
-
* Use the next_page_token field to check for more results and pass its value as the page_token in subsequent requests.
|
|
529
|
-
* If any array properties have more than 100 elements, additional results will be returned on subsequent requests. Arrays without additional results will be empty on later pages.
|
|
530
|
-
*/
|
|
531
|
-
async getRun(
|
|
532
|
-
req: GetRunRequest,
|
|
533
|
-
options?: CallOptions
|
|
534
|
-
): Promise<GetRunResponse> {
|
|
535
|
-
const url = `${this.host}/api/2.2/jobs/runs/get`;
|
|
536
|
-
const params = new URLSearchParams();
|
|
537
|
-
if (req.runId !== undefined) {
|
|
538
|
-
params.append('run_id', String(req.runId));
|
|
539
|
-
}
|
|
540
|
-
if (req.includeHistory !== undefined) {
|
|
541
|
-
params.append('include_history', String(req.includeHistory));
|
|
542
|
-
}
|
|
543
|
-
if (req.includeResolvedValues !== undefined) {
|
|
544
|
-
params.append(
|
|
545
|
-
'include_resolved_values',
|
|
546
|
-
String(req.includeResolvedValues)
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
|
-
if (req.pageToken !== undefined) {
|
|
550
|
-
params.append('page_token', req.pageToken);
|
|
551
|
-
}
|
|
552
|
-
const query = params.toString();
|
|
553
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
554
|
-
let resp: GetRunResponse | undefined;
|
|
555
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
556
|
-
const headers = new Headers();
|
|
557
|
-
if (this.workspaceId !== undefined) {
|
|
558
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
559
|
-
}
|
|
560
|
-
headers.set('User-Agent', this.userAgent);
|
|
561
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
562
|
-
const respBody = await executeHttpCall({
|
|
563
|
-
request: httpReq,
|
|
564
|
-
httpClient: this.httpClient,
|
|
565
|
-
logger: this.logger,
|
|
566
|
-
});
|
|
567
|
-
resp = parseResponse(respBody, unmarshalGetRunResponseSchema);
|
|
568
|
-
};
|
|
569
|
-
await executeCall(call, options);
|
|
570
|
-
if (resp === undefined) {
|
|
571
|
-
throw new Error('operation completed without a result.');
|
|
572
|
-
}
|
|
573
|
-
return resp;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Retrieve the output and metadata of a single task run. When a notebook task returns
|
|
578
|
-
* a value through the `dbutils.notebook.exit()` call, you can use this endpoint to retrieve
|
|
579
|
-
* that value. <Databricks> restricts this API to returning the first 5 MB of the output.
|
|
580
|
-
* To return a larger result, you can store job results in a cloud storage service.
|
|
581
|
-
*
|
|
582
|
-
* This endpoint validates that the __run_id__ parameter is valid and returns an HTTP status
|
|
583
|
-
* code 400 if the __run_id__ parameter is invalid. Runs are automatically removed after
|
|
584
|
-
* 60 days. If you to want to reference them beyond 60 days, you must save old run results
|
|
585
|
-
* before they expire.
|
|
586
|
-
*/
|
|
587
|
-
async getRunOutput(
|
|
588
|
-
req: GetRunOutputRequest,
|
|
589
|
-
options?: CallOptions
|
|
590
|
-
): Promise<GetRunOutputResponse> {
|
|
591
|
-
const url = `${this.host}/api/2.2/jobs/runs/get-output`;
|
|
592
|
-
const params = new URLSearchParams();
|
|
593
|
-
if (req.runId !== undefined) {
|
|
594
|
-
params.append('run_id', String(req.runId));
|
|
595
|
-
}
|
|
596
|
-
const query = params.toString();
|
|
597
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
598
|
-
let resp: GetRunOutputResponse | undefined;
|
|
599
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
600
|
-
const headers = new Headers();
|
|
601
|
-
if (this.workspaceId !== undefined) {
|
|
602
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
603
|
-
}
|
|
604
|
-
headers.set('User-Agent', this.userAgent);
|
|
605
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
606
|
-
const respBody = await executeHttpCall({
|
|
607
|
-
request: httpReq,
|
|
608
|
-
httpClient: this.httpClient,
|
|
609
|
-
logger: this.logger,
|
|
610
|
-
});
|
|
611
|
-
resp = parseResponse(respBody, unmarshalGetRunOutputResponseSchema);
|
|
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
|
-
|
|
620
|
-
/** Retrieves a list of jobs. */
|
|
621
|
-
async listJobs(
|
|
622
|
-
req: ListJobsRequest,
|
|
623
|
-
options?: CallOptions
|
|
624
|
-
): Promise<ListJobsResponse> {
|
|
625
|
-
const url = `${this.host}/api/2.2/jobs/list`;
|
|
626
|
-
const params = new URLSearchParams();
|
|
627
|
-
if (req.offset !== undefined) {
|
|
628
|
-
params.append('offset', String(req.offset));
|
|
629
|
-
}
|
|
630
|
-
if (req.limit !== undefined) {
|
|
631
|
-
params.append('limit', String(req.limit));
|
|
632
|
-
}
|
|
633
|
-
if (req.expandTasks !== undefined) {
|
|
634
|
-
params.append('expand_tasks', String(req.expandTasks));
|
|
635
|
-
}
|
|
636
|
-
if (req.name !== undefined) {
|
|
637
|
-
params.append('name', req.name);
|
|
638
|
-
}
|
|
639
|
-
if (req.pageToken !== undefined) {
|
|
640
|
-
params.append('page_token', req.pageToken);
|
|
641
|
-
}
|
|
642
|
-
const query = params.toString();
|
|
643
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
644
|
-
let resp: ListJobsResponse | undefined;
|
|
645
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
646
|
-
const headers = new Headers();
|
|
647
|
-
if (this.workspaceId !== undefined) {
|
|
648
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
649
|
-
}
|
|
650
|
-
headers.set('User-Agent', this.userAgent);
|
|
651
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
652
|
-
const respBody = await executeHttpCall({
|
|
653
|
-
request: httpReq,
|
|
654
|
-
httpClient: this.httpClient,
|
|
655
|
-
logger: this.logger,
|
|
656
|
-
});
|
|
657
|
-
resp = parseResponse(respBody, unmarshalListJobsResponseSchema);
|
|
658
|
-
};
|
|
659
|
-
await executeCall(call, options);
|
|
660
|
-
if (resp === undefined) {
|
|
661
|
-
throw new Error('operation completed without a result.');
|
|
662
|
-
}
|
|
663
|
-
return resp;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
async *listJobsIter(
|
|
667
|
-
req: ListJobsRequest,
|
|
668
|
-
options?: CallOptions
|
|
669
|
-
): AsyncGenerator<BaseJob> {
|
|
670
|
-
const pageReq: ListJobsRequest = {...req};
|
|
671
|
-
for (;;) {
|
|
672
|
-
const resp = await this.listJobs(pageReq, options);
|
|
673
|
-
for (const item of resp.jobs ?? []) {
|
|
674
|
-
yield item;
|
|
675
|
-
}
|
|
676
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/** List runs in descending order by start time. */
|
|
684
|
-
async listRuns(
|
|
685
|
-
req: ListRunsRequest,
|
|
686
|
-
options?: CallOptions
|
|
687
|
-
): Promise<ListRunsResponse> {
|
|
688
|
-
const url = `${this.host}/api/2.2/jobs/runs/list`;
|
|
689
|
-
const params = new URLSearchParams();
|
|
690
|
-
if (req.jobId !== undefined) {
|
|
691
|
-
params.append('job_id', String(req.jobId));
|
|
692
|
-
}
|
|
693
|
-
if (req.stateConstraint?.$case === 'activeOnly') {
|
|
694
|
-
params.append('active_only', String(req.stateConstraint.activeOnly));
|
|
695
|
-
}
|
|
696
|
-
if (req.stateConstraint?.$case === 'completedOnly') {
|
|
697
|
-
params.append(
|
|
698
|
-
'completed_only',
|
|
699
|
-
String(req.stateConstraint.completedOnly)
|
|
700
|
-
);
|
|
701
|
-
}
|
|
702
|
-
if (req.offset !== undefined) {
|
|
703
|
-
params.append('offset', String(req.offset));
|
|
704
|
-
}
|
|
705
|
-
if (req.limit !== undefined) {
|
|
706
|
-
params.append('limit', String(req.limit));
|
|
707
|
-
}
|
|
708
|
-
if (req.runType !== undefined) {
|
|
709
|
-
params.append('run_type', req.runType);
|
|
710
|
-
}
|
|
711
|
-
if (req.expandTasks !== undefined) {
|
|
712
|
-
params.append('expand_tasks', String(req.expandTasks));
|
|
713
|
-
}
|
|
714
|
-
if (req.startTimeFrom !== undefined) {
|
|
715
|
-
params.append('start_time_from', String(req.startTimeFrom));
|
|
716
|
-
}
|
|
717
|
-
if (req.startTimeTo !== undefined) {
|
|
718
|
-
params.append('start_time_to', String(req.startTimeTo));
|
|
719
|
-
}
|
|
720
|
-
if (req.pageToken !== undefined) {
|
|
721
|
-
params.append('page_token', req.pageToken);
|
|
722
|
-
}
|
|
723
|
-
const query = params.toString();
|
|
724
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
725
|
-
let resp: ListRunsResponse | undefined;
|
|
726
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
727
|
-
const headers = new Headers();
|
|
728
|
-
if (this.workspaceId !== undefined) {
|
|
729
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
730
|
-
}
|
|
731
|
-
headers.set('User-Agent', this.userAgent);
|
|
732
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
733
|
-
const respBody = await executeHttpCall({
|
|
734
|
-
request: httpReq,
|
|
735
|
-
httpClient: this.httpClient,
|
|
736
|
-
logger: this.logger,
|
|
737
|
-
});
|
|
738
|
-
resp = parseResponse(respBody, unmarshalListRunsResponseSchema);
|
|
739
|
-
};
|
|
740
|
-
await executeCall(call, options);
|
|
741
|
-
if (resp === undefined) {
|
|
742
|
-
throw new Error('operation completed without a result.');
|
|
743
|
-
}
|
|
744
|
-
return resp;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
async *listRunsIter(
|
|
748
|
-
req: ListRunsRequest,
|
|
749
|
-
options?: CallOptions
|
|
750
|
-
): AsyncGenerator<BaseRun> {
|
|
751
|
-
const pageReq: ListRunsRequest = {...req};
|
|
752
|
-
for (;;) {
|
|
753
|
-
const resp = await this.listRuns(pageReq, options);
|
|
754
|
-
for (const item of resp.runs ?? []) {
|
|
755
|
-
yield item;
|
|
756
|
-
}
|
|
757
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Re-run one or more tasks. Tasks are re-run as part of the original job run.
|
|
766
|
-
* They use the current job and task settings, and can be viewed in the history for the
|
|
767
|
-
* original job run.
|
|
768
|
-
*/
|
|
769
|
-
private async repair(
|
|
770
|
-
req: RepairRunRequest,
|
|
771
|
-
options?: CallOptions
|
|
772
|
-
): Promise<RepairRunResponse> {
|
|
773
|
-
const url = `${this.host}/api/2.2/jobs/runs/repair`;
|
|
774
|
-
const body = marshalRequest(req, marshalRepairRunRequestSchema);
|
|
775
|
-
let resp: RepairRunResponse | undefined;
|
|
776
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
777
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
778
|
-
if (this.workspaceId !== undefined) {
|
|
779
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
780
|
-
}
|
|
781
|
-
headers.set('User-Agent', this.userAgent);
|
|
782
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
783
|
-
const respBody = await executeHttpCall({
|
|
784
|
-
request: httpReq,
|
|
785
|
-
httpClient: this.httpClient,
|
|
786
|
-
logger: this.logger,
|
|
787
|
-
});
|
|
788
|
-
resp = parseResponse(respBody, unmarshalRepairRunResponseSchema);
|
|
789
|
-
};
|
|
790
|
-
await executeCall(call, options);
|
|
791
|
-
if (resp === undefined) {
|
|
792
|
-
throw new Error('operation completed without a result.');
|
|
793
|
-
}
|
|
794
|
-
return resp;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
async repairWaiter(
|
|
798
|
-
req: RepairRunRequest,
|
|
799
|
-
options?: CallOptions
|
|
800
|
-
): Promise<RepairWaiter> {
|
|
801
|
-
await this.repair(req, options);
|
|
802
|
-
if (req.runId === undefined) {
|
|
803
|
-
throw new Error('request field runId required for polling is missing');
|
|
804
|
-
}
|
|
805
|
-
return new RepairWaiter(this, req.runId);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/** Overwrite all settings for the given job. Use the [_Update_ endpoint](:method:jobs/update) to update job settings partially. */
|
|
809
|
-
async resetJob(
|
|
810
|
-
req: ResetJobRequest,
|
|
811
|
-
options?: CallOptions
|
|
812
|
-
): Promise<ResetJobResponse> {
|
|
813
|
-
const url = `${this.host}/api/2.2/jobs/reset`;
|
|
814
|
-
const body = marshalRequest(req, marshalResetJobRequestSchema);
|
|
815
|
-
let resp: ResetJobResponse | undefined;
|
|
816
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
817
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
818
|
-
if (this.workspaceId !== undefined) {
|
|
819
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
820
|
-
}
|
|
821
|
-
headers.set('User-Agent', this.userAgent);
|
|
822
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
823
|
-
const respBody = await executeHttpCall({
|
|
824
|
-
request: httpReq,
|
|
825
|
-
httpClient: this.httpClient,
|
|
826
|
-
logger: this.logger,
|
|
827
|
-
});
|
|
828
|
-
resp = parseResponse(respBody, unmarshalResetJobResponseSchema);
|
|
829
|
-
};
|
|
830
|
-
await executeCall(call, options);
|
|
831
|
-
if (resp === undefined) {
|
|
832
|
-
throw new Error('operation completed without a result.');
|
|
833
|
-
}
|
|
834
|
-
return resp;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/** Run a job and return the `run_id` of the triggered run. */
|
|
838
|
-
private async runNow(
|
|
839
|
-
req: RunNowRequest,
|
|
840
|
-
options?: CallOptions
|
|
841
|
-
): Promise<RunNowResponse> {
|
|
842
|
-
const url = `${this.host}/api/2.2/jobs/run-now`;
|
|
843
|
-
const body = marshalRequest(req, marshalRunNowRequestSchema);
|
|
844
|
-
let resp: RunNowResponse | undefined;
|
|
845
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
846
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
847
|
-
if (this.workspaceId !== undefined) {
|
|
848
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
849
|
-
}
|
|
850
|
-
headers.set('User-Agent', this.userAgent);
|
|
851
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
852
|
-
const respBody = await executeHttpCall({
|
|
853
|
-
request: httpReq,
|
|
854
|
-
httpClient: this.httpClient,
|
|
855
|
-
logger: this.logger,
|
|
856
|
-
});
|
|
857
|
-
resp = parseResponse(respBody, unmarshalRunNowResponseSchema);
|
|
858
|
-
};
|
|
859
|
-
await executeCall(call, options);
|
|
860
|
-
if (resp === undefined) {
|
|
861
|
-
throw new Error('operation completed without a result.');
|
|
862
|
-
}
|
|
863
|
-
return resp;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
async runNowWaiter(
|
|
867
|
-
req: RunNowRequest,
|
|
868
|
-
options?: CallOptions
|
|
869
|
-
): Promise<RunNowWaiter> {
|
|
870
|
-
const resp = await this.runNow(req, options);
|
|
871
|
-
if (resp.runId === undefined) {
|
|
872
|
-
throw new Error('response field runId required for polling is missing');
|
|
873
|
-
}
|
|
874
|
-
return new RunNowWaiter(this, resp.runId);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* Submit a one-time run. This endpoint allows you to submit a workload directly
|
|
879
|
-
* without creating a job. Runs submitted using this endpoint don’t display in
|
|
880
|
-
* the UI. Use the `jobs/runs/get` API to check the run state after the job is
|
|
881
|
-
* submitted.
|
|
882
|
-
*
|
|
883
|
-
* **Important:** Jobs submitted using this endpoint are not saved as a job.
|
|
884
|
-
* They do not show up in the Jobs UI, and do not retry when they fail. Because
|
|
885
|
-
* they are not saved, <Databricks> cannot auto-optimize serverless compute in case
|
|
886
|
-
* of failure. If your job fails, you may want to use classic compute to specify
|
|
887
|
-
* the compute needs for the job. Alternatively, use the `POST /jobs/create` and
|
|
888
|
-
* `POST /jobs/run-now` endpoints to create and run a saved job.
|
|
889
|
-
*/
|
|
890
|
-
private async submitRun(
|
|
891
|
-
req: SubmitRunRequest,
|
|
892
|
-
options?: CallOptions
|
|
893
|
-
): Promise<SubmitRunResponse> {
|
|
894
|
-
const url = `${this.host}/api/2.2/jobs/runs/submit`;
|
|
895
|
-
const body = marshalRequest(req, marshalSubmitRunRequestSchema);
|
|
896
|
-
let resp: SubmitRunResponse | undefined;
|
|
897
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
898
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
899
|
-
if (this.workspaceId !== undefined) {
|
|
900
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
901
|
-
}
|
|
902
|
-
headers.set('User-Agent', this.userAgent);
|
|
903
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
904
|
-
const respBody = await executeHttpCall({
|
|
905
|
-
request: httpReq,
|
|
906
|
-
httpClient: this.httpClient,
|
|
907
|
-
logger: this.logger,
|
|
908
|
-
});
|
|
909
|
-
resp = parseResponse(respBody, unmarshalSubmitRunResponseSchema);
|
|
910
|
-
};
|
|
911
|
-
await executeCall(call, options);
|
|
912
|
-
if (resp === undefined) {
|
|
913
|
-
throw new Error('operation completed without a result.');
|
|
914
|
-
}
|
|
915
|
-
return resp;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
async submitRunWaiter(
|
|
919
|
-
req: SubmitRunRequest,
|
|
920
|
-
options?: CallOptions
|
|
921
|
-
): Promise<SubmitRunWaiter> {
|
|
922
|
-
const resp = await this.submitRun(req, options);
|
|
923
|
-
if (resp.runId === undefined) {
|
|
924
|
-
throw new Error('response field runId required for polling is missing');
|
|
925
|
-
}
|
|
926
|
-
return new SubmitRunWaiter(this, resp.runId);
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
/** Add, update, or remove specific settings of an existing job. Use the [_Reset_ endpoint](:method:jobs/reset) to overwrite all job settings. */
|
|
930
|
-
async updateJob(
|
|
931
|
-
req: UpdateJobRequest,
|
|
932
|
-
options?: CallOptions
|
|
933
|
-
): Promise<UpdateJobResponse> {
|
|
934
|
-
const url = `${this.host}/api/2.2/jobs/update`;
|
|
935
|
-
const body = marshalRequest(req, marshalUpdateJobRequestSchema);
|
|
936
|
-
let resp: UpdateJobResponse | undefined;
|
|
937
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
938
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
939
|
-
if (this.workspaceId !== undefined) {
|
|
940
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
941
|
-
}
|
|
942
|
-
headers.set('User-Agent', this.userAgent);
|
|
943
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
944
|
-
const respBody = await executeHttpCall({
|
|
945
|
-
request: httpReq,
|
|
946
|
-
httpClient: this.httpClient,
|
|
947
|
-
logger: this.logger,
|
|
948
|
-
});
|
|
949
|
-
resp = parseResponse(respBody, unmarshalUpdateJobResponseSchema);
|
|
950
|
-
};
|
|
951
|
-
await executeCall(call, options);
|
|
952
|
-
if (resp === undefined) {
|
|
953
|
-
throw new Error('operation completed without a result.');
|
|
954
|
-
}
|
|
955
|
-
return resp;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
export class CancelRunWaiter {
|
|
960
|
-
constructor(
|
|
961
|
-
private readonly client: JobsClient,
|
|
962
|
-
readonly runId: bigint
|
|
963
|
-
) {}
|
|
964
|
-
|
|
965
|
-
/**
|
|
966
|
-
* Polls until the operation reaches a terminal state.
|
|
967
|
-
*
|
|
968
|
-
* Throws if a failure state is reached.
|
|
969
|
-
*/
|
|
970
|
-
async wait(options?: LroOptions): Promise<GetRunResponse> {
|
|
971
|
-
let result: GetRunResponse | undefined;
|
|
972
|
-
|
|
973
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
974
|
-
const pollResp = await this.client.getRun(
|
|
975
|
-
{
|
|
976
|
-
runId: this.runId,
|
|
977
|
-
},
|
|
978
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
979
|
-
);
|
|
980
|
-
|
|
981
|
-
const status = pollResp.state?.lifeCycleState;
|
|
982
|
-
if (status === undefined) {
|
|
983
|
-
throw new Error('response missing required status field');
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
switch (status) {
|
|
987
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
988
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
989
|
-
result = pollResp;
|
|
990
|
-
return;
|
|
991
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR: {
|
|
992
|
-
const msg = pollResp.state?.stateMessage ?? '(no message)';
|
|
993
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
994
|
-
}
|
|
995
|
-
default:
|
|
996
|
-
throw new StillRunningError();
|
|
997
|
-
}
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
await executeWait(call, options);
|
|
1001
|
-
if (result === undefined) {
|
|
1002
|
-
throw new Error('operation completed without a result.');
|
|
1003
|
-
}
|
|
1004
|
-
return result;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
1008
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
1009
|
-
const pollResp = await this.client.getRun(
|
|
1010
|
-
{
|
|
1011
|
-
runId: this.runId,
|
|
1012
|
-
},
|
|
1013
|
-
options
|
|
1014
|
-
);
|
|
1015
|
-
|
|
1016
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1017
|
-
if (status === undefined) {
|
|
1018
|
-
throw new Error('response missing required status field');
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
switch (status) {
|
|
1022
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1023
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1024
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR:
|
|
1025
|
-
return true;
|
|
1026
|
-
default:
|
|
1027
|
-
return false;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
export class RepairWaiter {
|
|
1033
|
-
constructor(
|
|
1034
|
-
private readonly client: JobsClient,
|
|
1035
|
-
readonly runId: bigint
|
|
1036
|
-
) {}
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Polls until the operation reaches a terminal state.
|
|
1040
|
-
*
|
|
1041
|
-
* Throws if a failure state is reached.
|
|
1042
|
-
*/
|
|
1043
|
-
async wait(options?: LroOptions): Promise<GetRunResponse> {
|
|
1044
|
-
let result: GetRunResponse | undefined;
|
|
1045
|
-
|
|
1046
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
1047
|
-
const pollResp = await this.client.getRun(
|
|
1048
|
-
{
|
|
1049
|
-
runId: this.runId,
|
|
1050
|
-
},
|
|
1051
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
1052
|
-
);
|
|
1053
|
-
|
|
1054
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1055
|
-
if (status === undefined) {
|
|
1056
|
-
throw new Error('response missing required status field');
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
switch (status) {
|
|
1060
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1061
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1062
|
-
result = pollResp;
|
|
1063
|
-
return;
|
|
1064
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR: {
|
|
1065
|
-
const msg = pollResp.state?.stateMessage ?? '(no message)';
|
|
1066
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
1067
|
-
}
|
|
1068
|
-
default:
|
|
1069
|
-
throw new StillRunningError();
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
await executeWait(call, options);
|
|
1074
|
-
if (result === undefined) {
|
|
1075
|
-
throw new Error('operation completed without a result.');
|
|
1076
|
-
}
|
|
1077
|
-
return result;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
1081
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
1082
|
-
const pollResp = await this.client.getRun(
|
|
1083
|
-
{
|
|
1084
|
-
runId: this.runId,
|
|
1085
|
-
},
|
|
1086
|
-
options
|
|
1087
|
-
);
|
|
1088
|
-
|
|
1089
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1090
|
-
if (status === undefined) {
|
|
1091
|
-
throw new Error('response missing required status field');
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
switch (status) {
|
|
1095
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1096
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1097
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR:
|
|
1098
|
-
return true;
|
|
1099
|
-
default:
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
export class RunNowWaiter {
|
|
1106
|
-
constructor(
|
|
1107
|
-
private readonly client: JobsClient,
|
|
1108
|
-
readonly runId: bigint
|
|
1109
|
-
) {}
|
|
1110
|
-
|
|
1111
|
-
/**
|
|
1112
|
-
* Polls until the operation reaches a terminal state.
|
|
1113
|
-
*
|
|
1114
|
-
* Throws if a failure state is reached.
|
|
1115
|
-
*/
|
|
1116
|
-
async wait(options?: LroOptions): Promise<GetRunResponse> {
|
|
1117
|
-
let result: GetRunResponse | undefined;
|
|
1118
|
-
|
|
1119
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
1120
|
-
const pollResp = await this.client.getRun(
|
|
1121
|
-
{
|
|
1122
|
-
runId: this.runId,
|
|
1123
|
-
},
|
|
1124
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
1125
|
-
);
|
|
1126
|
-
|
|
1127
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1128
|
-
if (status === undefined) {
|
|
1129
|
-
throw new Error('response missing required status field');
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
switch (status) {
|
|
1133
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1134
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1135
|
-
result = pollResp;
|
|
1136
|
-
return;
|
|
1137
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR: {
|
|
1138
|
-
const msg = pollResp.state?.stateMessage ?? '(no message)';
|
|
1139
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
1140
|
-
}
|
|
1141
|
-
default:
|
|
1142
|
-
throw new StillRunningError();
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
await executeWait(call, options);
|
|
1147
|
-
if (result === undefined) {
|
|
1148
|
-
throw new Error('operation completed without a result.');
|
|
1149
|
-
}
|
|
1150
|
-
return result;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
1154
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
1155
|
-
const pollResp = await this.client.getRun(
|
|
1156
|
-
{
|
|
1157
|
-
runId: this.runId,
|
|
1158
|
-
},
|
|
1159
|
-
options
|
|
1160
|
-
);
|
|
1161
|
-
|
|
1162
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1163
|
-
if (status === undefined) {
|
|
1164
|
-
throw new Error('response missing required status field');
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
switch (status) {
|
|
1168
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1169
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1170
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR:
|
|
1171
|
-
return true;
|
|
1172
|
-
default:
|
|
1173
|
-
return false;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
export class SubmitRunWaiter {
|
|
1179
|
-
constructor(
|
|
1180
|
-
private readonly client: JobsClient,
|
|
1181
|
-
readonly runId: bigint
|
|
1182
|
-
) {}
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
* Polls until the operation reaches a terminal state.
|
|
1186
|
-
*
|
|
1187
|
-
* Throws if a failure state is reached.
|
|
1188
|
-
*/
|
|
1189
|
-
async wait(options?: LroOptions): Promise<GetRunResponse> {
|
|
1190
|
-
let result: GetRunResponse | undefined;
|
|
1191
|
-
|
|
1192
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
1193
|
-
const pollResp = await this.client.getRun(
|
|
1194
|
-
{
|
|
1195
|
-
runId: this.runId,
|
|
1196
|
-
},
|
|
1197
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
1198
|
-
);
|
|
1199
|
-
|
|
1200
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1201
|
-
if (status === undefined) {
|
|
1202
|
-
throw new Error('response missing required status field');
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
switch (status) {
|
|
1206
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1207
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1208
|
-
result = pollResp;
|
|
1209
|
-
return;
|
|
1210
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR: {
|
|
1211
|
-
const msg = pollResp.state?.stateMessage ?? '(no message)';
|
|
1212
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
1213
|
-
}
|
|
1214
|
-
default:
|
|
1215
|
-
throw new StillRunningError();
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
|
|
1219
|
-
await executeWait(call, options);
|
|
1220
|
-
if (result === undefined) {
|
|
1221
|
-
throw new Error('operation completed without a result.');
|
|
1222
|
-
}
|
|
1223
|
-
return result;
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
1227
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
1228
|
-
const pollResp = await this.client.getRun(
|
|
1229
|
-
{
|
|
1230
|
-
runId: this.runId,
|
|
1231
|
-
},
|
|
1232
|
-
options
|
|
1233
|
-
);
|
|
1234
|
-
|
|
1235
|
-
const status = pollResp.state?.lifeCycleState;
|
|
1236
|
-
if (status === undefined) {
|
|
1237
|
-
throw new Error('response missing required status field');
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
switch (status) {
|
|
1241
|
-
case RunLifeCycleState_RunLifeCycleState.TERMINATED:
|
|
1242
|
-
case RunLifeCycleState_RunLifeCycleState.SKIPPED:
|
|
1243
|
-
case RunLifeCycleState_RunLifeCycleState.INTERNAL_ERROR:
|
|
1244
|
-
return true;
|
|
1245
|
-
default:
|
|
1246
|
-
return false;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|