@databricks/sdk-warehouses 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/dist/v1/client.d.ts +10 -10
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +10 -10
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/model.d.ts +274 -265
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +283 -293
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +2 -1
- package/dist/v1/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/v1/client.ts +0 -961
- package/src/v1/index.ts +0 -62
- package/src/v1/model.ts +0 -2008
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -180
package/src/v1/client.ts
DELETED
|
@@ -1,961 +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
|
-
marshalRequest,
|
|
17
|
-
parseResponse,
|
|
18
|
-
executeWait,
|
|
19
|
-
StillRunningError,
|
|
20
|
-
} from './utils';
|
|
21
|
-
import pkgJson from '../../package.json' with {type: 'json'};
|
|
22
|
-
import type {
|
|
23
|
-
CreateDefaultWarehouseOverrideRequest,
|
|
24
|
-
CreateWarehouseRequest,
|
|
25
|
-
CreateWarehouseRequest_Response,
|
|
26
|
-
DefaultWarehouseOverride,
|
|
27
|
-
DeleteDefaultWarehouseOverrideRequest,
|
|
28
|
-
DeleteWarehouseRequest,
|
|
29
|
-
DeleteWarehouseRequest_Response,
|
|
30
|
-
EditWarehouseRequest,
|
|
31
|
-
EditWarehouseRequest_Response,
|
|
32
|
-
EndpointInfo,
|
|
33
|
-
GetDefaultWarehouseOverrideRequest,
|
|
34
|
-
GetWarehouseRequest,
|
|
35
|
-
GetWarehouseRequest_Response,
|
|
36
|
-
GetWorkspaceWarehouseConfigRequest,
|
|
37
|
-
GetWorkspaceWarehouseConfigRequest_Response,
|
|
38
|
-
ListDefaultWarehouseOverridesRequest,
|
|
39
|
-
ListDefaultWarehouseOverridesResponse,
|
|
40
|
-
ListWarehousesRequest,
|
|
41
|
-
ListWarehousesRequest_Response,
|
|
42
|
-
SetWorkspaceWarehouseConfigRequest,
|
|
43
|
-
SetWorkspaceWarehouseConfigRequest_Response,
|
|
44
|
-
StartRequest,
|
|
45
|
-
StartRequest_Response,
|
|
46
|
-
StopRequest,
|
|
47
|
-
StopRequest_Response,
|
|
48
|
-
UpdateDefaultWarehouseOverrideRequest,
|
|
49
|
-
} from './model';
|
|
50
|
-
import {
|
|
51
|
-
EndpointState,
|
|
52
|
-
marshalCreateWarehouseRequestSchema,
|
|
53
|
-
marshalDefaultWarehouseOverrideSchema,
|
|
54
|
-
marshalEditWarehouseRequestSchema,
|
|
55
|
-
marshalSetWorkspaceWarehouseConfigRequestSchema,
|
|
56
|
-
marshalStartRequestSchema,
|
|
57
|
-
marshalStopRequestSchema,
|
|
58
|
-
unmarshalCreateWarehouseRequest_ResponseSchema,
|
|
59
|
-
unmarshalDefaultWarehouseOverrideSchema,
|
|
60
|
-
unmarshalDeleteWarehouseRequest_ResponseSchema,
|
|
61
|
-
unmarshalEditWarehouseRequest_ResponseSchema,
|
|
62
|
-
unmarshalGetWarehouseRequest_ResponseSchema,
|
|
63
|
-
unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema,
|
|
64
|
-
unmarshalListDefaultWarehouseOverridesResponseSchema,
|
|
65
|
-
unmarshalListWarehousesRequest_ResponseSchema,
|
|
66
|
-
unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema,
|
|
67
|
-
unmarshalStartRequest_ResponseSchema,
|
|
68
|
-
unmarshalStopRequest_ResponseSchema,
|
|
69
|
-
} from './model';
|
|
70
|
-
|
|
71
|
-
// Package identity segment for this client to be used in the User-Agent header.
|
|
72
|
-
const PACKAGE_SEGMENT = {
|
|
73
|
-
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
74
|
-
value: pkgJson.version,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export class WarehousesClient {
|
|
78
|
-
private readonly host: string;
|
|
79
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
80
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
81
|
-
// request.
|
|
82
|
-
private readonly workspaceId: string | undefined;
|
|
83
|
-
private readonly httpClient: HttpClient;
|
|
84
|
-
private readonly logger: Logger;
|
|
85
|
-
// User-Agent header value. Composed once at construction from
|
|
86
|
-
// createDefault() merged with this package's identity and the active
|
|
87
|
-
// credential's name.
|
|
88
|
-
private readonly userAgent: string;
|
|
89
|
-
|
|
90
|
-
constructor(options: ClientOptions) {
|
|
91
|
-
if (options.host === undefined) {
|
|
92
|
-
throw new Error('Host is required.');
|
|
93
|
-
}
|
|
94
|
-
this.host = options.host.replace(/\/$/, '');
|
|
95
|
-
this.workspaceId = options.workspaceId;
|
|
96
|
-
this.logger = options.logger ?? new NoOpLogger();
|
|
97
|
-
const info = createDefault()
|
|
98
|
-
.with(PACKAGE_SEGMENT)
|
|
99
|
-
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
100
|
-
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
101
|
-
this.userAgent = info.toString();
|
|
102
|
-
this.httpClient = newHttpClient(options);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Creates a new default warehouse override for a user.
|
|
107
|
-
* Users can create their own override. Admins can create overrides for any user.
|
|
108
|
-
*/
|
|
109
|
-
async createDefaultWarehouseOverride(
|
|
110
|
-
req: CreateDefaultWarehouseOverrideRequest,
|
|
111
|
-
options?: CallOptions
|
|
112
|
-
): Promise<DefaultWarehouseOverride> {
|
|
113
|
-
const url = `${this.host}/api/warehouses/v1/default-warehouse-overrides`;
|
|
114
|
-
const params = new URLSearchParams();
|
|
115
|
-
if (req.defaultWarehouseOverrideId !== undefined) {
|
|
116
|
-
params.append(
|
|
117
|
-
'default_warehouse_override_id',
|
|
118
|
-
req.defaultWarehouseOverrideId
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
const query = params.toString();
|
|
122
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
123
|
-
const body = marshalRequest(
|
|
124
|
-
req.defaultWarehouseOverride,
|
|
125
|
-
marshalDefaultWarehouseOverrideSchema
|
|
126
|
-
);
|
|
127
|
-
let resp: DefaultWarehouseOverride | undefined;
|
|
128
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
129
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
130
|
-
if (this.workspaceId !== undefined) {
|
|
131
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
132
|
-
}
|
|
133
|
-
headers.set('User-Agent', this.userAgent);
|
|
134
|
-
const httpReq = buildHttpRequest(
|
|
135
|
-
'POST',
|
|
136
|
-
fullUrl,
|
|
137
|
-
headers,
|
|
138
|
-
callSignal,
|
|
139
|
-
body
|
|
140
|
-
);
|
|
141
|
-
const respBody = await executeHttpCall({
|
|
142
|
-
request: httpReq,
|
|
143
|
-
httpClient: this.httpClient,
|
|
144
|
-
logger: this.logger,
|
|
145
|
-
});
|
|
146
|
-
resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema);
|
|
147
|
-
};
|
|
148
|
-
await executeCall(call, options);
|
|
149
|
-
if (resp === undefined) {
|
|
150
|
-
throw new Error('operation completed without a result.');
|
|
151
|
-
}
|
|
152
|
-
return resp;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** Creates a new SQL warehouse. */
|
|
156
|
-
private async createWarehouse(
|
|
157
|
-
req: CreateWarehouseRequest,
|
|
158
|
-
options?: CallOptions
|
|
159
|
-
): Promise<CreateWarehouseRequest_Response> {
|
|
160
|
-
const url = `${this.host}/api/2.0/sql/warehouses`;
|
|
161
|
-
const body = marshalRequest(req, marshalCreateWarehouseRequestSchema);
|
|
162
|
-
let resp: CreateWarehouseRequest_Response | undefined;
|
|
163
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
164
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
165
|
-
if (this.workspaceId !== undefined) {
|
|
166
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
167
|
-
}
|
|
168
|
-
headers.set('User-Agent', this.userAgent);
|
|
169
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
170
|
-
const respBody = await executeHttpCall({
|
|
171
|
-
request: httpReq,
|
|
172
|
-
httpClient: this.httpClient,
|
|
173
|
-
logger: this.logger,
|
|
174
|
-
});
|
|
175
|
-
resp = parseResponse(
|
|
176
|
-
respBody,
|
|
177
|
-
unmarshalCreateWarehouseRequest_ResponseSchema
|
|
178
|
-
);
|
|
179
|
-
};
|
|
180
|
-
await executeCall(call, options);
|
|
181
|
-
if (resp === undefined) {
|
|
182
|
-
throw new Error('operation completed without a result.');
|
|
183
|
-
}
|
|
184
|
-
return resp;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
async createWarehouseWaiter(
|
|
188
|
-
req: CreateWarehouseRequest,
|
|
189
|
-
options?: CallOptions
|
|
190
|
-
): Promise<CreateWarehouseWaiter> {
|
|
191
|
-
const resp = await this.createWarehouse(req, options);
|
|
192
|
-
if (resp.id === undefined) {
|
|
193
|
-
throw new Error('response field id required for polling is missing');
|
|
194
|
-
}
|
|
195
|
-
return new CreateWarehouseWaiter(this, resp.id);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Deletes the default warehouse override for a user.
|
|
200
|
-
* Users can delete their own override. Admins can delete overrides for any user.
|
|
201
|
-
* After deletion, the workspace default warehouse will be used.
|
|
202
|
-
*/
|
|
203
|
-
async deleteDefaultWarehouseOverride(
|
|
204
|
-
req: DeleteDefaultWarehouseOverrideRequest,
|
|
205
|
-
options?: CallOptions
|
|
206
|
-
): Promise<void> {
|
|
207
|
-
const url = `${this.host}/api/warehouses/v1/${req.name ?? ''}`;
|
|
208
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
209
|
-
const headers = new Headers();
|
|
210
|
-
if (this.workspaceId !== undefined) {
|
|
211
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
212
|
-
}
|
|
213
|
-
headers.set('User-Agent', this.userAgent);
|
|
214
|
-
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
215
|
-
await executeHttpCall({
|
|
216
|
-
request: httpReq,
|
|
217
|
-
httpClient: this.httpClient,
|
|
218
|
-
logger: this.logger,
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
await executeCall(call, options);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** Deletes a SQL warehouse. */
|
|
225
|
-
async deleteWarehouse(
|
|
226
|
-
req: DeleteWarehouseRequest,
|
|
227
|
-
options?: CallOptions
|
|
228
|
-
): Promise<DeleteWarehouseRequest_Response> {
|
|
229
|
-
const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}`;
|
|
230
|
-
let resp: DeleteWarehouseRequest_Response | undefined;
|
|
231
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
232
|
-
const headers = new Headers();
|
|
233
|
-
if (this.workspaceId !== undefined) {
|
|
234
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
235
|
-
}
|
|
236
|
-
headers.set('User-Agent', this.userAgent);
|
|
237
|
-
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
238
|
-
const respBody = await executeHttpCall({
|
|
239
|
-
request: httpReq,
|
|
240
|
-
httpClient: this.httpClient,
|
|
241
|
-
logger: this.logger,
|
|
242
|
-
});
|
|
243
|
-
resp = parseResponse(
|
|
244
|
-
respBody,
|
|
245
|
-
unmarshalDeleteWarehouseRequest_ResponseSchema
|
|
246
|
-
);
|
|
247
|
-
};
|
|
248
|
-
await executeCall(call, options);
|
|
249
|
-
if (resp === undefined) {
|
|
250
|
-
throw new Error('operation completed without a result.');
|
|
251
|
-
}
|
|
252
|
-
return resp;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/** Updates the configuration for a SQL warehouse. */
|
|
256
|
-
private async editWarehouse(
|
|
257
|
-
req: EditWarehouseRequest,
|
|
258
|
-
options?: CallOptions
|
|
259
|
-
): Promise<EditWarehouseRequest_Response> {
|
|
260
|
-
const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/edit`;
|
|
261
|
-
const body = marshalRequest(req, marshalEditWarehouseRequestSchema);
|
|
262
|
-
let resp: EditWarehouseRequest_Response | undefined;
|
|
263
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
264
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
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('POST', url, headers, callSignal, body);
|
|
270
|
-
const respBody = await executeHttpCall({
|
|
271
|
-
request: httpReq,
|
|
272
|
-
httpClient: this.httpClient,
|
|
273
|
-
logger: this.logger,
|
|
274
|
-
});
|
|
275
|
-
resp = parseResponse(
|
|
276
|
-
respBody,
|
|
277
|
-
unmarshalEditWarehouseRequest_ResponseSchema
|
|
278
|
-
);
|
|
279
|
-
};
|
|
280
|
-
await executeCall(call, options);
|
|
281
|
-
if (resp === undefined) {
|
|
282
|
-
throw new Error('operation completed without a result.');
|
|
283
|
-
}
|
|
284
|
-
return resp;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
async editWarehouseWaiter(
|
|
288
|
-
req: EditWarehouseRequest,
|
|
289
|
-
options?: CallOptions
|
|
290
|
-
): Promise<EditWarehouseWaiter> {
|
|
291
|
-
await this.editWarehouse(req, options);
|
|
292
|
-
if (req.id === undefined) {
|
|
293
|
-
throw new Error('request field id required for polling is missing');
|
|
294
|
-
}
|
|
295
|
-
return new EditWarehouseWaiter(this, req.id);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Returns the default warehouse override for a user.
|
|
300
|
-
* Users can fetch their own override. Admins can fetch overrides for any user.
|
|
301
|
-
* If no override exists, the UI will fallback to the workspace default warehouse.
|
|
302
|
-
*/
|
|
303
|
-
async getDefaultWarehouseOverride(
|
|
304
|
-
req: GetDefaultWarehouseOverrideRequest,
|
|
305
|
-
options?: CallOptions
|
|
306
|
-
): Promise<DefaultWarehouseOverride> {
|
|
307
|
-
const url = `${this.host}/api/warehouses/v1/${req.name ?? ''}`;
|
|
308
|
-
let resp: DefaultWarehouseOverride | undefined;
|
|
309
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
310
|
-
const headers = new Headers();
|
|
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('GET', url, headers, callSignal);
|
|
316
|
-
const respBody = await executeHttpCall({
|
|
317
|
-
request: httpReq,
|
|
318
|
-
httpClient: this.httpClient,
|
|
319
|
-
logger: this.logger,
|
|
320
|
-
});
|
|
321
|
-
resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema);
|
|
322
|
-
};
|
|
323
|
-
await executeCall(call, options);
|
|
324
|
-
if (resp === undefined) {
|
|
325
|
-
throw new Error('operation completed without a result.');
|
|
326
|
-
}
|
|
327
|
-
return resp;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/** Gets the information for a single SQL warehouse. */
|
|
331
|
-
async getWarehouse(
|
|
332
|
-
req: GetWarehouseRequest,
|
|
333
|
-
options?: CallOptions
|
|
334
|
-
): Promise<GetWarehouseRequest_Response> {
|
|
335
|
-
const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}`;
|
|
336
|
-
let resp: GetWarehouseRequest_Response | undefined;
|
|
337
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
338
|
-
const headers = new Headers();
|
|
339
|
-
if (this.workspaceId !== undefined) {
|
|
340
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
341
|
-
}
|
|
342
|
-
headers.set('User-Agent', this.userAgent);
|
|
343
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
344
|
-
const respBody = await executeHttpCall({
|
|
345
|
-
request: httpReq,
|
|
346
|
-
httpClient: this.httpClient,
|
|
347
|
-
logger: this.logger,
|
|
348
|
-
});
|
|
349
|
-
resp = parseResponse(
|
|
350
|
-
respBody,
|
|
351
|
-
unmarshalGetWarehouseRequest_ResponseSchema
|
|
352
|
-
);
|
|
353
|
-
};
|
|
354
|
-
await executeCall(call, options);
|
|
355
|
-
if (resp === undefined) {
|
|
356
|
-
throw new Error('operation completed without a result.');
|
|
357
|
-
}
|
|
358
|
-
return resp;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/** Gets the workspace level configuration that is shared by all SQL warehouses in a workspace. */
|
|
362
|
-
async getWorkspaceWarehouseConfig(
|
|
363
|
-
_req: GetWorkspaceWarehouseConfigRequest,
|
|
364
|
-
options?: CallOptions
|
|
365
|
-
): Promise<GetWorkspaceWarehouseConfigRequest_Response> {
|
|
366
|
-
const url = `${this.host}/api/2.0/sql/config/warehouses`;
|
|
367
|
-
let resp: GetWorkspaceWarehouseConfigRequest_Response | undefined;
|
|
368
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
369
|
-
const headers = new Headers();
|
|
370
|
-
if (this.workspaceId !== undefined) {
|
|
371
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
372
|
-
}
|
|
373
|
-
headers.set('User-Agent', this.userAgent);
|
|
374
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
375
|
-
const respBody = await executeHttpCall({
|
|
376
|
-
request: httpReq,
|
|
377
|
-
httpClient: this.httpClient,
|
|
378
|
-
logger: this.logger,
|
|
379
|
-
});
|
|
380
|
-
resp = parseResponse(
|
|
381
|
-
respBody,
|
|
382
|
-
unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema
|
|
383
|
-
);
|
|
384
|
-
};
|
|
385
|
-
await executeCall(call, options);
|
|
386
|
-
if (resp === undefined) {
|
|
387
|
-
throw new Error('operation completed without a result.');
|
|
388
|
-
}
|
|
389
|
-
return resp;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Lists all default warehouse overrides in the workspace.
|
|
394
|
-
* Only workspace administrators can list all overrides.
|
|
395
|
-
*/
|
|
396
|
-
async listDefaultWarehouseOverrides(
|
|
397
|
-
req: ListDefaultWarehouseOverridesRequest,
|
|
398
|
-
options?: CallOptions
|
|
399
|
-
): Promise<ListDefaultWarehouseOverridesResponse> {
|
|
400
|
-
const url = `${this.host}/api/warehouses/v1/default-warehouse-overrides`;
|
|
401
|
-
const params = new URLSearchParams();
|
|
402
|
-
if (req.pageSize !== undefined) {
|
|
403
|
-
params.append('page_size', String(req.pageSize));
|
|
404
|
-
}
|
|
405
|
-
if (req.pageToken !== undefined) {
|
|
406
|
-
params.append('page_token', req.pageToken);
|
|
407
|
-
}
|
|
408
|
-
const query = params.toString();
|
|
409
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
410
|
-
let resp: ListDefaultWarehouseOverridesResponse | undefined;
|
|
411
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
412
|
-
const headers = new Headers();
|
|
413
|
-
if (this.workspaceId !== undefined) {
|
|
414
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
415
|
-
}
|
|
416
|
-
headers.set('User-Agent', this.userAgent);
|
|
417
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
418
|
-
const respBody = await executeHttpCall({
|
|
419
|
-
request: httpReq,
|
|
420
|
-
httpClient: this.httpClient,
|
|
421
|
-
logger: this.logger,
|
|
422
|
-
});
|
|
423
|
-
resp = parseResponse(
|
|
424
|
-
respBody,
|
|
425
|
-
unmarshalListDefaultWarehouseOverridesResponseSchema
|
|
426
|
-
);
|
|
427
|
-
};
|
|
428
|
-
await executeCall(call, options);
|
|
429
|
-
if (resp === undefined) {
|
|
430
|
-
throw new Error('operation completed without a result.');
|
|
431
|
-
}
|
|
432
|
-
return resp;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
async *listDefaultWarehouseOverridesIter(
|
|
436
|
-
req: ListDefaultWarehouseOverridesRequest,
|
|
437
|
-
options?: CallOptions
|
|
438
|
-
): AsyncGenerator<DefaultWarehouseOverride> {
|
|
439
|
-
const pageReq: ListDefaultWarehouseOverridesRequest = {...req};
|
|
440
|
-
for (;;) {
|
|
441
|
-
const resp = await this.listDefaultWarehouseOverrides(pageReq, options);
|
|
442
|
-
for (const item of resp.defaultWarehouseOverrides ?? []) {
|
|
443
|
-
yield item;
|
|
444
|
-
}
|
|
445
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/** Lists all SQL warehouses that a user has access to. */
|
|
453
|
-
async listWarehouses(
|
|
454
|
-
req: ListWarehousesRequest,
|
|
455
|
-
options?: CallOptions
|
|
456
|
-
): Promise<ListWarehousesRequest_Response> {
|
|
457
|
-
const url = `${this.host}/api/2.0/sql/warehouses`;
|
|
458
|
-
const params = new URLSearchParams();
|
|
459
|
-
if (req.runAsUserId !== undefined) {
|
|
460
|
-
params.append('run_as_user_id', String(req.runAsUserId));
|
|
461
|
-
}
|
|
462
|
-
if (req.pageSize !== undefined) {
|
|
463
|
-
params.append('page_size', String(req.pageSize));
|
|
464
|
-
}
|
|
465
|
-
if (req.pageToken !== undefined) {
|
|
466
|
-
params.append('page_token', req.pageToken);
|
|
467
|
-
}
|
|
468
|
-
const query = params.toString();
|
|
469
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
470
|
-
let resp: ListWarehousesRequest_Response | undefined;
|
|
471
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
472
|
-
const headers = new Headers();
|
|
473
|
-
if (this.workspaceId !== undefined) {
|
|
474
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
475
|
-
}
|
|
476
|
-
headers.set('User-Agent', this.userAgent);
|
|
477
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
478
|
-
const respBody = await executeHttpCall({
|
|
479
|
-
request: httpReq,
|
|
480
|
-
httpClient: this.httpClient,
|
|
481
|
-
logger: this.logger,
|
|
482
|
-
});
|
|
483
|
-
resp = parseResponse(
|
|
484
|
-
respBody,
|
|
485
|
-
unmarshalListWarehousesRequest_ResponseSchema
|
|
486
|
-
);
|
|
487
|
-
};
|
|
488
|
-
await executeCall(call, options);
|
|
489
|
-
if (resp === undefined) {
|
|
490
|
-
throw new Error('operation completed without a result.');
|
|
491
|
-
}
|
|
492
|
-
return resp;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
async *listWarehousesIter(
|
|
496
|
-
req: ListWarehousesRequest,
|
|
497
|
-
options?: CallOptions
|
|
498
|
-
): AsyncGenerator<EndpointInfo> {
|
|
499
|
-
const pageReq: ListWarehousesRequest = {...req};
|
|
500
|
-
for (;;) {
|
|
501
|
-
const resp = await this.listWarehouses(pageReq, options);
|
|
502
|
-
for (const item of resp.warehouses ?? []) {
|
|
503
|
-
yield item;
|
|
504
|
-
}
|
|
505
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/** Sets the workspace level configuration that is shared by all SQL warehouses in a workspace. */
|
|
513
|
-
async setWorkspaceWarehouseConfig(
|
|
514
|
-
req: SetWorkspaceWarehouseConfigRequest,
|
|
515
|
-
options?: CallOptions
|
|
516
|
-
): Promise<SetWorkspaceWarehouseConfigRequest_Response> {
|
|
517
|
-
const url = `${this.host}/api/2.0/sql/config/warehouses`;
|
|
518
|
-
const body = marshalRequest(
|
|
519
|
-
req,
|
|
520
|
-
marshalSetWorkspaceWarehouseConfigRequestSchema
|
|
521
|
-
);
|
|
522
|
-
let resp: SetWorkspaceWarehouseConfigRequest_Response | undefined;
|
|
523
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
524
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
525
|
-
if (this.workspaceId !== undefined) {
|
|
526
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
527
|
-
}
|
|
528
|
-
headers.set('User-Agent', this.userAgent);
|
|
529
|
-
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
530
|
-
const respBody = await executeHttpCall({
|
|
531
|
-
request: httpReq,
|
|
532
|
-
httpClient: this.httpClient,
|
|
533
|
-
logger: this.logger,
|
|
534
|
-
});
|
|
535
|
-
resp = parseResponse(
|
|
536
|
-
respBody,
|
|
537
|
-
unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema
|
|
538
|
-
);
|
|
539
|
-
};
|
|
540
|
-
await executeCall(call, options);
|
|
541
|
-
if (resp === undefined) {
|
|
542
|
-
throw new Error('operation completed without a result.');
|
|
543
|
-
}
|
|
544
|
-
return resp;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/** Starts a SQL warehouse. */
|
|
548
|
-
private async startWarehouse(
|
|
549
|
-
req: StartRequest,
|
|
550
|
-
options?: CallOptions
|
|
551
|
-
): Promise<StartRequest_Response> {
|
|
552
|
-
const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/start`;
|
|
553
|
-
const body = marshalRequest(req, marshalStartRequestSchema);
|
|
554
|
-
let resp: StartRequest_Response | undefined;
|
|
555
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
556
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
557
|
-
if (this.workspaceId !== undefined) {
|
|
558
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
559
|
-
}
|
|
560
|
-
headers.set('User-Agent', this.userAgent);
|
|
561
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
562
|
-
const respBody = await executeHttpCall({
|
|
563
|
-
request: httpReq,
|
|
564
|
-
httpClient: this.httpClient,
|
|
565
|
-
logger: this.logger,
|
|
566
|
-
});
|
|
567
|
-
resp = parseResponse(respBody, unmarshalStartRequest_ResponseSchema);
|
|
568
|
-
};
|
|
569
|
-
await executeCall(call, options);
|
|
570
|
-
if (resp === undefined) {
|
|
571
|
-
throw new Error('operation completed without a result.');
|
|
572
|
-
}
|
|
573
|
-
return resp;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
async startWarehouseWaiter(
|
|
577
|
-
req: StartRequest,
|
|
578
|
-
options?: CallOptions
|
|
579
|
-
): Promise<StartWarehouseWaiter> {
|
|
580
|
-
await this.startWarehouse(req, options);
|
|
581
|
-
if (req.id === undefined) {
|
|
582
|
-
throw new Error('request field id required for polling is missing');
|
|
583
|
-
}
|
|
584
|
-
return new StartWarehouseWaiter(this, req.id);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/** Stops a SQL warehouse. */
|
|
588
|
-
private async stopWarehouse(
|
|
589
|
-
req: StopRequest,
|
|
590
|
-
options?: CallOptions
|
|
591
|
-
): Promise<StopRequest_Response> {
|
|
592
|
-
const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/stop`;
|
|
593
|
-
const body = marshalRequest(req, marshalStopRequestSchema);
|
|
594
|
-
let resp: StopRequest_Response | undefined;
|
|
595
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
596
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
597
|
-
if (this.workspaceId !== undefined) {
|
|
598
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
599
|
-
}
|
|
600
|
-
headers.set('User-Agent', this.userAgent);
|
|
601
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
602
|
-
const respBody = await executeHttpCall({
|
|
603
|
-
request: httpReq,
|
|
604
|
-
httpClient: this.httpClient,
|
|
605
|
-
logger: this.logger,
|
|
606
|
-
});
|
|
607
|
-
resp = parseResponse(respBody, unmarshalStopRequest_ResponseSchema);
|
|
608
|
-
};
|
|
609
|
-
await executeCall(call, options);
|
|
610
|
-
if (resp === undefined) {
|
|
611
|
-
throw new Error('operation completed without a result.');
|
|
612
|
-
}
|
|
613
|
-
return resp;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
async stopWarehouseWaiter(
|
|
617
|
-
req: StopRequest,
|
|
618
|
-
options?: CallOptions
|
|
619
|
-
): Promise<StopWarehouseWaiter> {
|
|
620
|
-
await this.stopWarehouse(req, options);
|
|
621
|
-
if (req.id === undefined) {
|
|
622
|
-
throw new Error('request field id required for polling is missing');
|
|
623
|
-
}
|
|
624
|
-
return new StopWarehouseWaiter(this, req.id);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Updates an existing default warehouse override for a user.
|
|
629
|
-
* Users can update their own override. Admins can update overrides for any user.
|
|
630
|
-
*/
|
|
631
|
-
async updateDefaultWarehouseOverride(
|
|
632
|
-
req: UpdateDefaultWarehouseOverrideRequest,
|
|
633
|
-
options?: CallOptions
|
|
634
|
-
): Promise<DefaultWarehouseOverride> {
|
|
635
|
-
const url = `${this.host}/api/warehouses/v1/${req.defaultWarehouseOverride?.name ?? ''}`;
|
|
636
|
-
const params = new URLSearchParams();
|
|
637
|
-
if (req.updateMask !== undefined) {
|
|
638
|
-
params.append('update_mask', req.updateMask.toString());
|
|
639
|
-
}
|
|
640
|
-
if (req.allowMissing !== undefined) {
|
|
641
|
-
params.append('allow_missing', String(req.allowMissing));
|
|
642
|
-
}
|
|
643
|
-
const query = params.toString();
|
|
644
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
645
|
-
const body = marshalRequest(
|
|
646
|
-
req.defaultWarehouseOverride,
|
|
647
|
-
marshalDefaultWarehouseOverrideSchema
|
|
648
|
-
);
|
|
649
|
-
let resp: DefaultWarehouseOverride | undefined;
|
|
650
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
651
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
652
|
-
if (this.workspaceId !== undefined) {
|
|
653
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
654
|
-
}
|
|
655
|
-
headers.set('User-Agent', this.userAgent);
|
|
656
|
-
const httpReq = buildHttpRequest(
|
|
657
|
-
'PATCH',
|
|
658
|
-
fullUrl,
|
|
659
|
-
headers,
|
|
660
|
-
callSignal,
|
|
661
|
-
body
|
|
662
|
-
);
|
|
663
|
-
const respBody = await executeHttpCall({
|
|
664
|
-
request: httpReq,
|
|
665
|
-
httpClient: this.httpClient,
|
|
666
|
-
logger: this.logger,
|
|
667
|
-
});
|
|
668
|
-
resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema);
|
|
669
|
-
};
|
|
670
|
-
await executeCall(call, options);
|
|
671
|
-
if (resp === undefined) {
|
|
672
|
-
throw new Error('operation completed without a result.');
|
|
673
|
-
}
|
|
674
|
-
return resp;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
export class CreateWarehouseWaiter {
|
|
679
|
-
constructor(
|
|
680
|
-
private readonly client: WarehousesClient,
|
|
681
|
-
readonly id: string
|
|
682
|
-
) {}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Polls until the operation reaches a terminal state.
|
|
686
|
-
*
|
|
687
|
-
* Throws if a failure state is reached.
|
|
688
|
-
*/
|
|
689
|
-
async wait(options?: LroOptions): Promise<GetWarehouseRequest_Response> {
|
|
690
|
-
let result: GetWarehouseRequest_Response | undefined;
|
|
691
|
-
|
|
692
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
693
|
-
const pollResp = await this.client.getWarehouse(
|
|
694
|
-
{
|
|
695
|
-
id: this.id,
|
|
696
|
-
},
|
|
697
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
698
|
-
);
|
|
699
|
-
|
|
700
|
-
const status = pollResp.state;
|
|
701
|
-
if (status === undefined) {
|
|
702
|
-
throw new Error('response missing required status field');
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
switch (status) {
|
|
706
|
-
case EndpointState.RUNNING:
|
|
707
|
-
result = pollResp;
|
|
708
|
-
return;
|
|
709
|
-
case EndpointState.STOPPED:
|
|
710
|
-
case EndpointState.DELETED: {
|
|
711
|
-
const msg = pollResp.health?.summary ?? '(no message)';
|
|
712
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
713
|
-
}
|
|
714
|
-
default:
|
|
715
|
-
throw new StillRunningError();
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
await executeWait(call, options);
|
|
720
|
-
if (result === undefined) {
|
|
721
|
-
throw new Error('operation completed without a result.');
|
|
722
|
-
}
|
|
723
|
-
return result;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
727
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
728
|
-
const pollResp = await this.client.getWarehouse(
|
|
729
|
-
{
|
|
730
|
-
id: this.id,
|
|
731
|
-
},
|
|
732
|
-
options
|
|
733
|
-
);
|
|
734
|
-
|
|
735
|
-
const status = pollResp.state;
|
|
736
|
-
if (status === undefined) {
|
|
737
|
-
throw new Error('response missing required status field');
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
switch (status) {
|
|
741
|
-
case EndpointState.RUNNING:
|
|
742
|
-
case EndpointState.STOPPED:
|
|
743
|
-
case EndpointState.DELETED:
|
|
744
|
-
return true;
|
|
745
|
-
default:
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
export class EditWarehouseWaiter {
|
|
752
|
-
constructor(
|
|
753
|
-
private readonly client: WarehousesClient,
|
|
754
|
-
readonly id: string
|
|
755
|
-
) {}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* Polls until the operation reaches a terminal state.
|
|
759
|
-
*
|
|
760
|
-
* Throws if a failure state is reached.
|
|
761
|
-
*/
|
|
762
|
-
async wait(options?: LroOptions): Promise<GetWarehouseRequest_Response> {
|
|
763
|
-
let result: GetWarehouseRequest_Response | undefined;
|
|
764
|
-
|
|
765
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
766
|
-
const pollResp = await this.client.getWarehouse(
|
|
767
|
-
{
|
|
768
|
-
id: this.id,
|
|
769
|
-
},
|
|
770
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
771
|
-
);
|
|
772
|
-
|
|
773
|
-
const status = pollResp.state;
|
|
774
|
-
if (status === undefined) {
|
|
775
|
-
throw new Error('response missing required status field');
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
switch (status) {
|
|
779
|
-
case EndpointState.RUNNING:
|
|
780
|
-
result = pollResp;
|
|
781
|
-
return;
|
|
782
|
-
case EndpointState.STOPPED:
|
|
783
|
-
case EndpointState.DELETED: {
|
|
784
|
-
const msg = pollResp.health?.summary ?? '(no message)';
|
|
785
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
786
|
-
}
|
|
787
|
-
default:
|
|
788
|
-
throw new StillRunningError();
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
await executeWait(call, options);
|
|
793
|
-
if (result === undefined) {
|
|
794
|
-
throw new Error('operation completed without a result.');
|
|
795
|
-
}
|
|
796
|
-
return result;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
800
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
801
|
-
const pollResp = await this.client.getWarehouse(
|
|
802
|
-
{
|
|
803
|
-
id: this.id,
|
|
804
|
-
},
|
|
805
|
-
options
|
|
806
|
-
);
|
|
807
|
-
|
|
808
|
-
const status = pollResp.state;
|
|
809
|
-
if (status === undefined) {
|
|
810
|
-
throw new Error('response missing required status field');
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
switch (status) {
|
|
814
|
-
case EndpointState.RUNNING:
|
|
815
|
-
case EndpointState.STOPPED:
|
|
816
|
-
case EndpointState.DELETED:
|
|
817
|
-
return true;
|
|
818
|
-
default:
|
|
819
|
-
return false;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
export class StartWarehouseWaiter {
|
|
825
|
-
constructor(
|
|
826
|
-
private readonly client: WarehousesClient,
|
|
827
|
-
readonly id: string
|
|
828
|
-
) {}
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* Polls until the operation reaches a terminal state.
|
|
832
|
-
*
|
|
833
|
-
* Throws if a failure state is reached.
|
|
834
|
-
*/
|
|
835
|
-
async wait(options?: LroOptions): Promise<GetWarehouseRequest_Response> {
|
|
836
|
-
let result: GetWarehouseRequest_Response | undefined;
|
|
837
|
-
|
|
838
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
839
|
-
const pollResp = await this.client.getWarehouse(
|
|
840
|
-
{
|
|
841
|
-
id: this.id,
|
|
842
|
-
},
|
|
843
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
844
|
-
);
|
|
845
|
-
|
|
846
|
-
const status = pollResp.state;
|
|
847
|
-
if (status === undefined) {
|
|
848
|
-
throw new Error('response missing required status field');
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
switch (status) {
|
|
852
|
-
case EndpointState.RUNNING:
|
|
853
|
-
result = pollResp;
|
|
854
|
-
return;
|
|
855
|
-
case EndpointState.STOPPED:
|
|
856
|
-
case EndpointState.DELETED: {
|
|
857
|
-
const msg = pollResp.health?.summary ?? '(no message)';
|
|
858
|
-
throw new Error(`terminal state ${status}: ${msg}`);
|
|
859
|
-
}
|
|
860
|
-
default:
|
|
861
|
-
throw new StillRunningError();
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
await executeWait(call, options);
|
|
866
|
-
if (result === undefined) {
|
|
867
|
-
throw new Error('operation completed without a result.');
|
|
868
|
-
}
|
|
869
|
-
return result;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
873
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
874
|
-
const pollResp = await this.client.getWarehouse(
|
|
875
|
-
{
|
|
876
|
-
id: this.id,
|
|
877
|
-
},
|
|
878
|
-
options
|
|
879
|
-
);
|
|
880
|
-
|
|
881
|
-
const status = pollResp.state;
|
|
882
|
-
if (status === undefined) {
|
|
883
|
-
throw new Error('response missing required status field');
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
switch (status) {
|
|
887
|
-
case EndpointState.RUNNING:
|
|
888
|
-
case EndpointState.STOPPED:
|
|
889
|
-
case EndpointState.DELETED:
|
|
890
|
-
return true;
|
|
891
|
-
default:
|
|
892
|
-
return false;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
export class StopWarehouseWaiter {
|
|
898
|
-
constructor(
|
|
899
|
-
private readonly client: WarehousesClient,
|
|
900
|
-
readonly id: string
|
|
901
|
-
) {}
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* Polls until the operation reaches a terminal state.
|
|
905
|
-
*
|
|
906
|
-
* Throws if a failure state is reached.
|
|
907
|
-
*/
|
|
908
|
-
async wait(options?: LroOptions): Promise<GetWarehouseRequest_Response> {
|
|
909
|
-
let result: GetWarehouseRequest_Response | undefined;
|
|
910
|
-
|
|
911
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
912
|
-
const pollResp = await this.client.getWarehouse(
|
|
913
|
-
{
|
|
914
|
-
id: this.id,
|
|
915
|
-
},
|
|
916
|
-
callSignal !== undefined ? {signal: callSignal} : undefined
|
|
917
|
-
);
|
|
918
|
-
|
|
919
|
-
const status = pollResp.state;
|
|
920
|
-
if (status === undefined) {
|
|
921
|
-
throw new Error('response missing required status field');
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
switch (status) {
|
|
925
|
-
case EndpointState.STOPPED:
|
|
926
|
-
result = pollResp;
|
|
927
|
-
return;
|
|
928
|
-
default:
|
|
929
|
-
throw new StillRunningError();
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
await executeWait(call, options);
|
|
934
|
-
if (result === undefined) {
|
|
935
|
-
throw new Error('operation completed without a result.');
|
|
936
|
-
}
|
|
937
|
-
return result;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
/** Checks whether the operation has reached a terminal state. */
|
|
941
|
-
async done(options?: CallOptions): Promise<boolean> {
|
|
942
|
-
const pollResp = await this.client.getWarehouse(
|
|
943
|
-
{
|
|
944
|
-
id: this.id,
|
|
945
|
-
},
|
|
946
|
-
options
|
|
947
|
-
);
|
|
948
|
-
|
|
949
|
-
const status = pollResp.state;
|
|
950
|
-
if (status === undefined) {
|
|
951
|
-
throw new Error('response missing required status field');
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
switch (status) {
|
|
955
|
-
case EndpointState.STOPPED:
|
|
956
|
-
return true;
|
|
957
|
-
default:
|
|
958
|
-
return false;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|