@databricks/sdk-uc-registeredmodels 0.0.0-dev → 0.1.0-dev.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAQvD,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,0EAA0E;AAC1E,6EAA6E;AAC7E,gEAAgE;AAChE,MAAM,UAAU,GAAG,OAAO,CAAC,EAAC,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;AAQpD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAU,EACV,OAAqB;IAErB,MAAM,IAAI,GAAY;QACpB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;QACjE,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,IAAI;YACxC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;QACF,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;KAClE,CAAC;IACF,OAAO,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,OAAO,CACpB,IAAuC;IAEvC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,MAAM,GAAiB,EAAE,C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c,EACd,MAAuB;IAEvB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0CAA0C;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,41 @@
1
1
  {
2
2
  "name": "@databricks/sdk-uc-registeredmodels",
3
- "version": "0.0.0-dev",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0-dev.1",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "typecheck": "tsc --noEmit",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
25
+ "test": "echo 'no tests'",
26
+ "test:browser": "echo 'no tests'"
27
+ },
28
+ "author": "Databricks",
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@databricks/sdk-auth": ">=0.1.0-dev.2 <1.0.0",
32
+ "@databricks/sdk-core": ">=0.1.0-dev.3 <1.0.0",
33
+ "@databricks/sdk-options": ">=0.1.0-dev.2 <1.0.0",
34
+ "@js-temporal/polyfill": "^0.5.0",
35
+ "json-bigint": "^1.0.0",
36
+ "zod": "^4.3.6"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ }
7
41
  }
