@databricks/sdk-uc-metastores 0.27.0 → 0.35.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
@@ -1,590 +1,475 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
- import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
3
- import { createDefault } from '@databricks/sdk-core/clientinfo';
4
- import { NoOpLogger } from '@databricks/sdk-core/logger';
5
- import { resolveClientConfig } from './transport';
6
- import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
7
- import pkgJson from '../../package.json' with { type: 'json' };
8
- import { marshalAccountsCreateMetastoreAssignmentRequestSchema, marshalAccountsCreateMetastoreRequestSchema, marshalAccountsUpdateMetastoreAssignmentRequestSchema, marshalAccountsUpdateMetastoreRequestSchema, marshalCreateMetastoreAssignmentRequestSchema, marshalCreateMetastoreRequestSchema, marshalUpdateMetastoreAssignmentRequestSchema, marshalUpdateMetastoreRequestSchema, unmarshalAccountsCreateMetastoreAssignmentResponseSchema, unmarshalAccountsCreateMetastoreResponseSchema, unmarshalAccountsDeleteMetastoreAssignmentResponseSchema, unmarshalAccountsDeleteMetastoreResponseSchema, unmarshalAccountsGetMetastoreAssignmentResponseSchema, unmarshalAccountsGetMetastoreResponseSchema, unmarshalAccountsListMetastoresResponseSchema, unmarshalAccountsListWorkspaceIdsForMetastoreResponseSchema, unmarshalAccountsUpdateMetastoreAssignmentResponseSchema, unmarshalAccountsUpdateMetastoreResponseSchema, unmarshalCreateMetastoreAssignmentResponseSchema, unmarshalDeleteMetastoreAssignmentResponseSchema, unmarshalDeleteMetastoreResponseSchema, unmarshalGetMetastoreSummaryResponseSchema, unmarshalListMetastoresResponseSchema, unmarshalMetastoreAssignmentSchema, unmarshalMetastoreInfoSchema, unmarshalUpdateMetastoreAssignmentResponseSchema, } from './model';
9
- // Package identity segment for this client to be used in the User-Agent header.
1
+ import { resolveClientConfig } from "./transport.js";
2
+ import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalAccountsCreateMetastoreAssignmentRequestSchema, marshalAccountsCreateMetastoreRequestSchema, marshalAccountsUpdateMetastoreAssignmentRequestSchema, marshalAccountsUpdateMetastoreRequestSchema, marshalCreateMetastoreAssignmentRequestSchema, marshalCreateMetastoreRequestSchema, marshalUpdateMetastoreAssignmentRequestSchema, marshalUpdateMetastoreRequestSchema, unmarshalAccountsCreateMetastoreAssignmentResponseSchema, unmarshalAccountsCreateMetastoreResponseSchema, unmarshalAccountsDeleteMetastoreAssignmentResponseSchema, unmarshalAccountsDeleteMetastoreResponseSchema, unmarshalAccountsGetMetastoreAssignmentResponseSchema, unmarshalAccountsGetMetastoreResponseSchema, unmarshalAccountsListMetastoresResponseSchema, unmarshalAccountsListWorkspaceIdsForMetastoreResponseSchema, unmarshalAccountsUpdateMetastoreAssignmentResponseSchema, unmarshalAccountsUpdateMetastoreResponseSchema, unmarshalCreateMetastoreAssignmentResponseSchema, unmarshalDeleteMetastoreAssignmentResponseSchema, unmarshalDeleteMetastoreResponseSchema, unmarshalGetMetastoreSummaryResponseSchema, unmarshalListMetastoresResponseSchema, unmarshalMetastoreAssignmentSchema, unmarshalMetastoreInfoSchema, unmarshalUpdateMetastoreAssignmentResponseSchema } from "./model.js";
5
+ import { VERSION } from "@databricks/sdk-auth";
6
+ import { createDefault } from "@databricks/sdk-core/clientinfo";
7
+ import { NoOpLogger } from "@databricks/sdk-core/logger";
8
+
9
+ //#region src/v1/client.ts
10
10
  const PACKAGE_SEGMENT = {
11
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
12
- value: pkgJson.version,
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
13
  };
