@databricks/sdk-postgres 0.2.0 → 0.3.0

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/dist/v1/client.js CHANGED
@@ -6,7 +6,7 @@ import { resolveClientConfig } from './transport';
6
6
  import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, executeWait, StillRunningError, } from './utils';
7
7
  import pkgJson from '../../package.json' with { type: 'json' };
8
8
  import { z } from 'zod';
9
- import { marshalBranchSchema, marshalCatalogSchema, marshalDatabaseSchema, marshalEndpointSchema, marshalGenerateDatabaseCredentialRequestSchema, marshalProjectSchema, marshalRoleSchema, marshalSyncedTableSchema, marshalUndeleteBranchRequestSchema, marshalUndeleteProjectRequestSchema, unmarshalBranchOperationMetadataSchema, unmarshalBranchSchema, unmarshalCatalogOperationMetadataSchema, unmarshalCatalogSchema, unmarshalDatabaseCredentialSchema, unmarshalDatabaseOperationMetadataSchema, unmarshalDatabaseSchema, unmarshalEndpointOperationMetadataSchema, unmarshalEndpointSchema, unmarshalListBranchesResponseSchema, unmarshalListDatabasesResponseSchema, unmarshalListEndpointsResponseSchema, unmarshalListProjectsResponseSchema, unmarshalListRolesResponseSchema, unmarshalOperationSchema, unmarshalProjectOperationMetadataSchema, unmarshalProjectSchema, unmarshalRoleOperationMetadataSchema, unmarshalRoleSchema, unmarshalSyncedTableOperationMetadataSchema, unmarshalSyncedTableSchema, } from './model';
9
+ import { marshalBranchSchema, marshalCatalogSchema, marshalDataApiSchema, marshalDatabaseSchema, marshalEndpointSchema, marshalGenerateDatabaseCredentialRequestSchema, marshalProjectSchema, marshalRoleSchema, marshalSyncedTableSchema, marshalUndeleteBranchRequestSchema, marshalUndeleteProjectRequestSchema, unmarshalBranchOperationMetadataSchema, unmarshalBranchSchema, unmarshalCatalogOperationMetadataSchema, unmarshalCatalogSchema, unmarshalDataApiOperationMetadataSchema, unmarshalDataApiSchema, unmarshalDatabaseCredentialSchema, unmarshalDatabaseOperationMetadataSchema, unmarshalDatabaseSchema, unmarshalEndpointOperationMetadataSchema, unmarshalEndpointSchema, unmarshalListBranchesResponseSchema, unmarshalListDatabasesResponseSchema, unmarshalListEndpointsResponseSchema, unmarshalListProjectsResponseSchema, unmarshalListRolesResponseSchema, unmarshalOperationSchema, unmarshalProjectOperationMetadataSchema, unmarshalProjectSchema, unmarshalRoleOperationMetadataSchema, unmarshalRoleSchema, unmarshalSyncedTableOperationMetadataSchema, unmarshalSyncedTableSchema, } from './model';
10
10
  // Package identity segment for this client to be used in the User-Agent header.
