@databricks/sdk-genie 0.1.0-dev.5 → 0.2.0

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.js CHANGED
@@ -2,56 +2,55 @@
2
2
  import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
3
3
  import { createDefault } from '@databricks/sdk-core/clientinfo';
4
4
  import { NoOpLogger } from '@databricks/sdk-core/logger';
5
- import { newHttpClient } from './transport';
5
+ import { resolveClientConfig } from './transport';
6
6
  import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, executeWait, StillRunningError, } from './utils';
7
7
  import pkgJson from '../../package.json' with { type: 'json' };
8
- import { MessageStatus_MessageStatus, marshalGenieCreateConversationMessageRequestSchema, marshalGenieCreateEvalRunRequestSchema, marshalGenieCreateMessageCommentRequestSchema, marshalGenieCreateSpaceRequestSchema, marshalGenieExecuteMessageAttachmentQueryRequestSchema, marshalGenieExecuteMessageQueryRequestSchema, marshalGenieGenerateDownloadFullQueryResultRequestSchema, marshalGenieSendMessageFeedbackRequestSchema, marshalGenieStartConversationMessageRequestSchema, marshalGenieUpdateSpaceRequestSchema, unmarshalGenieEvalResultDetailsSchema, unmarshalGenieEvalRunResponseSchema, unmarshalGenieGenerateDownloadFullQueryResultResponseSchema, unmarshalGenieGetDownloadFullQueryResultResponseSchema, unmarshalGenieGetMessageQueryResultResponseSchema, unmarshalGenieListConversationCommentsResponseSchema, unmarshalGenieListConversationMessagesResponseSchema, unmarshalGenieListConversationsResponseSchema, unmarshalGenieListEvalResultsResponseSchema, unmarshalGenieListEvalRunsResponseSchema, unmarshalGenieListMessageCommentsResponseSchema, unmarshalGenieListSpacesResponseSchema, unmarshalGenieMessageCommentSchema, unmarshalGenieMessageSchema, unmarshalGenieSpaceSchema, unmarshalGenieStartConversationResponseSchema, } from './model';
8
+ import { MessageStatus_MessageStatus, marshalGenieCreateConversationMessageRequestSchema, marshalGenieCreateEvalRunRequestSchema, marshalGenieCreateMessageCommentRequestSchema, marshalGenieCreateSpaceRequestSchema, marshalGenieExecuteMessageAttachmentQueryRequestSchema, marshalGenieExecuteMessageQueryRequestSchema, marshalGenieGenerateDownloadFullQueryResultRequestSchema, marshalGenieSendMessageFeedbackRequestSchema, marshalGenieStartConversationRequestSchema, marshalGenieUpdateSpaceRequestSchema, unmarshalGenieEvalResultDetailsSchema, unmarshalGenieEvalRunResponseSchema, unmarshalGenieGenerateDownloadFullQueryResultResponseSchema, unmarshalGenieGetDownloadFullQueryResultResponseSchema, unmarshalGenieGetMessageQueryResultResponseSchema, unmarshalGenieListConversationCommentsResponseSchema, unmarshalGenieListConversationMessagesResponseSchema, unmarshalGenieListConversationsResponseSchema, unmarshalGenieListEvalResultsResponseSchema, unmarshalGenieListEvalRunsResponseSchema, unmarshalGenieListMessageCommentsResponseSchema, unmarshalGenieListSpacesResponseSchema, unmarshalGenieMessageCommentSchema, unmarshalGenieMessageSchema, unmarshalGenieSpaceSchema, unmarshalGenieStartConversationResponseSchema, } from './model';
9
9
  // Package identity segment for this client to be used in the User-Agent header.
10
10
  const PACKAGE_SEGMENT = {
11
11
  key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
12
12
  value: pkgJson.version,
13
13
  };