14
- export class MetastoresClient {
15
- options;
16
- logger;
17
- // User-Agent header value. Composed once at construction from
18
- // createDefault() merged with this package's identity and the active
19
- // credential's name.
20
- userAgent;
21
- // Memoized configuration. The profile is resolved once, lazily, on the first
22
- // request, then reused; host, workspaceId/accountId, and credentials are
23
- // filled from it when not set explicitly on the options.
24
- config;
25
- constructor(options) {
26
- this.options = options;
27
- this.logger = options.logger ?? new NoOpLogger();
28
- const info = createDefault()
29
- .with(PACKAGE_SEGMENT)
30
- .with({ key: 'sdk-js-auth', value: AUTH_VERSION })
31
- .with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
32
- this.userAgent = info.toString();
33
- }
34
- resolveConfig() {
35
- this.config ??= resolveClientConfig(this.options);
36
- return this.config;
37
- }
38
- /** Creates a Unity Catalog metastore. */
39
- async createAccountsMetastore(req, options) {
40
- const { host, accountId, httpClient } = await this.resolveConfig();
41
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores`;
42
- const body = marshalRequest(req, marshalAccountsCreateMetastoreRequestSchema);
43
- let resp;
44
- const call = async (callSignal) => {
45
- const headers = new Headers({ 'Content-Type': 'application/json' });
46
- headers.set('User-Agent', this.userAgent);
47
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
48
- const respBody = await executeHttpCall({
49
- request: httpReq,
50
- httpClient,
51
- logger: this.logger,
52
- });
53
- resp = parseResponse(respBody, unmarshalAccountsCreateMetastoreResponseSchema);
54
- };
55
- await executeCall(call, options);
56
- if (resp === undefined) {
57
- throw new Error('operation completed without a result.');
58
- }
59
- return resp;
60
- }
61
- /** Creates an assignment to a metastore for a workspace */
62
- async createAccountsMetastoreAssignment(req, options) {
63
- const { host, accountId, httpClient } = await this.resolveConfig();
64
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/metastores/${req.metastoreId ?? ''}`;
65
- const body = marshalRequest(req, marshalAccountsCreateMetastoreAssignmentRequestSchema);
66
- let resp;
67
- const call = async (callSignal) => {
68
- const headers = new Headers({ 'Content-Type': 'application/json' });
69
- headers.set('User-Agent', this.userAgent);
70
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
71
- const respBody = await executeHttpCall({
72
- request: httpReq,
73
- httpClient,
74
- logger: this.logger,
75
- });
76
- resp = parseResponse(respBody, unmarshalAccountsCreateMetastoreAssignmentResponseSchema);
77
- };
78
- await executeCall(call, options);
79
- if (resp === undefined) {
80
- throw new Error('operation completed without a result.');
81
- }
82
- return resp;
83
- }
84
- /** Deletes a Unity Catalog metastore for an account, both specified by ID. */
85
- async deleteAccountsMetastore(req, options) {
86
- const { host, accountId, httpClient } = await this.resolveConfig();
87
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}`;
88
- const params = new URLSearchParams();
89
- if (req.force !== undefined) {
90
- params.append('force', String(req.force));
91
- }
92
- const query = params.toString();
93
- const fullUrl = query !== '' ? `${url}?${query}` : url;
94
- let resp;
95
- const call = async (callSignal) => {
96
- const headers = new Headers();
97
- headers.set('User-Agent', this.userAgent);
98
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
99
- const respBody = await executeHttpCall({
100
- request: httpReq,
101
- httpClient,
102
- logger: this.logger,
103
- });
104
- resp = parseResponse(respBody, unmarshalAccountsDeleteMetastoreResponseSchema);
105
- };
106
- await executeCall(call, options);
107
- if (resp === undefined) {
108
- throw new Error('operation completed without a result.');
109
- }
110
- return resp;
111
- }
112
- /** Deletes a metastore assignment to a workspace, leaving the workspace with no metastore. */
113
- async deleteAccountsMetastoreAssignment(req, options) {
114
- const { host, accountId, httpClient } = await this.resolveConfig();
115
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/metastores/${req.metastoreId ?? ''}`;
116
- let resp;
117
- const call = async (callSignal) => {
118
- const headers = new Headers();
119
- headers.set('User-Agent', this.userAgent);
120
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
121
- const respBody = await executeHttpCall({
122
- request: httpReq,
123
- httpClient,
124
- logger: this.logger,
125
- });
126
- resp = parseResponse(respBody, unmarshalAccountsDeleteMetastoreAssignmentResponseSchema);
127
- };
128
- await executeCall(call, options);
129
- if (resp === undefined) {
130
- throw new Error('operation completed without a result.');
131
- }
132
- return resp;
133
- }
134
- /** Gets a Unity Catalog metastore from an account, both specified by ID. */
135
- async getAccountsMetastore(req, options) {
136
- const { host, accountId, httpClient } = await this.resolveConfig();
137
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}`;
138
- let resp;
139
- const call = async (callSignal) => {
140
- const headers = new Headers();
141
- headers.set('User-Agent', this.userAgent);
142
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
143
- const respBody = await executeHttpCall({
144
- request: httpReq,
145
- httpClient,
146
- logger: this.logger,
147
- });
148
- resp = parseResponse(respBody, unmarshalAccountsGetMetastoreResponseSchema);
149
- };
150
- await executeCall(call, options);
151
- if (resp === undefined) {
152
- throw new Error('operation completed without a result.');
153
- }
154
- return resp;
155
- }
156
- /**
157
- * Gets the metastore assignment, if any, for the workspace specified by ID.
158
- * If the workspace is assigned a metastore, the mapping will be returned.
159
- * If no metastore is assigned to the workspace, the assignment will not be
160
- * found and a 404 returned.
161
- */
162
- async getMetastoreAssignment(req, options) {
163
- const { host, accountId, httpClient } = await this.resolveConfig();
164
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/metastore`;
165
- let resp;
166
- const call = async (callSignal) => {
167
- const headers = new Headers();
168
- headers.set('User-Agent', this.userAgent);
169
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
170
- const respBody = await executeHttpCall({
171
- request: httpReq,
172
- httpClient,
173
- logger: this.logger,
174
- });
175
- resp = parseResponse(respBody, unmarshalAccountsGetMetastoreAssignmentResponseSchema);
176
- };
177
- await executeCall(call, options);
178
- if (resp === undefined) {
179
- throw new Error('operation completed without a result.');
180
- }
181
- return resp;
182
- }
183
- /** Gets all Unity Catalog metastores associated with an account specified by ID. */
184
- async listAccountsMetastores(req, options) {
185
- const { host, accountId, httpClient } = await this.resolveConfig();
186
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores`;
187
- let resp;
188
- const call = async (callSignal) => {
189
- const headers = new Headers();
190
- headers.set('User-Agent', this.userAgent);
191
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
192
- const respBody = await executeHttpCall({
193
- request: httpReq,
194
- httpClient,
195
- logger: this.logger,
196
- });
197
- resp = parseResponse(respBody, unmarshalAccountsListMetastoresResponseSchema);
198
- };
199
- await executeCall(call, options);
200
- if (resp === undefined) {
201
- throw new Error('operation completed without a result.');
202
- }
203
- return resp;
204
- }
205
- /** Gets a list of all <Databricks> workspace IDs that have been assigned to given metastore. */
206
- async listMetastoreAssignments(req, options) {
207
- const { host, accountId, httpClient } = await this.resolveConfig();
208
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/workspaces`;
209
- let resp;
210
- const call = async (callSignal) => {
211
- const headers = new Headers();
212
- headers.set('User-Agent', this.userAgent);
213
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
214
- const respBody = await executeHttpCall({
215
- request: httpReq,
216
- httpClient,
217
- logger: this.logger,
218
- });
219
- resp = parseResponse(respBody, unmarshalAccountsListWorkspaceIdsForMetastoreResponseSchema);
220
- };
221
- await executeCall(call, options);
222
- if (resp === undefined) {
223
- throw new Error('operation completed without a result.');
224
- }
225
- return resp;
226
- }
227
- /** Updates an existing Unity Catalog metastore. */
228
- async updateAccountsMetastore(req, options) {
229
- const { host, accountId, httpClient } = await this.resolveConfig();
230
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}`;
231
- const body = marshalRequest(req, marshalAccountsUpdateMetastoreRequestSchema);
232
- let resp;
233
- const call = async (callSignal) => {
234
- const headers = new Headers({ 'Content-Type': 'application/json' });
235
- headers.set('User-Agent', this.userAgent);
236
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
237
- const respBody = await executeHttpCall({
238
- request: httpReq,
239
- httpClient,
240
- logger: this.logger,
241
- });
242
- resp = parseResponse(respBody, unmarshalAccountsUpdateMetastoreResponseSchema);
243
- };
244
- await executeCall(call, options);
245
- if (resp === undefined) {
246
- throw new Error('operation completed without a result.');
247
- }
248
- return resp;
249
- }
250
- /** Updates an assignment to a metastore for a workspace. Currently, only the default catalog may be updated. */
251
- async updateAccountsMetastoreAssignment(req, options) {
252
- const { host, accountId, httpClient } = await this.resolveConfig();
253
- const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/workspaces/${String(req.workspaceId ?? '')}/metastores/${req.metastoreId ?? ''}`;
254
- const body = marshalRequest(req, marshalAccountsUpdateMetastoreAssignmentRequestSchema);
255
- let resp;
256
- const call = async (callSignal) => {
257
- const headers = new Headers({ 'Content-Type': 'application/json' });
258
- headers.set('User-Agent', this.userAgent);
259
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
260
- const respBody = await executeHttpCall({
261
- request: httpReq,
262
- httpClient,
263
- logger: this.logger,
264
- });
265
- resp = parseResponse(respBody, unmarshalAccountsUpdateMetastoreAssignmentResponseSchema);
266
- };
267
- await executeCall(call, options);
268
- if (resp === undefined) {
269
- throw new Error('operation completed without a result.');
270
- }
271
- return resp;
272
- }
273
- /**
274
- * Creates a new metastore based on a provided name and optional storage root path.
275
- * By default (if the __owner__ field is not set), the owner of the new metastore is the user calling
276
- * the __createMetastore__ API. If the __owner__ field is set to the empty string (**""**), the ownership is
277
- * assigned to the System User instead.
278
- */
279
- async createMetastore(req, options) {
280
- const { host, workspaceId, httpClient } = await this.resolveConfig();
281
- const url = `${host}/api/2.1/unity-catalog/metastores`;
282
- const body = marshalRequest(req, marshalCreateMetastoreRequestSchema);
283
- let resp;
284
- const call = async (callSignal) => {
285
- const headers = new Headers({ 'Content-Type': 'application/json' });
286
- if (workspaceId !== undefined) {
287
- headers.set('X-Databricks-Workspace-Id', workspaceId);
288
- }
289
- headers.set('User-Agent', this.userAgent);
290
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
291
- const respBody = await executeHttpCall({
292
- request: httpReq,
293
- httpClient,
294
- logger: this.logger,
295
- });
296
- resp = parseResponse(respBody, unmarshalMetastoreInfoSchema);
297
- };
298
- await executeCall(call, options);
299
- if (resp === undefined) {
300
- throw new Error('operation completed without a result.');
301
- }
302
- return resp;
303
- }
304
- /**
305
- * Creates a new metastore assignment.
306
- * If an assignment for the same __workspace_id__ exists, it will be overwritten by the new __metastore_id__ and
307
- * __default_catalog_name__. The caller must be an account admin.
308
- */
309
- async createMetastoreAssignment(req, options) {
310
- const { host, workspaceId, httpClient } = await this.resolveConfig();
311
- const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`;
312
- const body = marshalRequest(req, marshalCreateMetastoreAssignmentRequestSchema);
313
- let resp;
314
- const call = async (callSignal) => {
315
- const headers = new Headers({ 'Content-Type': 'application/json' });
316
- if (workspaceId !== undefined) {
317
- headers.set('X-Databricks-Workspace-Id', workspaceId);
318
- }
319
- headers.set('User-Agent', this.userAgent);
320
- const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
321
- const respBody = await executeHttpCall({
322
- request: httpReq,
323
- httpClient,
324
- logger: this.logger,
325
- });
326
- resp = parseResponse(respBody, unmarshalCreateMetastoreAssignmentResponseSchema);
327
- };
328
- await executeCall(call, options);
329
- if (resp === undefined) {
330
- throw new Error('operation completed without a result.');
331
- }
332
- return resp;
333
- }
334
- /** Deletes a metastore. The caller must be a metastore admin. */
335
- async deleteMetastore(req, options) {
336
- const { host, workspaceId, httpClient } = await this.resolveConfig();
337
- const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`;
338
- const params = new URLSearchParams();
339
- if (req.force !== undefined) {
340
- params.append('force', String(req.force));
341
- }
342
- const query = params.toString();
343
- const fullUrl = query !== '' ? `${url}?${query}` : url;
344
- let resp;
345
- const call = async (callSignal) => {
346
- const headers = new Headers();
347
- if (workspaceId !== undefined) {
348
- headers.set('X-Databricks-Workspace-Id', workspaceId);
349
- }
350
- headers.set('User-Agent', this.userAgent);
351
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
352
- const respBody = await executeHttpCall({
353
- request: httpReq,
354
- httpClient,
355
- logger: this.logger,
356
- });
357
- resp = parseResponse(respBody, unmarshalDeleteMetastoreResponseSchema);
358
- };
359
- await executeCall(call, options);
360
- if (resp === undefined) {
361
- throw new Error('operation completed without a result.');
362
- }
363
- return resp;
364
- }
365
- /** Deletes a metastore assignment. The caller must be an account administrator. */
366
- async deleteMetastoreAssignment(req, options) {
367
- const { host, workspaceId, httpClient } = await this.resolveConfig();
368
- const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`;
369
- const params = new URLSearchParams();
370
- if (req.metastoreId !== undefined) {
371
- params.append('metastore_id', req.metastoreId);
372
- }
373
- const query = params.toString();
374
- const fullUrl = query !== '' ? `${url}?${query}` : url;
375
- let resp;
376
- const call = async (callSignal) => {
377
- const headers = new Headers();
378
- if (workspaceId !== undefined) {
379
- headers.set('X-Databricks-Workspace-Id', workspaceId);
380
- }
381
- headers.set('User-Agent', this.userAgent);
382
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
383
- const respBody = await executeHttpCall({
384
- request: httpReq,
385
- httpClient,
386
- logger: this.logger,
387
- });
388
- resp = parseResponse(respBody, unmarshalDeleteMetastoreAssignmentResponseSchema);
389
- };
390
- await executeCall(call, options);
391
- if (resp === undefined) {
392
- throw new Error('operation completed without a result.');
393
- }
394
- return resp;
395
- }
396
- /** Gets the metastore assignment for the workspace being accessed. */
397
- async getCurrentMetastoreAssignment(_req, options) {
398
- const { host, workspaceId, httpClient } = await this.resolveConfig();
399
- const url = `${host}/api/2.1/unity-catalog/current-metastore-assignment`;
400
- let resp;
401
- const call = async (callSignal) => {
402
- const headers = new Headers();
403
- if (workspaceId !== undefined) {
404
- headers.set('X-Databricks-Workspace-Id', workspaceId);
405
- }
406
- headers.set('User-Agent', this.userAgent);
407
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
408
- const respBody = await executeHttpCall({
409
- request: httpReq,
410
- httpClient,
411
- logger: this.logger,
412
- });
413
- resp = parseResponse(respBody, unmarshalMetastoreAssignmentSchema);
414
- };
415
- await executeCall(call, options);
416
- if (resp === undefined) {
417
- throw new Error('operation completed without a result.');
418
- }
419
- return resp;
420
- }
421
- /** Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this info. */
422
- async getMetastore(req, options) {
423
- const { host, workspaceId, httpClient } = await this.resolveConfig();
424
- const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`;
425
- let resp;
426
- const call = async (callSignal) => {
427
- const headers = new Headers();
428
- if (workspaceId !== undefined) {
429
- headers.set('X-Databricks-Workspace-Id', workspaceId);
430
- }
431
- headers.set('User-Agent', this.userAgent);
432
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
433
- const respBody = await executeHttpCall({
434
- request: httpReq,
435
- httpClient,
436
- logger: this.logger,
437
- });
438
- resp = parseResponse(respBody, unmarshalMetastoreInfoSchema);
439
- };
440
- await executeCall(call, options);
441
- if (resp === undefined) {
442
- throw new Error('operation completed without a result.');
443
- }
444
- return resp;
445
- }
446
- /**
447
- * Gets information about a metastore.
448
- * This summary includes the storage credential, the cloud vendor, the cloud region, and the global metastore ID.
449
- */
450
- async getMetastoreSummary(_req, options) {
451
- const { host, workspaceId, httpClient } = await this.resolveConfig();
452
- const url = `${host}/api/2.1/unity-catalog/metastore_summary`;
453
- let resp;
454
- const call = async (callSignal) => {
455
- const headers = new Headers();
456
- if (workspaceId !== undefined) {
457
- headers.set('X-Databricks-Workspace-Id', workspaceId);
458
- }
459
- headers.set('User-Agent', this.userAgent);
460
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
461
- const respBody = await executeHttpCall({
462
- request: httpReq,
463
- httpClient,
464
- logger: this.logger,
465
- });
466
- resp = parseResponse(respBody, unmarshalGetMetastoreSummaryResponseSchema);
467
- };
468
- await executeCall(call, options);
469
- if (resp === undefined) {
470
- throw new Error('operation completed without a result.');
471
- }
472
- return resp;
473
- }
474
- /**
475
- * Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin to retrieve this info.
476
- * There is no guarantee of a specific ordering of the elements in the array.
477
- *
478
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
479
- *
480
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
481
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
482
- */
483
- async listMetastores(req, options) {
484
- const { host, workspaceId, httpClient } = await this.resolveConfig();
485
- const url = `${host}/api/2.1/unity-catalog/metastores`;
486
- const params = new URLSearchParams();
487
- if (req.maxResults !== undefined) {
488
- params.append('max_results', String(req.maxResults));
489
- }
490
- if (req.pageToken !== undefined) {
491
- params.append('page_token', req.pageToken);
492
- }
493
- const query = params.toString();
494
- const fullUrl = query !== '' ? `${url}?${query}` : url;
495
- let resp;
496
- const call = async (callSignal) => {
497
- const headers = new Headers();
498
- if (workspaceId !== undefined) {
499
- headers.set('X-Databricks-Workspace-Id', workspaceId);
500
- }
501
- headers.set('User-Agent', this.userAgent);
502
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
503
- const respBody = await executeHttpCall({
504
- request: httpReq,
505
- httpClient,
506
- logger: this.logger,
507
- });
508
- resp = parseResponse(respBody, unmarshalListMetastoresResponseSchema);
509
- };
510
- await executeCall(call, options);
511
- if (resp === undefined) {
512
- throw new Error('operation completed without a result.');
513
- }
514
- return resp;
515
- }
516
- async *listMetastoresIter(req, options) {
517
- const pageReq = { ...req };
518
- for (;;) {
519
- const resp = await this.listMetastores(pageReq, options);
520
- for (const item of resp.metastores ?? []) {
521
- yield item;
522
- }
523
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
524
- return;
525
- }
526
- pageReq.pageToken = resp.nextPageToken;
527
- }
528
- }
529
- /**
530
- * Updates information for a specific metastore. The caller must be a metastore admin.
531
- * If the __owner__ field is set to the empty string (**""**), the ownership is updated
532
- * to the System User.
533
- */
534
- async updateMetastore(req, options) {
535
- const { host, workspaceId, httpClient } = await this.resolveConfig();
536
- const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`;
537
- const body = marshalRequest(req, marshalUpdateMetastoreRequestSchema);
538
- let resp;
539
- const call = async (callSignal) => {
540
- const headers = new Headers({ 'Content-Type': 'application/json' });
541
- if (workspaceId !== undefined) {
542
- headers.set('X-Databricks-Workspace-Id', workspaceId);
543
- }
544
- headers.set('User-Agent', this.userAgent);
545
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
546
- const respBody = await executeHttpCall({
547
- request: httpReq,
548
- httpClient,
549
- logger: this.logger,
550
- });
551
- resp = parseResponse(respBody, unmarshalMetastoreInfoSchema);
552
- };
553
- await executeCall(call, options);
554
- if (resp === undefined) {
555
- throw new Error('operation completed without a result.');
556
- }
557
- return resp;
558
- }
559
- /**
560
- * Updates a metastore assignment. This operation can be used to update __metastore_id__ or __default_catalog_name__
561
- * for a specified Workspace, if the Workspace is already assigned a metastore.
562
- * The caller must be an account admin to update __metastore_id__; otherwise, the caller can be a Workspace admin.
563
- */
564
- async updateMetastoreAssignment(req, options) {
565
- const { host, workspaceId, httpClient } = await this.resolveConfig();
566
- const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`;
567
- const body = marshalRequest(req, marshalUpdateMetastoreAssignmentRequestSchema);
568
- let resp;
569
- const call = async (callSignal) => {
570
- const headers = new Headers({ 'Content-Type': 'application/json' });
571
- if (workspaceId !== undefined) {
572
- headers.set('X-Databricks-Workspace-Id', workspaceId);
573
- }
574
- headers.set('User-Agent', this.userAgent);
575
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
576
- const respBody = await executeHttpCall({
577
- request: httpReq,
578
- httpClient,
579
- logger: this.logger,
580
- });
581
- resp = parseResponse(respBody, unmarshalUpdateMetastoreAssignmentResponseSchema);
582
- };
583
- await executeCall(call, options);
584
- if (resp === undefined) {
585
- throw new Error('operation completed without a result.');
586
- }
587
- return resp;
588
- }
589
- }
14
+ var MetastoresClient = class {
15
+ options;
16
+ logger;
17
+ userAgent;
18
+ config;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.logger = options.logger ?? new NoOpLogger();
22
+ this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
23
+ key: "sdk-js-auth",
24
+ value: VERSION
25
+ }).with({
26
+ key: "auth",
27
+ value: options.credentials?.name() ?? "default"
28
+ }).toString();
29
+ }
30
+ resolveConfig() {
31
+ this.config ??= resolveClientConfig(this.options);
32
+ return this.config;
33
+ }
34
+ /** Creates a Unity Catalog metastore. */
35
+ async createAccountsMetastore(req, options) {
36
+ const { host, accountId, httpClient } = await this.resolveConfig();
37
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores`;
38
+ const body = marshalRequest(req, marshalAccountsCreateMetastoreRequestSchema);
39
+ let resp;
40
+ const call = async (callSignal) => {
41
+ const headers = new Headers({ "Content-Type": "application/json" });
42
+ headers.set("User-Agent", this.userAgent);
43
+ resp = parseResponse(await executeHttpCall({
44
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
45
+ httpClient,
46
+ logger: this.logger
47
+ }), unmarshalAccountsCreateMetastoreResponseSchema);
48
+ };
49
+ await executeCall(call, options);
50
+ if (resp === void 0) throw new Error("operation completed without a result.");
51
+ return resp;
52
+ }
53
+ /** Creates an assignment to a metastore for a workspace */
54
+ async createAccountsMetastoreAssignment(req, options) {
55
+ const { host, accountId, httpClient } = await this.resolveConfig();
56
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/metastores/${req.metastoreId ?? ""}`;
57
+ const body = marshalRequest(req, marshalAccountsCreateMetastoreAssignmentRequestSchema);
58
+ let resp;
59
+ const call = async (callSignal) => {
60
+ const headers = new Headers({ "Content-Type": "application/json" });
61
+ headers.set("User-Agent", this.userAgent);
62
+ resp = parseResponse(await executeHttpCall({
63
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
64
+ httpClient,
65
+ logger: this.logger
66
+ }), unmarshalAccountsCreateMetastoreAssignmentResponseSchema);
67
+ };
68
+ await executeCall(call, options);
69
+ if (resp === void 0) throw new Error("operation completed without a result.");
70
+ return resp;
71
+ }
72
+ /** Deletes a Unity Catalog metastore for an account, both specified by ID. */
73
+ async deleteAccountsMetastore(req, options) {
74
+ const { host, accountId, httpClient } = await this.resolveConfig();
75
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores/${req.metastoreId ?? ""}`;
76
+ const params = new URLSearchParams();
77
+ if (req.force !== void 0) params.append("force", String(req.force));
78
+ const query = params.toString();
79
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
80
+ let resp;
81
+ const call = async (callSignal) => {
82
+ const headers = new Headers();
83
+ headers.set("User-Agent", this.userAgent);
84
+ resp = parseResponse(await executeHttpCall({
85
+ request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
86
+ httpClient,
87
+ logger: this.logger
88
+ }), unmarshalAccountsDeleteMetastoreResponseSchema);
89
+ };
90
+ await executeCall(call, options);
91
+ if (resp === void 0) throw new Error("operation completed without a result.");
92
+ return resp;
93
+ }
94
+ /** Deletes a metastore assignment to a workspace, leaving the workspace with no metastore. */
95
+ async deleteAccountsMetastoreAssignment(req, options) {
96
+ const { host, accountId, httpClient } = await this.resolveConfig();
97
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/metastores/${req.metastoreId ?? ""}`;
98
+ let resp;
99
+ const call = async (callSignal) => {
100
+ const headers = new Headers();
101
+ headers.set("User-Agent", this.userAgent);
102
+ resp = parseResponse(await executeHttpCall({
103
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
104
+ httpClient,
105
+ logger: this.logger
106
+ }), unmarshalAccountsDeleteMetastoreAssignmentResponseSchema);
107
+ };
108
+ await executeCall(call, options);
109
+ if (resp === void 0) throw new Error("operation completed without a result.");
110
+ return resp;
111
+ }
112
+ /** Gets a Unity Catalog metastore from an account, both specified by ID. */
113
+ async getAccountsMetastore(req, options) {
114
+ const { host, accountId, httpClient } = await this.resolveConfig();
115
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores/${req.metastoreId ?? ""}`;
116
+ let resp;
117
+ const call = async (callSignal) => {
118
+ const headers = new Headers();
119
+ headers.set("User-Agent", this.userAgent);
120
+ resp = parseResponse(await executeHttpCall({
121
+ request: buildHttpRequest("GET", url, headers, callSignal),
122
+ httpClient,
123
+ logger: this.logger
124
+ }), unmarshalAccountsGetMetastoreResponseSchema);
125
+ };
126
+ await executeCall(call, options);
127
+ if (resp === void 0) throw new Error("operation completed without a result.");
128
+ return resp;
129
+ }
130
+ /**
131
+ * Gets the metastore assignment, if any, for the workspace specified by ID.
132
+ * If the workspace is assigned a metastore, the mapping will be returned.
133
+ * If no metastore is assigned to the workspace, the assignment will not be
134
+ * found and a 404 returned.
135
+ */
136
+ async getMetastoreAssignment(req, options) {
137
+ const { host, accountId, httpClient } = await this.resolveConfig();
138
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/metastore`;
139
+ let resp;
140
+ const call = async (callSignal) => {
141
+ const headers = new Headers();
142
+ headers.set("User-Agent", this.userAgent);
143
+ resp = parseResponse(await executeHttpCall({
144
+ request: buildHttpRequest("GET", url, headers, callSignal),
145
+ httpClient,
146
+ logger: this.logger
147
+ }), unmarshalAccountsGetMetastoreAssignmentResponseSchema);
148
+ };
149
+ await executeCall(call, options);
150
+ if (resp === void 0) throw new Error("operation completed without a result.");
151
+ return resp;
152
+ }
153
+ /** Gets all Unity Catalog metastores associated with an account specified by ID. */
154
+ async listAccountsMetastores(req, options) {
155
+ const { host, accountId, httpClient } = await this.resolveConfig();
156
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores`;
157
+ let resp;
158
+ const call = async (callSignal) => {
159
+ const headers = new Headers();
160
+ headers.set("User-Agent", this.userAgent);
161
+ resp = parseResponse(await executeHttpCall({
162
+ request: buildHttpRequest("GET", url, headers, callSignal),
163
+ httpClient,
164
+ logger: this.logger
165
+ }), unmarshalAccountsListMetastoresResponseSchema);
166
+ };
167
+ await executeCall(call, options);
168
+ if (resp === void 0) throw new Error("operation completed without a result.");
169
+ return resp;
170
+ }
171
+ /** Gets a list of all <Databricks> workspace IDs that have been assigned to given metastore. */
172
+ async listMetastoreAssignments(req, options) {
173
+ const { host, accountId, httpClient } = await this.resolveConfig();
174
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores/${req.metastoreId ?? ""}/workspaces`;
175
+ let resp;
176
+ const call = async (callSignal) => {
177
+ const headers = new Headers();
178
+ headers.set("User-Agent", this.userAgent);
179
+ resp = parseResponse(await executeHttpCall({
180
+ request: buildHttpRequest("GET", url, headers, callSignal),
181
+ httpClient,
182
+ logger: this.logger
183
+ }), unmarshalAccountsListWorkspaceIdsForMetastoreResponseSchema);
184
+ };
185
+ await executeCall(call, options);
186
+ if (resp === void 0) throw new Error("operation completed without a result.");
187
+ return resp;
188
+ }
189
+ /** Updates an existing Unity Catalog metastore. */
190
+ async updateAccountsMetastore(req, options) {
191
+ const { host, accountId, httpClient } = await this.resolveConfig();
192
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/metastores/${req.metastoreId ?? ""}`;
193
+ const body = marshalRequest(req, marshalAccountsUpdateMetastoreRequestSchema);
194
+ let resp;
195
+ const call = async (callSignal) => {
196
+ const headers = new Headers({ "Content-Type": "application/json" });
197
+ headers.set("User-Agent", this.userAgent);
198
+ resp = parseResponse(await executeHttpCall({
199
+ request: buildHttpRequest("PUT", url, headers, callSignal, body),
200
+ httpClient,
201
+ logger: this.logger
202
+ }), unmarshalAccountsUpdateMetastoreResponseSchema);
203
+ };
204
+ await executeCall(call, options);
205
+ if (resp === void 0) throw new Error("operation completed without a result.");
206
+ return resp;
207
+ }
208
+ /** Updates an assignment to a metastore for a workspace. Currently, only the default catalog may be updated. */
209
+ async updateAccountsMetastoreAssignment(req, options) {
210
+ const { host, accountId, httpClient } = await this.resolveConfig();
211
+ const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ""}/workspaces/${String(req.workspaceId ?? "")}/metastores/${req.metastoreId ?? ""}`;
212
+ const body = marshalRequest(req, marshalAccountsUpdateMetastoreAssignmentRequestSchema);
213
+ let resp;
214
+ const call = async (callSignal) => {
215
+ const headers = new Headers({ "Content-Type": "application/json" });
216
+ headers.set("User-Agent", this.userAgent);
217
+ resp = parseResponse(await executeHttpCall({
218
+ request: buildHttpRequest("PUT", url, headers, callSignal, body),
219
+ httpClient,
220
+ logger: this.logger
221
+ }), unmarshalAccountsUpdateMetastoreAssignmentResponseSchema);
222
+ };
223
+ await executeCall(call, options);
224
+ if (resp === void 0) throw new Error("operation completed without a result.");
225
+ return resp;
226
+ }
227
+ /**
228
+ * Creates a new metastore based on a provided name and optional storage root path.
229
+ * By default (if the __owner__ field is not set), the owner of the new metastore is the user calling
230
+ * the __createMetastore__ API. If the __owner__ field is set to the empty string (**""**), the ownership is
231
+ * assigned to the System User instead.
232
+ */
233
+ async createMetastore(req, options) {
234
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
235
+ const url = `${host}/api/2.1/unity-catalog/metastores`;
236
+ const body = marshalRequest(req, marshalCreateMetastoreRequestSchema);
237
+ let resp;
238
+ const call = async (callSignal) => {
239
+ const headers = new Headers({ "Content-Type": "application/json" });
240
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
241
+ headers.set("User-Agent", this.userAgent);
242
+ resp = parseResponse(await executeHttpCall({
243
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
244
+ httpClient,
245
+ logger: this.logger
246
+ }), unmarshalMetastoreInfoSchema);
247
+ };
248
+ await executeCall(call, options);
249
+ if (resp === void 0) throw new Error("operation completed without a result.");
250
+ return resp;
251
+ }
252
+ /**
253
+ * Creates a new metastore assignment.
254
+ * If an assignment for the same __workspace_id__ exists, it will be overwritten by the new __metastore_id__ and
255
+ * __default_catalog_name__. The caller must be an account admin.
256
+ */
257
+ async createMetastoreAssignment(req, options) {
258
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
259
+ const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? "")}/metastore`;
260
+ const body = marshalRequest(req, marshalCreateMetastoreAssignmentRequestSchema);
261
+ let resp;
262
+ const call = async (callSignal) => {
263
+ const headers = new Headers({ "Content-Type": "application/json" });
264
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
265
+ headers.set("User-Agent", this.userAgent);
266
+ resp = parseResponse(await executeHttpCall({
267
+ request: buildHttpRequest("PUT", url, headers, callSignal, body),
268
+ httpClient,
269
+ logger: this.logger
270
+ }), unmarshalCreateMetastoreAssignmentResponseSchema);
271
+ };
272
+ await executeCall(call, options);
273
+ if (resp === void 0) throw new Error("operation completed without a result.");
274
+ return resp;
275
+ }
276
+ /** Deletes a metastore. The caller must be a metastore admin. */
277
+ async deleteMetastore(req, options) {
278
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
279
+ const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ""}`;
280
+ const params = new URLSearchParams();
281
+ if (req.force !== void 0) params.append("force", String(req.force));
282
+ const query = params.toString();
283
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
284
+ let resp;
285
+ const call = async (callSignal) => {
286
+ const headers = new Headers();
287
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
288
+ headers.set("User-Agent", this.userAgent);
289
+ resp = parseResponse(await executeHttpCall({
290
+ request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
291
+ httpClient,
292
+ logger: this.logger
293
+ }), unmarshalDeleteMetastoreResponseSchema);
294
+ };
295
+ await executeCall(call, options);
296
+ if (resp === void 0) throw new Error("operation completed without a result.");
297
+ return resp;
298
+ }
299
+ /** Deletes a metastore assignment. The caller must be an account administrator. */
300
+ async deleteMetastoreAssignment(req, options) {
301
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
302
+ const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? "")}/metastore`;
303
+ const params = new URLSearchParams();
304
+ if (req.metastoreId !== void 0) params.append("metastore_id", req.metastoreId);
305
+ const query = params.toString();
306
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
307
+ let resp;
308
+ const call = async (callSignal) => {
309
+ const headers = new Headers();
310
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
311
+ headers.set("User-Agent", this.userAgent);
312
+ resp = parseResponse(await executeHttpCall({
313
+ request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
314
+ httpClient,
315
+ logger: this.logger
316
+ }), unmarshalDeleteMetastoreAssignmentResponseSchema);
317
+ };
318
+ await executeCall(call, options);
319
+ if (resp === void 0) throw new Error("operation completed without a result.");
320
+ return resp;
321
+ }
322
+ /** Gets the metastore assignment for the workspace being accessed. */
323
+ async getCurrentMetastoreAssignment(_req, options) {
324
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
325
+ const url = `${host}/api/2.1/unity-catalog/current-metastore-assignment`;
326
+ let resp;
327
+ const call = async (callSignal) => {
328
+ const headers = new Headers();
329
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
330
+ headers.set("User-Agent", this.userAgent);
331
+ resp = parseResponse(await executeHttpCall({
332
+ request: buildHttpRequest("GET", url, headers, callSignal),
333
+ httpClient,
334
+ logger: this.logger
335
+ }), unmarshalMetastoreAssignmentSchema);
336
+ };
337
+ await executeCall(call, options);
338
+ if (resp === void 0) throw new Error("operation completed without a result.");
339
+ return resp;
340
+ }
341
+ /** Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this info. */
342
+ async getMetastore(req, options) {
343
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
344
+ const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ""}`;
345
+ let resp;
346
+ const call = async (callSignal) => {
347
+ const headers = new Headers();
348
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
349
+ headers.set("User-Agent", this.userAgent);
350
+ resp = parseResponse(await executeHttpCall({
351
+ request: buildHttpRequest("GET", url, headers, callSignal),
352
+ httpClient,
353
+ logger: this.logger
354
+ }), unmarshalMetastoreInfoSchema);
355
+ };
356
+ await executeCall(call, options);
357
+ if (resp === void 0) throw new Error("operation completed without a result.");
358
+ return resp;
359
+ }
360
+ /**
361
+ * Gets information about a metastore.
362
+ * This summary includes the storage credential, the cloud vendor, the cloud region, and the global metastore ID.
363
+ */
364
+ async getMetastoreSummary(_req, options) {
365
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
366
+ const url = `${host}/api/2.1/unity-catalog/metastore_summary`;
367
+ let resp;
368
+ const call = async (callSignal) => {
369
+ const headers = new Headers();
370
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
371
+ headers.set("User-Agent", this.userAgent);
372
+ resp = parseResponse(await executeHttpCall({
373
+ request: buildHttpRequest("GET", url, headers, callSignal),
374
+ httpClient,
375
+ logger: this.logger
376
+ }), unmarshalGetMetastoreSummaryResponseSchema);
377
+ };
378
+ await executeCall(call, options);
379
+ if (resp === void 0) throw new Error("operation completed without a result.");
380
+ return resp;
381
+ }
382
+ /**
383
+ * Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin to retrieve this info.
384
+ * There is no guarantee of a specific ordering of the elements in the array.
385
+ *
386
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
387
+ *
388
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
389
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
390
+ */
391
+ async listMetastores(req, options) {
392
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
393
+ const url = `${host}/api/2.1/unity-catalog/metastores`;
394
+ const params = new URLSearchParams();
395
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
396
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
397
+ const query = params.toString();
398
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
399
+ let resp;
400
+ const call = async (callSignal) => {
401
+ const headers = new Headers();
402
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
403
+ headers.set("User-Agent", this.userAgent);
404
+ resp = parseResponse(await executeHttpCall({
405
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
406
+ httpClient,
407
+ logger: this.logger
408
+ }), unmarshalListMetastoresResponseSchema);
409
+ };
410
+ await executeCall(call, options);
411
+ if (resp === void 0) throw new Error("operation completed without a result.");
412
+ return resp;
413
+ }
414
+ async *listMetastoresIter(req, options) {
415
+ const pageReq = { ...req };
416
+ for (;;) {
417
+ const resp = await this.listMetastores(pageReq, options);
418
+ for (const item of resp.metastores ?? []) yield item;
419
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
420
+ pageReq.pageToken = resp.nextPageToken;
421
+ }
422
+ }
423
+ /**
424
+ * Updates information for a specific metastore. The caller must be a metastore admin.
425
+ * If the __owner__ field is set to the empty string (**""**), the ownership is updated
426
+ * to the System User.
427
+ */
428
+ async updateMetastore(req, options) {
429
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
430
+ const url = `${host}/api/2.1/unity-catalog/metastores/${req.id ?? ""}`;
431
+ const body = marshalRequest(req, marshalUpdateMetastoreRequestSchema);
432
+ let resp;
433
+ const call = async (callSignal) => {
434
+ const headers = new Headers({ "Content-Type": "application/json" });
435
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
436
+ headers.set("User-Agent", this.userAgent);
437
+ resp = parseResponse(await executeHttpCall({
438
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
439
+ httpClient,
440
+ logger: this.logger
441
+ }), unmarshalMetastoreInfoSchema);
442
+ };
443
+ await executeCall(call, options);
444
+ if (resp === void 0) throw new Error("operation completed without a result.");
445
+ return resp;
446
+ }
447
+ /**
448
+ * Updates a metastore assignment. This operation can be used to update __metastore_id__ or __default_catalog_name__
449
+ * for a specified Workspace, if the Workspace is already assigned a metastore.
450
+ * The caller must be an account admin to update __metastore_id__; otherwise, the caller can be a Workspace admin.
451
+ */
452
+ async updateMetastoreAssignment(req, options) {
453
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
454
+ const url = `${host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? "")}/metastore`;
455
+ const body = marshalRequest(req, marshalUpdateMetastoreAssignmentRequestSchema);
456
+ let resp;
457
+ const call = async (callSignal) => {
458
+ const headers = new Headers({ "Content-Type": "application/json" });
459
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
460
+ headers.set("User-Agent", this.userAgent);
461
+ resp = parseResponse(await executeHttpCall({
462
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
463
+ httpClient,
464
+ logger: this.logger
465
+ }), unmarshalUpdateMetastoreAssignmentResponseSchema);
466
+ };
467
+ await executeCall(call, options);
468
+ if (resp === void 0) throw new Error("operation completed without a result.");
469
+ return resp;
470
+ }
471
+ };
472
+
473
+ //#endregion
474
+ export { MetastoresClient };
590
475
  //# sourceMappingURL=client.js.map