@databricks/sdk-uc-tables 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,460 +1,357 @@
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 { marshalCreateTableConstraintRequestSchema, marshalCreateTableRequestSchema, marshalUpdateTableRequestSchema, unmarshalDeleteTableConstraintResponseSchema, unmarshalDeleteTableResponseSchema, unmarshalListTableSummariesResponseSchema, unmarshalListTablesResponseSchema, unmarshalTableConstraintSchema, unmarshalTableExistsResponseSchema, unmarshalTableInfoSchema, unmarshalUpdateTableResponseSchema, } 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 { marshalCreateTableConstraintRequestSchema, marshalCreateTableRequestSchema, marshalUpdateTableRequestSchema, unmarshalDeleteTableConstraintResponseSchema, unmarshalDeleteTableResponseSchema, unmarshalListTableSummariesResponseSchema, unmarshalListTablesResponseSchema, unmarshalTableConstraintSchema, unmarshalTableExistsResponseSchema, unmarshalTableInfoSchema, unmarshalUpdateTableResponseSchema } 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 TablesClient {
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
- /**
39
- * Creates a new table in the specified catalog and schema.
40
- *
41
- * To create an external delta table, the caller must have the **EXTERNAL_USE_SCHEMA** privilege on the parent schema
42
- * and the **EXTERNAL_USE_LOCATION** privilege on the external location. These privileges must always be granted explicitly,
43
- * and cannot be inherited through ownership or **ALL_PRIVILEGES**.
44
- *
45
- * Standard UC permissions needed to create tables still apply: **USE_CATALOG** on the parent catalog (or ownership of
46
- * the parent catalog), **CREATE_TABLE** and **USE_SCHEMA** on the parent schema (or ownership of the parent schema),
47
- * and **CREATE_EXTERNAL_TABLE** on external location.
48
- *
49
- * The **columns** field needs to be in a Spark compatible format, so we recommend you use Spark to create these tables.
50
- * The API itself does not validate the correctness of the column spec. If the spec is not Spark compatible,
51
- * the tables may not be readable by Databricks Runtime.
52
- *
53
- *
54
- *
55
- *
56
- *
57
- *
58
- *
59
- * NOTE: The Create Table API for external clients only supports creating **external delta tables**. The values shown
60
- * in the respective enums are all values supported by <Databricks>, however for this specific Create Table API,
61
- * only **table_type** **EXTERNAL** and **data_source_format** **DELTA** are supported. Additionally, column masks
62
- * are not supported when creating tables through this API.
63
- */
64
- async createTable(req, options) {
65
- const { host, workspaceId, httpClient } = await this.resolveConfig();
66
- const url = `${host}/api/2.1/unity-catalog/tables`;
67
- const body = marshalRequest(req, marshalCreateTableRequestSchema);
68
- let resp;
69
- const call = async (callSignal) => {
70
- const headers = new Headers({ 'Content-Type': 'application/json' });
71
- if (workspaceId !== undefined) {
72
- headers.set('X-Databricks-Workspace-Id', workspaceId);
73
- }
74
- headers.set('User-Agent', this.userAgent);
75
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
76
- const respBody = await executeHttpCall({
77
- request: httpReq,
78
- httpClient,
79
- logger: this.logger,
80
- });
81
- resp = parseResponse(respBody, unmarshalTableInfoSchema);
82
- };
83
- await executeCall(call, options);
84
- if (resp === undefined) {
85
- throw new Error('operation completed without a result.');
86
- }
87
- return resp;
88
- }
89
- /**
90
- * Creates a new table constraint.
91
- *
92
- * For the table constraint creation to succeed, the user must satisfy both of these conditions:
93
- * - the user must have the **USE_CATALOG** privilege on the table's parent catalog,
94
- * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table.
95
- * - if the new constraint is a __ForeignKeyConstraint__,
96
- * the user must have the **USE_CATALOG** privilege on the referenced parent table's catalog,
97
- * the **USE_SCHEMA** privilege on the referenced parent table's schema,
98
- * and be the owner of the referenced parent table.
99
- */
100
- async createTableConstraint(req, options) {
101
- const { host, workspaceId, httpClient } = await this.resolveConfig();
102
- const url = `${host}/api/2.1/unity-catalog/constraints`;
103
- const body = marshalRequest(req, marshalCreateTableConstraintRequestSchema);
104
- let resp;
105
- const call = async (callSignal) => {
106
- const headers = new Headers({ 'Content-Type': 'application/json' });
107
- if (workspaceId !== undefined) {
108
- headers.set('X-Databricks-Workspace-Id', workspaceId);
109
- }
110
- headers.set('User-Agent', this.userAgent);
111
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
112
- const respBody = await executeHttpCall({
113
- request: httpReq,
114
- httpClient,
115
- logger: this.logger,
116
- });
117
- resp = parseResponse(respBody, unmarshalTableConstraintSchema);
118
- };
119
- await executeCall(call, options);
120
- if (resp === undefined) {
121
- throw new Error('operation completed without a result.');
122
- }
123
- return resp;
124
- }
125
- /**
126
- * Deletes a table from the specified parent catalog and schema.
127
- * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema,
128
- * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
129
- */
130
- async deleteTable(req, options) {
131
- const { host, workspaceId, httpClient } = await this.resolveConfig();
132
- const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`;
133
- let resp;
134
- const call = async (callSignal) => {
135
- const headers = new Headers();
136
- if (workspaceId !== undefined) {
137
- headers.set('X-Databricks-Workspace-Id', workspaceId);
138
- }
139
- headers.set('User-Agent', this.userAgent);
140
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
141
- const respBody = await executeHttpCall({
142
- request: httpReq,
143
- httpClient,
144
- logger: this.logger,
145
- });
146
- resp = parseResponse(respBody, unmarshalDeleteTableResponseSchema);
147
- };
148
- await executeCall(call, options);
149
- if (resp === undefined) {
150
- throw new Error('operation completed without a result.');
151
- }
152
- return resp;
153
- }
154
- /**
155
- * Deletes a table constraint.
156
- *
157
- * For the table constraint deletion to succeed, the user must satisfy both of these conditions:
158
- * - the user must have the **USE_CATALOG** privilege on the table's parent catalog,
159
- * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table.
160
- * - if __cascade__ argument is **true**, the user must have the following permissions on all of the child tables:
161
- * the **USE_CATALOG** privilege on the table's catalog,
162
- * the **USE_SCHEMA** privilege on the table's schema,
163
- * and be the owner of the table.
164
- */
165
- async deleteTableConstraint(req, options) {
166
- const { host, workspaceId, httpClient } = await this.resolveConfig();
167
- const url = `${host}/api/2.1/unity-catalog/constraints/${req.fullNameArg ?? ''}`;
168
- const params = new URLSearchParams();
169
- if (req.constraintName !== undefined) {
170
- params.append('constraint_name', req.constraintName);
171
- }
172
- if (req.cascade !== undefined) {
173
- params.append('cascade', String(req.cascade));
174
- }
175
- const query = params.toString();
176
- const fullUrl = query !== '' ? `${url}?${query}` : url;
177
- let resp;
178
- const call = async (callSignal) => {
179
- const headers = new Headers();
180
- if (workspaceId !== undefined) {
181
- headers.set('X-Databricks-Workspace-Id', workspaceId);
182
- }
183
- headers.set('User-Agent', this.userAgent);
184
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
185
- const respBody = await executeHttpCall({
186
- request: httpReq,
187
- httpClient,
188
- logger: this.logger,
189
- });
190
- resp = parseResponse(respBody, unmarshalDeleteTableConstraintResponseSchema);
191
- };
192
- await executeCall(call, options);
193
- if (resp === undefined) {
194
- throw new Error('operation completed without a result.');
195
- }
196
- return resp;
197
- }
198
- /**
199
- * Gets a table from the metastore for a specific catalog and schema.
200
- * The caller must satisfy one of the following requirements:
201
- * * Be a metastore admin
202
- * * Be the owner of the parent catalog
203
- * * Be the owner of the parent schema and have the **USE_CATALOG** privilege on the parent catalog
204
- * * Have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema,
205
- * and either be the table owner or have the **SELECT** privilege on the table.
206
- */
207
- async getTable(req, options) {
208
- const { host, workspaceId, httpClient } = await this.resolveConfig();
209
- const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`;
210
- const params = new URLSearchParams();
211
- if (req.includeDeltaMetadata !== undefined) {
212
- params.append('include_delta_metadata', String(req.includeDeltaMetadata));
213
- }
214
- if (req.includeBrowse !== undefined) {
215
- params.append('include_browse', String(req.includeBrowse));
216
- }
217
- if (req.includeManifestCapabilities !== undefined) {
218
- params.append('include_manifest_capabilities', String(req.includeManifestCapabilities));
219
- }
220
- const query = params.toString();
221
- const fullUrl = query !== '' ? `${url}?${query}` : url;
222
- let resp;
223
- const call = async (callSignal) => {
224
- const headers = new Headers();
225
- if (workspaceId !== undefined) {
226
- headers.set('X-Databricks-Workspace-Id', workspaceId);
227
- }
228
- headers.set('User-Agent', this.userAgent);
229
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
230
- const respBody = await executeHttpCall({
231
- request: httpReq,
232
- httpClient,
233
- logger: this.logger,
234
- });
235
- resp = parseResponse(respBody, unmarshalTableInfoSchema);
236
- };
237
- await executeCall(call, options);
238
- if (resp === undefined) {
239
- throw new Error('operation completed without a result.');
240
- }
241
- return resp;
242
- }
243
- /**
244
- * Gets an array of summaries for tables for a schema and catalog within the metastore. The table summaries returned are either:
245
- *
246
- * * summaries for tables (within the current metastore and parent catalog and schema), when the user is a metastore admin, or:
247
- * * summaries for tables and schemas (within the current metastore and parent catalog)
248
- * for which the user has ownership or the **SELECT** privilege on the table and ownership or **USE_SCHEMA** privilege on the schema,
249
- * provided that the user also has ownership or the **USE_CATALOG** privilege on the parent catalog.
250
- *
251
- * There is no guarantee of a specific ordering of the elements in the array.
252
- *
253
- * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
254
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
255
- */
256
- async listTableSummaries(req, options) {
257
- const { host, workspaceId, httpClient } = await this.resolveConfig();
258
- const url = `${host}/api/2.1/unity-catalog/table-summaries`;
259
- const params = new URLSearchParams();
260
- if (req.catalogName !== undefined) {
261
- params.append('catalog_name', req.catalogName);
262
- }
263
- if (req.schemaNamePattern !== undefined) {
264
- params.append('schema_name_pattern', req.schemaNamePattern);
265
- }
266
- if (req.tableNamePattern !== undefined) {
267
- params.append('table_name_pattern', req.tableNamePattern);
268
- }
269
- if (req.maxResults !== undefined) {
270
- params.append('max_results', String(req.maxResults));
271
- }
272
- if (req.pageToken !== undefined) {
273
- params.append('page_token', req.pageToken);
274
- }
275
- if (req.includeManifestCapabilities !== undefined) {
276
- params.append('include_manifest_capabilities', String(req.includeManifestCapabilities));
277
- }
278
- const query = params.toString();
279
- const fullUrl = query !== '' ? `${url}?${query}` : url;
280
- let resp;
281
- const call = async (callSignal) => {
282
- const headers = new Headers();
283
- if (workspaceId !== undefined) {
284
- headers.set('X-Databricks-Workspace-Id', workspaceId);
285
- }
286
- headers.set('User-Agent', this.userAgent);
287
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
288
- const respBody = await executeHttpCall({
289
- request: httpReq,
290
- httpClient,
291
- logger: this.logger,
292
- });
293
- resp = parseResponse(respBody, unmarshalListTableSummariesResponseSchema);
294
- };
295
- await executeCall(call, options);
296
- if (resp === undefined) {
297
- throw new Error('operation completed without a result.');
298
- }
299
- return resp;
300
- }
301
- async *listTableSummariesIter(req, options) {
302
- const pageReq = { ...req };
303
- for (;;) {
304
- const resp = await this.listTableSummaries(pageReq, options);
305
- for (const item of resp.tables ?? []) {
306
- yield item;
307
- }
308
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
309
- return;
310
- }
311
- pageReq.pageToken = resp.nextPageToken;
312
- }
313
- }
314
- /**
315
- * Gets an array of all tables for the current metastore under the parent catalog and schema.
316
- * The caller must be a metastore admin or an owner of (or have the **SELECT** privilege on) the table.
317
- * For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
318
- * There is no guarantee of a specific ordering of the elements in the array.
319
- *
320
- * NOTE: **view_dependencies** and **table_constraints** are not returned by ListTables queries.
321
- *
322
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
323
- *
324
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
325
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
326
- */
327
- async listTables(req, options) {
328
- const { host, workspaceId, httpClient } = await this.resolveConfig();
329
- const url = `${host}/api/2.1/unity-catalog/tables`;
330
- const params = new URLSearchParams();
331
- if (req.catalogName !== undefined) {
332
- params.append('catalog_name', req.catalogName);
333
- }
334
- if (req.schemaName !== undefined) {
335
- params.append('schema_name', req.schemaName);
336
- }
337
- if (req.maxResults !== undefined) {
338
- params.append('max_results', String(req.maxResults));
339
- }
340
- if (req.pageToken !== undefined) {
341
- params.append('page_token', req.pageToken);
342
- }
343
- if (req.omitColumns !== undefined) {
344
- params.append('omit_columns', String(req.omitColumns));
345
- }
346
- if (req.omitProperties !== undefined) {
347
- params.append('omit_properties', String(req.omitProperties));
348
- }
349
- if (req.omitUsername !== undefined) {
350
- params.append('omit_username', String(req.omitUsername));
351
- }
352
- if (req.includeBrowse !== undefined) {
353
- params.append('include_browse', String(req.includeBrowse));
354
- }
355
- if (req.includeManifestCapabilities !== undefined) {
356
- params.append('include_manifest_capabilities', String(req.includeManifestCapabilities));
357
- }
358
- const query = params.toString();
359
- const fullUrl = query !== '' ? `${url}?${query}` : url;
360
- let resp;
361
- const call = async (callSignal) => {
362
- const headers = new Headers();
363
- if (workspaceId !== undefined) {
364
- headers.set('X-Databricks-Workspace-Id', workspaceId);
365
- }
366
- headers.set('User-Agent', this.userAgent);
367
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
368
- const respBody = await executeHttpCall({
369
- request: httpReq,
370
- httpClient,
371
- logger: this.logger,
372
- });
373
- resp = parseResponse(respBody, unmarshalListTablesResponseSchema);
374
- };
375
- await executeCall(call, options);
376
- if (resp === undefined) {
377
- throw new Error('operation completed without a result.');
378
- }
379
- return resp;
380
- }
381
- async *listTablesIter(req, options) {
382
- const pageReq = { ...req };
383
- for (;;) {
384
- const resp = await this.listTables(pageReq, options);
385
- for (const item of resp.tables ?? []) {
386
- yield item;
387
- }
388
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
389
- return;
390
- }
391
- pageReq.pageToken = resp.nextPageToken;
392
- }
393
- }
394
- /**
395
- * Gets if a table exists in the metastore for a specific catalog and schema.
396
- * The caller must satisfy one of the following requirements:
397
- * * Be a metastore admin
398
- * * Be the owner of the parent catalog
399
- * * Be the owner of the parent schema and have the **USE_CATALOG** privilege on the parent catalog
400
- * * Have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema,
401
- * and either be the table owner or have the **SELECT** privilege on the table.
402
- * * Have **BROWSE** privilege on the parent catalog
403
- * * Have **BROWSE** privilege on the parent schema
404
- */
405
- async tableExists(req, options) {
406
- const { host, workspaceId, httpClient } = await this.resolveConfig();
407
- const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}/exists`;
408
- let resp;
409
- const call = async (callSignal) => {
410
- const headers = new Headers();
411
- if (workspaceId !== undefined) {
412
- headers.set('X-Databricks-Workspace-Id', workspaceId);
413
- }
414
- headers.set('User-Agent', this.userAgent);
415
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
416
- const respBody = await executeHttpCall({
417
- request: httpReq,
418
- httpClient,
419
- logger: this.logger,
420
- });
421
- resp = parseResponse(respBody, unmarshalTableExistsResponseSchema);
422
- };
423
- await executeCall(call, options);
424
- if (resp === undefined) {
425
- throw new Error('operation completed without a result.');
426
- }
427
- return resp;
428
- }
429
- /**
430
- * Change the owner of the table.
431
- * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema,
432
- * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
433
- */
434
- async updateTable(req, options) {
435
- const { host, workspaceId, httpClient } = await this.resolveConfig();
436
- const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`;
437
- const body = marshalRequest(req, marshalUpdateTableRequestSchema);
438
- let resp;
439
- const call = async (callSignal) => {
440
- const headers = new Headers({ 'Content-Type': 'application/json' });
441
- if (workspaceId !== undefined) {
442
- headers.set('X-Databricks-Workspace-Id', workspaceId);
443
- }
444
- headers.set('User-Agent', this.userAgent);
445
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
446
- const respBody = await executeHttpCall({
447
- request: httpReq,
448
- httpClient,
449
- logger: this.logger,
450
- });
451
- resp = parseResponse(respBody, unmarshalUpdateTableResponseSchema);
452
- };
453
- await executeCall(call, options);
454
- if (resp === undefined) {
455
- throw new Error('operation completed without a result.');
456
- }
457
- return resp;
458
- }
459
- }
14
+ var TablesClient = 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
+ /**
35
+ * Creates a new table in the specified catalog and schema.
36
+ *
37
+ * To create an external delta table, the caller must have the **EXTERNAL_USE_SCHEMA** privilege on the parent schema
38
+ * and the **EXTERNAL_USE_LOCATION** privilege on the external location. These privileges must always be granted explicitly,
39
+ * and cannot be inherited through ownership or **ALL_PRIVILEGES**.
40
+ *
41
+ * Standard UC permissions needed to create tables still apply: **USE_CATALOG** on the parent catalog (or ownership of
42
+ * the parent catalog), **CREATE_TABLE** and **USE_SCHEMA** on the parent schema (or ownership of the parent schema),
43
+ * and **CREATE_EXTERNAL_TABLE** on external location.
44
+ *
45
+ * The **columns** field needs to be in a Spark compatible format, so we recommend you use Spark to create these tables.
46
+ * The API itself does not validate the correctness of the column spec. If the spec is not Spark compatible,
47
+ * the tables may not be readable by Databricks Runtime.
48
+ *
49
+ *
50
+ *
51
+ *
52
+ *
53
+ *
54
+ *
55
+ * NOTE: The Create Table API for external clients only supports creating **external delta tables**. The values shown
56
+ * in the respective enums are all values supported by <Databricks>, however for this specific Create Table API,
57
+ * only **table_type** **EXTERNAL** and **data_source_format** **DELTA** are supported. Additionally, column masks
58
+ * are not supported when creating tables through this API.
59
+ */
60
+ async createTable(req, options) {
61
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
62
+ const url = `${host}/api/2.1/unity-catalog/tables`;
63
+ const body = marshalRequest(req, marshalCreateTableRequestSchema);
64
+ let resp;
65
+ const call = async (callSignal) => {
66
+ const headers = new Headers({ "Content-Type": "application/json" });
67
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
68
+ headers.set("User-Agent", this.userAgent);
69
+ resp = parseResponse(await executeHttpCall({
70
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
71
+ httpClient,
72
+ logger: this.logger
73
+ }), unmarshalTableInfoSchema);
74
+ };
75
+ await executeCall(call, options);
76
+ if (resp === void 0) throw new Error("operation completed without a result.");
77
+ return resp;
78
+ }
79
+ /**
80
+ * Creates a new table constraint.
81
+ *
82
+ * For the table constraint creation to succeed, the user must satisfy both of these conditions:
83
+ * - the user must have the **USE_CATALOG** privilege on the table's parent catalog,
84
+ * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table.
85
+ * - if the new constraint is a __ForeignKeyConstraint__,
86
+ * the user must have the **USE_CATALOG** privilege on the referenced parent table's catalog,
87
+ * the **USE_SCHEMA** privilege on the referenced parent table's schema,
88
+ * and be the owner of the referenced parent table.
89
+ */
90
+ async createTableConstraint(req, options) {
91
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
92
+ const url = `${host}/api/2.1/unity-catalog/constraints`;
93
+ const body = marshalRequest(req, marshalCreateTableConstraintRequestSchema);
94
+ let resp;
95
+ const call = async (callSignal) => {
96
+ const headers = new Headers({ "Content-Type": "application/json" });
97
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
98
+ headers.set("User-Agent", this.userAgent);
99
+ resp = parseResponse(await executeHttpCall({
100
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
101
+ httpClient,
102
+ logger: this.logger
103
+ }), unmarshalTableConstraintSchema);
104
+ };
105
+ await executeCall(call, options);
106
+ if (resp === void 0) throw new Error("operation completed without a result.");
107
+ return resp;
108
+ }
109
+ /**
110
+ * Deletes a table from the specified parent catalog and schema.
111
+ * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema,
112
+ * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
113
+ */
114
+ async deleteTable(req, options) {
115
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
116
+ const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ""}`;
117
+ let resp;
118
+ const call = async (callSignal) => {
119
+ const headers = new Headers();
120
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
121
+ headers.set("User-Agent", this.userAgent);
122
+ resp = parseResponse(await executeHttpCall({
123
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
124
+ httpClient,
125
+ logger: this.logger
126
+ }), unmarshalDeleteTableResponseSchema);
127
+ };
128
+ await executeCall(call, options);
129
+ if (resp === void 0) throw new Error("operation completed without a result.");
130
+ return resp;
131
+ }
132
+ /**
133
+ * Deletes a table constraint.
134
+ *
135
+ * For the table constraint deletion to succeed, the user must satisfy both of these conditions:
136
+ * - the user must have the **USE_CATALOG** privilege on the table's parent catalog,
137
+ * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table.
138
+ * - if __cascade__ argument is **true**, the user must have the following permissions on all of the child tables:
139
+ * the **USE_CATALOG** privilege on the table's catalog,
140
+ * the **USE_SCHEMA** privilege on the table's schema,
141
+ * and be the owner of the table.
142
+ */
143
+ async deleteTableConstraint(req, options) {
144
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
145
+ const url = `${host}/api/2.1/unity-catalog/constraints/${req.fullNameArg ?? ""}`;
146
+ const params = new URLSearchParams();
147
+ if (req.constraintName !== void 0) params.append("constraint_name", req.constraintName);
148
+ if (req.cascade !== void 0) params.append("cascade", String(req.cascade));
149
+ const query = params.toString();
150
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
151
+ let resp;
152
+ const call = async (callSignal) => {
153
+ const headers = new Headers();
154
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
155
+ headers.set("User-Agent", this.userAgent);
156
+ resp = parseResponse(await executeHttpCall({
157
+ request: buildHttpRequest("DELETE", fullUrl, headers, callSignal),
158
+ httpClient,
159
+ logger: this.logger
160
+ }), unmarshalDeleteTableConstraintResponseSchema);
161
+ };
162
+ await executeCall(call, options);
163
+ if (resp === void 0) throw new Error("operation completed without a result.");
164
+ return resp;
165
+ }
166
+ /**
167
+ * Gets a table from the metastore for a specific catalog and schema.
168
+ * The caller must satisfy one of the following requirements:
169
+ * * Be a metastore admin
170
+ * * Be the owner of the parent catalog
171
+ * * Be the owner of the parent schema and have the **USE_CATALOG** privilege on the parent catalog
172
+ * * Have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema,
173
+ * and either be the table owner or have the **SELECT** privilege on the table.
174
+ */
175
+ async getTable(req, options) {
176
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
177
+ const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ""}`;
178
+ const params = new URLSearchParams();
179
+ if (req.includeDeltaMetadata !== void 0) params.append("include_delta_metadata", String(req.includeDeltaMetadata));
180
+ if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
181
+ if (req.includeManifestCapabilities !== void 0) params.append("include_manifest_capabilities", String(req.includeManifestCapabilities));
182
+ const query = params.toString();
183
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
184
+ let resp;
185
+ const call = async (callSignal) => {
186
+ const headers = new Headers();
187
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
188
+ headers.set("User-Agent", this.userAgent);
189
+ resp = parseResponse(await executeHttpCall({
190
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
191
+ httpClient,
192
+ logger: this.logger
193
+ }), unmarshalTableInfoSchema);
194
+ };
195
+ await executeCall(call, options);
196
+ if (resp === void 0) throw new Error("operation completed without a result.");
197
+ return resp;
198
+ }
199
+ /**
200
+ * Gets an array of summaries for tables for a schema and catalog within the metastore. The table summaries returned are either:
201
+ *
202
+ * * summaries for tables (within the current metastore and parent catalog and schema), when the user is a metastore admin, or:
203
+ * * summaries for tables and schemas (within the current metastore and parent catalog)
204
+ * for which the user has ownership or the **SELECT** privilege on the table and ownership or **USE_SCHEMA** privilege on the schema,
205
+ * provided that the user also has ownership or the **USE_CATALOG** privilege on the parent catalog.
206
+ *
207
+ * There is no guarantee of a specific ordering of the elements in the array.
208
+ *
209
+ * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
210
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
211
+ */
212
+ async listTableSummaries(req, options) {
213
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
214
+ const url = `${host}/api/2.1/unity-catalog/table-summaries`;
215
+ const params = new URLSearchParams();
216
+ if (req.catalogName !== void 0) params.append("catalog_name", req.catalogName);
217
+ if (req.schemaNamePattern !== void 0) params.append("schema_name_pattern", req.schemaNamePattern);
218
+ if (req.tableNamePattern !== void 0) params.append("table_name_pattern", req.tableNamePattern);
219
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
220
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
221
+ if (req.includeManifestCapabilities !== void 0) params.append("include_manifest_capabilities", String(req.includeManifestCapabilities));
222
+ const query = params.toString();
223
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
224
+ let resp;
225
+ const call = async (callSignal) => {
226
+ const headers = new Headers();
227
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
228
+ headers.set("User-Agent", this.userAgent);
229
+ resp = parseResponse(await executeHttpCall({
230
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
231
+ httpClient,
232
+ logger: this.logger
233
+ }), unmarshalListTableSummariesResponseSchema);
234
+ };
235
+ await executeCall(call, options);
236
+ if (resp === void 0) throw new Error("operation completed without a result.");
237
+ return resp;
238
+ }
239
+ async *listTableSummariesIter(req, options) {
240
+ const pageReq = { ...req };
241
+ for (;;) {
242
+ const resp = await this.listTableSummaries(pageReq, options);
243
+ for (const item of resp.tables ?? []) yield item;
244
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
245
+ pageReq.pageToken = resp.nextPageToken;
246
+ }
247
+ }
248
+ /**
249
+ * Gets an array of all tables for the current metastore under the parent catalog and schema.
250
+ * The caller must be a metastore admin or an owner of (or have the **SELECT** privilege on) the table.
251
+ * For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
252
+ * There is no guarantee of a specific ordering of the elements in the array.
253
+ *
254
+ * NOTE: **view_dependencies** and **table_constraints** are not returned by ListTables queries.
255
+ *
256
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
257
+ *
258
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
259
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
260
+ */
261
+ async listTables(req, options) {
262
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
263
+ const url = `${host}/api/2.1/unity-catalog/tables`;
264
+ const params = new URLSearchParams();
265
+ if (req.catalogName !== void 0) params.append("catalog_name", req.catalogName);
266
+ if (req.schemaName !== void 0) params.append("schema_name", req.schemaName);
267
+ if (req.maxResults !== void 0) params.append("max_results", String(req.maxResults));
268
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
269
+ if (req.omitColumns !== void 0) params.append("omit_columns", String(req.omitColumns));
270
+ if (req.omitProperties !== void 0) params.append("omit_properties", String(req.omitProperties));
271
+ if (req.omitUsername !== void 0) params.append("omit_username", String(req.omitUsername));
272
+ if (req.includeBrowse !== void 0) params.append("include_browse", String(req.includeBrowse));
273
+ if (req.includeManifestCapabilities !== void 0) params.append("include_manifest_capabilities", String(req.includeManifestCapabilities));
274
+ const query = params.toString();
275
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
276
+ let resp;
277
+ const call = async (callSignal) => {
278
+ const headers = new Headers();
279
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
280
+ headers.set("User-Agent", this.userAgent);
281
+ resp = parseResponse(await executeHttpCall({
282
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
283
+ httpClient,
284
+ logger: this.logger
285
+ }), unmarshalListTablesResponseSchema);
286
+ };
287
+ await executeCall(call, options);
288
+ if (resp === void 0) throw new Error("operation completed without a result.");
289
+ return resp;
290
+ }
291
+ async *listTablesIter(req, options) {
292
+ const pageReq = { ...req };
293
+ for (;;) {
294
+ const resp = await this.listTables(pageReq, options);
295
+ for (const item of resp.tables ?? []) yield item;
296
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
297
+ pageReq.pageToken = resp.nextPageToken;
298
+ }
299
+ }
300
+ /**
301
+ * Gets if a table exists in the metastore for a specific catalog and schema.
302
+ * The caller must satisfy one of the following requirements:
303
+ * * Be a metastore admin
304
+ * * Be the owner of the parent catalog
305
+ * * Be the owner of the parent schema and have the **USE_CATALOG** privilege on the parent catalog
306
+ * * Have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema,
307
+ * and either be the table owner or have the **SELECT** privilege on the table.
308
+ * * Have **BROWSE** privilege on the parent catalog
309
+ * * Have **BROWSE** privilege on the parent schema
310
+ */
311
+ async tableExists(req, options) {
312
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
313
+ const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ""}/exists`;
314
+ let resp;
315
+ const call = async (callSignal) => {
316
+ const headers = new Headers();
317
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
318
+ headers.set("User-Agent", this.userAgent);
319
+ resp = parseResponse(await executeHttpCall({
320
+ request: buildHttpRequest("GET", url, headers, callSignal),
321
+ httpClient,
322
+ logger: this.logger
323
+ }), unmarshalTableExistsResponseSchema);
324
+ };
325
+ await executeCall(call, options);
326
+ if (resp === void 0) throw new Error("operation completed without a result.");
327
+ return resp;
328
+ }
329
+ /**
330
+ * Change the owner of the table.
331
+ * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema,
332
+ * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
333
+ */
334
+ async updateTable(req, options) {
335
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
336
+ const url = `${host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ""}`;
337
+ const body = marshalRequest(req, marshalUpdateTableRequestSchema);
338
+ let resp;
339
+ const call = async (callSignal) => {
340
+ const headers = new Headers({ "Content-Type": "application/json" });
341
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
342
+ headers.set("User-Agent", this.userAgent);
343
+ resp = parseResponse(await executeHttpCall({
344
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
345
+ httpClient,
346
+ logger: this.logger
347
+ }), unmarshalUpdateTableResponseSchema);
348
+ };
349
+ await executeCall(call, options);
350
+ if (resp === void 0) throw new Error("operation completed without a result.");
351
+ return resp;
352
+ }
353
+ };
354
+
355
+ //#endregion
356
+ export { TablesClient };
460
357
  //# sourceMappingURL=client.js.map