@databricks/sdk-environments 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.js +7 -0
- package/dist/package.js.map +1 -0
- package/dist/v1/client.d.ts +146 -142
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +439 -574
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +3 -8
- package/dist/v1/index.js +4 -8
- package/dist/v1/model.d.ts +700 -710
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +222 -679
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +21 -17
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +60 -69
- package/dist/v1/transport.js.map +1 -1
- package/dist/v1/utils.d.ts +21 -18
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +90 -118
- package/dist/v1/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/v1/index.d.ts.map +0 -1
- package/dist/v1/index.js.map +0 -1
package/dist/v1/client.js
CHANGED
|
@@ -1,577 +1,442 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { z } from
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { resolveClientConfig } from "./transport.js";
|
|
2
|
+
import { StillRunningError, buildHttpRequest, executeCall, executeHttpCall, executeWait, marshalRequest, parseResponse } from "./utils.js";
|
|
3
|
+
import { name, version } from "../package.js";
|
|
4
|
+
import { marshalDefaultWorkspaceBaseEnvironmentSchema, marshalRefreshWorkspaceBaseEnvironmentRequestSchema, marshalWorkspaceBaseEnvironmentSchema, unmarshalDefaultWorkspaceBaseEnvironmentSchema, unmarshalListWorkspaceBaseEnvironmentsResponseSchema, unmarshalOperationSchema, unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema, unmarshalWorkspaceBaseEnvironmentSchema } from "./model.js";
|
|
5
|
+
import { VERSION } from "@databricks/sdk-auth";
|
|
6
|
+
import { createDefault } from "@databricks/sdk-core/clientinfo";
|
|
7
|
+
import { NoOpLogger } from "@databricks/sdk-core/logger";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
//#region src/v1/client.ts
|
|
11
11
|
const PACKAGE_SEGMENT = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
|
|
13
|
+
value: version
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
export
|
|
442
|
-
operation;
|
|
443
|
-
getOperation;
|
|
444
|
-
constructor(operation, getOperation) {
|
|
445
|
-
this.operation = operation;
|
|
446
|
-
this.getOperation = getOperation;
|
|
447
|
-
}
|
|
448
|
-
/** Returns the server-assigned name of the long-running operation. */
|
|
449
|
-
name() {
|
|
450
|
-
return Promise.resolve(this.operation.name);
|
|
451
|
-
}
|
|
452
|
-
/** Returns metadata associated with the long-running operation. */
|
|
453
|
-
metadata() {
|
|
454
|
-
if (this.operation.metadata === undefined) {
|
|
455
|
-
return Promise.resolve(undefined);
|
|
456
|
-
}
|
|
457
|
-
return Promise.resolve(z
|
|
458
|
-
.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema)
|
|
459
|
-
.parse(this.operation.metadata));
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Polls the operation until it completes.
|
|
463
|
-
*
|
|
464
|
-
* Throws if the operation failed.
|
|
465
|
-
*/
|
|
466
|
-
async wait(options) {
|
|
467
|
-
let result;
|
|
468
|
-
const call = async (callSignal) => {
|
|
469
|
-
const op = await this.getOperation({
|
|
470
|
-
name: this.operation.name,
|
|
471
|
-
}, callSignal !== undefined ? { signal: callSignal } : undefined);
|
|
472
|
-
this.operation = op;
|
|
473
|
-
if (op.done === undefined) {
|
|
474
|
-
throw new Error('operation is missing the done field');
|
|
475
|
-
}
|
|
476
|
-
if (!op.done) {
|
|
477
|
-
throw new StillRunningError();
|
|
478
|
-
}
|
|
479
|
-
if (op.result?.$case === 'error') {
|
|
480
|
-
const err = op.result.error;
|
|
481
|
-
const msg = err.message !== undefined && err.message !== ''
|
|
482
|
-
? err.message
|
|
483
|
-
: 'unknown error';
|
|
484
|
-
const errorMsg = err.errorCode !== undefined ? `[${err.errorCode}] ${msg}` : msg;
|
|
485
|
-
throw new Error(`operation failed: ${errorMsg}`, {
|
|
486
|
-
cause: err,
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
if (op.result?.$case !== 'response') {
|
|
490
|
-
throw new Error('operation completed without a response');
|
|
491
|
-
}
|
|
492
|
-
result = z
|
|
493
|
-
.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema)
|
|
494
|
-
.parse(op.result.response);
|
|
495
|
-
};
|
|
496
|
-
await executeWait(call, options);
|
|
497
|
-
if (result === undefined) {
|
|
498
|
-
throw new Error('operation completed without a result.');
|
|
499
|
-
}
|
|
500
|
-
return result;
|
|
501
|
-
}
|
|
502
|
-
/** Checks whether the operation has completed */
|
|
503
|
-
async done(options) {
|
|
504
|
-
const op = await this.getOperation({ name: this.operation.name }, options);
|
|
505
|
-
this.operation = op;
|
|
506
|
-
return op.done;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
export class UpdateWorkspaceBaseEnvironmentOperation {
|
|
510
|
-
operation;
|
|
511
|
-
getOperation;
|
|
512
|
-
constructor(operation, getOperation) {
|
|
513
|
-
this.operation = operation;
|
|
514
|
-
this.getOperation = getOperation;
|
|
515
|
-
}
|
|
516
|
-
/** Returns the server-assigned name of the long-running operation. */
|
|
517
|
-
name() {
|
|
518
|
-
return Promise.resolve(this.operation.name);
|
|
519
|
-
}
|
|
520
|
-
/** Returns metadata associated with the long-running operation. */
|
|
521
|
-
metadata() {
|
|
522
|
-
if (this.operation.metadata === undefined) {
|
|
523
|
-
return Promise.resolve(undefined);
|
|
524
|
-
}
|
|
525
|
-
return Promise.resolve(z
|
|
526
|
-
.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema)
|
|
527
|
-
.parse(this.operation.metadata));
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Polls the operation until it completes.
|
|
531
|
-
*
|
|
532
|
-
* Throws if the operation failed.
|
|
533
|
-
*/
|
|
534
|
-
async wait(options) {
|
|
535
|
-
let result;
|
|
536
|
-
const call = async (callSignal) => {
|
|
537
|
-
const op = await this.getOperation({
|
|
538
|
-
name: this.operation.name,
|
|
539
|
-
}, callSignal !== undefined ? { signal: callSignal } : undefined);
|
|
540
|
-
this.operation = op;
|
|
541
|
-
if (op.done === undefined) {
|
|
542
|
-
throw new Error('operation is missing the done field');
|
|
543
|
-
}
|
|
544
|
-
if (!op.done) {
|
|
545
|
-
throw new StillRunningError();
|
|
546
|
-
}
|
|
547
|
-
if (op.result?.$case === 'error') {
|
|
548
|
-
const err = op.result.error;
|
|
549
|
-
const msg = err.message !== undefined && err.message !== ''
|
|
550
|
-
? err.message
|
|
551
|
-
: 'unknown error';
|
|
552
|
-
const errorMsg = err.errorCode !== undefined ? `[${err.errorCode}] ${msg}` : msg;
|
|
553
|
-
throw new Error(`operation failed: ${errorMsg}`, {
|
|
554
|
-
cause: err,
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
if (op.result?.$case !== 'response') {
|
|
558
|
-
throw new Error('operation completed without a response');
|
|
559
|
-
}
|
|
560
|
-
result = z
|
|
561
|
-
.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema)
|
|
562
|
-
.parse(op.result.response);
|
|
563
|
-
};
|
|
564
|
-
await executeWait(call, options);
|
|
565
|
-
if (result === undefined) {
|
|
566
|
-
throw new Error('operation completed without a result.');
|
|
567
|
-
}
|
|
568
|
-
return result;
|
|
569
|
-
}
|
|
570
|
-
/** Checks whether the operation has completed */
|
|
571
|
-
async done(options) {
|
|
572
|
-
const op = await this.getOperation({ name: this.operation.name }, options);
|
|
573
|
-
this.operation = op;
|
|
574
|
-
return op.done;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
15
|
+
var EnvironmentsClient = class {
|
|
16
|
+
options;
|
|
17
|
+
logger;
|
|
18
|
+
userAgent;
|
|
19
|
+
config;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
23
|
+
this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
|
|
24
|
+
key: "sdk-js-auth",
|
|
25
|
+
value: VERSION
|
|
26
|
+
}).with({
|
|
27
|
+
key: "auth",
|
|
28
|
+
value: options.credentials?.name() ?? "default"
|
|
29
|
+
}).toString();
|
|
30
|
+
}
|
|
31
|
+
resolveConfig() {
|
|
32
|
+
this.config ??= resolveClientConfig(this.options);
|
|
33
|
+
return this.config;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new WorkspaceBaseEnvironment.
|
|
37
|
+
* This is a long-running operation. The operation will asynchronously generate a materialized environment
|
|
38
|
+
* to optimize dependency resolution and is only marked as done when the materialized environment has been
|
|
39
|
+
* successfully generated or has failed.
|
|
40
|
+
*/
|
|
41
|
+
async createWorkspaceBaseEnvironmentBase(req, options) {
|
|
42
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
43
|
+
const url = `${host}/api/environments/v1/workspace-base-environments`;
|
|
44
|
+
const params = new URLSearchParams();
|
|
45
|
+
if (req.workspaceBaseEnvironmentId !== void 0) params.append("workspace_base_environment_id", req.workspaceBaseEnvironmentId);
|
|
46
|
+
if (req.requestId !== void 0) params.append("request_id", req.requestId);
|
|
47
|
+
const query = params.toString();
|
|
48
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
49
|
+
const body = marshalRequest(req.workspaceBaseEnvironment, marshalWorkspaceBaseEnvironmentSchema);
|
|
50
|
+
let resp;
|
|
51
|
+
const call = async (callSignal) => {
|
|
52
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
53
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
54
|
+
headers.set("User-Agent", this.userAgent);
|
|
55
|
+
resp = parseResponse(await executeHttpCall({
|
|
56
|
+
request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
|
|
57
|
+
httpClient,
|
|
58
|
+
logger: this.logger
|
|
59
|
+
}), unmarshalOperationSchema);
|
|
60
|
+
};
|
|
61
|
+
await executeCall(call, options);
|
|
62
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
63
|
+
return resp;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new WorkspaceBaseEnvironment.
|
|
67
|
+
* This is a long-running operation. The operation will asynchronously generate a materialized environment
|
|
68
|
+
* to optimize dependency resolution and is only marked as done when the materialized environment has been
|
|
69
|
+
* successfully generated or has failed.
|
|
70
|
+
*/
|
|
71
|
+
async createWorkspaceBaseEnvironment(req, options) {
|
|
72
|
+
return new CreateWorkspaceBaseEnvironmentOperation(await this.createWorkspaceBaseEnvironmentBase(req, options), (req, options) => this.getOperation(req, options));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Deletes a WorkspaceBaseEnvironment.
|
|
76
|
+
* Deleting a base environment may impact linked notebooks and jobs.
|
|
77
|
+
* This operation is irreversible and should be performed only when you are certain the environment is no longer needed.
|
|
78
|
+
*/
|
|
79
|
+
async deleteWorkspaceBaseEnvironment(req, options) {
|
|
80
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
81
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}`;
|
|
82
|
+
const call = async (callSignal) => {
|
|
83
|
+
const headers = new Headers();
|
|
84
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
85
|
+
headers.set("User-Agent", this.userAgent);
|
|
86
|
+
await executeHttpCall({
|
|
87
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
88
|
+
httpClient,
|
|
89
|
+
logger: this.logger
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
await executeCall(call, options);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the default WorkspaceBaseEnvironment configuration for the workspace.
|
|
96
|
+
* Returns the current default base environment settings for both CPU and GPU compute.
|
|
97
|
+
*/
|
|
98
|
+
async getDefaultWorkspaceBaseEnvironment(req, options) {
|
|
99
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
100
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}`;
|
|
101
|
+
let resp;
|
|
102
|
+
const call = async (callSignal) => {
|
|
103
|
+
const headers = new Headers();
|
|
104
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
105
|
+
headers.set("User-Agent", this.userAgent);
|
|
106
|
+
resp = parseResponse(await executeHttpCall({
|
|
107
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
108
|
+
httpClient,
|
|
109
|
+
logger: this.logger
|
|
110
|
+
}), unmarshalDefaultWorkspaceBaseEnvironmentSchema);
|
|
111
|
+
};
|
|
112
|
+
await executeCall(call, options);
|
|
113
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
114
|
+
return resp;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets the status of a long-running operation.
|
|
118
|
+
* Clients can use this method to poll the operation result.
|
|
119
|
+
*/
|
|
120
|
+
async getOperation(req, options) {
|
|
121
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
122
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}`;
|
|
123
|
+
let resp;
|
|
124
|
+
const call = async (callSignal) => {
|
|
125
|
+
const headers = new Headers();
|
|
126
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
127
|
+
headers.set("User-Agent", this.userAgent);
|
|
128
|
+
resp = parseResponse(await executeHttpCall({
|
|
129
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
130
|
+
httpClient,
|
|
131
|
+
logger: this.logger
|
|
132
|
+
}), unmarshalOperationSchema);
|
|
133
|
+
};
|
|
134
|
+
await executeCall(call, options);
|
|
135
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
136
|
+
return resp;
|
|
137
|
+
}
|
|
138
|
+
/** Retrieves a WorkspaceBaseEnvironment by its name. */
|
|
139
|
+
async getWorkspaceBaseEnvironment(req, options) {
|
|
140
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
141
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}`;
|
|
142
|
+
let resp;
|
|
143
|
+
const call = async (callSignal) => {
|
|
144
|
+
const headers = new Headers();
|
|
145
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
146
|
+
headers.set("User-Agent", this.userAgent);
|
|
147
|
+
resp = parseResponse(await executeHttpCall({
|
|
148
|
+
request: buildHttpRequest("GET", url, headers, callSignal),
|
|
149
|
+
httpClient,
|
|
150
|
+
logger: this.logger
|
|
151
|
+
}), unmarshalWorkspaceBaseEnvironmentSchema);
|
|
152
|
+
};
|
|
153
|
+
await executeCall(call, options);
|
|
154
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
155
|
+
return resp;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Lists all WorkspaceBaseEnvironments in the workspace.
|
|
159
|
+
*
|
|
160
|
+
* <Databricks> provides the following base environments:
|
|
161
|
+
*
|
|
162
|
+
* - `workspace-base-environments/databricks_ai_...`: includes popular AI and deep learning packages for serverless GPU compute.
|
|
163
|
+
*
|
|
164
|
+
*
|
|
165
|
+
*
|
|
166
|
+
* - `workspace-base-environments/databricks_ml_...`: includes popular ML packages for serverless compute.
|
|
167
|
+
*
|
|
168
|
+
*
|
|
169
|
+
*
|
|
170
|
+
*
|
|
171
|
+
* Databricks-provided base environments are versioned. For example, `workspace-base-environments/databricks_ml_v5` corresponds to the ML environment built on environment version 5.
|
|
172
|
+
*/
|
|
173
|
+
async listWorkspaceBaseEnvironments(req, options) {
|
|
174
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
175
|
+
const url = `${host}/api/environments/v1/workspace-base-environments`;
|
|
176
|
+
const params = new URLSearchParams();
|
|
177
|
+
if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
|
|
178
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
179
|
+
const query = params.toString();
|
|
180
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
181
|
+
let resp;
|
|
182
|
+
const call = async (callSignal) => {
|
|
183
|
+
const headers = new Headers();
|
|
184
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
185
|
+
headers.set("User-Agent", this.userAgent);
|
|
186
|
+
resp = parseResponse(await executeHttpCall({
|
|
187
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
188
|
+
httpClient,
|
|
189
|
+
logger: this.logger
|
|
190
|
+
}), unmarshalListWorkspaceBaseEnvironmentsResponseSchema);
|
|
191
|
+
};
|
|
192
|
+
await executeCall(call, options);
|
|
193
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
194
|
+
return resp;
|
|
195
|
+
}
|
|
196
|
+
async *listWorkspaceBaseEnvironmentsIter(req, options) {
|
|
197
|
+
const pageReq = { ...req };
|
|
198
|
+
for (;;) {
|
|
199
|
+
const resp = await this.listWorkspaceBaseEnvironments(pageReq, options);
|
|
200
|
+
for (const item of resp.workspaceBaseEnvironments ?? []) yield item;
|
|
201
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
202
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Refreshes the materialized environment for a WorkspaceBaseEnvironment.
|
|
207
|
+
* This is a long-running operation. The operation will asynchronously regenerate the materialized environment
|
|
208
|
+
* and is only marked as done when the materialized environment has been successfully generated or has failed.
|
|
209
|
+
* The existing materialized environment remains available until it expires.
|
|
210
|
+
*/
|
|
211
|
+
async refreshWorkspaceBaseEnvironmentBase(req, options) {
|
|
212
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
213
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}/refresh`;
|
|
214
|
+
const body = marshalRequest(req, marshalRefreshWorkspaceBaseEnvironmentRequestSchema);
|
|
215
|
+
let resp;
|
|
216
|
+
const call = async (callSignal) => {
|
|
217
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
218
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
219
|
+
headers.set("User-Agent", this.userAgent);
|
|
220
|
+
resp = parseResponse(await executeHttpCall({
|
|
221
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
222
|
+
httpClient,
|
|
223
|
+
logger: this.logger
|
|
224
|
+
}), unmarshalOperationSchema);
|
|
225
|
+
};
|
|
226
|
+
await executeCall(call, options);
|
|
227
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
228
|
+
return resp;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Refreshes the materialized environment for a WorkspaceBaseEnvironment.
|
|
232
|
+
* This is a long-running operation. The operation will asynchronously regenerate the materialized environment
|
|
233
|
+
* and is only marked as done when the materialized environment has been successfully generated or has failed.
|
|
234
|
+
* The existing materialized environment remains available until it expires.
|
|
235
|
+
*/
|
|
236
|
+
async refreshWorkspaceBaseEnvironment(req, options) {
|
|
237
|
+
return new RefreshWorkspaceBaseEnvironmentOperation(await this.refreshWorkspaceBaseEnvironmentBase(req, options), (req, options) => this.getOperation(req, options));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Updates the default WorkspaceBaseEnvironment configuration for the workspace.
|
|
241
|
+
* Sets the specified base environments as the workspace defaults for CPU and/or GPU compute.
|
|
242
|
+
*/
|
|
243
|
+
async updateDefaultWorkspaceBaseEnvironment(req, options) {
|
|
244
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
245
|
+
const url = `${host}/api/environments/v1/${req.defaultWorkspaceBaseEnvironment?.name ?? ""}`;
|
|
246
|
+
const params = new URLSearchParams();
|
|
247
|
+
if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
|
|
248
|
+
const query = params.toString();
|
|
249
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
250
|
+
const body = marshalRequest(req.defaultWorkspaceBaseEnvironment, marshalDefaultWorkspaceBaseEnvironmentSchema);
|
|
251
|
+
let resp;
|
|
252
|
+
const call = async (callSignal) => {
|
|
253
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
254
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
255
|
+
headers.set("User-Agent", this.userAgent);
|
|
256
|
+
resp = parseResponse(await executeHttpCall({
|
|
257
|
+
request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
|
|
258
|
+
httpClient,
|
|
259
|
+
logger: this.logger
|
|
260
|
+
}), unmarshalDefaultWorkspaceBaseEnvironmentSchema);
|
|
261
|
+
};
|
|
262
|
+
await executeCall(call, options);
|
|
263
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
264
|
+
return resp;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Updates an existing WorkspaceBaseEnvironment.
|
|
268
|
+
* This is a long-running operation. The operation will asynchronously regenerate the materialized environment
|
|
269
|
+
* and is only marked as done when the materialized environment has been successfully generated or has failed.
|
|
270
|
+
* The existing materialized environment remains available until it expires.
|
|
271
|
+
*/
|
|
272
|
+
async updateWorkspaceBaseEnvironmentBase(req, options) {
|
|
273
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
274
|
+
const url = `${host}/api/environments/v1/${req.name ?? ""}`;
|
|
275
|
+
const body = marshalRequest(req.workspaceBaseEnvironment, marshalWorkspaceBaseEnvironmentSchema);
|
|
276
|
+
let resp;
|
|
277
|
+
const call = async (callSignal) => {
|
|
278
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
279
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
280
|
+
headers.set("User-Agent", this.userAgent);
|
|
281
|
+
resp = parseResponse(await executeHttpCall({
|
|
282
|
+
request: buildHttpRequest("PATCH", url, headers, callSignal, body),
|
|
283
|
+
httpClient,
|
|
284
|
+
logger: this.logger
|
|
285
|
+
}), unmarshalOperationSchema);
|
|
286
|
+
};
|
|
287
|
+
await executeCall(call, options);
|
|
288
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
289
|
+
return resp;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Updates an existing WorkspaceBaseEnvironment.
|
|
293
|
+
* This is a long-running operation. The operation will asynchronously regenerate the materialized environment
|
|
294
|
+
* and is only marked as done when the materialized environment has been successfully generated or has failed.
|
|
295
|
+
* The existing materialized environment remains available until it expires.
|
|
296
|
+
*/
|
|
297
|
+
async updateWorkspaceBaseEnvironment(req, options) {
|
|
298
|
+
return new UpdateWorkspaceBaseEnvironmentOperation(await this.updateWorkspaceBaseEnvironmentBase(req, options), (req, options) => this.getOperation(req, options));
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
var CreateWorkspaceBaseEnvironmentOperation = class {
|
|
302
|
+
constructor(operation, getOperation) {
|
|
303
|
+
this.operation = operation;
|
|
304
|
+
this.getOperation = getOperation;
|
|
305
|
+
}
|
|
306
|
+
/** Returns the server-assigned name of the long-running operation. */
|
|
307
|
+
name() {
|
|
308
|
+
return Promise.resolve(this.operation.name);
|
|
309
|
+
}
|
|
310
|
+
/** Returns metadata associated with the long-running operation. */
|
|
311
|
+
metadata() {
|
|
312
|
+
if (this.operation.metadata === void 0) return Promise.resolve(void 0);
|
|
313
|
+
return Promise.resolve(z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata));
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Polls the operation until it completes.
|
|
317
|
+
*
|
|
318
|
+
* Throws if the operation failed.
|
|
319
|
+
*/
|
|
320
|
+
async wait(options) {
|
|
321
|
+
let result;
|
|
322
|
+
const call = async (callSignal) => {
|
|
323
|
+
const op = await this.getOperation({ name: this.operation.name }, callSignal !== void 0 ? { signal: callSignal } : void 0);
|
|
324
|
+
this.operation = op;
|
|
325
|
+
if (op.done === void 0) throw new Error("operation is missing the done field");
|
|
326
|
+
if (!op.done) throw new StillRunningError();
|
|
327
|
+
if (op.result?.$case === "error") {
|
|
328
|
+
const err = op.result.error;
|
|
329
|
+
const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
|
|
330
|
+
const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
|
|
331
|
+
throw new Error(`operation failed: ${errorMsg}`, { cause: err });
|
|
332
|
+
}
|
|
333
|
+
if (op.result?.$case !== "response") throw new Error("operation completed without a response");
|
|
334
|
+
result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.result.response);
|
|
335
|
+
};
|
|
336
|
+
await executeWait(call, options);
|
|
337
|
+
if (result === void 0) throw new Error("operation completed without a result.");
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
/** Checks whether the operation has completed */
|
|
341
|
+
async done(options) {
|
|
342
|
+
const op = await this.getOperation({ name: this.operation.name }, options);
|
|
343
|
+
this.operation = op;
|
|
344
|
+
return op.done;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var RefreshWorkspaceBaseEnvironmentOperation = class {
|
|
348
|
+
constructor(operation, getOperation) {
|
|
349
|
+
this.operation = operation;
|
|
350
|
+
this.getOperation = getOperation;
|
|
351
|
+
}
|
|
352
|
+
/** Returns the server-assigned name of the long-running operation. */
|
|
353
|
+
name() {
|
|
354
|
+
return Promise.resolve(this.operation.name);
|
|
355
|
+
}
|
|
356
|
+
/** Returns metadata associated with the long-running operation. */
|
|
357
|
+
metadata() {
|
|
358
|
+
if (this.operation.metadata === void 0) return Promise.resolve(void 0);
|
|
359
|
+
return Promise.resolve(z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata));
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Polls the operation until it completes.
|
|
363
|
+
*
|
|
364
|
+
* Throws if the operation failed.
|
|
365
|
+
*/
|
|
366
|
+
async wait(options) {
|
|
367
|
+
let result;
|
|
368
|
+
const call = async (callSignal) => {
|
|
369
|
+
const op = await this.getOperation({ name: this.operation.name }, callSignal !== void 0 ? { signal: callSignal } : void 0);
|
|
370
|
+
this.operation = op;
|
|
371
|
+
if (op.done === void 0) throw new Error("operation is missing the done field");
|
|
372
|
+
if (!op.done) throw new StillRunningError();
|
|
373
|
+
if (op.result?.$case === "error") {
|
|
374
|
+
const err = op.result.error;
|
|
375
|
+
const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
|
|
376
|
+
const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
|
|
377
|
+
throw new Error(`operation failed: ${errorMsg}`, { cause: err });
|
|
378
|
+
}
|
|
379
|
+
if (op.result?.$case !== "response") throw new Error("operation completed without a response");
|
|
380
|
+
result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.result.response);
|
|
381
|
+
};
|
|
382
|
+
await executeWait(call, options);
|
|
383
|
+
if (result === void 0) throw new Error("operation completed without a result.");
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
/** Checks whether the operation has completed */
|
|
387
|
+
async done(options) {
|
|
388
|
+
const op = await this.getOperation({ name: this.operation.name }, options);
|
|
389
|
+
this.operation = op;
|
|
390
|
+
return op.done;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
var UpdateWorkspaceBaseEnvironmentOperation = class {
|
|
394
|
+
constructor(operation, getOperation) {
|
|
395
|
+
this.operation = operation;
|
|
396
|
+
this.getOperation = getOperation;
|
|
397
|
+
}
|
|
398
|
+
/** Returns the server-assigned name of the long-running operation. */
|
|
399
|
+
name() {
|
|
400
|
+
return Promise.resolve(this.operation.name);
|
|
401
|
+
}
|
|
402
|
+
/** Returns metadata associated with the long-running operation. */
|
|
403
|
+
metadata() {
|
|
404
|
+
if (this.operation.metadata === void 0) return Promise.resolve(void 0);
|
|
405
|
+
return Promise.resolve(z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata));
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Polls the operation until it completes.
|
|
409
|
+
*
|
|
410
|
+
* Throws if the operation failed.
|
|
411
|
+
*/
|
|
412
|
+
async wait(options) {
|
|
413
|
+
let result;
|
|
414
|
+
const call = async (callSignal) => {
|
|
415
|
+
const op = await this.getOperation({ name: this.operation.name }, callSignal !== void 0 ? { signal: callSignal } : void 0);
|
|
416
|
+
this.operation = op;
|
|
417
|
+
if (op.done === void 0) throw new Error("operation is missing the done field");
|
|
418
|
+
if (!op.done) throw new StillRunningError();
|
|
419
|
+
if (op.result?.$case === "error") {
|
|
420
|
+
const err = op.result.error;
|
|
421
|
+
const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
|
|
422
|
+
const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
|
|
423
|
+
throw new Error(`operation failed: ${errorMsg}`, { cause: err });
|
|
424
|
+
}
|
|
425
|
+
if (op.result?.$case !== "response") throw new Error("operation completed without a response");
|
|
426
|
+
result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.result.response);
|
|
427
|
+
};
|
|
428
|
+
await executeWait(call, options);
|
|
429
|
+
if (result === void 0) throw new Error("operation completed without a result.");
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
/** Checks whether the operation has completed */
|
|
433
|
+
async done(options) {
|
|
434
|
+
const op = await this.getOperation({ name: this.operation.name }, options);
|
|
435
|
+
this.operation = op;
|
|
436
|
+
return op.done;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
//#endregion
|
|
441
|
+
export { CreateWorkspaceBaseEnvironmentOperation, EnvironmentsClient, RefreshWorkspaceBaseEnvironmentOperation, UpdateWorkspaceBaseEnvironmentOperation };
|
|
577
442
|
//# sourceMappingURL=client.js.map
|