@databricks/sdk-uc-registeredmodels 0.34.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 +145 -141
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +418 -525
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +3 -7
- package/dist/v1/index.js +4 -7
- package/dist/v1/model.d.ts +371 -373
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +286 -411
- 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 +18 -14
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +76 -103
- 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,528 +1,421 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { resolveClientConfig } from "./transport.js";
|
|
2
|
+
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
|
|
3
|
+
import { name, version } from "../package.js";
|
|
4
|
+
import { marshalCreateRegisteredModelRequestSchema, marshalSetRegisteredModelAliasRequestSchema, marshalUpdateModelVersionRequestSchema, marshalUpdateRegisteredModelRequestSchema, unmarshalDeleteModelVersionResponseSchema, unmarshalDeleteRegisteredModelAliasResponseSchema, unmarshalDeleteRegisteredModelResponseSchema, unmarshalListModelVersionsResponseSchema, unmarshalListRegisteredModelsResponseSchema, unmarshalModelVersionInfoSchema, unmarshalRegisteredModelAliasInfoSchema, unmarshalRegisteredModelInfoSchema } 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
|
+
|
|
9
|
+
//#region src/v1/client.ts
|
|
10
10
|
const PACKAGE_SEGMENT = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
|
|
12
|
+
value: version
|
|
13
13
|
};
|
|
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
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Set an alias on the specified registered model.
|
|
429
|
-
*
|
|
430
|
-
* The caller must be a metastore admin or an owner of the registered model.
|
|
431
|
-
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
432
|
-
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
433
|
-
*/
|
|
434
|
-
async setRegisteredModelAlias(req, options) {
|
|
435
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
436
|
-
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`;
|
|
437
|
-
const body = marshalRequest(req, marshalSetRegisteredModelAliasRequestSchema);
|
|
438
|
-
let resp;
|
|
439
|
-
const call = async (callSignal) => {
|
|
440
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
441
|
-
if (workspaceId !== undefined) {
|
|
442
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
443
|
-
}
|
|
444
|
-
headers.set('User-Agent', this.userAgent);
|
|
445
|
-
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
446
|
-
const respBody = await executeHttpCall({
|
|
447
|
-
request: httpReq,
|
|
448
|
-
httpClient,
|
|
449
|
-
logger: this.logger,
|
|
450
|
-
});
|
|
451
|
-
resp = parseResponse(respBody, unmarshalRegisteredModelAliasInfoSchema);
|
|
452
|
-
};
|
|
453
|
-
await executeCall(call, options);
|
|
454
|
-
if (resp === undefined) {
|
|
455
|
-
throw new Error('operation completed without a result.');
|
|
456
|
-
}
|
|
457
|
-
return resp;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Updates the specified model version.
|
|
461
|
-
*
|
|
462
|
-
* The caller must be a metastore admin or an owner of the parent registered model.
|
|
463
|
-
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
464
|
-
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
465
|
-
*
|
|
466
|
-
* Currently only the comment of the model version can be updated.
|
|
467
|
-
*/
|
|
468
|
-
async updateModelVersion(req, options) {
|
|
469
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
470
|
-
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`;
|
|
471
|
-
const body = marshalRequest(req, marshalUpdateModelVersionRequestSchema);
|
|
472
|
-
let resp;
|
|
473
|
-
const call = async (callSignal) => {
|
|
474
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
475
|
-
if (workspaceId !== undefined) {
|
|
476
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
477
|
-
}
|
|
478
|
-
headers.set('User-Agent', this.userAgent);
|
|
479
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
480
|
-
const respBody = await executeHttpCall({
|
|
481
|
-
request: httpReq,
|
|
482
|
-
httpClient,
|
|
483
|
-
logger: this.logger,
|
|
484
|
-
});
|
|
485
|
-
resp = parseResponse(respBody, unmarshalModelVersionInfoSchema);
|
|
486
|
-
};
|
|
487
|
-
await executeCall(call, options);
|
|
488
|
-
if (resp === undefined) {
|
|
489
|
-
throw new Error('operation completed without a result.');
|
|
490
|
-
}
|
|
491
|
-
return resp;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Updates the specified registered model.
|
|
495
|
-
*
|
|
496
|
-
* The caller must be a metastore admin or an owner of the registered model.
|
|
497
|
-
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
498
|
-
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
499
|
-
*
|
|
500
|
-
* Currently only the name, the owner or the comment of the registered model can be updated.
|
|
501
|
-
*/
|
|
502
|
-
async updateRegisteredModel(req, options) {
|
|
503
|
-
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
504
|
-
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`;
|
|
505
|
-
const body = marshalRequest(req, marshalUpdateRegisteredModelRequestSchema);
|
|
506
|
-
let resp;
|
|
507
|
-
const call = async (callSignal) => {
|
|
508
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
509
|
-
if (workspaceId !== undefined) {
|
|
510
|
-
headers.set('X-Databricks-Workspace-Id', workspaceId);
|
|
511
|
-
}
|
|
512
|
-
headers.set('User-Agent', this.userAgent);
|
|
513
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
514
|
-
const respBody = await executeHttpCall({
|
|
515
|
-
request: httpReq,
|
|
516
|
-
httpClient,
|
|
517
|
-
logger: this.logger,
|
|
518
|
-
});
|
|
519
|
-
resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema);
|
|
520
|
-
};
|
|
521
|
-
await executeCall(call, options);
|
|
522
|
-
if (resp === undefined) {
|
|
523
|
-
throw new Error('operation completed without a result.');
|
|
524
|
-
}
|
|
525
|
-
return resp;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
14
|
+
var RegisteredModelsClient = class {
|
|
15
|
+
options;
|
|
16
|
+
logger;
|
|
17
|
+
userAgent;
|
|
18
|
+
config;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
22
|
+
this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
|
|
23
|
+
key: "sdk-js-auth",
|
|
24
|
+
value: VERSION
|
|
25
|
+
}).with({
|
|
26
|
+
key: "auth",
|
|
27
|
+
value: options.credentials?.name() ?? "default"
|
|
28
|
+
}).toString();
|
|
29
|
+
}
|
|
30
|
+
resolveConfig() {
|
|
31
|
+
this.config ??= resolveClientConfig(this.options);
|
|
32
|
+
return this.config;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new registered model in Unity Catalog.
|
|
36
|
+
*
|
|
37
|
+
* File storage for model versions in the registered model
|
|
38
|
+
* will be located in the default location which is specified by the parent schema,
|
|
39
|
+
* or the parent catalog, or the Metastore.
|
|
40
|
+
*
|
|
41
|
+
* For registered model creation to succeed, the user must satisfy the following conditions:
|
|
42
|
+
* - The caller must be a metastore admin, or be the owner of the parent catalog and schema,
|
|
43
|
+
* or have the **USE_CATALOG** privilege on the parent catalog
|
|
44
|
+
* and the **USE_SCHEMA** privilege on the parent schema.
|
|
45
|
+
* - The caller must have the **CREATE MODEL** or **CREATE FUNCTION** privilege on the parent schema.
|
|
46
|
+
*/
|
|
47
|
+
async createRegisteredModel(req, options) {
|
|
48
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
49
|
+
const url = `${host}/api/2.1/unity-catalog/models`;
|
|
50
|
+
const body = marshalRequest(req, marshalCreateRegisteredModelRequestSchema);
|
|
51
|
+
let resp;
|
|
52
|
+
const call = async (callSignal) => {
|
|
53
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
54
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
55
|
+
headers.set("User-Agent", this.userAgent);
|
|
56
|
+
resp = parseResponse(await executeHttpCall({
|
|
57
|
+
request: buildHttpRequest("POST", url, headers, callSignal, body),
|
|
58
|
+
httpClient,
|
|
59
|
+
logger: this.logger
|
|
60
|
+
}), unmarshalRegisteredModelInfoSchema);
|
|
61
|
+
};
|
|
62
|
+
await executeCall(call, options);
|
|
63
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
64
|
+
return resp;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Deletes a model version from the specified registered model. Any aliases assigned to the
|
|
68
|
+
* model version will also be deleted.
|
|
69
|
+
*
|
|
70
|
+
* The caller must be a metastore admin or an owner of the parent registered model.
|
|
71
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
72
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
73
|
+
*/
|
|
74
|
+
async deleteModelVersion(req, options) {
|
|
75
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
76
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/versions/${String(req.versionArg ?? "")}`;
|
|
77
|
+
let resp;
|
|
78
|
+
const call = async (callSignal) => {
|
|
79
|
+
const headers = new Headers();
|
|
80
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
81
|
+
headers.set("User-Agent", this.userAgent);
|
|
82
|
+
resp = parseResponse(await executeHttpCall({
|
|
83
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
84
|
+
httpClient,
|
|
85
|
+
logger: this.logger
|
|
86
|
+
}), unmarshalDeleteModelVersionResponseSchema);
|
|
87
|
+
};
|
|
88
|
+
await executeCall(call, options);
|
|
89
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
90
|
+
return resp;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deletes a registered model and all its model versions from the specified parent catalog and schema.
|
|
94
|
+
*
|
|
95
|
+
* The caller must be a metastore admin or an owner of the registered model.
|
|
96
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
97
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
98
|
+
*/
|
|
99
|
+
async deleteRegisteredModel(req, options) {
|
|
100
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
101
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}`;
|
|
102
|
+
let resp;
|
|
103
|
+
const call = async (callSignal) => {
|
|
104
|
+
const headers = new Headers();
|
|
105
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
106
|
+
headers.set("User-Agent", this.userAgent);
|
|
107
|
+
resp = parseResponse(await executeHttpCall({
|
|
108
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
109
|
+
httpClient,
|
|
110
|
+
logger: this.logger
|
|
111
|
+
}), unmarshalDeleteRegisteredModelResponseSchema);
|
|
112
|
+
};
|
|
113
|
+
await executeCall(call, options);
|
|
114
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
115
|
+
return resp;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Deletes a registered model alias.
|
|
119
|
+
*
|
|
120
|
+
* The caller must be a metastore admin or an owner of the registered model.
|
|
121
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
122
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
123
|
+
*/
|
|
124
|
+
async deleteRegisteredModelAlias(req, options) {
|
|
125
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
126
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/aliases/${req.aliasArg ?? ""}`;
|
|
127
|
+
let resp;
|
|
128
|
+
const call = async (callSignal) => {
|
|
129
|
+
const headers = new Headers();
|
|
130
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
131
|
+
headers.set("User-Agent", this.userAgent);
|
|
132
|
+
resp = parseResponse(await executeHttpCall({
|
|
133
|
+
request: buildHttpRequest("DELETE", url, headers, callSignal),
|
|
134
|
+
httpClient,
|
|
135
|
+
logger: this.logger
|
|
136
|
+
}), unmarshalDeleteRegisteredModelAliasResponseSchema);
|
|
137
|
+
};
|
|
138
|
+
await executeCall(call, options);
|
|
139
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
140
|
+
return resp;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get a model version.
|
|
144
|
+
*
|
|
145
|
+
* The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
|
146
|
+
* privilege on) the parent registered model. For the latter case, the caller must also be the owner
|
|
147
|
+
* or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
|
|
148
|
+
* on the parent schema.
|
|
149
|
+
*/
|
|
150
|
+
async getModelVersion(req, options) {
|
|
151
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
152
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/versions/${String(req.versionArg ?? "")}`;
|
|
153
|
+
const params = new URLSearchParams();
|
|
154
|
+
if (req.includeAliases !== void 0) params.append("include_aliases", String(req.includeAliases));
|
|
155
|
+
if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
|
|
156
|
+
const query = params.toString();
|
|
157
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
158
|
+
let resp;
|
|
159
|
+
const call = async (callSignal) => {
|
|
160
|
+
const headers = new Headers();
|
|
161
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
162
|
+
headers.set("User-Agent", this.userAgent);
|
|
163
|
+
resp = parseResponse(await executeHttpCall({
|
|
164
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
165
|
+
httpClient,
|
|
166
|
+
logger: this.logger
|
|
167
|
+
}), unmarshalModelVersionInfoSchema);
|
|
168
|
+
};
|
|
169
|
+
await executeCall(call, options);
|
|
170
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
171
|
+
return resp;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get a model version by alias.
|
|
175
|
+
*
|
|
176
|
+
* The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
|
177
|
+
* privilege on) the registered model. For the latter case, the caller must also be the owner
|
|
178
|
+
* or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
|
|
179
|
+
* on the parent schema.
|
|
180
|
+
*/
|
|
181
|
+
async getModelVersionByAlias(req, options) {
|
|
182
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
183
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/aliases/${req.aliasArg ?? ""}`;
|
|
184
|
+
const params = new URLSearchParams();
|
|
185
|
+
if (req.includeAliases !== void 0) params.append("include_aliases", String(req.includeAliases));
|
|
186
|
+
const query = params.toString();
|
|
187
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
188
|
+
let resp;
|
|
189
|
+
const call = async (callSignal) => {
|
|
190
|
+
const headers = new Headers();
|
|
191
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
192
|
+
headers.set("User-Agent", this.userAgent);
|
|
193
|
+
resp = parseResponse(await executeHttpCall({
|
|
194
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
195
|
+
httpClient,
|
|
196
|
+
logger: this.logger
|
|
197
|
+
}), unmarshalModelVersionInfoSchema);
|
|
198
|
+
};
|
|
199
|
+
await executeCall(call, options);
|
|
200
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
201
|
+
return resp;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get a registered model.
|
|
205
|
+
*
|
|
206
|
+
* The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
|
207
|
+
* privilege on) the registered model. For the latter case, the caller must also be the owner
|
|
208
|
+
* or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
|
|
209
|
+
* on the parent schema.
|
|
210
|
+
*/
|
|
211
|
+
async getRegisteredModel(req, options) {
|
|
212
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
213
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}`;
|
|
214
|
+
const params = new URLSearchParams();
|
|
215
|
+
if (req.includeAliases !== void 0) params.append("include_aliases", String(req.includeAliases));
|
|
216
|
+
if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
|
|
217
|
+
const query = params.toString();
|
|
218
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
219
|
+
let resp;
|
|
220
|
+
const call = async (callSignal) => {
|
|
221
|
+
const headers = new Headers();
|
|
222
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
223
|
+
headers.set("User-Agent", this.userAgent);
|
|
224
|
+
resp = parseResponse(await executeHttpCall({
|
|
225
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
226
|
+
httpClient,
|
|
227
|
+
logger: this.logger
|
|
228
|
+
}), unmarshalRegisteredModelInfoSchema);
|
|
229
|
+
};
|
|
230
|
+
await executeCall(call, options);
|
|
231
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
232
|
+
return resp;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* List model versions. You can list model versions under a particular schema,
|
|
236
|
+
* or list all model versions in the current metastore.
|
|
237
|
+
*
|
|
238
|
+
* The returned models are filtered based on the privileges of the calling user.
|
|
239
|
+
* For example, the metastore admin is able to list all the model versions.
|
|
240
|
+
* A regular user needs to be the owner or have the **EXECUTE** privilege
|
|
241
|
+
* on the parent registered model to receive the model versions in the response.
|
|
242
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
243
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
244
|
+
*
|
|
245
|
+
* There is no guarantee of a specific ordering of the elements in the response. The
|
|
246
|
+
* elements in the response will not contain any aliases or tags.
|
|
247
|
+
*
|
|
248
|
+
* PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
|
|
249
|
+
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
250
|
+
*/
|
|
251
|
+
async listModelVersions(req, options) {
|
|
252
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
253
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/versions`;
|
|
254
|
+
const params = new URLSearchParams();
|
|
255
|
+
if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
|
|
256
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
257
|
+
if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
|
|
258
|
+
const query = params.toString();
|
|
259
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
260
|
+
let resp;
|
|
261
|
+
const call = async (callSignal) => {
|
|
262
|
+
const headers = new Headers();
|
|
263
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
264
|
+
headers.set("User-Agent", this.userAgent);
|
|
265
|
+
resp = parseResponse(await executeHttpCall({
|
|
266
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
267
|
+
httpClient,
|
|
268
|
+
logger: this.logger
|
|
269
|
+
}), unmarshalListModelVersionsResponseSchema);
|
|
270
|
+
};
|
|
271
|
+
await executeCall(call, options);
|
|
272
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
273
|
+
return resp;
|
|
274
|
+
}
|
|
275
|
+
async *listModelVersionsIter(req, options) {
|
|
276
|
+
const pageReq = { ...req };
|
|
277
|
+
for (;;) {
|
|
278
|
+
const resp = await this.listModelVersions(pageReq, options);
|
|
279
|
+
for (const item of resp.modelVersions ?? []) yield item;
|
|
280
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
281
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* List registered models. You can list registered models under a particular schema,
|
|
286
|
+
* or list all registered models in the current metastore.
|
|
287
|
+
*
|
|
288
|
+
* The returned models are filtered based on the privileges of the calling user.
|
|
289
|
+
* For example, the metastore admin is able to list all the registered models.
|
|
290
|
+
* A regular user needs to be the owner or have the **EXECUTE** privilege
|
|
291
|
+
* on the registered model to receive the registered models in the response.
|
|
292
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
293
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
294
|
+
*
|
|
295
|
+
* There is no guarantee of a specific ordering of the elements in the response.
|
|
296
|
+
*
|
|
297
|
+
* PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
|
|
298
|
+
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
299
|
+
*/
|
|
300
|
+
async listRegisteredModels(req, options) {
|
|
301
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
302
|
+
const url = `${host}/api/2.1/unity-catalog/models`;
|
|
303
|
+
const params = new URLSearchParams();
|
|
304
|
+
if (req.catalogName !== void 0) params.append("catalog_name", req.catalogName);
|
|
305
|
+
if (req.schemaName !== void 0) params.append("schema_name", req.schemaName);
|
|
306
|
+
if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
|
|
307
|
+
if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
|
|
308
|
+
if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
|
|
309
|
+
const query = params.toString();
|
|
310
|
+
const fullUrl = query !== "" ? `${url}?${query}` : url;
|
|
311
|
+
let resp;
|
|
312
|
+
const call = async (callSignal) => {
|
|
313
|
+
const headers = new Headers();
|
|
314
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
315
|
+
headers.set("User-Agent", this.userAgent);
|
|
316
|
+
resp = parseResponse(await executeHttpCall({
|
|
317
|
+
request: buildHttpRequest("GET", fullUrl, headers, callSignal),
|
|
318
|
+
httpClient,
|
|
319
|
+
logger: this.logger
|
|
320
|
+
}), unmarshalListRegisteredModelsResponseSchema);
|
|
321
|
+
};
|
|
322
|
+
await executeCall(call, options);
|
|
323
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
324
|
+
return resp;
|
|
325
|
+
}
|
|
326
|
+
async *listRegisteredModelsIter(req, options) {
|
|
327
|
+
const pageReq = { ...req };
|
|
328
|
+
for (;;) {
|
|
329
|
+
const resp = await this.listRegisteredModels(pageReq, options);
|
|
330
|
+
for (const item of resp.registeredModels ?? []) yield item;
|
|
331
|
+
if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
|
|
332
|
+
pageReq.pageToken = resp.nextPageToken;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Set an alias on the specified registered model.
|
|
337
|
+
*
|
|
338
|
+
* The caller must be a metastore admin or an owner of the registered model.
|
|
339
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
340
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
341
|
+
*/
|
|
342
|
+
async setRegisteredModelAlias(req, options) {
|
|
343
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
344
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/aliases/${req.aliasArg ?? ""}`;
|
|
345
|
+
const body = marshalRequest(req, marshalSetRegisteredModelAliasRequestSchema);
|
|
346
|
+
let resp;
|
|
347
|
+
const call = async (callSignal) => {
|
|
348
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
349
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
350
|
+
headers.set("User-Agent", this.userAgent);
|
|
351
|
+
resp = parseResponse(await executeHttpCall({
|
|
352
|
+
request: buildHttpRequest("PUT", url, headers, callSignal, body),
|
|
353
|
+
httpClient,
|
|
354
|
+
logger: this.logger
|
|
355
|
+
}), unmarshalRegisteredModelAliasInfoSchema);
|
|
356
|
+
};
|
|
357
|
+
await executeCall(call, options);
|
|
358
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
359
|
+
return resp;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Updates the specified model version.
|
|
363
|
+
*
|
|
364
|
+
* The caller must be a metastore admin or an owner of the parent registered model.
|
|
365
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
366
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
367
|
+
*
|
|
368
|
+
* Currently only the comment of the model version can be updated.
|
|
369
|
+
*/
|
|
370
|
+
async updateModelVersion(req, options) {
|
|
371
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
372
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}/versions/${String(req.versionArg ?? "")}`;
|
|
373
|
+
const body = marshalRequest(req, marshalUpdateModelVersionRequestSchema);
|
|
374
|
+
let resp;
|
|
375
|
+
const call = async (callSignal) => {
|
|
376
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
377
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
378
|
+
headers.set("User-Agent", this.userAgent);
|
|
379
|
+
resp = parseResponse(await executeHttpCall({
|
|
380
|
+
request: buildHttpRequest("PATCH", url, headers, callSignal, body),
|
|
381
|
+
httpClient,
|
|
382
|
+
logger: this.logger
|
|
383
|
+
}), unmarshalModelVersionInfoSchema);
|
|
384
|
+
};
|
|
385
|
+
await executeCall(call, options);
|
|
386
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
387
|
+
return resp;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Updates the specified registered model.
|
|
391
|
+
*
|
|
392
|
+
* The caller must be a metastore admin or an owner of the registered model.
|
|
393
|
+
* For the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
|
394
|
+
* privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
|
|
395
|
+
*
|
|
396
|
+
* Currently only the name, the owner or the comment of the registered model can be updated.
|
|
397
|
+
*/
|
|
398
|
+
async updateRegisteredModel(req, options) {
|
|
399
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
400
|
+
const url = `${host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ""}`;
|
|
401
|
+
const body = marshalRequest(req, marshalUpdateRegisteredModelRequestSchema);
|
|
402
|
+
let resp;
|
|
403
|
+
const call = async (callSignal) => {
|
|
404
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
405
|
+
if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
|
|
406
|
+
headers.set("User-Agent", this.userAgent);
|
|
407
|
+
resp = parseResponse(await executeHttpCall({
|
|
408
|
+
request: buildHttpRequest("PATCH", url, headers, callSignal, body),
|
|
409
|
+
httpClient,
|
|
410
|
+
logger: this.logger
|
|
411
|
+
}), unmarshalRegisteredModelInfoSchema);
|
|
412
|
+
};
|
|
413
|
+
await executeCall(call, options);
|
|
414
|
+
if (resp === void 0) throw new Error("operation completed without a result.");
|
|
415
|
+
return resp;
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
//#endregion
|
|
420
|
+
export { RegisteredModelsClient };
|
|
528
421
|
//# sourceMappingURL=client.js.map
|