@databricks/sdk-uc-volumes 0.1.0-dev.2 → 0.1.0-dev.4

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,314 +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
- CreateVolumeRequest,
21
- DeleteVolumeRequest,
22
- DeleteVolumeRequest_Response,
23
- GetVolumeRequest,
24
- ListVolumesRequest,
25
- ListVolumesRequest_Response,
26
- UpdateVolumeRequest,
27
- VolumeInfo,
28
- } from './model';
29
- import {
30
- marshalCreateVolumeRequestSchema,
31
- marshalUpdateVolumeRequestSchema,
32
- unmarshalDeleteVolumeRequest_ResponseSchema,
33
- unmarshalListVolumesRequest_ResponseSchema,
34
- unmarshalVolumeInfoSchema,
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 VolumesClient {
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 volume.
73
- *
74
- * The user could create either an external volume or a managed volume. An external volume
75
- * will be created in the specified external location, while a managed volume
76
- * will be located in the default location which is specified by the parent schema,
77
- * or the parent catalog, or the Metastore.
78
- *
79
- * For the volume creation to succeed, the user must satisfy following conditions:
80
- * - The caller must be a metastore admin, or be the owner of the parent catalog and schema,
81
- * or have the **USE_CATALOG** privilege on the parent catalog
82
- * and the **USE_SCHEMA** privilege on the parent schema.
83
- * - The caller must have **CREATE VOLUME** privilege on the parent schema.
84
- *
85
- * For an external volume, following conditions also need to satisfy
86
- * - The caller must have **CREATE EXTERNAL VOLUME** privilege on the external location.
87
- * - There are no other tables, nor volumes existing in the specified storage location.
88
- * - The specified storage location is not under the location of other tables, nor volumes,
89
- * or catalogs or schemas.
90
- */
91
- async createVolume(
92
- req: CreateVolumeRequest,
93
- options?: CallOptions
94
- ): Promise<VolumeInfo> {
95
- const url = `${this.host}/api/2.1/unity-catalog/volumes`;
96
- const body = marshalRequest(req, marshalCreateVolumeRequestSchema);
97
- let resp: VolumeInfo | undefined;
98
- const call = async (callSignal?: AbortSignal): Promise<void> => {
99
- const headers = new Headers({'Content-Type': 'application/json'});
100
- if (this.workspaceId !== undefined) {
101
- headers.set('X-Databricks-Org-Id', this.workspaceId);
102
- }
103
- headers.set('User-Agent', this.userAgent);
104
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
105
- const respBody = await executeHttpCall({
106
- request: httpReq,
107
- httpClient: this.httpClient,
108
- logger: this.logger,
109
- });
110
- resp = parseResponse(respBody, unmarshalVolumeInfoSchema);
111
- };
112
- await executeCall(call, options);
113
- if (resp === undefined) {
114
- throw new Error('operation completed without a result.');
115
- }
116
- return resp;
117
- }
118
-
119
- /**
120
- * Deletes a volume from the specified parent catalog and schema.
121
- *
122
- * The caller must be a metastore admin or an owner of the volume.
123
- * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
124
- * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
125
- */
126
- async deleteVolume(
127
- req: DeleteVolumeRequest,
128
- options?: CallOptions
129
- ): Promise<DeleteVolumeRequest_Response> {
130
- const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`;
131
- let resp: DeleteVolumeRequest_Response | undefined;
132
- const call = async (callSignal?: AbortSignal): Promise<void> => {
133
- const headers = new Headers();
134
- if (this.workspaceId !== undefined) {
135
- headers.set('X-Databricks-Org-Id', this.workspaceId);
136
- }
137
- headers.set('User-Agent', this.userAgent);
138
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
139
- const respBody = await executeHttpCall({
140
- request: httpReq,
141
- httpClient: this.httpClient,
142
- logger: this.logger,
143
- });
144
- resp = parseResponse(
145
- respBody,
146
- unmarshalDeleteVolumeRequest_ResponseSchema
147
- );
148
- };
149
- await executeCall(call, options);
150
- if (resp === undefined) {
151
- throw new Error('operation completed without a result.');
152
- }
153
- return resp;
154
- }
155
-
156
- /**
157
- * Gets a volume from the metastore for a specific catalog and schema.
158
- *
159
- * The caller must be a metastore admin or an owner of (or have the **READ VOLUME**
160
- * privilege on) the volume.
161
- * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
162
- * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
163
- */
164
- async getVolume(
165
- req: GetVolumeRequest,
166
- options?: CallOptions
167
- ): Promise<VolumeInfo> {
168
- const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`;
169
- const params = new URLSearchParams();
170
- if (req.includeBrowse !== undefined) {
171
- params.append('include_browse', String(req.includeBrowse));
172
- }
173
- const query = params.toString();
174
- const fullUrl = query !== '' ? `${url}?${query}` : url;
175
- let resp: VolumeInfo | undefined;
176
- const call = async (callSignal?: AbortSignal): Promise<void> => {
177
- const headers = new Headers();
178
- if (this.workspaceId !== undefined) {
179
- headers.set('X-Databricks-Org-Id', this.workspaceId);
180
- }
181
- headers.set('User-Agent', this.userAgent);
182
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
183
- const respBody = await executeHttpCall({
184
- request: httpReq,
185
- httpClient: this.httpClient,
186
- logger: this.logger,
187
- });
188
- resp = parseResponse(respBody, unmarshalVolumeInfoSchema);
189
- };
190
- await executeCall(call, options);
191
- if (resp === undefined) {
192
- throw new Error('operation completed without a result.');
193
- }
194
- return resp;
195
- }
196
-
197
- /**
198
- * Gets an array of volumes for the current metastore
199
- * under the parent catalog and schema.
200
- *
201
- * The returned volumes are filtered based on the privileges of the calling user.
202
- * For example, the metastore admin is able to list all the volumes.
203
- * A regular user needs to be the owner or have the **READ VOLUME** privilege
204
- * on the volume to receive the volumes in the response.
205
- * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
206
- * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
207
- *
208
- * There is no guarantee of a specific ordering of the elements in the array.
209
- *
210
- * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
211
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
212
- */
213
- async listVolumes(
214
- req: ListVolumesRequest,
215
- options?: CallOptions
216
- ): Promise<ListVolumesRequest_Response> {
217
- const url = `${this.host}/api/2.1/unity-catalog/volumes`;
218
- const params = new URLSearchParams();
219
- if (req.catalogName !== undefined) {
220
- params.append('catalog_name', req.catalogName);
221
- }
222
- if (req.schemaName !== undefined) {
223
- params.append('schema_name', req.schemaName);
224
- }
225
- if (req.includeBrowse !== undefined) {
226
- params.append('include_browse', String(req.includeBrowse));
227
- }
228
- if (req.maxResults !== undefined) {
229
- params.append('max_results', String(req.maxResults));
230
- }
231
- if (req.pageToken !== undefined) {
232
- params.append('page_token', req.pageToken);
233
- }
234
- const query = params.toString();
235
- const fullUrl = query !== '' ? `${url}?${query}` : url;
236
- let resp: ListVolumesRequest_Response | undefined;
237
- const call = async (callSignal?: AbortSignal): Promise<void> => {
238
- const headers = new Headers();
239
- if (this.workspaceId !== undefined) {
240
- headers.set('X-Databricks-Org-Id', this.workspaceId);
241
- }
242
- headers.set('User-Agent', this.userAgent);
243
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
244
- const respBody = await executeHttpCall({
245
- request: httpReq,
246
- httpClient: this.httpClient,
247
- logger: this.logger,
248
- });
249
- resp = parseResponse(
250
- respBody,
251
- unmarshalListVolumesRequest_ResponseSchema
252
- );
253
- };
254
- await executeCall(call, options);
255
- if (resp === undefined) {
256
- throw new Error('operation completed without a result.');
257
- }
258
- return resp;
259
- }
260
-
261
- async *listVolumesIter(
262
- req: ListVolumesRequest,
263
- options?: CallOptions
264
- ): AsyncGenerator<VolumeInfo> {
265
- const pageReq: ListVolumesRequest = {...req};
266
- for (;;) {
267
- const resp = await this.listVolumes(pageReq, options);
268
- for (const item of resp.volumes ?? []) {
269
- yield item;
270
- }
271
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
272
- return;
273
- }
274
- pageReq.pageToken = resp.nextPageToken;
275
- }
276
- }
277
-
278
- /**
279
- * Updates the specified volume under the specified parent catalog and schema.
280
- *
281
- * The caller must be a metastore admin or an owner of the volume.
282
- * For the latter case, the caller must also be the owner or have the **USE_CATALOG**
283
- * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema.
284
- *
285
- * Currently only the name, the owner or the comment of the volume could be updated.
286
- */
287
- async updateVolume(
288
- req: UpdateVolumeRequest,
289
- options?: CallOptions
290
- ): Promise<VolumeInfo> {
291
- const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`;
292
- const body = marshalRequest(req, marshalUpdateVolumeRequestSchema);
293
- let resp: VolumeInfo | undefined;
294
- const call = async (callSignal?: AbortSignal): Promise<void> => {
295
- const headers = new Headers({'Content-Type': 'application/json'});
296
- if (this.workspaceId !== undefined) {
297
- headers.set('X-Databricks-Org-Id', this.workspaceId);
298
- }
299
- headers.set('User-Agent', this.userAgent);
300
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
301
- const respBody = await executeHttpCall({
302
- request: httpReq,
303
- httpClient: this.httpClient,
304
- logger: this.logger,
305
- });
306
- resp = parseResponse(respBody, unmarshalVolumeInfoSchema);
307
- };
308
- await executeCall(call, options);
309
- if (resp === undefined) {
310
- throw new Error('operation completed without a result.');
311
- }
312
- return resp;
313
- }
314
- }
package/src/v1/index.ts DELETED
@@ -1,18 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {VolumesClient} from './client';
4
-
5
- export {SseEncryptionAlgorithm, VolumeType} from './model';
6
-
7
- export type {
8
- CreateVolumeRequest,
9
- DeleteVolumeRequest,
10
- DeleteVolumeRequest_Response,
11
- EncryptionDetails,
12
- GetVolumeRequest,
13
- ListVolumesRequest,
14
- ListVolumesRequest_Response,
15
- SseEncryptionDetails,
16
- UpdateVolumeRequest,
17
- VolumeInfo,
18
- } from './model';