@databricks/sdk-genie 0.1.0-dev.4 → 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,1302 +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
- GenieCreateConversationMessageRequest,
24
- GenieCreateEvalRunRequest,
25
- GenieCreateMessageCommentRequest,
26
- GenieCreateSpaceRequest,
27
- GenieDeleteConversationMessageRequest,
28
- GenieDeleteConversationRequest,
29
- GenieEvalResultDetails,
30
- GenieEvalRunResponse,
31
- GenieExecuteMessageAttachmentQueryRequest,
32
- GenieExecuteMessageQueryRequest,
33
- GenieGenerateDownloadFullQueryResultRequest,
34
- GenieGenerateDownloadFullQueryResultResponse,
35
- GenieGetConversationMessageRequest,
36
- GenieGetDownloadFullQueryResultRequest,
37
- GenieGetDownloadFullQueryResultResponse,
38
- GenieGetEvalResultDetailsRequest,
39
- GenieGetEvalRunRequest,
40
- GenieGetMessageAttachmentQueryResultRequest,
41
- GenieGetMessageQueryResultRequest,
42
- GenieGetMessageQueryResultResponse,
43
- GenieGetQueryResultByAttachmentRequest,
44
- GenieGetSpaceRequest,
45
- GenieListConversationCommentsRequest,
46
- GenieListConversationCommentsResponse,
47
- GenieListConversationMessagesRequest,
48
- GenieListConversationMessagesResponse,
49
- GenieListConversationsRequest,
50
- GenieListConversationsResponse,
51
- GenieListEvalResultsRequest,
52
- GenieListEvalResultsResponse,
53
- GenieListEvalRunsRequest,
54
- GenieListEvalRunsResponse,
55
- GenieListMessageCommentsRequest,
56
- GenieListMessageCommentsResponse,
57
- GenieListSpacesRequest,
58
- GenieListSpacesResponse,
59
- GenieMessage,
60
- GenieMessageComment,
61
- GenieSendMessageFeedbackRequest,
62
- GenieSpace,
63
- GenieStartConversationMessageRequest,
64
- GenieStartConversationResponse,
65
- GenieTrashSpaceRequest,
66
- GenieUpdateSpaceRequest,
67
- } from './model';
68
- import {
69
- MessageStatus_MessageStatus,
70
- marshalGenieCreateConversationMessageRequestSchema,
71
- marshalGenieCreateEvalRunRequestSchema,
72
- marshalGenieCreateMessageCommentRequestSchema,
73
- marshalGenieCreateSpaceRequestSchema,
74
- marshalGenieExecuteMessageAttachmentQueryRequestSchema,
75
- marshalGenieExecuteMessageQueryRequestSchema,
76
- marshalGenieGenerateDownloadFullQueryResultRequestSchema,
77
- marshalGenieSendMessageFeedbackRequestSchema,
78
- marshalGenieStartConversationMessageRequestSchema,
79
- marshalGenieUpdateSpaceRequestSchema,
80
- unmarshalGenieEvalResultDetailsSchema,
81
- unmarshalGenieEvalRunResponseSchema,
82
- unmarshalGenieGenerateDownloadFullQueryResultResponseSchema,
83
- unmarshalGenieGetDownloadFullQueryResultResponseSchema,
84
- unmarshalGenieGetMessageQueryResultResponseSchema,
85
- unmarshalGenieListConversationCommentsResponseSchema,
86
- unmarshalGenieListConversationMessagesResponseSchema,
87
- unmarshalGenieListConversationsResponseSchema,
88
- unmarshalGenieListEvalResultsResponseSchema,
89
- unmarshalGenieListEvalRunsResponseSchema,
90
- unmarshalGenieListMessageCommentsResponseSchema,
91
- unmarshalGenieListSpacesResponseSchema,
92
- unmarshalGenieMessageCommentSchema,
93
- unmarshalGenieMessageSchema,
94
- unmarshalGenieSpaceSchema,
95
- unmarshalGenieStartConversationResponseSchema,
96
- } from './model';
97
-
98
- // Package identity segment for this client to be used in the User-Agent header.
99
- const PACKAGE_SEGMENT = {
100
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
101
- value: pkgJson.version,
102
- };
103
-
104
- export class GenieClient {
105
- private readonly host: string;
106
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
107
- // When set, workspace-level methods send X-Databricks-Org-Id on every
108
- // request.
109
- private readonly workspaceId: string | undefined;
110
- private readonly httpClient: HttpClient;
111
- private readonly logger: Logger;
112
- // User-Agent header value. Composed once at construction from
113
- // createDefault() merged with this package's identity and the active
114
- // credential's name.
115
- private readonly userAgent: string;
116
-
117
- constructor(options: ClientOptions) {
118
- if (options.host === undefined) {
119
- throw new Error('Host is required.');
120
- }
121
- this.host = options.host.replace(/\/$/, '');
122
- this.workspaceId = options.workspaceId;
123
- this.logger = options.logger ?? new NoOpLogger();
124
- const info = createDefault()
125
- .with(PACKAGE_SEGMENT)
126
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
127
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
128
- this.userAgent = info.toString();
129
- this.httpClient = newHttpClient(options);
130
- }
131
-
132
- /** Creates a Genie space from a serialized payload. */
133
- async createSpace(
134
- req: GenieCreateSpaceRequest,
135
- options?: CallOptions
136
- ): Promise<GenieSpace> {
137
- const url = `${this.host}/api/2.0/genie/spaces`;
138
- const body = marshalRequest(req, marshalGenieCreateSpaceRequestSchema);
139
- let resp: GenieSpace | undefined;
140
- const call = async (callSignal?: AbortSignal): Promise<void> => {
141
- const headers = new Headers({'Content-Type': 'application/json'});
142
- if (this.workspaceId !== undefined) {
143
- headers.set('X-Databricks-Org-Id', this.workspaceId);
144
- }
145
- headers.set('User-Agent', this.userAgent);
146
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
147
- const respBody = await executeHttpCall({
148
- request: httpReq,
149
- httpClient: this.httpClient,
150
- logger: this.logger,
151
- });
152
- resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
153
- };
154
- await executeCall(call, options);
155
- if (resp === undefined) {
156
- throw new Error('operation completed without a result.');
157
- }
158
- return resp;
159
- }
160
-
161
- /**
162
- * Create new message in a [conversation](:method:genie/startconversation).
163
- * The AI response uses all previously created messages in the conversation to respond.
164
- */
165
- private async genieCreateConversationMessage(
166
- req: GenieCreateConversationMessageRequest,
167
- options?: CallOptions
168
- ): Promise<GenieMessage> {
169
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
170
- const body = marshalRequest(
171
- req,
172
- marshalGenieCreateConversationMessageRequestSchema
173
- );
174
- let resp: GenieMessage | undefined;
175
- const call = async (callSignal?: AbortSignal): Promise<void> => {
176
- const headers = new Headers({'Content-Type': 'application/json'});
177
- if (this.workspaceId !== undefined) {
178
- headers.set('X-Databricks-Org-Id', this.workspaceId);
179
- }
180
- headers.set('User-Agent', this.userAgent);
181
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
182
- const respBody = await executeHttpCall({
183
- request: httpReq,
184
- httpClient: this.httpClient,
185
- logger: this.logger,
186
- });
187
- resp = parseResponse(respBody, unmarshalGenieMessageSchema);
188
- };
189
- await executeCall(call, options);
190
- if (resp === undefined) {
191
- throw new Error('operation completed without a result.');
192
- }
193
- return resp;
194
- }
195
-
196
- async genieCreateConversationMessageWaiter(
197
- req: GenieCreateConversationMessageRequest,
198
- options?: CallOptions
199
- ): Promise<GenieCreateConversationMessageWaiter> {
200
- const resp = await this.genieCreateConversationMessage(req, options);
201
- if (resp.messageId === undefined) {
202
- throw new Error(
203
- 'response field messageId required for polling is missing'
204
- );
205
- }
206
- if (req.conversationId === undefined) {
207
- throw new Error(
208
- 'request field conversationId required for polling is missing'
209
- );
210
- }
211
- if (req.spaceId === undefined) {
212
- throw new Error('request field spaceId required for polling is missing');
213
- }
214
- return new GenieCreateConversationMessageWaiter(
215
- this,
216
- resp.messageId,
217
- req.conversationId,
218
- req.spaceId
219
- );
220
- }
221
-
222
- /** Create and run evaluations for multiple benchmark questions in a Genie space. */
223
- async genieCreateEvalRun(
224
- req: GenieCreateEvalRunRequest,
225
- options?: CallOptions
226
- ): Promise<GenieEvalRunResponse> {
227
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
228
- const body = marshalRequest(req, marshalGenieCreateEvalRunRequestSchema);
229
- let resp: GenieEvalRunResponse | undefined;
230
- const call = async (callSignal?: AbortSignal): Promise<void> => {
231
- const headers = new Headers({'Content-Type': 'application/json'});
232
- if (this.workspaceId !== undefined) {
233
- headers.set('X-Databricks-Org-Id', this.workspaceId);
234
- }
235
- headers.set('User-Agent', this.userAgent);
236
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
237
- const respBody = await executeHttpCall({
238
- request: httpReq,
239
- httpClient: this.httpClient,
240
- logger: this.logger,
241
- });
242
- resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
243
- };
244
- await executeCall(call, options);
245
- if (resp === undefined) {
246
- throw new Error('operation completed without a result.');
247
- }
248
- return resp;
249
- }
250
-
251
- /** Create a comment on a conversation message. */
252
- async genieCreateMessageComment(
253
- req: GenieCreateMessageCommentRequest,
254
- options?: CallOptions
255
- ): Promise<GenieMessageComment> {
256
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
257
- const body = marshalRequest(
258
- req,
259
- marshalGenieCreateMessageCommentRequestSchema
260
- );
261
- let resp: GenieMessageComment | undefined;
262
- const call = async (callSignal?: AbortSignal): Promise<void> => {
263
- const headers = new Headers({'Content-Type': 'application/json'});
264
- if (this.workspaceId !== undefined) {
265
- headers.set('X-Databricks-Org-Id', this.workspaceId);
266
- }
267
- headers.set('User-Agent', this.userAgent);
268
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
269
- const respBody = await executeHttpCall({
270
- request: httpReq,
271
- httpClient: this.httpClient,
272
- logger: this.logger,
273
- });
274
- resp = parseResponse(respBody, unmarshalGenieMessageCommentSchema);
275
- };
276
- await executeCall(call, options);
277
- if (resp === undefined) {
278
- throw new Error('operation completed without a result.');
279
- }
280
- return resp;
281
- }
282
-
283
- /** Delete a conversation. */
284
- async genieDeleteConversation(
285
- req: GenieDeleteConversationRequest,
286
- options?: CallOptions
287
- ): Promise<void> {
288
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`;
289
- const call = async (callSignal?: AbortSignal): Promise<void> => {
290
- const headers = new Headers();
291
- if (this.workspaceId !== undefined) {
292
- headers.set('X-Databricks-Org-Id', this.workspaceId);
293
- }
294
- headers.set('User-Agent', this.userAgent);
295
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
296
- await executeHttpCall({
297
- request: httpReq,
298
- httpClient: this.httpClient,
299
- logger: this.logger,
300
- });
301
- };
302
- await executeCall(call, options);
303
- }
304
-
305
- /** Delete a conversation message. */
306
- async genieDeleteConversationMessage(
307
- req: GenieDeleteConversationMessageRequest,
308
- options?: CallOptions
309
- ): Promise<void> {
310
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
311
- const call = async (callSignal?: AbortSignal): Promise<void> => {
312
- const headers = new Headers();
313
- if (this.workspaceId !== undefined) {
314
- headers.set('X-Databricks-Org-Id', this.workspaceId);
315
- }
316
- headers.set('User-Agent', this.userAgent);
317
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
318
- await executeHttpCall({
319
- request: httpReq,
320
- httpClient: this.httpClient,
321
- logger: this.logger,
322
- });
323
- };
324
- await executeCall(call, options);
325
- }
326
-
327
- /** Execute the SQL for a message query attachment. Use this API when the query attachment has expired and needs to be re-executed. */
328
- async genieExecuteMessageAttachmentQuery(
329
- req: GenieExecuteMessageAttachmentQueryRequest,
330
- options?: CallOptions
331
- ): Promise<GenieGetMessageQueryResultResponse> {
332
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/execute-query`;
333
- const body = marshalRequest(
334
- req,
335
- marshalGenieExecuteMessageAttachmentQueryRequestSchema
336
- );
337
- let resp: GenieGetMessageQueryResultResponse | undefined;
338
- const call = async (callSignal?: AbortSignal): Promise<void> => {
339
- const headers = new Headers({'Content-Type': 'application/json'});
340
- if (this.workspaceId !== undefined) {
341
- headers.set('X-Databricks-Org-Id', this.workspaceId);
342
- }
343
- headers.set('User-Agent', this.userAgent);
344
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
345
- const respBody = await executeHttpCall({
346
- request: httpReq,
347
- httpClient: this.httpClient,
348
- logger: this.logger,
349
- });
350
- resp = parseResponse(
351
- respBody,
352
- unmarshalGenieGetMessageQueryResultResponseSchema
353
- );
354
- };
355
- await executeCall(call, options);
356
- if (resp === undefined) {
357
- throw new Error('operation completed without a result.');
358
- }
359
- return resp;
360
- }
361
-
362
- /** DEPRECATED: Use [Execute Message Attachment Query](:method:genie/executemessageattachmentquery) instead. */
363
- async genieExecuteMessageQuery(
364
- req: GenieExecuteMessageQueryRequest,
365
- options?: CallOptions
366
- ): Promise<GenieGetMessageQueryResultResponse> {
367
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`;
368
- const body = marshalRequest(
369
- req,
370
- marshalGenieExecuteMessageQueryRequestSchema
371
- );
372
- let resp: GenieGetMessageQueryResultResponse | undefined;
373
- const call = async (callSignal?: AbortSignal): Promise<void> => {
374
- const headers = new Headers({'Content-Type': 'application/json'});
375
- if (this.workspaceId !== undefined) {
376
- headers.set('X-Databricks-Org-Id', this.workspaceId);
377
- }
378
- headers.set('User-Agent', this.userAgent);
379
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
380
- const respBody = await executeHttpCall({
381
- request: httpReq,
382
- httpClient: this.httpClient,
383
- logger: this.logger,
384
- });
385
- resp = parseResponse(
386
- respBody,
387
- unmarshalGenieGetMessageQueryResultResponseSchema
388
- );
389
- };
390
- await executeCall(call, options);
391
- if (resp === undefined) {
392
- throw new Error('operation completed without a result.');
393
- }
394
- return resp;
395
- }
396
-
397
- /**
398
- * Initiates a new SQL execution and returns a `download_id` and `download_id_signature` that you can use to track the progress of the download.
399
- * The query result is stored in an external link and can be retrieved using the [Get Download Full Query Result](:method:genie/getdownloadfullqueryresult) API.
400
- * Both `download_id` and `download_id_signature` must be provided when calling the Get endpoint.
401
- *
402
- * ----
403
- *
404
- * ### **Warning: Databricks strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.**
405
- *
406
- * When you use the `EXTERNAL_LINKS` disposition, a
407
- * short-lived, URL is generated, which can be
408
- * used to download the results directly
409
- * from . As a
410
- * short-lived is
411
- * embedded in this URL, you should protect
412
- * the URL.
413
- *
414
- * Because URLs are already generated with
415
- * embedded temporary s,
416
- * you must not set an `Authorization` header in the download requests.
417
- *
418
- * See [Execute Statement](:method:statementexecution/executestatement) for more details.
419
- *
420
- * ----
421
- */
422
- async genieGenerateDownloadFullQueryResult(
423
- req: GenieGenerateDownloadFullQueryResultRequest,
424
- options?: CallOptions
425
- ): Promise<GenieGenerateDownloadFullQueryResultResponse> {
426
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads`;
427
- const body = marshalRequest(
428
- req,
429
- marshalGenieGenerateDownloadFullQueryResultRequestSchema
430
- );
431
- let resp: GenieGenerateDownloadFullQueryResultResponse | undefined;
432
- const call = async (callSignal?: AbortSignal): Promise<void> => {
433
- const headers = new Headers({'Content-Type': 'application/json'});
434
- if (this.workspaceId !== undefined) {
435
- headers.set('X-Databricks-Org-Id', this.workspaceId);
436
- }
437
- headers.set('User-Agent', this.userAgent);
438
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
439
- const respBody = await executeHttpCall({
440
- request: httpReq,
441
- httpClient: this.httpClient,
442
- logger: this.logger,
443
- });
444
- resp = parseResponse(
445
- respBody,
446
- unmarshalGenieGenerateDownloadFullQueryResultResponseSchema
447
- );
448
- };
449
- await executeCall(call, options);
450
- if (resp === undefined) {
451
- throw new Error('operation completed without a result.');
452
- }
453
- return resp;
454
- }
455
-
456
- /** Get message from conversation. */
457
- async genieGetConversationMessage(
458
- req: GenieGetConversationMessageRequest,
459
- options?: CallOptions
460
- ): Promise<GenieMessage> {
461
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
462
- let resp: GenieMessage | undefined;
463
- const call = async (callSignal?: AbortSignal): Promise<void> => {
464
- const headers = new Headers();
465
- if (this.workspaceId !== undefined) {
466
- headers.set('X-Databricks-Org-Id', this.workspaceId);
467
- }
468
- headers.set('User-Agent', this.userAgent);
469
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
470
- const respBody = await executeHttpCall({
471
- request: httpReq,
472
- httpClient: this.httpClient,
473
- logger: this.logger,
474
- });
475
- resp = parseResponse(respBody, unmarshalGenieMessageSchema);
476
- };
477
- await executeCall(call, options);
478
- if (resp === undefined) {
479
- throw new Error('operation completed without a result.');
480
- }
481
- return resp;
482
- }
483
-
484
- /**
485
- * After [Generating a Full Query Result Download](:method:genie/generatedownloadfullqueryresult) and successfully receiving a `download_id` and `download_id_signature`, use this API to poll the download progress.
486
- * Both `download_id` and `download_id_signature` are required to call this endpoint.
487
- * When the download is complete, the API returns the result in the `EXTERNAL_LINKS` disposition, containing one or more external links to the query result files.
488
- *
489
- * ----
490
- *
491
- * ### **Warning: Databricks strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.**
492
- *
493
- * When you use the `EXTERNAL_LINKS` disposition, a
494
- * short-lived, URL is generated, which can be
495
- * used to download the results directly
496
- * from . As a
497
- * short-lived is
498
- * embedded in this URL, you should protect
499
- * the URL.
500
- *
501
- * Because URLs are already generated with
502
- * embedded temporary s,
503
- * you must not set an `Authorization` header in the download requests.
504
- *
505
- * See [Execute Statement](:method:statementexecution/executestatement) for more details.
506
- *
507
- * ----
508
- */
509
- async genieGetDownloadFullQueryResult(
510
- req: GenieGetDownloadFullQueryResultRequest,
511
- options?: CallOptions
512
- ): Promise<GenieGetDownloadFullQueryResultResponse> {
513
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads/${req.downloadId ?? ''}`;
514
- const params = new URLSearchParams();
515
- if (req.downloadIdSignature !== undefined) {
516
- params.append('download_id_signature', req.downloadIdSignature);
517
- }
518
- const query = params.toString();
519
- const fullUrl = query !== '' ? `${url}?${query}` : url;
520
- let resp: GenieGetDownloadFullQueryResultResponse | undefined;
521
- const call = async (callSignal?: AbortSignal): Promise<void> => {
522
- const headers = new Headers();
523
- if (this.workspaceId !== undefined) {
524
- headers.set('X-Databricks-Org-Id', this.workspaceId);
525
- }
526
- headers.set('User-Agent', this.userAgent);
527
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
528
- const respBody = await executeHttpCall({
529
- request: httpReq,
530
- httpClient: this.httpClient,
531
- logger: this.logger,
532
- });
533
- resp = parseResponse(
534
- respBody,
535
- unmarshalGenieGetDownloadFullQueryResultResponseSchema
536
- );
537
- };
538
- await executeCall(call, options);
539
- if (resp === undefined) {
540
- throw new Error('operation completed without a result.');
541
- }
542
- return resp;
543
- }
544
-
545
- /** Get details for evaluation results. */
546
- async genieGetEvalResultDetails(
547
- req: GenieGetEvalResultDetailsRequest,
548
- options?: CallOptions
549
- ): Promise<GenieEvalResultDetails> {
550
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`;
551
- let resp: GenieEvalResultDetails | undefined;
552
- const call = async (callSignal?: AbortSignal): Promise<void> => {
553
- const headers = new Headers();
554
- if (this.workspaceId !== undefined) {
555
- headers.set('X-Databricks-Org-Id', this.workspaceId);
556
- }
557
- headers.set('User-Agent', this.userAgent);
558
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
559
- const respBody = await executeHttpCall({
560
- request: httpReq,
561
- httpClient: this.httpClient,
562
- logger: this.logger,
563
- });
564
- resp = parseResponse(respBody, unmarshalGenieEvalResultDetailsSchema);
565
- };
566
- await executeCall(call, options);
567
- if (resp === undefined) {
568
- throw new Error('operation completed without a result.');
569
- }
570
- return resp;
571
- }
572
-
573
- /** Get evaluation run details. */
574
- async genieGetEvalRun(
575
- req: GenieGetEvalRunRequest,
576
- options?: CallOptions
577
- ): Promise<GenieEvalRunResponse> {
578
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`;
579
- let resp: GenieEvalRunResponse | undefined;
580
- const call = async (callSignal?: AbortSignal): Promise<void> => {
581
- const headers = new Headers();
582
- if (this.workspaceId !== undefined) {
583
- headers.set('X-Databricks-Org-Id', this.workspaceId);
584
- }
585
- headers.set('User-Agent', this.userAgent);
586
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
587
- const respBody = await executeHttpCall({
588
- request: httpReq,
589
- httpClient: this.httpClient,
590
- logger: this.logger,
591
- });
592
- resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
593
- };
594
- await executeCall(call, options);
595
- if (resp === undefined) {
596
- throw new Error('operation completed without a result.');
597
- }
598
- return resp;
599
- }
600
-
601
- /**
602
- * Get the result of SQL query if the message has a query attachment.
603
- * This is only available if a message has a query attachment and the message status is `EXECUTING_QUERY` OR `COMPLETED`.
604
- */
605
- async genieGetMessageAttachmentQueryResult(
606
- req: GenieGetMessageAttachmentQueryResultRequest,
607
- options?: CallOptions
608
- ): Promise<GenieGetMessageQueryResultResponse> {
609
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/query-result`;
610
- let resp: GenieGetMessageQueryResultResponse | undefined;
611
- const call = async (callSignal?: AbortSignal): Promise<void> => {
612
- const headers = new Headers();
613
- if (this.workspaceId !== undefined) {
614
- headers.set('X-Databricks-Org-Id', this.workspaceId);
615
- }
616
- headers.set('User-Agent', this.userAgent);
617
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
618
- const respBody = await executeHttpCall({
619
- request: httpReq,
620
- httpClient: this.httpClient,
621
- logger: this.logger,
622
- });
623
- resp = parseResponse(
624
- respBody,
625
- unmarshalGenieGetMessageQueryResultResponseSchema
626
- );
627
- };
628
- await executeCall(call, options);
629
- if (resp === undefined) {
630
- throw new Error('operation completed without a result.');
631
- }
632
- return resp;
633
- }
634
-
635
- /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
636
- async genieGetMessageQueryResult(
637
- req: GenieGetMessageQueryResultRequest,
638
- options?: CallOptions
639
- ): Promise<GenieGetMessageQueryResultResponse> {
640
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`;
641
- let resp: GenieGetMessageQueryResultResponse | undefined;
642
- const call = async (callSignal?: AbortSignal): Promise<void> => {
643
- const headers = new Headers();
644
- if (this.workspaceId !== undefined) {
645
- headers.set('X-Databricks-Org-Id', this.workspaceId);
646
- }
647
- headers.set('User-Agent', this.userAgent);
648
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
649
- const respBody = await executeHttpCall({
650
- request: httpReq,
651
- httpClient: this.httpClient,
652
- logger: this.logger,
653
- });
654
- resp = parseResponse(
655
- respBody,
656
- unmarshalGenieGetMessageQueryResultResponseSchema
657
- );
658
- };
659
- await executeCall(call, options);
660
- if (resp === undefined) {
661
- throw new Error('operation completed without a result.');
662
- }
663
- return resp;
664
- }
665
-
666
- /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
667
- async genieGetQueryResultByAttachment(
668
- req: GenieGetQueryResultByAttachmentRequest,
669
- options?: CallOptions
670
- ): Promise<GenieGetMessageQueryResultResponse> {
671
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result/${req.attachmentId ?? ''}`;
672
- let resp: GenieGetMessageQueryResultResponse | undefined;
673
- const call = async (callSignal?: AbortSignal): Promise<void> => {
674
- const headers = new Headers();
675
- if (this.workspaceId !== undefined) {
676
- headers.set('X-Databricks-Org-Id', this.workspaceId);
677
- }
678
- headers.set('User-Agent', this.userAgent);
679
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
680
- const respBody = await executeHttpCall({
681
- request: httpReq,
682
- httpClient: this.httpClient,
683
- logger: this.logger,
684
- });
685
- resp = parseResponse(
686
- respBody,
687
- unmarshalGenieGetMessageQueryResultResponseSchema
688
- );
689
- };
690
- await executeCall(call, options);
691
- if (resp === undefined) {
692
- throw new Error('operation completed without a result.');
693
- }
694
- return resp;
695
- }
696
-
697
- /** Get details of a Genie Space. */
698
- async genieGetSpace(
699
- req: GenieGetSpaceRequest,
700
- options?: CallOptions
701
- ): Promise<GenieSpace> {
702
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
703
- const params = new URLSearchParams();
704
- if (req.includeSerializedSpace !== undefined) {
705
- params.append(
706
- 'include_serialized_space',
707
- String(req.includeSerializedSpace)
708
- );
709
- }
710
- const query = params.toString();
711
- const fullUrl = query !== '' ? `${url}?${query}` : url;
712
- let resp: GenieSpace | undefined;
713
- const call = async (callSignal?: AbortSignal): Promise<void> => {
714
- const headers = new Headers();
715
- if (this.workspaceId !== undefined) {
716
- headers.set('X-Databricks-Org-Id', this.workspaceId);
717
- }
718
- headers.set('User-Agent', this.userAgent);
719
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
720
- const respBody = await executeHttpCall({
721
- request: httpReq,
722
- httpClient: this.httpClient,
723
- logger: this.logger,
724
- });
725
- resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
726
- };
727
- await executeCall(call, options);
728
- if (resp === undefined) {
729
- throw new Error('operation completed without a result.');
730
- }
731
- return resp;
732
- }
733
-
734
- /** List all comments across all messages in a conversation. */
735
- async genieListConversationComments(
736
- req: GenieListConversationCommentsRequest,
737
- options?: CallOptions
738
- ): Promise<GenieListConversationCommentsResponse> {
739
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`;
740
- const params = new URLSearchParams();
741
- if (req.pageSize !== undefined) {
742
- params.append('page_size', String(req.pageSize));
743
- }
744
- if (req.pageToken !== undefined) {
745
- params.append('page_token', req.pageToken);
746
- }
747
- const query = params.toString();
748
- const fullUrl = query !== '' ? `${url}?${query}` : url;
749
- let resp: GenieListConversationCommentsResponse | undefined;
750
- const call = async (callSignal?: AbortSignal): Promise<void> => {
751
- const headers = new Headers();
752
- if (this.workspaceId !== undefined) {
753
- headers.set('X-Databricks-Org-Id', this.workspaceId);
754
- }
755
- headers.set('User-Agent', this.userAgent);
756
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
757
- const respBody = await executeHttpCall({
758
- request: httpReq,
759
- httpClient: this.httpClient,
760
- logger: this.logger,
761
- });
762
- resp = parseResponse(
763
- respBody,
764
- unmarshalGenieListConversationCommentsResponseSchema
765
- );
766
- };
767
- await executeCall(call, options);
768
- if (resp === undefined) {
769
- throw new Error('operation completed without a result.');
770
- }
771
- return resp;
772
- }
773
-
774
- /** List messages in a conversation */
775
- async genieListConversationMessages(
776
- req: GenieListConversationMessagesRequest,
777
- options?: CallOptions
778
- ): Promise<GenieListConversationMessagesResponse> {
779
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
780
- const params = new URLSearchParams();
781
- if (req.pageSize !== undefined) {
782
- params.append('page_size', String(req.pageSize));
783
- }
784
- if (req.pageToken !== undefined) {
785
- params.append('page_token', req.pageToken);
786
- }
787
- const query = params.toString();
788
- const fullUrl = query !== '' ? `${url}?${query}` : url;
789
- let resp: GenieListConversationMessagesResponse | undefined;
790
- const call = async (callSignal?: AbortSignal): Promise<void> => {
791
- const headers = new Headers();
792
- if (this.workspaceId !== undefined) {
793
- headers.set('X-Databricks-Org-Id', this.workspaceId);
794
- }
795
- headers.set('User-Agent', this.userAgent);
796
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
797
- const respBody = await executeHttpCall({
798
- request: httpReq,
799
- httpClient: this.httpClient,
800
- logger: this.logger,
801
- });
802
- resp = parseResponse(
803
- respBody,
804
- unmarshalGenieListConversationMessagesResponseSchema
805
- );
806
- };
807
- await executeCall(call, options);
808
- if (resp === undefined) {
809
- throw new Error('operation completed without a result.');
810
- }
811
- return resp;
812
- }
813
-
814
- /** Get a list of conversations in a Genie Space. */
815
- async genieListConversations(
816
- req: GenieListConversationsRequest,
817
- options?: CallOptions
818
- ): Promise<GenieListConversationsResponse> {
819
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`;
820
- const params = new URLSearchParams();
821
- if (req.pageSize !== undefined) {
822
- params.append('page_size', String(req.pageSize));
823
- }
824
- if (req.pageToken !== undefined) {
825
- params.append('page_token', req.pageToken);
826
- }
827
- if (req.includeAll !== undefined) {
828
- params.append('include_all', String(req.includeAll));
829
- }
830
- const query = params.toString();
831
- const fullUrl = query !== '' ? `${url}?${query}` : url;
832
- let resp: GenieListConversationsResponse | undefined;
833
- const call = async (callSignal?: AbortSignal): Promise<void> => {
834
- const headers = new Headers();
835
- if (this.workspaceId !== undefined) {
836
- headers.set('X-Databricks-Org-Id', this.workspaceId);
837
- }
838
- headers.set('User-Agent', this.userAgent);
839
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
840
- const respBody = await executeHttpCall({
841
- request: httpReq,
842
- httpClient: this.httpClient,
843
- logger: this.logger,
844
- });
845
- resp = parseResponse(
846
- respBody,
847
- unmarshalGenieListConversationsResponseSchema
848
- );
849
- };
850
- await executeCall(call, options);
851
- if (resp === undefined) {
852
- throw new Error('operation completed without a result.');
853
- }
854
- return resp;
855
- }
856
-
857
- /** List evaluation results for a specific evaluation run. */
858
- async genieListEvalResults(
859
- req: GenieListEvalResultsRequest,
860
- options?: CallOptions
861
- ): Promise<GenieListEvalResultsResponse> {
862
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`;
863
- const params = new URLSearchParams();
864
- if (req.pageSize !== undefined) {
865
- params.append('page_size', String(req.pageSize));
866
- }
867
- if (req.pageToken !== undefined) {
868
- params.append('page_token', req.pageToken);
869
- }
870
- const query = params.toString();
871
- const fullUrl = query !== '' ? `${url}?${query}` : url;
872
- let resp: GenieListEvalResultsResponse | undefined;
873
- const call = async (callSignal?: AbortSignal): Promise<void> => {
874
- const headers = new Headers();
875
- if (this.workspaceId !== undefined) {
876
- headers.set('X-Databricks-Org-Id', this.workspaceId);
877
- }
878
- headers.set('User-Agent', this.userAgent);
879
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
880
- const respBody = await executeHttpCall({
881
- request: httpReq,
882
- httpClient: this.httpClient,
883
- logger: this.logger,
884
- });
885
- resp = parseResponse(
886
- respBody,
887
- unmarshalGenieListEvalResultsResponseSchema
888
- );
889
- };
890
- await executeCall(call, options);
891
- if (resp === undefined) {
892
- throw new Error('operation completed without a result.');
893
- }
894
- return resp;
895
- }
896
-
897
- /** Lists all evaluation runs in a space. */
898
- async genieListEvalRuns(
899
- req: GenieListEvalRunsRequest,
900
- options?: CallOptions
901
- ): Promise<GenieListEvalRunsResponse> {
902
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
903
- const params = new URLSearchParams();
904
- if (req.pageSize !== undefined) {
905
- params.append('page_size', String(req.pageSize));
906
- }
907
- if (req.pageToken !== undefined) {
908
- params.append('page_token', req.pageToken);
909
- }
910
- const query = params.toString();
911
- const fullUrl = query !== '' ? `${url}?${query}` : url;
912
- let resp: GenieListEvalRunsResponse | undefined;
913
- const call = async (callSignal?: AbortSignal): Promise<void> => {
914
- const headers = new Headers();
915
- if (this.workspaceId !== undefined) {
916
- headers.set('X-Databricks-Org-Id', this.workspaceId);
917
- }
918
- headers.set('User-Agent', this.userAgent);
919
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
920
- const respBody = await executeHttpCall({
921
- request: httpReq,
922
- httpClient: this.httpClient,
923
- logger: this.logger,
924
- });
925
- resp = parseResponse(respBody, unmarshalGenieListEvalRunsResponseSchema);
926
- };
927
- await executeCall(call, options);
928
- if (resp === undefined) {
929
- throw new Error('operation completed without a result.');
930
- }
931
- return resp;
932
- }
933
-
934
- /** List comments on a specific conversation message. */
935
- async genieListMessageComments(
936
- req: GenieListMessageCommentsRequest,
937
- options?: CallOptions
938
- ): Promise<GenieListMessageCommentsResponse> {
939
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
940
- const params = new URLSearchParams();
941
- if (req.pageSize !== undefined) {
942
- params.append('page_size', String(req.pageSize));
943
- }
944
- if (req.pageToken !== undefined) {
945
- params.append('page_token', req.pageToken);
946
- }
947
- const query = params.toString();
948
- const fullUrl = query !== '' ? `${url}?${query}` : url;
949
- let resp: GenieListMessageCommentsResponse | undefined;
950
- const call = async (callSignal?: AbortSignal): Promise<void> => {
951
- const headers = new Headers();
952
- if (this.workspaceId !== undefined) {
953
- headers.set('X-Databricks-Org-Id', this.workspaceId);
954
- }
955
- headers.set('User-Agent', this.userAgent);
956
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
957
- const respBody = await executeHttpCall({
958
- request: httpReq,
959
- httpClient: this.httpClient,
960
- logger: this.logger,
961
- });
962
- resp = parseResponse(
963
- respBody,
964
- unmarshalGenieListMessageCommentsResponseSchema
965
- );
966
- };
967
- await executeCall(call, options);
968
- if (resp === undefined) {
969
- throw new Error('operation completed without a result.');
970
- }
971
- return resp;
972
- }
973
-
974
- /** Get list of Genie Spaces. */
975
- async genieListSpaces(
976
- req: GenieListSpacesRequest,
977
- options?: CallOptions
978
- ): Promise<GenieListSpacesResponse> {
979
- const url = `${this.host}/api/2.0/genie/spaces`;
980
- const params = new URLSearchParams();
981
- if (req.pageSize !== undefined) {
982
- params.append('page_size', String(req.pageSize));
983
- }
984
- if (req.pageToken !== undefined) {
985
- params.append('page_token', req.pageToken);
986
- }
987
- const query = params.toString();
988
- const fullUrl = query !== '' ? `${url}?${query}` : url;
989
- let resp: GenieListSpacesResponse | undefined;
990
- const call = async (callSignal?: AbortSignal): Promise<void> => {
991
- const headers = new Headers();
992
- if (this.workspaceId !== undefined) {
993
- headers.set('X-Databricks-Org-Id', this.workspaceId);
994
- }
995
- headers.set('User-Agent', this.userAgent);
996
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
997
- const respBody = await executeHttpCall({
998
- request: httpReq,
999
- httpClient: this.httpClient,
1000
- logger: this.logger,
1001
- });
1002
- resp = parseResponse(respBody, unmarshalGenieListSpacesResponseSchema);
1003
- };
1004
- await executeCall(call, options);
1005
- if (resp === undefined) {
1006
- throw new Error('operation completed without a result.');
1007
- }
1008
- return resp;
1009
- }
1010
-
1011
- /** Send feedback for a message. */
1012
- async genieSendMessageFeedback(
1013
- req: GenieSendMessageFeedbackRequest,
1014
- options?: CallOptions
1015
- ): Promise<void> {
1016
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`;
1017
- const body = marshalRequest(
1018
- req,
1019
- marshalGenieSendMessageFeedbackRequestSchema
1020
- );
1021
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1022
- const headers = new Headers({'Content-Type': 'application/json'});
1023
- if (this.workspaceId !== undefined) {
1024
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1025
- }
1026
- headers.set('User-Agent', this.userAgent);
1027
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1028
- await executeHttpCall({
1029
- request: httpReq,
1030
- httpClient: this.httpClient,
1031
- logger: this.logger,
1032
- });
1033
- };
1034
- await executeCall(call, options);
1035
- }
1036
-
1037
- /** Start a new conversation. */
1038
- private async genieStartConversation(
1039
- req: GenieStartConversationMessageRequest,
1040
- options?: CallOptions
1041
- ): Promise<GenieStartConversationResponse> {
1042
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`;
1043
- const body = marshalRequest(
1044
- req,
1045
- marshalGenieStartConversationMessageRequestSchema
1046
- );
1047
- let resp: GenieStartConversationResponse | undefined;
1048
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1049
- const headers = new Headers({'Content-Type': 'application/json'});
1050
- if (this.workspaceId !== undefined) {
1051
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1052
- }
1053
- headers.set('User-Agent', this.userAgent);
1054
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
1055
- const respBody = await executeHttpCall({
1056
- request: httpReq,
1057
- httpClient: this.httpClient,
1058
- logger: this.logger,
1059
- });
1060
- resp = parseResponse(
1061
- respBody,
1062
- unmarshalGenieStartConversationResponseSchema
1063
- );
1064
- };
1065
- await executeCall(call, options);
1066
- if (resp === undefined) {
1067
- throw new Error('operation completed without a result.');
1068
- }
1069
- return resp;
1070
- }
1071
-
1072
- async genieStartConversationWaiter(
1073
- req: GenieStartConversationMessageRequest,
1074
- options?: CallOptions
1075
- ): Promise<GenieStartConversationWaiter> {
1076
- const resp = await this.genieStartConversation(req, options);
1077
- if (resp.messageId === undefined) {
1078
- throw new Error(
1079
- 'response field messageId required for polling is missing'
1080
- );
1081
- }
1082
- if (resp.conversationId === undefined) {
1083
- throw new Error(
1084
- 'response field conversationId required for polling is missing'
1085
- );
1086
- }
1087
- if (req.spaceId === undefined) {
1088
- throw new Error('request field spaceId required for polling is missing');
1089
- }
1090
- return new GenieStartConversationWaiter(
1091
- this,
1092
- resp.messageId,
1093
- resp.conversationId,
1094
- req.spaceId
1095
- );
1096
- }
1097
-
1098
- /** Move a Genie Space to the trash. */
1099
- async genieTrashSpace(
1100
- req: GenieTrashSpaceRequest,
1101
- options?: CallOptions
1102
- ): Promise<void> {
1103
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
1104
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1105
- const headers = new Headers();
1106
- if (this.workspaceId !== undefined) {
1107
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1108
- }
1109
- headers.set('User-Agent', this.userAgent);
1110
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
1111
- await executeHttpCall({
1112
- request: httpReq,
1113
- httpClient: this.httpClient,
1114
- logger: this.logger,
1115
- });
1116
- };
1117
- await executeCall(call, options);
1118
- }
1119
-
1120
- /** Updates a Genie space with a serialized payload. */
1121
- async updateSpace(
1122
- req: GenieUpdateSpaceRequest,
1123
- options?: CallOptions
1124
- ): Promise<GenieSpace> {
1125
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
1126
- const body = marshalRequest(req, marshalGenieUpdateSpaceRequestSchema);
1127
- let resp: GenieSpace | undefined;
1128
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1129
- const headers = new Headers({'Content-Type': 'application/json'});
1130
- if (this.workspaceId !== undefined) {
1131
- headers.set('X-Databricks-Org-Id', this.workspaceId);
1132
- }
1133
- headers.set('User-Agent', this.userAgent);
1134
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
1135
- const respBody = await executeHttpCall({
1136
- request: httpReq,
1137
- httpClient: this.httpClient,
1138
- logger: this.logger,
1139
- });
1140
- resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
1141
- };
1142
- await executeCall(call, options);
1143
- if (resp === undefined) {
1144
- throw new Error('operation completed without a result.');
1145
- }
1146
- return resp;
1147
- }
1148
- }
1149
-
1150
- export class GenieCreateConversationMessageWaiter {
1151
- constructor(
1152
- private readonly client: GenieClient,
1153
- readonly messageId: string,
1154
- readonly conversationId: string,
1155
- readonly spaceId: string
1156
- ) {}
1157
-
1158
- /**
1159
- * Polls until the operation reaches a terminal state.
1160
- *
1161
- * Throws if a failure state is reached.
1162
- */
1163
- async wait(options?: LroOptions): Promise<GenieMessage> {
1164
- let result: GenieMessage | undefined;
1165
-
1166
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1167
- const pollResp = await this.client.genieGetConversationMessage(
1168
- {
1169
- messageId: this.messageId,
1170
- conversationId: this.conversationId,
1171
- spaceId: this.spaceId,
1172
- },
1173
- callSignal !== undefined ? {signal: callSignal} : undefined
1174
- );
1175
-
1176
- const status = pollResp.status;
1177
- if (status === undefined) {
1178
- throw new Error('response missing required status field');
1179
- }
1180
-
1181
- switch (status) {
1182
- case MessageStatus_MessageStatus.COMPLETED:
1183
- result = pollResp;
1184
- return;
1185
- case MessageStatus_MessageStatus.FAILED: {
1186
- const msg = '(no message)';
1187
- throw new Error(`terminal state ${status}: ${msg}`);
1188
- }
1189
- default:
1190
- throw new StillRunningError();
1191
- }
1192
- };
1193
-
1194
- await executeWait(call, options);
1195
- if (result === undefined) {
1196
- throw new Error('operation completed without a result.');
1197
- }
1198
- return result;
1199
- }
1200
-
1201
- /** Checks whether the operation has reached a terminal state. */
1202
- async done(options?: CallOptions): Promise<boolean> {
1203
- const pollResp = await this.client.genieGetConversationMessage(
1204
- {
1205
- messageId: this.messageId,
1206
- conversationId: this.conversationId,
1207
- spaceId: this.spaceId,
1208
- },
1209
- options
1210
- );
1211
-
1212
- const status = pollResp.status;
1213
- if (status === undefined) {
1214
- throw new Error('response missing required status field');
1215
- }
1216
-
1217
- switch (status) {
1218
- case MessageStatus_MessageStatus.COMPLETED:
1219
- case MessageStatus_MessageStatus.FAILED:
1220
- return true;
1221
- default:
1222
- return false;
1223
- }
1224
- }
1225
- }
1226
-
1227
- export class GenieStartConversationWaiter {
1228
- constructor(
1229
- private readonly client: GenieClient,
1230
- readonly messageId: string,
1231
- readonly conversationId: string,
1232
- readonly spaceId: string
1233
- ) {}
1234
-
1235
- /**
1236
- * Polls until the operation reaches a terminal state.
1237
- *
1238
- * Throws if a failure state is reached.
1239
- */
1240
- async wait(options?: LroOptions): Promise<GenieMessage> {
1241
- let result: GenieMessage | undefined;
1242
-
1243
- const call = async (callSignal?: AbortSignal): Promise<void> => {
1244
- const pollResp = await this.client.genieGetConversationMessage(
1245
- {
1246
- messageId: this.messageId,
1247
- conversationId: this.conversationId,
1248
- spaceId: this.spaceId,
1249
- },
1250
- callSignal !== undefined ? {signal: callSignal} : undefined
1251
- );
1252
-
1253
- const status = pollResp.status;
1254
- if (status === undefined) {
1255
- throw new Error('response missing required status field');
1256
- }
1257
-
1258
- switch (status) {
1259
- case MessageStatus_MessageStatus.COMPLETED:
1260
- result = pollResp;
1261
- return;
1262
- case MessageStatus_MessageStatus.FAILED: {
1263
- const msg = '(no message)';
1264
- throw new Error(`terminal state ${status}: ${msg}`);
1265
- }
1266
- default:
1267
- throw new StillRunningError();
1268
- }
1269
- };
1270
-
1271
- await executeWait(call, options);
1272
- if (result === undefined) {
1273
- throw new Error('operation completed without a result.');
1274
- }
1275
- return result;
1276
- }
1277
-
1278
- /** Checks whether the operation has reached a terminal state. */
1279
- async done(options?: CallOptions): Promise<boolean> {
1280
- const pollResp = await this.client.genieGetConversationMessage(
1281
- {
1282
- messageId: this.messageId,
1283
- conversationId: this.conversationId,
1284
- spaceId: this.spaceId,
1285
- },
1286
- options
1287
- );
1288
-
1289
- const status = pollResp.status;
1290
- if (status === undefined) {
1291
- throw new Error('response missing required status field');
1292
- }
1293
-
1294
- switch (status) {
1295
- case MessageStatus_MessageStatus.COMPLETED:
1296
- case MessageStatus_MessageStatus.FAILED:
1297
- return true;
1298
- default:
1299
- return false;
1300
- }
1301
- }
1302
- }