@databricks/sdk-jobs 0.1.0-dev.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/v2/client.d.ts +36 -13
- package/dist/v2/client.d.ts.map +1 -1
- package/dist/v2/client.js +141 -101
- 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 +1 -219
- package/dist/v2/model.d.ts.map +1 -1
- 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/package.json +9 -4
package/dist/v2/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
3
|
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
4
4
|
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
5
|
-
import {
|
|
5
|
+
import { resolveClientConfig } from './transport';
|
|
6
6
|
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, executeWait, StillRunningError, } from './utils';
|
|
7
7
|
import pkgJson from '../../package.json' with { type: 'json' };
|
|
8
8
|
import { RunLifeCycleState_RunLifeCycleState, marshalCancelAllRunsRequestSchema, marshalCancelRunRequestSchema, marshalCreateJobRequestSchema, marshalDeleteJobRequestSchema, marshalDeleteRunRequestSchema, marshalEnforcePolicyComplianceForJobSchema, marshalRepairRunRequestSchema, marshalResetJobRequestSchema, marshalRunNowRequestSchema, marshalSubmitRunRequestSchema, marshalUpdateJobRequestSchema, unmarshalCancelAllRunsResponseSchema, unmarshalCancelRunResponseSchema, unmarshalCreateJobResponseSchema, unmarshalDeleteJobResponseSchema, unmarshalDeleteRunResponseSchema, unmarshalEnforcePolicyComplianceResponseSchema, unmarshalExportRunResponseSchema, unmarshalGetJobResponseSchema, unmarshalGetPolicyComplianceForJobResponseSchema, unmarshalGetRunOutputResponseSchema, unmarshalGetRunResponseSchema, unmarshalListJobComplianceResponseSchema, unmarshalListJobsResponseSchema, unmarshalListRunsResponseSchema, unmarshalRepairRunResponseSchema, unmarshalResetJobResponseSchema, unmarshalRunNowResponseSchema, unmarshalSubmitRunResponseSchema, unmarshalUpdateJobResponseSchema, } from './model';
|
|
@@ -12,30 +12,28 @@ const PACKAGE_SEGMENT = {
|
|
|
12
12
|
value: pkgJson.version,
|
|
13
13
|
};
|
|
14
14
|
export class JobsClient {
|
|
15
|
-
|
|
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;
|
|
15
|
+
options;
|
|
21
16
|
logger;
|
|
22
17
|
// User-Agent header value. Composed once at construction from
|
|
23
18
|
// createDefault() merged with this package's identity and the active
|
|
24
19
|
// credential's name.
|
|
25
20
|
userAgent;
|
|
21
|
+
// Memoized configuration. The profile is resolved once, lazily, on the first
|
|
22
|
+
// request, then reused; host, workspaceId/accountId, and credentials are
|
|
23
|
+
// filled from it when not set explicitly on the options.
|
|
24
|
+
config;
|
|
26
25
|
constructor(options) {
|
|
27
|
-
|
|
28
|
-
throw new Error('Host is required.');
|
|
29
|
-
}
|
|
30
|
-
this.host = options.host.replace(/\/$/, '');
|
|
31
|
-
this.workspaceId = options.workspaceId;
|
|
26
|
+
this.options = options;
|
|
32
27
|
this.logger = options.logger ?? new NoOpLogger();
|
|
33
28
|
const info = createDefault()
|
|
34
29
|
.with(PACKAGE_SEGMENT)
|
|
35
30
|
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
36
31
|
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
37
32
|
this.userAgent = info.toString();
|
|
38
|
-
|
|
33
|
+
}
|
|
34
|
+
resolveConfig() {
|
|
35
|
+
this.config ??= resolveClientConfig(this.options);
|
|
36
|
+
return this.config;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* Updates a job so the job clusters that are created when running
|
|
@@ -44,19 +42,20 @@ export class JobsClient {
|
|
|
44
42
|
* All-purpose clusters used in the job will not be updated.
|
|
45
43
|
*/
|
|
46
44
|
async enforcePolicyComplianceForJob(req, options) {
|
|
47
|
-
const
|
|
45
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
46
|
+
const url = `${host}/api/2.0/policies/jobs/enforce-compliance`;
|
|
48
47
|
const body = marshalRequest(req, marshalEnforcePolicyComplianceForJobSchema);
|
|
49
48
|
let resp;
|
|
50
49
|
const call = async (callSignal) => {
|
|
51
50
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
52
|
-
if (
|
|
53
|
-
headers.set('X-Databricks-Org-Id',
|
|
51
|
+
if (workspaceId !== undefined) {
|
|
52
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
54
53
|
}
|
|
55
54
|
headers.set('User-Agent', this.userAgent);
|
|
56
55
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
57
56
|
const respBody = await executeHttpCall({
|
|
58
57
|
request: httpReq,
|
|
59
|
-
httpClient
|
|
58
|
+
httpClient,
|
|
60
59
|
logger: this.logger,
|
|
61
60
|
});
|
|
62
61
|
resp = parseResponse(respBody, unmarshalEnforcePolicyComplianceResponseSchema);
|
|
@@ -74,7 +73,8 @@ export class JobsClient {
|
|
|
74
73
|
* their updated policies.
|
|
75
74
|
*/
|
|
76
75
|
async getPolicyComplianceForJob(req, options) {
|
|
77
|
-
const
|
|
76
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
77
|
+
const url = `${host}/api/2.0/policies/jobs/get-compliance`;
|
|
78
78
|
const params = new URLSearchParams();
|
|
79
79
|
if (req.jobId !== undefined) {
|
|
80
80
|
params.append('job_id', String(req.jobId));
|
|
@@ -84,14 +84,14 @@ export class JobsClient {
|
|
|
84
84
|
let resp;
|
|
85
85
|
const call = async (callSignal) => {
|
|
86
86
|
const headers = new Headers();
|
|
87
|
-
if (
|
|
88
|
-
headers.set('X-Databricks-Org-Id',
|
|
87
|
+
if (workspaceId !== undefined) {
|
|
88
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
89
89
|
}
|
|
90
90
|
headers.set('User-Agent', this.userAgent);
|
|
91
91
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
92
92
|
const respBody = await executeHttpCall({
|
|
93
93
|
request: httpReq,
|
|
94
|
-
httpClient
|
|
94
|
+
httpClient,
|
|
95
95
|
logger: this.logger,
|
|
96
96
|
});
|
|
97
97
|
resp = parseResponse(respBody, unmarshalGetPolicyComplianceForJobResponseSchema);
|
|
@@ -109,7 +109,8 @@ export class JobsClient {
|
|
|
109
109
|
* clusters no longer comply with the updated policy.
|
|
110
110
|
*/
|
|
111
111
|
async listJobComplianceForPolicy(req, options) {
|
|
112
|
-
const
|
|
112
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
113
|
+
const url = `${host}/api/2.0/policies/jobs/list-compliance`;
|
|
113
114
|
const params = new URLSearchParams();
|
|
114
115
|
if (req.policyId !== undefined) {
|
|
115
116
|
params.append('policy_id', req.policyId);
|
|
@@ -125,14 +126,14 @@ export class JobsClient {
|
|
|
125
126
|
let resp;
|
|
126
127
|
const call = async (callSignal) => {
|
|
127
128
|
const headers = new Headers();
|
|
128
|
-
if (
|
|
129
|
-
headers.set('X-Databricks-Org-Id',
|
|
129
|
+
if (workspaceId !== undefined) {
|
|
130
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
130
131
|
}
|
|
131
132
|
headers.set('User-Agent', this.userAgent);
|
|
132
133
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
133
134
|
const respBody = await executeHttpCall({
|
|
134
135
|
request: httpReq,
|
|
135
|
-
httpClient
|
|
136
|
+
httpClient,
|
|
136
137
|
logger: this.logger,
|
|
137
138
|
});
|
|
138
139
|
resp = parseResponse(respBody, unmarshalListJobComplianceResponseSchema);
|
|
@@ -161,19 +162,20 @@ export class JobsClient {
|
|
|
161
162
|
* prevent new runs from being started.
|
|
162
163
|
*/
|
|
163
164
|
async cancelAllRuns(req, options) {
|
|
164
|
-
const
|
|
165
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
166
|
+
const url = `${host}/api/2.0/jobs/runs/cancel-all`;
|
|
165
167
|
const body = marshalRequest(req, marshalCancelAllRunsRequestSchema);
|
|
166
168
|
let resp;
|
|
167
169
|
const call = async (callSignal) => {
|
|
168
170
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
169
|
-
if (
|
|
170
|
-
headers.set('X-Databricks-Org-Id',
|
|
171
|
+
if (workspaceId !== undefined) {
|
|
172
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
171
173
|
}
|
|
172
174
|
headers.set('User-Agent', this.userAgent);
|
|
173
175
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
174
176
|
const respBody = await executeHttpCall({
|
|
175
177
|
request: httpReq,
|
|
176
|
-
httpClient
|
|
178
|
+
httpClient,
|
|
177
179
|
logger: this.logger,
|
|
178
180
|
});
|
|
179
181
|
resp = parseResponse(respBody, unmarshalCancelAllRunsResponseSchema);
|
|
@@ -188,20 +190,21 @@ export class JobsClient {
|
|
|
188
190
|
* Cancels a job run or a task run. The run is canceled asynchronously, so it may still be running when
|
|
189
191
|
* this request completes.
|
|
190
192
|
*/
|
|
191
|
-
async
|
|
192
|
-
const
|
|
193
|
+
async cancelRunBase(req, options) {
|
|
194
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
195
|
+
const url = `${host}/api/2.0/jobs/runs/cancel`;
|
|
193
196
|
const body = marshalRequest(req, marshalCancelRunRequestSchema);
|
|
194
197
|
let resp;
|
|
195
198
|
const call = async (callSignal) => {
|
|
196
199
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
197
|
-
if (
|
|
198
|
-
headers.set('X-Databricks-Org-Id',
|
|
200
|
+
if (workspaceId !== undefined) {
|
|
201
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
199
202
|
}
|
|
200
203
|
headers.set('User-Agent', this.userAgent);
|
|
201
204
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
202
205
|
const respBody = await executeHttpCall({
|
|
203
206
|
request: httpReq,
|
|
204
|
-
httpClient
|
|
207
|
+
httpClient,
|
|
205
208
|
logger: this.logger,
|
|
206
209
|
});
|
|
207
210
|
resp = parseResponse(respBody, unmarshalCancelRunResponseSchema);
|
|
@@ -212,8 +215,12 @@ export class JobsClient {
|
|
|
212
215
|
}
|
|
213
216
|
return resp;
|
|
214
217
|
}
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
/**
|
|
219
|
+
* Cancels a job run or a task run. The run is canceled asynchronously, so it may still be running when
|
|
220
|
+
* this request completes.
|
|
221
|
+
*/
|
|
222
|
+
async cancelRun(req, options) {
|
|
223
|
+
await this.cancelRunBase(req, options);
|
|
217
224
|
if (req.runId === undefined) {
|
|
218
225
|
throw new Error('request field runId required for polling is missing');
|
|
219
226
|
}
|
|
@@ -221,19 +228,20 @@ export class JobsClient {
|
|
|
221
228
|
}
|
|
222
229
|
/** Create a new job. */
|
|
223
230
|
async createJob(req, options) {
|
|
224
|
-
const
|
|
231
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
232
|
+
const url = `${host}/api/2.0/jobs/create`;
|
|
225
233
|
const body = marshalRequest(req, marshalCreateJobRequestSchema);
|
|
226
234
|
let resp;
|
|
227
235
|
const call = async (callSignal) => {
|
|
228
236
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
229
|
-
if (
|
|
230
|
-
headers.set('X-Databricks-Org-Id',
|
|
237
|
+
if (workspaceId !== undefined) {
|
|
238
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
231
239
|
}
|
|
232
240
|
headers.set('User-Agent', this.userAgent);
|
|
233
241
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
234
242
|
const respBody = await executeHttpCall({
|
|
235
243
|
request: httpReq,
|
|
236
|
-
httpClient
|
|
244
|
+
httpClient,
|
|
237
245
|
logger: this.logger,
|
|
238
246
|
});
|
|
239
247
|
resp = parseResponse(respBody, unmarshalCreateJobResponseSchema);
|
|
@@ -246,19 +254,20 @@ export class JobsClient {
|
|
|
246
254
|
}
|
|
247
255
|
/** Deletes a job. */
|
|
248
256
|
async deleteJob(req, options) {
|
|
249
|
-
const
|
|
257
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
258
|
+
const url = `${host}/api/2.0/jobs/delete`;
|
|
250
259
|
const body = marshalRequest(req, marshalDeleteJobRequestSchema);
|
|
251
260
|
let resp;
|
|
252
261
|
const call = async (callSignal) => {
|
|
253
262
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
254
|
-
if (
|
|
255
|
-
headers.set('X-Databricks-Org-Id',
|
|
263
|
+
if (workspaceId !== undefined) {
|
|
264
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
256
265
|
}
|
|
257
266
|
headers.set('User-Agent', this.userAgent);
|
|
258
267
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
259
268
|
const respBody = await executeHttpCall({
|
|
260
269
|
request: httpReq,
|
|
261
|
-
httpClient
|
|
270
|
+
httpClient,
|
|
262
271
|
logger: this.logger,
|
|
263
272
|
});
|
|
264
273
|
resp = parseResponse(respBody, unmarshalDeleteJobResponseSchema);
|
|
@@ -271,19 +280,20 @@ export class JobsClient {
|
|
|
271
280
|
}
|
|
272
281
|
/** Deletes a non-active run. Returns an error if the run is active. */
|
|
273
282
|
async deleteRun(req, options) {
|
|
274
|
-
const
|
|
283
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
284
|
+
const url = `${host}/api/2.0/jobs/runs/delete`;
|
|
275
285
|
const body = marshalRequest(req, marshalDeleteRunRequestSchema);
|
|
276
286
|
let resp;
|
|
277
287
|
const call = async (callSignal) => {
|
|
278
288
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
279
|
-
if (
|
|
280
|
-
headers.set('X-Databricks-Org-Id',
|
|
289
|
+
if (workspaceId !== undefined) {
|
|
290
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
281
291
|
}
|
|
282
292
|
headers.set('User-Agent', this.userAgent);
|
|
283
293
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
284
294
|
const respBody = await executeHttpCall({
|
|
285
295
|
request: httpReq,
|
|
286
|
-
httpClient
|
|
296
|
+
httpClient,
|
|
287
297
|
logger: this.logger,
|
|
288
298
|
});
|
|
289
299
|
resp = parseResponse(respBody, unmarshalDeleteRunResponseSchema);
|
|
@@ -296,7 +306,8 @@ export class JobsClient {
|
|
|
296
306
|
}
|
|
297
307
|
/** Export and retrieve the job run task. */
|
|
298
308
|
async exportRun(req, options) {
|
|
299
|
-
const
|
|
309
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
310
|
+
const url = `${host}/api/2.2/jobs/runs/export`;
|
|
300
311
|
const params = new URLSearchParams();
|
|
301
312
|
if (req.runId !== undefined) {
|
|
302
313
|
params.append('run_id', String(req.runId));
|
|
@@ -309,14 +320,14 @@ export class JobsClient {
|
|
|
309
320
|
let resp;
|
|
310
321
|
const call = async (callSignal) => {
|
|
311
322
|
const headers = new Headers();
|
|
312
|
-
if (
|
|
313
|
-
headers.set('X-Databricks-Org-Id',
|
|
323
|
+
if (workspaceId !== undefined) {
|
|
324
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
314
325
|
}
|
|
315
326
|
headers.set('User-Agent', this.userAgent);
|
|
316
327
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
317
328
|
const respBody = await executeHttpCall({
|
|
318
329
|
request: httpReq,
|
|
319
|
-
httpClient
|
|
330
|
+
httpClient,
|
|
320
331
|
logger: this.logger,
|
|
321
332
|
});
|
|
322
333
|
resp = parseResponse(respBody, unmarshalExportRunResponseSchema);
|
|
@@ -336,7 +347,8 @@ export class JobsClient {
|
|
|
336
347
|
* 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.
|
|
337
348
|
*/
|
|
338
349
|
async getJob(req, options) {
|
|
339
|
-
const
|
|
350
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
351
|
+
const url = `${host}/api/2.2/jobs/get`;
|
|
340
352
|
const params = new URLSearchParams();
|
|
341
353
|
if (req.jobId !== undefined) {
|
|
342
354
|
params.append('job_id', String(req.jobId));
|
|
@@ -352,14 +364,14 @@ export class JobsClient {
|
|
|
352
364
|
let resp;
|
|
353
365
|
const call = async (callSignal) => {
|
|
354
366
|
const headers = new Headers();
|
|
355
|
-
if (
|
|
356
|
-
headers.set('X-Databricks-Org-Id',
|
|
367
|
+
if (workspaceId !== undefined) {
|
|
368
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
357
369
|
}
|
|
358
370
|
headers.set('User-Agent', this.userAgent);
|
|
359
371
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
360
372
|
const respBody = await executeHttpCall({
|
|
361
373
|
request: httpReq,
|
|
362
|
-
httpClient
|
|
374
|
+
httpClient,
|
|
363
375
|
logger: this.logger,
|
|
364
376
|
});
|
|
365
377
|
resp = parseResponse(respBody, unmarshalGetJobResponseSchema);
|
|
@@ -379,7 +391,8 @@ export class JobsClient {
|
|
|
379
391
|
* 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.
|
|
380
392
|
*/
|
|
381
393
|
async getRun(req, options) {
|
|
382
|
-
const
|
|
394
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
395
|
+
const url = `${host}/api/2.2/jobs/runs/get`;
|
|
383
396
|
const params = new URLSearchParams();
|
|
384
397
|
if (req.runId !== undefined) {
|
|
385
398
|
params.append('run_id', String(req.runId));
|
|
@@ -398,14 +411,14 @@ export class JobsClient {
|
|
|
398
411
|
let resp;
|
|
399
412
|
const call = async (callSignal) => {
|
|
400
413
|
const headers = new Headers();
|
|
401
|
-
if (
|
|
402
|
-
headers.set('X-Databricks-Org-Id',
|
|
414
|
+
if (workspaceId !== undefined) {
|
|
415
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
403
416
|
}
|
|
404
417
|
headers.set('User-Agent', this.userAgent);
|
|
405
418
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
406
419
|
const respBody = await executeHttpCall({
|
|
407
420
|
request: httpReq,
|
|
408
|
-
httpClient
|
|
421
|
+
httpClient,
|
|
409
422
|
logger: this.logger,
|
|
410
423
|
});
|
|
411
424
|
resp = parseResponse(respBody, unmarshalGetRunResponseSchema);
|
|
@@ -428,7 +441,8 @@ export class JobsClient {
|
|
|
428
441
|
* before they expire.
|
|
429
442
|
*/
|
|
430
443
|
async getRunOutput(req, options) {
|
|
431
|
-
const
|
|
444
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
445
|
+
const url = `${host}/api/2.2/jobs/runs/get-output`;
|
|
432
446
|
const params = new URLSearchParams();
|
|
433
447
|
if (req.runId !== undefined) {
|
|
434
448
|
params.append('run_id', String(req.runId));
|
|
@@ -438,14 +452,14 @@ export class JobsClient {
|
|
|
438
452
|
let resp;
|
|
439
453
|
const call = async (callSignal) => {
|
|
440
454
|
const headers = new Headers();
|
|
441
|
-
if (
|
|
442
|
-
headers.set('X-Databricks-Org-Id',
|
|
455
|
+
if (workspaceId !== undefined) {
|
|
456
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
443
457
|
}
|
|
444
458
|
headers.set('User-Agent', this.userAgent);
|
|
445
459
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
446
460
|
const respBody = await executeHttpCall({
|
|
447
461
|
request: httpReq,
|
|
448
|
-
httpClient
|
|
462
|
+
httpClient,
|
|
449
463
|
logger: this.logger,
|
|
450
464
|
});
|
|
451
465
|
resp = parseResponse(respBody, unmarshalGetRunOutputResponseSchema);
|
|
@@ -458,7 +472,8 @@ export class JobsClient {
|
|
|
458
472
|
}
|
|
459
473
|
/** Retrieves a list of jobs. */
|
|
460
474
|
async listJobs(req, options) {
|
|
461
|
-
const
|
|
475
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
476
|
+
const url = `${host}/api/2.2/jobs/list`;
|
|
462
477
|
const params = new URLSearchParams();
|
|
463
478
|
if (req.offset !== undefined) {
|
|
464
479
|
params.append('offset', String(req.offset));
|
|
@@ -480,14 +495,14 @@ export class JobsClient {
|
|
|
480
495
|
let resp;
|
|
481
496
|
const call = async (callSignal) => {
|
|
482
497
|
const headers = new Headers();
|
|
483
|
-
if (
|
|
484
|
-
headers.set('X-Databricks-Org-Id',
|
|
498
|
+
if (workspaceId !== undefined) {
|
|
499
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
485
500
|
}
|
|
486
501
|
headers.set('User-Agent', this.userAgent);
|
|
487
502
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
488
503
|
const respBody = await executeHttpCall({
|
|
489
504
|
request: httpReq,
|
|
490
|
-
httpClient
|
|
505
|
+
httpClient,
|
|
491
506
|
logger: this.logger,
|
|
492
507
|
});
|
|
493
508
|
resp = parseResponse(respBody, unmarshalListJobsResponseSchema);
|
|
@@ -513,7 +528,8 @@ export class JobsClient {
|
|
|
513
528
|
}
|
|
514
529
|
/** List runs in descending order by start time. */
|
|
515
530
|
async listRuns(req, options) {
|
|
516
|
-
const
|
|
531
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
532
|
+
const url = `${host}/api/2.2/jobs/runs/list`;
|
|
517
533
|
const params = new URLSearchParams();
|
|
518
534
|
if (req.jobId !== undefined) {
|
|
519
535
|
params.append('job_id', String(req.jobId));
|
|
@@ -550,14 +566,14 @@ export class JobsClient {
|
|
|
550
566
|
let resp;
|
|
551
567
|
const call = async (callSignal) => {
|
|
552
568
|
const headers = new Headers();
|
|
553
|
-
if (
|
|
554
|
-
headers.set('X-Databricks-Org-Id',
|
|
569
|
+
if (workspaceId !== undefined) {
|
|
570
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
555
571
|
}
|
|
556
572
|
headers.set('User-Agent', this.userAgent);
|
|
557
573
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
558
574
|
const respBody = await executeHttpCall({
|
|
559
575
|
request: httpReq,
|
|
560
|
-
httpClient
|
|
576
|
+
httpClient,
|
|
561
577
|
logger: this.logger,
|
|
562
578
|
});
|
|
563
579
|
resp = parseResponse(respBody, unmarshalListRunsResponseSchema);
|
|
@@ -586,20 +602,21 @@ export class JobsClient {
|
|
|
586
602
|
* They use the current job and task settings, and can be viewed in the history for the
|
|
587
603
|
* original job run.
|
|
588
604
|
*/
|
|
589
|
-
async
|
|
590
|
-
const
|
|
605
|
+
async repairBase(req, options) {
|
|
606
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
607
|
+
const url = `${host}/api/2.1/jobs/runs/repair`;
|
|
591
608
|
const body = marshalRequest(req, marshalRepairRunRequestSchema);
|
|
592
609
|
let resp;
|
|
593
610
|
const call = async (callSignal) => {
|
|
594
611
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
595
|
-
if (
|
|
596
|
-
headers.set('X-Databricks-Org-Id',
|
|
612
|
+
if (workspaceId !== undefined) {
|
|
613
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
597
614
|
}
|
|
598
615
|
headers.set('User-Agent', this.userAgent);
|
|
599
616
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
600
617
|
const respBody = await executeHttpCall({
|
|
601
618
|
request: httpReq,
|
|
602
|
-
httpClient
|
|
619
|
+
httpClient,
|
|
603
620
|
logger: this.logger,
|
|
604
621
|
});
|
|
605
622
|
resp = parseResponse(respBody, unmarshalRepairRunResponseSchema);
|
|
@@ -610,8 +627,13 @@ export class JobsClient {
|
|
|
610
627
|
}
|
|
611
628
|
return resp;
|
|
612
629
|
}
|
|
613
|
-
|
|
614
|
-
|
|
630
|
+
/**
|
|
631
|
+
* Re-run one or more tasks. Tasks are re-run as part of the original job run.
|
|
632
|
+
* They use the current job and task settings, and can be viewed in the history for the
|
|
633
|
+
* original job run.
|
|
634
|
+
*/
|
|
635
|
+
async repair(req, options) {
|
|
636
|
+
await this.repairBase(req, options);
|
|
615
637
|
if (req.runId === undefined) {
|
|
616
638
|
throw new Error('request field runId required for polling is missing');
|
|
617
639
|
}
|
|
@@ -619,19 +641,20 @@ export class JobsClient {
|
|
|
619
641
|
}
|
|
620
642
|
/** Overwrite all settings for the given job. Use the [_Update_ endpoint](:method:jobs/update) to update job settings partially. */
|
|
621
643
|
async resetJob(req, options) {
|
|
622
|
-
const
|
|
644
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
645
|
+
const url = `${host}/api/2.0/jobs/reset`;
|
|
623
646
|
const body = marshalRequest(req, marshalResetJobRequestSchema);
|
|
624
647
|
let resp;
|
|
625
648
|
const call = async (callSignal) => {
|
|
626
649
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
627
|
-
if (
|
|
628
|
-
headers.set('X-Databricks-Org-Id',
|
|
650
|
+
if (workspaceId !== undefined) {
|
|
651
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
629
652
|
}
|
|
630
653
|
headers.set('User-Agent', this.userAgent);
|
|
631
654
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
632
655
|
const respBody = await executeHttpCall({
|
|
633
656
|
request: httpReq,
|
|
634
|
-
httpClient
|
|
657
|
+
httpClient,
|
|
635
658
|
logger: this.logger,
|
|
636
659
|
});
|
|
637
660
|
resp = parseResponse(respBody, unmarshalResetJobResponseSchema);
|
|
@@ -643,20 +666,21 @@ export class JobsClient {
|
|
|
643
666
|
return resp;
|
|
644
667
|
}
|
|
645
668
|
/** Run a job and return the `run_id` of the triggered run. */
|
|
646
|
-
async
|
|
647
|
-
const
|
|
669
|
+
async runNowBase(req, options) {
|
|
670
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
671
|
+
const url = `${host}/api/2.0/jobs/run-now`;
|
|
648
672
|
const body = marshalRequest(req, marshalRunNowRequestSchema);
|
|
649
673
|
let resp;
|
|
650
674
|
const call = async (callSignal) => {
|
|
651
675
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
652
|
-
if (
|
|
653
|
-
headers.set('X-Databricks-Org-Id',
|
|
676
|
+
if (workspaceId !== undefined) {
|
|
677
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
654
678
|
}
|
|
655
679
|
headers.set('User-Agent', this.userAgent);
|
|
656
680
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
657
681
|
const respBody = await executeHttpCall({
|
|
658
682
|
request: httpReq,
|
|
659
|
-
httpClient
|
|
683
|
+
httpClient,
|
|
660
684
|
logger: this.logger,
|
|
661
685
|
});
|
|
662
686
|
resp = parseResponse(respBody, unmarshalRunNowResponseSchema);
|
|
@@ -667,8 +691,9 @@ export class JobsClient {
|
|
|
667
691
|
}
|
|
668
692
|
return resp;
|
|
669
693
|
}
|
|
670
|
-
|
|
671
|
-
|
|
694
|
+
/** Run a job and return the `run_id` of the triggered run. */
|
|
695
|
+
async runNow(req, options) {
|
|
696
|
+
const resp = await this.runNowBase(req, options);
|
|
672
697
|
if (resp.runId === undefined) {
|
|
673
698
|
throw new Error('response field runId required for polling is missing');
|
|
674
699
|
}
|
|
@@ -687,20 +712,21 @@ export class JobsClient {
|
|
|
687
712
|
* the compute needs for the job. Alternatively, use the `POST /jobs/create` and
|
|
688
713
|
* `POST /jobs/run-now` endpoints to create and run a saved job.
|
|
689
714
|
*/
|
|
690
|
-
async
|
|
691
|
-
const
|
|
715
|
+
async submitRunBase(req, options) {
|
|
716
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
717
|
+
const url = `${host}/api/2.0/jobs/runs/submit`;
|
|
692
718
|
const body = marshalRequest(req, marshalSubmitRunRequestSchema);
|
|
693
719
|
let resp;
|
|
694
720
|
const call = async (callSignal) => {
|
|
695
721
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
696
|
-
if (
|
|
697
|
-
headers.set('X-Databricks-Org-Id',
|
|
722
|
+
if (workspaceId !== undefined) {
|
|
723
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
698
724
|
}
|
|
699
725
|
headers.set('User-Agent', this.userAgent);
|
|
700
726
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
701
727
|
const respBody = await executeHttpCall({
|
|
702
728
|
request: httpReq,
|
|
703
|
-
httpClient
|
|
729
|
+
httpClient,
|
|
704
730
|
logger: this.logger,
|
|
705
731
|
});
|
|
706
732
|
resp = parseResponse(respBody, unmarshalSubmitRunResponseSchema);
|
|
@@ -711,8 +737,21 @@ export class JobsClient {
|
|
|
711
737
|
}
|
|
712
738
|
return resp;
|
|
713
739
|
}
|
|
714
|
-
|
|
715
|
-
|
|
740
|
+
/**
|
|
741
|
+
* Submit a one-time run. This endpoint allows you to submit a workload directly
|
|
742
|
+
* without creating a job. Runs submitted using this endpoint don’t display in
|
|
743
|
+
* the UI. Use the `jobs/runs/get` API to check the run state after the job is
|
|
744
|
+
* submitted.
|
|
745
|
+
*
|
|
746
|
+
* **Important:** Jobs submitted using this endpoint are not saved as a job.
|
|
747
|
+
* They do not show up in the Jobs UI, and do not retry when they fail. Because
|
|
748
|
+
* they are not saved, <Databricks> cannot auto-optimize serverless compute in case
|
|
749
|
+
* of failure. If your job fails, you may want to use classic compute to specify
|
|
750
|
+
* the compute needs for the job. Alternatively, use the `POST /jobs/create` and
|
|
751
|
+
* `POST /jobs/run-now` endpoints to create and run a saved job.
|
|
752
|
+
*/
|
|
753
|
+
async submitRun(req, options) {
|
|
754
|
+
const resp = await this.submitRunBase(req, options);
|
|
716
755
|
if (resp.runId === undefined) {
|
|
717
756
|
throw new Error('response field runId required for polling is missing');
|
|
718
757
|
}
|
|
@@ -720,19 +759,20 @@ export class JobsClient {
|
|
|
720
759
|
}
|
|
721
760
|
/** Add, update, or remove specific settings of an existing job. Use the [_Reset_ endpoint](:method:jobs/reset) to overwrite all job settings. */
|
|
722
761
|
async updateJob(req, options) {
|
|
723
|
-
const
|
|
762
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
763
|
+
const url = `${host}/api/2.0/jobs/update`;
|
|
724
764
|
const body = marshalRequest(req, marshalUpdateJobRequestSchema);
|
|
725
765
|
let resp;
|
|
726
766
|
const call = async (callSignal) => {
|
|
727
767
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
728
|
-
if (
|
|
729
|
-
headers.set('X-Databricks-Org-Id',
|
|
768
|
+
if (workspaceId !== undefined) {
|
|
769
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
730
770
|
}
|
|
731
771
|
headers.set('User-Agent', this.userAgent);
|
|
732
772
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
733
773
|
const respBody = await executeHttpCall({
|
|
734
774
|
request: httpReq,
|
|
735
|
-
httpClient
|
|
775
|
+
httpClient,
|
|
736
776
|
logger: this.logger,
|
|
737
777
|
});
|
|
738
778
|
resp = parseResponse(respBody, unmarshalUpdateJobResponseSchema);
|