@databricks/sdk-uc-schemas 0.0.0-dev → 0.1.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,41 @@
1
1
  {
2
2
  "name": "@databricks/sdk-uc-schemas",
3
- "version": "0.0.0-dev",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0-dev.2",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "typecheck": "tsc --noEmit",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
25
+ "test": "echo 'no tests'",
26
+ "test:browser": "echo 'no tests'"
27
+ },
28
+ "author": "Databricks",
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@databricks/sdk-auth": ">=0.1.0-dev.3 <1.0.0",
32
+ "@databricks/sdk-core": ">=0.1.0-dev.4 <1.0.0",
33
+ "@databricks/sdk-options": ">=0.1.0-dev.3 <1.0.0",
34
+ "@js-temporal/polyfill": "^0.5.0",
35
+ "json-bigint": "^1.0.0",
36
+ "zod": "^4.3.6"
37
+ },
38
+ "engines": {
39
+ "node": ">=22.0.0"
40
+ }
7
41
  }
@@ -0,0 +1,285 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
5
+ import type {Logger} from '@databricks/sdk-core/logger';
6
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
7
+ import type {CallOptions} from '@databricks/sdk-options/call';
8
+ import type {ClientOptions} from '@databricks/sdk-options/client';
9
+ import type {HttpClient} from '@databricks/sdk-core/http';
10
+ import {newHttpClient} from './transport';
11
+ import {
12
+ buildHttpRequest,
13
+ executeCall,
14
+ executeHttpCall,
15
+ marshalRequest,
16
+ parseResponse,
17
+ } from './utils';
18
+ import pkgJson from '../../package.json' with {type: 'json'};
19
+ import type {
20
+ CreateSchemaRequest,
21
+ DeleteSchemaRequest,
22
+ DeleteSchemaRequest_Response,
23
+ GetSchemaRequest,
24
+ ListSchemasRequest,
25
+ ListSchemasRequest_Response,
26
+ SchemaInfo,
27
+ UpdateSchemaRequest,
28
+ } from './model';
29
+ import {
30
+ marshalCreateSchemaRequestSchema,
31
+ marshalUpdateSchemaRequestSchema,
32
+ unmarshalDeleteSchemaRequest_ResponseSchema,
33
+ unmarshalListSchemasRequest_ResponseSchema,
34
+ unmarshalSchemaInfoSchema,
35
+ } from './model';
36
+
37
+ // Package identity segment for this client to be used in the User-Agent header.
38
+ const PACKAGE_SEGMENT = {
39
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
40
+ value: pkgJson.version,
41
+ };
42
+
43
+ export class SchemasClient {
44
+ private readonly host: string;
45
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
46
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
47
+ // request.
48
+ private readonly workspaceId: string | undefined;
49
+ private readonly httpClient: HttpClient;
50
+ private readonly logger: Logger;
51
+ // User-Agent header value. Composed once at construction from
52
+ // createDefault() merged with this package's identity and the active
53
+ // credential's name.
54
+ private readonly userAgent: string;
55
+
56
+ constructor(options: ClientOptions) {
57
+ if (options.host === undefined) {
58
+ throw new Error('Host is required.');
59
+ }
60
+ this.host = options.host.replace(/\/$/, '');
61
+ this.workspaceId = options.workspaceId;
62
+ this.logger = options.logger ?? new NoOpLogger();
63
+ const info = createDefault()
64
+ .with(PACKAGE_SEGMENT)
65
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
66
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
67
+ this.userAgent = info.toString();
68
+ this.httpClient = newHttpClient(options);
69
+ }
70
+
71
+ /**
72
+ * Creates a new schema for catalog in the Metastore.
73
+ * The caller must be a metastore admin, or have the **CREATE_SCHEMA** privilege in the parent catalog.
74
+ */
75
+ async createSchema(
76
+ req: CreateSchemaRequest,
77
+ options?: CallOptions
78
+ ): Promise<SchemaInfo> {
79
+ const url = `${this.host}/api/2.1/unity-catalog/schemas`;
80
+ const body = marshalRequest(req, marshalCreateSchemaRequestSchema);
81
+ let resp: SchemaInfo | undefined;
82
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
83
+ const headers = new Headers({'Content-Type': 'application/json'});
84
+ if (this.workspaceId !== undefined) {
85
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
86
+ }
87
+ headers.set('User-Agent', this.userAgent);
88
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
89
+ const respBody = await executeHttpCall({
90
+ request: httpReq,
91
+ httpClient: this.httpClient,
92
+ logger: this.logger,
93
+ });
94
+ resp = parseResponse(respBody, unmarshalSchemaInfoSchema);
95
+ };
96
+ await executeCall(call, options);
97
+ if (resp === undefined) {
98
+ throw new Error('operation completed without a result.');
99
+ }
100
+ return resp;
101
+ }
102
+
103
+ /**
104
+ * Deletes the specified schema from the parent catalog.
105
+ * The caller must be the owner of the schema or an owner of the parent catalog.
106
+ */
107
+ async deleteSchema(
108
+ req: DeleteSchemaRequest,
109
+ options?: CallOptions
110
+ ): Promise<DeleteSchemaRequest_Response> {
111
+ const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`;
112
+ const params = new URLSearchParams();
113
+ if (req.force !== undefined) {
114
+ params.append('force', String(req.force));
115
+ }
116
+ const query = params.toString();
117
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
118
+ let resp: DeleteSchemaRequest_Response | undefined;
119
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
120
+ const headers = new Headers();
121
+ if (this.workspaceId !== undefined) {
122
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
123
+ }
124
+ headers.set('User-Agent', this.userAgent);
125
+ const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
126
+ const respBody = await executeHttpCall({
127
+ request: httpReq,
128
+ httpClient: this.httpClient,
129
+ logger: this.logger,
130
+ });
131
+ resp = parseResponse(
132
+ respBody,
133
+ unmarshalDeleteSchemaRequest_ResponseSchema
134
+ );
135
+ };
136
+ await executeCall(call, options);
137
+ if (resp === undefined) {
138
+ throw new Error('operation completed without a result.');
139
+ }
140
+ return resp;
141
+ }
142
+
143
+ /**
144
+ * Gets the specified schema within the metastore.
145
+ * The caller must be a metastore admin, the owner of the schema, or a user that has the **USE_SCHEMA** privilege on the schema.
146
+ */
147
+ async getSchema(
148
+ req: GetSchemaRequest,
149
+ options?: CallOptions
150
+ ): Promise<SchemaInfo> {
151
+ const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`;
152
+ const params = new URLSearchParams();
153
+ if (req.includeBrowse !== undefined) {
154
+ params.append('include_browse', String(req.includeBrowse));
155
+ }
156
+ const query = params.toString();
157
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
158
+ let resp: SchemaInfo | undefined;
159
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
160
+ const headers = new Headers();
161
+ if (this.workspaceId !== undefined) {
162
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
163
+ }
164
+ headers.set('User-Agent', this.userAgent);
165
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
166
+ const respBody = await executeHttpCall({
167
+ request: httpReq,
168
+ httpClient: this.httpClient,
169
+ logger: this.logger,
170
+ });
171
+ resp = parseResponse(respBody, unmarshalSchemaInfoSchema);
172
+ };
173
+ await executeCall(call, options);
174
+ if (resp === undefined) {
175
+ throw new Error('operation completed without a result.');
176
+ }
177
+ return resp;
178
+ }
179
+
180
+ /**
181
+ * Gets an array of schemas for a catalog in the metastore.
182
+ * If the caller is the metastore admin or the owner of the parent catalog, all schemas for the catalog will be retrieved.
183
+ * Otherwise, only schemas owned by the caller (or for which the caller has the **USE_SCHEMA** privilege) will be retrieved.
184
+ * There is no guarantee of a specific ordering of the elements in the array.
185
+ *
186
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
187
+ *
188
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
189
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
190
+ */
191
+ async listSchemas(
192
+ req: ListSchemasRequest,
193
+ options?: CallOptions
194
+ ): Promise<ListSchemasRequest_Response> {
195
+ const url = `${this.host}/api/2.1/unity-catalog/schemas`;
196
+ const params = new URLSearchParams();
197
+ if (req.catalogName !== undefined) {
198
+ params.append('catalog_name', req.catalogName);
199
+ }
200
+ if (req.maxResults !== undefined) {
201
+ params.append('max_results', String(req.maxResults));
202
+ }
203
+ if (req.pageToken !== undefined) {
204
+ params.append('page_token', req.pageToken);
205
+ }
206
+ if (req.includeBrowse !== undefined) {
207
+ params.append('include_browse', String(req.includeBrowse));
208
+ }
209
+ const query = params.toString();
210
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
211
+ let resp: ListSchemasRequest_Response | undefined;
212
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
213
+ const headers = new Headers();
214
+ if (this.workspaceId !== undefined) {
215
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
216
+ }
217
+ headers.set('User-Agent', this.userAgent);
218
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
219
+ const respBody = await executeHttpCall({
220
+ request: httpReq,
221
+ httpClient: this.httpClient,
222
+ logger: this.logger,
223
+ });
224
+ resp = parseResponse(
225
+ respBody,
226
+ unmarshalListSchemasRequest_ResponseSchema
227
+ );
228
+ };
229
+ await executeCall(call, options);
230
+ if (resp === undefined) {
231
+ throw new Error('operation completed without a result.');
232
+ }
233
+ return resp;
234
+ }
235
+
236
+ async *listSchemasIter(
237
+ req: ListSchemasRequest,
238
+ options?: CallOptions
239
+ ): AsyncGenerator<SchemaInfo> {
240
+ const pageReq: ListSchemasRequest = {...req};
241
+ for (;;) {
242
+ const resp = await this.listSchemas(pageReq, options);
243
+ for (const item of resp.schemas ?? []) {
244
+ yield item;
245
+ }
246
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
247
+ return;
248
+ }
249
+ pageReq.pageToken = resp.nextPageToken;
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Updates a schema for a catalog. The caller must be the owner of the schema or a metastore admin.
255
+ * If the caller is a metastore admin, only the __owner__ field can be changed in the update.
256
+ * If the __name__ field must be updated, the caller must be a metastore admin or have the **CREATE_SCHEMA** privilege on the parent catalog.
257
+ */
258
+ async updateSchema(
259
+ req: UpdateSchemaRequest,
260
+ options?: CallOptions
261
+ ): Promise<SchemaInfo> {
262
+ const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`;
263
+ const body = marshalRequest(req, marshalUpdateSchemaRequestSchema);
264
+ let resp: SchemaInfo | undefined;
265
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
266
+ const headers = new Headers({'Content-Type': 'application/json'});
267
+ if (this.workspaceId !== undefined) {
268
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
269
+ }
270
+ headers.set('User-Agent', this.userAgent);
271
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
272
+ const respBody = await executeHttpCall({
273
+ request: httpReq,
274
+ httpClient: this.httpClient,
275
+ logger: this.logger,
276
+ });
277
+ resp = parseResponse(respBody, unmarshalSchemaInfoSchema);
278
+ };
279
+ await executeCall(call, options);
280
+ if (resp === undefined) {
281
+ throw new Error('operation completed without a result.');
282
+ }
283
+ return resp;
284
+ }
285
+ }
@@ -0,0 +1,23 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {SchemasClient} from './client';
4
+
5
+ export {CatalogType} from './model';
6
+
7
+ export type {
8
+ CreateSchemaRequest,
9
+ CreateSchemaRequest_OptionsEntry,
10
+ CreateSchemaRequest_PropertiesEntry,
11
+ DeleteSchemaRequest,
12
+ DeleteSchemaRequest_Response,
13
+ EffectivePredictiveOptimizationFlag,
14
+ GetSchemaRequest,
15
+ ListSchemasRequest,
16
+ ListSchemasRequest_Response,
17
+ SchemaInfo,
18
+ SchemaInfo_OptionsEntry,
19
+ SchemaInfo_PropertiesEntry,
20
+ UpdateSchemaRequest,
21
+ UpdateSchemaRequest_OptionsEntry,
22
+ UpdateSchemaRequest_PropertiesEntry,
23
+ } from './model';