@@ -0,0 +1,641 @@
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 type {Call} from '@databricks/sdk-core/api';
5
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
6
+ import type {Logger} from '@databricks/sdk-core/logger';
7
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
8
+ import type {CallOptions} from '@databricks/sdk-options/call';
9
+ import type {ClientOptions} from '@databricks/sdk-options/client';
10
+ import type {HttpClient} from '@databricks/sdk-core/http';
11
+ import {newHttpClient} from './transport';
12
+ import {
13
+ buildHttpRequest,
14
+ executeCall,
15
+ executeHttpCall,
16
+ marshalRequest,
17
+ parseResponse,
18
+ } from './utils';
19
+ import pkgJson from '../../package.json' with {type: 'json'};
20
+ import type {
21
+ CreateRegisteredModelRequest,
22
+ DeleteModelVersionRequest,
23
+ DeleteModelVersionRequest_Response,
24
+ DeleteRegisteredModelAliasRequest,
25
+ DeleteRegisteredModelAliasRequest_Response,
26
+ DeleteRegisteredModelRequest,
27
+ DeleteRegisteredModelRequest_Response,
28
+ GetModelVersionByAliasRequest,
29
+ GetModelVersionRequest,
30
+ GetRegisteredModelRequest,
31
+ ListModelVersionsRequest,
32
+ ListModelVersionsRequest_Response,
33
+ ListRegisteredModelsRequest,
34
+ ListRegisteredModelsRequest_Response,
35
+ ModelVersionInfo,
36
+ RegisteredModelAliasInfo,
37
+ RegisteredModelInfo,
38
+ SetRegisteredModelAliasRequest,
39
+ UpdateModelVersionRequest,
40
+ UpdateRegisteredModelRequest,
41
+ } from './model';
42
+ import {
43
+ marshalCreateRegisteredModelRequestSchema,
44
+ marshalSetRegisteredModelAliasRequestSchema,
45
+ marshalUpdateModelVersionRequestSchema,
46
+ marshalUpdateRegisteredModelRequestSchema,
47
+ unmarshalDeleteModelVersionRequest_ResponseSchema,
48
+ unmarshalDeleteRegisteredModelAliasRequest_ResponseSchema,
49
+ unmarshalDeleteRegisteredModelRequest_ResponseSchema,
50
+ unmarshalListModelVersionsRequest_ResponseSchema,
51
+ unmarshalListRegisteredModelsRequest_ResponseSchema,
52
+ unmarshalModelVersionInfoSchema,
53
+ unmarshalRegisteredModelAliasInfoSchema,
54
+ unmarshalRegisteredModelInfoSchema,
55
+ } from './model';
56
+
57
+ // Package identity segment for this client to be used in the User-Agent header.
58
+ const PACKAGE_SEGMENT = {
59
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
60
+ value: pkgJson.version,
61
+ };
62
+
63
+ export class RegisteredmodelsClient {
64
+ private readonly host: string;
65
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
66
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
67
+ // request.
68
+ private readonly workspaceId: string | undefined;
69
+ private readonly httpClient: HttpClient;
70
+ private readonly logger: Logger;
71
+ // User-Agent header value. Composed once at construction from
72
+ // createDefault() merged with this package's identity and the active
73
+ // credential's name.
74
+ private readonly userAgent: string;
75
+
76
+ constructor(options: ClientOptions) {
77
+ if (options.host === undefined) {
78
+ throw new Error('Host is required.');
79
+ }
80
+ this.host = options.host.replace(/\/$/, '');
81
+ this.workspaceId = options.workspaceId;
82
+ this.logger = options.logger ?? new NoOpLogger();
83
+ const info = createDefault()
84
+ .with(PACKAGE_SEGMENT)
85
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
86
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
87
+ this.userAgent = info.toString();
88
+ this.httpClient = newHttpClient(options);
89
+ }
90
+
91
+ /**
92
+ * Creates a new registered model in Unity Catalog.
93
+ *
94
+ * File storage for model versions in the registered model
95
+ * will be located in the default location which is specified by the parent schema,
96
+ * or the parent catalog, or the Metastore.
97
+ *
98
+ * For registered model creation to succeed, the user must satisfy the following conditions:
99
+ * - The caller must be a metastore admin, or be the owner of the parent catalog and schema,
100
+ * or have the **USE_CATALOG** privilege on the parent catalog
101
+ * and the **USE_SCHEMA** privilege on the parent schema.
102
+ * - The caller must have the **CREATE MODEL** or **CREATE FUNCTION** privilege on the parent schema.
103
+ */
104
+ async createRegisteredModel(
105
+ req: CreateRegisteredModelRequest,
106
+ options?: CallOptions
107
+ ): Promise<RegisteredModelInfo> {
108
+ const url = `${this.host}/api/2.1/unity-catalog/models`;
109
+ const body = marshalRequest(req, marshalCreateRegisteredModelRequestSchema);
110
+ let resp: RegisteredModelInfo | undefined;
111
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
112
+ const headers = new Headers({'Content-Type': 'application/json'});
113
+ if (this.workspaceId !== undefined) {
114
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
115
+ }
116
+ headers.set('User-Agent', this.userAgent);
117
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
118
+ const respBody = await executeHttpCall({
119
+ request: httpReq,
120
+ httpClient: this.httpClient,
121
+ logger: this.logger,
122
+ });
123
+ resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema);
124
+ };
125
+ await executeCall(call, options);
126
+ if (resp === undefined) {
127
+ throw new Error('API call completed without a result.');
128
+ }
129
+ return resp;
130
+ }
131
+
132
+ /**
133
+ * Deletes a model version from the specified registered model. Any aliases assigned to the
134
+ * model version will also be deleted.
135
+ *
136
+ * The caller must be a metastore admin or an owner of the parent registered model.
137
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
138
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
139
+ */
140
+ async deleteModelVersion(
141
+ req: DeleteModelVersionRequest,
142
+ options?: CallOptions
143
+ ): Promise<DeleteModelVersionRequest_Response> {
144
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`;
145
+ let resp: DeleteModelVersionRequest_Response | undefined;
146
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
147
+ const headers = new Headers();
148
+ if (this.workspaceId !== undefined) {
149
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
150
+ }
151
+ headers.set('User-Agent', this.userAgent);
152
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
153
+ const respBody = await executeHttpCall({
154
+ request: httpReq,
155
+ httpClient: this.httpClient,
156
+ logger: this.logger,
157
+ });
158
+ resp = parseResponse(
159
+ respBody,
160
+ unmarshalDeleteModelVersionRequest_ResponseSchema
161
+ );
162
+ };
163
+ await executeCall(call, options);
164
+ if (resp === undefined) {
165
+ throw new Error('API call completed without a result.');
166
+ }
167
+ return resp;
168
+ }
169
+
170
+ /**
171
+ * Deletes a registered model and all its model versions from the specified parent catalog and schema.
172
+ *
173
+ * The caller must be a metastore admin or an owner of the registered model.
174
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
175
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
176
+ */
177
+ async deleteRegisteredModel(
178
+ req: DeleteRegisteredModelRequest,
179
+ options?: CallOptions
180
+ ): Promise<DeleteRegisteredModelRequest_Response> {
181
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`;
182
+ let resp: DeleteRegisteredModelRequest_Response | undefined;
183
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
184
+ const headers = new Headers();
185
+ if (this.workspaceId !== undefined) {
186
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
187
+ }
188
+ headers.set('User-Agent', this.userAgent);
189
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
190
+ const respBody = await executeHttpCall({
191
+ request: httpReq,
192
+ httpClient: this.httpClient,
193
+ logger: this.logger,
194
+ });
195
+ resp = parseResponse(
196
+ respBody,
197
+ unmarshalDeleteRegisteredModelRequest_ResponseSchema
198
+ );
199
+ };
200
+ await executeCall(call, options);
201
+ if (resp === undefined) {
202
+ throw new Error('API call completed without a result.');
203
+ }
204
+ return resp;
205
+ }
206
+
207
+ /**
208
+ * Deletes a registered model alias.
209
+ *
210
+ * The caller must be a metastore admin or an owner of the registered model.
211
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
212
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
213
+ */
214
+ async deleteRegisteredModelAlias(
215
+ req: DeleteRegisteredModelAliasRequest,
216
+ options?: CallOptions
217
+ ): Promise<DeleteRegisteredModelAliasRequest_Response> {
218
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`;
219
+ let resp: DeleteRegisteredModelAliasRequest_Response | undefined;
220
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
221
+ const headers = new Headers();
222
+ if (this.workspaceId !== undefined) {
223
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
224
+ }
225
+ headers.set('User-Agent', this.userAgent);
226
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
227
+ const respBody = await executeHttpCall({
228
+ request: httpReq,
229
+ httpClient: this.httpClient,
230
+ logger: this.logger,
231
+ });
232
+ resp = parseResponse(
233
+ respBody,
234
+ unmarshalDeleteRegisteredModelAliasRequest_ResponseSchema
235
+ );
236
+ };
237
+ await executeCall(call, options);
238
+ if (resp === undefined) {
239
+ throw new Error('API call completed without a result.');
240
+ }
241
+ return resp;
242
+ }
243
+
244
+ /**
245
+ * Get a model version.
246
+ *
247
+ * The caller must be a metastore admin or an owner of (or have the **EXECUTE**
248
+ * privilege on) the parent registered model. For the latter case, the caller must also be the owner
249
+ * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
250
+ * on the parent schema.
251
+ */
252
+ async getModelVersion(
253
+ req: GetModelVersionRequest,
254
+ options?: CallOptions
255
+ ): Promise<ModelVersionInfo> {
256
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`;
257
+ const params = new URLSearchParams();
258
+ if (req.includeAliases !== undefined) {
259
+ params.append('include_aliases', String(req.includeAliases));
260
+ }
261
+ if (req.includeBrowse !== undefined) {
262
+ params.append('include_browse', String(req.includeBrowse));
263
+ }
264
+ const query = params.toString();
265
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
266
+ let resp: ModelVersionInfo | undefined;
267
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
268
+ const headers = new Headers();
269
+ if (this.workspaceId !== undefined) {
270
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
271
+ }
272
+ headers.set('User-Agent', this.userAgent);
273
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
274
+ const respBody = await executeHttpCall({
275
+ request: httpReq,
276
+ httpClient: this.httpClient,
277
+ logger: this.logger,
278
+ });
279
+ resp = parseResponse(respBody, unmarshalModelVersionInfoSchema);
280
+ };
281
+ await executeCall(call, options);
282
+ if (resp === undefined) {
283
+ throw new Error('API call completed without a result.');
284
+ }
285
+ return resp;
286
+ }
287
+
288
+ /**
289
+ * Get a model version by alias.
290
+ *
291
+ * The caller must be a metastore admin or an owner of (or have the **EXECUTE**
292
+ * privilege on) the registered model. For the latter case, the caller must also be the owner
293
+ * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
294
+ * on the parent schema.
295
+ */
296
+ async getModelVersionByAlias(
297
+ req: GetModelVersionByAliasRequest,
298
+ options?: CallOptions
299
+ ): Promise<ModelVersionInfo> {
300
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`;
301
+ const params = new URLSearchParams();
302
+ if (req.includeAliases !== undefined) {
303
+ params.append('include_aliases', String(req.includeAliases));
304
+ }
305
+ const query = params.toString();
306
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
307
+ let resp: ModelVersionInfo | undefined;
308
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
309
+ const headers = new Headers();
310
+ if (this.workspaceId !== undefined) {
311
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
312
+ }
313
+ headers.set('User-Agent', this.userAgent);
314
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
315
+ const respBody = await executeHttpCall({
316
+ request: httpReq,
317
+ httpClient: this.httpClient,
318
+ logger: this.logger,
319
+ });
320
+ resp = parseResponse(respBody, unmarshalModelVersionInfoSchema);
321
+ };
322
+ await executeCall(call, options);
323
+ if (resp === undefined) {
324
+ throw new Error('API call completed without a result.');
325
+ }
326
+ return resp;
327
+ }
328
+
329
+ /**
330
+ * Get a registered model.
331
+ *
332
+ * The caller must be a metastore admin or an owner of (or have the **EXECUTE**
333
+ * privilege on) the registered model. For the latter case, the caller must also be the owner
334
+ * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege
335
+ * on the parent schema.
336
+ */
337
+ async getRegisteredModel(
338
+ req: GetRegisteredModelRequest,
339
+ options?: CallOptions
340
+ ): Promise<RegisteredModelInfo> {
341
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`;
342
+ const params = new URLSearchParams();
343
+ if (req.includeAliases !== undefined) {
344
+ params.append('include_aliases', String(req.includeAliases));
345
+ }
346
+ if (req.includeBrowse !== undefined) {
347
+ params.append('include_browse', String(req.includeBrowse));
348
+ }
349
+ const query = params.toString();
350
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
351
+ let resp: RegisteredModelInfo | undefined;
352
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
353
+ const headers = new Headers();
354
+ if (this.workspaceId !== undefined) {
355
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
356
+ }
357
+ headers.set('User-Agent', this.userAgent);
358
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
359
+ const respBody = await executeHttpCall({
360
+ request: httpReq,
361
+ httpClient: this.httpClient,
362
+ logger: this.logger,
363
+ });
364
+ resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema);
365
+ };
366
+ await executeCall(call, options);
367
+ if (resp === undefined) {
368
+ throw new Error('API call completed without a result.');
369
+ }
370
+ return resp;
371
+ }
372
+
373
+ /**
374
+ * List model versions. You can list model versions under a particular schema,
375
+ * or list all model versions in the current metastore.
376
+ *
377
+ * The returned models are filtered based on the privileges of the calling user.
378
+ * For example, the metastore admin is able to list all the model versions.
379
+ * A regular user needs to be the owner or have the **EXECUTE** privilege
380
+ * on the parent registered model to recieve the model versions in the response.
381
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
382
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
383
+ *
384
+ * There is no guarantee of a specific ordering of the elements in the response. The
385
+ * elements in the response will not contain any aliases or tags.
386
+ *
387
+ * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
388
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
389
+ */
390
+ async listModelVersions(
391
+ req: ListModelVersionsRequest,
392
+ options?: CallOptions
393
+ ): Promise<ListModelVersionsRequest_Response> {
394
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions`;
395
+ const params = new URLSearchParams();
396
+ if (req.maxResults !== undefined) {
397
+ params.append('max_results', String(req.maxResults));
398
+ }
399
+ if (req.pageToken !== undefined) {
400
+ params.append('page_token', req.pageToken);
401
+ }
402
+ if (req.includeBrowse !== undefined) {
403
+ params.append('include_browse', String(req.includeBrowse));
404
+ }
405
+ const query = params.toString();
406
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
407
+ let resp: ListModelVersionsRequest_Response | undefined;
408
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
409
+ const headers = new Headers();
410
+ if (this.workspaceId !== undefined) {
411
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
412
+ }
413
+ headers.set('User-Agent', this.userAgent);
414
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
415
+ const respBody = await executeHttpCall({
416
+ request: httpReq,
417
+ httpClient: this.httpClient,
418
+ logger: this.logger,
419
+ });
420
+ resp = parseResponse(
421
+ respBody,
422
+ unmarshalListModelVersionsRequest_ResponseSchema
423
+ );
424
+ };
425
+ await executeCall(call, options);
426
+ if (resp === undefined) {
427
+ throw new Error('API call completed without a result.');
428
+ }
429
+ return resp;
430
+ }
431
+
432
+ async *listModelVersionsIter(
433
+ req: ListModelVersionsRequest,
434
+ options?: CallOptions
435
+ ): AsyncGenerator<ModelVersionInfo> {
436
+ const pageReq: ListModelVersionsRequest = {...req};
437
+ for (;;) {
438
+ const resp = await this.listModelVersions(pageReq, options);
439
+ for (const item of resp.modelVersions ?? []) {
440
+ yield item;
441
+ }
442
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
443
+ return;
444
+ }
445
+ pageReq.pageToken = resp.nextPageToken;
446
+ }
447
+ }
448
+
449
+ /**
450
+ * List registered models. You can list registered models under a particular schema,
451
+ * or list all registered models in the current metastore.
452
+ *
453
+ * The returned models are filtered based on the privileges of the calling user.
454
+ * For example, the metastore admin is able to list all the registered models.
455
+ * A regular user needs to be the owner or have the **EXECUTE** privilege
456
+ * on the registered model to recieve the registered models in the response.
457
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
458
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
459
+ *
460
+ * There is no guarantee of a specific ordering of the elements in the response.
461
+ *
462
+ * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
463
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
464
+ */
465
+ async listRegisteredModels(
466
+ req: ListRegisteredModelsRequest,
467
+ options?: CallOptions
468
+ ): Promise<ListRegisteredModelsRequest_Response> {
469
+ const url = `${this.host}/api/2.1/unity-catalog/models`;
470
+ const params = new URLSearchParams();
471
+ if (req.catalogName !== undefined) {
472
+ params.append('catalog_name', req.catalogName);
473
+ }
474
+ if (req.schemaName !== undefined) {
475
+ params.append('schema_name', req.schemaName);
476
+ }
477
+ if (req.includeBrowse !== undefined) {
478
+ params.append('include_browse', String(req.includeBrowse));
479
+ }
480
+ if (req.maxResults !== undefined) {
481
+ params.append('max_results', String(req.maxResults));
482
+ }
483
+ if (req.pageToken !== undefined) {
484
+ params.append('page_token', req.pageToken);
485
+ }
486
+ const query = params.toString();
487
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
488
+ let resp: ListRegisteredModelsRequest_Response | undefined;
489
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
490
+ const headers = new Headers();
491
+ if (this.workspaceId !== undefined) {
492
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
493
+ }
494
+ headers.set('User-Agent', this.userAgent);
495
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
496
+ const respBody = await executeHttpCall({
497
+ request: httpReq,
498
+ httpClient: this.httpClient,
499
+ logger: this.logger,
500
+ });
501
+ resp = parseResponse(
502
+ respBody,
503
+ unmarshalListRegisteredModelsRequest_ResponseSchema
504
+ );
505
+ };
506
+ await executeCall(call, options);
507
+ if (resp === undefined) {
508
+ throw new Error('API call completed without a result.');
509
+ }
510
+ return resp;
511
+ }
512
+
513
+ async *listRegisteredModelsIter(
514
+ req: ListRegisteredModelsRequest,
515
+ options?: CallOptions
516
+ ): AsyncGenerator<RegisteredModelInfo> {
517
+ const pageReq: ListRegisteredModelsRequest = {...req};
518
+ for (;;) {
519
+ const resp = await this.listRegisteredModels(pageReq, options);
520
+ for (const item of resp.registeredModels ?? []) {
521
+ yield item;
522
+ }
523
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
524
+ return;
525
+ }
526
+ pageReq.pageToken = resp.nextPageToken;
527
+ }
528
+ }
529
+
530
+ /**
531
+ * Set an alias on the specified registered model.
532
+ *
533
+ * The caller must be a metastore admin or an owner of the registered model.
534
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
535
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
536
+ */
537
+ async setRegisteredModelAlias(
538
+ req: SetRegisteredModelAliasRequest,
539
+ options?: CallOptions
540
+ ): Promise<RegisteredModelAliasInfo> {
541
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`;
542
+ const body = marshalRequest(
543
+ req,
544
+ marshalSetRegisteredModelAliasRequestSchema
545
+ );
546
+ let resp: RegisteredModelAliasInfo | undefined;
547
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
548
+ const headers = new Headers({'Content-Type': 'application/json'});
549
+ if (this.workspaceId !== undefined) {
550
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
551
+ }
552
+ headers.set('User-Agent', this.userAgent);
553
+ const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
554
+ const respBody = await executeHttpCall({
555
+ request: httpReq,
556
+ httpClient: this.httpClient,
557
+ logger: this.logger,
558
+ });
559
+ resp = parseResponse(respBody, unmarshalRegisteredModelAliasInfoSchema);
560
+ };
561
+ await executeCall(call, options);
562
+ if (resp === undefined) {
563
+ throw new Error('API call completed without a result.');
564
+ }
565
+ return resp;
566
+ }
567
+
568
+ /**
569
+ * Updates the specified model version.
570
+ *
571
+ * The caller must be a metastore admin or an owner of the parent registered model.
572
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
573
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
574
+ *
575
+ * Currently only the comment of the model version can be updated.
576
+ */
577
+ async updateModelVersion(
578
+ req: UpdateModelVersionRequest,
579
+ options?: CallOptions
580
+ ): Promise<ModelVersionInfo> {
581
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`;
582
+ const body = marshalRequest(req, marshalUpdateModelVersionRequestSchema);
583
+ let resp: ModelVersionInfo | undefined;
584
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
585
+ const headers = new Headers({'Content-Type': 'application/json'});
586
+ if (this.workspaceId !== undefined) {
587
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
588
+ }
589
+ headers.set('User-Agent', this.userAgent);
590
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
591
+ const respBody = await executeHttpCall({
592
+ request: httpReq,
593
+ httpClient: this.httpClient,
594
+ logger: this.logger,
595
+ });
596
+ resp = parseResponse(respBody, unmarshalModelVersionInfoSchema);
597
+ };
598
+ await executeCall(call, options);
599
+ if (resp === undefined) {
600
+ throw new Error('API call completed without a result.');
601
+ }
602
+ return resp;
603
+ }
604
+
605
+ /**
606
+ * Updates the specified registered model.
607
+ *
608
+ * The caller must be a metastore admin or an owner of the registered model.
609
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
610
+ * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
611
+ *
612
+ * Currently only the name, the owner or the comment of the registered model can be updated.
613
+ */
614
+ async updateRegisteredModel(
615
+ req: UpdateRegisteredModelRequest,
616
+ options?: CallOptions
617
+ ): Promise<RegisteredModelInfo> {
618
+ const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`;
619
+ const body = marshalRequest(req, marshalUpdateRegisteredModelRequestSchema);
620
+ let resp: RegisteredModelInfo | undefined;
621
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
622
+ const headers = new Headers({'Content-Type': 'application/json'});
623
+ if (this.workspaceId !== undefined) {
624
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
625
+ }
626
+ headers.set('User-Agent', this.userAgent);
627
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
628
+ const respBody = await executeHttpCall({
629
+ request: httpReq,
630
+ httpClient: this.httpClient,
631
+ logger: this.logger,
632
+ });
633
+ resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema);
634
+ };
635
+ await executeCall(call, options);
636
+ if (resp === undefined) {
637
+ throw new Error('API call completed without a result.');
638
+ }
639
+ return resp;
640
+ }
641
+ }