@databricks/sdk-uc-externallocations 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-externallocations",
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,286 @@
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
+ CreateExternalLocationRequest,
21
+ DeleteExternalLocationRequest,
22
+ DeleteExternalLocationRequest_Response,
23
+ ExternalLocationInfo,
24
+ GetExternalLocationRequest,
25
+ ListExternalLocationsRequest,
26
+ ListExternalLocationsRequest_Response,
27
+ UpdateExternalLocationRequest,
28
+ } from './model';
29
+ import {
30
+ marshalCreateExternalLocationRequestSchema,
31
+ marshalUpdateExternalLocationRequestSchema,
32
+ unmarshalDeleteExternalLocationRequest_ResponseSchema,
33
+ unmarshalExternalLocationInfoSchema,
34
+ unmarshalListExternalLocationsRequest_ResponseSchema,
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 ExternalLocationsClient {
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 external location entry in the metastore.
73
+ * The caller must be a metastore admin or have the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage credential.
74
+ */
75
+ async createExternalLocation(
76
+ req: CreateExternalLocationRequest,
77
+ options?: CallOptions
78
+ ): Promise<ExternalLocationInfo> {
79
+ const url = `${this.host}/api/2.1/unity-catalog/external-locations`;
80
+ const body = marshalRequest(
81
+ req,
82
+ marshalCreateExternalLocationRequestSchema
83
+ );
84
+ let resp: ExternalLocationInfo | undefined;
85
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
86
+ const headers = new Headers({'Content-Type': 'application/json'});
87
+ if (this.workspaceId !== undefined) {
88
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
89
+ }
90
+ headers.set('User-Agent', this.userAgent);
91
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
92
+ const respBody = await executeHttpCall({
93
+ request: httpReq,
94
+ httpClient: this.httpClient,
95
+ logger: this.logger,
96
+ });
97
+ resp = parseResponse(respBody, unmarshalExternalLocationInfoSchema);
98
+ };
99
+ await executeCall(call, options);
100
+ if (resp === undefined) {
101
+ throw new Error('operation completed without a result.');
102
+ }
103
+ return resp;
104
+ }
105
+
106
+ /** Deletes the specified external location from the metastore. The caller must be the owner of the external location. */
107
+ async deleteExternalLocation(
108
+ req: DeleteExternalLocationRequest,
109
+ options?: CallOptions
110
+ ): Promise<DeleteExternalLocationRequest_Response> {
111
+ const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`;
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: DeleteExternalLocationRequest_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
+ unmarshalDeleteExternalLocationRequest_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 an external location from the metastore.
145
+ * The caller must be either a metastore admin, the owner of the external location, or a user that has some privilege on the external location.
146
+ */
147
+ async getExternalLocation(
148
+ req: GetExternalLocationRequest,
149
+ options?: CallOptions
150
+ ): Promise<ExternalLocationInfo> {
151
+ const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`;
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: ExternalLocationInfo | 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, unmarshalExternalLocationInfoSchema);
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 external locations (__ExternalLocationInfo__ objects) from the metastore.
182
+ * The caller must be a metastore admin, the owner of the external location, or a user that has some privilege on the external location.
183
+ * There is no guarantee of a specific ordering of the elements in the array.
184
+ *
185
+ * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
186
+ *
187
+ * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
188
+ * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
189
+ */
190
+ async listExternalLocations(
191
+ req: ListExternalLocationsRequest,
192
+ options?: CallOptions
193
+ ): Promise<ListExternalLocationsRequest_Response> {
194
+ const url = `${this.host}/api/2.1/unity-catalog/external-locations`;
195
+ const params = new URLSearchParams();
196
+ if (req.includeBrowse !== undefined) {
197
+ params.append('include_browse', String(req.includeBrowse));
198
+ }
199
+ if (req.maxResults !== undefined) {
200
+ params.append('max_results', String(req.maxResults));
201
+ }
202
+ if (req.pageToken !== undefined) {
203
+ params.append('page_token', req.pageToken);
204
+ }
205
+ if (req.includeUnbound !== undefined) {
206
+ params.append('include_unbound', String(req.includeUnbound));
207
+ }
208
+ const query = params.toString();
209
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
210
+ let resp: ListExternalLocationsRequest_Response | undefined;
211
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
212
+ const headers = new Headers();
213
+ if (this.workspaceId !== undefined) {
214
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
215
+ }
216
+ headers.set('User-Agent', this.userAgent);
217
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
218
+ const respBody = await executeHttpCall({
219
+ request: httpReq,
220
+ httpClient: this.httpClient,
221
+ logger: this.logger,
222
+ });
223
+ resp = parseResponse(
224
+ respBody,
225
+ unmarshalListExternalLocationsRequest_ResponseSchema
226
+ );
227
+ };
228
+ await executeCall(call, options);
229
+ if (resp === undefined) {
230
+ throw new Error('operation completed without a result.');
231
+ }
232
+ return resp;
233
+ }
234
+
235
+ async *listExternalLocationsIter(
236
+ req: ListExternalLocationsRequest,
237
+ options?: CallOptions
238
+ ): AsyncGenerator<ExternalLocationInfo> {
239
+ const pageReq: ListExternalLocationsRequest = {...req};
240
+ for (;;) {
241
+ const resp = await this.listExternalLocations(pageReq, options);
242
+ for (const item of resp.externalLocations ?? []) {
243
+ yield item;
244
+ }
245
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
246
+ return;
247
+ }
248
+ pageReq.pageToken = resp.nextPageToken;
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Updates an external location in the metastore. The caller must be the owner of the external location, or be a metastore admin.
254
+ * In the second case, the admin can only update the name of the external location.
255
+ */
256
+ async updateExternalLocation(
257
+ req: UpdateExternalLocationRequest,
258
+ options?: CallOptions
259
+ ): Promise<ExternalLocationInfo> {
260
+ const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`;
261
+ const body = marshalRequest(
262
+ req,
263
+ marshalUpdateExternalLocationRequestSchema
264
+ );
265
+ let resp: ExternalLocationInfo | undefined;
266
+ const call = async (callSignal?: AbortSignal): Promise<void> => {
267
+ const headers = new Headers({'Content-Type': 'application/json'});
268
+ if (this.workspaceId !== undefined) {
269
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
270
+ }
271
+ headers.set('User-Agent', this.userAgent);
272
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
273
+ const respBody = await executeHttpCall({
274
+ request: httpReq,
275
+ httpClient: this.httpClient,
276
+ logger: this.logger,
277
+ });
278
+ resp = parseResponse(respBody, unmarshalExternalLocationInfoSchema);
279
+ };
280
+ await executeCall(call, options);
281
+ if (resp === undefined) {
282
+ throw new Error('operation completed without a result.');
283
+ }
284
+ return resp;
285
+ }
286
+ }
@@ -0,0 +1,22 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {ExternalLocationsClient} from './client';
4
+
5
+ export {IsolationMode, SseEncryptionAlgorithm} from './model';
6
+
7
+ export type {
8
+ AwsSqsQueue,
9
+ AzureQueueStorage,
10
+ CreateExternalLocationRequest,
11
+ DeleteExternalLocationRequest,
12
+ DeleteExternalLocationRequest_Response,
13
+ EncryptionDetails,
14
+ ExternalLocationInfo,
15
+ FileEventQueue,
16
+ GcpPubsub,
17
+ GetExternalLocationRequest,
18
+ ListExternalLocationsRequest,
19
+ ListExternalLocationsRequest_Response,
20
+ SseEncryptionDetails,
21
+ UpdateExternalLocationRequest,
22
+ } from './model';