@databricks/sdk-modelserving 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.
- package/LICENSE +203 -0
- package/dist/v1/client.d.ts +100 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +735 -0
- package/dist/v1/client.js.map +1 -0
- package/dist/v1/index.d.ts +4 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +4 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/model.d.ts +1087 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +1424 -0
- package/dist/v1/model.js.map +1 -0
- package/dist/v1/transport.d.ts +5 -0
- package/dist/v1/transport.d.ts.map +1 -0
- package/dist/v1/transport.js +57 -0
- package/dist/v1/transport.js.map +1 -0
- package/dist/v1/utils.d.ts +28 -0
- package/dist/v1/utils.d.ts.map +1 -0
- package/dist/v1/utils.js +142 -0
- package/dist/v1/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v1/client.ts +984 -0
- package/src/v1/index.ts +92 -0
- package/src/v1/model.ts +2589 -0
- package/src/v1/transport.ts +73 -0
- package/src/v1/utils.ts +191 -0
- package/README.md +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
|
+
import { retryOn } from '@databricks/sdk-core/api';
|
|
4
|
+
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
5
|
+
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
6
|
+
import { newHttpClient } from './transport';
|
|
7
|
+
import { buildHttpRequest, executeCall, executeHttpCall, sendAndCheckError, marshalRequest, parseResponse, } from './utils';
|
|
8
|
+
import pkgJson from '../../package.json' with { type: 'json' };
|
|
9
|
+
import { InferenceEndpointState_ConfigUpdateState, marshalCreateInferenceEndpointRequestSchema, marshalCreatePtEndpointRequestSchema, marshalExternalFunctionRequestSchema, marshalPatchInferenceEndpointTagsRequestSchema, marshalPutInferenceEndpointAiGatewayRequestSchema, marshalPutInferenceEndpointConfigRequestSchema, marshalPutInferenceEndpointRateLimitsRequestSchema, marshalPutPtEndpointConfigRequestSchema, marshalUpdateInferenceEndpointNotificationsRequestSchema, unmarshalDeleteInferenceEndpointRequest_ResponseSchema, unmarshalGetServedModelBuildLogsRequest_ResponseSchema, unmarshalGetServedModelLogsRequest_ResponseSchema, unmarshalInferenceEndpointDetailedSchema, unmarshalListInferenceEndpointsRequest_ResponseSchema, unmarshalPatchInferenceEndpointTagsRequest_ResponseSchema, unmarshalPutInferenceEndpointAiGatewayRequest_ResponseSchema, unmarshalPutInferenceEndpointRateLimitsRequest_ResponseSchema, unmarshalUpdateInferenceEndpointNotificationsRequest_ResponseSchema, } from './model';
|
|
10
|
+
// Package identity segment for this client to be used in the User-Agent header.
|
|
11
|
+
const PACKAGE_SEGMENT = {
|
|
12
|
+
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
13
|
+
value: pkgJson.version,
|
|
14
|
+
};
|
|
15
|
+
class StillRunningError extends Error {
|
|
16
|
+
}
|
|
17
|
+
export class ModelservingClient {
|
|
18
|
+
host;
|
|
19
|
+
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
20
|
+
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
21
|
+
// request.
|
|
22
|
+
workspaceId;
|
|
23
|
+
httpClient;
|
|
24
|
+
logger;
|
|
25
|
+
// User-Agent header value. Composed once at construction from
|
|
26
|
+
// createDefault() merged with this package's identity and the active
|
|
27
|
+
// credential's name.
|
|
28
|
+
userAgent;
|
|
29
|
+
constructor(options) {
|
|
30
|
+
if (options.host === undefined) {
|
|
31
|
+
throw new Error('Host is required.');
|
|
32
|
+
}
|
|
33
|
+
this.host = options.host.replace(/\/$/, '');
|
|
34
|
+
this.workspaceId = options.workspaceId;
|
|
35
|
+
this.logger = options.logger ?? new NoOpLogger();
|
|
36
|
+
const info = createDefault()
|
|
37
|
+
.with(PACKAGE_SEGMENT)
|
|
38
|
+
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
39
|
+
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
40
|
+
this.userAgent = info.toString();
|
|
41
|
+
this.httpClient = newHttpClient(options);
|
|
42
|
+
}
|
|
43
|
+
/** Create a new serving endpoint. */
|
|
44
|
+
async createInferenceEndpoint(req, options) {
|
|
45
|
+
const url = `${this.host}/api/2.0/serving-endpoints`;
|
|
46
|
+
const body = marshalRequest(req, marshalCreateInferenceEndpointRequestSchema);
|
|
47
|
+
let resp;
|
|
48
|
+
const call = async (callSignal) => {
|
|
49
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
50
|
+
if (this.workspaceId !== undefined) {
|
|
51
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
52
|
+
}
|
|
53
|
+
headers.set('User-Agent', this.userAgent);
|
|
54
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
55
|
+
const respBody = await executeHttpCall({
|
|
56
|
+
request: httpReq,
|
|
57
|
+
httpClient: this.httpClient,
|
|
58
|
+
logger: this.logger,
|
|
59
|
+
});
|
|
60
|
+
resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
|
|
61
|
+
};
|
|
62
|
+
await executeCall(call, options);
|
|
63
|
+
if (resp === undefined) {
|
|
64
|
+
throw new Error('API call completed without a result.');
|
|
65
|
+
}
|
|
66
|
+
return resp;
|
|
67
|
+
}
|
|
68
|
+
async createInferenceEndpointWaiter(req, options) {
|
|
69
|
+
await this.createInferenceEndpoint(req, options);
|
|
70
|
+
if (req.name === undefined) {
|
|
71
|
+
throw new Error('request field name required for polling is missing');
|
|
72
|
+
}
|
|
73
|
+
return new CreateInferenceEndpointWaiter(this, req.name);
|
|
74
|
+
}
|
|
75
|
+
/** Create a new PT serving endpoint. */
|
|
76
|
+
async createProvisionedThroughputInferenceEndpoint(req, options) {
|
|
77
|
+
const url = `${this.host}/api/2.0/serving-endpoints/pt`;
|
|
78
|
+
const body = marshalRequest(req, marshalCreatePtEndpointRequestSchema);
|
|
79
|
+
let resp;
|
|
80
|
+
const call = async (callSignal) => {
|
|
81
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
82
|
+
if (this.workspaceId !== undefined) {
|
|
83
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
84
|
+
}
|
|
85
|
+
headers.set('User-Agent', this.userAgent);
|
|
86
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
87
|
+
const respBody = await executeHttpCall({
|
|
88
|
+
request: httpReq,
|
|
89
|
+
httpClient: this.httpClient,
|
|
90
|
+
logger: this.logger,
|
|
91
|
+
});
|
|
92
|
+
resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
|
|
93
|
+
};
|
|
94
|
+
await executeCall(call, options);
|
|
95
|
+
if (resp === undefined) {
|
|
96
|
+
throw new Error('API call completed without a result.');
|
|
97
|
+
}
|
|
98
|
+
return resp;
|
|
99
|
+
}
|
|
100
|
+
async createProvisionedThroughputInferenceEndpointWaiter(req, options) {
|
|
101
|
+
await this.createProvisionedThroughputInferenceEndpoint(req, options);
|
|
102
|
+
if (req.name === undefined) {
|
|
103
|
+
throw new Error('request field name required for polling is missing');
|
|
104
|
+
}
|
|
105
|
+
return new CreateProvisionedThroughputInferenceEndpointWaiter(this, req.name);
|
|
106
|
+
}
|
|
107
|
+
/** Delete a serving endpoint. */
|
|
108
|
+
async deleteInferenceEndpoint(req, options) {
|
|
109
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}`;
|
|
110
|
+
let resp;
|
|
111
|
+
const call = async (callSignal) => {
|
|
112
|
+
const headers = new Headers();
|
|
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('DELETE', url, headers, callSignal);
|
|
118
|
+
const respBody = await executeHttpCall({
|
|
119
|
+
request: httpReq,
|
|
120
|
+
httpClient: this.httpClient,
|
|
121
|
+
logger: this.logger,
|
|
122
|
+
});
|
|
123
|
+
resp = parseResponse(respBody, unmarshalDeleteInferenceEndpointRequest_ResponseSchema);
|
|
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
|
+
/** Retrieves the metrics associated with the provided serving endpoint in either Prometheus or OpenMetrics exposition format. */
|
|
132
|
+
async getExportEndpointMetrics(req, options) {
|
|
133
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/metrics`;
|
|
134
|
+
let resp;
|
|
135
|
+
const call = async (callSignal) => {
|
|
136
|
+
const headers = new Headers();
|
|
137
|
+
if (this.workspaceId !== undefined) {
|
|
138
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
139
|
+
}
|
|
140
|
+
headers.set('User-Agent', this.userAgent);
|
|
141
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
142
|
+
const httpResp = await sendAndCheckError({
|
|
143
|
+
request: httpReq,
|
|
144
|
+
httpClient: this.httpClient,
|
|
145
|
+
logger: this.logger,
|
|
146
|
+
});
|
|
147
|
+
resp = {
|
|
148
|
+
contents: httpResp.body ?? undefined,
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
await executeCall(call, options);
|
|
152
|
+
if (resp === undefined) {
|
|
153
|
+
throw new Error('API call completed without a result.');
|
|
154
|
+
}
|
|
155
|
+
return resp;
|
|
156
|
+
}
|
|
157
|
+
/** Retrieves the details for a single serving endpoint. */
|
|
158
|
+
async getInferenceEndpoint(req, options) {
|
|
159
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}`;
|
|
160
|
+
let resp;
|
|
161
|
+
const call = async (callSignal) => {
|
|
162
|
+
const headers = new Headers();
|
|
163
|
+
if (this.workspaceId !== undefined) {
|
|
164
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
165
|
+
}
|
|
166
|
+
headers.set('User-Agent', this.userAgent);
|
|
167
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
168
|
+
const respBody = await executeHttpCall({
|
|
169
|
+
request: httpReq,
|
|
170
|
+
httpClient: this.httpClient,
|
|
171
|
+
logger: this.logger,
|
|
172
|
+
});
|
|
173
|
+
resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
|
|
174
|
+
};
|
|
175
|
+
await executeCall(call, options);
|
|
176
|
+
if (resp === undefined) {
|
|
177
|
+
throw new Error('API call completed without a result.');
|
|
178
|
+
}
|
|
179
|
+
return resp;
|
|
180
|
+
}
|
|
181
|
+
/** 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. */
|
|
182
|
+
async getInferenceEndpointSchema(req, options) {
|
|
183
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/openapi`;
|
|
184
|
+
let resp;
|
|
185
|
+
const call = async (callSignal) => {
|
|
186
|
+
const headers = new Headers();
|
|
187
|
+
if (this.workspaceId !== undefined) {
|
|
188
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
189
|
+
}
|
|
190
|
+
headers.set('User-Agent', this.userAgent);
|
|
191
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
192
|
+
const httpResp = await sendAndCheckError({
|
|
193
|
+
request: httpReq,
|
|
194
|
+
httpClient: this.httpClient,
|
|
195
|
+
logger: this.logger,
|
|
196
|
+
});
|
|
197
|
+
resp = {
|
|
198
|
+
contents: httpResp.body ?? undefined,
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
await executeCall(call, options);
|
|
202
|
+
if (resp === undefined) {
|
|
203
|
+
throw new Error('API call completed without a result.');
|
|
204
|
+
}
|
|
205
|
+
return resp;
|
|
206
|
+
}
|
|
207
|
+
/** Retrieves the build logs associated with the provided served model. */
|
|
208
|
+
async getServedModelBuildLogs(req, options) {
|
|
209
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/build-logs`;
|
|
210
|
+
let resp;
|
|
211
|
+
const call = async (callSignal) => {
|
|
212
|
+
const headers = new Headers();
|
|
213
|
+
if (this.workspaceId !== undefined) {
|
|
214
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
215
|
+
}
|
|
216
|
+
headers.set('User-Agent', this.userAgent);
|
|
217
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
218
|
+
const respBody = await executeHttpCall({
|
|
219
|
+
request: httpReq,
|
|
220
|
+
httpClient: this.httpClient,
|
|
221
|
+
logger: this.logger,
|
|
222
|
+
});
|
|
223
|
+
resp = parseResponse(respBody, unmarshalGetServedModelBuildLogsRequest_ResponseSchema);
|
|
224
|
+
};
|
|
225
|
+
await executeCall(call, options);
|
|
226
|
+
if (resp === undefined) {
|
|
227
|
+
throw new Error('API call completed without a result.');
|
|
228
|
+
}
|
|
229
|
+
return resp;
|
|
230
|
+
}
|
|
231
|
+
/** Retrieves the service logs associated with the provided served model. */
|
|
232
|
+
async getServedModelLogs(req, options) {
|
|
233
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/served-models/${req.servedModelName ?? ''}/logs`;
|
|
234
|
+
let resp;
|
|
235
|
+
const call = async (callSignal) => {
|
|
236
|
+
const headers = new Headers();
|
|
237
|
+
if (this.workspaceId !== undefined) {
|
|
238
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
239
|
+
}
|
|
240
|
+
headers.set('User-Agent', this.userAgent);
|
|
241
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
242
|
+
const respBody = await executeHttpCall({
|
|
243
|
+
request: httpReq,
|
|
244
|
+
httpClient: this.httpClient,
|
|
245
|
+
logger: this.logger,
|
|
246
|
+
});
|
|
247
|
+
resp = parseResponse(respBody, unmarshalGetServedModelLogsRequest_ResponseSchema);
|
|
248
|
+
};
|
|
249
|
+
await executeCall(call, options);
|
|
250
|
+
if (resp === undefined) {
|
|
251
|
+
throw new Error('API call completed without a result.');
|
|
252
|
+
}
|
|
253
|
+
return resp;
|
|
254
|
+
}
|
|
255
|
+
/** Get all serving endpoints. */
|
|
256
|
+
async listInferenceEndpoints(_req, options) {
|
|
257
|
+
const url = `${this.host}/api/2.0/serving-endpoints`;
|
|
258
|
+
let resp;
|
|
259
|
+
const call = async (callSignal) => {
|
|
260
|
+
const headers = new Headers();
|
|
261
|
+
if (this.workspaceId !== undefined) {
|
|
262
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
263
|
+
}
|
|
264
|
+
headers.set('User-Agent', this.userAgent);
|
|
265
|
+
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
266
|
+
const respBody = await executeHttpCall({
|
|
267
|
+
request: httpReq,
|
|
268
|
+
httpClient: this.httpClient,
|
|
269
|
+
logger: this.logger,
|
|
270
|
+
});
|
|
271
|
+
resp = parseResponse(respBody, unmarshalListInferenceEndpointsRequest_ResponseSchema);
|
|
272
|
+
};
|
|
273
|
+
await executeCall(call, options);
|
|
274
|
+
if (resp === undefined) {
|
|
275
|
+
throw new Error('API call completed without a result.');
|
|
276
|
+
}
|
|
277
|
+
return resp;
|
|
278
|
+
}
|
|
279
|
+
/** Used to batch add and delete tags from a serving endpoint with a single API call. */
|
|
280
|
+
async patchInferenceEndpointTags(req, options) {
|
|
281
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/tags`;
|
|
282
|
+
const body = marshalRequest(req, marshalPatchInferenceEndpointTagsRequestSchema);
|
|
283
|
+
let resp;
|
|
284
|
+
const call = async (callSignal) => {
|
|
285
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
286
|
+
if (this.workspaceId !== undefined) {
|
|
287
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
288
|
+
}
|
|
289
|
+
headers.set('User-Agent', this.userAgent);
|
|
290
|
+
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
291
|
+
const respBody = await executeHttpCall({
|
|
292
|
+
request: httpReq,
|
|
293
|
+
httpClient: this.httpClient,
|
|
294
|
+
logger: this.logger,
|
|
295
|
+
});
|
|
296
|
+
resp = parseResponse(respBody, unmarshalPatchInferenceEndpointTagsRequest_ResponseSchema);
|
|
297
|
+
};
|
|
298
|
+
await executeCall(call, options);
|
|
299
|
+
if (resp === undefined) {
|
|
300
|
+
throw new Error('API call completed without a result.');
|
|
301
|
+
}
|
|
302
|
+
return resp;
|
|
303
|
+
}
|
|
304
|
+
/** 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. */
|
|
305
|
+
async putInferenceEndpointAiGateway(req, options) {
|
|
306
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/ai-gateway`;
|
|
307
|
+
const body = marshalRequest(req, marshalPutInferenceEndpointAiGatewayRequestSchema);
|
|
308
|
+
let resp;
|
|
309
|
+
const call = async (callSignal) => {
|
|
310
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
311
|
+
if (this.workspaceId !== undefined) {
|
|
312
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
313
|
+
}
|
|
314
|
+
headers.set('User-Agent', this.userAgent);
|
|
315
|
+
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
316
|
+
const respBody = await executeHttpCall({
|
|
317
|
+
request: httpReq,
|
|
318
|
+
httpClient: this.httpClient,
|
|
319
|
+
logger: this.logger,
|
|
320
|
+
});
|
|
321
|
+
resp = parseResponse(respBody, unmarshalPutInferenceEndpointAiGatewayRequest_ResponseSchema);
|
|
322
|
+
};
|
|
323
|
+
await executeCall(call, options);
|
|
324
|
+
if (resp === undefined) {
|
|
325
|
+
throw new Error('API call completed without a result.');
|
|
326
|
+
}
|
|
327
|
+
return resp;
|
|
328
|
+
}
|
|
329
|
+
/** 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. */
|
|
330
|
+
async putInferenceEndpointConfig(req, options) {
|
|
331
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/config`;
|
|
332
|
+
const body = marshalRequest(req, marshalPutInferenceEndpointConfigRequestSchema);
|
|
333
|
+
let resp;
|
|
334
|
+
const call = async (callSignal) => {
|
|
335
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
336
|
+
if (this.workspaceId !== undefined) {
|
|
337
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
338
|
+
}
|
|
339
|
+
headers.set('User-Agent', this.userAgent);
|
|
340
|
+
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
341
|
+
const respBody = await executeHttpCall({
|
|
342
|
+
request: httpReq,
|
|
343
|
+
httpClient: this.httpClient,
|
|
344
|
+
logger: this.logger,
|
|
345
|
+
});
|
|
346
|
+
resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
|
|
347
|
+
};
|
|
348
|
+
await executeCall(call, options);
|
|
349
|
+
if (resp === undefined) {
|
|
350
|
+
throw new Error('API call completed without a result.');
|
|
351
|
+
}
|
|
352
|
+
return resp;
|
|
353
|
+
}
|
|
354
|
+
async putInferenceEndpointConfigWaiter(req, options) {
|
|
355
|
+
await this.putInferenceEndpointConfig(req, options);
|
|
356
|
+
if (req.name === undefined) {
|
|
357
|
+
throw new Error('request field name required for polling is missing');
|
|
358
|
+
}
|
|
359
|
+
return new PutInferenceEndpointConfigWaiter(this, req.name);
|
|
360
|
+
}
|
|
361
|
+
/** Deprecated: Please use AI Gateway to manage rate limits instead. */
|
|
362
|
+
async putInferenceEndpointRateLimits(req, options) {
|
|
363
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/rate-limits`;
|
|
364
|
+
const body = marshalRequest(req, marshalPutInferenceEndpointRateLimitsRequestSchema);
|
|
365
|
+
let resp;
|
|
366
|
+
const call = async (callSignal) => {
|
|
367
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
368
|
+
if (this.workspaceId !== undefined) {
|
|
369
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
370
|
+
}
|
|
371
|
+
headers.set('User-Agent', this.userAgent);
|
|
372
|
+
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
373
|
+
const respBody = await executeHttpCall({
|
|
374
|
+
request: httpReq,
|
|
375
|
+
httpClient: this.httpClient,
|
|
376
|
+
logger: this.logger,
|
|
377
|
+
});
|
|
378
|
+
resp = parseResponse(respBody, unmarshalPutInferenceEndpointRateLimitsRequest_ResponseSchema);
|
|
379
|
+
};
|
|
380
|
+
await executeCall(call, options);
|
|
381
|
+
if (resp === undefined) {
|
|
382
|
+
throw new Error('API call completed without a result.');
|
|
383
|
+
}
|
|
384
|
+
return resp;
|
|
385
|
+
}
|
|
386
|
+
/** 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 */
|
|
387
|
+
async putProvisionedThroughputInferenceEndpointConfig(req, options) {
|
|
388
|
+
const url = `${this.host}/api/2.0/serving-endpoints/pt/${req.name ?? ''}/config`;
|
|
389
|
+
const body = marshalRequest(req, marshalPutPtEndpointConfigRequestSchema);
|
|
390
|
+
let resp;
|
|
391
|
+
const call = async (callSignal) => {
|
|
392
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
393
|
+
if (this.workspaceId !== undefined) {
|
|
394
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
395
|
+
}
|
|
396
|
+
headers.set('User-Agent', this.userAgent);
|
|
397
|
+
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
398
|
+
const respBody = await executeHttpCall({
|
|
399
|
+
request: httpReq,
|
|
400
|
+
httpClient: this.httpClient,
|
|
401
|
+
logger: this.logger,
|
|
402
|
+
});
|
|
403
|
+
resp = parseResponse(respBody, unmarshalInferenceEndpointDetailedSchema);
|
|
404
|
+
};
|
|
405
|
+
await executeCall(call, options);
|
|
406
|
+
if (resp === undefined) {
|
|
407
|
+
throw new Error('API call completed without a result.');
|
|
408
|
+
}
|
|
409
|
+
return resp;
|
|
410
|
+
}
|
|
411
|
+
async putProvisionedThroughputInferenceEndpointConfigWaiter(req, options) {
|
|
412
|
+
await this.putProvisionedThroughputInferenceEndpointConfig(req, options);
|
|
413
|
+
if (req.name === undefined) {
|
|
414
|
+
throw new Error('request field name required for polling is missing');
|
|
415
|
+
}
|
|
416
|
+
return new PutProvisionedThroughputInferenceEndpointConfigWaiter(this, req.name);
|
|
417
|
+
}
|
|
418
|
+
/** Updates the email and webhook notification settings for an endpoint. */
|
|
419
|
+
async updateInferenceEndpointNotifications(req, options) {
|
|
420
|
+
const url = `${this.host}/api/2.0/serving-endpoints/${req.name ?? ''}/notifications`;
|
|
421
|
+
const body = marshalRequest(req, marshalUpdateInferenceEndpointNotificationsRequestSchema);
|
|
422
|
+
let resp;
|
|
423
|
+
const call = async (callSignal) => {
|
|
424
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
425
|
+
if (this.workspaceId !== undefined) {
|
|
426
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
427
|
+
}
|
|
428
|
+
headers.set('User-Agent', this.userAgent);
|
|
429
|
+
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
430
|
+
const respBody = await executeHttpCall({
|
|
431
|
+
request: httpReq,
|
|
432
|
+
httpClient: this.httpClient,
|
|
433
|
+
logger: this.logger,
|
|
434
|
+
});
|
|
435
|
+
resp = parseResponse(respBody, unmarshalUpdateInferenceEndpointNotificationsRequest_ResponseSchema);
|
|
436
|
+
};
|
|
437
|
+
await executeCall(call, options);
|
|
438
|
+
if (resp === undefined) {
|
|
439
|
+
throw new Error('API call completed without a result.');
|
|
440
|
+
}
|
|
441
|
+
return resp;
|
|
442
|
+
}
|
|
443
|
+
/** Make external services call using the credentials stored in UC Connection. */
|
|
444
|
+
async httpRequest(req, options) {
|
|
445
|
+
const url = `${this.host}/api/2.0/external-function`;
|
|
446
|
+
const body = marshalRequest(req, marshalExternalFunctionRequestSchema);
|
|
447
|
+
let resp;
|
|
448
|
+
const call = async (callSignal) => {
|
|
449
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
450
|
+
if (this.workspaceId !== undefined) {
|
|
451
|
+
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
452
|
+
}
|
|
453
|
+
headers.set('User-Agent', this.userAgent);
|
|
454
|
+
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
455
|
+
const httpResp = await sendAndCheckError({
|
|
456
|
+
request: httpReq,
|
|
457
|
+
httpClient: this.httpClient,
|
|
458
|
+
logger: this.logger,
|
|
459
|
+
});
|
|
460
|
+
resp = {
|
|
461
|
+
contents: httpResp.body ?? undefined,
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
await executeCall(call, options);
|
|
465
|
+
if (resp === undefined) {
|
|
466
|
+
throw new Error('API call completed without a result.');
|
|
467
|
+
}
|
|
468
|
+
return resp;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
export class CreateInferenceEndpointWaiter {
|
|
472
|
+
client;
|
|
473
|
+
name;
|
|
474
|
+
constructor(client, name) {
|
|
475
|
+
this.client = client;
|
|
476
|
+
this.name = name;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Polls until the operation reaches a terminal state.
|
|
480
|
+
*
|
|
481
|
+
* Throws if a failure state is reached.
|
|
482
|
+
*/
|
|
483
|
+
async wait(options) {
|
|
484
|
+
let result;
|
|
485
|
+
const call = async (callSignal) => {
|
|
486
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
487
|
+
name: this.name,
|
|
488
|
+
}, { ...options, ...(callSignal !== undefined && { signal: callSignal }) });
|
|
489
|
+
const status = pollResp.state?.configUpdate;
|
|
490
|
+
if (status === undefined) {
|
|
491
|
+
throw new Error('response missing required status field');
|
|
492
|
+
}
|
|
493
|
+
switch (status) {
|
|
494
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
495
|
+
result = pollResp;
|
|
496
|
+
return;
|
|
497
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
498
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
|
|
499
|
+
const msg = '(no message)';
|
|
500
|
+
throw new Error(`terminal state ${status}: ${msg}`);
|
|
501
|
+
}
|
|
502
|
+
default:
|
|
503
|
+
throw new StillRunningError();
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const retryOptions = {
|
|
507
|
+
...(options?.signal !== undefined && { signal: options.signal }),
|
|
508
|
+
retrier: () => retryOn({}, (err) => {
|
|
509
|
+
return err instanceof StillRunningError;
|
|
510
|
+
}),
|
|
511
|
+
};
|
|
512
|
+
await executeCall(call, retryOptions);
|
|
513
|
+
if (result === undefined) {
|
|
514
|
+
throw new Error('API call completed without a result.');
|
|
515
|
+
}
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
/** Checks whether the operation has reached a terminal state. */
|
|
519
|
+
async done(options) {
|
|
520
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
521
|
+
name: this.name,
|
|
522
|
+
}, options);
|
|
523
|
+
const status = pollResp.state?.configUpdate;
|
|
524
|
+
if (status === undefined) {
|
|
525
|
+
throw new Error('response missing required status field');
|
|
526
|
+
}
|
|
527
|
+
switch (status) {
|
|
528
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
529
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
530
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
|
|
531
|
+
return true;
|
|
532
|
+
default:
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
export class CreateProvisionedThroughputInferenceEndpointWaiter {
|
|
538
|
+
client;
|
|
539
|
+
name;
|
|
540
|
+
constructor(client, name) {
|
|
541
|
+
this.client = client;
|
|
542
|
+
this.name = name;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Polls until the operation reaches a terminal state.
|
|
546
|
+
*
|
|
547
|
+
* Throws if a failure state is reached.
|
|
548
|
+
*/
|
|
549
|
+
async wait(options) {
|
|
550
|
+
let result;
|
|
551
|
+
const call = async (callSignal) => {
|
|
552
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
553
|
+
name: this.name,
|
|
554
|
+
}, { ...options, ...(callSignal !== undefined && { signal: callSignal }) });
|
|
555
|
+
const status = pollResp.state?.configUpdate;
|
|
556
|
+
if (status === undefined) {
|
|
557
|
+
throw new Error('response missing required status field');
|
|
558
|
+
}
|
|
559
|
+
switch (status) {
|
|
560
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
561
|
+
result = pollResp;
|
|
562
|
+
return;
|
|
563
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
564
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
|
|
565
|
+
const msg = '(no message)';
|
|
566
|
+
throw new Error(`terminal state ${status}: ${msg}`);
|
|
567
|
+
}
|
|
568
|
+
default:
|
|
569
|
+
throw new StillRunningError();
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const retryOptions = {
|
|
573
|
+
...(options?.signal !== undefined && { signal: options.signal }),
|
|
574
|
+
retrier: () => retryOn({}, (err) => {
|
|
575
|
+
return err instanceof StillRunningError;
|
|
576
|
+
}),
|
|
577
|
+
};
|
|
578
|
+
await executeCall(call, retryOptions);
|
|
579
|
+
if (result === undefined) {
|
|
580
|
+
throw new Error('API call completed without a result.');
|
|
581
|
+
}
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
/** Checks whether the operation has reached a terminal state. */
|
|
585
|
+
async done(options) {
|
|
586
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
587
|
+
name: this.name,
|
|
588
|
+
}, options);
|
|
589
|
+
const status = pollResp.state?.configUpdate;
|
|
590
|
+
if (status === undefined) {
|
|
591
|
+
throw new Error('response missing required status field');
|
|
592
|
+
}
|
|
593
|
+
switch (status) {
|
|
594
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
595
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
596
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
|
|
597
|
+
return true;
|
|
598
|
+
default:
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
export class PutInferenceEndpointConfigWaiter {
|
|
604
|
+
client;
|
|
605
|
+
name;
|
|
606
|
+
constructor(client, name) {
|
|
607
|
+
this.client = client;
|
|
608
|
+
this.name = name;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Polls until the operation reaches a terminal state.
|
|
612
|
+
*
|
|
613
|
+
* Throws if a failure state is reached.
|
|
614
|
+
*/
|
|
615
|
+
async wait(options) {
|
|
616
|
+
let result;
|
|
617
|
+
const call = async (callSignal) => {
|
|
618
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
619
|
+
name: this.name,
|
|
620
|
+
}, { ...options, ...(callSignal !== undefined && { signal: callSignal }) });
|
|
621
|
+
const status = pollResp.state?.configUpdate;
|
|
622
|
+
if (status === undefined) {
|
|
623
|
+
throw new Error('response missing required status field');
|
|
624
|
+
}
|
|
625
|
+
switch (status) {
|
|
626
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
627
|
+
result = pollResp;
|
|
628
|
+
return;
|
|
629
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
630
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
|
|
631
|
+
const msg = '(no message)';
|
|
632
|
+
throw new Error(`terminal state ${status}: ${msg}`);
|
|
633
|
+
}
|
|
634
|
+
default:
|
|
635
|
+
throw new StillRunningError();
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
const retryOptions = {
|
|
639
|
+
...(options?.signal !== undefined && { signal: options.signal }),
|
|
640
|
+
retrier: () => retryOn({}, (err) => {
|
|
641
|
+
return err instanceof StillRunningError;
|
|
642
|
+
}),
|
|
643
|
+
};
|
|
644
|
+
await executeCall(call, retryOptions);
|
|
645
|
+
if (result === undefined) {
|
|
646
|
+
throw new Error('API call completed without a result.');
|
|
647
|
+
}
|
|
648
|
+
return result;
|
|
649
|
+
}
|
|
650
|
+
/** Checks whether the operation has reached a terminal state. */
|
|
651
|
+
async done(options) {
|
|
652
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
653
|
+
name: this.name,
|
|
654
|
+
}, options);
|
|
655
|
+
const status = pollResp.state?.configUpdate;
|
|
656
|
+
if (status === undefined) {
|
|
657
|
+
throw new Error('response missing required status field');
|
|
658
|
+
}
|
|
659
|
+
switch (status) {
|
|
660
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
661
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
662
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
|
|
663
|
+
return true;
|
|
664
|
+
default:
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
export class PutProvisionedThroughputInferenceEndpointConfigWaiter {
|
|
670
|
+
client;
|
|
671
|
+
name;
|
|
672
|
+
constructor(client, name) {
|
|
673
|
+
this.client = client;
|
|
674
|
+
this.name = name;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Polls until the operation reaches a terminal state.
|
|
678
|
+
*
|
|
679
|
+
* Throws if a failure state is reached.
|
|
680
|
+
*/
|
|
681
|
+
async wait(options) {
|
|
682
|
+
let result;
|
|
683
|
+
const call = async (callSignal) => {
|
|
684
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
685
|
+
name: this.name,
|
|
686
|
+
}, { ...options, ...(callSignal !== undefined && { signal: callSignal }) });
|
|
687
|
+
const status = pollResp.state?.configUpdate;
|
|
688
|
+
if (status === undefined) {
|
|
689
|
+
throw new Error('response missing required status field');
|
|
690
|
+
}
|
|
691
|
+
switch (status) {
|
|
692
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
693
|
+
result = pollResp;
|
|
694
|
+
return;
|
|
695
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
696
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED: {
|
|
697
|
+
const msg = '(no message)';
|
|
698
|
+
throw new Error(`terminal state ${status}: ${msg}`);
|
|
699
|
+
}
|
|
700
|
+
default:
|
|
701
|
+
throw new StillRunningError();
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const retryOptions = {
|
|
705
|
+
...(options?.signal !== undefined && { signal: options.signal }),
|
|
706
|
+
retrier: () => retryOn({}, (err) => {
|
|
707
|
+
return err instanceof StillRunningError;
|
|
708
|
+
}),
|
|
709
|
+
};
|
|
710
|
+
await executeCall(call, retryOptions);
|
|
711
|
+
if (result === undefined) {
|
|
712
|
+
throw new Error('API call completed without a result.');
|
|
713
|
+
}
|
|
714
|
+
return result;
|
|
715
|
+
}
|
|
716
|
+
/** Checks whether the operation has reached a terminal state. */
|
|
717
|
+
async done(options) {
|
|
718
|
+
const pollResp = await this.client.getInferenceEndpoint({
|
|
719
|
+
name: this.name,
|
|
720
|
+
}, options);
|
|
721
|
+
const status = pollResp.state?.configUpdate;
|
|
722
|
+
if (status === undefined) {
|
|
723
|
+
throw new Error('response missing required status field');
|
|
724
|
+
}
|
|
725
|
+
switch (status) {
|
|
726
|
+
case InferenceEndpointState_ConfigUpdateState.NOT_UPDATING:
|
|
727
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_FAILED:
|
|
728
|
+
case InferenceEndpointState_ConfigUpdateState.UPDATE_CANCELED:
|
|
729
|
+
return true;
|
|
730
|
+
default:
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
//# sourceMappingURL=client.js.map
|