14
14
  export class GenieClient {
15
- host;
16
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
17
- // When set, workspace-level methods send X-Databricks-Org-Id on every
18
- // request.
19
- workspaceId;
20
- httpClient;
15
+ options;
21
16
  logger;
22
17
  // User-Agent header value. Composed once at construction from
23
18
  // createDefault() merged with this package's identity and the active
24
19
  // credential's name.
25
20
  userAgent;
21
+ // Memoized configuration. The profile is resolved once, lazily, on the first
22
+ // request, then reused; host, workspaceId/accountId, and credentials are
23
+ // filled from it when not set explicitly on the options.
24
+ config;
26
25
  constructor(options) {
27
- if (options.host === undefined) {
28
- throw new Error('Host is required.');
29
- }
30
- this.host = options.host.replace(/\/$/, '');
31
- this.workspaceId = options.workspaceId;
26
+ this.options = options;
32
27
  this.logger = options.logger ?? new NoOpLogger();
33
28
  const info = createDefault()
34
29
  .with(PACKAGE_SEGMENT)
35
30
  .with({ key: 'sdk-js-auth', value: AUTH_VERSION })
36
31
  .with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
37
32
  this.userAgent = info.toString();
38
- this.httpClient = newHttpClient(options);
33
+ }
34
+ resolveConfig() {
35
+ this.config ??= resolveClientConfig(this.options);
36
+ return this.config;
39
37
  }
40
38
  /** Creates a Genie space from a serialized payload. */
41
39
  async createSpace(req, options) {
42
- const url = `${this.host}/api/2.0/genie/spaces`;
40
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
41
+ const url = `${host}/api/2.0/genie/spaces`;
43
42
  const body = marshalRequest(req, marshalGenieCreateSpaceRequestSchema);
44
43
  let resp;
45
44
  const call = async (callSignal) => {
46
45
  const headers = new Headers({ 'Content-Type': 'application/json' });
47
- if (this.workspaceId !== undefined) {
48
- headers.set('X-Databricks-Org-Id', this.workspaceId);
46
+ if (workspaceId !== undefined) {
47
+ headers.set('X-Databricks-Org-Id', workspaceId);
49
48
  }
50
49
  headers.set('User-Agent', this.userAgent);
51
50
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
52
51
  const respBody = await executeHttpCall({
53
52
  request: httpReq,
54
- httpClient: this.httpClient,
53
+ httpClient,
55
54
  logger: this.logger,
56
55
  });
57
56
  resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
@@ -66,20 +65,21 @@ export class GenieClient {
66
65
  * Create new message in a [conversation](:method:genie/startconversation).
67
66
  * The AI response uses all previously created messages in the conversation to respond.
68
67
  */
69
- async genieCreateConversationMessage(req, options) {
70
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
68
+ async genieCreateConversationMessageBase(req, options) {
69
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
70
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
71
71
  const body = marshalRequest(req, marshalGenieCreateConversationMessageRequestSchema);
72
72
  let resp;
73
73
  const call = async (callSignal) => {
74
74
  const headers = new Headers({ 'Content-Type': 'application/json' });
75
- if (this.workspaceId !== undefined) {
76
- headers.set('X-Databricks-Org-Id', this.workspaceId);
75
+ if (workspaceId !== undefined) {
76
+ headers.set('X-Databricks-Org-Id', workspaceId);
77
77
  }
78
78
  headers.set('User-Agent', this.userAgent);
79
79
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
80
80
  const respBody = await executeHttpCall({
81
81
  request: httpReq,
82
- httpClient: this.httpClient,
82
+ httpClient,
83
83
  logger: this.logger,
84
84
  });
85
85
  resp = parseResponse(respBody, unmarshalGenieMessageSchema);
@@ -90,8 +90,12 @@ export class GenieClient {
90
90
  }
91
91
  return resp;
92
92
  }
93
- async genieCreateConversationMessageWaiter(req, options) {
94
- const resp = await this.genieCreateConversationMessage(req, options);
93
+ /**
94
+ * Create new message in a [conversation](:method:genie/startconversation).
95
+ * The AI response uses all previously created messages in the conversation to respond.
96
+ */
97
+ async genieCreateConversationMessage(req, options) {
98
+ const resp = await this.genieCreateConversationMessageBase(req, options);
95
99
  if (resp.messageId === undefined) {
96
100
  throw new Error('response field messageId required for polling is missing');
97
101
  }
@@ -105,19 +109,20 @@ export class GenieClient {
105
109
  }
106
110
  /** Create and run evaluations for multiple benchmark questions in a Genie space. */
107
111
  async genieCreateEvalRun(req, options) {
108
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
112
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
113
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
109
114
  const body = marshalRequest(req, marshalGenieCreateEvalRunRequestSchema);
110
115
  let resp;
111
116
  const call = async (callSignal) => {
112
117
  const headers = new Headers({ 'Content-Type': 'application/json' });
113
- if (this.workspaceId !== undefined) {
114
- headers.set('X-Databricks-Org-Id', this.workspaceId);
118
+ if (workspaceId !== undefined) {
119
+ headers.set('X-Databricks-Org-Id', workspaceId);
115
120
  }
116
121
  headers.set('User-Agent', this.userAgent);
117
122
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
118
123
  const respBody = await executeHttpCall({
119
124
  request: httpReq,
120
- httpClient: this.httpClient,
125
+ httpClient,
121
126
  logger: this.logger,
122
127
  });
123
128
  resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
@@ -130,19 +135,20 @@ export class GenieClient {
130
135
  }
131
136
  /** Create a comment on a conversation message. */
132
137
  async genieCreateMessageComment(req, options) {
133
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
138
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
139
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
134
140
  const body = marshalRequest(req, marshalGenieCreateMessageCommentRequestSchema);
135
141
  let resp;
136
142
  const call = async (callSignal) => {
137
143
  const headers = new Headers({ 'Content-Type': 'application/json' });
138
- if (this.workspaceId !== undefined) {
139
- headers.set('X-Databricks-Org-Id', this.workspaceId);
144
+ if (workspaceId !== undefined) {
145
+ headers.set('X-Databricks-Org-Id', workspaceId);
140
146
  }
141
147
  headers.set('User-Agent', this.userAgent);
142
148
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
143
149
  const respBody = await executeHttpCall({
144
150
  request: httpReq,
145
- httpClient: this.httpClient,
151
+ httpClient,
146
152
  logger: this.logger,
147
153
  });
148
154
  resp = parseResponse(respBody, unmarshalGenieMessageCommentSchema);
@@ -155,17 +161,18 @@ export class GenieClient {
155
161
  }
156
162
  /** Delete a conversation. */
157
163
  async genieDeleteConversation(req, options) {
158
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`;
164
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
165
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`;
159
166
  const call = async (callSignal) => {
160
167
  const headers = new Headers();
161
- if (this.workspaceId !== undefined) {
162
- headers.set('X-Databricks-Org-Id', this.workspaceId);
168
+ if (workspaceId !== undefined) {
169
+ headers.set('X-Databricks-Org-Id', workspaceId);
163
170
  }
164
171
  headers.set('User-Agent', this.userAgent);
165
172
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
166
173
  await executeHttpCall({
167
174
  request: httpReq,
168
- httpClient: this.httpClient,
175
+ httpClient,
169
176
  logger: this.logger,
170
177
  });
171
178
  };
@@ -173,17 +180,18 @@ export class GenieClient {
173
180
  }
174
181
  /** Delete a conversation message. */
175
182
  async genieDeleteConversationMessage(req, options) {
176
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
183
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
184
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
177
185
  const call = async (callSignal) => {
178
186
  const headers = new Headers();
179
- if (this.workspaceId !== undefined) {
180
- headers.set('X-Databricks-Org-Id', this.workspaceId);
187
+ if (workspaceId !== undefined) {
188
+ headers.set('X-Databricks-Org-Id', workspaceId);
181
189
  }
182
190
  headers.set('User-Agent', this.userAgent);
183
191
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
184
192
  await executeHttpCall({
185
193
  request: httpReq,
186
- httpClient: this.httpClient,
194
+ httpClient,
187
195
  logger: this.logger,
188
196
  });
189
197
  };
@@ -191,19 +199,20 @@ export class GenieClient {
191
199
  }
192
200
  /** Execute the SQL for a message query attachment. Use this API when the query attachment has expired and needs to be re-executed. */
193
201
  async genieExecuteMessageAttachmentQuery(req, options) {
194
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/execute-query`;
202
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
203
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/execute-query`;
195
204
  const body = marshalRequest(req, marshalGenieExecuteMessageAttachmentQueryRequestSchema);
196
205
  let resp;
197
206
  const call = async (callSignal) => {
198
207
  const headers = new Headers({ 'Content-Type': 'application/json' });
199
- if (this.workspaceId !== undefined) {
200
- headers.set('X-Databricks-Org-Id', this.workspaceId);
208
+ if (workspaceId !== undefined) {
209
+ headers.set('X-Databricks-Org-Id', workspaceId);
201
210
  }
202
211
  headers.set('User-Agent', this.userAgent);
203
212
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
204
213
  const respBody = await executeHttpCall({
205
214
  request: httpReq,
206
- httpClient: this.httpClient,
215
+ httpClient,
207
216
  logger: this.logger,
208
217
  });
209
218
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -216,19 +225,20 @@ export class GenieClient {
216
225
  }
217
226
  /** DEPRECATED: Use [Execute Message Attachment Query](:method:genie/executemessageattachmentquery) instead. */
218
227
  async genieExecuteMessageQuery(req, options) {
219
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`;
228
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
229
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`;
220
230
  const body = marshalRequest(req, marshalGenieExecuteMessageQueryRequestSchema);
221
231
  let resp;
222
232
  const call = async (callSignal) => {
223
233
  const headers = new Headers({ 'Content-Type': 'application/json' });
224
- if (this.workspaceId !== undefined) {
225
- headers.set('X-Databricks-Org-Id', this.workspaceId);
234
+ if (workspaceId !== undefined) {
235
+ headers.set('X-Databricks-Org-Id', workspaceId);
226
236
  }
227
237
  headers.set('User-Agent', this.userAgent);
228
238
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
229
239
  const respBody = await executeHttpCall({
230
240
  request: httpReq,
231
- httpClient: this.httpClient,
241
+ httpClient,
232
242
  logger: this.logger,
233
243
  });
234
244
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -265,19 +275,20 @@ export class GenieClient {
265
275
  * ----
266
276
  */
267
277
  async genieGenerateDownloadFullQueryResult(req, options) {
268
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads`;
278
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
279
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads`;
269
280
  const body = marshalRequest(req, marshalGenieGenerateDownloadFullQueryResultRequestSchema);
270
281
  let resp;
271
282
  const call = async (callSignal) => {
272
283
  const headers = new Headers({ 'Content-Type': 'application/json' });
273
- if (this.workspaceId !== undefined) {
274
- headers.set('X-Databricks-Org-Id', this.workspaceId);
284
+ if (workspaceId !== undefined) {
285
+ headers.set('X-Databricks-Org-Id', workspaceId);
275
286
  }
276
287
  headers.set('User-Agent', this.userAgent);
277
288
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
278
289
  const respBody = await executeHttpCall({
279
290
  request: httpReq,
280
- httpClient: this.httpClient,
291
+ httpClient,
281
292
  logger: this.logger,
282
293
  });
283
294
  resp = parseResponse(respBody, unmarshalGenieGenerateDownloadFullQueryResultResponseSchema);
@@ -290,18 +301,19 @@ export class GenieClient {
290
301
  }
291
302
  /** Get message from conversation. */
292
303
  async genieGetConversationMessage(req, options) {
293
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
304
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
305
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
294
306
  let resp;
295
307
  const call = async (callSignal) => {
296
308
  const headers = new Headers();
297
- if (this.workspaceId !== undefined) {
298
- headers.set('X-Databricks-Org-Id', this.workspaceId);
309
+ if (workspaceId !== undefined) {
310
+ headers.set('X-Databricks-Org-Id', workspaceId);
299
311
  }
300
312
  headers.set('User-Agent', this.userAgent);
301
313
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
302
314
  const respBody = await executeHttpCall({
303
315
  request: httpReq,
304
- httpClient: this.httpClient,
316
+ httpClient,
305
317
  logger: this.logger,
306
318
  });
307
319
  resp = parseResponse(respBody, unmarshalGenieMessageSchema);
@@ -338,7 +350,8 @@ export class GenieClient {
338
350
  * ----
339
351
  */
340
352
  async genieGetDownloadFullQueryResult(req, options) {
341
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads/${req.downloadId ?? ''}`;
353
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
354
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads/${req.downloadId ?? ''}`;
342
355
  const params = new URLSearchParams();
343
356
  if (req.downloadIdSignature !== undefined) {
344
357
  params.append('download_id_signature', req.downloadIdSignature);
@@ -348,14 +361,14 @@ export class GenieClient {
348
361
  let resp;
349
362
  const call = async (callSignal) => {
350
363
  const headers = new Headers();
351
- if (this.workspaceId !== undefined) {
352
- headers.set('X-Databricks-Org-Id', this.workspaceId);
364
+ if (workspaceId !== undefined) {
365
+ headers.set('X-Databricks-Org-Id', workspaceId);
353
366
  }
354
367
  headers.set('User-Agent', this.userAgent);
355
368
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
356
369
  const respBody = await executeHttpCall({
357
370
  request: httpReq,
358
- httpClient: this.httpClient,
371
+ httpClient,
359
372
  logger: this.logger,
360
373
  });
361
374
  resp = parseResponse(respBody, unmarshalGenieGetDownloadFullQueryResultResponseSchema);
@@ -368,18 +381,19 @@ export class GenieClient {
368
381
  }
369
382
  /** Get details for evaluation results. */
370
383
  async genieGetEvalResultDetails(req, options) {
371
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`;
384
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
385
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`;
372
386
  let resp;
373
387
  const call = async (callSignal) => {
374
388
  const headers = new Headers();
375
- if (this.workspaceId !== undefined) {
376
- headers.set('X-Databricks-Org-Id', this.workspaceId);
389
+ if (workspaceId !== undefined) {
390
+ headers.set('X-Databricks-Org-Id', workspaceId);
377
391
  }
378
392
  headers.set('User-Agent', this.userAgent);
379
393
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
380
394
  const respBody = await executeHttpCall({
381
395
  request: httpReq,
382
- httpClient: this.httpClient,
396
+ httpClient,
383
397
  logger: this.logger,
384
398
  });
385
399
  resp = parseResponse(respBody, unmarshalGenieEvalResultDetailsSchema);
@@ -392,18 +406,19 @@ export class GenieClient {
392
406
  }
393
407
  /** Get evaluation run details. */
394
408
  async genieGetEvalRun(req, options) {
395
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`;
409
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
410
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`;
396
411
  let resp;
397
412
  const call = async (callSignal) => {
398
413
  const headers = new Headers();
399
- if (this.workspaceId !== undefined) {
400
- headers.set('X-Databricks-Org-Id', this.workspaceId);
414
+ if (workspaceId !== undefined) {
415
+ headers.set('X-Databricks-Org-Id', workspaceId);
401
416
  }
402
417
  headers.set('User-Agent', this.userAgent);
403
418
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
404
419
  const respBody = await executeHttpCall({
405
420
  request: httpReq,
406
- httpClient: this.httpClient,
421
+ httpClient,
407
422
  logger: this.logger,
408
423
  });
409
424
  resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
@@ -419,18 +434,19 @@ export class GenieClient {
419
434
  * This is only available if a message has a query attachment and the message status is `EXECUTING_QUERY` OR `COMPLETED`.
420
435
  */
421
436
  async genieGetMessageAttachmentQueryResult(req, options) {
422
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/query-result`;
437
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
438
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/query-result`;
423
439
  let resp;
424
440
  const call = async (callSignal) => {
425
441
  const headers = new Headers();
426
- if (this.workspaceId !== undefined) {
427
- headers.set('X-Databricks-Org-Id', this.workspaceId);
442
+ if (workspaceId !== undefined) {
443
+ headers.set('X-Databricks-Org-Id', workspaceId);
428
444
  }
429
445
  headers.set('User-Agent', this.userAgent);
430
446
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
431
447
  const respBody = await executeHttpCall({
432
448
  request: httpReq,
433
- httpClient: this.httpClient,
449
+ httpClient,
434
450
  logger: this.logger,
435
451
  });
436
452
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -443,18 +459,19 @@ export class GenieClient {
443
459
  }
444
460
  /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
445
461
  async genieGetMessageQueryResult(req, options) {
446
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`;
462
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
463
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`;
447
464
  let resp;
448
465
  const call = async (callSignal) => {
449
466
  const headers = new Headers();
450
- if (this.workspaceId !== undefined) {
451
- headers.set('X-Databricks-Org-Id', this.workspaceId);
467
+ if (workspaceId !== undefined) {
468
+ headers.set('X-Databricks-Org-Id', workspaceId);
452
469
  }
453
470
  headers.set('User-Agent', this.userAgent);
454
471
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
455
472
  const respBody = await executeHttpCall({
456
473
  request: httpReq,
457
- httpClient: this.httpClient,
474
+ httpClient,
458
475
  logger: this.logger,
459
476
  });
460
477
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -467,18 +484,19 @@ export class GenieClient {
467
484
  }
468
485
  /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
469
486
  async genieGetQueryResultByAttachment(req, options) {
470
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result/${req.attachmentId ?? ''}`;
487
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
488
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result/${req.attachmentId ?? ''}`;
471
489
  let resp;
472
490
  const call = async (callSignal) => {
473
491
  const headers = new Headers();
474
- if (this.workspaceId !== undefined) {
475
- headers.set('X-Databricks-Org-Id', this.workspaceId);
492
+ if (workspaceId !== undefined) {
493
+ headers.set('X-Databricks-Org-Id', workspaceId);
476
494
  }
477
495
  headers.set('User-Agent', this.userAgent);
478
496
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
479
497
  const respBody = await executeHttpCall({
480
498
  request: httpReq,
481
- httpClient: this.httpClient,
499
+ httpClient,
482
500
  logger: this.logger,
483
501
  });
484
502
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -491,7 +509,8 @@ export class GenieClient {
491
509
  }
492
510
  /** Get details of a Genie Space. */
493
511
  async genieGetSpace(req, options) {
494
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
512
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
513
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
495
514
  const params = new URLSearchParams();
496
515
  if (req.includeSerializedSpace !== undefined) {
497
516
  params.append('include_serialized_space', String(req.includeSerializedSpace));
@@ -501,14 +520,14 @@ export class GenieClient {
501
520
  let resp;
502
521
  const call = async (callSignal) => {
503
522
  const headers = new Headers();
504
- if (this.workspaceId !== undefined) {
505
- headers.set('X-Databricks-Org-Id', this.workspaceId);
523
+ if (workspaceId !== undefined) {
524
+ headers.set('X-Databricks-Org-Id', workspaceId);
506
525
  }
507
526
  headers.set('User-Agent', this.userAgent);
508
527
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
509
528
  const respBody = await executeHttpCall({
510
529
  request: httpReq,
511
- httpClient: this.httpClient,
530
+ httpClient,
512
531
  logger: this.logger,
513
532
  });
514
533
  resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
@@ -521,7 +540,8 @@ export class GenieClient {
521
540
  }
522
541
  /** List all comments across all messages in a conversation. */
523
542
  async genieListConversationComments(req, options) {
524
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`;
543
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
544
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`;
525
545
  const params = new URLSearchParams();
526
546
  if (req.pageSize !== undefined) {
527
547
  params.append('page_size', String(req.pageSize));
@@ -534,14 +554,14 @@ export class GenieClient {
534
554
  let resp;
535
555
  const call = async (callSignal) => {
536
556
  const headers = new Headers();
537
- if (this.workspaceId !== undefined) {
538
- headers.set('X-Databricks-Org-Id', this.workspaceId);
557
+ if (workspaceId !== undefined) {
558
+ headers.set('X-Databricks-Org-Id', workspaceId);
539
559
  }
540
560
  headers.set('User-Agent', this.userAgent);
541
561
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
542
562
  const respBody = await executeHttpCall({
543
563
  request: httpReq,
544
- httpClient: this.httpClient,
564
+ httpClient,
545
565
  logger: this.logger,
546
566
  });
547
567
  resp = parseResponse(respBody, unmarshalGenieListConversationCommentsResponseSchema);
@@ -554,7 +574,8 @@ export class GenieClient {
554
574
  }
555
575
  /** List messages in a conversation */
556
576
  async genieListConversationMessages(req, options) {
557
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
577
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
578
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
558
579
  const params = new URLSearchParams();
559
580
  if (req.pageSize !== undefined) {
560
581
  params.append('page_size', String(req.pageSize));
@@ -567,14 +588,14 @@ export class GenieClient {
567
588
  let resp;
568
589
  const call = async (callSignal) => {
569
590
  const headers = new Headers();
570
- if (this.workspaceId !== undefined) {
571
- headers.set('X-Databricks-Org-Id', this.workspaceId);
591
+ if (workspaceId !== undefined) {
592
+ headers.set('X-Databricks-Org-Id', workspaceId);
572
593
  }
573
594
  headers.set('User-Agent', this.userAgent);
574
595
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
575
596
  const respBody = await executeHttpCall({
576
597
  request: httpReq,
577
- httpClient: this.httpClient,
598
+ httpClient,
578
599
  logger: this.logger,
579
600
  });
580
601
  resp = parseResponse(respBody, unmarshalGenieListConversationMessagesResponseSchema);
@@ -587,7 +608,8 @@ export class GenieClient {
587
608
  }
588
609
  /** Get a list of conversations in a Genie Space. */
589
610
  async genieListConversations(req, options) {
590
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`;
611
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
612
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`;
591
613
  const params = new URLSearchParams();
592
614
  if (req.pageSize !== undefined) {
593
615
  params.append('page_size', String(req.pageSize));
@@ -603,14 +625,14 @@ export class GenieClient {
603
625
  let resp;
604
626
  const call = async (callSignal) => {
605
627
  const headers = new Headers();
606
- if (this.workspaceId !== undefined) {
607
- headers.set('X-Databricks-Org-Id', this.workspaceId);
628
+ if (workspaceId !== undefined) {
629
+ headers.set('X-Databricks-Org-Id', workspaceId);
608
630
  }
609
631
  headers.set('User-Agent', this.userAgent);
610
632
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
611
633
  const respBody = await executeHttpCall({
612
634
  request: httpReq,
613
- httpClient: this.httpClient,
635
+ httpClient,
614
636
  logger: this.logger,
615
637
  });
616
638
  resp = parseResponse(respBody, unmarshalGenieListConversationsResponseSchema);
@@ -623,7 +645,8 @@ export class GenieClient {
623
645
  }
624
646
  /** List evaluation results for a specific evaluation run. */
625
647
  async genieListEvalResults(req, options) {
626
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`;
648
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
649
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`;
627
650
  const params = new URLSearchParams();
628
651
  if (req.pageSize !== undefined) {
629
652
  params.append('page_size', String(req.pageSize));
@@ -636,14 +659,14 @@ export class GenieClient {
636
659
  let resp;
637
660
  const call = async (callSignal) => {
638
661
  const headers = new Headers();
639
- if (this.workspaceId !== undefined) {
640
- headers.set('X-Databricks-Org-Id', this.workspaceId);
662
+ if (workspaceId !== undefined) {
663
+ headers.set('X-Databricks-Org-Id', workspaceId);
641
664
  }
642
665
  headers.set('User-Agent', this.userAgent);
643
666
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
644
667
  const respBody = await executeHttpCall({
645
668
  request: httpReq,
646
- httpClient: this.httpClient,
669
+ httpClient,
647
670
  logger: this.logger,
648
671
  });
649
672
  resp = parseResponse(respBody, unmarshalGenieListEvalResultsResponseSchema);
@@ -656,7 +679,8 @@ export class GenieClient {
656
679
  }
657
680
  /** Lists all evaluation runs in a space. */
658
681
  async genieListEvalRuns(req, options) {
659
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
682
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
683
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
660
684
  const params = new URLSearchParams();
661
685
  if (req.pageSize !== undefined) {
662
686
  params.append('page_size', String(req.pageSize));
@@ -669,14 +693,14 @@ export class GenieClient {
669
693
  let resp;
670
694
  const call = async (callSignal) => {
671
695
  const headers = new Headers();
672
- if (this.workspaceId !== undefined) {
673
- headers.set('X-Databricks-Org-Id', this.workspaceId);
696
+ if (workspaceId !== undefined) {
697
+ headers.set('X-Databricks-Org-Id', workspaceId);
674
698
  }
675
699
  headers.set('User-Agent', this.userAgent);
676
700
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
677
701
  const respBody = await executeHttpCall({
678
702
  request: httpReq,
679
- httpClient: this.httpClient,
703
+ httpClient,
680
704
  logger: this.logger,
681
705
  });
682
706
  resp = parseResponse(respBody, unmarshalGenieListEvalRunsResponseSchema);
@@ -689,7 +713,8 @@ export class GenieClient {
689
713
  }
690
714
  /** List comments on a specific conversation message. */
691
715
  async genieListMessageComments(req, options) {
692
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
716
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
717
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
693
718
  const params = new URLSearchParams();
694
719
  if (req.pageSize !== undefined) {
695
720
  params.append('page_size', String(req.pageSize));
@@ -702,14 +727,14 @@ export class GenieClient {
702
727
  let resp;
703
728
  const call = async (callSignal) => {
704
729
  const headers = new Headers();
705
- if (this.workspaceId !== undefined) {
706
- headers.set('X-Databricks-Org-Id', this.workspaceId);
730
+ if (workspaceId !== undefined) {
731
+ headers.set('X-Databricks-Org-Id', workspaceId);
707
732
  }
708
733
  headers.set('User-Agent', this.userAgent);
709
734
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
710
735
  const respBody = await executeHttpCall({
711
736
  request: httpReq,
712
- httpClient: this.httpClient,
737
+ httpClient,
713
738
  logger: this.logger,
714
739
  });
715
740
  resp = parseResponse(respBody, unmarshalGenieListMessageCommentsResponseSchema);
@@ -722,7 +747,8 @@ export class GenieClient {
722
747
  }
723
748
  /** Get list of Genie Spaces. */
724
749
  async genieListSpaces(req, options) {
725
- const url = `${this.host}/api/2.0/genie/spaces`;
750
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
751
+ const url = `${host}/api/2.0/genie/spaces`;
726
752
  const params = new URLSearchParams();
727
753
  if (req.pageSize !== undefined) {
728
754
  params.append('page_size', String(req.pageSize));
@@ -735,14 +761,14 @@ export class GenieClient {
735
761
  let resp;
736
762
  const call = async (callSignal) => {
737
763
  const headers = new Headers();
738
- if (this.workspaceId !== undefined) {
739
- headers.set('X-Databricks-Org-Id', this.workspaceId);
764
+ if (workspaceId !== undefined) {
765
+ headers.set('X-Databricks-Org-Id', workspaceId);
740
766
  }
741
767
  headers.set('User-Agent', this.userAgent);
742
768
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
743
769
  const respBody = await executeHttpCall({
744
770
  request: httpReq,
745
- httpClient: this.httpClient,
771
+ httpClient,
746
772
  logger: this.logger,
747
773
  });
748
774
  resp = parseResponse(respBody, unmarshalGenieListSpacesResponseSchema);
@@ -755,38 +781,40 @@ export class GenieClient {
755
781
  }
756
782
  /** Send feedback for a message. */
757
783
  async genieSendMessageFeedback(req, options) {
758
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`;
784
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
785
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`;
759
786
  const body = marshalRequest(req, marshalGenieSendMessageFeedbackRequestSchema);
760
787
  const call = async (callSignal) => {
761
788
  const headers = new Headers({ 'Content-Type': 'application/json' });
762
- if (this.workspaceId !== undefined) {
763
- headers.set('X-Databricks-Org-Id', this.workspaceId);
789
+ if (workspaceId !== undefined) {
790
+ headers.set('X-Databricks-Org-Id', workspaceId);
764
791
  }
765
792
  headers.set('User-Agent', this.userAgent);
766
793
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
767
794
  await executeHttpCall({
768
795
  request: httpReq,
769
- httpClient: this.httpClient,
796
+ httpClient,
770
797
  logger: this.logger,
771
798
  });
772
799
  };
773
800
  await executeCall(call, options);
774
801
  }
775
802
  /** Start a new conversation. */
776
- async genieStartConversation(req, options) {
777
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`;
778
- const body = marshalRequest(req, marshalGenieStartConversationMessageRequestSchema);
803
+ async genieStartConversationBase(req, options) {
804
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
805
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`;
806
+ const body = marshalRequest(req, marshalGenieStartConversationRequestSchema);
779
807
  let resp;
780
808
  const call = async (callSignal) => {
781
809
  const headers = new Headers({ 'Content-Type': 'application/json' });
782
- if (this.workspaceId !== undefined) {
783
- headers.set('X-Databricks-Org-Id', this.workspaceId);
810
+ if (workspaceId !== undefined) {
811
+ headers.set('X-Databricks-Org-Id', workspaceId);
784
812
  }
785
813
  headers.set('User-Agent', this.userAgent);
786
814
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
787
815
  const respBody = await executeHttpCall({
788
816
  request: httpReq,
789
- httpClient: this.httpClient,
817
+ httpClient,
790
818
  logger: this.logger,
791
819
  });
792
820
  resp = parseResponse(respBody, unmarshalGenieStartConversationResponseSchema);
@@ -797,8 +825,9 @@ export class GenieClient {
797
825
  }
798
826
  return resp;
799
827
  }
800
- async genieStartConversationWaiter(req, options) {
801
- const resp = await this.genieStartConversation(req, options);
828
+ /** Start a new conversation. */
829
+ async genieStartConversation(req, options) {
830
+ const resp = await this.genieStartConversationBase(req, options);
802
831
  if (resp.messageId === undefined) {
803
832
  throw new Error('response field messageId required for polling is missing');
804
833
  }
@@ -812,17 +841,18 @@ export class GenieClient {
812
841
  }
813
842
  /** Move a Genie Space to the trash. */
814
843
  async genieTrashSpace(req, options) {
815
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
844
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
845
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
816
846
  const call = async (callSignal) => {
817
847
  const headers = new Headers();
818
- if (this.workspaceId !== undefined) {
819
- headers.set('X-Databricks-Org-Id', this.workspaceId);
848
+ if (workspaceId !== undefined) {
849
+ headers.set('X-Databricks-Org-Id', workspaceId);
820
850
  }
821
851
  headers.set('User-Agent', this.userAgent);
822
852
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
823
853
  await executeHttpCall({
824
854
  request: httpReq,
825
- httpClient: this.httpClient,
855
+ httpClient,
826
856
  logger: this.logger,
827
857
  });
828
858
  };
@@ -830,19 +860,20 @@ export class GenieClient {
830
860
  }
831
861
  /** Updates a Genie space with a serialized payload. */
832
862
  async updateSpace(req, options) {
833
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
863
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
864
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
834
865
  const body = marshalRequest(req, marshalGenieUpdateSpaceRequestSchema);
835
866
  let resp;
836
867
  const call = async (callSignal) => {
837
868
  const headers = new Headers({ 'Content-Type': 'application/json' });
838
- if (this.workspaceId !== undefined) {
839
- headers.set('X-Databricks-Org-Id', this.workspaceId);
869
+ if (workspaceId !== undefined) {
870
+ headers.set('X-Databricks-Org-Id', workspaceId);
840
871
  }
841
872
  headers.set('User-Agent', this.userAgent);
842
873
  const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
843
874
  const respBody = await executeHttpCall({
844
875
  request: httpReq,
845
- httpClient: this.httpClient,
876
+ httpClient,
846
877
  logger: this.logger,
847
878
  });
848
879
  resp = parseResponse(respBody, unmarshalGenieSpaceSchema);