@databricks/sdk-modelserving 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,955 +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 {LroOptions} from '@databricks/sdk-options/lro';
10
- import type {HttpClient} from '@databricks/sdk-core/http';
11
- import {newHttpClient} from './transport';
12
- import {
13
- buildHttpRequest,
14
- executeCall,
15
- executeHttpCall,
16
- sendAndCheckError,
17
- marshalRequest,
18
- parseResponse,
19
- executeWait,
20
- StillRunningError,
21
- } from './utils';
22
- import pkgJson from '../../package.json' with {type: 'json'};
23
- import type {
24
- CreateInferenceEndpointRequest,
25
- CreatePtEndpointRequest,
26
- DeleteInferenceEndpointRequest,
27
- DeleteInferenceEndpointRequest_Response,
28
- ExportMetricsResponse,
29
- ExternalFunctionRequest,
30
- ExternalFunctionResponse,
31
- GetExportEndpointMetricsRequest,
32
- GetInferenceEndpointRequest,
33
- GetInferenceEndpointSchemaRequest,
34
- GetOpenApiResponse,
35
- GetServedModelBuildLogsRequest,
36
- GetServedModelBuildLogsRequest_Response,
37
- GetServedModelLogsRequest,
38
- GetServedModelLogsRequest_Response,
39
- InferenceEndpointDetailed,
40
- ListInferenceEndpointsRequest,
41
- ListInferenceEndpointsRequest_Response,
42
- PatchInferenceEndpointTagsRequest,
43
- PatchInferenceEndpointTagsRequest_Response,
44
- PutInferenceEndpointAiGatewayRequest,
45
- PutInferenceEndpointAiGatewayRequest_Response,
46
- PutInferenceEndpointConfigRequest,
47
- PutInferenceEndpointRateLimitsRequest,
48
- PutInferenceEndpointRateLimitsRequest_Response,
49
- PutPtEndpointConfigRequest,
50
- UpdateInferenceEndpointNotificationsRequest,
51
- UpdateInferenceEndpointNotificationsRequest_Response,
52
- } from './model';
53
- import {
54
- InferenceEndpointState_ConfigUpdateState,
55
- marshalCreateInferenceEndpointRequestSchema,
56
- marshalCreatePtEndpointRequestSchema,
57
- marshalExternalFunctionRequestSchema,
58
- marshalPatchInferenceEndpointTagsRequestSchema,
59
- marshalPutInferenceEndpointAiGatewayRequestSchema,
60
- marshalPutInferenceEndpointConfigRequestSchema,
61
- marshalPutInferenceEndpointRateLimitsRequestSchema,
62
- marshalPutPtEndpointConfigRequestSchema,
63
- marshalUpdateInferenceEndpointNotificationsRequestSchema,
64
- unmarshalDeleteInferenceEndpointRequest_ResponseSchema,
65
- unmarshalGetServedModelBuildLogsRequest_ResponseSchema,
66
- unmarshalGetServedModelLogsRequest_ResponseSchema,
67
- unmarshalInferenceEndpointDetailedSchema,
68
- unmarshalListInferenceEndpointsRequest_ResponseSchema,
69
- unmarshalPatchInferenceEndpointTagsRequest_ResponseSchema,
70
- unmarshalPutInferenceEndpointAiGatewayRequest_ResponseSchema,
71
- unmarshalPutInferenceEndpointRateLimitsRequest_ResponseSchema,
72
- unmarshalUpdateInferenceEndpointNotificationsRequest_ResponseSchema,
73
- } from './model';
74
-
75
- // Package identity segment for this client to be used in the User-Agent header.
76
- const PACKAGE_SEGMENT = {
77
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
78
- value: pkgJson.version,
79
- };
80
-
81
- export class ModelServingClient {
82
- private readonly host: string;
83
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
84
- // When set, workspace-level methods send X-Databricks-Org-Id on every
85
- // request.
86
- private readonly workspaceId: string | undefined;
87
- private readonly httpClient: HttpClient;
88
- private readonly logger: Logger;
89
- // User-Agent header value. Composed once at construction from
90
- // createDefault() merged with this package's identity and the active
91
- // credential's name.
92
- private readonly userAgent: string;
93
-
94
- constructor(options: ClientOptions) {
95
- if (options.host === undefined) {
96
- throw new Error('Host is required.');
97
- }
98
- this.host = options.host.replace(/\/$/, '');
99
- this.workspaceId = options.workspaceId;
100
- this.logger = options.logger ?? new NoOpLogger();
101
- const info = createDefault()
102
- .with(PACKAGE_SEGMENT)
103
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
104
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
105
- this.userAgent = info.toString();
106
- this.httpClient = newHttpClient(options);
107
- }
108
-
109
- /** Create a new serving endpoint. */
110
- private async createInferenceEndpoint(
111
- req: CreateInferenceEndpointRequest,
112
- options?: CallOptions
113
- ): Promise<InferenceEndpointDetailed> {
114
- const url = `${this.host}/api/2.0/serving-endpoints`;
115
- const body = marshalRequest(
116
- req,
117
- marshalCreateInferenceEndpointRequestSchema
118
- );
119
- let resp: InferenceEndpointDetailed | undefined;
120
- const call = async (callSignal?: AbortSignal): Promise<void> => {
121
- const headers = new Headers({'Content-Type': 'application/json'});
122
- if (this.workspaceId !== undefined) {
123
- headers.set('X-Databricks-Org-Id', this.workspaceId);
124
- }
125
- headers.set('User-Agent', this.userAgent);
126
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
127
- const respBody = await executeHttpCall({
128
- request: httpReq,
129
- httpClient: this.httpClient,
130
- logger: this.logger,
131
- });
132
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
133
- };
134
- await executeCall(call, options);
135
- if (resp === undefined) {
136
- throw new Error('operation completed without a result.');
137
- }
138
- return resp;
139
- }
140
-
141
- async createInferenceEndpointWaiter(
142
- req: CreateInferenceEndpointRequest,
143
- options?: CallOptions
144
- ): Promise<CreateInferenceEndpointWaiter> {
145
- await this.createInferenceEndpoint(req, options);
146
- if (req.name === undefined) {
147
- throw new Error('request field name required for polling is missing');
148
- }
149
- return new CreateInferenceEndpointWaiter(this, req.name);
150
- }
151
-
152
- /** Create a new PT serving endpoint. */
153
- private async createProvisionedThroughputInferenceEndpoint(
154
- req: CreatePtEndpointRequest,
155
- options?: CallOptions
156
- ): Promise<InferenceEndpointDetailed> {
157
- const url = `${this.host}/api/2.0/serving-endpoints/pt`;
158
- const body = marshalRequest(req, marshalCreatePtEndpointRequestSchema);
159
- let resp: InferenceEndpointDetailed | undefined;
160
- const call = async (callSignal?: AbortSignal): Promise<void> => {
161
- const headers = new Headers({'Content-Type': 'application/json'});
162
- if (this.workspaceId !== undefined) {
163
- headers.set('X-Databricks-Org-Id', this.workspaceId);
164
- }
165
- headers.set('User-Agent', this.userAgent);
166
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
167
- const respBody = await executeHttpCall({
168
- request: httpReq,
169
- httpClient: this.httpClient,
170
- logger: this.logger,
171
- });
172
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
173
- };
174
- await executeCall(call, options);
175
- if (resp === undefined) {
176
- throw new Error('operation completed without a result.');
177
- }
178
- return resp;
179
- }
180
-
181
- async createProvisionedThroughputInferenceEndpointWaiter(
182
- req: CreatePtEndpointRequest,
183
- options?: CallOptions
184
- ): Promise<CreateProvisionedThroughputInferenceEndpointWaiter> {
185
- await this.createProvisionedThroughputInferenceEndpoint(req, options);
186
- if (req.name === undefined) {
187
- throw new Error('request field name required for polling is missing');
188
- }
189
- return new CreateProvisionedThroughputInferenceEndpointWaiter(
190
- this,
191
- req.name
192
- );
193
- }
194
-
195
- /** Delete a serving endpoint. */
196
- async deleteInferenceEndpoint(
197
- req: DeleteInferenceEndpointRequest,
198
- options?: CallOptions
199
- ): Promise<DeleteInferenceEndpointRequest_Response> {
200
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}`;
201
- let resp: DeleteInferenceEndpointRequest_Response | undefined;
202
- const call = async (callSignal?: AbortSignal): Promise<void> => {
203
- const headers = new Headers();
204
- if (this.workspaceId !== undefined) {
205
- headers.set('X-Databricks-Org-Id', this.workspaceId);
206
- }
207
- headers.set('User-Agent', this.userAgent);
208
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
209
- const respBody = await executeHttpCall({
210
- request: httpReq,
211
- httpClient: this.httpClient,
212
- logger: this.logger,
213
- });
214
- resp = parseResponse(
215
- respBody,
216
- unmarshalDeleteInferenceEndpointRequest_ResponseSchema
217
- );
218
- };
219
- await executeCall(call, options);
220
- if (resp === undefined) {
221
- throw new Error('operation completed without a result.');
222
- }
223
- return resp;
224
- }
225
-
226
- /** Retrieves the metrics associated with the provided serving endpoint in either Prometheus or OpenMetrics exposition format. */
227
- async getExportEndpointMetrics(
228
- req: GetExportEndpointMetricsRequest,
229
- options?: CallOptions
230
- ): Promise<ExportMetricsResponse> {
231
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/metrics`;
232
- let resp: ExportMetricsResponse | undefined;
233
- const call = async (callSignal?: AbortSignal): Promise<void> => {
234
- const headers = new Headers();
235
- if (this.workspaceId !== undefined) {
236
- headers.set('X-Databricks-Org-Id', this.workspaceId);
237
- }
238
- headers.set('User-Agent', this.userAgent);
239
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
240
- const httpResp = await sendAndCheckError({
241
- request: httpReq,
242
- httpClient: this.httpClient,
243
- logger: this.logger,
244
- });
245
- resp = {
246
- contents: httpResp.body ?? undefined,
247
- };
248
- };
249
- await executeCall(call, options);
250
- if (resp === undefined) {
251
- throw new Error('operation completed without a result.');
252
- }
253
- return resp;
254
- }
255
-
256
- /** Retrieves the details for a single serving endpoint. */
257
- async getInferenceEndpoint(
258
- req: GetInferenceEndpointRequest,
259
- options?: CallOptions
260
- ): Promise<InferenceEndpointDetailed> {
261
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}`;
262
- let resp: InferenceEndpointDetailed | undefined;
263
- const call = async (callSignal?: AbortSignal): Promise<void> => {
264
- const headers = new Headers();
265
- if (this.workspaceId !== undefined) {
266
- headers.set('X-Databricks-Org-Id', this.workspaceId);
267
- }
268
- headers.set('User-Agent', this.userAgent);
269
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
270
- const respBody = await executeHttpCall({
271
- request: httpReq,
272
- httpClient: this.httpClient,
273
- logger: this.logger,
274
- });
275
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
276
- };
277
- await executeCall(call, options);
278
- if (resp === undefined) {
279
- throw new Error('operation completed without a result.');
280
- }
281
- return resp;
282
- }
283
-
284
- /** Get the query schema of the serving endpoint in OpenAPI format. The schema contains information for the supported paths, input and output format and datatypes. */
285
- async getInferenceEndpointSchema(
286
- req: GetInferenceEndpointSchemaRequest,
287
- options?: CallOptions
288
- ): Promise<GetOpenApiResponse> {
289
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/openapi`;
290
- let resp: GetOpenApiResponse | undefined;
291
- const call = async (callSignal?: AbortSignal): Promise<void> => {
292
- const headers = new Headers();
293
- if (this.workspaceId !== undefined) {
294
- headers.set('X-Databricks-Org-Id', this.workspaceId);
295
- }
296
- headers.set('User-Agent', this.userAgent);
297
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
298
- const httpResp = await sendAndCheckError({
299
- request: httpReq,
300
- httpClient: this.httpClient,
301
- logger: this.logger,
302
- });
303
- resp = {
304
- contents: httpResp.body ?? undefined,
305
- };
306
- };
307
- await executeCall(call, options);
308
- if (resp === undefined) {
309
- throw new Error('operation completed without a result.');
310
- }
311
- return resp;
312
- }
313
-
314
- /** Retrieves the build logs associated with the provided served model. */
315
- async getServedModelBuildLogs(
316
- req: GetServedModelBuildLogsRequest,
317
- options?: CallOptions
318
- ): Promise<GetServedModelBuildLogsRequest_Response> {
319
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/build-logs`;
320
- let resp: GetServedModelBuildLogsRequest_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('GET', url, 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
- unmarshalGetServedModelBuildLogsRequest_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
- /** Retrieves the service logs associated with the provided served model. */
346
- async getServedModelLogs(
347
- req: GetServedModelLogsRequest,
348
- options?: CallOptions
349
- ): Promise<GetServedModelLogsRequest_Response> {
350
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/logs`;
351
- let resp: GetServedModelLogsRequest_Response | undefined;
352
- const 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', url, headers, callSignal);
359
- const respBody = await executeHttpCall({
360
- request: httpReq,
361
- httpClient: this.httpClient,
362
- logger: this.logger,
363
- });
364
- resp = parseResponse(
365
- respBody,
366
- unmarshalGetServedModelLogsRequest_ResponseSchema
367
- );
368
- };
369
- await executeCall(call, options);
370
- if (resp === undefined) {
371
- throw new Error('operation completed without a result.');
372
- }
373
- return resp;
374
- }
375
-
376
- /** Get all serving endpoints. */
377
- async listInferenceEndpoints(
378
- _req: ListInferenceEndpointsRequest,
379
- options?: CallOptions
380
- ): Promise<ListInferenceEndpointsRequest_Response> {
381
- const url = `${this.host}/api/2.0/serving-endpoints`;
382
- let resp: ListInferenceEndpointsRequest_Response | undefined;
383
- const call = async (callSignal?: AbortSignal): Promise<void> => {
384
- const headers = new Headers();
385
- if (this.workspaceId !== undefined) {
386
- headers.set('X-Databricks-Org-Id', this.workspaceId);
387
- }
388
- headers.set('User-Agent', this.userAgent);
389
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
390
- const respBody = await executeHttpCall({
391
- request: httpReq,
392
- httpClient: this.httpClient,
393
- logger: this.logger,
394
- });
395
- resp = parseResponse(
396
- respBody,
397
- unmarshalListInferenceEndpointsRequest_ResponseSchema
398
- );
399
- };
400
- await executeCall(call, options);
401
- if (resp === undefined) {
402
- throw new Error('operation completed without a result.');
403
- }
404
- return resp;
405
- }
406
-
407
- /** Used to batch add and delete tags from a serving endpoint with a single API call. */
408
- async patchInferenceEndpointTags(
409
- req: PatchInferenceEndpointTagsRequest,
410
- options?: CallOptions
411
- ): Promise<PatchInferenceEndpointTagsRequest_Response> {
412
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/tags`;
413
- const body = marshalRequest(
414
- req,
415
- marshalPatchInferenceEndpointTagsRequestSchema
416
- );
417
- let resp: PatchInferenceEndpointTagsRequest_Response | undefined;
418
- const call = async (callSignal?: AbortSignal): Promise<void> => {
419
- const headers = new Headers({'Content-Type': 'application/json'});
420
- if (this.workspaceId !== undefined) {
421
- headers.set('X-Databricks-Org-Id', this.workspaceId);
422
- }
423
- headers.set('User-Agent', this.userAgent);
424
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
425
- const respBody = await executeHttpCall({
426
- request: httpReq,
427
- httpClient: this.httpClient,
428
- logger: this.logger,
429
- });
430
- resp = parseResponse(
431
- respBody,
432
- unmarshalPatchInferenceEndpointTagsRequest_ResponseSchema
433
- );
434
- };
435
- await executeCall(call, options);
436
- if (resp === undefined) {
437
- throw new Error('operation completed without a result.');
438
- }
439
- return resp;
440
- }
441
-
442
- /** Used to update the AI Gateway of a serving endpoint. NOTE: External model, provisioned throughput, and pay-per-token endpoints are fully supported; agent endpoints currently only support inference tables. */
443
- async putInferenceEndpointAiGateway(
444
- req: PutInferenceEndpointAiGatewayRequest,
445
- options?: CallOptions
446
- ): Promise<PutInferenceEndpointAiGatewayRequest_Response> {
447
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/ai-gateway`;
448
- const body = marshalRequest(
449
- req,
450
- marshalPutInferenceEndpointAiGatewayRequestSchema
451
- );
452
- let resp: PutInferenceEndpointAiGatewayRequest_Response | undefined;
453
- const call = async (callSignal?: AbortSignal): Promise<void> => {
454
- const headers = new Headers({'Content-Type': 'application/json'});
455
- if (this.workspaceId !== undefined) {
456
- headers.set('X-Databricks-Org-Id', this.workspaceId);
457
- }
458
- headers.set('User-Agent', this.userAgent);
459
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
460
- const respBody = await executeHttpCall({
461
- request: httpReq,
462
- httpClient: this.httpClient,
463
- logger: this.logger,
464
- });
465
- resp = parseResponse(
466
- respBody,
467
- unmarshalPutInferenceEndpointAiGatewayRequest_ResponseSchema
468
- );
469
- };
470
- await executeCall(call, options);
471
- if (resp === undefined) {
472
- throw new Error('operation completed without a result.');
473
- }
474
- return resp;
475
- }
476
-
477
- /** Updates any combination of the serving endpoint's served entities, the compute configuration of those served entities, and the endpoint's traffic config. An endpoint that already has an update in progress can not be updated until the current update completes or fails. */
478
- private async putInferenceEndpointConfig(
479
- req: PutInferenceEndpointConfigRequest,
480
- options?: CallOptions
481
- ): Promise<InferenceEndpointDetailed> {
482
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/config`;
483
- const body = marshalRequest(
484
- req,
485
- marshalPutInferenceEndpointConfigRequestSchema
486
- );
487
- let resp: InferenceEndpointDetailed | undefined;
488
- const call = async (callSignal?: AbortSignal): Promise<void> => {
489
- const headers = new Headers({'Content-Type': 'application/json'});
490
- if (this.workspaceId !== undefined) {
491
- headers.set('X-Databricks-Org-Id', this.workspaceId);
492
- }
493
- headers.set('User-Agent', this.userAgent);
494
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
495
- const respBody = await executeHttpCall({
496
- request: httpReq,
497
- httpClient: this.httpClient,
498
- logger: this.logger,
499
- });
500
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
501
- };
502
- await executeCall(call, options);
503
- if (resp === undefined) {
504
- throw new Error('operation completed without a result.');
505
- }
506
- return resp;
507
- }
508
-
509
- async putInferenceEndpointConfigWaiter(
510
- req: PutInferenceEndpointConfigRequest,
511
- options?: CallOptions
512
- ): Promise<PutInferenceEndpointConfigWaiter> {
513
- await this.putInferenceEndpointConfig(req, options);
514
- if (req.name === undefined) {
515
- throw new Error('request field name required for polling is missing');
516
- }
517
- return new PutInferenceEndpointConfigWaiter(this, req.name);
518
- }
519
-
520
- /** Deprecated: Please use AI Gateway to manage rate limits instead. */
521
- async putInferenceEndpointRateLimits(
522
- req: PutInferenceEndpointRateLimitsRequest,
523
- options?: CallOptions
524
- ): Promise<PutInferenceEndpointRateLimitsRequest_Response> {
525
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/rate-limits`;
526
- const body = marshalRequest(
527
- req,
528
- marshalPutInferenceEndpointRateLimitsRequestSchema
529
- );
530
- let resp: PutInferenceEndpointRateLimitsRequest_Response | undefined;
531
- const call = async (callSignal?: AbortSignal): Promise<void> => {
532
- const headers = new Headers({'Content-Type': 'application/json'});
533
- if (this.workspaceId !== undefined) {
534
- headers.set('X-Databricks-Org-Id', this.workspaceId);
535
- }
536
- headers.set('User-Agent', this.userAgent);
537
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
538
- const respBody = await executeHttpCall({
539
- request: httpReq,
540
- httpClient: this.httpClient,
541
- logger: this.logger,
542
- });
543
- resp = parseResponse(
544
- respBody,
545
- unmarshalPutInferenceEndpointRateLimitsRequest_ResponseSchema
546
- );
547
- };
548
- await executeCall(call, options);
549
- if (resp === undefined) {
550
- throw new Error('operation completed without a result.');
551
- }
552
- return resp;
553
- }
554
-
555
- /** Updates any combination of the pt endpoint's served entities, the compute configuration of those served entities, and the endpoint's traffic config. Updates are instantaneous and endpoint should be updated instantly */
556
- private async putProvisionedThroughputInferenceEndpointConfig(
557
- req: PutPtEndpointConfigRequest,
558
- options?: CallOptions
559
- ): Promise<InferenceEndpointDetailed> {
560
- const url = `${this.host}/api/2.0/serving-endpoints/pt/${req.name ?? ''}/config`;
561
- const body = marshalRequest(req, marshalPutPtEndpointConfigRequestSchema);
562
- let resp: InferenceEndpointDetailed | undefined;
563
- const call = async (callSignal?: AbortSignal): Promise<void> => {
564
- const headers = new Headers({'Content-Type': 'application/json'});
565
- if (this.workspaceId !== undefined) {
566
- headers.set('X-Databricks-Org-Id', this.workspaceId);
567
- }
568
- headers.set('User-Agent', this.userAgent);
569
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
570
- const respBody = await executeHttpCall({
571
- request: httpReq,
572
- httpClient: this.httpClient,
573
- logger: this.logger,
574
- });
575
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
576
- };
577
- await executeCall(call, options);
578
- if (resp === undefined) {
579
- throw new Error('operation completed without a result.');
580
- }
581
- return resp;
582
- }
583
-
584
- async putProvisionedThroughputInferenceEndpointConfigWaiter(
585
- req: PutPtEndpointConfigRequest,
586
- options?: CallOptions
587
- ): Promise<PutProvisionedThroughputInferenceEndpointConfigWaiter> {
588
- await this.putProvisionedThroughputInferenceEndpointConfig(req, options);
589
- if (req.name === undefined) {
590
- throw new Error('request field name required for polling is missing');
591
- }
592
- return new PutProvisionedThroughputInferenceEndpointConfigWaiter(
593
- this,
594
- req.name
595
- );
596
- }
597
-
598
- /** Updates the email and webhook notification settings for an endpoint. */
599
- async updateInferenceEndpointNotifications(
600
- req: UpdateInferenceEndpointNotificationsRequest,
601
- options?: CallOptions
602
- ): Promise<UpdateInferenceEndpointNotificationsRequest_Response> {
603
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/notifications`;
604
- const body = marshalRequest(
605
- req,
606
- marshalUpdateInferenceEndpointNotificationsRequestSchema
607
- );
608
- let resp: UpdateInferenceEndpointNotificationsRequest_Response | undefined;
609
- const call = async (callSignal?: AbortSignal): Promise<void> => {
610
- const headers = new Headers({'Content-Type': 'application/json'});
611
- if (this.workspaceId !== undefined) {
612
- headers.set('X-Databricks-Org-Id', this.workspaceId);
613
- }
614
- headers.set('User-Agent', this.userAgent);
615
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
616
- const respBody = await executeHttpCall({
617
- request: httpReq,
618
- httpClient: this.httpClient,
619
- logger: this.logger,
620
- });
621
- resp = parseResponse(
622
- respBody,
623
- unmarshalUpdateInferenceEndpointNotificationsRequest_ResponseSchema
624
- );
625
- };
626
- await executeCall(call, options);
627
- if (resp === undefined) {
628
- throw new Error('operation completed without a result.');
629
- }
630
- return resp;
631
- }
632
-
633
- /** Make external services call using the credentials stored in UC Connection. */
634
- async httpRequest(
635
- req: ExternalFunctionRequest,
636
- options?: CallOptions
637
- ): Promise<ExternalFunctionResponse> {
638
- const url = `${this.host}/api/2.0/external-function`;
639
- const body = marshalRequest(req, marshalExternalFunctionRequestSchema);
640
- let resp: ExternalFunctionResponse | undefined;
641
- const call = async (callSignal?: AbortSignal): Promise<void> => {
642
- const headers = new Headers({'Content-Type': 'application/json'});
643
- if (this.workspaceId !== undefined) {
644
- headers.set('X-Databricks-Org-Id', this.workspaceId);
645
- }
646
- headers.set('User-Agent', this.userAgent);
647
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
648
- const httpResp = await sendAndCheckError({
649
- request: httpReq,
650
- httpClient: this.httpClient,
651
- logger: this.logger,
652
- });
653
- resp = {
654
- contents: httpResp.body ?? undefined,
655
- };
656
- };
657
- await executeCall(call, options);
658
- if (resp === undefined) {
659
- throw new Error('operation completed without a result.');
660
- }
661
- return resp;
662
- }
663
- }
664
-
665
- export class CreateInferenceEndpointWaiter {
666
- constructor(
667
- private readonly client: ModelServingClient,
668
- readonly name: string
669
- ) {}
670
-
671
- /**
672
- * Polls until the operation reaches a terminal state.
673
- *
674
- * Throws if a failure state is reached.
675
- */
676
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
677
- let result: InferenceEndpointDetailed | undefined;
678
-
679
- const call = async (callSignal?: AbortSignal): Promise<void> => {
680
- const pollResp = await this.client.getInferenceEndpoint(
681
- {
682
- name: this.name,
683
- },
684
- callSignal !== undefined ? {signal: callSignal} : undefined
685
- );
686
-
687
- const status = pollResp.state?.configUpdate;
688
- if (status === undefined) {
689
- throw new Error('response missing required status field');
690
- }
691
-
692
- switch (status) {
693
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
694
- result = pollResp;
695
- return;
696
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
697
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
698
- const msg = '(no message)';
699
- throw new Error(`terminal state ${status}: ${msg}`);
700
- }
701
- default:
702
- throw new StillRunningError();
703
- }
704
- };
705
-
706
- await executeWait(call, options);
707
- if (result === undefined) {
708
- throw new Error('operation completed without a result.');
709
- }
710
- return result;
711
- }
712
-
713
- /** Checks whether the operation has reached a terminal state. */
714
- async done(options?: CallOptions): Promise<boolean> {
715
- const pollResp = await this.client.getInferenceEndpoint(
716
- {
717
- name: this.name,
718
- },
719
- options
720
- );
721
-
722
- const status = pollResp.state?.configUpdate;
723
- if (status === undefined) {
724
- throw new Error('response missing required status field');
725
- }
726
-
727
- switch (status) {
728
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
729
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
730
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
731
- return true;
732
- default:
733
- return false;
734
- }
735
- }
736
- }
737
-
738
- export class CreateProvisionedThroughputInferenceEndpointWaiter {
739
- constructor(
740
- private readonly client: ModelServingClient,
741
- readonly name: string
742
- ) {}
743
-
744
- /**
745
- * Polls until the operation reaches a terminal state.
746
- *
747
- * Throws if a failure state is reached.
748
- */
749
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
750
- let result: InferenceEndpointDetailed | undefined;
751
-
752
- const call = async (callSignal?: AbortSignal): Promise<void> => {
753
- const pollResp = await this.client.getInferenceEndpoint(
754
- {
755
- name: this.name,
756
- },
757
- callSignal !== undefined ? {signal: callSignal} : undefined
758
- );
759
-
760
- const status = pollResp.state?.configUpdate;
761
- if (status === undefined) {
762
- throw new Error('response missing required status field');
763
- }
764
-
765
- switch (status) {
766
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
767
- result = pollResp;
768
- return;
769
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
770
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
771
- const msg = '(no message)';
772
- throw new Error(`terminal state ${status}: ${msg}`);
773
- }
774
- default:
775
- throw new StillRunningError();
776
- }
777
- };
778
-
779
- await executeWait(call, options);
780
- if (result === undefined) {
781
- throw new Error('operation completed without a result.');
782
- }
783
- return result;
784
- }
785
-
786
- /** Checks whether the operation has reached a terminal state. */
787
- async done(options?: CallOptions): Promise<boolean> {
788
- const pollResp = await this.client.getInferenceEndpoint(
789
- {
790
- name: this.name,
791
- },
792
- options
793
- );
794
-
795
- const status = pollResp.state?.configUpdate;
796
- if (status === undefined) {
797
- throw new Error('response missing required status field');
798
- }
799
-
800
- switch (status) {
801
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
802
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
803
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
804
- return true;
805
- default:
806
- return false;
807
- }
808
- }
809
- }
810
-
811
- export class PutInferenceEndpointConfigWaiter {
812
- constructor(
813
- private readonly client: ModelServingClient,
814
- readonly name: string
815
- ) {}
816
-
817
- /**
818
- * Polls until the operation reaches a terminal state.
819
- *
820
- * Throws if a failure state is reached.
821
- */
822
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
823
- let result: InferenceEndpointDetailed | undefined;
824
-
825
- const call = async (callSignal?: AbortSignal): Promise<void> => {
826
- const pollResp = await this.client.getInferenceEndpoint(
827
- {
828
- name: this.name,
829
- },
830
- callSignal !== undefined ? {signal: callSignal} : undefined
831
- );
832
-
833
- const status = pollResp.state?.configUpdate;
834
- if (status === undefined) {
835
- throw new Error('response missing required status field');
836
- }
837
-
838
- switch (status) {
839
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
840
- result = pollResp;
841
- return;
842
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
843
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
844
- const msg = '(no message)';
845
- throw new Error(`terminal state ${status}: ${msg}`);
846
- }
847
- default:
848
- throw new StillRunningError();
849
- }
850
- };
851
-
852
- await executeWait(call, options);
853
- if (result === undefined) {
854
- throw new Error('operation completed without a result.');
855
- }
856
- return result;
857
- }
858
-
859
- /** Checks whether the operation has reached a terminal state. */
860
- async done(options?: CallOptions): Promise<boolean> {
861
- const pollResp = await this.client.getInferenceEndpoint(
862
- {
863
- name: this.name,
864
- },
865
- options
866
- );
867
-
868
- const status = pollResp.state?.configUpdate;
869
- if (status === undefined) {
870
- throw new Error('response missing required status field');
871
- }
872
-
873
- switch (status) {
874
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
875
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
876
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
877
- return true;
878
- default:
879
- return false;
880
- }
881
- }
882
- }
883
-
884
- export class PutProvisionedThroughputInferenceEndpointConfigWaiter {
885
- constructor(
886
- private readonly client: ModelServingClient,
887
- readonly name: string
888
- ) {}
889
-
890
- /**
891
- * Polls until the operation reaches a terminal state.
892
- *
893
- * Throws if a failure state is reached.
894
- */
895
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
896
- let result: InferenceEndpointDetailed | undefined;
897
-
898
- const call = async (callSignal?: AbortSignal): Promise<void> => {
899
- const pollResp = await this.client.getInferenceEndpoint(
900
- {
901
- name: this.name,
902
- },
903
- callSignal !== undefined ? {signal: callSignal} : undefined
904
- );
905
-
906
- const status = pollResp.state?.configUpdate;
907
- if (status === undefined) {
908
- throw new Error('response missing required status field');
909
- }
910
-
911
- switch (status) {
912
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
913
- result = pollResp;
914
- return;
915
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
916
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
917
- const msg = '(no message)';
918
- throw new Error(`terminal state ${status}: ${msg}`);
919
- }
920
- default:
921
- throw new StillRunningError();
922
- }
923
- };
924
-
925
- await executeWait(call, options);
926
- if (result === undefined) {
927
- throw new Error('operation completed without a result.');
928
- }
929
- return result;
930
- }
931
-
932
- /** Checks whether the operation has reached a terminal state. */
933
- async done(options?: CallOptions): Promise<boolean> {
934
- const pollResp = await this.client.getInferenceEndpoint(
935
- {
936
- name: this.name,
937
- },
938
- options
939
- );
940
-
941
- const status = pollResp.state?.configUpdate;
942
- if (status === undefined) {
943
- throw new Error('response missing required status field');
944
- }
945
-
946
- switch (status) {
947
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
948
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
949
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
950
- return true;
951
- default:
952
- return false;
953
- }
954
- }
955
- }