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

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