@databricks/sdk-features 0.1.0-dev.2 → 0.1.0-dev.4

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