@databricks/sdk-features 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,874 @@
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
+ BatchCreateMaterializedFeaturesRequest,
22
+ BatchCreateMaterializedFeaturesResponse,
23
+ CreateFeatureRequest,
24
+ CreateKafkaConfigRequest,
25
+ CreateMaterializedFeatureRequest,
26
+ CreateStreamRequest,
27
+ DeleteFeatureRequest,
28
+ DeleteKafkaConfigRequest,
29
+ DeleteMaterializedFeatureRequest,
30
+ DeleteStreamRequest,
31
+ Feature,
32
+ GetFeatureRequest,
33
+ GetKafkaConfigRequest,
34
+ GetMaterializedFeatureRequest,
35
+ GetStreamRequest,
36
+ KafkaConfig,
37
+ ListFeaturesRequest,
38
+ ListFeaturesResponse,
39
+ ListKafkaConfigsRequest,
40
+ ListKafkaConfigsResponse,
41
+ ListMaterializedFeaturesRequest,
42
+ ListMaterializedFeaturesResponse,
43
+ ListStreamsRequest,
44
+ ListStreamsResponse,
45
+ MaterializedFeature,
46
+ Stream,
47
+ UpdateFeatureRequest,
48
+ UpdateKafkaConfigRequest,
49
+ UpdateMaterializedFeatureRequest,
50
+ UpdateStreamRequest,
51
+ } from './model';
52
+ import {
53
+ marshalBatchCreateMaterializedFeaturesRequestSchema,
54
+ marshalFeatureSchema,
55
+ marshalKafkaConfigSchema,
56
+ marshalMaterializedFeatureSchema,
57
+ marshalStreamSchema,
58
+ unmarshalBatchCreateMaterializedFeaturesResponseSchema,
59
+ unmarshalFeatureSchema,
60
+ unmarshalKafkaConfigSchema,
61
+ unmarshalListFeaturesResponseSchema,
62
+ unmarshalListKafkaConfigsResponseSchema,
63
+ unmarshalListMaterializedFeaturesResponseSchema,
64
+ unmarshalListStreamsResponseSchema,
65
+ unmarshalMaterializedFeatureSchema,
66
+ unmarshalStreamSchema,
67
+ } from './model';
68
+
69
+ // Package identity segment for this client to be used in the User-Agent header.
70
+ const PACKAGE_SEGMENT = {
71
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
72
+ value: pkgJson.version,
73
+ };
74
+
75
+ export class FeaturesClient {
76
+ private readonly host: string;
77
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
78
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
79
+ // request.
80
+ private readonly workspaceId: string | undefined;
81
+ private readonly httpClient: HttpClient;
82
+ private readonly logger: Logger;
83
+ // User-Agent header value. Composed once at construction from
84
+ // createDefault() merged with this package's identity and the active
85
+ // credential's name.
86
+ private readonly userAgent: string;
87
+
88
+ constructor(options: ClientOptions) {
89
+ if (options.host === undefined) {
90
+ throw new Error('Host is required.');
91
+ }
92
+ this.host = options.host.replace(/\/$/, '');
93
+ this.workspaceId = options.workspaceId;
94
+ this.logger = options.logger ?? new NoOpLogger();
95
+ const info = createDefault()
96
+ .with(PACKAGE_SEGMENT)
97
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
98
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
99
+ this.userAgent = info.toString();
100
+ this.httpClient = newHttpClient(options);
101
+ }
102
+
103
+ /** Batch create materialized features. */
104
+ async batchCreateMaterializedFeatures(
105
+ req: BatchCreateMaterializedFeaturesRequest,
106
+ options?: CallOptions
107
+ ): Promise<BatchCreateMaterializedFeaturesResponse> {
108
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features:batchCreate`;
109
+ const body = marshalRequest(
110
+ req,
111
+ marshalBatchCreateMaterializedFeaturesRequestSchema
112
+ );
113
+ let resp: BatchCreateMaterializedFeaturesResponse | undefined;
114
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
115
+ const headers = new Headers({'Content-Type': 'application/json'});
116
+ if (this.workspaceId !== undefined) {
117
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
118
+ }
119
+ headers.set('User-Agent', this.userAgent);
120
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
121
+ const respBody = await executeHttpCall({
122
+ request: httpReq,
123
+ httpClient: this.httpClient,
124
+ logger: this.logger,
125
+ });
126
+ resp = parseResponse(
127
+ respBody,
128
+ unmarshalBatchCreateMaterializedFeaturesResponseSchema
129
+ );
130
+ };
131
+ await executeCall(call, options);
132
+ if (resp === undefined) {
133
+ throw new Error('API call completed without a result.');
134
+ }
135
+ return resp;
136
+ }
137
+
138
+ /** Create a Feature. */
139
+ async createFeature(
140
+ req: CreateFeatureRequest,
141
+ options?: CallOptions
142
+ ): Promise<Feature> {
143
+ const url = `${this.host}/api/2.0/feature-engineering/features`;
144
+ const body = marshalRequest(req.feature, marshalFeatureSchema);
145
+ let resp: Feature | undefined;
146
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
147
+ const headers = new Headers({'Content-Type': 'application/json'});
148
+ if (this.workspaceId !== undefined) {
149
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
150
+ }
151
+ headers.set('User-Agent', this.userAgent);
152
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
153
+ const respBody = await executeHttpCall({
154
+ request: httpReq,
155
+ httpClient: this.httpClient,
156
+ logger: this.logger,
157
+ });
158
+ resp = parseResponse(respBody, unmarshalFeatureSchema);
159
+ };
160
+ await executeCall(call, options);
161
+ if (resp === undefined) {
162
+ throw new Error('API call completed without a result.');
163
+ }
164
+ return resp;
165
+ }
166
+
167
+ /**
168
+ * Create a Kafka config.
169
+ * During PrPr, Kafka configs can be read and used when creating features under the entire metastore.
170
+ * Only the creator of the Kafka config can delete it.
171
+ */
172
+ async createKafkaConfig(
173
+ req: CreateKafkaConfigRequest,
174
+ options?: CallOptions
175
+ ): Promise<KafkaConfig> {
176
+ const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs`;
177
+ const body = marshalRequest(req.kafkaConfig, marshalKafkaConfigSchema);
178
+ let resp: KafkaConfig | undefined;
179
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
180
+ const headers = new Headers({'Content-Type': 'application/json'});
181
+ if (this.workspaceId !== undefined) {
182
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
183
+ }
184
+ headers.set('User-Agent', this.userAgent);
185
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
186
+ const respBody = await executeHttpCall({
187
+ request: httpReq,
188
+ httpClient: this.httpClient,
189
+ logger: this.logger,
190
+ });
191
+ resp = parseResponse(respBody, unmarshalKafkaConfigSchema);
192
+ };
193
+ await executeCall(call, options);
194
+ if (resp === undefined) {
195
+ throw new Error('API call completed without a result.');
196
+ }
197
+ return resp;
198
+ }
199
+
200
+ /** Create a materialized feature. */
201
+ async createMaterializedFeature(
202
+ req: CreateMaterializedFeatureRequest,
203
+ options?: CallOptions
204
+ ): Promise<MaterializedFeature> {
205
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features`;
206
+ const body = marshalRequest(
207
+ req.materializedFeature,
208
+ marshalMaterializedFeatureSchema
209
+ );
210
+ let resp: MaterializedFeature | undefined;
211
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
212
+ const headers = new Headers({'Content-Type': 'application/json'});
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('POST', url, headers, callSignal, body);
218
+ const respBody = await executeHttpCall({
219
+ request: httpReq,
220
+ httpClient: this.httpClient,
221
+ logger: this.logger,
222
+ });
223
+ resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema);
224
+ };
225
+ await executeCall(call, options);
226
+ if (resp === undefined) {
227
+ throw new Error('API call completed without a result.');
228
+ }
229
+ return resp;
230
+ }
231
+
232
+ /** Create a Stream, a governed UC entity representing an external streaming data source. */
233
+ async createStream(
234
+ req: CreateStreamRequest,
235
+ options?: CallOptions
236
+ ): Promise<Stream> {
237
+ const url = `${this.host}/api/2.0/feature-engineering/streams`;
238
+ const body = marshalRequest(req.stream, marshalStreamSchema);
239
+ let resp: Stream | undefined;
240
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
241
+ const headers = new Headers({'Content-Type': 'application/json'});
242
+ if (this.workspaceId !== undefined) {
243
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
244
+ }
245
+ headers.set('User-Agent', this.userAgent);
246
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
247
+ const respBody = await executeHttpCall({
248
+ request: httpReq,
249
+ httpClient: this.httpClient,
250
+ logger: this.logger,
251
+ });
252
+ resp = parseResponse(respBody, unmarshalStreamSchema);
253
+ };
254
+ await executeCall(call, options);
255
+ if (resp === undefined) {
256
+ throw new Error('API call completed without a result.');
257
+ }
258
+ return resp;
259
+ }
260
+
261
+ /** Delete a Feature. */
262
+ async deleteFeature(
263
+ req: DeleteFeatureRequest,
264
+ options?: CallOptions
265
+ ): Promise<void> {
266
+ const url = `${this.host}/api/2.0/feature-engineering/features/${req.fullName ?? ''}`;
267
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
268
+ const headers = new Headers();
269
+ if (this.workspaceId !== undefined) {
270
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
271
+ }
272
+ headers.set('User-Agent', this.userAgent);
273
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
274
+ await executeHttpCall({
275
+ request: httpReq,
276
+ httpClient: this.httpClient,
277
+ logger: this.logger,
278
+ });
279
+ };
280
+ await executeCall(call, options);
281
+ }
282
+
283
+ /**
284
+ * Delete a Kafka config.
285
+ * During PrPr, Kafka configs can be read and used when creating features under the entire metastore.
286
+ * Only the creator of the Kafka config can delete it.
287
+ */
288
+ async deleteKafkaConfig(
289
+ req: DeleteKafkaConfigRequest,
290
+ options?: CallOptions
291
+ ): Promise<void> {
292
+ const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.name ?? ''}`;
293
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
294
+ const headers = new Headers();
295
+ if (this.workspaceId !== undefined) {
296
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
297
+ }
298
+ headers.set('User-Agent', this.userAgent);
299
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
300
+ await executeHttpCall({
301
+ request: httpReq,
302
+ httpClient: this.httpClient,
303
+ logger: this.logger,
304
+ });
305
+ };
306
+ await executeCall(call, options);
307
+ }
308
+
309
+ /** Delete a materialized feature. */
310
+ async deleteMaterializedFeature(
311
+ req: DeleteMaterializedFeatureRequest,
312
+ options?: CallOptions
313
+ ): Promise<void> {
314
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeatureId ?? ''}`;
315
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
316
+ const headers = new Headers();
317
+ if (this.workspaceId !== undefined) {
318
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
319
+ }
320
+ headers.set('User-Agent', this.userAgent);
321
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
322
+ await executeHttpCall({
323
+ request: httpReq,
324
+ httpClient: this.httpClient,
325
+ logger: this.logger,
326
+ });
327
+ };
328
+ await executeCall(call, options);
329
+ }
330
+
331
+ /** Delete a Stream by its full three-part name (catalog.schema.stream). */
332
+ async deleteStream(
333
+ req: DeleteStreamRequest,
334
+ options?: CallOptions
335
+ ): Promise<void> {
336
+ const url = `${this.host}/api/2.0/feature-engineering/streams/${req.name ?? ''}`;
337
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
338
+ const headers = new Headers();
339
+ if (this.workspaceId !== undefined) {
340
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
341
+ }
342
+ headers.set('User-Agent', this.userAgent);
343
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
344
+ await executeHttpCall({
345
+ request: httpReq,
346
+ httpClient: this.httpClient,
347
+ logger: this.logger,
348
+ });
349
+ };
350
+ await executeCall(call, options);
351
+ }
352
+
353
+ /** Get a Feature. */
354
+ async getFeature(
355
+ req: GetFeatureRequest,
356
+ options?: CallOptions
357
+ ): Promise<Feature> {
358
+ const url = `${this.host}/api/2.0/feature-engineering/features/${req.fullName ?? ''}`;
359
+ let resp: Feature | undefined;
360
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
361
+ const headers = new Headers();
362
+ if (this.workspaceId !== undefined) {
363
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
364
+ }
365
+ headers.set('User-Agent', this.userAgent);
366
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
367
+ const respBody = await executeHttpCall({
368
+ request: httpReq,
369
+ httpClient: this.httpClient,
370
+ logger: this.logger,
371
+ });
372
+ resp = parseResponse(respBody, unmarshalFeatureSchema);
373
+ };
374
+ await executeCall(call, options);
375
+ if (resp === undefined) {
376
+ throw new Error('API call completed without a result.');
377
+ }
378
+ return resp;
379
+ }
380
+
381
+ /**
382
+ * Get a Kafka config.
383
+ * During PrPr, Kafka configs can be read and used when creating features under the entire metastore.
384
+ * Only the creator of the Kafka config can delete it.
385
+ */
386
+ async getKafkaConfig(
387
+ req: GetKafkaConfigRequest,
388
+ options?: CallOptions
389
+ ): Promise<KafkaConfig> {
390
+ const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.name ?? ''}`;
391
+ let resp: KafkaConfig | undefined;
392
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
393
+ const headers = new Headers();
394
+ if (this.workspaceId !== undefined) {
395
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
396
+ }
397
+ headers.set('User-Agent', this.userAgent);
398
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
399
+ const respBody = await executeHttpCall({
400
+ request: httpReq,
401
+ httpClient: this.httpClient,
402
+ logger: this.logger,
403
+ });
404
+ resp = parseResponse(respBody, unmarshalKafkaConfigSchema);
405
+ };
406
+ await executeCall(call, options);
407
+ if (resp === undefined) {
408
+ throw new Error('API call completed without a result.');
409
+ }
410
+ return resp;
411
+ }
412
+
413
+ /** Get a materialized feature. */
414
+ async getMaterializedFeature(
415
+ req: GetMaterializedFeatureRequest,
416
+ options?: CallOptions
417
+ ): Promise<MaterializedFeature> {
418
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeatureId ?? ''}`;
419
+ let resp: MaterializedFeature | undefined;
420
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
421
+ const headers = new Headers();
422
+ if (this.workspaceId !== undefined) {
423
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
424
+ }
425
+ headers.set('User-Agent', this.userAgent);
426
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
427
+ const respBody = await executeHttpCall({
428
+ request: httpReq,
429
+ httpClient: this.httpClient,
430
+ logger: this.logger,
431
+ });
432
+ resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema);
433
+ };
434
+ await executeCall(call, options);
435
+ if (resp === undefined) {
436
+ throw new Error('API call completed without a result.');
437
+ }
438
+ return resp;
439
+ }
440
+
441
+ /** Get a Stream by its full three-part name (catalog.schema.stream). */
442
+ async getStream(
443
+ req: GetStreamRequest,
444
+ options?: CallOptions
445
+ ): Promise<Stream> {
446
+ const url = `${this.host}/api/2.0/feature-engineering/streams/${req.name ?? ''}`;
447
+ let resp: Stream | undefined;
448
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
449
+ const headers = new Headers();
450
+ if (this.workspaceId !== undefined) {
451
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
452
+ }
453
+ headers.set('User-Agent', this.userAgent);
454
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
455
+ const respBody = await executeHttpCall({
456
+ request: httpReq,
457
+ httpClient: this.httpClient,
458
+ logger: this.logger,
459
+ });
460
+ resp = parseResponse(respBody, unmarshalStreamSchema);
461
+ };
462
+ await executeCall(call, options);
463
+ if (resp === undefined) {
464
+ throw new Error('API call completed without a result.');
465
+ }
466
+ return resp;
467
+ }
468
+
469
+ /** List Features. */
470
+ async listFeatures(
471
+ req: ListFeaturesRequest,
472
+ options?: CallOptions
473
+ ): Promise<ListFeaturesResponse> {
474
+ const url = `${this.host}/api/2.0/feature-engineering/features`;
475
+ const params = new URLSearchParams();
476
+ if (req.pageToken !== undefined) {
477
+ params.append('page_token', req.pageToken);
478
+ }
479
+ if (req.pageSize !== undefined) {
480
+ params.append('page_size', String(req.pageSize));
481
+ }
482
+ if (req.catalogName !== undefined) {
483
+ params.append('catalog_name', req.catalogName);
484
+ }
485
+ if (req.schemaName !== undefined) {
486
+ params.append('schema_name', req.schemaName);
487
+ }
488
+ const query = params.toString();
489
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
490
+ let resp: ListFeaturesResponse | undefined;
491
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
492
+ const headers = new Headers();
493
+ if (this.workspaceId !== undefined) {
494
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
495
+ }
496
+ headers.set('User-Agent', this.userAgent);
497
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
498
+ const respBody = await executeHttpCall({
499
+ request: httpReq,
500
+ httpClient: this.httpClient,
501
+ logger: this.logger,
502
+ });
503
+ resp = parseResponse(respBody, unmarshalListFeaturesResponseSchema);
504
+ };
505
+ await executeCall(call, options);
506
+ if (resp === undefined) {
507
+ throw new Error('API call completed without a result.');
508
+ }
509
+ return resp;
510
+ }
511
+
512
+ async *listFeaturesIter(
513
+ req: ListFeaturesRequest,
514
+ options?: CallOptions
515
+ ): AsyncGenerator<Feature> {
516
+ const pageReq: ListFeaturesRequest = {...req};
517
+ for (;;) {
518
+ const resp = await this.listFeatures(pageReq, options);
519
+ for (const item of resp.features ?? []) {
520
+ yield item;
521
+ }
522
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
523
+ return;
524
+ }
525
+ pageReq.pageToken = resp.nextPageToken;
526
+ }
527
+ }
528
+
529
+ /**
530
+ * List Kafka configs.
531
+ * During PrPr, Kafka configs can be read and used when creating features under the entire metastore.
532
+ * Only the creator of the Kafka config can delete it.
533
+ */
534
+ async listKafkaConfigs(
535
+ req: ListKafkaConfigsRequest,
536
+ options?: CallOptions
537
+ ): Promise<ListKafkaConfigsResponse> {
538
+ const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs`;
539
+ const params = new URLSearchParams();
540
+ if (req.pageToken !== undefined) {
541
+ params.append('page_token', req.pageToken);
542
+ }
543
+ if (req.pageSize !== undefined) {
544
+ params.append('page_size', String(req.pageSize));
545
+ }
546
+ const query = params.toString();
547
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
548
+ let resp: ListKafkaConfigsResponse | undefined;
549
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
550
+ const headers = new Headers();
551
+ if (this.workspaceId !== undefined) {
552
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
553
+ }
554
+ headers.set('User-Agent', this.userAgent);
555
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
556
+ const respBody = await executeHttpCall({
557
+ request: httpReq,
558
+ httpClient: this.httpClient,
559
+ logger: this.logger,
560
+ });
561
+ resp = parseResponse(respBody, unmarshalListKafkaConfigsResponseSchema);
562
+ };
563
+ await executeCall(call, options);
564
+ if (resp === undefined) {
565
+ throw new Error('API call completed without a result.');
566
+ }
567
+ return resp;
568
+ }
569
+
570
+ async *listKafkaConfigsIter(
571
+ req: ListKafkaConfigsRequest,
572
+ options?: CallOptions
573
+ ): AsyncGenerator<KafkaConfig> {
574
+ const pageReq: ListKafkaConfigsRequest = {...req};
575
+ for (;;) {
576
+ const resp = await this.listKafkaConfigs(pageReq, options);
577
+ for (const item of resp.kafkaConfigs ?? []) {
578
+ yield item;
579
+ }
580
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
581
+ return;
582
+ }
583
+ pageReq.pageToken = resp.nextPageToken;
584
+ }
585
+ }
586
+
587
+ /** List materialized features. */
588
+ async listMaterializedFeatures(
589
+ req: ListMaterializedFeaturesRequest,
590
+ options?: CallOptions
591
+ ): Promise<ListMaterializedFeaturesResponse> {
592
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features`;
593
+ const params = new URLSearchParams();
594
+ if (req.featureName !== undefined) {
595
+ params.append('feature_name', req.featureName);
596
+ }
597
+ if (req.pageToken !== undefined) {
598
+ params.append('page_token', req.pageToken);
599
+ }
600
+ if (req.pageSize !== undefined) {
601
+ params.append('page_size', String(req.pageSize));
602
+ }
603
+ const query = params.toString();
604
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
605
+ let resp: ListMaterializedFeaturesResponse | undefined;
606
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
607
+ const headers = new Headers();
608
+ if (this.workspaceId !== undefined) {
609
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
610
+ }
611
+ headers.set('User-Agent', this.userAgent);
612
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
613
+ const respBody = await executeHttpCall({
614
+ request: httpReq,
615
+ httpClient: this.httpClient,
616
+ logger: this.logger,
617
+ });
618
+ resp = parseResponse(
619
+ respBody,
620
+ unmarshalListMaterializedFeaturesResponseSchema
621
+ );
622
+ };
623
+ await executeCall(call, options);
624
+ if (resp === undefined) {
625
+ throw new Error('API call completed without a result.');
626
+ }
627
+ return resp;
628
+ }
629
+
630
+ async *listMaterializedFeaturesIter(
631
+ req: ListMaterializedFeaturesRequest,
632
+ options?: CallOptions
633
+ ): AsyncGenerator<MaterializedFeature> {
634
+ const pageReq: ListMaterializedFeaturesRequest = {...req};
635
+ for (;;) {
636
+ const resp = await this.listMaterializedFeatures(pageReq, options);
637
+ for (const item of resp.materializedFeatures ?? []) {
638
+ yield item;
639
+ }
640
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
641
+ return;
642
+ }
643
+ pageReq.pageToken = resp.nextPageToken;
644
+ }
645
+ }
646
+
647
+ /** List Streams under a given catalog.schema parent. */
648
+ async listStreams(
649
+ req: ListStreamsRequest,
650
+ options?: CallOptions
651
+ ): Promise<ListStreamsResponse> {
652
+ const url = `${this.host}/api/2.0/feature-engineering/streams`;
653
+ const params = new URLSearchParams();
654
+ if (req.parent !== undefined) {
655
+ params.append('parent', req.parent);
656
+ }
657
+ if (req.pageSize !== undefined) {
658
+ params.append('page_size', String(req.pageSize));
659
+ }
660
+ if (req.pageToken !== undefined) {
661
+ params.append('page_token', req.pageToken);
662
+ }
663
+ const query = params.toString();
664
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
665
+ let resp: ListStreamsResponse | undefined;
666
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
667
+ const headers = new Headers();
668
+ if (this.workspaceId !== undefined) {
669
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
670
+ }
671
+ headers.set('User-Agent', this.userAgent);
672
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
673
+ const respBody = await executeHttpCall({
674
+ request: httpReq,
675
+ httpClient: this.httpClient,
676
+ logger: this.logger,
677
+ });
678
+ resp = parseResponse(respBody, unmarshalListStreamsResponseSchema);
679
+ };
680
+ await executeCall(call, options);
681
+ if (resp === undefined) {
682
+ throw new Error('API call completed without a result.');
683
+ }
684
+ return resp;
685
+ }
686
+
687
+ async *listStreamsIter(
688
+ req: ListStreamsRequest,
689
+ options?: CallOptions
690
+ ): AsyncGenerator<Stream> {
691
+ const pageReq: ListStreamsRequest = {...req};
692
+ for (;;) {
693
+ const resp = await this.listStreams(pageReq, options);
694
+ for (const item of resp.streams ?? []) {
695
+ yield item;
696
+ }
697
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
698
+ return;
699
+ }
700
+ pageReq.pageToken = resp.nextPageToken;
701
+ }
702
+ }
703
+
704
+ /** Update a Feature. */
705
+ async updateFeature(
706
+ req: UpdateFeatureRequest,
707
+ options?: CallOptions
708
+ ): Promise<Feature> {
709
+ const url = `${this.host}/api/2.0/feature-engineering/features/${req.feature?.fullName ?? ''}`;
710
+ const params = new URLSearchParams();
711
+ if (req.updateMask !== undefined) {
712
+ params.append('update_mask', req.updateMask.toString());
713
+ }
714
+ const query = params.toString();
715
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
716
+ const body = marshalRequest(req.feature, marshalFeatureSchema);
717
+ let resp: Feature | undefined;
718
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
719
+ const headers = new Headers({'Content-Type': 'application/json'});
720
+ if (this.workspaceId !== undefined) {
721
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
722
+ }
723
+ headers.set('User-Agent', this.userAgent);
724
+ const httpReq = buildHttpRequest(
725
+ 'PATCH',
726
+ fullUrl,
727
+ headers,
728
+ callSignal,
729
+ body
730
+ );
731
+ const respBody = await executeHttpCall({
732
+ request: httpReq,
733
+ httpClient: this.httpClient,
734
+ logger: this.logger,
735
+ });
736
+ resp = parseResponse(respBody, unmarshalFeatureSchema);
737
+ };
738
+ await executeCall(call, options);
739
+ if (resp === undefined) {
740
+ throw new Error('API call completed without a result.');
741
+ }
742
+ return resp;
743
+ }
744
+
745
+ /**
746
+ * Update a Kafka config.
747
+ * During PrPr, Kafka configs can be read and used when creating features under the entire metastore.
748
+ * Only the creator of the Kafka config can delete it.
749
+ */
750
+ async updateKafkaConfig(
751
+ req: UpdateKafkaConfigRequest,
752
+ options?: CallOptions
753
+ ): Promise<KafkaConfig> {
754
+ const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.kafkaConfig?.name ?? ''}`;
755
+ const params = new URLSearchParams();
756
+ if (req.updateMask !== undefined) {
757
+ params.append('update_mask', req.updateMask.toString());
758
+ }
759
+ const query = params.toString();
760
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
761
+ const body = marshalRequest(req.kafkaConfig, marshalKafkaConfigSchema);
762
+ let resp: KafkaConfig | undefined;
763
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
764
+ const headers = new Headers({'Content-Type': 'application/json'});
765
+ if (this.workspaceId !== undefined) {
766
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
767
+ }
768
+ headers.set('User-Agent', this.userAgent);
769
+ const httpReq = buildHttpRequest(
770
+ 'PATCH',
771
+ fullUrl,
772
+ headers,
773
+ callSignal,
774
+ body
775
+ );
776
+ const respBody = await executeHttpCall({
777
+ request: httpReq,
778
+ httpClient: this.httpClient,
779
+ logger: this.logger,
780
+ });
781
+ resp = parseResponse(respBody, unmarshalKafkaConfigSchema);
782
+ };
783
+ await executeCall(call, options);
784
+ if (resp === undefined) {
785
+ throw new Error('API call completed without a result.');
786
+ }
787
+ return resp;
788
+ }
789
+
790
+ /** Update a materialized feature (pause/resume). */
791
+ async updateMaterializedFeature(
792
+ req: UpdateMaterializedFeatureRequest,
793
+ options?: CallOptions
794
+ ): Promise<MaterializedFeature> {
795
+ const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeature?.materializedFeatureId ?? ''}`;
796
+ const params = new URLSearchParams();
797
+ if (req.updateMask !== undefined) {
798
+ params.append('update_mask', req.updateMask.toString());
799
+ }
800
+ const query = params.toString();
801
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
802
+ const body = marshalRequest(
803
+ req.materializedFeature,
804
+ marshalMaterializedFeatureSchema
805
+ );
806
+ let resp: MaterializedFeature | undefined;
807
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
808
+ const headers = new Headers({'Content-Type': 'application/json'});
809
+ if (this.workspaceId !== undefined) {
810
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
811
+ }
812
+ headers.set('User-Agent', this.userAgent);
813
+ const httpReq = buildHttpRequest(
814
+ 'PATCH',
815
+ fullUrl,
816
+ headers,
817
+ callSignal,
818
+ body
819
+ );
820
+ const respBody = await executeHttpCall({
821
+ request: httpReq,
822
+ httpClient: this.httpClient,
823
+ logger: this.logger,
824
+ });
825
+ resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema);
826
+ };
827
+ await executeCall(call, options);
828
+ if (resp === undefined) {
829
+ throw new Error('API call completed without a result.');
830
+ }
831
+ return resp;
832
+ }
833
+
834
+ /** Update a Stream. Only fields listed in `update_mask` are mutated. */
835
+ async updateStream(
836
+ req: UpdateStreamRequest,
837
+ options?: CallOptions
838
+ ): Promise<Stream> {
839
+ const url = `${this.host}/api/2.0/feature-engineering/streams/${req.stream?.name ?? ''}`;
840
+ const params = new URLSearchParams();
841
+ if (req.updateMask !== undefined) {
842
+ params.append('update_mask', req.updateMask.toString());
843
+ }
844
+ const query = params.toString();
845
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
846
+ const body = marshalRequest(req.stream, marshalStreamSchema);
847
+ let resp: Stream | undefined;
848
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
849
+ const headers = new Headers({'Content-Type': 'application/json'});
850
+ if (this.workspaceId !== undefined) {
851
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
852
+ }
853
+ headers.set('User-Agent', this.userAgent);
854
+ const httpReq = buildHttpRequest(
855
+ 'PATCH',
856
+ fullUrl,
857
+ headers,
858
+ callSignal,
859
+ body
860
+ );
861
+ const respBody = await executeHttpCall({
862
+ request: httpReq,
863
+ httpClient: this.httpClient,
864
+ logger: this.logger,
865
+ });
866
+ resp = parseResponse(respBody, unmarshalStreamSchema);
867
+ };
868
+ await executeCall(call, options);
869
+ if (resp === undefined) {
870
+ throw new Error('API call completed without a result.');
871
+ }
872
+ return resp;
873
+ }
874
+ }