@databricks/sdk-uc-credentials 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/README.md +28 -0
- package/dist/v1/client.d.ts +3 -4
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +118 -99
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/model.d.ts +42 -35
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +56 -61
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/transport.d.ts +30 -2
- package/dist/v1/transport.d.ts.map +1 -1
- package/dist/v1/transport.js +33 -16
- package/dist/v1/transport.js.map +1 -1
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +2 -1
- package/dist/v1/utils.js.map +1 -1
- package/package.json +9 -5
- package/src/v1/client.ts +0 -1075
- package/src/v1/index.ts +0 -80
- package/src/v1/model.ts +0 -2881
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/dist/v1/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
|
|
3
3
|
import { createDefault } from '@databricks/sdk-core/clientinfo';
|
|
4
4
|
import { NoOpLogger } from '@databricks/sdk-core/logger';
|
|
5
|
-
import {
|
|
5
|
+
import { resolveClientConfig } from './transport';
|
|
6
6
|
import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
|
|
7
7
|
import pkgJson from '../../package.json' with { type: 'json' };
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -13,34 +13,28 @@ const PACKAGE_SEGMENT = {
|
|
|
13
13
|
value: pkgJson.version,
|
|
14
14
|
};
|
|
15
15
|
export class CredentialsClient {
|
|
16
|
-
|
|
17
|
-
// Fallback for endpoints whose path contains {account_id}. If the request
|
|
18
|
-
// already carries an accountId, that value wins.
|
|
19
|
-
accountId;
|
|
20
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
21
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
22
|
-
// request.
|
|
23
|
-
workspaceId;
|
|
24
|
-
httpClient;
|
|
16
|
+
options;
|
|
25
17
|
logger;
|
|
26
18
|
// User-Agent header value. Composed once at construction from
|
|
27
19
|
// createDefault() merged with this package's identity and the active
|
|
28
20
|
// credential's name.
|
|
29
21
|
userAgent;
|
|
22
|
+
// Memoized configuration. The profile is resolved once, lazily, on the first
|
|
23
|
+
// request, then reused; host, workspaceId/accountId, and credentials are
|
|
24
|
+
// filled from it when not set explicitly on the options.
|
|
25
|
+
config;
|
|
30
26
|
constructor(options) {
|
|
31
|
-
|
|
32
|
-
throw new Error('Host is required.');
|
|
33
|
-
}
|
|
34
|
-
this.host = options.host.replace(/\/$/, '');
|
|
35
|
-
this.accountId = options.accountId;
|
|
36
|
-
this.workspaceId = options.workspaceId;
|
|
27
|
+
this.options = options;
|
|
37
28
|
this.logger = options.logger ?? new NoOpLogger();
|
|
38
29
|
const info = createDefault()
|
|
39
30
|
.with(PACKAGE_SEGMENT)
|
|
40
31
|
.with({ key: 'sdk-js-auth', value: AUTH_VERSION })
|
|
41
32
|
.with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
|
|
42
33
|
this.userAgent = info.toString();
|
|
43
|
-
|
|
34
|
+
}
|
|
35
|
+
resolveConfig() {
|
|
36
|
+
this.config ??= resolveClientConfig(this.options);
|
|
37
|
+
return this.config;
|
|
44
38
|
}
|
|
45
39
|
/**
|
|
46
40
|
* Creates a new storage credential. The request object is specific to the cloud:
|
|
@@ -51,7 +45,8 @@ export class CredentialsClient {
|
|
|
51
45
|
* The caller must be a metastore admin and have the `CREATE_STORAGE_CREDENTIAL` privilege on the metastore.
|
|
52
46
|
*/
|
|
53
47
|
async createAccountsStorageCredential(req, options) {
|
|
54
|
-
const
|
|
48
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
49
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/storage-credentials`;
|
|
55
50
|
const body = marshalRequest(req, marshalAccountsCreateStorageCredentialRequestSchema);
|
|
56
51
|
let resp;
|
|
57
52
|
const call = async (callSignal) => {
|
|
@@ -60,7 +55,7 @@ export class CredentialsClient {
|
|
|
60
55
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
61
56
|
const respBody = await executeHttpCall({
|
|
62
57
|
request: httpReq,
|
|
63
|
-
httpClient
|
|
58
|
+
httpClient,
|
|
64
59
|
logger: this.logger,
|
|
65
60
|
});
|
|
66
61
|
resp = parseResponse(respBody, unmarshalAccountsCreateStorageCredentialResponseSchema);
|
|
@@ -73,7 +68,8 @@ export class CredentialsClient {
|
|
|
73
68
|
}
|
|
74
69
|
/** Deletes a storage credential from the metastore. The caller must be an owner of the storage credential. */
|
|
75
70
|
async deleteAccountsStorageCredential(req, options) {
|
|
76
|
-
const
|
|
71
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
72
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/storage-credentials/${req.nameArg ?? ''}`;
|
|
77
73
|
const params = new URLSearchParams();
|
|
78
74
|
if (req.force !== undefined) {
|
|
79
75
|
params.append('force', String(req.force));
|
|
@@ -87,7 +83,7 @@ export class CredentialsClient {
|
|
|
87
83
|
const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
|
|
88
84
|
const respBody = await executeHttpCall({
|
|
89
85
|
request: httpReq,
|
|
90
|
-
httpClient
|
|
86
|
+
httpClient,
|
|
91
87
|
logger: this.logger,
|
|
92
88
|
});
|
|
93
89
|
resp = parseResponse(respBody, unmarshalAccountsDeleteStorageCredentialResponseSchema);
|
|
@@ -103,7 +99,8 @@ export class CredentialsClient {
|
|
|
103
99
|
* storage credential, or have a level of privilege on the storage credential.
|
|
104
100
|
*/
|
|
105
101
|
async getAccountsStorageCredential(req, options) {
|
|
106
|
-
const
|
|
102
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
103
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/storage-credentials/${req.nameArg ?? ''}`;
|
|
107
104
|
let resp;
|
|
108
105
|
const call = async (callSignal) => {
|
|
109
106
|
const headers = new Headers();
|
|
@@ -111,7 +108,7 @@ export class CredentialsClient {
|
|
|
111
108
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
112
109
|
const respBody = await executeHttpCall({
|
|
113
110
|
request: httpReq,
|
|
114
|
-
httpClient
|
|
111
|
+
httpClient,
|
|
115
112
|
logger: this.logger,
|
|
116
113
|
});
|
|
117
114
|
resp = parseResponse(respBody, unmarshalAccountsGetStorageCredentialResponseSchema);
|
|
@@ -124,7 +121,8 @@ export class CredentialsClient {
|
|
|
124
121
|
}
|
|
125
122
|
/** Gets a list of all storage credentials that have been assigned to given metastore. */
|
|
126
123
|
async listAccountsStorageCredentials(req, options) {
|
|
127
|
-
const
|
|
124
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
125
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/storage-credentials`;
|
|
128
126
|
let resp;
|
|
129
127
|
const call = async (callSignal) => {
|
|
130
128
|
const headers = new Headers();
|
|
@@ -132,7 +130,7 @@ export class CredentialsClient {
|
|
|
132
130
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
133
131
|
const respBody = await executeHttpCall({
|
|
134
132
|
request: httpReq,
|
|
135
|
-
httpClient
|
|
133
|
+
httpClient,
|
|
136
134
|
logger: this.logger,
|
|
137
135
|
});
|
|
138
136
|
resp = parseResponse(respBody, unmarshalAccountsListStorageCredentialsResponseSchema);
|
|
@@ -148,7 +146,8 @@ export class CredentialsClient {
|
|
|
148
146
|
* If the caller is a metastore admin, only the **owner** credential can be changed.
|
|
149
147
|
*/
|
|
150
148
|
async updateAccountsStorageCredential(req, options) {
|
|
151
|
-
const
|
|
149
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
150
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/metastores/${req.metastoreId ?? ''}/storage-credentials/${req.nameArg ?? ''}`;
|
|
152
151
|
const body = marshalRequest(req, marshalAccountsUpdateStorageCredentialRequestSchema);
|
|
153
152
|
let resp;
|
|
154
153
|
const call = async (callSignal) => {
|
|
@@ -157,7 +156,7 @@ export class CredentialsClient {
|
|
|
157
156
|
const httpReq = buildHttpRequest('PUT', url, headers, callSignal, body);
|
|
158
157
|
const respBody = await executeHttpCall({
|
|
159
158
|
request: httpReq,
|
|
160
|
-
httpClient
|
|
159
|
+
httpClient,
|
|
161
160
|
logger: this.logger,
|
|
162
161
|
});
|
|
163
162
|
resp = parseResponse(respBody, unmarshalAccountsUpdateStorageCredentialResponseSchema);
|
|
@@ -176,19 +175,20 @@ export class CredentialsClient {
|
|
|
176
175
|
* credentials, or **CREATE_SERVICE_CREDENTIAL** for service credentials.
|
|
177
176
|
*/
|
|
178
177
|
async createCredential(req, options) {
|
|
179
|
-
const
|
|
178
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
179
|
+
const url = `${host}/api/2.1/unity-catalog/credentials`;
|
|
180
180
|
const body = marshalRequest(req, marshalCreateCredentialRequestSchema);
|
|
181
181
|
let resp;
|
|
182
182
|
const call = async (callSignal) => {
|
|
183
183
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
184
|
-
if (
|
|
185
|
-
headers.set('X-Databricks-Org-Id',
|
|
184
|
+
if (workspaceId !== undefined) {
|
|
185
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
186
186
|
}
|
|
187
187
|
headers.set('User-Agent', this.userAgent);
|
|
188
188
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
189
189
|
const respBody = await executeHttpCall({
|
|
190
190
|
request: httpReq,
|
|
191
|
-
httpClient
|
|
191
|
+
httpClient,
|
|
192
192
|
logger: this.logger,
|
|
193
193
|
});
|
|
194
194
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -205,19 +205,20 @@ export class CredentialsClient {
|
|
|
205
205
|
* The caller must be a metastore admin or have the **CREATE_STORAGE_CREDENTIAL** privilege on the metastore.
|
|
206
206
|
*/
|
|
207
207
|
async createStorageCredential(req, options) {
|
|
208
|
-
const
|
|
208
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
209
|
+
const url = `${host}/api/2.1/unity-catalog/storage-credentials`;
|
|
209
210
|
const body = marshalRequest(req, marshalCreateStorageCredentialRequestSchema);
|
|
210
211
|
let resp;
|
|
211
212
|
const call = async (callSignal) => {
|
|
212
213
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
213
|
-
if (
|
|
214
|
-
headers.set('X-Databricks-Org-Id',
|
|
214
|
+
if (workspaceId !== undefined) {
|
|
215
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
215
216
|
}
|
|
216
217
|
headers.set('User-Agent', this.userAgent);
|
|
217
218
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
218
219
|
const respBody = await executeHttpCall({
|
|
219
220
|
request: httpReq,
|
|
220
|
-
httpClient
|
|
221
|
+
httpClient,
|
|
221
222
|
logger: this.logger,
|
|
222
223
|
});
|
|
223
224
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -230,7 +231,8 @@ export class CredentialsClient {
|
|
|
230
231
|
}
|
|
231
232
|
/** Deletes a service or storage credential from the metastore. The caller must be an owner of the credential. */
|
|
232
233
|
async deleteCredential(req, options) {
|
|
233
|
-
const
|
|
234
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
235
|
+
const url = `${host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`;
|
|
234
236
|
const params = new URLSearchParams();
|
|
235
237
|
if (req.force !== undefined) {
|
|
236
238
|
params.append('force', String(req.force));
|
|
@@ -240,14 +242,14 @@ export class CredentialsClient {
|
|
|
240
242
|
let resp;
|
|
241
243
|
const call = async (callSignal) => {
|
|
242
244
|
const headers = new Headers();
|
|
243
|
-
if (
|
|
244
|
-
headers.set('X-Databricks-Org-Id',
|
|
245
|
+
if (workspaceId !== undefined) {
|
|
246
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
245
247
|
}
|
|
246
248
|
headers.set('User-Agent', this.userAgent);
|
|
247
249
|
const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
|
|
248
250
|
const respBody = await executeHttpCall({
|
|
249
251
|
request: httpReq,
|
|
250
|
-
httpClient
|
|
252
|
+
httpClient,
|
|
251
253
|
logger: this.logger,
|
|
252
254
|
});
|
|
253
255
|
resp = parseResponse(respBody, unmarshalDeleteCredentialResponseSchema);
|
|
@@ -260,7 +262,8 @@ export class CredentialsClient {
|
|
|
260
262
|
}
|
|
261
263
|
/** Deletes a storage credential from the metastore. The caller must be an owner of the storage credential. */
|
|
262
264
|
async deleteStorageCredential(req, options) {
|
|
263
|
-
const
|
|
265
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
266
|
+
const url = `${host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`;
|
|
264
267
|
const params = new URLSearchParams();
|
|
265
268
|
if (req.force !== undefined) {
|
|
266
269
|
params.append('force', String(req.force));
|
|
@@ -270,14 +273,14 @@ export class CredentialsClient {
|
|
|
270
273
|
let resp;
|
|
271
274
|
const call = async (callSignal) => {
|
|
272
275
|
const headers = new Headers();
|
|
273
|
-
if (
|
|
274
|
-
headers.set('X-Databricks-Org-Id',
|
|
276
|
+
if (workspaceId !== undefined) {
|
|
277
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
275
278
|
}
|
|
276
279
|
headers.set('User-Agent', this.userAgent);
|
|
277
280
|
const httpReq = buildHttpRequest('DELETE', fullUrl, headers, callSignal);
|
|
278
281
|
const respBody = await executeHttpCall({
|
|
279
282
|
request: httpReq,
|
|
280
|
-
httpClient
|
|
283
|
+
httpClient,
|
|
281
284
|
logger: this.logger,
|
|
282
285
|
});
|
|
283
286
|
resp = parseResponse(respBody, unmarshalDeleteStorageCredentialResponseSchema);
|
|
@@ -299,19 +302,20 @@ export class CredentialsClient {
|
|
|
299
302
|
* this privilege can only be granted by catalog owners.
|
|
300
303
|
*/
|
|
301
304
|
async generateTemporaryPathCredential(req, options) {
|
|
302
|
-
const
|
|
305
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
306
|
+
const url = `${host}/api/2.0/unity-catalog/temporary-path-credentials`;
|
|
303
307
|
const body = marshalRequest(req, marshalGenerateTemporaryPathCredentialRequestSchema);
|
|
304
308
|
let resp;
|
|
305
309
|
const call = async (callSignal) => {
|
|
306
310
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
307
|
-
if (
|
|
308
|
-
headers.set('X-Databricks-Org-Id',
|
|
311
|
+
if (workspaceId !== undefined) {
|
|
312
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
309
313
|
}
|
|
310
314
|
headers.set('User-Agent', this.userAgent);
|
|
311
315
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
312
316
|
const respBody = await executeHttpCall({
|
|
313
317
|
request: httpReq,
|
|
314
|
-
httpClient
|
|
318
|
+
httpClient,
|
|
315
319
|
logger: this.logger,
|
|
316
320
|
});
|
|
317
321
|
resp = parseResponse(respBody, unmarshalGenerateTemporaryPathCredentialResponseSchema);
|
|
@@ -327,19 +331,20 @@ export class CredentialsClient {
|
|
|
327
331
|
* The caller must be a metastore admin or have the metastore privilege **ACCESS** on the service credential.
|
|
328
332
|
*/
|
|
329
333
|
async generateTemporaryServiceCredential(req, options) {
|
|
330
|
-
const
|
|
334
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
335
|
+
const url = `${host}/api/2.1/unity-catalog/temporary-service-credentials`;
|
|
331
336
|
const body = marshalRequest(req, marshalGenerateTemporaryServiceCredentialRequestSchema);
|
|
332
337
|
let resp;
|
|
333
338
|
const call = async (callSignal) => {
|
|
334
339
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
335
|
-
if (
|
|
336
|
-
headers.set('X-Databricks-Org-Id',
|
|
340
|
+
if (workspaceId !== undefined) {
|
|
341
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
337
342
|
}
|
|
338
343
|
headers.set('User-Agent', this.userAgent);
|
|
339
344
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
340
345
|
const respBody = await executeHttpCall({
|
|
341
346
|
request: httpReq,
|
|
342
|
-
httpClient
|
|
347
|
+
httpClient,
|
|
343
348
|
logger: this.logger,
|
|
344
349
|
});
|
|
345
350
|
resp = parseResponse(respBody, unmarshalTemporaryCredentialsSchema);
|
|
@@ -357,19 +362,20 @@ export class CredentialsClient {
|
|
|
357
362
|
* by catalog owners.
|
|
358
363
|
*/
|
|
359
364
|
async generateTemporaryTableCredential(req, options) {
|
|
360
|
-
const
|
|
365
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
366
|
+
const url = `${host}/api/2.0/unity-catalog/temporary-table-credentials`;
|
|
361
367
|
const body = marshalRequest(req, marshalGenerateTemporaryTableCredentialRequestSchema);
|
|
362
368
|
let resp;
|
|
363
369
|
const call = async (callSignal) => {
|
|
364
370
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
365
|
-
if (
|
|
366
|
-
headers.set('X-Databricks-Org-Id',
|
|
371
|
+
if (workspaceId !== undefined) {
|
|
372
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
367
373
|
}
|
|
368
374
|
headers.set('User-Agent', this.userAgent);
|
|
369
375
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
370
376
|
const respBody = await executeHttpCall({
|
|
371
377
|
request: httpReq,
|
|
372
|
-
httpClient
|
|
378
|
+
httpClient,
|
|
373
379
|
logger: this.logger,
|
|
374
380
|
});
|
|
375
381
|
resp = parseResponse(respBody, unmarshalGenerateTemporaryTableCredentialResponseSchema);
|
|
@@ -387,19 +393,20 @@ export class CredentialsClient {
|
|
|
387
393
|
* by catalog owners.
|
|
388
394
|
*/
|
|
389
395
|
async generateTemporaryVolumeCredential(req, options) {
|
|
390
|
-
const
|
|
396
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
397
|
+
const url = `${host}/api/2.0/unity-catalog/temporary-volume-credentials`;
|
|
391
398
|
const body = marshalRequest(req, marshalGenerateTemporaryVolumeCredentialRequestSchema);
|
|
392
399
|
let resp;
|
|
393
400
|
const call = async (callSignal) => {
|
|
394
401
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
395
|
-
if (
|
|
396
|
-
headers.set('X-Databricks-Org-Id',
|
|
402
|
+
if (workspaceId !== undefined) {
|
|
403
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
397
404
|
}
|
|
398
405
|
headers.set('User-Agent', this.userAgent);
|
|
399
406
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
400
407
|
const respBody = await executeHttpCall({
|
|
401
408
|
request: httpReq,
|
|
402
|
-
httpClient
|
|
409
|
+
httpClient,
|
|
403
410
|
logger: this.logger,
|
|
404
411
|
});
|
|
405
412
|
resp = parseResponse(respBody, unmarshalGenerateTemporaryVolumeCredentialResponseSchema);
|
|
@@ -415,18 +422,19 @@ export class CredentialsClient {
|
|
|
415
422
|
* The caller must be a metastore admin, the owner of the credential, or have any permission on the credential.
|
|
416
423
|
*/
|
|
417
424
|
async getCredential(req, options) {
|
|
418
|
-
const
|
|
425
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
426
|
+
const url = `${host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`;
|
|
419
427
|
let resp;
|
|
420
428
|
const call = async (callSignal) => {
|
|
421
429
|
const headers = new Headers();
|
|
422
|
-
if (
|
|
423
|
-
headers.set('X-Databricks-Org-Id',
|
|
430
|
+
if (workspaceId !== undefined) {
|
|
431
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
424
432
|
}
|
|
425
433
|
headers.set('User-Agent', this.userAgent);
|
|
426
434
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
427
435
|
const respBody = await executeHttpCall({
|
|
428
436
|
request: httpReq,
|
|
429
|
-
httpClient
|
|
437
|
+
httpClient,
|
|
430
438
|
logger: this.logger,
|
|
431
439
|
});
|
|
432
440
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -442,18 +450,19 @@ export class CredentialsClient {
|
|
|
442
450
|
* The caller must be a metastore admin, the owner of the storage credential, or have some permission on the storage credential.
|
|
443
451
|
*/
|
|
444
452
|
async getStorageCredential(req, options) {
|
|
445
|
-
const
|
|
453
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
454
|
+
const url = `${host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`;
|
|
446
455
|
let resp;
|
|
447
456
|
const call = async (callSignal) => {
|
|
448
457
|
const headers = new Headers();
|
|
449
|
-
if (
|
|
450
|
-
headers.set('X-Databricks-Org-Id',
|
|
458
|
+
if (workspaceId !== undefined) {
|
|
459
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
451
460
|
}
|
|
452
461
|
headers.set('User-Agent', this.userAgent);
|
|
453
462
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
454
463
|
const respBody = await executeHttpCall({
|
|
455
464
|
request: httpReq,
|
|
456
|
-
httpClient
|
|
465
|
+
httpClient,
|
|
457
466
|
logger: this.logger,
|
|
458
467
|
});
|
|
459
468
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -475,7 +484,8 @@ export class CredentialsClient {
|
|
|
475
484
|
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
476
485
|
*/
|
|
477
486
|
async listCredentials(req, options) {
|
|
478
|
-
const
|
|
487
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
488
|
+
const url = `${host}/api/2.1/unity-catalog/credentials`;
|
|
479
489
|
const params = new URLSearchParams();
|
|
480
490
|
if (req.includeUnbound !== undefined) {
|
|
481
491
|
params.append('include_unbound', String(req.includeUnbound));
|
|
@@ -491,14 +501,14 @@ export class CredentialsClient {
|
|
|
491
501
|
let resp;
|
|
492
502
|
const call = async (callSignal) => {
|
|
493
503
|
const headers = new Headers();
|
|
494
|
-
if (
|
|
495
|
-
headers.set('X-Databricks-Org-Id',
|
|
504
|
+
if (workspaceId !== undefined) {
|
|
505
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
496
506
|
}
|
|
497
507
|
headers.set('User-Agent', this.userAgent);
|
|
498
508
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
499
509
|
const respBody = await executeHttpCall({
|
|
500
510
|
request: httpReq,
|
|
501
|
-
httpClient
|
|
511
|
+
httpClient,
|
|
502
512
|
logger: this.logger,
|
|
503
513
|
});
|
|
504
514
|
resp = parseResponse(respBody, unmarshalListCredentialsRequest_ResponseSchema);
|
|
@@ -534,7 +544,8 @@ export class CredentialsClient {
|
|
|
534
544
|
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
535
545
|
*/
|
|
536
546
|
async listStorageCredentials(req, options) {
|
|
537
|
-
const
|
|
547
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
548
|
+
const url = `${host}/api/2.1/unity-catalog/storage-credentials`;
|
|
538
549
|
const params = new URLSearchParams();
|
|
539
550
|
if (req.includeUnbound !== undefined) {
|
|
540
551
|
params.append('include_unbound', String(req.includeUnbound));
|
|
@@ -550,14 +561,14 @@ export class CredentialsClient {
|
|
|
550
561
|
let resp;
|
|
551
562
|
const call = async (callSignal) => {
|
|
552
563
|
const headers = new Headers();
|
|
553
|
-
if (
|
|
554
|
-
headers.set('X-Databricks-Org-Id',
|
|
564
|
+
if (workspaceId !== undefined) {
|
|
565
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
555
566
|
}
|
|
556
567
|
headers.set('User-Agent', this.userAgent);
|
|
557
568
|
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
558
569
|
const respBody = await executeHttpCall({
|
|
559
570
|
request: httpReq,
|
|
560
|
-
httpClient
|
|
571
|
+
httpClient,
|
|
561
572
|
logger: this.logger,
|
|
562
573
|
});
|
|
563
574
|
resp = parseResponse(respBody, unmarshalListStorageCredentialsResponseSchema);
|
|
@@ -588,19 +599,20 @@ export class CredentialsClient {
|
|
|
588
599
|
* a metastore admin, only the __owner__ field can be changed.
|
|
589
600
|
*/
|
|
590
601
|
async updateCredential(req, options) {
|
|
591
|
-
const
|
|
602
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
603
|
+
const url = `${host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`;
|
|
592
604
|
const body = marshalRequest(req, marshalUpdateCredentialRequestSchema);
|
|
593
605
|
let resp;
|
|
594
606
|
const call = async (callSignal) => {
|
|
595
607
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
596
|
-
if (
|
|
597
|
-
headers.set('X-Databricks-Org-Id',
|
|
608
|
+
if (workspaceId !== undefined) {
|
|
609
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
598
610
|
}
|
|
599
611
|
headers.set('User-Agent', this.userAgent);
|
|
600
612
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
601
613
|
const respBody = await executeHttpCall({
|
|
602
614
|
request: httpReq,
|
|
603
|
-
httpClient
|
|
615
|
+
httpClient,
|
|
604
616
|
logger: this.logger,
|
|
605
617
|
});
|
|
606
618
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -618,19 +630,20 @@ export class CredentialsClient {
|
|
|
618
630
|
* If the caller is a metastore admin, only the **owner** field can be changed.
|
|
619
631
|
*/
|
|
620
632
|
async updateStorageCredential(req, options) {
|
|
621
|
-
const
|
|
633
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
634
|
+
const url = `${host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`;
|
|
622
635
|
const body = marshalRequest(req, marshalUpdateStorageCredentialRequestSchema);
|
|
623
636
|
let resp;
|
|
624
637
|
const call = async (callSignal) => {
|
|
625
638
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
626
|
-
if (
|
|
627
|
-
headers.set('X-Databricks-Org-Id',
|
|
639
|
+
if (workspaceId !== undefined) {
|
|
640
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
628
641
|
}
|
|
629
642
|
headers.set('User-Agent', this.userAgent);
|
|
630
643
|
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
631
644
|
const respBody = await executeHttpCall({
|
|
632
645
|
request: httpReq,
|
|
633
|
-
httpClient
|
|
646
|
+
httpClient,
|
|
634
647
|
logger: this.logger,
|
|
635
648
|
});
|
|
636
649
|
resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema);
|
|
@@ -656,19 +669,20 @@ export class CredentialsClient {
|
|
|
656
669
|
* the credential (e.g., **CREATE_EXTERNAL_LOCATION** when purpose is **STORAGE**).
|
|
657
670
|
*/
|
|
658
671
|
async validateCredential(req, options) {
|
|
659
|
-
const
|
|
672
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
673
|
+
const url = `${host}/api/2.1/unity-catalog/validate-credentials`;
|
|
660
674
|
const body = marshalRequest(req, marshalValidateCredentialRequestSchema);
|
|
661
675
|
let resp;
|
|
662
676
|
const call = async (callSignal) => {
|
|
663
677
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
664
|
-
if (
|
|
665
|
-
headers.set('X-Databricks-Org-Id',
|
|
678
|
+
if (workspaceId !== undefined) {
|
|
679
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
666
680
|
}
|
|
667
681
|
headers.set('User-Agent', this.userAgent);
|
|
668
682
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
669
683
|
const respBody = await executeHttpCall({
|
|
670
684
|
request: httpReq,
|
|
671
|
-
httpClient
|
|
685
|
+
httpClient,
|
|
672
686
|
logger: this.logger,
|
|
673
687
|
});
|
|
674
688
|
resp = parseResponse(respBody, unmarshalValidateCredentialResponseSchema);
|
|
@@ -691,19 +705,20 @@ export class CredentialsClient {
|
|
|
691
705
|
* have the **CREATE_EXTERNAL_LOCATION** privilege on the metastore and the storage credential.
|
|
692
706
|
*/
|
|
693
707
|
async validateStorageCredential(req, options) {
|
|
694
|
-
const
|
|
708
|
+
const { host, workspaceId, httpClient } = await this.resolveConfig();
|
|
709
|
+
const url = `${host}/api/2.1/unity-catalog/validate-storage-credentials`;
|
|
695
710
|
const body = marshalRequest(req, marshalValidateStorageCredentialRequestSchema);
|
|
696
711
|
let resp;
|
|
697
712
|
const call = async (callSignal) => {
|
|
698
713
|
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
699
|
-
if (
|
|
700
|
-
headers.set('X-Databricks-Org-Id',
|
|
714
|
+
if (workspaceId !== undefined) {
|
|
715
|
+
headers.set('X-Databricks-Org-Id', workspaceId);
|
|
701
716
|
}
|
|
702
717
|
headers.set('User-Agent', this.userAgent);
|
|
703
718
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
704
719
|
const respBody = await executeHttpCall({
|
|
705
720
|
request: httpReq,
|
|
706
|
-
httpClient
|
|
721
|
+
httpClient,
|
|
707
722
|
logger: this.logger,
|
|
708
723
|
});
|
|
709
724
|
resp = parseResponse(respBody, unmarshalValidateStorageCredentialResponseSchema);
|
|
@@ -722,7 +737,8 @@ export class CredentialsClient {
|
|
|
722
737
|
* For information about how to create a new workspace with this API, see [Create a new workspace using the Account API](http://docs.databricks.com/administration-guide/account-api/new-workspace.html)
|
|
723
738
|
*/
|
|
724
739
|
async createCredentialsPublic(req, options) {
|
|
725
|
-
const
|
|
740
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
741
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/credentials`;
|
|
726
742
|
const body = marshalRequest(req, marshalCreateCredentialsRequestSchema);
|
|
727
743
|
let resp;
|
|
728
744
|
const call = async (callSignal) => {
|
|
@@ -731,7 +747,7 @@ export class CredentialsClient {
|
|
|
731
747
|
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
732
748
|
const respBody = await executeHttpCall({
|
|
733
749
|
request: httpReq,
|
|
734
|
-
httpClient
|
|
750
|
+
httpClient,
|
|
735
751
|
logger: this.logger,
|
|
736
752
|
});
|
|
737
753
|
resp = parseResponse(respBody, unmarshalCredentialsSchema);
|
|
@@ -744,7 +760,8 @@ export class CredentialsClient {
|
|
|
744
760
|
}
|
|
745
761
|
/** Deletes a <Databricks> credential configuration object for an account, both specified by ID. You cannot delete a credential that is associated with any workspace. */
|
|
746
762
|
async deleteCredentialsPublic(req, options) {
|
|
747
|
-
const
|
|
763
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
764
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/credentials/${req.credentialsId ?? ''}`;
|
|
748
765
|
let resp;
|
|
749
766
|
const call = async (callSignal) => {
|
|
750
767
|
const headers = new Headers();
|
|
@@ -752,7 +769,7 @@ export class CredentialsClient {
|
|
|
752
769
|
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
753
770
|
const respBody = await executeHttpCall({
|
|
754
771
|
request: httpReq,
|
|
755
|
-
httpClient
|
|
772
|
+
httpClient,
|
|
756
773
|
logger: this.logger,
|
|
757
774
|
});
|
|
758
775
|
resp = parseResponse(respBody, unmarshalCredentialsSchema);
|
|
@@ -765,7 +782,8 @@ export class CredentialsClient {
|
|
|
765
782
|
}
|
|
766
783
|
/** Gets a <Databricks> credential configuration object for an account, both specified by ID. */
|
|
767
784
|
async getCredentialsPublic(req, options) {
|
|
768
|
-
const
|
|
785
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
786
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/credentials/${req.credentialsId ?? ''}`;
|
|
769
787
|
let resp;
|
|
770
788
|
const call = async (callSignal) => {
|
|
771
789
|
const headers = new Headers();
|
|
@@ -773,7 +791,7 @@ export class CredentialsClient {
|
|
|
773
791
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
774
792
|
const respBody = await executeHttpCall({
|
|
775
793
|
request: httpReq,
|
|
776
|
-
httpClient
|
|
794
|
+
httpClient,
|
|
777
795
|
logger: this.logger,
|
|
778
796
|
});
|
|
779
797
|
resp = parseResponse(respBody, unmarshalCredentialsSchema);
|
|
@@ -786,7 +804,8 @@ export class CredentialsClient {
|
|
|
786
804
|
}
|
|
787
805
|
/** List <Databricks> credential configuration objects for an account, specified by ID. */
|
|
788
806
|
async listCredentialsPublic(req, options) {
|
|
789
|
-
const
|
|
807
|
+
const { host, accountId, httpClient } = await this.resolveConfig();
|
|
808
|
+
const url = `${host}/api/2.0/accounts/${req.accountId ?? accountId ?? ''}/credentials`;
|
|
790
809
|
let resp;
|
|
791
810
|
const call = async (callSignal) => {
|
|
792
811
|
const headers = new Headers();
|
|
@@ -794,7 +813,7 @@ export class CredentialsClient {
|
|
|
794
813
|
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
795
814
|
const respBody = await executeHttpCall({
|
|
796
815
|
request: httpReq,
|
|
797
|
-
httpClient
|
|
816
|
+
httpClient,
|
|
798
817
|
logger: this.logger,
|
|
799
818
|
});
|
|
800
819
|
resp = {
|