@databricks/sdk-genie 0.1.0-dev.4 → 0.1.0-dev.6

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,7 +2,7 @@
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
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';
@@ -12,46 +12,45 @@ const PACKAGE_SEGMENT = {
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);
@@ -67,19 +66,20 @@ export class GenieClient {
67
66
  * The AI response uses all previously created messages in the conversation to respond.
68
67
  */
69
68
  async genieCreateConversationMessage(req, options) {
70
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
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);
@@ -105,19 +105,20 @@ export class GenieClient {
105
105
  }
106
106
  /** Create and run evaluations for multiple benchmark questions in a Genie space. */
107
107
  async genieCreateEvalRun(req, options) {
108
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
108
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
109
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
109
110
  const body = marshalRequest(req, marshalGenieCreateEvalRunRequestSchema);
110
111
  let resp;
111
112
  const call = async (callSignal) => {
112
113
  const headers = new Headers({ 'Content-Type': 'application/json' });
113
- if (this.workspaceId !== undefined) {
114
- headers.set('X-Databricks-Org-Id', this.workspaceId);
114
+ if (workspaceId !== undefined) {
115
+ headers.set('X-Databricks-Org-Id', workspaceId);
115
116
  }
116
117
  headers.set('User-Agent', this.userAgent);
117
118
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
118
119
  const respBody = await executeHttpCall({
119
120
  request: httpReq,
120
- httpClient: this.httpClient,
121
+ httpClient,
121
122
  logger: this.logger,
122
123
  });
123
124
  resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
@@ -130,19 +131,20 @@ export class GenieClient {
130
131
  }
131
132
  /** Create a comment on a conversation message. */
132
133
  async genieCreateMessageComment(req, options) {
133
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
134
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
135
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
134
136
  const body = marshalRequest(req, marshalGenieCreateMessageCommentRequestSchema);
135
137
  let resp;
136
138
  const call = async (callSignal) => {
137
139
  const headers = new Headers({ 'Content-Type': 'application/json' });
138
- if (this.workspaceId !== undefined) {
139
- headers.set('X-Databricks-Org-Id', this.workspaceId);
140
+ if (workspaceId !== undefined) {
141
+ headers.set('X-Databricks-Org-Id', workspaceId);
140
142
  }
141
143
  headers.set('User-Agent', this.userAgent);
142
144
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
143
145
  const respBody = await executeHttpCall({
144
146
  request: httpReq,
145
- httpClient: this.httpClient,
147
+ httpClient,
146
148
  logger: this.logger,
147
149
  });
148
150
  resp = parseResponse(respBody, unmarshalGenieMessageCommentSchema);
@@ -155,17 +157,18 @@ export class GenieClient {
155
157
  }
156
158
  /** Delete a conversation. */
157
159
  async genieDeleteConversation(req, options) {
158
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`;
160
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
161
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`;
159
162
  const call = async (callSignal) => {
160
163
  const headers = new Headers();
161
- if (this.workspaceId !== undefined) {
162
- headers.set('X-Databricks-Org-Id', this.workspaceId);
164
+ if (workspaceId !== undefined) {
165
+ headers.set('X-Databricks-Org-Id', workspaceId);
163
166
  }
164
167
  headers.set('User-Agent', this.userAgent);
165
168
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
166
169
  await executeHttpCall({
167
170
  request: httpReq,
168
- httpClient: this.httpClient,
171
+ httpClient,
169
172
  logger: this.logger,
170
173
  });
171
174
  };
@@ -173,17 +176,18 @@ export class GenieClient {
173
176
  }
174
177
  /** Delete a conversation message. */
175
178
  async genieDeleteConversationMessage(req, options) {
176
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
179
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
180
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
177
181
  const call = async (callSignal) => {
178
182
  const headers = new Headers();
179
- if (this.workspaceId !== undefined) {
180
- headers.set('X-Databricks-Org-Id', this.workspaceId);
183
+ if (workspaceId !== undefined) {
184
+ headers.set('X-Databricks-Org-Id', workspaceId);
181
185
  }
182
186
  headers.set('User-Agent', this.userAgent);
183
187
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
184
188
  await executeHttpCall({
185
189
  request: httpReq,
186
- httpClient: this.httpClient,
190
+ httpClient,
187
191
  logger: this.logger,
188
192
  });
189
193
  };
@@ -191,19 +195,20 @@ export class GenieClient {
191
195
  }
192
196
  /** Execute the SQL for a message query attachment. Use this API when the query attachment has expired and needs to be re-executed. */
193
197
  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`;
198
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
199
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/execute-query`;
195
200
  const body = marshalRequest(req, marshalGenieExecuteMessageAttachmentQueryRequestSchema);
196
201
  let resp;
197
202
  const call = async (callSignal) => {
198
203
  const headers = new Headers({ 'Content-Type': 'application/json' });
199
- if (this.workspaceId !== undefined) {
200
- headers.set('X-Databricks-Org-Id', this.workspaceId);
204
+ if (workspaceId !== undefined) {
205
+ headers.set('X-Databricks-Org-Id', workspaceId);
201
206
  }
202
207
  headers.set('User-Agent', this.userAgent);
203
208
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
204
209
  const respBody = await executeHttpCall({
205
210
  request: httpReq,
206
- httpClient: this.httpClient,
211
+ httpClient,
207
212
  logger: this.logger,
208
213
  });
209
214
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -216,19 +221,20 @@ export class GenieClient {
216
221
  }
217
222
  /** DEPRECATED: Use [Execute Message Attachment Query](:method:genie/executemessageattachmentquery) instead. */
218
223
  async genieExecuteMessageQuery(req, options) {
219
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`;
224
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
225
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`;
220
226
  const body = marshalRequest(req, marshalGenieExecuteMessageQueryRequestSchema);
221
227
  let resp;
222
228
  const call = async (callSignal) => {
223
229
  const headers = new Headers({ 'Content-Type': 'application/json' });
224
- if (this.workspaceId !== undefined) {
225
- headers.set('X-Databricks-Org-Id', this.workspaceId);
230
+ if (workspaceId !== undefined) {
231
+ headers.set('X-Databricks-Org-Id', workspaceId);
226
232
  }
227
233
  headers.set('User-Agent', this.userAgent);
228
234
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
229
235
  const respBody = await executeHttpCall({
230
236
  request: httpReq,
231
- httpClient: this.httpClient,
237
+ httpClient,
232
238
  logger: this.logger,
233
239
  });
234
240
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -265,19 +271,20 @@ export class GenieClient {
265
271
  * ----
266
272
  */
267
273
  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`;
274
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
275
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads`;
269
276
  const body = marshalRequest(req, marshalGenieGenerateDownloadFullQueryResultRequestSchema);
270
277
  let resp;
271
278
  const call = async (callSignal) => {
272
279
  const headers = new Headers({ 'Content-Type': 'application/json' });
273
- if (this.workspaceId !== undefined) {
274
- headers.set('X-Databricks-Org-Id', this.workspaceId);
280
+ if (workspaceId !== undefined) {
281
+ headers.set('X-Databricks-Org-Id', workspaceId);
275
282
  }
276
283
  headers.set('User-Agent', this.userAgent);
277
284
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
278
285
  const respBody = await executeHttpCall({
279
286
  request: httpReq,
280
- httpClient: this.httpClient,
287
+ httpClient,
281
288
  logger: this.logger,
282
289
  });
283
290
  resp = parseResponse(respBody, unmarshalGenieGenerateDownloadFullQueryResultResponseSchema);
@@ -290,18 +297,19 @@ export class GenieClient {
290
297
  }
291
298
  /** Get message from conversation. */
292
299
  async genieGetConversationMessage(req, options) {
293
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
300
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
301
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`;
294
302
  let resp;
295
303
  const call = async (callSignal) => {
296
304
  const headers = new Headers();
297
- if (this.workspaceId !== undefined) {
298
- headers.set('X-Databricks-Org-Id', this.workspaceId);
305
+ if (workspaceId !== undefined) {
306
+ headers.set('X-Databricks-Org-Id', workspaceId);
299
307
  }
300
308
  headers.set('User-Agent', this.userAgent);
301
309
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
302
310
  const respBody = await executeHttpCall({
303
311
  request: httpReq,
304
- httpClient: this.httpClient,
312
+ httpClient,
305
313
  logger: this.logger,
306
314
  });
307
315
  resp = parseResponse(respBody, unmarshalGenieMessageSchema);
@@ -338,7 +346,8 @@ export class GenieClient {
338
346
  * ----
339
347
  */
340
348
  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 ?? ''}`;
349
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
350
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads/${req.downloadId ?? ''}`;
342
351
  const params = new URLSearchParams();
343
352
  if (req.downloadIdSignature !== undefined) {
344
353
  params.append('download_id_signature', req.downloadIdSignature);
@@ -348,14 +357,14 @@ export class GenieClient {
348
357
  let resp;
349
358
  const call = async (callSignal) => {
350
359
  const headers = new Headers();
351
- if (this.workspaceId !== undefined) {
352
- headers.set('X-Databricks-Org-Id', this.workspaceId);
360
+ if (workspaceId !== undefined) {
361
+ headers.set('X-Databricks-Org-Id', workspaceId);
353
362
  }
354
363
  headers.set('User-Agent', this.userAgent);
355
364
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
356
365
  const respBody = await executeHttpCall({
357
366
  request: httpReq,
358
- httpClient: this.httpClient,
367
+ httpClient,
359
368
  logger: this.logger,
360
369
  });
361
370
  resp = parseResponse(respBody, unmarshalGenieGetDownloadFullQueryResultResponseSchema);
@@ -368,18 +377,19 @@ export class GenieClient {
368
377
  }
369
378
  /** Get details for evaluation results. */
370
379
  async genieGetEvalResultDetails(req, options) {
371
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`;
380
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
381
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`;
372
382
  let resp;
373
383
  const call = async (callSignal) => {
374
384
  const headers = new Headers();
375
- if (this.workspaceId !== undefined) {
376
- headers.set('X-Databricks-Org-Id', this.workspaceId);
385
+ if (workspaceId !== undefined) {
386
+ headers.set('X-Databricks-Org-Id', workspaceId);
377
387
  }
378
388
  headers.set('User-Agent', this.userAgent);
379
389
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
380
390
  const respBody = await executeHttpCall({
381
391
  request: httpReq,
382
- httpClient: this.httpClient,
392
+ httpClient,
383
393
  logger: this.logger,
384
394
  });
385
395
  resp = parseResponse(respBody, unmarshalGenieEvalResultDetailsSchema);
@@ -392,18 +402,19 @@ export class GenieClient {
392
402
  }
393
403
  /** Get evaluation run details. */
394
404
  async genieGetEvalRun(req, options) {
395
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`;
405
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
406
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`;
396
407
  let resp;
397
408
  const call = async (callSignal) => {
398
409
  const headers = new Headers();
399
- if (this.workspaceId !== undefined) {
400
- headers.set('X-Databricks-Org-Id', this.workspaceId);
410
+ if (workspaceId !== undefined) {
411
+ headers.set('X-Databricks-Org-Id', workspaceId);
401
412
  }
402
413
  headers.set('User-Agent', this.userAgent);
403
414
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
404
415
  const respBody = await executeHttpCall({
405
416
  request: httpReq,
406
- httpClient: this.httpClient,
417
+ httpClient,
407
418
  logger: this.logger,
408
419
  });
409
420
  resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema);
@@ -419,18 +430,19 @@ export class GenieClient {
419
430
  * This is only available if a message has a query attachment and the message status is `EXECUTING_QUERY` OR `COMPLETED`.
420
431
  */
421
432
  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`;
433
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
434
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/query-result`;
423
435
  let resp;
424
436
  const call = async (callSignal) => {
425
437
  const headers = new Headers();
426
- if (this.workspaceId !== undefined) {
427
- headers.set('X-Databricks-Org-Id', this.workspaceId);
438
+ if (workspaceId !== undefined) {
439
+ headers.set('X-Databricks-Org-Id', workspaceId);
428
440
  }
429
441
  headers.set('User-Agent', this.userAgent);
430
442
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
431
443
  const respBody = await executeHttpCall({
432
444
  request: httpReq,
433
- httpClient: this.httpClient,
445
+ httpClient,
434
446
  logger: this.logger,
435
447
  });
436
448
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -443,18 +455,19 @@ export class GenieClient {
443
455
  }
444
456
  /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
445
457
  async genieGetMessageQueryResult(req, options) {
446
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`;
458
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
459
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`;
447
460
  let resp;
448
461
  const call = async (callSignal) => {
449
462
  const headers = new Headers();
450
- if (this.workspaceId !== undefined) {
451
- headers.set('X-Databricks-Org-Id', this.workspaceId);
463
+ if (workspaceId !== undefined) {
464
+ headers.set('X-Databricks-Org-Id', workspaceId);
452
465
  }
453
466
  headers.set('User-Agent', this.userAgent);
454
467
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
455
468
  const respBody = await executeHttpCall({
456
469
  request: httpReq,
457
- httpClient: this.httpClient,
470
+ httpClient,
458
471
  logger: this.logger,
459
472
  });
460
473
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -467,18 +480,19 @@ export class GenieClient {
467
480
  }
468
481
  /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */
469
482
  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 ?? ''}`;
483
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
484
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result/${req.attachmentId ?? ''}`;
471
485
  let resp;
472
486
  const call = async (callSignal) => {
473
487
  const headers = new Headers();
474
- if (this.workspaceId !== undefined) {
475
- headers.set('X-Databricks-Org-Id', this.workspaceId);
488
+ if (workspaceId !== undefined) {
489
+ headers.set('X-Databricks-Org-Id', workspaceId);
476
490
  }
477
491
  headers.set('User-Agent', this.userAgent);
478
492
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
479
493
  const respBody = await executeHttpCall({
480
494
  request: httpReq,
481
- httpClient: this.httpClient,
495
+ httpClient,
482
496
  logger: this.logger,
483
497
  });
484
498
  resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema);
@@ -491,7 +505,8 @@ export class GenieClient {
491
505
  }
492
506
  /** Get details of a Genie Space. */
493
507
  async genieGetSpace(req, options) {
494
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
508
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
509
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
495
510
  const params = new URLSearchParams();
496
511
  if (req.includeSerializedSpace !== undefined) {
497
512
  params.append('include_serialized_space', String(req.includeSerializedSpace));
@@ -501,14 +516,14 @@ export class GenieClient {
501
516
  let resp;
502
517
  const call = async (callSignal) => {
503
518
  const headers = new Headers();
504
- if (this.workspaceId !== undefined) {
505
- headers.set('X-Databricks-Org-Id', this.workspaceId);
519
+ if (workspaceId !== undefined) {
520
+ headers.set('X-Databricks-Org-Id', workspaceId);
506
521
  }
507
522
  headers.set('User-Agent', this.userAgent);
508
523
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
509
524
  const respBody = await executeHttpCall({
510
525
  request: httpReq,
511
- httpClient: this.httpClient,
526
+ httpClient,
512
527
  logger: this.logger,
513
528
  });
514
529
  resp = parseResponse(respBody, unmarshalGenieSpaceSchema);
@@ -521,7 +536,8 @@ export class GenieClient {
521
536
  }
522
537
  /** List all comments across all messages in a conversation. */
523
538
  async genieListConversationComments(req, options) {
524
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`;
539
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
540
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`;
525
541
  const params = new URLSearchParams();
526
542
  if (req.pageSize !== undefined) {
527
543
  params.append('page_size', String(req.pageSize));
@@ -534,14 +550,14 @@ export class GenieClient {
534
550
  let resp;
535
551
  const call = async (callSignal) => {
536
552
  const headers = new Headers();
537
- if (this.workspaceId !== undefined) {
538
- headers.set('X-Databricks-Org-Id', this.workspaceId);
553
+ if (workspaceId !== undefined) {
554
+ headers.set('X-Databricks-Org-Id', workspaceId);
539
555
  }
540
556
  headers.set('User-Agent', this.userAgent);
541
557
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
542
558
  const respBody = await executeHttpCall({
543
559
  request: httpReq,
544
- httpClient: this.httpClient,
560
+ httpClient,
545
561
  logger: this.logger,
546
562
  });
547
563
  resp = parseResponse(respBody, unmarshalGenieListConversationCommentsResponseSchema);
@@ -554,7 +570,8 @@ export class GenieClient {
554
570
  }
555
571
  /** List messages in a conversation */
556
572
  async genieListConversationMessages(req, options) {
557
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
573
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
574
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`;
558
575
  const params = new URLSearchParams();
559
576
  if (req.pageSize !== undefined) {
560
577
  params.append('page_size', String(req.pageSize));
@@ -567,14 +584,14 @@ export class GenieClient {
567
584
  let resp;
568
585
  const call = async (callSignal) => {
569
586
  const headers = new Headers();
570
- if (this.workspaceId !== undefined) {
571
- headers.set('X-Databricks-Org-Id', this.workspaceId);
587
+ if (workspaceId !== undefined) {
588
+ headers.set('X-Databricks-Org-Id', workspaceId);
572
589
  }
573
590
  headers.set('User-Agent', this.userAgent);
574
591
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
575
592
  const respBody = await executeHttpCall({
576
593
  request: httpReq,
577
- httpClient: this.httpClient,
594
+ httpClient,
578
595
  logger: this.logger,
579
596
  });
580
597
  resp = parseResponse(respBody, unmarshalGenieListConversationMessagesResponseSchema);
@@ -587,7 +604,8 @@ export class GenieClient {
587
604
  }
588
605
  /** Get a list of conversations in a Genie Space. */
589
606
  async genieListConversations(req, options) {
590
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`;
607
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
608
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`;
591
609
  const params = new URLSearchParams();
592
610
  if (req.pageSize !== undefined) {
593
611
  params.append('page_size', String(req.pageSize));
@@ -603,14 +621,14 @@ export class GenieClient {
603
621
  let resp;
604
622
  const call = async (callSignal) => {
605
623
  const headers = new Headers();
606
- if (this.workspaceId !== undefined) {
607
- headers.set('X-Databricks-Org-Id', this.workspaceId);
624
+ if (workspaceId !== undefined) {
625
+ headers.set('X-Databricks-Org-Id', workspaceId);
608
626
  }
609
627
  headers.set('User-Agent', this.userAgent);
610
628
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
611
629
  const respBody = await executeHttpCall({
612
630
  request: httpReq,
613
- httpClient: this.httpClient,
631
+ httpClient,
614
632
  logger: this.logger,
615
633
  });
616
634
  resp = parseResponse(respBody, unmarshalGenieListConversationsResponseSchema);
@@ -623,7 +641,8 @@ export class GenieClient {
623
641
  }
624
642
  /** List evaluation results for a specific evaluation run. */
625
643
  async genieListEvalResults(req, options) {
626
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`;
644
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
645
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`;
627
646
  const params = new URLSearchParams();
628
647
  if (req.pageSize !== undefined) {
629
648
  params.append('page_size', String(req.pageSize));
@@ -636,14 +655,14 @@ export class GenieClient {
636
655
  let resp;
637
656
  const call = async (callSignal) => {
638
657
  const headers = new Headers();
639
- if (this.workspaceId !== undefined) {
640
- headers.set('X-Databricks-Org-Id', this.workspaceId);
658
+ if (workspaceId !== undefined) {
659
+ headers.set('X-Databricks-Org-Id', workspaceId);
641
660
  }
642
661
  headers.set('User-Agent', this.userAgent);
643
662
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
644
663
  const respBody = await executeHttpCall({
645
664
  request: httpReq,
646
- httpClient: this.httpClient,
665
+ httpClient,
647
666
  logger: this.logger,
648
667
  });
649
668
  resp = parseResponse(respBody, unmarshalGenieListEvalResultsResponseSchema);
@@ -656,7 +675,8 @@ export class GenieClient {
656
675
  }
657
676
  /** Lists all evaluation runs in a space. */
658
677
  async genieListEvalRuns(req, options) {
659
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
678
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
679
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`;
660
680
  const params = new URLSearchParams();
661
681
  if (req.pageSize !== undefined) {
662
682
  params.append('page_size', String(req.pageSize));
@@ -669,14 +689,14 @@ export class GenieClient {
669
689
  let resp;
670
690
  const call = async (callSignal) => {
671
691
  const headers = new Headers();
672
- if (this.workspaceId !== undefined) {
673
- headers.set('X-Databricks-Org-Id', this.workspaceId);
692
+ if (workspaceId !== undefined) {
693
+ headers.set('X-Databricks-Org-Id', workspaceId);
674
694
  }
675
695
  headers.set('User-Agent', this.userAgent);
676
696
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
677
697
  const respBody = await executeHttpCall({
678
698
  request: httpReq,
679
- httpClient: this.httpClient,
699
+ httpClient,
680
700
  logger: this.logger,
681
701
  });
682
702
  resp = parseResponse(respBody, unmarshalGenieListEvalRunsResponseSchema);
@@ -689,7 +709,8 @@ export class GenieClient {
689
709
  }
690
710
  /** List comments on a specific conversation message. */
691
711
  async genieListMessageComments(req, options) {
692
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
712
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
713
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`;
693
714
  const params = new URLSearchParams();
694
715
  if (req.pageSize !== undefined) {
695
716
  params.append('page_size', String(req.pageSize));
@@ -702,14 +723,14 @@ export class GenieClient {
702
723
  let resp;
703
724
  const call = async (callSignal) => {
704
725
  const headers = new Headers();
705
- if (this.workspaceId !== undefined) {
706
- headers.set('X-Databricks-Org-Id', this.workspaceId);
726
+ if (workspaceId !== undefined) {
727
+ headers.set('X-Databricks-Org-Id', workspaceId);
707
728
  }
708
729
  headers.set('User-Agent', this.userAgent);
709
730
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
710
731
  const respBody = await executeHttpCall({
711
732
  request: httpReq,
712
- httpClient: this.httpClient,
733
+ httpClient,
713
734
  logger: this.logger,
714
735
  });
715
736
  resp = parseResponse(respBody, unmarshalGenieListMessageCommentsResponseSchema);
@@ -722,7 +743,8 @@ export class GenieClient {
722
743
  }
723
744
  /** Get list of Genie Spaces. */
724
745
  async genieListSpaces(req, options) {
725
- const url = `${this.host}/api/2.0/genie/spaces`;
746
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
747
+ const url = `${host}/api/2.0/genie/spaces`;
726
748
  const params = new URLSearchParams();
727
749
  if (req.pageSize !== undefined) {
728
750
  params.append('page_size', String(req.pageSize));
@@ -735,14 +757,14 @@ export class GenieClient {
735
757
  let resp;
736
758
  const call = async (callSignal) => {
737
759
  const headers = new Headers();
738
- if (this.workspaceId !== undefined) {
739
- headers.set('X-Databricks-Org-Id', this.workspaceId);
760
+ if (workspaceId !== undefined) {
761
+ headers.set('X-Databricks-Org-Id', workspaceId);
740
762
  }
741
763
  headers.set('User-Agent', this.userAgent);
742
764
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
743
765
  const respBody = await executeHttpCall({
744
766
  request: httpReq,
745
- httpClient: this.httpClient,
767
+ httpClient,
746
768
  logger: this.logger,
747
769
  });
748
770
  resp = parseResponse(respBody, unmarshalGenieListSpacesResponseSchema);
@@ -755,18 +777,19 @@ export class GenieClient {
755
777
  }
756
778
  /** Send feedback for a message. */
757
779
  async genieSendMessageFeedback(req, options) {
758
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`;
780
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
781
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`;
759
782
  const body = marshalRequest(req, marshalGenieSendMessageFeedbackRequestSchema);
760
783
  const call = async (callSignal) => {
761
784
  const headers = new Headers({ 'Content-Type': 'application/json' });
762
- if (this.workspaceId !== undefined) {
763
- headers.set('X-Databricks-Org-Id', this.workspaceId);
785
+ if (workspaceId !== undefined) {
786
+ headers.set('X-Databricks-Org-Id', workspaceId);
764
787
  }
765
788
  headers.set('User-Agent', this.userAgent);
766
789
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
767
790
  await executeHttpCall({
768
791
  request: httpReq,
769
- httpClient: this.httpClient,
792
+ httpClient,
770
793
  logger: this.logger,
771
794
  });
772
795
  };
@@ -774,19 +797,20 @@ export class GenieClient {
774
797
  }
775
798
  /** Start a new conversation. */
776
799
  async genieStartConversation(req, options) {
777
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`;
800
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
801
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`;
778
802
  const body = marshalRequest(req, marshalGenieStartConversationMessageRequestSchema);
779
803
  let resp;
780
804
  const call = async (callSignal) => {
781
805
  const headers = new Headers({ 'Content-Type': 'application/json' });
782
- if (this.workspaceId !== undefined) {
783
- headers.set('X-Databricks-Org-Id', this.workspaceId);
806
+ if (workspaceId !== undefined) {
807
+ headers.set('X-Databricks-Org-Id', workspaceId);
784
808
  }
785
809
  headers.set('User-Agent', this.userAgent);
786
810
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
787
811
  const respBody = await executeHttpCall({
788
812
  request: httpReq,
789
- httpClient: this.httpClient,
813
+ httpClient,
790
814
  logger: this.logger,
791
815
  });
792
816
  resp = parseResponse(respBody, unmarshalGenieStartConversationResponseSchema);
@@ -812,17 +836,18 @@ export class GenieClient {
812
836
  }
813
837
  /** Move a Genie Space to the trash. */
814
838
  async genieTrashSpace(req, options) {
815
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
839
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
840
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
816
841
  const call = async (callSignal) => {
817
842
  const headers = new Headers();
818
- if (this.workspaceId !== undefined) {
819
- headers.set('X-Databricks-Org-Id', this.workspaceId);
843
+ if (workspaceId !== undefined) {
844
+ headers.set('X-Databricks-Org-Id', workspaceId);
820
845
  }
821
846
  headers.set('User-Agent', this.userAgent);
822
847
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
823
848
  await executeHttpCall({
824
849
  request: httpReq,
825
- httpClient: this.httpClient,
850
+ httpClient,
826
851
  logger: this.logger,
827
852
  });
828
853
  };
@@ -830,19 +855,20 @@ export class GenieClient {
830
855
  }
831
856
  /** Updates a Genie space with a serialized payload. */
832
857
  async updateSpace(req, options) {
833
- const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
858
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
859
+ const url = `${host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`;
834
860
  const body = marshalRequest(req, marshalGenieUpdateSpaceRequestSchema);
835
861
  let resp;
836
862
  const call = async (callSignal) => {
837
863
  const headers = new Headers({ 'Content-Type': 'application/json' });
838
- if (this.workspaceId !== undefined) {
839
- headers.set('X-Databricks-Org-Id', this.workspaceId);
864
+ if (workspaceId !== undefined) {
865
+ headers.set('X-Databricks-Org-Id', workspaceId);
840
866
  }
841
867
  headers.set('User-Agent', this.userAgent);
842
868
  const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
843
869
  const respBody = await executeHttpCall({
844
870
  request: httpReq,
845
- httpClient: this.httpClient,
871
+ httpClient,
846
872
  logger: this.logger,
847
873
  });
848
874
  resp = parseResponse(respBody, unmarshalGenieSpaceSchema);