11
11
  const PACKAGE_SEGMENT = {
12
12
  key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
@@ -54,7 +54,7 @@ export class PostgresClient {
54
54
  const call = async (callSignal) => {
55
55
  const headers = new Headers({ 'Content-Type': 'application/json' });
56
56
  if (workspaceId !== undefined) {
57
- headers.set('X-Databricks-Org-Id', workspaceId);
57
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
58
58
  }
59
59
  headers.set('User-Agent', this.userAgent);
60
60
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -91,7 +91,7 @@ export class PostgresClient {
91
91
  const call = async (callSignal) => {
92
92
  const headers = new Headers({ 'Content-Type': 'application/json' });
93
93
  if (workspaceId !== undefined) {
94
- headers.set('X-Databricks-Org-Id', workspaceId);
94
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
95
95
  }
96
96
  headers.set('User-Agent', this.userAgent);
97
97
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -113,6 +113,37 @@ export class PostgresClient {
113
113
  const op = await this.createCatalogBase(req, options);
114
114
  return new CreateCatalogOperation(op, (req, options) => this.getOperation(req, options));
115
115
  }
116
+ /** Enable Data API for a database. */
117
+ async createDataApiBase(req, options) {
118
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
119
+ const url = `${host}/api/2.0/postgres/${req.parent ?? ''}/data-api`;
120
+ const body = marshalRequest(req.dataApi, marshalDataApiSchema);
121
+ let resp;
122
+ const call = async (callSignal) => {
123
+ const headers = new Headers({ 'Content-Type': 'application/json' });
124
+ if (workspaceId !== undefined) {
125
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
126
+ }
127
+ headers.set('User-Agent', this.userAgent);
128
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
129
+ const respBody = await executeHttpCall({
130
+ request: httpReq,
131
+ httpClient,
132
+ logger: this.logger,
133
+ });
134
+ resp = parseResponse(respBody, unmarshalOperationSchema);
135
+ };
136
+ await executeCall(call, options);
137
+ if (resp === undefined) {
138
+ throw new Error('operation completed without a result.');
139
+ }
140
+ return resp;
141
+ }
142
+ /** Enable Data API for a database. */
143
+ async createDataApi(req, options) {
144
+ const op = await this.createDataApiBase(req, options);
145
+ return new CreateDataApiOperation(op, (req, options) => this.getOperation(req, options));
146
+ }
116
147
  /**
117
148
  * Create a Database.
118
149
  *
@@ -132,7 +163,7 @@ export class PostgresClient {
132
163
  const call = async (callSignal) => {
133
164
  const headers = new Headers({ 'Content-Type': 'application/json' });
134
165
  if (workspaceId !== undefined) {
135
- headers.set('X-Databricks-Org-Id', workspaceId);
166
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
136
167
  }
137
168
  headers.set('User-Agent', this.userAgent);
138
169
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -176,7 +207,7 @@ export class PostgresClient {
176
207
  const call = async (callSignal) => {
177
208
  const headers = new Headers({ 'Content-Type': 'application/json' });
178
209
  if (workspaceId !== undefined) {
179
- headers.set('X-Databricks-Org-Id', workspaceId);
210
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
180
211
  }
181
212
  headers.set('User-Agent', this.userAgent);
182
213
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -213,7 +244,7 @@ export class PostgresClient {
213
244
  const call = async (callSignal) => {
214
245
  const headers = new Headers({ 'Content-Type': 'application/json' });
215
246
  if (workspaceId !== undefined) {
216
- headers.set('X-Databricks-Org-Id', workspaceId);
247
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
217
248
  }
218
249
  headers.set('User-Agent', this.userAgent);
219
250
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -250,7 +281,7 @@ export class PostgresClient {
250
281
  const call = async (callSignal) => {
251
282
  const headers = new Headers({ 'Content-Type': 'application/json' });
252
283
  if (workspaceId !== undefined) {
253
- headers.set('X-Databricks-Org-Id', workspaceId);
284
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
254
285
  }
255
286
  headers.set('User-Agent', this.userAgent);
256
287
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -287,7 +318,7 @@ export class PostgresClient {
287
318
  const call = async (callSignal) => {
288
319
  const headers = new Headers({ 'Content-Type': 'application/json' });
289
320
  if (workspaceId !== undefined) {
290
- headers.set('X-Databricks-Org-Id', workspaceId);
321
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
291
322
  }
292
323
  headers.set('User-Agent', this.userAgent);
293
324
  const httpReq = buildHttpRequest('POST', fullUrl, headers, callSignal, body);
@@ -323,7 +354,7 @@ export class PostgresClient {
323
354
  const call = async (callSignal) => {
324
355
  const headers = new Headers();
325
356
  if (workspaceId !== undefined) {
326
- headers.set('X-Databricks-Org-Id', workspaceId);
357
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
327
358
  }
328
359
  headers.set('User-Agent', this.userAgent);
329
360
  const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
@@ -353,7 +384,7 @@ export class PostgresClient {
353
384
  const call = async (callSignal) => {
354
385
  const headers = new Headers();
355
386
  if (workspaceId !== undefined) {
356
- headers.set('X-Databricks-Org-Id', workspaceId);
387
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
357
388
  }
358
389
  headers.set('User-Agent', this.userAgent);
359
390
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
@@ -375,6 +406,36 @@ export class PostgresClient {
375
406
  const op = await this.deleteCatalogBase(req, options);
376
407
  return new DeleteCatalogOperation(op, (req, options) => this.getOperation(req, options));
377
408
  }
409
+ /** Disable Data API for a database. */
410
+ async deleteDataApiBase(req, options) {
411
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
412
+ const url = `${host}/api/2.0/postgres/${req.name ?? ''}`;
413
+ let resp;
414
+ const call = async (callSignal) => {
415
+ const headers = new Headers();
416
+ if (workspaceId !== undefined) {
417
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
418
+ }
419
+ headers.set('User-Agent', this.userAgent);
420
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
421
+ const respBody = await executeHttpCall({
422
+ request: httpReq,
423
+ httpClient,
424
+ logger: this.logger,
425
+ });
426
+ resp = parseResponse(respBody, unmarshalOperationSchema);
427
+ };
428
+ await executeCall(call, options);
429
+ if (resp === undefined) {
430
+ throw new Error('operation completed without a result.');
431
+ }
432
+ return resp;
433
+ }
434
+ /** Disable Data API for a database. */
435
+ async deleteDataApi(req, options) {
436
+ const op = await this.deleteDataApiBase(req, options);
437
+ return new DeleteDataApiOperation(op, (req, options) => this.getOperation(req, options));
438
+ }
378
439
  /** Delete a Database. */
379
440
  async deleteDatabaseBase(req, options) {
380
441
  const { host, workspaceId, httpClient } = await this.resolveConfig();
@@ -383,7 +444,7 @@ export class PostgresClient {
383
444
  const call = async (callSignal) => {
384
445
  const headers = new Headers();
385
446
  if (workspaceId !== undefined) {
386
- headers.set('X-Databricks-Org-Id', workspaceId);
447
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
387
448
  }
388
449
  headers.set('User-Agent', this.userAgent);
389
450
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
@@ -413,7 +474,7 @@ export class PostgresClient {
413
474
  const call = async (callSignal) => {
414
475
  const headers = new Headers();
415
476
  if (workspaceId !== undefined) {
416
- headers.set('X-Databricks-Org-Id', workspaceId);
477
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
417
478
  }
418
479
  headers.set('User-Agent', this.userAgent);
419
480
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
@@ -449,7 +510,7 @@ export class PostgresClient {
449
510
  const call = async (callSignal) => {
450
511
  const headers = new Headers();
451
512
  if (workspaceId !== undefined) {
452
- headers.set('X-Databricks-Org-Id', workspaceId);
513
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
453
514
  }
454
515
  headers.set('User-Agent', this.userAgent);
455
516
  const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
@@ -485,7 +546,7 @@ export class PostgresClient {
485
546
  const call = async (callSignal) => {
486
547
  const headers = new Headers();
487
548
  if (workspaceId !== undefined) {
488
- headers.set('X-Databricks-Org-Id', workspaceId);
549
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
489
550
  }
490
551
  headers.set('User-Agent', this.userAgent);
491
552
  const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
@@ -515,7 +576,7 @@ export class PostgresClient {
515
576
  const call = async (callSignal) => {
516
577
  const headers = new Headers();
517
578
  if (workspaceId !== undefined) {
518
- headers.set('X-Databricks-Org-Id', workspaceId);
579
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
519
580
  }
520
581
  headers.set('User-Agent', this.userAgent);
521
582
  const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
@@ -546,7 +607,7 @@ export class PostgresClient {
546
607
  const call = async (callSignal) => {
547
608
  const headers = new Headers({ 'Content-Type': 'application/json' });
548
609
  if (workspaceId !== undefined) {
549
- headers.set('X-Databricks-Org-Id', workspaceId);
610
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
550
611
  }
551
612
  headers.set('User-Agent', this.userAgent);
552
613
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
@@ -571,7 +632,7 @@ export class PostgresClient {
571
632
  const call = async (callSignal) => {
572
633
  const headers = new Headers();
573
634
  if (workspaceId !== undefined) {
574
- headers.set('X-Databricks-Org-Id', workspaceId);
635
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
575
636
  }
576
637
  headers.set('User-Agent', this.userAgent);
577
638
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -596,7 +657,7 @@ export class PostgresClient {
596
657
  const call = async (callSignal) => {
597
658
  const headers = new Headers();
598
659
  if (workspaceId !== undefined) {
599
- headers.set('X-Databricks-Org-Id', workspaceId);
660
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
600
661
  }
601
662
  headers.set('User-Agent', this.userAgent);
602
663
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -613,6 +674,31 @@ export class PostgresClient {
613
674
  }
614
675
  return resp;
615
676
  }
677
+ /** Get Data API configuration for a database. */
678
+ async getDataApi(req, options) {
679
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
680
+ const url = `${host}/api/2.0/postgres/${req.name ?? ''}`;
681
+ let resp;
682
+ const call = async (callSignal) => {
683
+ const headers = new Headers();
684
+ if (workspaceId !== undefined) {
685
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
686
+ }
687
+ headers.set('User-Agent', this.userAgent);
688
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
689
+ const respBody = await executeHttpCall({
690
+ request: httpReq,
691
+ httpClient,
692
+ logger: this.logger,
693
+ });
694
+ resp = parseResponse(respBody, unmarshalDataApiSchema);
695
+ };
696
+ await executeCall(call, options);
697
+ if (resp === undefined) {
698
+ throw new Error('operation completed without a result.');
699
+ }
700
+ return resp;
701
+ }
616
702
  /** Get a Database. */
617
703
  async getDatabase(req, options) {
618
704
  const { host, workspaceId, httpClient } = await this.resolveConfig();
@@ -621,7 +707,7 @@ export class PostgresClient {
621
707
  const call = async (callSignal) => {
622
708
  const headers = new Headers();
623
709
  if (workspaceId !== undefined) {
624
- headers.set('X-Databricks-Org-Id', workspaceId);
710
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
625
711
  }
626
712
  headers.set('User-Agent', this.userAgent);
627
713
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -646,7 +732,7 @@ export class PostgresClient {
646
732
  const call = async (callSignal) => {
647
733
  const headers = new Headers();
648
734
  if (workspaceId !== undefined) {
649
- headers.set('X-Databricks-Org-Id', workspaceId);
735
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
650
736
  }
651
737
  headers.set('User-Agent', this.userAgent);
652
738
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -671,7 +757,7 @@ export class PostgresClient {
671
757
  const call = async (callSignal) => {
672
758
  const headers = new Headers();
673
759
  if (workspaceId !== undefined) {
674
- headers.set('X-Databricks-Org-Id', workspaceId);
760
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
675
761
  }
676
762
  headers.set('User-Agent', this.userAgent);
677
763
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -696,7 +782,7 @@ export class PostgresClient {
696
782
  const call = async (callSignal) => {
697
783
  const headers = new Headers();
698
784
  if (workspaceId !== undefined) {
699
- headers.set('X-Databricks-Org-Id', workspaceId);
785
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
700
786
  }
701
787
  headers.set('User-Agent', this.userAgent);
702
788
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -721,7 +807,7 @@ export class PostgresClient {
721
807
  const call = async (callSignal) => {
722
808
  const headers = new Headers();
723
809
  if (workspaceId !== undefined) {
724
- headers.set('X-Databricks-Org-Id', workspaceId);
810
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
725
811
  }
726
812
  headers.set('User-Agent', this.userAgent);
727
813
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -746,7 +832,7 @@ export class PostgresClient {
746
832
  const call = async (callSignal) => {
747
833
  const headers = new Headers();
748
834
  if (workspaceId !== undefined) {
749
- headers.set('X-Databricks-Org-Id', workspaceId);
835
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
750
836
  }
751
837
  headers.set('User-Agent', this.userAgent);
752
838
  const httpReq = buildHttpRequest('GET', url, headers, callSignal);
@@ -783,7 +869,7 @@ export class PostgresClient {
783
869
  const call = async (callSignal) => {
784
870
  const headers = new Headers();
785
871
  if (workspaceId !== undefined) {
786
- headers.set('X-Databricks-Org-Id', workspaceId);
872
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
787
873
  }
788
874
  headers.set('User-Agent', this.userAgent);
789
875
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
@@ -830,7 +916,7 @@ export class PostgresClient {
830
916
  const call = async (callSignal) => {
831
917
  const headers = new Headers();
832
918
  if (workspaceId !== undefined) {
833
- headers.set('X-Databricks-Org-Id', workspaceId);
919
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
834
920
  }
835
921
  headers.set('User-Agent', this.userAgent);
836
922
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
@@ -877,7 +963,7 @@ export class PostgresClient {
877
963
  const call = async (callSignal) => {
878
964
  const headers = new Headers();
879
965
  if (workspaceId !== undefined) {
880
- headers.set('X-Databricks-Org-Id', workspaceId);
966
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
881
967
  }
882
968
  headers.set('User-Agent', this.userAgent);
883
969
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
@@ -927,7 +1013,7 @@ export class PostgresClient {
927
1013
  const call = async (callSignal) => {
928
1014
  const headers = new Headers();
929
1015
  if (workspaceId !== undefined) {
930
- headers.set('X-Databricks-Org-Id', workspaceId);
1016
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
931
1017
  }
932
1018
  headers.set('User-Agent', this.userAgent);
933
1019
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
@@ -974,7 +1060,7 @@ export class PostgresClient {
974
1060
  const call = async (callSignal) => {
975
1061
  const headers = new Headers();
976
1062
  if (workspaceId !== undefined) {
977
- headers.set('X-Databricks-Org-Id', workspaceId);
1063
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
978
1064
  }
979
1065
  headers.set('User-Agent', this.userAgent);
980
1066
  const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
@@ -1013,7 +1099,7 @@ export class PostgresClient {
1013
1099
  const call = async (callSignal) => {
1014
1100
  const headers = new Headers({ 'Content-Type': 'application/json' });
1015
1101
  if (workspaceId !== undefined) {
1016
- headers.set('X-Databricks-Org-Id', workspaceId);
1102
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1017
1103
  }
1018
1104
  headers.set('User-Agent', this.userAgent);
1019
1105
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
@@ -1044,7 +1130,7 @@ export class PostgresClient {
1044
1130
  const call = async (callSignal) => {
1045
1131
  const headers = new Headers({ 'Content-Type': 'application/json' });
1046
1132
  if (workspaceId !== undefined) {
1047
- headers.set('X-Databricks-Org-Id', workspaceId);
1133
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1048
1134
  }
1049
1135
  headers.set('User-Agent', this.userAgent);
1050
1136
  const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
@@ -1081,7 +1167,7 @@ export class PostgresClient {
1081
1167
  const call = async (callSignal) => {
1082
1168
  const headers = new Headers({ 'Content-Type': 'application/json' });
1083
1169
  if (workspaceId !== undefined) {
1084
- headers.set('X-Databricks-Org-Id', workspaceId);
1170
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1085
1171
  }
1086
1172
  headers.set('User-Agent', this.userAgent);
1087
1173
  const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
@@ -1103,6 +1189,43 @@ export class PostgresClient {
1103
1189
  const op = await this.updateBranchBase(req, options);
1104
1190
  return new UpdateBranchOperation(op, (req, options) => this.getOperation(req, options));
1105
1191
  }
1192
+ /** Update Data API configuration for a database. */
1193
+ async updateDataApiBase(req, options) {
1194
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
1195
+ const url = `${host}/api/2.0/postgres/${req.dataApi?.name ?? ''}`;
1196
+ const params = new URLSearchParams();
1197
+ if (req.updateMask !== undefined) {
1198
+ params.append('update_mask', req.updateMask.toString());
1199
+ }
1200
+ const query = params.toString();
1201
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
1202
+ const body = marshalRequest(req.dataApi, marshalDataApiSchema);
1203
+ let resp;
1204
+ const call = async (callSignal) => {
1205
+ const headers = new Headers({ 'Content-Type': 'application/json' });
1206
+ if (workspaceId !== undefined) {
1207
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1208
+ }
1209
+ headers.set('User-Agent', this.userAgent);
1210
+ const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
1211
+ const respBody = await executeHttpCall({
1212
+ request: httpReq,
1213
+ httpClient,
1214
+ logger: this.logger,
1215
+ });
1216
+ resp = parseResponse(respBody, unmarshalOperationSchema);
1217
+ };
1218
+ await executeCall(call, options);
1219
+ if (resp === undefined) {
1220
+ throw new Error('operation completed without a result.');
1221
+ }
1222
+ return resp;
1223
+ }
1224
+ /** Update Data API configuration for a database. */
1225
+ async updateDataApi(req, options) {
1226
+ const op = await this.updateDataApiBase(req, options);
1227
+ return new UpdateDataApiOperation(op, (req, options) => this.getOperation(req, options));
1228
+ }
1106
1229
  /** Update a Database. */
1107
1230
  async updateDatabaseBase(req, options) {
1108
1231
  const { host, workspaceId, httpClient } = await this.resolveConfig();
@@ -1118,7 +1241,7 @@ export class PostgresClient {
1118
1241
  const call = async (callSignal) => {
1119
1242
  const headers = new Headers({ 'Content-Type': 'application/json' });
1120
1243
  if (workspaceId !== undefined) {
1121
- headers.set('X-Databricks-Org-Id', workspaceId);
1244
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1122
1245
  }
1123
1246
  headers.set('User-Agent', this.userAgent);
1124
1247
  const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
@@ -1155,7 +1278,7 @@ export class PostgresClient {
1155
1278
  const call = async (callSignal) => {
1156
1279
  const headers = new Headers({ 'Content-Type': 'application/json' });
1157
1280
  if (workspaceId !== undefined) {
1158
- headers.set('X-Databricks-Org-Id', workspaceId);
1281
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1159
1282
  }
1160
1283
  headers.set('User-Agent', this.userAgent);
1161
1284
  const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
@@ -1192,7 +1315,7 @@ export class PostgresClient {
1192
1315
  const call = async (callSignal) => {
1193
1316
  const headers = new Headers({ 'Content-Type': 'application/json' });
1194
1317
  if (workspaceId !== undefined) {
1195
- headers.set('X-Databricks-Org-Id', workspaceId);
1318
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1196
1319
  }
1197
1320
  headers.set('User-Agent', this.userAgent);
1198
1321
  const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
@@ -1229,7 +1352,7 @@ export class PostgresClient {
1229
1352
  const call = async (callSignal) => {
1230
1353
  const headers = new Headers({ 'Content-Type': 'application/json' });
1231
1354
  if (workspaceId !== undefined) {
1232
- headers.set('X-Databricks-Org-Id', workspaceId);
1355
+ headers.set('X-Databricks-Workspace-Id', workspaceId);
1233
1356
  }
1234
1357
  headers.set('User-Agent', this.userAgent);
1235
1358
  const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
@@ -1384,6 +1507,72 @@ export class CreateCatalogOperation {
1384
1507
  return op.done;
1385
1508
  }
1386
1509
  }
1510
+ export class CreateDataApiOperation {
1511
+ operation;
1512
+ getOperation;
1513
+ constructor(operation, getOperation) {
1514
+ this.operation = operation;
1515
+ this.getOperation = getOperation;
1516
+ }
1517
+ /** Returns the server-assigned name of the long-running operation. */
1518
+ name() {
1519
+ return Promise.resolve(this.operation.name);
1520
+ }
1521
+ /** Returns metadata associated with the long-running operation. */
1522
+ metadata() {
1523
+ if (this.operation.metadata === undefined) {
1524
+ return Promise.resolve(undefined);
1525
+ }
1526
+ return Promise.resolve(z
1527
+ .lazy(() => unmarshalDataApiOperationMetadataSchema)
1528
+ .parse(this.operation.metadata));
1529
+ }
1530
+ /**
1531
+ * Polls the operation until it completes.
1532
+ *
1533
+ * Throws if the operation failed.
1534
+ */
1535
+ async wait(options) {
1536
+ let result;
1537
+ const call = async (callSignal) => {
1538
+ const op = await this.getOperation({
1539
+ name: this.operation.name,
1540
+ }, callSignal !== undefined ? { signal: callSignal } : undefined);
1541
+ this.operation = op;
1542
+ if (op.done === undefined) {
1543
+ throw new Error('operation is missing the done field');
1544
+ }
1545
+ if (!op.done) {
1546
+ throw new StillRunningError();
1547
+ }
1548
+ if (op.result?.$case === 'error') {
1549
+ const err = op.result.error;
1550
+ const msg = err.message !== undefined && err.message !== ''
1551
+ ? err.message
1552
+ : 'unknown error';
1553
+ const errorMsg = err.errorCode !== undefined ? `[${err.errorCode}] ${msg}` : msg;
1554
+ throw new Error(`operation failed: ${errorMsg}`, {
1555
+ cause: err,
1556
+ });
1557
+ }
1558
+ if (op.result?.$case !== 'response') {
1559
+ throw new Error('operation completed without a response');
1560
+ }
1561
+ result = z.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
1562
+ };
1563
+ await executeWait(call, options);
1564
+ if (result === undefined) {
1565
+ throw new Error('operation completed without a result.');
1566
+ }
1567
+ return result;
1568
+ }
1569
+ /** Checks whether the operation has completed */
1570
+ async done(options) {
1571
+ const op = await this.getOperation({ name: this.operation.name }, options);
1572
+ this.operation = op;
1573
+ return op.done;
1574
+ }
1575
+ }
1387
1576
  export class CreateDatabaseOperation {
1388
1577
  operation;
1389
1578
  getOperation;
@@ -1830,6 +2019,63 @@ export class DeleteCatalogOperation {
1830
2019
  return op.done;
1831
2020
  }
1832
2021
  }
2022
+ export class DeleteDataApiOperation {
2023
+ operation;
2024
+ getOperation;
2025
+ constructor(operation, getOperation) {
2026
+ this.operation = operation;
2027
+ this.getOperation = getOperation;
2028
+ }
2029
+ /** Returns the server-assigned name of the long-running operation. */
2030
+ name() {
2031
+ return Promise.resolve(this.operation.name);
2032
+ }
2033
+ /** Returns metadata associated with the long-running operation. */
2034
+ metadata() {
2035
+ if (this.operation.metadata === undefined) {
2036
+ return Promise.resolve(undefined);
2037
+ }
2038
+ return Promise.resolve(z
2039
+ .lazy(() => unmarshalDataApiOperationMetadataSchema)
2040
+ .parse(this.operation.metadata));
2041
+ }
2042
+ /**
2043
+ * Polls the operation until it completes.
2044
+ *
2045
+ * Throws if the operation failed.
2046
+ */
2047
+ async wait(options) {
2048
+ const call = async (callSignal) => {
2049
+ const op = await this.getOperation({
2050
+ name: this.operation.name,
2051
+ }, callSignal !== undefined ? { signal: callSignal } : undefined);
2052
+ this.operation = op;
2053
+ if (op.done === undefined) {
2054
+ throw new Error('operation is missing the done field');
2055
+ }
2056
+ if (!op.done) {
2057
+ throw new StillRunningError();
2058
+ }
2059
+ if (op.result?.$case === 'error') {
2060
+ const err = op.result.error;
2061
+ const msg = err.message !== undefined && err.message !== ''
2062
+ ? err.message
2063
+ : 'unknown error';
2064
+ const errorMsg = err.errorCode !== undefined ? `[${err.errorCode}] ${msg}` : msg;
2065
+ throw new Error(`operation failed: ${errorMsg}`, {
2066
+ cause: err,
2067
+ });
2068
+ }
2069
+ };
2070
+ await executeWait(call, options);
2071
+ }
2072
+ /** Checks whether the operation has completed */
2073
+ async done(options) {
2074
+ const op = await this.getOperation({ name: this.operation.name }, options);
2075
+ this.operation = op;
2076
+ return op.done;
2077
+ }
2078
+ }
1833
2079
  export class DeleteDatabaseOperation {
1834
2080
  operation;
1835
2081
  getOperation;
@@ -2295,6 +2541,72 @@ export class UpdateBranchOperation {
2295
2541
  return op.done;
2296
2542
  }
2297
2543
  }
2544
+ export class UpdateDataApiOperation {
2545
+ operation;
2546
+ getOperation;
2547
+ constructor(operation, getOperation) {
2548
+ this.operation = operation;
2549
+ this.getOperation = getOperation;
2550
+ }
2551
+ /** Returns the server-assigned name of the long-running operation. */
2552
+ name() {
2553
+ return Promise.resolve(this.operation.name);
2554
+ }
2555
+ /** Returns metadata associated with the long-running operation. */
2556
+ metadata() {
2557
+ if (this.operation.metadata === undefined) {
2558
+ return Promise.resolve(undefined);
2559
+ }
2560
+ return Promise.resolve(z
2561
+ .lazy(() => unmarshalDataApiOperationMetadataSchema)
2562
+ .parse(this.operation.metadata));
2563
+ }
2564
+ /**
2565
+ * Polls the operation until it completes.
2566
+ *
2567
+ * Throws if the operation failed.
2568
+ */
2569
+ async wait(options) {
2570
+ let result;
2571
+ const call = async (callSignal) => {
2572
+ const op = await this.getOperation({
2573
+ name: this.operation.name,
2574
+ }, callSignal !== undefined ? { signal: callSignal } : undefined);
2575
+ this.operation = op;
2576
+ if (op.done === undefined) {
2577
+ throw new Error('operation is missing the done field');
2578
+ }
2579
+ if (!op.done) {
2580
+ throw new StillRunningError();
2581
+ }
2582
+ if (op.result?.$case === 'error') {
2583
+ const err = op.result.error;
2584
+ const msg = err.message !== undefined && err.message !== ''
2585
+ ? err.message
2586
+ : 'unknown error';
2587
+ const errorMsg = err.errorCode !== undefined ? `[${err.errorCode}] ${msg}` : msg;
2588
+ throw new Error(`operation failed: ${errorMsg}`, {
2589
+ cause: err,
2590
+ });
2591
+ }
2592
+ if (op.result?.$case !== 'response') {
2593
+ throw new Error('operation completed without a response');
2594
+ }
2595
+ result = z.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
2596
+ };
2597
+ await executeWait(call, options);
2598
+ if (result === undefined) {
2599
+ throw new Error('operation completed without a result.');
2600
+ }
2601
+ return result;
2602
+ }
2603
+ /** Checks whether the operation has completed */
2604
+ async done(options) {
2605
+ const op = await this.getOperation({ name: this.operation.name }, options);
2606
+ this.operation = op;
2607
+ return op.done;
2608
+ }
2609
+ }
2298
2610
  export class UpdateDatabaseOperation {
2299
2611
  operation;
2300
2612
  getOperation;