@databricks/sdk-modelregistry 0.1.0-dev.2 → 0.1.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/v1/client.ts DELETED
@@ -1,1435 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
- import {createDefault} from '@databricks/sdk-core/clientinfo';
5
- import type {Logger} from '@databricks/sdk-core/logger';
6
- import {NoOpLogger} from '@databricks/sdk-core/logger';
7
- import type {CallOptions} from '@databricks/sdk-options/call';
8
- import type {ClientOptions} from '@databricks/sdk-options/client';
9
- import type {HttpClient} from '@databricks/sdk-core/http';
10
- import {newHttpClient} from './transport';
11
- import {
12
- buildHttpRequest,
13
- executeCall,
14
- executeHttpCall,
15
- marshalRequest,
16
- parseResponse,
17
- } from './utils';
18
- import pkgJson from '../../package.json' with {type: 'json'};
19
- import type {
20
- ApproveTransitionRequest,
21
- ApproveTransitionRequest_Response,
22
- CreateCommentRequest,
23
- CreateCommentRequest_Response,
24
- CreateModelVersionRequest,
25
- CreateModelVersionRequest_Response,
26
- CreateRegisteredModelRequest,
27
- CreateRegisteredModelRequest_Response,
28
- CreateRegistryWebhookRequest,
29
- CreateRegistryWebhookRequest_Response,
30
- CreateTransitionRequest,
31
- CreateTransitionRequest_Response,
32
- DeleteCommentRequest,
33
- DeleteCommentRequest_Response,
34
- DeleteModelVersionRequest,
35
- DeleteModelVersionRequest_Response,
36
- DeleteModelVersionTagRequest,
37
- DeleteModelVersionTagRequest_Response,
38
- DeleteRegisteredModelRequest,
39
- DeleteRegisteredModelRequest_Response,
40
- DeleteRegisteredModelTagRequest,
41
- DeleteRegisteredModelTagRequest_Response,
42
- DeleteRegistryWebhookRequest,
43
- DeleteRegistryWebhookRequest_Response,
44
- DeleteTransitionRequest,
45
- DeleteTransitionRequest_Response,
46
- GetModelVersionDownloadUriRequest,
47
- GetModelVersionDownloadUriRequest_Response,
48
- GetModelVersionRequest,
49
- GetModelVersionRequest_Response,
50
- GetRegisteredModelDatabricksRequest,
51
- GetRegisteredModelDatabricksRequest_Response,
52
- ListLatestVersionsRequest,
53
- ListLatestVersionsRequest_Response,
54
- ListRegisteredModelsRequest,
55
- ListRegisteredModelsRequest_Response,
56
- ListRegistryWebhooksRequest,
57
- ListRegistryWebhooksRequest_Response,
58
- ListTransitionRequest,
59
- ListTransitionRequest_Response,
60
- ModelVersion,
61
- RegisteredModel,
62
- RegistryWebhook,
63
- RejectTransitionRequest,
64
- RejectTransitionRequest_Response,
65
- RenameRegisteredModelRequest,
66
- RenameRegisteredModelRequest_Response,
67
- SearchModelVersionsRequest,
68
- SearchModelVersionsRequest_Response,
69
- SearchRegisteredModelsRequest,
70
- SearchRegisteredModelsRequest_Response,
71
- SetModelVersionTagRequest,
72
- SetModelVersionTagRequest_Response,
73
- SetRegisteredModelTagRequest,
74
- SetRegisteredModelTagRequest_Response,
75
- TestRegistryWebhookRequest,
76
- TestRegistryWebhookRequest_Response,
77
- TransitionModelVersionStageDatabricksRequest,
78
- TransitionModelVersionStageDatabricksRequest_Response,
79
- UpdateCommentRequest,
80
- UpdateCommentRequest_Response,
81
- UpdateModelVersionRequest,
82
- UpdateModelVersionRequest_Response,
83
- UpdateRegisteredModelRequest,
84
- UpdateRegisteredModelRequest_Response,
85
- UpdateRegistryWebhookRequest,
86
- UpdateRegistryWebhookRequest_Response,
87
- } from './model';
88
- import {
89
- marshalApproveTransitionRequestSchema,
90
- marshalCreateCommentRequestSchema,
91
- marshalCreateModelVersionRequestSchema,
92
- marshalCreateRegisteredModelRequestSchema,
93
- marshalCreateRegistryWebhookRequestSchema,
94
- marshalCreateTransitionRequestSchema,
95
- marshalListLatestVersionsRequestSchema,
96
- marshalRejectTransitionRequestSchema,
97
- marshalRenameRegisteredModelRequestSchema,
98
- marshalSetModelVersionTagRequestSchema,
99
- marshalSetRegisteredModelTagRequestSchema,
100
- marshalTestRegistryWebhookRequestSchema,
101
- marshalTransitionModelVersionStageDatabricksRequestSchema,
102
- marshalUpdateCommentRequestSchema,
103
- marshalUpdateModelVersionRequestSchema,
104
- marshalUpdateRegisteredModelRequestSchema,
105
- marshalUpdateRegistryWebhookRequestSchema,
106
- unmarshalApproveTransitionRequest_ResponseSchema,
107
- unmarshalCreateCommentRequest_ResponseSchema,
108
- unmarshalCreateModelVersionRequest_ResponseSchema,
109
- unmarshalCreateRegisteredModelRequest_ResponseSchema,
110
- unmarshalCreateRegistryWebhookRequest_ResponseSchema,
111
- unmarshalCreateTransitionRequest_ResponseSchema,
112
- unmarshalDeleteCommentRequest_ResponseSchema,
113
- unmarshalDeleteModelVersionRequest_ResponseSchema,
114
- unmarshalDeleteModelVersionTagRequest_ResponseSchema,
115
- unmarshalDeleteRegisteredModelRequest_ResponseSchema,
116
- unmarshalDeleteRegisteredModelTagRequest_ResponseSchema,
117
- unmarshalDeleteRegistryWebhookRequest_ResponseSchema,
118
- unmarshalDeleteTransitionRequest_ResponseSchema,
119
- unmarshalGetModelVersionDownloadUriRequest_ResponseSchema,
120
- unmarshalGetModelVersionRequest_ResponseSchema,
121
- unmarshalGetRegisteredModelDatabricksRequest_ResponseSchema,
122
- unmarshalListLatestVersionsRequest_ResponseSchema,
123
- unmarshalListRegisteredModelsRequest_ResponseSchema,
124
- unmarshalListRegistryWebhooksRequest_ResponseSchema,
125
- unmarshalListTransitionRequest_ResponseSchema,
126
- unmarshalRejectTransitionRequest_ResponseSchema,
127
- unmarshalRenameRegisteredModelRequest_ResponseSchema,
128
- unmarshalSearchModelVersionsRequest_ResponseSchema,
129
- unmarshalSearchRegisteredModelsRequest_ResponseSchema,
130
- unmarshalSetModelVersionTagRequest_ResponseSchema,
131
- unmarshalSetRegisteredModelTagRequest_ResponseSchema,
132
- unmarshalTestRegistryWebhookRequest_ResponseSchema,
133
- unmarshalTransitionModelVersionStageDatabricksRequest_ResponseSchema,
134
- unmarshalUpdateCommentRequest_ResponseSchema,
135
- unmarshalUpdateModelVersionRequest_ResponseSchema,
136
- unmarshalUpdateRegisteredModelRequest_ResponseSchema,
137
- unmarshalUpdateRegistryWebhookRequest_ResponseSchema,
138
- } from './model';
139
-
140
- // Package identity segment for this client to be used in the User-Agent header.
141
- const PACKAGE_SEGMENT = {
142
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
143
- value: pkgJson.version,
144
- };
145
-
146
- export class ModelRegistryClient {
147
- private readonly host: string;
148
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
149
- // When set, workspace-level methods send X-Databricks-Org-Id on every
150
- // request.
151
- private readonly workspaceId: string | undefined;
152
- private readonly httpClient: HttpClient;
153
- private readonly logger: Logger;
154
- // User-Agent header value. Composed once at construction from
155
- // createDefault() merged with this package's identity and the active
156
- // credential's name.
157
- private readonly userAgent: string;
158
-
159
- constructor(options: ClientOptions) {
160
- if (options.host === undefined) {
161
- throw new Error('Host is required.');
162
- }
163
- this.host = options.host.replace(/\/$/, '');
164
- this.workspaceId = options.workspaceId;
165
- this.logger = options.logger ?? new NoOpLogger();
166
- const info = createDefault()
167
- .with(PACKAGE_SEGMENT)
168
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
169
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
170
- this.userAgent = info.toString();
171
- this.httpClient = newHttpClient(options);
172
- }
173
-
174
- /** Approves a model version stage transition request. */
175
- async approveTransitionRequest(
176
- req: ApproveTransitionRequest,
177
- options?: CallOptions
178
- ): Promise<ApproveTransitionRequest_Response> {
179
- const url = `${this.host}/api/2.0/mlflow/transition-requests/approve`;
180
- const body = marshalRequest(req, marshalApproveTransitionRequestSchema);
181
- let resp: ApproveTransitionRequest_Response | undefined;
182
- const call = async (callSignal?: AbortSignal): Promise<void> => {
183
- const headers = new Headers({'Content-Type': 'application/json'});
184
- if (this.workspaceId !== undefined) {
185
- headers.set('X-Databricks-Org-Id', this.workspaceId);
186
- }
187
- headers.set('User-Agent', this.userAgent);
188
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
189
- const respBody = await executeHttpCall({
190
- request: httpReq,
191
- httpClient: this.httpClient,
192
- logger: this.logger,
193
- });
194
- resp = parseResponse(
195
- respBody,
196
- unmarshalApproveTransitionRequest_ResponseSchema
197
- );
198
- };
199
- await executeCall(call, options);
200
- if (resp === undefined) {
201
- throw new Error('operation completed without a result.');
202
- }
203
- return resp;
204
- }
205
-
206
- /**
207
- * Posts a comment on a model version. A comment can be submitted either by a user or programmatically to display
208
- * relevant information about the model. For example, test results or deployment errors.
209
- */
210
- async createComment(
211
- req: CreateCommentRequest,
212
- options?: CallOptions
213
- ): Promise<CreateCommentRequest_Response> {
214
- const url = `${this.host}/api/2.0/mlflow/comments/create`;
215
- const body = marshalRequest(req, marshalCreateCommentRequestSchema);
216
- let resp: CreateCommentRequest_Response | undefined;
217
- const call = async (callSignal?: AbortSignal): Promise<void> => {
218
- const headers = new Headers({'Content-Type': 'application/json'});
219
- if (this.workspaceId !== undefined) {
220
- headers.set('X-Databricks-Org-Id', this.workspaceId);
221
- }
222
- headers.set('User-Agent', this.userAgent);
223
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
224
- const respBody = await executeHttpCall({
225
- request: httpReq,
226
- httpClient: this.httpClient,
227
- logger: this.logger,
228
- });
229
- resp = parseResponse(
230
- respBody,
231
- unmarshalCreateCommentRequest_ResponseSchema
232
- );
233
- };
234
- await executeCall(call, options);
235
- if (resp === undefined) {
236
- throw new Error('operation completed without a result.');
237
- }
238
- return resp;
239
- }
240
-
241
- /**
242
- * **NOTE:** This endpoint is in Public Preview.
243
- * Creates a registry webhook.
244
- */
245
- async createRegistryWebhook(
246
- req: CreateRegistryWebhookRequest,
247
- options?: CallOptions
248
- ): Promise<CreateRegistryWebhookRequest_Response> {
249
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/create`;
250
- const body = marshalRequest(req, marshalCreateRegistryWebhookRequestSchema);
251
- let resp: CreateRegistryWebhookRequest_Response | undefined;
252
- const call = async (callSignal?: AbortSignal): Promise<void> => {
253
- const headers = new Headers({'Content-Type': 'application/json'});
254
- if (this.workspaceId !== undefined) {
255
- headers.set('X-Databricks-Org-Id', this.workspaceId);
256
- }
257
- headers.set('User-Agent', this.userAgent);
258
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
259
- const respBody = await executeHttpCall({
260
- request: httpReq,
261
- httpClient: this.httpClient,
262
- logger: this.logger,
263
- });
264
- resp = parseResponse(
265
- respBody,
266
- unmarshalCreateRegistryWebhookRequest_ResponseSchema
267
- );
268
- };
269
- await executeCall(call, options);
270
- if (resp === undefined) {
271
- throw new Error('operation completed without a result.');
272
- }
273
- return resp;
274
- }
275
-
276
- /** Creates a model version stage transition request. */
277
- async createTransitionRequest(
278
- req: CreateTransitionRequest,
279
- options?: CallOptions
280
- ): Promise<CreateTransitionRequest_Response> {
281
- const url = `${this.host}/api/2.0/mlflow/transition-requests/create`;
282
- const body = marshalRequest(req, marshalCreateTransitionRequestSchema);
283
- let resp: CreateTransitionRequest_Response | undefined;
284
- const call = async (callSignal?: AbortSignal): Promise<void> => {
285
- const headers = new Headers({'Content-Type': 'application/json'});
286
- if (this.workspaceId !== undefined) {
287
- headers.set('X-Databricks-Org-Id', this.workspaceId);
288
- }
289
- headers.set('User-Agent', this.userAgent);
290
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
291
- const respBody = await executeHttpCall({
292
- request: httpReq,
293
- httpClient: this.httpClient,
294
- logger: this.logger,
295
- });
296
- resp = parseResponse(
297
- respBody,
298
- unmarshalCreateTransitionRequest_ResponseSchema
299
- );
300
- };
301
- await executeCall(call, options);
302
- if (resp === undefined) {
303
- throw new Error('operation completed without a result.');
304
- }
305
- return resp;
306
- }
307
-
308
- /** Deletes a comment on a model version. */
309
- async deleteComment(
310
- req: DeleteCommentRequest,
311
- options?: CallOptions
312
- ): Promise<DeleteCommentRequest_Response> {
313
- const url = `${this.host}/api/2.0/mlflow/comments/delete`;
314
- const params = new URLSearchParams();
315
- if (req.id !== undefined) {
316
- params.append('id', req.id);
317
- }
318
- const query = params.toString();
319
- const fullUrl = query !== '' ? `${url}?${query}` : url;
320
- let resp: DeleteCommentRequest_Response | undefined;
321
- const call = async (callSignal?: AbortSignal): Promise<void> => {
322
- const headers = new Headers();
323
- if (this.workspaceId !== undefined) {
324
- headers.set('X-Databricks-Org-Id', this.workspaceId);
325
- }
326
- headers.set('User-Agent', this.userAgent);
327
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
328
- const respBody = await executeHttpCall({
329
- request: httpReq,
330
- httpClient: this.httpClient,
331
- logger: this.logger,
332
- });
333
- resp = parseResponse(
334
- respBody,
335
- unmarshalDeleteCommentRequest_ResponseSchema
336
- );
337
- };
338
- await executeCall(call, options);
339
- if (resp === undefined) {
340
- throw new Error('operation completed without a result.');
341
- }
342
- return resp;
343
- }
344
-
345
- /**
346
- * **NOTE:** This endpoint is in Public Preview.
347
- * Deletes a registry webhook.
348
- */
349
- async deleteRegistryWebhook(
350
- req: DeleteRegistryWebhookRequest,
351
- options?: CallOptions
352
- ): Promise<DeleteRegistryWebhookRequest_Response> {
353
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/delete`;
354
- const params = new URLSearchParams();
355
- if (req.id !== undefined) {
356
- params.append('id', req.id);
357
- }
358
- const query = params.toString();
359
- const fullUrl = query !== '' ? `${url}?${query}` : url;
360
- let resp: DeleteRegistryWebhookRequest_Response | undefined;
361
- const call = async (callSignal?: AbortSignal): Promise<void> => {
362
- const headers = new Headers();
363
- if (this.workspaceId !== undefined) {
364
- headers.set('X-Databricks-Org-Id', this.workspaceId);
365
- }
366
- headers.set('User-Agent', this.userAgent);
367
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
368
- const respBody = await executeHttpCall({
369
- request: httpReq,
370
- httpClient: this.httpClient,
371
- logger: this.logger,
372
- });
373
- resp = parseResponse(
374
- respBody,
375
- unmarshalDeleteRegistryWebhookRequest_ResponseSchema
376
- );
377
- };
378
- await executeCall(call, options);
379
- if (resp === undefined) {
380
- throw new Error('operation completed without a result.');
381
- }
382
- return resp;
383
- }
384
-
385
- /** Cancels a model version stage transition request. */
386
- async deleteTransitionRequest(
387
- req: DeleteTransitionRequest,
388
- options?: CallOptions
389
- ): Promise<DeleteTransitionRequest_Response> {
390
- const url = `${this.host}/api/2.0/mlflow/transition-requests/delete`;
391
- const params = new URLSearchParams();
392
- if (req.name !== undefined) {
393
- params.append('name', req.name);
394
- }
395
- if (req.version !== undefined) {
396
- params.append('version', req.version);
397
- }
398
- if (req.stage !== undefined) {
399
- params.append('stage', req.stage);
400
- }
401
- if (req.creator !== undefined) {
402
- params.append('creator', req.creator);
403
- }
404
- if (req.comment !== undefined) {
405
- params.append('comment', req.comment);
406
- }
407
- const query = params.toString();
408
- const fullUrl = query !== '' ? `${url}?${query}` : url;
409
- let resp: DeleteTransitionRequest_Response | undefined;
410
- const call = async (callSignal?: AbortSignal): Promise<void> => {
411
- const headers = new Headers();
412
- if (this.workspaceId !== undefined) {
413
- headers.set('X-Databricks-Org-Id', this.workspaceId);
414
- }
415
- headers.set('User-Agent', this.userAgent);
416
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
417
- const respBody = await executeHttpCall({
418
- request: httpReq,
419
- httpClient: this.httpClient,
420
- logger: this.logger,
421
- });
422
- resp = parseResponse(
423
- respBody,
424
- unmarshalDeleteTransitionRequest_ResponseSchema
425
- );
426
- };
427
- await executeCall(call, options);
428
- if (resp === undefined) {
429
- throw new Error('operation completed without a result.');
430
- }
431
- return resp;
432
- }
433
-
434
- /**
435
- * Get the details of a model.
436
- * This is a <Databricks> workspace version of the [MLflow endpoint](https://www.mlflow.org/docs/latest/rest-api.html#get-registeredmodel)
437
- * that also returns the model's <Databricks> workspace ID and the permission level of the requesting user on the model.
438
- */
439
- async getRegisteredModelDatabricks(
440
- req: GetRegisteredModelDatabricksRequest,
441
- options?: CallOptions
442
- ): Promise<GetRegisteredModelDatabricksRequest_Response> {
443
- const url = `${this.host}/api/2.0/mlflow/databricks/registered-models/get`;
444
- const params = new URLSearchParams();
445
- if (req.name !== undefined) {
446
- params.append('name', req.name);
447
- }
448
- const query = params.toString();
449
- const fullUrl = query !== '' ? `${url}?${query}` : url;
450
- let resp: GetRegisteredModelDatabricksRequest_Response | undefined;
451
- const call = async (callSignal?: AbortSignal): Promise<void> => {
452
- const headers = new Headers();
453
- if (this.workspaceId !== undefined) {
454
- headers.set('X-Databricks-Org-Id', this.workspaceId);
455
- }
456
- headers.set('User-Agent', this.userAgent);
457
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
458
- const respBody = await executeHttpCall({
459
- request: httpReq,
460
- httpClient: this.httpClient,
461
- logger: this.logger,
462
- });
463
- resp = parseResponse(
464
- respBody,
465
- unmarshalGetRegisteredModelDatabricksRequest_ResponseSchema
466
- );
467
- };
468
- await executeCall(call, options);
469
- if (resp === undefined) {
470
- throw new Error('operation completed without a result.');
471
- }
472
- return resp;
473
- }
474
-
475
- /**
476
- * **NOTE:** This endpoint is in Public Preview.
477
- * Lists all registry webhooks.
478
- */
479
- async listRegistryWebhooks(
480
- req: ListRegistryWebhooksRequest,
481
- options?: CallOptions
482
- ): Promise<ListRegistryWebhooksRequest_Response> {
483
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/list`;
484
- const params = new URLSearchParams();
485
- if (req.modelName !== undefined) {
486
- params.append('model_name', req.modelName);
487
- }
488
- if (req.events !== undefined) {
489
- params.append('events', String(req.events));
490
- }
491
- if (req.pageToken !== undefined) {
492
- params.append('page_token', req.pageToken);
493
- }
494
- if (req.maxResults !== undefined) {
495
- params.append('max_results', String(req.maxResults));
496
- }
497
- const query = params.toString();
498
- const fullUrl = query !== '' ? `${url}?${query}` : url;
499
- let resp: ListRegistryWebhooksRequest_Response | undefined;
500
- const call = async (callSignal?: AbortSignal): Promise<void> => {
501
- const headers = new Headers();
502
- if (this.workspaceId !== undefined) {
503
- headers.set('X-Databricks-Org-Id', this.workspaceId);
504
- }
505
- headers.set('User-Agent', this.userAgent);
506
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
507
- const respBody = await executeHttpCall({
508
- request: httpReq,
509
- httpClient: this.httpClient,
510
- logger: this.logger,
511
- });
512
- resp = parseResponse(
513
- respBody,
514
- unmarshalListRegistryWebhooksRequest_ResponseSchema
515
- );
516
- };
517
- await executeCall(call, options);
518
- if (resp === undefined) {
519
- throw new Error('operation completed without a result.');
520
- }
521
- return resp;
522
- }
523
-
524
- async *listRegistryWebhooksIter(
525
- req: ListRegistryWebhooksRequest,
526
- options?: CallOptions
527
- ): AsyncGenerator<RegistryWebhook> {
528
- const pageReq: ListRegistryWebhooksRequest = {...req};
529
- for (;;) {
530
- const resp = await this.listRegistryWebhooks(pageReq, options);
531
- for (const item of resp.webhooks ?? []) {
532
- yield item;
533
- }
534
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
535
- return;
536
- }
537
- pageReq.pageToken = resp.nextPageToken;
538
- }
539
- }
540
-
541
- /** Gets a list of all open stage transition requests for the model version. */
542
- async listTransitionsRequest(
543
- req: ListTransitionRequest,
544
- options?: CallOptions
545
- ): Promise<ListTransitionRequest_Response> {
546
- const url = `${this.host}/api/2.0/mlflow/transition-requests/list`;
547
- const params = new URLSearchParams();
548
- if (req.name !== undefined) {
549
- params.append('name', req.name);
550
- }
551
- if (req.version !== undefined) {
552
- params.append('version', req.version);
553
- }
554
- const query = params.toString();
555
- const fullUrl = query !== '' ? `${url}?${query}` : url;
556
- let resp: ListTransitionRequest_Response | undefined;
557
- const call = async (callSignal?: AbortSignal): Promise<void> => {
558
- const headers = new Headers();
559
- if (this.workspaceId !== undefined) {
560
- headers.set('X-Databricks-Org-Id', this.workspaceId);
561
- }
562
- headers.set('User-Agent', this.userAgent);
563
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
564
- const respBody = await executeHttpCall({
565
- request: httpReq,
566
- httpClient: this.httpClient,
567
- logger: this.logger,
568
- });
569
- resp = parseResponse(
570
- respBody,
571
- unmarshalListTransitionRequest_ResponseSchema
572
- );
573
- };
574
- await executeCall(call, options);
575
- if (resp === undefined) {
576
- throw new Error('operation completed without a result.');
577
- }
578
- return resp;
579
- }
580
-
581
- /** Rejects a model version stage transition request. */
582
- async rejectTransitionRequest(
583
- req: RejectTransitionRequest,
584
- options?: CallOptions
585
- ): Promise<RejectTransitionRequest_Response> {
586
- const url = `${this.host}/api/2.0/mlflow/transition-requests/reject`;
587
- const body = marshalRequest(req, marshalRejectTransitionRequestSchema);
588
- let resp: RejectTransitionRequest_Response | undefined;
589
- const call = async (callSignal?: AbortSignal): Promise<void> => {
590
- const headers = new Headers({'Content-Type': 'application/json'});
591
- if (this.workspaceId !== undefined) {
592
- headers.set('X-Databricks-Org-Id', this.workspaceId);
593
- }
594
- headers.set('User-Agent', this.userAgent);
595
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
596
- const respBody = await executeHttpCall({
597
- request: httpReq,
598
- httpClient: this.httpClient,
599
- logger: this.logger,
600
- });
601
- resp = parseResponse(
602
- respBody,
603
- unmarshalRejectTransitionRequest_ResponseSchema
604
- );
605
- };
606
- await executeCall(call, options);
607
- if (resp === undefined) {
608
- throw new Error('operation completed without a result.');
609
- }
610
- return resp;
611
- }
612
-
613
- /**
614
- * **NOTE:** This endpoint is in Public Preview.
615
- * Tests a registry webhook.
616
- */
617
- async testRegistryWebhook(
618
- req: TestRegistryWebhookRequest,
619
- options?: CallOptions
620
- ): Promise<TestRegistryWebhookRequest_Response> {
621
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/test`;
622
- const body = marshalRequest(req, marshalTestRegistryWebhookRequestSchema);
623
- let resp: TestRegistryWebhookRequest_Response | undefined;
624
- const call = async (callSignal?: AbortSignal): Promise<void> => {
625
- const headers = new Headers({'Content-Type': 'application/json'});
626
- if (this.workspaceId !== undefined) {
627
- headers.set('X-Databricks-Org-Id', this.workspaceId);
628
- }
629
- headers.set('User-Agent', this.userAgent);
630
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
631
- const respBody = await executeHttpCall({
632
- request: httpReq,
633
- httpClient: this.httpClient,
634
- logger: this.logger,
635
- });
636
- resp = parseResponse(
637
- respBody,
638
- unmarshalTestRegistryWebhookRequest_ResponseSchema
639
- );
640
- };
641
- await executeCall(call, options);
642
- if (resp === undefined) {
643
- throw new Error('operation completed without a result.');
644
- }
645
- return resp;
646
- }
647
-
648
- /**
649
- * Transition a model version's stage.
650
- * This is a <Databricks> workspace version of the [MLflow endpoint](https://www.mlflow.org/docs/latest/rest-api.html#transition-modelversion-stage)
651
- * that also accepts a comment associated with the transition to be recorded.
652
- */
653
- async transitionModelVersionStageDatabricks(
654
- req: TransitionModelVersionStageDatabricksRequest,
655
- options?: CallOptions
656
- ): Promise<TransitionModelVersionStageDatabricksRequest_Response> {
657
- const url = `${this.host}/api/2.0/mlflow/databricks/model-versions/transition-stage`;
658
- const body = marshalRequest(
659
- req,
660
- marshalTransitionModelVersionStageDatabricksRequestSchema
661
- );
662
- let resp: TransitionModelVersionStageDatabricksRequest_Response | undefined;
663
- const call = async (callSignal?: AbortSignal): Promise<void> => {
664
- const headers = new Headers({'Content-Type': 'application/json'});
665
- if (this.workspaceId !== undefined) {
666
- headers.set('X-Databricks-Org-Id', this.workspaceId);
667
- }
668
- headers.set('User-Agent', this.userAgent);
669
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
670
- const respBody = await executeHttpCall({
671
- request: httpReq,
672
- httpClient: this.httpClient,
673
- logger: this.logger,
674
- });
675
- resp = parseResponse(
676
- respBody,
677
- unmarshalTransitionModelVersionStageDatabricksRequest_ResponseSchema
678
- );
679
- };
680
- await executeCall(call, options);
681
- if (resp === undefined) {
682
- throw new Error('operation completed without a result.');
683
- }
684
- return resp;
685
- }
686
-
687
- /** Post an edit to a comment on a model version. */
688
- async updateComment(
689
- req: UpdateCommentRequest,
690
- options?: CallOptions
691
- ): Promise<UpdateCommentRequest_Response> {
692
- const url = `${this.host}/api/2.0/mlflow/comments/update`;
693
- const body = marshalRequest(req, marshalUpdateCommentRequestSchema);
694
- let resp: UpdateCommentRequest_Response | undefined;
695
- const call = async (callSignal?: AbortSignal): Promise<void> => {
696
- const headers = new Headers({'Content-Type': 'application/json'});
697
- if (this.workspaceId !== undefined) {
698
- headers.set('X-Databricks-Org-Id', this.workspaceId);
699
- }
700
- headers.set('User-Agent', this.userAgent);
701
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
702
- const respBody = await executeHttpCall({
703
- request: httpReq,
704
- httpClient: this.httpClient,
705
- logger: this.logger,
706
- });
707
- resp = parseResponse(
708
- respBody,
709
- unmarshalUpdateCommentRequest_ResponseSchema
710
- );
711
- };
712
- await executeCall(call, options);
713
- if (resp === undefined) {
714
- throw new Error('operation completed without a result.');
715
- }
716
- return resp;
717
- }
718
-
719
- /**
720
- * **NOTE:** This endpoint is in Public Preview.
721
- * Updates a registry webhook.
722
- */
723
- async updateRegistryWebhook(
724
- req: UpdateRegistryWebhookRequest,
725
- options?: CallOptions
726
- ): Promise<UpdateRegistryWebhookRequest_Response> {
727
- const url = `${this.host}/api/2.0/mlflow/registry-webhooks/update`;
728
- const body = marshalRequest(req, marshalUpdateRegistryWebhookRequestSchema);
729
- let resp: UpdateRegistryWebhookRequest_Response | undefined;
730
- const call = async (callSignal?: AbortSignal): Promise<void> => {
731
- const headers = new Headers({'Content-Type': 'application/json'});
732
- if (this.workspaceId !== undefined) {
733
- headers.set('X-Databricks-Org-Id', this.workspaceId);
734
- }
735
- headers.set('User-Agent', this.userAgent);
736
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
737
- const respBody = await executeHttpCall({
738
- request: httpReq,
739
- httpClient: this.httpClient,
740
- logger: this.logger,
741
- });
742
- resp = parseResponse(
743
- respBody,
744
- unmarshalUpdateRegistryWebhookRequest_ResponseSchema
745
- );
746
- };
747
- await executeCall(call, options);
748
- if (resp === undefined) {
749
- throw new Error('operation completed without a result.');
750
- }
751
- return resp;
752
- }
753
-
754
- /** Creates a model version. */
755
- async createModelVersion(
756
- req: CreateModelVersionRequest,
757
- options?: CallOptions
758
- ): Promise<CreateModelVersionRequest_Response> {
759
- const url = `${this.host}/api/2.0/mlflow/model-versions/create`;
760
- const body = marshalRequest(req, marshalCreateModelVersionRequestSchema);
761
- let resp: CreateModelVersionRequest_Response | undefined;
762
- const call = async (callSignal?: AbortSignal): Promise<void> => {
763
- const headers = new Headers({'Content-Type': 'application/json'});
764
- if (this.workspaceId !== undefined) {
765
- headers.set('X-Databricks-Org-Id', this.workspaceId);
766
- }
767
- headers.set('User-Agent', this.userAgent);
768
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
769
- const respBody = await executeHttpCall({
770
- request: httpReq,
771
- httpClient: this.httpClient,
772
- logger: this.logger,
773
- });
774
- resp = parseResponse(
775
- respBody,
776
- unmarshalCreateModelVersionRequest_ResponseSchema
777
- );
778
- };
779
- await executeCall(call, options);
780
- if (resp === undefined) {
781
- throw new Error('operation completed without a result.');
782
- }
783
- return resp;
784
- }
785
-
786
- /**
787
- * Creates a new registered model with the name specified in the request body.
788
- * Throws `RESOURCE_ALREADY_EXISTS` if a registered model with the given name exists.
789
- */
790
- async createRegisteredModel(
791
- req: CreateRegisteredModelRequest,
792
- options?: CallOptions
793
- ): Promise<CreateRegisteredModelRequest_Response> {
794
- const url = `${this.host}/api/2.0/mlflow/registered-models/create`;
795
- const body = marshalRequest(req, marshalCreateRegisteredModelRequestSchema);
796
- let resp: CreateRegisteredModelRequest_Response | undefined;
797
- const call = async (callSignal?: AbortSignal): Promise<void> => {
798
- const headers = new Headers({'Content-Type': 'application/json'});
799
- if (this.workspaceId !== undefined) {
800
- headers.set('X-Databricks-Org-Id', this.workspaceId);
801
- }
802
- headers.set('User-Agent', this.userAgent);
803
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
804
- const respBody = await executeHttpCall({
805
- request: httpReq,
806
- httpClient: this.httpClient,
807
- logger: this.logger,
808
- });
809
- resp = parseResponse(
810
- respBody,
811
- unmarshalCreateRegisteredModelRequest_ResponseSchema
812
- );
813
- };
814
- await executeCall(call, options);
815
- if (resp === undefined) {
816
- throw new Error('operation completed without a result.');
817
- }
818
- return resp;
819
- }
820
-
821
- /** Deletes a model version. */
822
- async deleteModelVersion(
823
- req: DeleteModelVersionRequest,
824
- options?: CallOptions
825
- ): Promise<DeleteModelVersionRequest_Response> {
826
- const url = `${this.host}/api/2.0/mlflow/model-versions/delete`;
827
- const params = new URLSearchParams();
828
- if (req.name !== undefined) {
829
- params.append('name', req.name);
830
- }
831
- if (req.version !== undefined) {
832
- params.append('version', req.version);
833
- }
834
- const query = params.toString();
835
- const fullUrl = query !== '' ? `${url}?${query}` : url;
836
- let resp: DeleteModelVersionRequest_Response | undefined;
837
- const call = async (callSignal?: AbortSignal): Promise<void> => {
838
- const headers = new Headers();
839
- if (this.workspaceId !== undefined) {
840
- headers.set('X-Databricks-Org-Id', this.workspaceId);
841
- }
842
- headers.set('User-Agent', this.userAgent);
843
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
844
- const respBody = await executeHttpCall({
845
- request: httpReq,
846
- httpClient: this.httpClient,
847
- logger: this.logger,
848
- });
849
- resp = parseResponse(
850
- respBody,
851
- unmarshalDeleteModelVersionRequest_ResponseSchema
852
- );
853
- };
854
- await executeCall(call, options);
855
- if (resp === undefined) {
856
- throw new Error('operation completed without a result.');
857
- }
858
- return resp;
859
- }
860
-
861
- /** Deletes a model version tag. */
862
- async deleteModelVersionTag(
863
- req: DeleteModelVersionTagRequest,
864
- options?: CallOptions
865
- ): Promise<DeleteModelVersionTagRequest_Response> {
866
- const url = `${this.host}/api/2.0/mlflow/model-versions/delete-tag`;
867
- const params = new URLSearchParams();
868
- if (req.name !== undefined) {
869
- params.append('name', req.name);
870
- }
871
- if (req.version !== undefined) {
872
- params.append('version', req.version);
873
- }
874
- if (req.key !== undefined) {
875
- params.append('key', req.key);
876
- }
877
- const query = params.toString();
878
- const fullUrl = query !== '' ? `${url}?${query}` : url;
879
- let resp: DeleteModelVersionTagRequest_Response | undefined;
880
- const call = async (callSignal?: AbortSignal): Promise<void> => {
881
- const headers = new Headers();
882
- if (this.workspaceId !== undefined) {
883
- headers.set('X-Databricks-Org-Id', this.workspaceId);
884
- }
885
- headers.set('User-Agent', this.userAgent);
886
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
887
- const respBody = await executeHttpCall({
888
- request: httpReq,
889
- httpClient: this.httpClient,
890
- logger: this.logger,
891
- });
892
- resp = parseResponse(
893
- respBody,
894
- unmarshalDeleteModelVersionTagRequest_ResponseSchema
895
- );
896
- };
897
- await executeCall(call, options);
898
- if (resp === undefined) {
899
- throw new Error('operation completed without a result.');
900
- }
901
- return resp;
902
- }
903
-
904
- /** Deletes a registered model. */
905
- async deleteRegisteredModel(
906
- req: DeleteRegisteredModelRequest,
907
- options?: CallOptions
908
- ): Promise<DeleteRegisteredModelRequest_Response> {
909
- const url = `${this.host}/api/2.0/mlflow/registered-models/delete`;
910
- const params = new URLSearchParams();
911
- if (req.name !== undefined) {
912
- params.append('name', req.name);
913
- }
914
- const query = params.toString();
915
- const fullUrl = query !== '' ? `${url}?${query}` : url;
916
- let resp: DeleteRegisteredModelRequest_Response | undefined;
917
- const call = async (callSignal?: AbortSignal): Promise<void> => {
918
- const headers = new Headers();
919
- if (this.workspaceId !== undefined) {
920
- headers.set('X-Databricks-Org-Id', this.workspaceId);
921
- }
922
- headers.set('User-Agent', this.userAgent);
923
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
924
- const respBody = await executeHttpCall({
925
- request: httpReq,
926
- httpClient: this.httpClient,
927
- logger: this.logger,
928
- });
929
- resp = parseResponse(
930
- respBody,
931
- unmarshalDeleteRegisteredModelRequest_ResponseSchema
932
- );
933
- };
934
- await executeCall(call, options);
935
- if (resp === undefined) {
936
- throw new Error('operation completed without a result.');
937
- }
938
- return resp;
939
- }
940
-
941
- /** Deletes the tag for a registered model. */
942
- async deleteRegisteredModelTag(
943
- req: DeleteRegisteredModelTagRequest,
944
- options?: CallOptions
945
- ): Promise<DeleteRegisteredModelTagRequest_Response> {
946
- const url = `${this.host}/api/2.0/mlflow/registered-models/delete-tag`;
947
- const params = new URLSearchParams();
948
- if (req.name !== undefined) {
949
- params.append('name', req.name);
950
- }
951
- if (req.key !== undefined) {
952
- params.append('key', req.key);
953
- }
954
- const query = params.toString();
955
- const fullUrl = query !== '' ? `${url}?${query}` : url;
956
- let resp: DeleteRegisteredModelTagRequest_Response | undefined;
957
- const call = async (callSignal?: AbortSignal): Promise<void> => {
958
- const headers = new Headers();
959
- if (this.workspaceId !== undefined) {
960
- headers.set('X-Databricks-Org-Id', this.workspaceId);
961
- }
962
- headers.set('User-Agent', this.userAgent);
963
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
964
- const respBody = await executeHttpCall({
965
- request: httpReq,
966
- httpClient: this.httpClient,
967
- logger: this.logger,
968
- });
969
- resp = parseResponse(
970
- respBody,
971
- unmarshalDeleteRegisteredModelTagRequest_ResponseSchema
972
- );
973
- };
974
- await executeCall(call, options);
975
- if (resp === undefined) {
976
- throw new Error('operation completed without a result.');
977
- }
978
- return resp;
979
- }
980
-
981
- /** Get a model version. */
982
- async getModelVersion(
983
- req: GetModelVersionRequest,
984
- options?: CallOptions
985
- ): Promise<GetModelVersionRequest_Response> {
986
- const url = `${this.host}/api/2.0/mlflow/model-versions/get`;
987
- const params = new URLSearchParams();
988
- if (req.name !== undefined) {
989
- params.append('name', req.name);
990
- }
991
- if (req.version !== undefined) {
992
- params.append('version', req.version);
993
- }
994
- const query = params.toString();
995
- const fullUrl = query !== '' ? `${url}?${query}` : url;
996
- let resp: GetModelVersionRequest_Response | undefined;
997
- const call = async (callSignal?: AbortSignal): Promise<void> => {
998
- const headers = new Headers();
999
- if (this.workspaceId !== undefined) {
1000
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1001
- }
1002
- headers.set('User-Agent', this.userAgent);
1003
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1004
- const respBody = await executeHttpCall({
1005
- request: httpReq,
1006
- httpClient: this.httpClient,
1007
- logger: this.logger,
1008
- });
1009
- resp = parseResponse(
1010
- respBody,
1011
- unmarshalGetModelVersionRequest_ResponseSchema
1012
- );
1013
- };
1014
- await executeCall(call, options);
1015
- if (resp === undefined) {
1016
- throw new Error('operation completed without a result.');
1017
- }
1018
- return resp;
1019
- }
1020
-
1021
- /** Gets a URI to download the model version. */
1022
- async getModelVersionDownloadUri(
1023
- req: GetModelVersionDownloadUriRequest,
1024
- options?: CallOptions
1025
- ): Promise<GetModelVersionDownloadUriRequest_Response> {
1026
- const url = `${this.host}/api/2.0/mlflow/model-versions/get-download-uri`;
1027
- const params = new URLSearchParams();
1028
- if (req.name !== undefined) {
1029
- params.append('name', req.name);
1030
- }
1031
- if (req.version !== undefined) {
1032
- params.append('version', req.version);
1033
- }
1034
- const query = params.toString();
1035
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1036
- let resp: GetModelVersionDownloadUriRequest_Response | undefined;
1037
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1038
- const headers = new Headers();
1039
- if (this.workspaceId !== undefined) {
1040
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1041
- }
1042
- headers.set('User-Agent', this.userAgent);
1043
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1044
- const respBody = await executeHttpCall({
1045
- request: httpReq,
1046
- httpClient: this.httpClient,
1047
- logger: this.logger,
1048
- });
1049
- resp = parseResponse(
1050
- respBody,
1051
- unmarshalGetModelVersionDownloadUriRequest_ResponseSchema
1052
- );
1053
- };
1054
- await executeCall(call, options);
1055
- if (resp === undefined) {
1056
- throw new Error('operation completed without a result.');
1057
- }
1058
- return resp;
1059
- }
1060
-
1061
- /** Gets the latest version of a registered model. */
1062
- async listLatestVersions(
1063
- req: ListLatestVersionsRequest,
1064
- options?: CallOptions
1065
- ): Promise<ListLatestVersionsRequest_Response> {
1066
- const url = `${this.host}/api/2.0/mlflow/registered-models/get-latest-versions`;
1067
- const body = marshalRequest(req, marshalListLatestVersionsRequestSchema);
1068
- let resp: ListLatestVersionsRequest_Response | undefined;
1069
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1070
- const headers = new Headers({'Content-Type': 'application/json'});
1071
- if (this.workspaceId !== undefined) {
1072
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1073
- }
1074
- headers.set('User-Agent', this.userAgent);
1075
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1076
- const respBody = await executeHttpCall({
1077
- request: httpReq,
1078
- httpClient: this.httpClient,
1079
- logger: this.logger,
1080
- });
1081
- resp = parseResponse(
1082
- respBody,
1083
- unmarshalListLatestVersionsRequest_ResponseSchema
1084
- );
1085
- };
1086
- await executeCall(call, options);
1087
- if (resp === undefined) {
1088
- throw new Error('operation completed without a result.');
1089
- }
1090
- return resp;
1091
- }
1092
-
1093
- /** Lists all available registered models, up to the limit specified in __max_results__. */
1094
- async listRegisteredModels(
1095
- req: ListRegisteredModelsRequest,
1096
- options?: CallOptions
1097
- ): Promise<ListRegisteredModelsRequest_Response> {
1098
- const url = `${this.host}/api/2.0/mlflow/registered-models/list`;
1099
- const params = new URLSearchParams();
1100
- if (req.maxResults !== undefined) {
1101
- params.append('max_results', String(req.maxResults));
1102
- }
1103
- if (req.pageToken !== undefined) {
1104
- params.append('page_token', req.pageToken);
1105
- }
1106
- const query = params.toString();
1107
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1108
- let resp: ListRegisteredModelsRequest_Response | undefined;
1109
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1110
- const headers = new Headers();
1111
- if (this.workspaceId !== undefined) {
1112
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1113
- }
1114
- headers.set('User-Agent', this.userAgent);
1115
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1116
- const respBody = await executeHttpCall({
1117
- request: httpReq,
1118
- httpClient: this.httpClient,
1119
- logger: this.logger,
1120
- });
1121
- resp = parseResponse(
1122
- respBody,
1123
- unmarshalListRegisteredModelsRequest_ResponseSchema
1124
- );
1125
- };
1126
- await executeCall(call, options);
1127
- if (resp === undefined) {
1128
- throw new Error('operation completed without a result.');
1129
- }
1130
- return resp;
1131
- }
1132
-
1133
- async *listRegisteredModelsIter(
1134
- req: ListRegisteredModelsRequest,
1135
- options?: CallOptions
1136
- ): AsyncGenerator<RegisteredModel> {
1137
- const pageReq: ListRegisteredModelsRequest = {...req};
1138
- for (;;) {
1139
- const resp = await this.listRegisteredModels(pageReq, options);
1140
- for (const item of resp.registeredModels ?? []) {
1141
- yield item;
1142
- }
1143
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1144
- return;
1145
- }
1146
- pageReq.pageToken = resp.nextPageToken;
1147
- }
1148
- }
1149
-
1150
- /** Renames a registered model. */
1151
- async renameRegisteredModel(
1152
- req: RenameRegisteredModelRequest,
1153
- options?: CallOptions
1154
- ): Promise<RenameRegisteredModelRequest_Response> {
1155
- const url = `${this.host}/api/2.0/mlflow/registered-models/rename`;
1156
- const body = marshalRequest(req, marshalRenameRegisteredModelRequestSchema);
1157
- let resp: RenameRegisteredModelRequest_Response | undefined;
1158
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1159
- const headers = new Headers({'Content-Type': 'application/json'});
1160
- if (this.workspaceId !== undefined) {
1161
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1162
- }
1163
- headers.set('User-Agent', this.userAgent);
1164
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1165
- const respBody = await executeHttpCall({
1166
- request: httpReq,
1167
- httpClient: this.httpClient,
1168
- logger: this.logger,
1169
- });
1170
- resp = parseResponse(
1171
- respBody,
1172
- unmarshalRenameRegisteredModelRequest_ResponseSchema
1173
- );
1174
- };
1175
- await executeCall(call, options);
1176
- if (resp === undefined) {
1177
- throw new Error('operation completed without a result.');
1178
- }
1179
- return resp;
1180
- }
1181
-
1182
- /** Searches for specific model versions based on the supplied __filter__. */
1183
- async searchModelVersions(
1184
- req: SearchModelVersionsRequest,
1185
- options?: CallOptions
1186
- ): Promise<SearchModelVersionsRequest_Response> {
1187
- const url = `${this.host}/api/2.0/mlflow/model-versions/search`;
1188
- const params = new URLSearchParams();
1189
- if (req.filter !== undefined) {
1190
- params.append('filter', req.filter);
1191
- }
1192
- if (req.maxResults !== undefined) {
1193
- params.append('max_results', String(req.maxResults));
1194
- }
1195
- if (req.orderBy !== undefined) {
1196
- params.append('order_by', String(req.orderBy));
1197
- }
1198
- if (req.pageToken !== undefined) {
1199
- params.append('page_token', req.pageToken);
1200
- }
1201
- const query = params.toString();
1202
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1203
- let resp: SearchModelVersionsRequest_Response | undefined;
1204
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1205
- const headers = new Headers();
1206
- if (this.workspaceId !== undefined) {
1207
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1208
- }
1209
- headers.set('User-Agent', this.userAgent);
1210
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1211
- const respBody = await executeHttpCall({
1212
- request: httpReq,
1213
- httpClient: this.httpClient,
1214
- logger: this.logger,
1215
- });
1216
- resp = parseResponse(
1217
- respBody,
1218
- unmarshalSearchModelVersionsRequest_ResponseSchema
1219
- );
1220
- };
1221
- await executeCall(call, options);
1222
- if (resp === undefined) {
1223
- throw new Error('operation completed without a result.');
1224
- }
1225
- return resp;
1226
- }
1227
-
1228
- async *searchModelVersionsIter(
1229
- req: SearchModelVersionsRequest,
1230
- options?: CallOptions
1231
- ): AsyncGenerator<ModelVersion> {
1232
- const pageReq: SearchModelVersionsRequest = {...req};
1233
- for (;;) {
1234
- const resp = await this.searchModelVersions(pageReq, options);
1235
- for (const item of resp.modelVersions ?? []) {
1236
- yield item;
1237
- }
1238
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1239
- return;
1240
- }
1241
- pageReq.pageToken = resp.nextPageToken;
1242
- }
1243
- }
1244
-
1245
- /** Search for registered models based on the specified __filter__. */
1246
- async searchRegisteredModels(
1247
- req: SearchRegisteredModelsRequest,
1248
- options?: CallOptions
1249
- ): Promise<SearchRegisteredModelsRequest_Response> {
1250
- const url = `${this.host}/api/2.0/mlflow/registered-models/search`;
1251
- const params = new URLSearchParams();
1252
- if (req.filter !== undefined) {
1253
- params.append('filter', req.filter);
1254
- }
1255
- if (req.maxResults !== undefined) {
1256
- params.append('max_results', String(req.maxResults));
1257
- }
1258
- if (req.orderBy !== undefined) {
1259
- params.append('order_by', String(req.orderBy));
1260
- }
1261
- if (req.pageToken !== undefined) {
1262
- params.append('page_token', req.pageToken);
1263
- }
1264
- const query = params.toString();
1265
- const fullUrl = query !== '' ? `${url}?${query}` : url;
1266
- let resp: SearchRegisteredModelsRequest_Response | undefined;
1267
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1268
- const headers = new Headers();
1269
- if (this.workspaceId !== undefined) {
1270
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1271
- }
1272
- headers.set('User-Agent', this.userAgent);
1273
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
1274
- const respBody = await executeHttpCall({
1275
- request: httpReq,
1276
- httpClient: this.httpClient,
1277
- logger: this.logger,
1278
- });
1279
- resp = parseResponse(
1280
- respBody,
1281
- unmarshalSearchRegisteredModelsRequest_ResponseSchema
1282
- );
1283
- };
1284
- await executeCall(call, options);
1285
- if (resp === undefined) {
1286
- throw new Error('operation completed without a result.');
1287
- }
1288
- return resp;
1289
- }
1290
-
1291
- async *searchRegisteredModelsIter(
1292
- req: SearchRegisteredModelsRequest,
1293
- options?: CallOptions
1294
- ): AsyncGenerator<RegisteredModel> {
1295
- const pageReq: SearchRegisteredModelsRequest = {...req};
1296
- for (;;) {
1297
- const resp = await this.searchRegisteredModels(pageReq, options);
1298
- for (const item of resp.registeredModels ?? []) {
1299
- yield item;
1300
- }
1301
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
1302
- return;
1303
- }
1304
- pageReq.pageToken = resp.nextPageToken;
1305
- }
1306
- }
1307
-
1308
- /** Sets a model version tag. */
1309
- async setModelVersionTag(
1310
- req: SetModelVersionTagRequest,
1311
- options?: CallOptions
1312
- ): Promise<SetModelVersionTagRequest_Response> {
1313
- const url = `${this.host}/api/2.0/mlflow/model-versions/set-tag`;
1314
- const body = marshalRequest(req, marshalSetModelVersionTagRequestSchema);
1315
- let resp: SetModelVersionTagRequest_Response | undefined;
1316
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1317
- const headers = new Headers({'Content-Type': 'application/json'});
1318
- if (this.workspaceId !== undefined) {
1319
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1320
- }
1321
- headers.set('User-Agent', this.userAgent);
1322
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1323
- const respBody = await executeHttpCall({
1324
- request: httpReq,
1325
- httpClient: this.httpClient,
1326
- logger: this.logger,
1327
- });
1328
- resp = parseResponse(
1329
- respBody,
1330
- unmarshalSetModelVersionTagRequest_ResponseSchema
1331
- );
1332
- };
1333
- await executeCall(call, options);
1334
- if (resp === undefined) {
1335
- throw new Error('operation completed without a result.');
1336
- }
1337
- return resp;
1338
- }
1339
-
1340
- /** Sets a tag on a registered model. */
1341
- async setRegisteredModelTag(
1342
- req: SetRegisteredModelTagRequest,
1343
- options?: CallOptions
1344
- ): Promise<SetRegisteredModelTagRequest_Response> {
1345
- const url = `${this.host}/api/2.0/mlflow/registered-models/set-tag`;
1346
- const body = marshalRequest(req, marshalSetRegisteredModelTagRequestSchema);
1347
- let resp: SetRegisteredModelTagRequest_Response | undefined;
1348
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1349
- const headers = new Headers({'Content-Type': 'application/json'});
1350
- if (this.workspaceId !== undefined) {
1351
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1352
- }
1353
- headers.set('User-Agent', this.userAgent);
1354
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1355
- const respBody = await executeHttpCall({
1356
- request: httpReq,
1357
- httpClient: this.httpClient,
1358
- logger: this.logger,
1359
- });
1360
- resp = parseResponse(
1361
- respBody,
1362
- unmarshalSetRegisteredModelTagRequest_ResponseSchema
1363
- );
1364
- };
1365
- await executeCall(call, options);
1366
- if (resp === undefined) {
1367
- throw new Error('operation completed without a result.');
1368
- }
1369
- return resp;
1370
- }
1371
-
1372
- /** Updates the model version. */
1373
- async updateModelVersion(
1374
- req: UpdateModelVersionRequest,
1375
- options?: CallOptions
1376
- ): Promise<UpdateModelVersionRequest_Response> {
1377
- const url = `${this.host}/api/2.0/mlflow/model-versions/update`;
1378
- const body = marshalRequest(req, marshalUpdateModelVersionRequestSchema);
1379
- let resp: UpdateModelVersionRequest_Response | undefined;
1380
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1381
- const headers = new Headers({'Content-Type': 'application/json'});
1382
- if (this.workspaceId !== undefined) {
1383
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1384
- }
1385
- headers.set('User-Agent', this.userAgent);
1386
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1387
- const respBody = await executeHttpCall({
1388
- request: httpReq,
1389
- httpClient: this.httpClient,
1390
- logger: this.logger,
1391
- });
1392
- resp = parseResponse(
1393
- respBody,
1394
- unmarshalUpdateModelVersionRequest_ResponseSchema
1395
- );
1396
- };
1397
- await executeCall(call, options);
1398
- if (resp === undefined) {
1399
- throw new Error('operation completed without a result.');
1400
- }
1401
- return resp;
1402
- }
1403
-
1404
- /** Updates a registered model. */
1405
- async updateRegisteredModel(
1406
- req: UpdateRegisteredModelRequest,
1407
- options?: CallOptions
1408
- ): Promise<UpdateRegisteredModelRequest_Response> {
1409
- const url = `${this.host}/api/2.0/mlflow/registered-models/update`;
1410
- const body = marshalRequest(req, marshalUpdateRegisteredModelRequestSchema);
1411
- let resp: UpdateRegisteredModelRequest_Response | undefined;
1412
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1413
- const headers = new Headers({'Content-Type': 'application/json'});
1414
- if (this.workspaceId !== undefined) {
1415
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1416
- }
1417
- headers.set('User-Agent', this.userAgent);
1418
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1419
- const respBody = await executeHttpCall({
1420
- request: httpReq,
1421
- httpClient: this.httpClient,
1422
- logger: this.logger,
1423
- });
1424
- resp = parseResponse(
1425
- respBody,
1426
- unmarshalUpdateRegisteredModelRequest_ResponseSchema
1427
- );
1428
- };
1429
- await executeCall(call, options);
1430
- if (resp === undefined) {
1431
- throw new Error('operation completed without a result.');
1432
- }
1433
- return resp;
1434
- }
1435
- }