@databricks/sdk-knowledgeassistants 0.0.0-dev → 0.1.0-dev.2

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.
@@ -0,0 +1,652 @@
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 {HttpClient} from '@databricks/sdk-core/http';
10
+ import {newHttpClient} from './transport';
11
+ import {
12
+ buildHttpRequest,
13
+ executeCall,
14
+ executeHttpCall,
15
+ marshalRequest,
16
+ parseResponse,
17
+ } from './utils';
18
+ import pkgJson from '../../package.json' with {type: 'json'};
19
+ import type {
20
+ CreateExampleRequest,
21
+ CreateKnowledgeAssistantRequest,
22
+ CreateKnowledgeSourceRequest,
23
+ DeleteExampleRequest,
24
+ DeleteKnowledgeAssistantRequest,
25
+ DeleteKnowledgeSourceRequest,
26
+ Example,
27
+ GetExampleRequest,
28
+ GetKnowledgeAssistantRequest,
29
+ GetKnowledgeSourceRequest,
30
+ KnowledgeAssistant,
31
+ KnowledgeSource,
32
+ ListExamplesRequest,
33
+ ListExamplesResponse,
34
+ ListKnowledgeAssistantsRequest,
35
+ ListKnowledgeAssistantsResponse,
36
+ ListKnowledgeSourcesRequest,
37
+ ListKnowledgeSourcesResponse,
38
+ SyncKnowledgeSourcesRequest,
39
+ UpdateExampleRequest,
40
+ UpdateKnowledgeAssistantRequest,
41
+ UpdateKnowledgeSourceRequest,
42
+ } from './model';
43
+ import {
44
+ marshalExampleSchema,
45
+ marshalKnowledgeAssistantSchema,
46
+ marshalKnowledgeSourceSchema,
47
+ marshalSyncKnowledgeSourcesRequestSchema,
48
+ unmarshalExampleSchema,
49
+ unmarshalKnowledgeAssistantSchema,
50
+ unmarshalKnowledgeSourceSchema,
51
+ unmarshalListExamplesResponseSchema,
52
+ unmarshalListKnowledgeAssistantsResponseSchema,
53
+ unmarshalListKnowledgeSourcesResponseSchema,
54
+ } from './model';
55
+
56
+ // Package identity segment for this client to be used in the User-Agent header.
57
+ const PACKAGE_SEGMENT = {
58
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
59
+ value: pkgJson.version,
60
+ };
61
+
62
+ export class KnowledgeAssistantsClient {
63
+ private readonly host: string;
64
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
65
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
66
+ // request.
67
+ private readonly workspaceId: string | undefined;
68
+ private readonly httpClient: HttpClient;
69
+ private readonly logger: Logger;
70
+ // User-Agent header value. Composed once at construction from
71
+ // createDefault() merged with this package's identity and the active
72
+ // credential's name.
73
+ private readonly userAgent: string;
74
+
75
+ constructor(options: ClientOptions) {
76
+ if (options.host === undefined) {
77
+ throw new Error('Host is required.');
78
+ }
79
+ this.host = options.host.replace(/\/$/, '');
80
+ this.workspaceId = options.workspaceId;
81
+ this.logger = options.logger ?? new NoOpLogger();
82
+ const info = createDefault()
83
+ .with(PACKAGE_SEGMENT)
84
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
85
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
86
+ this.userAgent = info.toString();
87
+ this.httpClient = newHttpClient(options);
88
+ }
89
+
90
+ /** Creates an example for a Knowledge Assistant. */
91
+ async createExample(
92
+ req: CreateExampleRequest,
93
+ options?: CallOptions
94
+ ): Promise<Example> {
95
+ const url = `${this.host}/api/2.1/${req.parent ?? ''}/examples`;
96
+ const body = marshalRequest(req.example, marshalExampleSchema);
97
+ let resp: Example | undefined;
98
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
99
+ const headers = new Headers({'Content-Type': 'application/json'});
100
+ if (this.workspaceId !== undefined) {
101
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
102
+ }
103
+ headers.set('User-Agent', this.userAgent);
104
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
105
+ const respBody = await executeHttpCall({
106
+ request: httpReq,
107
+ httpClient: this.httpClient,
108
+ logger: this.logger,
109
+ });
110
+ resp = parseResponse(respBody, unmarshalExampleSchema);
111
+ };
112
+ await executeCall(call, options);
113
+ if (resp === undefined) {
114
+ throw new Error('operation completed without a result.');
115
+ }
116
+ return resp;
117
+ }
118
+
119
+ /** Creates a Knowledge Assistant. */
120
+ async createKnowledgeAssistant(
121
+ req: CreateKnowledgeAssistantRequest,
122
+ options?: CallOptions
123
+ ): Promise<KnowledgeAssistant> {
124
+ const url = `${this.host}/api/2.1/knowledge-assistants`;
125
+ const body = marshalRequest(
126
+ req.knowledgeAssistant,
127
+ marshalKnowledgeAssistantSchema
128
+ );
129
+ let resp: KnowledgeAssistant | undefined;
130
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
131
+ const headers = new Headers({'Content-Type': 'application/json'});
132
+ if (this.workspaceId !== undefined) {
133
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
134
+ }
135
+ headers.set('User-Agent', this.userAgent);
136
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
137
+ const respBody = await executeHttpCall({
138
+ request: httpReq,
139
+ httpClient: this.httpClient,
140
+ logger: this.logger,
141
+ });
142
+ resp = parseResponse(respBody, unmarshalKnowledgeAssistantSchema);
143
+ };
144
+ await executeCall(call, options);
145
+ if (resp === undefined) {
146
+ throw new Error('operation completed without a result.');
147
+ }
148
+ return resp;
149
+ }
150
+
151
+ /** Creates a Knowledge Source under a Knowledge Assistant. */
152
+ async createKnowledgeSource(
153
+ req: CreateKnowledgeSourceRequest,
154
+ options?: CallOptions
155
+ ): Promise<KnowledgeSource> {
156
+ const url = `${this.host}/api/2.1/${req.parent ?? ''}/knowledge-sources`;
157
+ const body = marshalRequest(
158
+ req.knowledgeSource,
159
+ marshalKnowledgeSourceSchema
160
+ );
161
+ let resp: KnowledgeSource | undefined;
162
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
163
+ const headers = new Headers({'Content-Type': 'application/json'});
164
+ if (this.workspaceId !== undefined) {
165
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
166
+ }
167
+ headers.set('User-Agent', this.userAgent);
168
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
169
+ const respBody = await executeHttpCall({
170
+ request: httpReq,
171
+ httpClient: this.httpClient,
172
+ logger: this.logger,
173
+ });
174
+ resp = parseResponse(respBody, unmarshalKnowledgeSourceSchema);
175
+ };
176
+ await executeCall(call, options);
177
+ if (resp === undefined) {
178
+ throw new Error('operation completed without a result.');
179
+ }
180
+ return resp;
181
+ }
182
+
183
+ /** Deletes an example from a Knowledge Assistant. */
184
+ async deleteExample(
185
+ req: DeleteExampleRequest,
186
+ options?: CallOptions
187
+ ): Promise<void> {
188
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
189
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
190
+ const headers = new Headers();
191
+ if (this.workspaceId !== undefined) {
192
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
193
+ }
194
+ headers.set('User-Agent', this.userAgent);
195
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
196
+ await executeHttpCall({
197
+ request: httpReq,
198
+ httpClient: this.httpClient,
199
+ logger: this.logger,
200
+ });
201
+ };
202
+ await executeCall(call, options);
203
+ }
204
+
205
+ /** Deletes a Knowledge Assistant. */
206
+ async deleteKnowledgeAssistant(
207
+ req: DeleteKnowledgeAssistantRequest,
208
+ options?: CallOptions
209
+ ): Promise<void> {
210
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
211
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
212
+ const headers = new Headers();
213
+ if (this.workspaceId !== undefined) {
214
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
215
+ }
216
+ headers.set('User-Agent', this.userAgent);
217
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
218
+ await executeHttpCall({
219
+ request: httpReq,
220
+ httpClient: this.httpClient,
221
+ logger: this.logger,
222
+ });
223
+ };
224
+ await executeCall(call, options);
225
+ }
226
+
227
+ /** Deletes a Knowledge Source. */
228
+ async deleteKnowledgeSource(
229
+ req: DeleteKnowledgeSourceRequest,
230
+ options?: CallOptions
231
+ ): Promise<void> {
232
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
233
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
234
+ const headers = new Headers();
235
+ if (this.workspaceId !== undefined) {
236
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
237
+ }
238
+ headers.set('User-Agent', this.userAgent);
239
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
240
+ await executeHttpCall({
241
+ request: httpReq,
242
+ httpClient: this.httpClient,
243
+ logger: this.logger,
244
+ });
245
+ };
246
+ await executeCall(call, options);
247
+ }
248
+
249
+ /** Gets an example from a Knowledge Assistant. */
250
+ async getExample(
251
+ req: GetExampleRequest,
252
+ options?: CallOptions
253
+ ): Promise<Example> {
254
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
255
+ let resp: Example | undefined;
256
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
257
+ const headers = new Headers();
258
+ if (this.workspaceId !== undefined) {
259
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
260
+ }
261
+ headers.set('User-Agent', this.userAgent);
262
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
263
+ const respBody = await executeHttpCall({
264
+ request: httpReq,
265
+ httpClient: this.httpClient,
266
+ logger: this.logger,
267
+ });
268
+ resp = parseResponse(respBody, unmarshalExampleSchema);
269
+ };
270
+ await executeCall(call, options);
271
+ if (resp === undefined) {
272
+ throw new Error('operation completed without a result.');
273
+ }
274
+ return resp;
275
+ }
276
+
277
+ /** Gets a Knowledge Assistant. */
278
+ async getKnowledgeAssistant(
279
+ req: GetKnowledgeAssistantRequest,
280
+ options?: CallOptions
281
+ ): Promise<KnowledgeAssistant> {
282
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
283
+ let resp: KnowledgeAssistant | undefined;
284
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
285
+ const headers = new Headers();
286
+ if (this.workspaceId !== undefined) {
287
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
288
+ }
289
+ headers.set('User-Agent', this.userAgent);
290
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
291
+ const respBody = await executeHttpCall({
292
+ request: httpReq,
293
+ httpClient: this.httpClient,
294
+ logger: this.logger,
295
+ });
296
+ resp = parseResponse(respBody, unmarshalKnowledgeAssistantSchema);
297
+ };
298
+ await executeCall(call, options);
299
+ if (resp === undefined) {
300
+ throw new Error('operation completed without a result.');
301
+ }
302
+ return resp;
303
+ }
304
+
305
+ /** Gets a Knowledge Source. */
306
+ async getKnowledgeSource(
307
+ req: GetKnowledgeSourceRequest,
308
+ options?: CallOptions
309
+ ): Promise<KnowledgeSource> {
310
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
311
+ let resp: KnowledgeSource | undefined;
312
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
313
+ const headers = new Headers();
314
+ if (this.workspaceId !== undefined) {
315
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
316
+ }
317
+ headers.set('User-Agent', this.userAgent);
318
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
319
+ const respBody = await executeHttpCall({
320
+ request: httpReq,
321
+ httpClient: this.httpClient,
322
+ logger: this.logger,
323
+ });
324
+ resp = parseResponse(respBody, unmarshalKnowledgeSourceSchema);
325
+ };
326
+ await executeCall(call, options);
327
+ if (resp === undefined) {
328
+ throw new Error('operation completed without a result.');
329
+ }
330
+ return resp;
331
+ }
332
+
333
+ /** Lists examples under a Knowledge Assistant. */
334
+ async listExamples(
335
+ req: ListExamplesRequest,
336
+ options?: CallOptions
337
+ ): Promise<ListExamplesResponse> {
338
+ const url = `${this.host}/api/2.1/${req.parent ?? ''}/examples`;
339
+ const params = new URLSearchParams();
340
+ if (req.pageSize !== undefined) {
341
+ params.append('page_size', String(req.pageSize));
342
+ }
343
+ if (req.pageToken !== undefined) {
344
+ params.append('page_token', req.pageToken);
345
+ }
346
+ const query = params.toString();
347
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
348
+ let resp: ListExamplesResponse | undefined;
349
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
350
+ const headers = new Headers();
351
+ if (this.workspaceId !== undefined) {
352
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
353
+ }
354
+ headers.set('User-Agent', this.userAgent);
355
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
356
+ const respBody = await executeHttpCall({
357
+ request: httpReq,
358
+ httpClient: this.httpClient,
359
+ logger: this.logger,
360
+ });
361
+ resp = parseResponse(respBody, unmarshalListExamplesResponseSchema);
362
+ };
363
+ await executeCall(call, options);
364
+ if (resp === undefined) {
365
+ throw new Error('operation completed without a result.');
366
+ }
367
+ return resp;
368
+ }
369
+
370
+ async *listExamplesIter(
371
+ req: ListExamplesRequest,
372
+ options?: CallOptions
373
+ ): AsyncGenerator<Example> {
374
+ const pageReq: ListExamplesRequest = {...req};
375
+ for (;;) {
376
+ const resp = await this.listExamples(pageReq, options);
377
+ for (const item of resp.examples ?? []) {
378
+ yield item;
379
+ }
380
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
381
+ return;
382
+ }
383
+ pageReq.pageToken = resp.nextPageToken;
384
+ }
385
+ }
386
+
387
+ /** List Knowledge Assistants */
388
+ async listKnowledgeAssistants(
389
+ req: ListKnowledgeAssistantsRequest,
390
+ options?: CallOptions
391
+ ): Promise<ListKnowledgeAssistantsResponse> {
392
+ const url = `${this.host}/api/2.1/knowledge-assistants`;
393
+ const params = new URLSearchParams();
394
+ if (req.pageSize !== undefined) {
395
+ params.append('page_size', String(req.pageSize));
396
+ }
397
+ if (req.pageToken !== undefined) {
398
+ params.append('page_token', req.pageToken);
399
+ }
400
+ const query = params.toString();
401
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
402
+ let resp: ListKnowledgeAssistantsResponse | undefined;
403
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
404
+ const headers = new Headers();
405
+ if (this.workspaceId !== undefined) {
406
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
407
+ }
408
+ headers.set('User-Agent', this.userAgent);
409
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
410
+ const respBody = await executeHttpCall({
411
+ request: httpReq,
412
+ httpClient: this.httpClient,
413
+ logger: this.logger,
414
+ });
415
+ resp = parseResponse(
416
+ respBody,
417
+ unmarshalListKnowledgeAssistantsResponseSchema
418
+ );
419
+ };
420
+ await executeCall(call, options);
421
+ if (resp === undefined) {
422
+ throw new Error('operation completed without a result.');
423
+ }
424
+ return resp;
425
+ }
426
+
427
+ async *listKnowledgeAssistantsIter(
428
+ req: ListKnowledgeAssistantsRequest,
429
+ options?: CallOptions
430
+ ): AsyncGenerator<KnowledgeAssistant> {
431
+ const pageReq: ListKnowledgeAssistantsRequest = {...req};
432
+ for (;;) {
433
+ const resp = await this.listKnowledgeAssistants(pageReq, options);
434
+ for (const item of resp.knowledgeAssistants ?? []) {
435
+ yield item;
436
+ }
437
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
438
+ return;
439
+ }
440
+ pageReq.pageToken = resp.nextPageToken;
441
+ }
442
+ }
443
+
444
+ /** Lists Knowledge Sources under a Knowledge Assistant. */
445
+ async listKnowledgeSources(
446
+ req: ListKnowledgeSourcesRequest,
447
+ options?: CallOptions
448
+ ): Promise<ListKnowledgeSourcesResponse> {
449
+ const url = `${this.host}/api/2.1/${req.parent ?? ''}/knowledge-sources`;
450
+ const params = new URLSearchParams();
451
+ if (req.pageSize !== undefined) {
452
+ params.append('page_size', String(req.pageSize));
453
+ }
454
+ if (req.pageToken !== undefined) {
455
+ params.append('page_token', req.pageToken);
456
+ }
457
+ const query = params.toString();
458
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
459
+ let resp: ListKnowledgeSourcesResponse | undefined;
460
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
461
+ const headers = new Headers();
462
+ if (this.workspaceId !== undefined) {
463
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
464
+ }
465
+ headers.set('User-Agent', this.userAgent);
466
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
467
+ const respBody = await executeHttpCall({
468
+ request: httpReq,
469
+ httpClient: this.httpClient,
470
+ logger: this.logger,
471
+ });
472
+ resp = parseResponse(
473
+ respBody,
474
+ unmarshalListKnowledgeSourcesResponseSchema
475
+ );
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
+ async *listKnowledgeSourcesIter(
485
+ req: ListKnowledgeSourcesRequest,
486
+ options?: CallOptions
487
+ ): AsyncGenerator<KnowledgeSource> {
488
+ const pageReq: ListKnowledgeSourcesRequest = {...req};
489
+ for (;;) {
490
+ const resp = await this.listKnowledgeSources(pageReq, options);
491
+ for (const item of resp.knowledgeSources ?? []) {
492
+ yield item;
493
+ }
494
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
495
+ return;
496
+ }
497
+ pageReq.pageToken = resp.nextPageToken;
498
+ }
499
+ }
500
+
501
+ /** Sync all non-index Knowledge Sources for a Knowledge Assistant (index sources do not require sync) */
502
+ async syncKnowledgeSources(
503
+ req: SyncKnowledgeSourcesRequest,
504
+ options?: CallOptions
505
+ ): Promise<void> {
506
+ const url = `${this.host}/api/2.1/${req.name ?? ''}/knowledge-sources:sync`;
507
+ const body = marshalRequest(req, marshalSyncKnowledgeSourcesRequestSchema);
508
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
509
+ const headers = new Headers({'Content-Type': 'application/json'});
510
+ if (this.workspaceId !== undefined) {
511
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
512
+ }
513
+ headers.set('User-Agent', this.userAgent);
514
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
515
+ await executeHttpCall({
516
+ request: httpReq,
517
+ httpClient: this.httpClient,
518
+ logger: this.logger,
519
+ });
520
+ };
521
+ await executeCall(call, options);
522
+ }
523
+
524
+ /** Updates an example in a Knowledge Assistant. */
525
+ async updateExample(
526
+ req: UpdateExampleRequest,
527
+ options?: CallOptions
528
+ ): Promise<Example> {
529
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
530
+ const params = new URLSearchParams();
531
+ if (req.updateMask !== undefined) {
532
+ params.append('update_mask', req.updateMask.toString());
533
+ }
534
+ const query = params.toString();
535
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
536
+ const body = marshalRequest(req.example, marshalExampleSchema);
537
+ let resp: Example | undefined;
538
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
539
+ const headers = new Headers({'Content-Type': 'application/json'});
540
+ if (this.workspaceId !== undefined) {
541
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
542
+ }
543
+ headers.set('User-Agent', this.userAgent);
544
+ const httpReq = buildHttpRequest(
545
+ 'PATCH',
546
+ fullUrl,
547
+ headers,
548
+ callSignal,
549
+ body
550
+ );
551
+ const respBody = await executeHttpCall({
552
+ request: httpReq,
553
+ httpClient: this.httpClient,
554
+ logger: this.logger,
555
+ });
556
+ resp = parseResponse(respBody, unmarshalExampleSchema);
557
+ };
558
+ await executeCall(call, options);
559
+ if (resp === undefined) {
560
+ throw new Error('operation completed without a result.');
561
+ }
562
+ return resp;
563
+ }
564
+
565
+ /** Updates a Knowledge Assistant. */
566
+ async updateKnowledgeAssistant(
567
+ req: UpdateKnowledgeAssistantRequest,
568
+ options?: CallOptions
569
+ ): Promise<KnowledgeAssistant> {
570
+ const url = `${this.host}/api/2.1/${req.knowledgeAssistant?.name ?? ''}`;
571
+ const params = new URLSearchParams();
572
+ if (req.updateMask !== undefined) {
573
+ params.append('update_mask', req.updateMask.toString());
574
+ }
575
+ const query = params.toString();
576
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
577
+ const body = marshalRequest(
578
+ req.knowledgeAssistant,
579
+ marshalKnowledgeAssistantSchema
580
+ );
581
+ let resp: KnowledgeAssistant | undefined;
582
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
583
+ const headers = new Headers({'Content-Type': 'application/json'});
584
+ if (this.workspaceId !== undefined) {
585
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
586
+ }
587
+ headers.set('User-Agent', this.userAgent);
588
+ const httpReq = buildHttpRequest(
589
+ 'PATCH',
590
+ fullUrl,
591
+ headers,
592
+ callSignal,
593
+ body
594
+ );
595
+ const respBody = await executeHttpCall({
596
+ request: httpReq,
597
+ httpClient: this.httpClient,
598
+ logger: this.logger,
599
+ });
600
+ resp = parseResponse(respBody, unmarshalKnowledgeAssistantSchema);
601
+ };
602
+ await executeCall(call, options);
603
+ if (resp === undefined) {
604
+ throw new Error('operation completed without a result.');
605
+ }
606
+ return resp;
607
+ }
608
+
609
+ /** Updates a Knowledge Source. */
610
+ async updateKnowledgeSource(
611
+ req: UpdateKnowledgeSourceRequest,
612
+ options?: CallOptions
613
+ ): Promise<KnowledgeSource> {
614
+ const url = `${this.host}/api/2.1/${req.name ?? ''}`;
615
+ const params = new URLSearchParams();
616
+ if (req.updateMask !== undefined) {
617
+ params.append('update_mask', req.updateMask.toString());
618
+ }
619
+ const query = params.toString();
620
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
621
+ const body = marshalRequest(
622
+ req.knowledgeSource,
623
+ marshalKnowledgeSourceSchema
624
+ );
625
+ let resp: KnowledgeSource | undefined;
626
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
627
+ const headers = new Headers({'Content-Type': 'application/json'});
628
+ if (this.workspaceId !== undefined) {
629
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
630
+ }
631
+ headers.set('User-Agent', this.userAgent);
632
+ const httpReq = buildHttpRequest(
633
+ 'PATCH',
634
+ fullUrl,
635
+ headers,
636
+ callSignal,
637
+ body
638
+ );
639
+ const respBody = await executeHttpCall({
640
+ request: httpReq,
641
+ httpClient: this.httpClient,
642
+ logger: this.logger,
643
+ });
644
+ resp = parseResponse(respBody, unmarshalKnowledgeSourceSchema);
645
+ };
646
+ await executeCall(call, options);
647
+ if (resp === undefined) {
648
+ throw new Error('operation completed without a result.');
649
+ }
650
+ return resp;
651
+ }
652
+ }
@@ -0,0 +1,39 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {KnowledgeAssistantsClient} from './client';
4
+
5
+ export {KnowledgeAssistant_State, KnowledgeSource_State} from './model';
6
+
7
+ export type {
8
+ CreateExampleRequest,
9
+ CreateKnowledgeAssistantRequest,
10
+ CreateKnowledgeSourceRequest,
11
+ DeleteExampleRequest,
12
+ DeleteKnowledgeAssistantRequest,
13
+ DeleteKnowledgeSourceRequest,
14
+ Example,
15
+ FileTableSpec,
16
+ FilesSpec,
17
+ GetExampleRequest,
18
+ GetKnowledgeAssistantRequest,
19
+ GetKnowledgeSourceRequest,
20
+ IndexSpec,
21
+ KnowledgeAssistant,
22
+ KnowledgeSource,
23
+ ListExamplesRequest,
24
+ ListExamplesResponse,
25
+ ListKnowledgeAssistantsRequest,
26
+ ListKnowledgeAssistantsResponse,
27
+ ListKnowledgeSourcesRequest,
28
+ ListKnowledgeSourcesResponse,
29
+ SyncKnowledgeSourcesRequest,
30
+ UpdateExampleRequest,
31
+ UpdateKnowledgeAssistantRequest,
32
+ UpdateKnowledgeSourceRequest,
33
+ } from './model';
34
+
35
+ export {
36
+ exampleFieldMask,
37
+ knowledgeAssistantFieldMask,
38
+ knowledgeSourceFieldMask,
39
+ } from './model';