@databricks/sdk-uc-catalogs 0.1.0-dev.3 → 0.1.0-dev.5

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/src/v1/client.ts DELETED
@@ -1,272 +0,0 @@
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
- CatalogInfo,
21
- CreateCatalogRequest,
22
- DeleteCatalogRequest,
23
- DeleteCatalogResponse,
24
- GetCatalogRequest,
25
- ListCatalogsRequest,
26
- ListCatalogsResponse,
27
- UpdateCatalogRequest,
28
- } from './model';
29
- import {
30
- marshalCreateCatalogRequestSchema,
31
- marshalUpdateCatalogRequestSchema,
32
- unmarshalCatalogInfoSchema,
33
- unmarshalDeleteCatalogResponseSchema,
34
- unmarshalListCatalogsResponseSchema,
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 CatalogsClient {
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
- /** Creates a new catalog instance in the parent metastore if the caller is a metastore admin or has the **CREATE_CATALOG** privilege. */
72
- async createCatalog(
73
- req: CreateCatalogRequest,
74
- options?: CallOptions
75
- ): Promise<CatalogInfo> {
76
- const url = `${this.host}/api/2.1/unity-catalog/catalogs`;
77
- const body = marshalRequest(req, marshalCreateCatalogRequestSchema);
78
- let resp: CatalogInfo | undefined;
79
- const call = async (callSignal?: AbortSignal): Promise<void> => {
80
- const headers = new Headers({'Content-Type': 'application/json'});
81
- if (this.workspaceId !== undefined) {
82
- headers.set('X-Databricks-Org-Id', this.workspaceId);
83
- }
84
- headers.set('User-Agent', this.userAgent);
85
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
86
- const respBody = await executeHttpCall({
87
- request: httpReq,
88
- httpClient: this.httpClient,
89
- logger: this.logger,
90
- });
91
- resp = parseResponse(respBody, unmarshalCatalogInfoSchema);
92
- };
93
- await executeCall(call, options);
94
- if (resp === undefined) {
95
- throw new Error('operation completed without a result.');
96
- }
97
- return resp;
98
- }
99
-
100
- /** Deletes the catalog that matches the supplied name. The caller must be a metastore admin or the owner of the catalog. */
101
- async deleteCatalog(
102
- req: DeleteCatalogRequest,
103
- options?: CallOptions
104
- ): Promise<DeleteCatalogResponse> {
105
- const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`;
106
- const params = new URLSearchParams();
107
- if (req.force !== undefined) {
108
- params.append('force', String(req.force));
109
- }
110
- const query = params.toString();
111
- const fullUrl = query !== '' ? `${url}?${query}` : url;
112
- let resp: DeleteCatalogResponse | undefined;
113
- const call = async (callSignal?: AbortSignal): Promise<void> => {
114
- const headers = new Headers();
115
- if (this.workspaceId !== undefined) {
116
- headers.set('X-Databricks-Org-Id', this.workspaceId);
117
- }
118
- headers.set('User-Agent', this.userAgent);
119
- const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
120
- const respBody = await executeHttpCall({
121
- request: httpReq,
122
- httpClient: this.httpClient,
123
- logger: this.logger,
124
- });
125
- resp = parseResponse(respBody, unmarshalDeleteCatalogResponseSchema);
126
- };
127
- await executeCall(call, options);
128
- if (resp === undefined) {
129
- throw new Error('operation completed without a result.');
130
- }
131
- return resp;
132
- }
133
-
134
- /**
135
- * Gets the specified catalog in a metastore.
136
- * The caller must be a metastore admin, the owner of the catalog, or a user that has the **USE_CATALOG** privilege set for their account.
137
- */
138
- async getCatalog(
139
- req: GetCatalogRequest,
140
- options?: CallOptions
141
- ): Promise<CatalogInfo> {
142
- const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`;
143
- const params = new URLSearchParams();
144
- if (req.includeBrowse !== undefined) {
145
- params.append('include_browse', String(req.includeBrowse));
146
- }
147
- const query = params.toString();
148
- const fullUrl = query !== '' ? `${url}?${query}` : url;
149
- let resp: CatalogInfo | undefined;
150
- const call = async (callSignal?: AbortSignal): Promise<void> => {
151
- const headers = new Headers();
152
- if (this.workspaceId !== undefined) {
153
- headers.set('X-Databricks-Org-Id', this.workspaceId);
154
- }
155
- headers.set('User-Agent', this.userAgent);
156
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
157
- const respBody = await executeHttpCall({
158
- request: httpReq,
159
- httpClient: this.httpClient,
160
- logger: this.logger,
161
- });
162
- resp = parseResponse(respBody, unmarshalCatalogInfoSchema);
163
- };
164
- await executeCall(call, options);
165
- if (resp === undefined) {
166
- throw new Error('operation completed without a result.');
167
- }
168
- return resp;
169
- }
170
-
171
- /**
172
- * Gets an array of catalogs in the metastore.
173
- * If the caller is the metastore admin, all catalogs will be retrieved.
174
- * Otherwise, only catalogs owned by the caller (or for which the caller has the **USE_CATALOG** privilege) will be retrieved.
175
- * There is no guarantee of a specific ordering of the elements in the array.
176
- *
177
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
178
- *
179
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
180
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
181
- */
182
- async listCatalogs(
183
- req: ListCatalogsRequest,
184
- options?: CallOptions
185
- ): Promise<ListCatalogsResponse> {
186
- const url = `${this.host}/api/2.1/unity-catalog/catalogs`;
187
- const params = new URLSearchParams();
188
- if (req.includeBrowse !== undefined) {
189
- params.append('include_browse', String(req.includeBrowse));
190
- }
191
- if (req.maxResults !== undefined) {
192
- params.append('max_results', String(req.maxResults));
193
- }
194
- if (req.pageToken !== undefined) {
195
- params.append('page_token', req.pageToken);
196
- }
197
- if (req.includeUnbound !== undefined) {
198
- params.append('include_unbound', String(req.includeUnbound));
199
- }
200
- const query = params.toString();
201
- const fullUrl = query !== '' ? `${url}?${query}` : url;
202
- let resp: ListCatalogsResponse | undefined;
203
- const call = async (callSignal?: AbortSignal): Promise<void> => {
204
- const headers = new Headers();
205
- if (this.workspaceId !== undefined) {
206
- headers.set('X-Databricks-Org-Id', this.workspaceId);
207
- }
208
- headers.set('User-Agent', this.userAgent);
209
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
210
- const respBody = await executeHttpCall({
211
- request: httpReq,
212
- httpClient: this.httpClient,
213
- logger: this.logger,
214
- });
215
- resp = parseResponse(respBody, unmarshalListCatalogsResponseSchema);
216
- };
217
- await executeCall(call, options);
218
- if (resp === undefined) {
219
- throw new Error('operation completed without a result.');
220
- }
221
- return resp;
222
- }
223
-
224
- async *listCatalogsIter(
225
- req: ListCatalogsRequest,
226
- options?: CallOptions
227
- ): AsyncGenerator<CatalogInfo> {
228
- const pageReq: ListCatalogsRequest = {...req};
229
- for (;;) {
230
- const resp = await this.listCatalogs(pageReq, options);
231
- for (const item of resp.catalogs ?? []) {
232
- yield item;
233
- }
234
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
235
- return;
236
- }
237
- pageReq.pageToken = resp.nextPageToken;
238
- }
239
- }
240
-
241
- /**
242
- * Updates the catalog that matches the supplied name.
243
- * The caller must be either the owner of the catalog, or a metastore admin (when changing the owner field of the catalog).
244
- */
245
- async updateCatalog(
246
- req: UpdateCatalogRequest,
247
- options?: CallOptions
248
- ): Promise<CatalogInfo> {
249
- const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`;
250
- const body = marshalRequest(req, marshalUpdateCatalogRequestSchema);
251
- let resp: CatalogInfo | undefined;
252
- const call = async (callSignal?: AbortSignal): Promise<void> => {
253
- const headers = new Headers({'Content-Type': 'application/json'});
254
- if (this.workspaceId !== undefined) {
255
- headers.set('X-Databricks-Org-Id', this.workspaceId);
256
- }
257
- headers.set('User-Agent', this.userAgent);
258
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
259
- const respBody = await executeHttpCall({
260
- request: httpReq,
261
- httpClient: this.httpClient,
262
- logger: this.logger,
263
- });
264
- resp = parseResponse(respBody, unmarshalCatalogInfoSchema);
265
- };
266
- await executeCall(call, options);
267
- if (resp === undefined) {
268
- throw new Error('operation completed without a result.');
269
- }
270
- return resp;
271
- }
272
- }
package/src/v1/index.ts DELETED
@@ -1,31 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {CatalogsClient} from './client';
4
-
5
- export {
6
- CatalogIsolationMode,
7
- CatalogType,
8
- SecurableType,
9
- ProvisioningInfo_State,
10
- } from './model';
11
-
12
- export type {
13
- AzureEncryptionSettings,
14
- CatalogInfo,
15
- CatalogInfo_OptionsEntry,
16
- CatalogInfo_PropertiesEntry,
17
- CreateCatalogRequest,
18
- CreateCatalogRequest_OptionsEntry,
19
- CreateCatalogRequest_PropertiesEntry,
20
- DeleteCatalogRequest,
21
- DeleteCatalogResponse,
22
- EffectivePredictiveOptimizationFlag,
23
- EncryptionSettings,
24
- GetCatalogRequest,
25
- ListCatalogsRequest,
26
- ListCatalogsResponse,
27
- ProvisioningInfo,
28
- UpdateCatalogRequest,
29
- UpdateCatalogRequest_OptionsEntry,
30
- UpdateCatalogRequest_PropertiesEntry,
31
- } from './model';