@databricks/sdk-uc-onlinetables 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,620 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {Temporal} from '@js-temporal/polyfill';
4
+ import {z} from 'zod';
5
+
6
+ /** The state of an online table. */
7
+ export enum OnlineTableState {
8
+ /** The default state. It should not be reported by any online tables. */
9
+ ONLINE_TABLE_STATE_UNSPECIFIED = 'ONLINE_TABLE_STATE_UNSPECIFIED',
10
+ /**
11
+ * The online table has just been created and resources are being provisioned. This is also the
12
+ * catch-all state if there is not a more suitable state to report for the online table.
13
+ */
14
+ PROVISIONING = 'PROVISIONING',
15
+ /** The online table is provisioning resources for the data synchronization pipeline. */
16
+ PROVISIONING_PIPELINE_RESOURCES = 'PROVISIONING_PIPELINE_RESOURCES',
17
+ /** The online table is executing the initial data synchronization. */
18
+ PROVISIONING_INITIAL_SNAPSHOT = 'PROVISIONING_INITIAL_SNAPSHOT',
19
+ /** The online table is ready to serve data. */
20
+ ONLINE = 'ONLINE',
21
+ /**
22
+ * The online table is ready to serve data and is continuously updating. Only shown for online
23
+ * tables using the "Continuous" sync mode.
24
+ */
25
+ ONLINE_CONTINUOUS_UPDATE = 'ONLINE_CONTINUOUS_UPDATE',
26
+ /**
27
+ * The online table is ready to serve data and an active update is in progress. Only shown for
28
+ * online tables using the "Triggered" sync mode.
29
+ */
30
+ ONLINE_TRIGGERED_UPDATE = 'ONLINE_TRIGGERED_UPDATE',
31
+ /**
32
+ * The online table is ready to serve data and there are no active updates. Only shown for online
33
+ * tables using the "Triggered" sync mode.
34
+ */
35
+ ONLINE_NO_PENDING_UPDATE = 'ONLINE_NO_PENDING_UPDATE',
36
+ /** The online table has encountered an internal error and is not available for serving. */
37
+ OFFLINE = 'OFFLINE',
38
+ /**
39
+ * The online table is not available for serving because the data synchronization pipeline has
40
+ * failed. Please review the pipeline event logs to troubleshoot.
41
+ */
42
+ OFFLINE_FAILED = 'OFFLINE_FAILED',
43
+ /**
44
+ * The data synchronization pipeline has encountered an error but the online table is still
45
+ * available for serving (potentially stale) data. Please review the pipeline event logs to
46
+ * troubleshoot.
47
+ */
48
+ ONLINE_PIPELINE_FAILED = 'ONLINE_PIPELINE_FAILED',
49
+ /**
50
+ * The online table is available for serving, and is provisioning resources for a newly started
51
+ * data synchronization pipeline.
52
+ */
53
+ ONLINE_UPDATING_PIPELINE_RESOURCES = 'ONLINE_UPDATING_PIPELINE_RESOURCES',
54
+ }
55
+
56
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name.
57
+ export enum ProvisioningInfo_State {
58
+ STATE_UNSPECIFIED = 'STATE_UNSPECIFIED',
59
+ PROVISIONING = 'PROVISIONING',
60
+ ACTIVE = 'ACTIVE',
61
+ FAILED = 'FAILED',
62
+ DELETING = 'DELETING',
63
+ UPDATING = 'UPDATING',
64
+ DEGRADED = 'DEGRADED',
65
+ }
66
+
67
+ /**
68
+ * Detailed status of an online table. Shown if the online table is in the ONLINE_CONTINUOUS_UPDATE
69
+ * or the ONLINE_UPDATING_PIPELINE_RESOURCES state.
70
+ */
71
+ export interface ContinuousUpdateStatus {
72
+ /**
73
+ * The last source table Delta version that was synced to the online table. Note that this Delta
74
+ * version may not be completely synced to the online table yet.
75
+ */
76
+ lastProcessedCommitVersion?: bigint | undefined;
77
+ /**
78
+ * The timestamp of the last time any data was synchronized from the source table to the online
79
+ * table.
80
+ */
81
+ timestamp?: Temporal.Instant | undefined;
82
+ /** Progress of the initial data synchronization. */
83
+ initialPipelineSyncProgress?: PipelineProgress | undefined;
84
+ }
85
+
86
+ /** Create an online table */
87
+ export interface CreateOnlineTableRequest {
88
+ /** Specification of the online table to be created. */
89
+ table?: OnlineTable | undefined;
90
+ }
91
+
92
+ /** Delete an online table. */
93
+ export interface DeleteOnlineTableRequest {
94
+ /** Full three-part (catalog, schema, table) name of the table. */
95
+ name?: string | undefined;
96
+ }
97
+
98
+ /**
99
+ * Detailed status of an online table. Shown if the online table is in the OFFLINE_FAILED or the
100
+ * ONLINE_PIPELINE_FAILED state.
101
+ */
102
+ export interface FailedStatus {
103
+ /**
104
+ * The last source table Delta version that was synced to the online table. Note that this Delta
105
+ * version may only be partially synced to the online table. Only populated if the table is still
106
+ * online and available for serving.
107
+ */
108
+ lastProcessedCommitVersion?: bigint | undefined;
109
+ /**
110
+ * The timestamp of the last time any data was synchronized from the source table to the online
111
+ * table. Only populated if the table is still online and available for serving.
112
+ */
113
+ timestamp?: Temporal.Instant | undefined;
114
+ }
115
+
116
+ /** Get information about an online table. */
117
+ export interface GetOnlineTableRequest {
118
+ /** Full three-part (catalog, schema, table) name of the table. */
119
+ name?: string | undefined;
120
+ }
121
+
122
+ /** Online Table information. */
123
+ export interface OnlineTable {
124
+ /** Full three-part (catalog, schema, table) name of the table. */
125
+ name?: string | undefined;
126
+ /** Specification of the online table. */
127
+ spec?: OnlineTableSpec | undefined;
128
+ /** Online Table data synchronization status */
129
+ status?: OnlineTableStatus | undefined;
130
+ /** Data serving REST API URL for this table */
131
+ tableServingUrl?: string | undefined;
132
+ /**
133
+ * The provisioning state of the online table entity in Unity Catalog. This is distinct from the
134
+ * state of the data synchronization pipeline (i.e. the table may be in "ACTIVE" but the pipeline
135
+ * may be in "PROVISIONING" as it runs asynchronously).
136
+ */
137
+ unityCatalogProvisioningState?: ProvisioningInfo_State | undefined;
138
+ }
139
+
140
+ /** Specification of an online table. */
141
+ export interface OnlineTableSpec {
142
+ /** Exactly one type of scheduling policy should be applied. */
143
+ schedulingPolicy?:
144
+ | {
145
+ $case: 'runContinuously';
146
+ /** Pipeline runs continuously after generating the initial data. */
147
+ runContinuously: OnlineTableSpec_ContinuousSchedulingPolicy;
148
+ }
149
+ | {
150
+ $case: 'runTriggered';
151
+ /** Pipeline stops after generating the initial data and can be triggered later (manually, through a cron job or through data triggers) */
152
+ runTriggered: OnlineTableSpec_TriggeredSchedulingPolicy;
153
+ }
154
+ | undefined;
155
+ /** Three-part (catalog, schema, table) name of the source Delta table. */
156
+ sourceTableFullName?: string | undefined;
157
+ /** Primary Key columns to be used for data insert/update in the destination. */
158
+ primaryKeyColumns?: string[] | undefined;
159
+ /** Time series key to deduplicate (tie-break) rows with the same primary key. */
160
+ timeseriesKey?: string | undefined;
161
+ /**
162
+ * Whether to create a full-copy pipeline -- a pipeline that stops after creates a full copy of
163
+ * the source table upon initialization and does not process any change data feeds (CDFs)
164
+ * afterwards. The pipeline can still be manually triggered afterwards, but it always perform a
165
+ * full copy of the source table and there are no incremental updates. This mode is useful for
166
+ * syncing views or tables without CDFs to online tables.
167
+ * Note that the full-copy pipeline only supports "triggered" scheduling policy.
168
+ */
169
+ performFullCopy?: boolean | undefined;
170
+ /** ID of the associated pipeline. Generated by the server - cannot be set by the caller. */
171
+ pipelineId?: string | undefined;
172
+ }
173
+
174
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
175
+ export interface OnlineTableSpec_ContinuousSchedulingPolicy {}
176
+
177
+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
178
+ export interface OnlineTableSpec_TriggeredSchedulingPolicy {}
179
+
180
+ /** Status of an online table. */
181
+ export interface OnlineTableStatus {
182
+ /** The state of the online table. */
183
+ detailedState?: OnlineTableState | undefined;
184
+ /** A text description of the current state of the online table. */
185
+ message?: string | undefined;
186
+ /** The detailed status based on the online table state. */
187
+ detailedStatus?:
188
+ | {$case: 'provisioningStatus'; provisioningStatus: ProvisioningStatus}
189
+ | {
190
+ $case: 'continuousUpdateStatus';
191
+ continuousUpdateStatus: ContinuousUpdateStatus;
192
+ }
193
+ | {
194
+ $case: 'triggeredUpdateStatus';
195
+ triggeredUpdateStatus: TriggeredUpdateStatus;
196
+ }
197
+ | {$case: 'failedStatus'; failedStatus: FailedStatus}
198
+ | undefined;
199
+ }
200
+
201
+ /** Progress information of the Online Table data synchronization pipeline. */
202
+ export interface PipelineProgress {
203
+ /**
204
+ * The source table Delta version that was last processed by the pipeline. The pipeline may not
205
+ * have completely processed this version yet.
206
+ */
207
+ latestVersionCurrentlyProcessing?: bigint | undefined;
208
+ /** The number of rows that have been synced in this update. */
209
+ syncedRowCount?: bigint | undefined;
210
+ /** The total number of rows that need to be synced in this update. This number may be an estimate. */
211
+ totalRowCount?: bigint | undefined;
212
+ /** The completion ratio of this update. This is a number between 0 and 1. */
213
+ syncProgressCompletion?: number | undefined;
214
+ /** The estimated time remaining to complete this update in seconds. */
215
+ estimatedCompletionTimeSeconds?: number | undefined;
216
+ }
217
+
218
+ /** Status of an asynchronously provisioned resource. */
219
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
220
+ export interface ProvisioningInfo {}
221
+
222
+ /**
223
+ * Detailed status of an online table. Shown if the online table is in the
224
+ * PROVISIONING_PIPELINE_RESOURCES or the PROVISIONING_INITIAL_SNAPSHOT state.
225
+ */
226
+ export interface ProvisioningStatus {
227
+ /**
228
+ * Details about initial data synchronization. Only populated when in the
229
+ * PROVISIONING_INITIAL_SNAPSHOT state.
230
+ */
231
+ initialPipelineSyncProgress?: PipelineProgress | undefined;
232
+ }
233
+
234
+ /**
235
+ * Detailed status of an online table. Shown if the online table is in the ONLINE_TRIGGERED_UPDATE
236
+ * or the ONLINE_NO_PENDING_UPDATE state.
237
+ */
238
+ export interface TriggeredUpdateStatus {
239
+ /**
240
+ * The last source table Delta version that was synced to the online table. Note that this Delta
241
+ * version may not be completely synced to the online table yet.
242
+ */
243
+ lastProcessedCommitVersion?: bigint | undefined;
244
+ /**
245
+ * The timestamp of the last time any data was synchronized from the source table to the online
246
+ * table.
247
+ */
248
+ timestamp?: Temporal.Instant | undefined;
249
+ /** Progress of the active data synchronization pipeline. */
250
+ triggeredUpdateProgress?: PipelineProgress | undefined;
251
+ }
252
+
253
+ export const unmarshalContinuousUpdateStatusSchema: z.ZodType<ContinuousUpdateStatus> =
254
+ z
255
+ .object({
256
+ last_processed_commit_version: z
257
+ .union([z.number(), z.bigint()])
258
+ .transform(v => BigInt(v))
259
+ .optional(),
260
+ timestamp: z
261
+ .string()
262
+ .transform(s => Temporal.Instant.from(s))
263
+ .optional(),
264
+ initial_pipeline_sync_progress: z
265
+ .lazy(() => unmarshalPipelineProgressSchema)
266
+ .optional(),
267
+ })
268
+ .transform(d => ({
269
+ lastProcessedCommitVersion: d.last_processed_commit_version,
270
+ timestamp: d.timestamp,
271
+ initialPipelineSyncProgress: d.initial_pipeline_sync_progress,
272
+ }));
273
+
274
+ export const unmarshalFailedStatusSchema: z.ZodType<FailedStatus> = z
275
+ .object({
276
+ last_processed_commit_version: z
277
+ .union([z.number(), z.bigint()])
278
+ .transform(v => BigInt(v))
279
+ .optional(),
280
+ timestamp: z
281
+ .string()
282
+ .transform(s => Temporal.Instant.from(s))
283
+ .optional(),
284
+ })
285
+ .transform(d => ({
286
+ lastProcessedCommitVersion: d.last_processed_commit_version,
287
+ timestamp: d.timestamp,
288
+ }));
289
+
290
+ export const unmarshalOnlineTableSchema: z.ZodType<OnlineTable> = z
291
+ .object({
292
+ name: z.string().optional(),
293
+ spec: z.lazy(() => unmarshalOnlineTableSpecSchema).optional(),
294
+ status: z.lazy(() => unmarshalOnlineTableStatusSchema).optional(),
295
+ table_serving_url: z.string().optional(),
296
+ unity_catalog_provisioning_state: z.enum(ProvisioningInfo_State).optional(),
297
+ })
298
+ .transform(d => ({
299
+ name: d.name,
300
+ spec: d.spec,
301
+ status: d.status,
302
+ tableServingUrl: d.table_serving_url,
303
+ unityCatalogProvisioningState: d.unity_catalog_provisioning_state,
304
+ }));
305
+
306
+ export const unmarshalOnlineTableSpecSchema: z.ZodType<OnlineTableSpec> = z
307
+ .object({
308
+ run_continuously: z
309
+ .lazy(() => unmarshalOnlineTableSpec_ContinuousSchedulingPolicySchema)
310
+ .optional(),
311
+ run_triggered: z
312
+ .lazy(() => unmarshalOnlineTableSpec_TriggeredSchedulingPolicySchema)
313
+ .optional(),
314
+ source_table_full_name: z.string().optional(),
315
+ primary_key_columns: z.array(z.string()).optional(),
316
+ timeseries_key: z.string().optional(),
317
+ perform_full_copy: z.boolean().optional(),
318
+ pipeline_id: z.string().optional(),
319
+ })
320
+ .transform(d => ({
321
+ schedulingPolicy:
322
+ d.run_continuously !== undefined
323
+ ? {
324
+ $case: 'runContinuously' as const,
325
+ runContinuously: d.run_continuously,
326
+ }
327
+ : d.run_triggered !== undefined
328
+ ? {$case: 'runTriggered' as const, runTriggered: d.run_triggered}
329
+ : undefined,
330
+ sourceTableFullName: d.source_table_full_name,
331
+ primaryKeyColumns: d.primary_key_columns,
332
+ timeseriesKey: d.timeseries_key,
333
+ performFullCopy: d.perform_full_copy,
334
+ pipelineId: d.pipeline_id,
335
+ }));
336
+
337
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
338
+ export const unmarshalOnlineTableSpec_ContinuousSchedulingPolicySchema: z.ZodType<OnlineTableSpec_ContinuousSchedulingPolicy> =
339
+ z.object({});
340
+
341
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
342
+ export const unmarshalOnlineTableSpec_TriggeredSchedulingPolicySchema: z.ZodType<OnlineTableSpec_TriggeredSchedulingPolicy> =
343
+ z.object({});
344
+
345
+ export const unmarshalOnlineTableStatusSchema: z.ZodType<OnlineTableStatus> = z
346
+ .object({
347
+ detailed_state: z.enum(OnlineTableState).optional(),
348
+ message: z.string().optional(),
349
+ provisioning_status: z
350
+ .lazy(() => unmarshalProvisioningStatusSchema)
351
+ .optional(),
352
+ continuous_update_status: z
353
+ .lazy(() => unmarshalContinuousUpdateStatusSchema)
354
+ .optional(),
355
+ triggered_update_status: z
356
+ .lazy(() => unmarshalTriggeredUpdateStatusSchema)
357
+ .optional(),
358
+ failed_status: z.lazy(() => unmarshalFailedStatusSchema).optional(),
359
+ })
360
+ .transform(d => ({
361
+ detailedState: d.detailed_state,
362
+ message: d.message,
363
+ detailedStatus:
364
+ d.provisioning_status !== undefined
365
+ ? {
366
+ $case: 'provisioningStatus' as const,
367
+ provisioningStatus: d.provisioning_status,
368
+ }
369
+ : d.continuous_update_status !== undefined
370
+ ? {
371
+ $case: 'continuousUpdateStatus' as const,
372
+ continuousUpdateStatus: d.continuous_update_status,
373
+ }
374
+ : d.triggered_update_status !== undefined
375
+ ? {
376
+ $case: 'triggeredUpdateStatus' as const,
377
+ triggeredUpdateStatus: d.triggered_update_status,
378
+ }
379
+ : d.failed_status !== undefined
380
+ ? {$case: 'failedStatus' as const, failedStatus: d.failed_status}
381
+ : undefined,
382
+ }));
383
+
384
+ export const unmarshalPipelineProgressSchema: z.ZodType<PipelineProgress> = z
385
+ .object({
386
+ latest_version_currently_processing: z
387
+ .union([z.number(), z.bigint()])
388
+ .transform(v => BigInt(v))
389
+ .optional(),
390
+ synced_row_count: z
391
+ .union([z.number(), z.bigint()])
392
+ .transform(v => BigInt(v))
393
+ .optional(),
394
+ total_row_count: z
395
+ .union([z.number(), z.bigint()])
396
+ .transform(v => BigInt(v))
397
+ .optional(),
398
+ sync_progress_completion: z.number().optional(),
399
+ estimated_completion_time_seconds: z.number().optional(),
400
+ })
401
+ .transform(d => ({
402
+ latestVersionCurrentlyProcessing: d.latest_version_currently_processing,
403
+ syncedRowCount: d.synced_row_count,
404
+ totalRowCount: d.total_row_count,
405
+ syncProgressCompletion: d.sync_progress_completion,
406
+ estimatedCompletionTimeSeconds: d.estimated_completion_time_seconds,
407
+ }));
408
+
409
+ export const unmarshalProvisioningStatusSchema: z.ZodType<ProvisioningStatus> =
410
+ z
411
+ .object({
412
+ initial_pipeline_sync_progress: z
413
+ .lazy(() => unmarshalPipelineProgressSchema)
414
+ .optional(),
415
+ })
416
+ .transform(d => ({
417
+ initialPipelineSyncProgress: d.initial_pipeline_sync_progress,
418
+ }));
419
+
420
+ export const unmarshalTriggeredUpdateStatusSchema: z.ZodType<TriggeredUpdateStatus> =
421
+ z
422
+ .object({
423
+ last_processed_commit_version: z
424
+ .union([z.number(), z.bigint()])
425
+ .transform(v => BigInt(v))
426
+ .optional(),
427
+ timestamp: z
428
+ .string()
429
+ .transform(s => Temporal.Instant.from(s))
430
+ .optional(),
431
+ triggered_update_progress: z
432
+ .lazy(() => unmarshalPipelineProgressSchema)
433
+ .optional(),
434
+ })
435
+ .transform(d => ({
436
+ lastProcessedCommitVersion: d.last_processed_commit_version,
437
+ timestamp: d.timestamp,
438
+ triggeredUpdateProgress: d.triggered_update_progress,
439
+ }));
440
+
441
+ export const marshalContinuousUpdateStatusSchema: z.ZodType = z
442
+ .object({
443
+ lastProcessedCommitVersion: z.bigint().optional(),
444
+ timestamp: z
445
+ .any()
446
+ .transform((d: Temporal.Instant) => d.toString())
447
+ .optional(),
448
+ initialPipelineSyncProgress: z
449
+ .lazy(() => marshalPipelineProgressSchema)
450
+ .optional(),
451
+ })
452
+ .transform(d => ({
453
+ last_processed_commit_version: d.lastProcessedCommitVersion,
454
+ timestamp: d.timestamp,
455
+ initial_pipeline_sync_progress: d.initialPipelineSyncProgress,
456
+ }));
457
+
458
+ export const marshalFailedStatusSchema: z.ZodType = z
459
+ .object({
460
+ lastProcessedCommitVersion: z.bigint().optional(),
461
+ timestamp: z
462
+ .any()
463
+ .transform((d: Temporal.Instant) => d.toString())
464
+ .optional(),
465
+ })
466
+ .transform(d => ({
467
+ last_processed_commit_version: d.lastProcessedCommitVersion,
468
+ timestamp: d.timestamp,
469
+ }));
470
+
471
+ export const marshalOnlineTableSchema: z.ZodType = z
472
+ .object({
473
+ name: z.string().optional(),
474
+ spec: z.lazy(() => marshalOnlineTableSpecSchema).optional(),
475
+ status: z.lazy(() => marshalOnlineTableStatusSchema).optional(),
476
+ tableServingUrl: z.string().optional(),
477
+ unityCatalogProvisioningState: z.enum(ProvisioningInfo_State).optional(),
478
+ })
479
+ .transform(d => ({
480
+ name: d.name,
481
+ spec: d.spec,
482
+ status: d.status,
483
+ table_serving_url: d.tableServingUrl,
484
+ unity_catalog_provisioning_state: d.unityCatalogProvisioningState,
485
+ }));
486
+
487
+ export const marshalOnlineTableSpecSchema: z.ZodType = z
488
+ .object({
489
+ schedulingPolicy: z
490
+ .discriminatedUnion('$case', [
491
+ z.object({
492
+ $case: z.literal('runContinuously'),
493
+ runContinuously: z.lazy(
494
+ () => marshalOnlineTableSpec_ContinuousSchedulingPolicySchema
495
+ ),
496
+ }),
497
+ z.object({
498
+ $case: z.literal('runTriggered'),
499
+ runTriggered: z.lazy(
500
+ () => marshalOnlineTableSpec_TriggeredSchedulingPolicySchema
501
+ ),
502
+ }),
503
+ ])
504
+ .optional(),
505
+ sourceTableFullName: z.string().optional(),
506
+ primaryKeyColumns: z.array(z.string()).optional(),
507
+ timeseriesKey: z.string().optional(),
508
+ performFullCopy: z.boolean().optional(),
509
+ pipelineId: z.string().optional(),
510
+ })
511
+ .transform(d => ({
512
+ ...(d.schedulingPolicy?.$case === 'runContinuously' && {
513
+ run_continuously: d.schedulingPolicy.runContinuously,
514
+ }),
515
+ ...(d.schedulingPolicy?.$case === 'runTriggered' && {
516
+ run_triggered: d.schedulingPolicy.runTriggered,
517
+ }),
518
+ source_table_full_name: d.sourceTableFullName,
519
+ primary_key_columns: d.primaryKeyColumns,
520
+ timeseries_key: d.timeseriesKey,
521
+ perform_full_copy: d.performFullCopy,
522
+ pipeline_id: d.pipelineId,
523
+ }));
524
+
525
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
526
+ export const marshalOnlineTableSpec_ContinuousSchedulingPolicySchema: z.ZodType =
527
+ z.object({});
528
+
529
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
530
+ export const marshalOnlineTableSpec_TriggeredSchedulingPolicySchema: z.ZodType =
531
+ z.object({});
532
+
533
+ export const marshalOnlineTableStatusSchema: z.ZodType = z
534
+ .object({
535
+ detailedState: z.enum(OnlineTableState).optional(),
536
+ message: z.string().optional(),
537
+ detailedStatus: z
538
+ .discriminatedUnion('$case', [
539
+ z.object({
540
+ $case: z.literal('provisioningStatus'),
541
+ provisioningStatus: z.lazy(() => marshalProvisioningStatusSchema),
542
+ }),
543
+ z.object({
544
+ $case: z.literal('continuousUpdateStatus'),
545
+ continuousUpdateStatus: z.lazy(
546
+ () => marshalContinuousUpdateStatusSchema
547
+ ),
548
+ }),
549
+ z.object({
550
+ $case: z.literal('triggeredUpdateStatus'),
551
+ triggeredUpdateStatus: z.lazy(
552
+ () => marshalTriggeredUpdateStatusSchema
553
+ ),
554
+ }),
555
+ z.object({
556
+ $case: z.literal('failedStatus'),
557
+ failedStatus: z.lazy(() => marshalFailedStatusSchema),
558
+ }),
559
+ ])
560
+ .optional(),
561
+ })
562
+ .transform(d => ({
563
+ detailed_state: d.detailedState,
564
+ message: d.message,
565
+ ...(d.detailedStatus?.$case === 'provisioningStatus' && {
566
+ provisioning_status: d.detailedStatus.provisioningStatus,
567
+ }),
568
+ ...(d.detailedStatus?.$case === 'continuousUpdateStatus' && {
569
+ continuous_update_status: d.detailedStatus.continuousUpdateStatus,
570
+ }),
571
+ ...(d.detailedStatus?.$case === 'triggeredUpdateStatus' && {
572
+ triggered_update_status: d.detailedStatus.triggeredUpdateStatus,
573
+ }),
574
+ ...(d.detailedStatus?.$case === 'failedStatus' && {
575
+ failed_status: d.detailedStatus.failedStatus,
576
+ }),
577
+ }));
578
+
579
+ export const marshalPipelineProgressSchema: z.ZodType = z
580
+ .object({
581
+ latestVersionCurrentlyProcessing: z.bigint().optional(),
582
+ syncedRowCount: z.bigint().optional(),
583
+ totalRowCount: z.bigint().optional(),
584
+ syncProgressCompletion: z.number().optional(),
585
+ estimatedCompletionTimeSeconds: z.number().optional(),
586
+ })
587
+ .transform(d => ({
588
+ latest_version_currently_processing: d.latestVersionCurrentlyProcessing,
589
+ synced_row_count: d.syncedRowCount,
590
+ total_row_count: d.totalRowCount,
591
+ sync_progress_completion: d.syncProgressCompletion,
592
+ estimated_completion_time_seconds: d.estimatedCompletionTimeSeconds,
593
+ }));
594
+
595
+ export const marshalProvisioningStatusSchema: z.ZodType = z
596
+ .object({
597
+ initialPipelineSyncProgress: z
598
+ .lazy(() => marshalPipelineProgressSchema)
599
+ .optional(),
600
+ })
601
+ .transform(d => ({
602
+ initial_pipeline_sync_progress: d.initialPipelineSyncProgress,
603
+ }));
604
+
605
+ export const marshalTriggeredUpdateStatusSchema: z.ZodType = z
606
+ .object({
607
+ lastProcessedCommitVersion: z.bigint().optional(),
608
+ timestamp: z
609
+ .any()
610
+ .transform((d: Temporal.Instant) => d.toString())
611
+ .optional(),
612
+ triggeredUpdateProgress: z
613
+ .lazy(() => marshalPipelineProgressSchema)
614
+ .optional(),
615
+ })
616
+ .transform(d => ({
617
+ last_processed_commit_version: d.lastProcessedCommitVersion,
618
+ timestamp: d.timestamp,
619
+ triggered_update_progress: d.triggeredUpdateProgress,
620
+ }));
@@ -0,0 +1,73 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import type {Credentials} from '@databricks/sdk-auth';
4
+ import {defaultCredentials} from '@databricks/sdk-auth/credentials';
5
+ import type {
6
+ HttpClient,
7
+ HttpRequest,
8
+ HttpResponse,
9
+ } from '@databricks/sdk-core/http';
10
+ import {newFetchHttpClient} from '@databricks/sdk-core/http';
11
+ import type {ClientOptions} from '@databricks/sdk-options/client';
12
+
13
+ /** Creates a new HTTP client with the given options. */
14
+ export function newHttpClient(options?: ClientOptions): HttpClient {
15
+ const opts = options ?? {};
16
+
17
+ // If an HTTP client is provided, use it as-is. Throw if other options are
18
+ // also set, since they would be silently ignored.
19
+ if (opts.httpClient !== undefined) {
20
+ if (opts.credentials !== undefined || opts.timeout !== undefined) {
21
+ throw new Error(
22
+ 'httpClient cannot be combined with credentials or timeout'
23
+ );
24
+ }
25
+ return opts.httpClient;
26
+ }
27
+
28
+ const credentials = opts.credentials ?? defaultCredentials();
29
+
30
+ const base = newFetchHttpClient();
31
+ let client: HttpClient = new AuthHttpClient(base, credentials);
32
+
33
+ if (opts.timeout !== undefined) {
34
+ client = new TimeoutHttpClient(client, opts.timeout);
35
+ }
36
+
37
+ return client;
38
+ }
39
+
40
+ /** Wraps an HttpClient and adds authentication headers to requests. */
41
+ class AuthHttpClient implements HttpClient {
42
+ constructor(
43
+ private readonly base: HttpClient,
44
+ private readonly credentials: Credentials
45
+ ) {}
46
+
47
+ async send(request: HttpRequest): Promise<HttpResponse> {
48
+ const authHeaders = await this.credentials.authHeaders();
49
+ // Do not modify the original request.
50
+ const headers = new Headers(request.headers);
51
+ for (const h of authHeaders) {
52
+ headers.set(h.key, h.value);
53
+ }
54
+ return this.base.send({...request, headers});
55
+ }
56
+ }
57
+
58
+ /** Wraps an HttpClient and applies a default timeout to requests. */
59
+ class TimeoutHttpClient implements HttpClient {
60
+ constructor(
61
+ private readonly base: HttpClient,
62
+ private readonly timeout: number
63
+ ) {}
64
+
65
+ async send(request: HttpRequest): Promise<HttpResponse> {
66
+ const timeoutSignal = AbortSignal.timeout(this.timeout);
67
+ const signal =
68
+ request.signal !== undefined
69
+ ? AbortSignal.any([request.signal, timeoutSignal])
70
+ : timeoutSignal;
71
+ return this.base.send({...request, signal});
72
+ }
73
+ }