@databricks/sdk-modelserving 0.1.0-dev.3 → 0.1.0-dev.5

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,952 +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
- DeleteInferenceEndpointResponse,
28
- ExportMetricsResponse,
29
- ExternalFunctionRequest,
30
- ExternalFunctionResponse,
31
- GetExportEndpointMetricsRequest,
32
- GetInferenceEndpointRequest,
33
- GetInferenceEndpointSchemaRequest,
34
- GetOpenApiResponse,
35
- GetServedModelBuildLogsRequest,
36
- GetServedModelBuildLogsResponse,
37
- GetServedModelLogsRequest,
38
- GetServedModelLogsResponse,
39
- InferenceEndpointDetailed,
40
- ListInferenceEndpointsRequest,
41
- ListInferenceEndpointsResponse,
42
- PatchInferenceEndpointTagsRequest,
43
- PatchInferenceEndpointTagsResponse,
44
- PutInferenceEndpointAiGatewayRequest,
45
- PutInferenceEndpointAiGatewayResponse,
46
- PutInferenceEndpointConfigRequest,
47
- PutInferenceEndpointRateLimitsRequest,
48
- PutInferenceEndpointRateLimitsResponse,
49
- PutPtEndpointConfigRequest,
50
- UpdateInferenceEndpointNotificationsRequest,
51
- UpdateInferenceEndpointNotificationsResponse,
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
- unmarshalDeleteInferenceEndpointResponseSchema,
65
- unmarshalGetServedModelBuildLogsResponseSchema,
66
- unmarshalGetServedModelLogsResponseSchema,
67
- unmarshalInferenceEndpointDetailedSchema,
68
- unmarshalListInferenceEndpointsResponseSchema,
69
- unmarshalPatchInferenceEndpointTagsResponseSchema,
70
- unmarshalPutInferenceEndpointAiGatewayResponseSchema,
71
- unmarshalPutInferenceEndpointRateLimitsResponseSchema,
72
- unmarshalUpdateInferenceEndpointNotificationsResponseSchema,
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<DeleteInferenceEndpointResponse> {
200
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}`;
201
- let resp: DeleteInferenceEndpointResponse | 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
- unmarshalDeleteInferenceEndpointResponseSchema
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<GetServedModelBuildLogsResponse> {
319
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/build-logs`;
320
- let resp: GetServedModelBuildLogsResponse | 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
- unmarshalGetServedModelBuildLogsResponseSchema
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<GetServedModelLogsResponse> {
350
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/logs`;
351
- let resp: GetServedModelLogsResponse | 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(respBody, unmarshalGetServedModelLogsResponseSchema);
365
- };
366
- await executeCall(call, options);
367
- if (resp === undefined) {
368
- throw new Error('operation completed without a result.');
369
- }
370
- return resp;
371
- }
372
-
373
- /** Get all serving endpoints. */
374
- async listInferenceEndpoints(
375
- _req: ListInferenceEndpointsRequest,
376
- options?: CallOptions
377
- ): Promise<ListInferenceEndpointsResponse> {
378
- const url = `${this.host}/api/2.0/serving-endpoints`;
379
- let resp: ListInferenceEndpointsResponse | undefined;
380
- const call = async (callSignal?: AbortSignal): Promise<void> => {
381
- const headers = new Headers();
382
- if (this.workspaceId !== undefined) {
383
- headers.set('X-Databricks-Org-Id', this.workspaceId);
384
- }
385
- headers.set('User-Agent', this.userAgent);
386
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
387
- const respBody = await executeHttpCall({
388
- request: httpReq,
389
- httpClient: this.httpClient,
390
- logger: this.logger,
391
- });
392
- resp = parseResponse(
393
- respBody,
394
- unmarshalListInferenceEndpointsResponseSchema
395
- );
396
- };
397
- await executeCall(call, options);
398
- if (resp === undefined) {
399
- throw new Error('operation completed without a result.');
400
- }
401
- return resp;
402
- }
403
-
404
- /** Used to batch add and delete tags from a serving endpoint with a single API call. */
405
- async patchInferenceEndpointTags(
406
- req: PatchInferenceEndpointTagsRequest,
407
- options?: CallOptions
408
- ): Promise<PatchInferenceEndpointTagsResponse> {
409
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/tags`;
410
- const body = marshalRequest(
411
- req,
412
- marshalPatchInferenceEndpointTagsRequestSchema
413
- );
414
- let resp: PatchInferenceEndpointTagsResponse | undefined;
415
- const call = async (callSignal?: AbortSignal): Promise<void> => {
416
- const headers = new Headers({'Content-Type': 'application/json'});
417
- if (this.workspaceId !== undefined) {
418
- headers.set('X-Databricks-Org-Id', this.workspaceId);
419
- }
420
- headers.set('User-Agent', this.userAgent);
421
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
422
- const respBody = await executeHttpCall({
423
- request: httpReq,
424
- httpClient: this.httpClient,
425
- logger: this.logger,
426
- });
427
- resp = parseResponse(
428
- respBody,
429
- unmarshalPatchInferenceEndpointTagsResponseSchema
430
- );
431
- };
432
- await executeCall(call, options);
433
- if (resp === undefined) {
434
- throw new Error('operation completed without a result.');
435
- }
436
- return resp;
437
- }
438
-
439
- /** 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. */
440
- async putInferenceEndpointAiGateway(
441
- req: PutInferenceEndpointAiGatewayRequest,
442
- options?: CallOptions
443
- ): Promise<PutInferenceEndpointAiGatewayResponse> {
444
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/ai-gateway`;
445
- const body = marshalRequest(
446
- req,
447
- marshalPutInferenceEndpointAiGatewayRequestSchema
448
- );
449
- let resp: PutInferenceEndpointAiGatewayResponse | undefined;
450
- const call = async (callSignal?: AbortSignal): Promise<void> => {
451
- const headers = new Headers({'Content-Type': 'application/json'});
452
- if (this.workspaceId !== undefined) {
453
- headers.set('X-Databricks-Org-Id', this.workspaceId);
454
- }
455
- headers.set('User-Agent', this.userAgent);
456
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
457
- const respBody = await executeHttpCall({
458
- request: httpReq,
459
- httpClient: this.httpClient,
460
- logger: this.logger,
461
- });
462
- resp = parseResponse(
463
- respBody,
464
- unmarshalPutInferenceEndpointAiGatewayResponseSchema
465
- );
466
- };
467
- await executeCall(call, options);
468
- if (resp === undefined) {
469
- throw new Error('operation completed without a result.');
470
- }
471
- return resp;
472
- }
473
-
474
- /** 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. */
475
- private async putInferenceEndpointConfig(
476
- req: PutInferenceEndpointConfigRequest,
477
- options?: CallOptions
478
- ): Promise<InferenceEndpointDetailed> {
479
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/config`;
480
- const body = marshalRequest(
481
- req,
482
- marshalPutInferenceEndpointConfigRequestSchema
483
- );
484
- let resp: InferenceEndpointDetailed | undefined;
485
- const call = async (callSignal?: AbortSignal): Promise<void> => {
486
- const headers = new Headers({'Content-Type': 'application/json'});
487
- if (this.workspaceId !== undefined) {
488
- headers.set('X-Databricks-Org-Id', this.workspaceId);
489
- }
490
- headers.set('User-Agent', this.userAgent);
491
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
492
- const respBody = await executeHttpCall({
493
- request: httpReq,
494
- httpClient: this.httpClient,
495
- logger: this.logger,
496
- });
497
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
498
- };
499
- await executeCall(call, options);
500
- if (resp === undefined) {
501
- throw new Error('operation completed without a result.');
502
- }
503
- return resp;
504
- }
505
-
506
- async putInferenceEndpointConfigWaiter(
507
- req: PutInferenceEndpointConfigRequest,
508
- options?: CallOptions
509
- ): Promise<PutInferenceEndpointConfigWaiter> {
510
- await this.putInferenceEndpointConfig(req, options);
511
- if (req.name === undefined) {
512
- throw new Error('request field name required for polling is missing');
513
- }
514
- return new PutInferenceEndpointConfigWaiter(this, req.name);
515
- }
516
-
517
- /** Deprecated: Please use AI Gateway to manage rate limits instead. */
518
- async putInferenceEndpointRateLimits(
519
- req: PutInferenceEndpointRateLimitsRequest,
520
- options?: CallOptions
521
- ): Promise<PutInferenceEndpointRateLimitsResponse> {
522
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/rate-limits`;
523
- const body = marshalRequest(
524
- req,
525
- marshalPutInferenceEndpointRateLimitsRequestSchema
526
- );
527
- let resp: PutInferenceEndpointRateLimitsResponse | undefined;
528
- const call = async (callSignal?: AbortSignal): Promise<void> => {
529
- const headers = new Headers({'Content-Type': 'application/json'});
530
- if (this.workspaceId !== undefined) {
531
- headers.set('X-Databricks-Org-Id', this.workspaceId);
532
- }
533
- headers.set('User-Agent', this.userAgent);
534
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
535
- const respBody = await executeHttpCall({
536
- request: httpReq,
537
- httpClient: this.httpClient,
538
- logger: this.logger,
539
- });
540
- resp = parseResponse(
541
- respBody,
542
- unmarshalPutInferenceEndpointRateLimitsResponseSchema
543
- );
544
- };
545
- await executeCall(call, options);
546
- if (resp === undefined) {
547
- throw new Error('operation completed without a result.');
548
- }
549
- return resp;
550
- }
551
-
552
- /** 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 */
553
- private async putProvisionedThroughputInferenceEndpointConfig(
554
- req: PutPtEndpointConfigRequest,
555
- options?: CallOptions
556
- ): Promise<InferenceEndpointDetailed> {
557
- const url = `${this.host}/api/2.0/serving-endpoints/pt/${req.name ?? ''}/config`;
558
- const body = marshalRequest(req, marshalPutPtEndpointConfigRequestSchema);
559
- let resp: InferenceEndpointDetailed | undefined;
560
- const call = async (callSignal?: AbortSignal): Promise<void> => {
561
- const headers = new Headers({'Content-Type': 'application/json'});
562
- if (this.workspaceId !== undefined) {
563
- headers.set('X-Databricks-Org-Id', this.workspaceId);
564
- }
565
- headers.set('User-Agent', this.userAgent);
566
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
567
- const respBody = await executeHttpCall({
568
- request: httpReq,
569
- httpClient: this.httpClient,
570
- logger: this.logger,
571
- });
572
- resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
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
- async putProvisionedThroughputInferenceEndpointConfigWaiter(
582
- req: PutPtEndpointConfigRequest,
583
- options?: CallOptions
584
- ): Promise<PutProvisionedThroughputInferenceEndpointConfigWaiter> {
585
- await this.putProvisionedThroughputInferenceEndpointConfig(req, options);
586
- if (req.name === undefined) {
587
- throw new Error('request field name required for polling is missing');
588
- }
589
- return new PutProvisionedThroughputInferenceEndpointConfigWaiter(
590
- this,
591
- req.name
592
- );
593
- }
594
-
595
- /** Updates the email and webhook notification settings for an endpoint. */
596
- async updateInferenceEndpointNotifications(
597
- req: UpdateInferenceEndpointNotificationsRequest,
598
- options?: CallOptions
599
- ): Promise<UpdateInferenceEndpointNotificationsResponse> {
600
- const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/notifications`;
601
- const body = marshalRequest(
602
- req,
603
- marshalUpdateInferenceEndpointNotificationsRequestSchema
604
- );
605
- let resp: UpdateInferenceEndpointNotificationsResponse | undefined;
606
- const call = async (callSignal?: AbortSignal): Promise<void> => {
607
- const headers = new Headers({'Content-Type': 'application/json'});
608
- if (this.workspaceId !== undefined) {
609
- headers.set('X-Databricks-Org-Id', this.workspaceId);
610
- }
611
- headers.set('User-Agent', this.userAgent);
612
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
613
- const respBody = await executeHttpCall({
614
- request: httpReq,
615
- httpClient: this.httpClient,
616
- logger: this.logger,
617
- });
618
- resp = parseResponse(
619
- respBody,
620
- unmarshalUpdateInferenceEndpointNotificationsResponseSchema
621
- );
622
- };
623
- await executeCall(call, options);
624
- if (resp === undefined) {
625
- throw new Error('operation completed without a result.');
626
- }
627
- return resp;
628
- }
629
-
630
- /** Make external services call using the credentials stored in UC Connection. */
631
- async httpRequest(
632
- req: ExternalFunctionRequest,
633
- options?: CallOptions
634
- ): Promise<ExternalFunctionResponse> {
635
- const url = `${this.host}/api/2.0/external-function`;
636
- const body = marshalRequest(req, marshalExternalFunctionRequestSchema);
637
- let resp: ExternalFunctionResponse | undefined;
638
- const call = async (callSignal?: AbortSignal): Promise<void> => {
639
- const headers = new Headers({'Content-Type': 'application/json'});
640
- if (this.workspaceId !== undefined) {
641
- headers.set('X-Databricks-Org-Id', this.workspaceId);
642
- }
643
- headers.set('User-Agent', this.userAgent);
644
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
645
- const httpResp = await sendAndCheckError({
646
- request: httpReq,
647
- httpClient: this.httpClient,
648
- logger: this.logger,
649
- });
650
- resp = {
651
- contents: httpResp.body ?? undefined,
652
- };
653
- };
654
- await executeCall(call, options);
655
- if (resp === undefined) {
656
- throw new Error('operation completed without a result.');
657
- }
658
- return resp;
659
- }
660
- }
661
-
662
- export class CreateInferenceEndpointWaiter {
663
- constructor(
664
- private readonly client: ModelServingClient,
665
- readonly name: string
666
- ) {}
667
-
668
- /**
669
- * Polls until the operation reaches a terminal state.
670
- *
671
- * Throws if a failure state is reached.
672
- */
673
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
674
- let result: InferenceEndpointDetailed | undefined;
675
-
676
- const call = async (callSignal?: AbortSignal): Promise<void> => {
677
- const pollResp = await this.client.getInferenceEndpoint(
678
- {
679
- name: this.name,
680
- },
681
- callSignal !== undefined ? {signal: callSignal} : undefined
682
- );
683
-
684
- const status = pollResp.state?.configUpdate;
685
- if (status === undefined) {
686
- throw new Error('response missing required status field');
687
- }
688
-
689
- switch (status) {
690
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
691
- result = pollResp;
692
- return;
693
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
694
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
695
- const msg = '(no message)';
696
- throw new Error(`terminal state ${status}: ${msg}`);
697
- }
698
- default:
699
- throw new StillRunningError();
700
- }
701
- };
702
-
703
- await executeWait(call, options);
704
- if (result === undefined) {
705
- throw new Error('operation completed without a result.');
706
- }
707
- return result;
708
- }
709
-
710
- /** Checks whether the operation has reached a terminal state. */
711
- async done(options?: CallOptions): Promise<boolean> {
712
- const pollResp = await this.client.getInferenceEndpoint(
713
- {
714
- name: this.name,
715
- },
716
- options
717
- );
718
-
719
- const status = pollResp.state?.configUpdate;
720
- if (status === undefined) {
721
- throw new Error('response missing required status field');
722
- }
723
-
724
- switch (status) {
725
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
726
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
727
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
728
- return true;
729
- default:
730
- return false;
731
- }
732
- }
733
- }
734
-
735
- export class CreateProvisionedThroughputInferenceEndpointWaiter {
736
- constructor(
737
- private readonly client: ModelServingClient,
738
- readonly name: string
739
- ) {}
740
-
741
- /**
742
- * Polls until the operation reaches a terminal state.
743
- *
744
- * Throws if a failure state is reached.
745
- */
746
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
747
- let result: InferenceEndpointDetailed | undefined;
748
-
749
- const call = async (callSignal?: AbortSignal): Promise<void> => {
750
- const pollResp = await this.client.getInferenceEndpoint(
751
- {
752
- name: this.name,
753
- },
754
- callSignal !== undefined ? {signal: callSignal} : undefined
755
- );
756
-
757
- const status = pollResp.state?.configUpdate;
758
- if (status === undefined) {
759
- throw new Error('response missing required status field');
760
- }
761
-
762
- switch (status) {
763
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
764
- result = pollResp;
765
- return;
766
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
767
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
768
- const msg = '(no message)';
769
- throw new Error(`terminal state ${status}: ${msg}`);
770
- }
771
- default:
772
- throw new StillRunningError();
773
- }
774
- };
775
-
776
- await executeWait(call, options);
777
- if (result === undefined) {
778
- throw new Error('operation completed without a result.');
779
- }
780
- return result;
781
- }
782
-
783
- /** Checks whether the operation has reached a terminal state. */
784
- async done(options?: CallOptions): Promise<boolean> {
785
- const pollResp = await this.client.getInferenceEndpoint(
786
- {
787
- name: this.name,
788
- },
789
- options
790
- );
791
-
792
- const status = pollResp.state?.configUpdate;
793
- if (status === undefined) {
794
- throw new Error('response missing required status field');
795
- }
796
-
797
- switch (status) {
798
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
799
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
800
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
801
- return true;
802
- default:
803
- return false;
804
- }
805
- }
806
- }
807
-
808
- export class PutInferenceEndpointConfigWaiter {
809
- constructor(
810
- private readonly client: ModelServingClient,
811
- readonly name: string
812
- ) {}
813
-
814
- /**
815
- * Polls until the operation reaches a terminal state.
816
- *
817
- * Throws if a failure state is reached.
818
- */
819
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
820
- let result: InferenceEndpointDetailed | undefined;
821
-
822
- const call = async (callSignal?: AbortSignal): Promise<void> => {
823
- const pollResp = await this.client.getInferenceEndpoint(
824
- {
825
- name: this.name,
826
- },
827
- callSignal !== undefined ? {signal: callSignal} : undefined
828
- );
829
-
830
- const status = pollResp.state?.configUpdate;
831
- if (status === undefined) {
832
- throw new Error('response missing required status field');
833
- }
834
-
835
- switch (status) {
836
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
837
- result = pollResp;
838
- return;
839
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
840
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
841
- const msg = '(no message)';
842
- throw new Error(`terminal state ${status}: ${msg}`);
843
- }
844
- default:
845
- throw new StillRunningError();
846
- }
847
- };
848
-
849
- await executeWait(call, options);
850
- if (result === undefined) {
851
- throw new Error('operation completed without a result.');
852
- }
853
- return result;
854
- }
855
-
856
- /** Checks whether the operation has reached a terminal state. */
857
- async done(options?: CallOptions): Promise<boolean> {
858
- const pollResp = await this.client.getInferenceEndpoint(
859
- {
860
- name: this.name,
861
- },
862
- options
863
- );
864
-
865
- const status = pollResp.state?.configUpdate;
866
- if (status === undefined) {
867
- throw new Error('response missing required status field');
868
- }
869
-
870
- switch (status) {
871
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
872
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
873
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
874
- return true;
875
- default:
876
- return false;
877
- }
878
- }
879
- }
880
-
881
- export class PutProvisionedThroughputInferenceEndpointConfigWaiter {
882
- constructor(
883
- private readonly client: ModelServingClient,
884
- readonly name: string
885
- ) {}
886
-
887
- /**
888
- * Polls until the operation reaches a terminal state.
889
- *
890
- * Throws if a failure state is reached.
891
- */
892
- async wait(options?: LroOptions): Promise<InferenceEndpointDetailed> {
893
- let result: InferenceEndpointDetailed | undefined;
894
-
895
- const call = async (callSignal?: AbortSignal): Promise<void> => {
896
- const pollResp = await this.client.getInferenceEndpoint(
897
- {
898
- name: this.name,
899
- },
900
- callSignal !== undefined ? {signal: callSignal} : undefined
901
- );
902
-
903
- const status = pollResp.state?.configUpdate;
904
- if (status === undefined) {
905
- throw new Error('response missing required status field');
906
- }
907
-
908
- switch (status) {
909
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
910
- result = pollResp;
911
- return;
912
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
913
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
914
- const msg = '(no message)';
915
- throw new Error(`terminal state ${status}: ${msg}`);
916
- }
917
- default:
918
- throw new StillRunningError();
919
- }
920
- };
921
-
922
- await executeWait(call, options);
923
- if (result === undefined) {
924
- throw new Error('operation completed without a result.');
925
- }
926
- return result;
927
- }
928
-
929
- /** Checks whether the operation has reached a terminal state. */
930
- async done(options?: CallOptions): Promise<boolean> {
931
- const pollResp = await this.client.getInferenceEndpoint(
932
- {
933
- name: this.name,
934
- },
935
- options
936
- );
937
-
938
- const status = pollResp.state?.configUpdate;
939
- if (status === undefined) {
940
- throw new Error('response missing required status field');
941
- }
942
-
943
- switch (status) {
944
- case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
945
- case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
946
- case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
947
- return true;
948
- default:
949
- return false;
950
- }
951
- }
952
- }