@databricks/sdk-secrets 0.0.0-dev → 0.1.0-dev.1
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/LICENSE +203 -0
- package/dist/v1/client.d.ts +297 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +604 -0
- package/dist/v1/client.js.map +1 -0
- package/dist/v1/index.d.ts +4 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +4 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/model.d.ts +189 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +206 -0
- package/dist/v1/model.js.map +1 -0
- package/dist/v1/transport.d.ts +5 -0
- package/dist/v1/transport.d.ts.map +1 -0
- package/dist/v1/transport.js +57 -0
- package/dist/v1/transport.js.map +1 -0
- package/dist/v1/utils.d.ts +22 -0
- package/dist/v1/utils.d.ts.map +1 -0
- package/dist/v1/utils.js +113 -0
- package/dist/v1/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v1/client.ts +713 -0
- package/src/v1/index.ts +33 -0
- package/src/v1/model.ts +413 -0
- package/src/v1/transport.ts +73 -0
- package/src/v1/utils.ts +156 -0
- package/README.md +0 -1
- package/index.js +0 -1
package/src/v1/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
export {SecretsClient} from './client';
|
|
4
|
+
|
|
5
|
+
export {AclPermission, ScopeBackendType} from './model';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
AclItem,
|
|
9
|
+
AzureKeyVaultSecretScopeMetadata,
|
|
10
|
+
CreateScopeRequest,
|
|
11
|
+
CreateScopeRequest_Response,
|
|
12
|
+
DeleteAclRequest,
|
|
13
|
+
DeleteAclRequest_Response,
|
|
14
|
+
DeleteScopeRequest,
|
|
15
|
+
DeleteScopeRequest_Response,
|
|
16
|
+
DeleteSecretRequest,
|
|
17
|
+
DeleteSecretRequest_Response,
|
|
18
|
+
GetAclRequest,
|
|
19
|
+
GetSecretRequest,
|
|
20
|
+
GetSecretRequest_Response,
|
|
21
|
+
ListAclsRequest,
|
|
22
|
+
ListAclsRequest_Response,
|
|
23
|
+
ListScopesRequest,
|
|
24
|
+
ListScopesRequest_Response,
|
|
25
|
+
ListSecretsRequest,
|
|
26
|
+
ListSecretsRequest_Response,
|
|
27
|
+
PutAclRequest,
|
|
28
|
+
PutAclRequest_Response,
|
|
29
|
+
PutSecretRequest,
|
|
30
|
+
PutSecretRequest_Response,
|
|
31
|
+
SecretMetadata,
|
|
32
|
+
SecretScope,
|
|
33
|
+
} from './model';
|
package/src/v1/model.ts
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import {z} from 'zod';
|
|
4
|
+
|
|
5
|
+
/** The ACL permission levels for Secret ACLs applied to secret scopes. */
|
|
6
|
+
export enum AclPermission {
|
|
7
|
+
/** Allowed to perform read operations (get, list) on secrets in this scope. */
|
|
8
|
+
READ = 'READ',
|
|
9
|
+
/** Allowed to read and write secrets to this secret scope. */
|
|
10
|
+
WRITE = 'WRITE',
|
|
11
|
+
/** Allowed to read/write ACLs, and read/write secrets to this secret scope. */
|
|
12
|
+
MANAGE = 'MANAGE',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The types of secret scope backends in the Secret Manager. Azure KeyVault backed secret scopes
|
|
17
|
+
* will be supported in a later release.
|
|
18
|
+
*/
|
|
19
|
+
export enum ScopeBackendType {
|
|
20
|
+
/**
|
|
21
|
+
* A secret scope in which secrets are stored in Databrick managed storage
|
|
22
|
+
* and encrypted with a cloud-based specific encryption key.
|
|
23
|
+
*/
|
|
24
|
+
DATABRICKS = 'DATABRICKS',
|
|
25
|
+
/**
|
|
26
|
+
* A customer Azure KeyVault backed secret scope. Reading secrets from this scope will directly
|
|
27
|
+
* read secrets from the customer vault. Only scope and secret ACL metadata are stored in Databricks.
|
|
28
|
+
*/
|
|
29
|
+
AZURE_KEYVAULT = 'AZURE_KEYVAULT',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An item representing an ACL rule applied to the given principal (user or group)
|
|
34
|
+
* on the associated scope point.
|
|
35
|
+
*/
|
|
36
|
+
export interface AclItem {
|
|
37
|
+
/** The principal in which the permission is applied. */
|
|
38
|
+
principal?: string | undefined;
|
|
39
|
+
/** The permission level applied to the principal. */
|
|
40
|
+
permission?: AclPermission | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The metadata of the Azure KeyVault for a secret scope of type `AZURE_KEYVAULT` */
|
|
44
|
+
export interface AzureKeyVaultSecretScopeMetadata {
|
|
45
|
+
/** The resource id of the azure KeyVault that user wants to associate the scope with. */
|
|
46
|
+
resourceId?: string | undefined;
|
|
47
|
+
/** The DNS of the KeyVault */
|
|
48
|
+
dnsName?: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CreateScopeRequest {
|
|
52
|
+
/** Scope name requested by the user. Scope names are unique. */
|
|
53
|
+
scope?: string | undefined;
|
|
54
|
+
/** The principal that is initially granted ``MANAGE`` permission to the created scope. */
|
|
55
|
+
initialManagePrincipal?: string | undefined;
|
|
56
|
+
/** The backend type the scope will be created with. If not specified, will default to ``DATABRICKS`` */
|
|
57
|
+
scopeBackendType?: ScopeBackendType | undefined;
|
|
58
|
+
/** The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` */
|
|
59
|
+
backendAzureKeyvault?: AzureKeyVaultSecretScopeMetadata | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
63
|
+
export interface CreateScopeRequest_Response {}
|
|
64
|
+
|
|
65
|
+
export interface DeleteAclRequest {
|
|
66
|
+
/** The name of the scope to remove permissions from. */
|
|
67
|
+
scope?: string | undefined;
|
|
68
|
+
/** The principal to remove an existing ACL from. */
|
|
69
|
+
principal?: string | undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
73
|
+
export interface DeleteAclRequest_Response {}
|
|
74
|
+
|
|
75
|
+
export interface DeleteScopeRequest {
|
|
76
|
+
/** Name of the scope to delete. */
|
|
77
|
+
scope?: string | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
81
|
+
export interface DeleteScopeRequest_Response {}
|
|
82
|
+
|
|
83
|
+
export interface DeleteSecretRequest {
|
|
84
|
+
/** The name of the scope that contains the secret to delete. */
|
|
85
|
+
scope?: string | undefined;
|
|
86
|
+
/** Name of the secret to delete. */
|
|
87
|
+
key?: string | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
91
|
+
export interface DeleteSecretRequest_Response {}
|
|
92
|
+
|
|
93
|
+
export interface GetAclRequest {
|
|
94
|
+
/** The name of the scope to fetch ACL information from. */
|
|
95
|
+
scope?: string | undefined;
|
|
96
|
+
/** The principal to fetch ACL information for. */
|
|
97
|
+
principal?: string | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface GetSecretRequest {
|
|
101
|
+
/** The name of the scope that contains the secret. */
|
|
102
|
+
scope?: string | undefined;
|
|
103
|
+
/** Name of the secret to fetch value information. */
|
|
104
|
+
key?: string | undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
108
|
+
export interface GetSecretRequest_Response {
|
|
109
|
+
/** A unique name to identify the secret. */
|
|
110
|
+
key?: string | undefined;
|
|
111
|
+
/** The value of the secret in its byte representation. */
|
|
112
|
+
value?: Uint8Array | undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ListAclsRequest {
|
|
116
|
+
/** The name of the scope to fetch ACL information from. */
|
|
117
|
+
scope?: string | undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
121
|
+
export interface ListAclsRequest_Response {
|
|
122
|
+
/** The associated ACLs rule applied to principals in the given scope. */
|
|
123
|
+
items?: AclItem[] | undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
127
|
+
export interface ListScopesRequest {}
|
|
128
|
+
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
130
|
+
export interface ListScopesRequest_Response {
|
|
131
|
+
/** The available secret scopes. */
|
|
132
|
+
scopes?: SecretScope[] | undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ListSecretsRequest {
|
|
136
|
+
/** The name of the scope to list secrets within. */
|
|
137
|
+
scope?: string | undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
141
|
+
export interface ListSecretsRequest_Response {
|
|
142
|
+
/** Metadata information of all secrets contained within the given scope. */
|
|
143
|
+
secrets?: SecretMetadata[] | undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface PutAclRequest {
|
|
147
|
+
/** The name of the scope to apply permissions to. */
|
|
148
|
+
scope?: string | undefined;
|
|
149
|
+
/** The principal in which the permission is applied. */
|
|
150
|
+
principal?: string | undefined;
|
|
151
|
+
/** The permission level applied to the principal. */
|
|
152
|
+
permission?: AclPermission | undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
156
|
+
export interface PutAclRequest_Response {}
|
|
157
|
+
|
|
158
|
+
export interface PutSecretRequest {
|
|
159
|
+
/** The name of the scope to which the secret will be associated with. */
|
|
160
|
+
scope?: string | undefined;
|
|
161
|
+
/** A unique name to identify the secret. */
|
|
162
|
+
key?: string | undefined;
|
|
163
|
+
value?:
|
|
164
|
+
| {
|
|
165
|
+
$case: 'stringValue';
|
|
166
|
+
/** If specified, note that the value will be stored in UTF-8 (MB4) form. */
|
|
167
|
+
stringValue: string;
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
$case: 'bytesValue';
|
|
171
|
+
/** If specified, value will be stored as bytes. */
|
|
172
|
+
bytesValue: Uint8Array;
|
|
173
|
+
}
|
|
174
|
+
| undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name.
|
|
178
|
+
export interface PutSecretRequest_Response {}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The metadata about a secret. Returned when listing secrets. Does not contain the
|
|
182
|
+
* actual secret value.
|
|
183
|
+
*/
|
|
184
|
+
export interface SecretMetadata {
|
|
185
|
+
/** A unique name to identify the secret. */
|
|
186
|
+
key?: string | undefined;
|
|
187
|
+
/** The last updated timestamp (in milliseconds) for the secret. */
|
|
188
|
+
lastUpdatedTimestamp?: bigint | undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* An organizational resource for storing secrets. Secret scopes can be
|
|
193
|
+
* different types (Databricks-managed, Azure KeyVault backed, etc), and ACLs
|
|
194
|
+
* can be applied to control permissions for all secrets within a scope.
|
|
195
|
+
*/
|
|
196
|
+
export interface SecretScope {
|
|
197
|
+
/** A unique name to identify the secret scope. */
|
|
198
|
+
name?: string | undefined;
|
|
199
|
+
/** The type of secret scope backend. */
|
|
200
|
+
backendType?: ScopeBackendType | undefined;
|
|
201
|
+
/** The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` */
|
|
202
|
+
keyvaultMetadata?: AzureKeyVaultSecretScopeMetadata | undefined;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export const unmarshalAclItemSchema: z.ZodType<AclItem> = z
|
|
206
|
+
.object({
|
|
207
|
+
principal: z.string().optional(),
|
|
208
|
+
permission: z.enum(AclPermission).optional(),
|
|
209
|
+
})
|
|
210
|
+
.transform(d => ({
|
|
211
|
+
principal: d.principal,
|
|
212
|
+
permission: d.permission,
|
|
213
|
+
}));
|
|
214
|
+
|
|
215
|
+
export const unmarshalAzureKeyVaultSecretScopeMetadataSchema: z.ZodType<AzureKeyVaultSecretScopeMetadata> =
|
|
216
|
+
z
|
|
217
|
+
.object({
|
|
218
|
+
resource_id: z.string().optional(),
|
|
219
|
+
dns_name: z.string().optional(),
|
|
220
|
+
})
|
|
221
|
+
.transform(d => ({
|
|
222
|
+
resourceId: d.resource_id,
|
|
223
|
+
dnsName: d.dns_name,
|
|
224
|
+
}));
|
|
225
|
+
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
227
|
+
export const unmarshalCreateScopeRequest_ResponseSchema: z.ZodType<CreateScopeRequest_Response> =
|
|
228
|
+
z.object({});
|
|
229
|
+
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
231
|
+
export const unmarshalDeleteAclRequest_ResponseSchema: z.ZodType<DeleteAclRequest_Response> =
|
|
232
|
+
z.object({});
|
|
233
|
+
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
235
|
+
export const unmarshalDeleteScopeRequest_ResponseSchema: z.ZodType<DeleteScopeRequest_Response> =
|
|
236
|
+
z.object({});
|
|
237
|
+
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
239
|
+
export const unmarshalDeleteSecretRequest_ResponseSchema: z.ZodType<DeleteSecretRequest_Response> =
|
|
240
|
+
z.object({});
|
|
241
|
+
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
243
|
+
export const unmarshalGetSecretRequest_ResponseSchema: z.ZodType<GetSecretRequest_Response> =
|
|
244
|
+
z
|
|
245
|
+
.object({
|
|
246
|
+
key: z.string().optional(),
|
|
247
|
+
value: z
|
|
248
|
+
.string()
|
|
249
|
+
.transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0)))
|
|
250
|
+
.optional(),
|
|
251
|
+
})
|
|
252
|
+
.transform(d => ({
|
|
253
|
+
key: d.key,
|
|
254
|
+
value: d.value,
|
|
255
|
+
}));
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
258
|
+
export const unmarshalListAclsRequest_ResponseSchema: z.ZodType<ListAclsRequest_Response> =
|
|
259
|
+
z
|
|
260
|
+
.object({
|
|
261
|
+
items: z.array(z.lazy(() => unmarshalAclItemSchema)).optional(),
|
|
262
|
+
})
|
|
263
|
+
.transform(d => ({
|
|
264
|
+
items: d.items,
|
|
265
|
+
}));
|
|
266
|
+
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
268
|
+
export const unmarshalListScopesRequest_ResponseSchema: z.ZodType<ListScopesRequest_Response> =
|
|
269
|
+
z
|
|
270
|
+
.object({
|
|
271
|
+
scopes: z.array(z.lazy(() => unmarshalSecretScopeSchema)).optional(),
|
|
272
|
+
})
|
|
273
|
+
.transform(d => ({
|
|
274
|
+
scopes: d.scopes,
|
|
275
|
+
}));
|
|
276
|
+
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
278
|
+
export const unmarshalListSecretsRequest_ResponseSchema: z.ZodType<ListSecretsRequest_Response> =
|
|
279
|
+
z
|
|
280
|
+
.object({
|
|
281
|
+
secrets: z.array(z.lazy(() => unmarshalSecretMetadataSchema)).optional(),
|
|
282
|
+
})
|
|
283
|
+
.transform(d => ({
|
|
284
|
+
secrets: d.secrets,
|
|
285
|
+
}));
|
|
286
|
+
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
288
|
+
export const unmarshalPutAclRequest_ResponseSchema: z.ZodType<PutAclRequest_Response> =
|
|
289
|
+
z.object({});
|
|
290
|
+
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
292
|
+
export const unmarshalPutSecretRequest_ResponseSchema: z.ZodType<PutSecretRequest_Response> =
|
|
293
|
+
z.object({});
|
|
294
|
+
|
|
295
|
+
export const unmarshalSecretMetadataSchema: z.ZodType<SecretMetadata> = z
|
|
296
|
+
.object({
|
|
297
|
+
key: z.string().optional(),
|
|
298
|
+
last_updated_timestamp: z
|
|
299
|
+
.union([z.number(), z.bigint()])
|
|
300
|
+
.transform(v => BigInt(v))
|
|
301
|
+
.optional(),
|
|
302
|
+
})
|
|
303
|
+
.transform(d => ({
|
|
304
|
+
key: d.key,
|
|
305
|
+
lastUpdatedTimestamp: d.last_updated_timestamp,
|
|
306
|
+
}));
|
|
307
|
+
|
|
308
|
+
export const unmarshalSecretScopeSchema: z.ZodType<SecretScope> = z
|
|
309
|
+
.object({
|
|
310
|
+
name: z.string().optional(),
|
|
311
|
+
backend_type: z.enum(ScopeBackendType).optional(),
|
|
312
|
+
keyvault_metadata: z
|
|
313
|
+
.lazy(() => unmarshalAzureKeyVaultSecretScopeMetadataSchema)
|
|
314
|
+
.optional(),
|
|
315
|
+
})
|
|
316
|
+
.transform(d => ({
|
|
317
|
+
name: d.name,
|
|
318
|
+
backendType: d.backend_type,
|
|
319
|
+
keyvaultMetadata: d.keyvault_metadata,
|
|
320
|
+
}));
|
|
321
|
+
|
|
322
|
+
export const marshalAzureKeyVaultSecretScopeMetadataSchema: z.ZodType = z
|
|
323
|
+
.object({
|
|
324
|
+
resourceId: z.string().optional(),
|
|
325
|
+
dnsName: z.string().optional(),
|
|
326
|
+
})
|
|
327
|
+
.transform(d => ({
|
|
328
|
+
resource_id: d.resourceId,
|
|
329
|
+
dns_name: d.dnsName,
|
|
330
|
+
}));
|
|
331
|
+
|
|
332
|
+
export const marshalCreateScopeRequestSchema: z.ZodType = z
|
|
333
|
+
.object({
|
|
334
|
+
scope: z.string().optional(),
|
|
335
|
+
initialManagePrincipal: z.string().optional(),
|
|
336
|
+
scopeBackendType: z.enum(ScopeBackendType).optional(),
|
|
337
|
+
backendAzureKeyvault: z
|
|
338
|
+
.lazy(() => marshalAzureKeyVaultSecretScopeMetadataSchema)
|
|
339
|
+
.optional(),
|
|
340
|
+
})
|
|
341
|
+
.transform(d => ({
|
|
342
|
+
scope: d.scope,
|
|
343
|
+
initial_manage_principal: d.initialManagePrincipal,
|
|
344
|
+
scope_backend_type: d.scopeBackendType,
|
|
345
|
+
backend_azure_keyvault: d.backendAzureKeyvault,
|
|
346
|
+
}));
|
|
347
|
+
|
|
348
|
+
export const marshalDeleteAclRequestSchema: z.ZodType = z
|
|
349
|
+
.object({
|
|
350
|
+
scope: z.string().optional(),
|
|
351
|
+
principal: z.string().optional(),
|
|
352
|
+
})
|
|
353
|
+
.transform(d => ({
|
|
354
|
+
scope: d.scope,
|
|
355
|
+
principal: d.principal,
|
|
356
|
+
}));
|
|
357
|
+
|
|
358
|
+
export const marshalDeleteScopeRequestSchema: z.ZodType = z
|
|
359
|
+
.object({
|
|
360
|
+
scope: z.string().optional(),
|
|
361
|
+
})
|
|
362
|
+
.transform(d => ({
|
|
363
|
+
scope: d.scope,
|
|
364
|
+
}));
|
|
365
|
+
|
|
366
|
+
export const marshalDeleteSecretRequestSchema: z.ZodType = z
|
|
367
|
+
.object({
|
|
368
|
+
scope: z.string().optional(),
|
|
369
|
+
key: z.string().optional(),
|
|
370
|
+
})
|
|
371
|
+
.transform(d => ({
|
|
372
|
+
scope: d.scope,
|
|
373
|
+
key: d.key,
|
|
374
|
+
}));
|
|
375
|
+
|
|
376
|
+
export const marshalPutAclRequestSchema: z.ZodType = z
|
|
377
|
+
.object({
|
|
378
|
+
scope: z.string().optional(),
|
|
379
|
+
principal: z.string().optional(),
|
|
380
|
+
permission: z.enum(AclPermission).optional(),
|
|
381
|
+
})
|
|
382
|
+
.transform(d => ({
|
|
383
|
+
scope: d.scope,
|
|
384
|
+
principal: d.principal,
|
|
385
|
+
permission: d.permission,
|
|
386
|
+
}));
|
|
387
|
+
|
|
388
|
+
export const marshalPutSecretRequestSchema: z.ZodType = z
|
|
389
|
+
.object({
|
|
390
|
+
scope: z.string().optional(),
|
|
391
|
+
key: z.string().optional(),
|
|
392
|
+
value: z
|
|
393
|
+
.discriminatedUnion('$case', [
|
|
394
|
+
z.object({$case: z.literal('stringValue'), stringValue: z.string()}),
|
|
395
|
+
z.object({
|
|
396
|
+
$case: z.literal('bytesValue'),
|
|
397
|
+
bytesValue: z
|
|
398
|
+
.any()
|
|
399
|
+
.transform((d: Uint8Array) =>
|
|
400
|
+
btoa(Array.from(d, b => String.fromCharCode(b)).join(''))
|
|
401
|
+
),
|
|
402
|
+
}),
|
|
403
|
+
])
|
|
404
|
+
.optional(),
|
|
405
|
+
})
|
|
406
|
+
.transform(d => ({
|
|
407
|
+
scope: d.scope,
|
|
408
|
+
key: d.key,
|
|
409
|
+
...(d.value?.$case === 'stringValue' && {
|
|
410
|
+
string_value: d.value.stringValue,
|
|
411
|
+
}),
|
|
412
|
+
...(d.value?.$case === 'bytesValue' && {bytes_value: d.value.bytesValue}),
|
|
413
|
+
}));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import type {Credentials} from '@databricks/sdk-auth';
|
|
4
|
+
import {defaultCredentials} from '@databricks/sdk-auth/credentials';
|
|
5
|
+
import type {
|
|
6
|
+
HttpClient,
|
|
7
|
+
HttpRequest,
|
|
8
|
+
HttpResponse,
|
|
9
|
+
} from '@databricks/sdk-core/http';
|
|
10
|
+
import {newFetchHttpClient} from '@databricks/sdk-core/http';
|
|
11
|
+
import type {ClientOptions} from '@databricks/sdk-options/client';
|
|
12
|
+
|
|
13
|
+
/** Creates a new HTTP client with the given options. */
|
|
14
|
+
export function newHttpClient(options?: ClientOptions): HttpClient {
|
|
15
|
+
const opts = options ?? {};
|
|
16
|
+
|
|
17
|
+
// If an HTTP client is provided, use it as-is. Throw if other options are
|
|
18
|
+
// also set, since they would be silently ignored.
|
|
19
|
+
if (opts.httpClient !== undefined) {
|
|
20
|
+
if (opts.credentials !== undefined || opts.timeout !== undefined) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'httpClient cannot be combined with credentials or timeout'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return opts.httpClient;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const credentials = opts.credentials ?? defaultCredentials();
|
|
29
|
+
|
|
30
|
+
const base = newFetchHttpClient();
|
|
31
|
+
let client: HttpClient = new AuthHttpClient(base, credentials);
|
|
32
|
+
|
|
33
|
+
if (opts.timeout !== undefined) {
|
|
34
|
+
client = new TimeoutHttpClient(client, opts.timeout);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
41
|
+
class AuthHttpClient implements HttpClient {
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly base: HttpClient,
|
|
44
|
+
private readonly credentials: Credentials
|
|
45
|
+
) {}
|
|
46
|
+
|
|
47
|
+
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
48
|
+
const authHeaders = await this.credentials.authHeaders();
|
|
49
|
+
// Do not modify the original request.
|
|
50
|
+
const headers = new Headers(request.headers);
|
|
51
|
+
for (const h of authHeaders) {
|
|
52
|
+
headers.set(h.key, h.value);
|
|
53
|
+
}
|
|
54
|
+
return this.base.send({...request, headers});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Wraps an HttpClient and applies a default timeout to requests. */
|
|
59
|
+
class TimeoutHttpClient implements HttpClient {
|
|
60
|
+
constructor(
|
|
61
|
+
private readonly base: HttpClient,
|
|
62
|
+
private readonly timeout: number
|
|
63
|
+
) {}
|
|
64
|
+
|
|
65
|
+
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
66
|
+
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
67
|
+
const signal =
|
|
68
|
+
request.signal !== undefined
|
|
69
|
+
? AbortSignal.any([request.signal, timeoutSignal])
|
|
70
|
+
: timeoutSignal;
|
|
71
|
+
return this.base.send({...request, signal});
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/v1/utils.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import type {Call, Options} from '@databricks/sdk-core/api';
|
|
4
|
+
import {execute} from '@databricks/sdk-core/api';
|
|
5
|
+
import {ApiError} from '@databricks/sdk-core/apierror';
|
|
6
|
+
import type {
|
|
7
|
+
HttpClient,
|
|
8
|
+
HttpRequest,
|
|
9
|
+
HttpResponse,
|
|
10
|
+
} from '@databricks/sdk-core/http';
|
|
11
|
+
import type {Logger} from '@databricks/sdk-core/logger';
|
|
12
|
+
import type {CallOptions} from '@databricks/sdk-options/call';
|
|
13
|
+
import JSONBig from 'json-bigint';
|
|
14
|
+
import type {z} from 'zod';
|
|
15
|
+
|
|
16
|
+
// JSON codec that preserves int64 precision. On the way in, large integer
|
|
17
|
+
// literals come back as bigint instead of being rounded to JS Number. On the
|
|
18
|
+
// way out, bigint values are emitted as raw JSON number digits.
|
|
19
|
+
const jsonBigint = JSONBig({useNativeBigInt: true});
|
|
20
|
+
|
|
21
|
+
export interface HttpCallOptions {
|
|
22
|
+
readonly request: HttpRequest;
|
|
23
|
+
readonly httpClient: HttpClient;
|
|
24
|
+
readonly logger: Logger;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Translates public CallOptions to the internal Options shape accepted by
|
|
29
|
+
* execute(). Even though the shapes match today, this isolates the public
|
|
30
|
+
* API from the executor's internal type so they can diverge.
|
|
31
|
+
*/
|
|
32
|
+
export async function executeCall(
|
|
33
|
+
call: Call,
|
|
34
|
+
options?: CallOptions
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
const opts: Options = {
|
|
37
|
+
...(options?.retrier !== undefined && {retrier: options.retrier}),
|
|
38
|
+
...(options?.rateLimiter !== undefined && {
|
|
39
|
+
rateLimiter: options.rateLimiter,
|
|
40
|
+
}),
|
|
41
|
+
...(options?.timeout !== undefined && {timeout: options.timeout}),
|
|
42
|
+
};
|
|
43
|
+
return execute(options?.signal, call, opts);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function readAll(
|
|
47
|
+
body: ReadableStream<Uint8Array> | null
|
|
48
|
+
): Promise<Uint8Array> {
|
|
49
|
+
if (body === null) {
|
|
50
|
+
return new Uint8Array(0);
|
|
51
|
+
}
|
|
52
|
+
const reader = body.getReader();
|
|
53
|
+
const chunks: Uint8Array[] = [];
|
|
54
|
+
for (;;) {
|
|
55
|
+
const {done, value} = await reader.read();
|
|
56
|
+
if (done) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
chunks.push(value);
|
|
60
|
+
}
|
|
61
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
62
|
+
const result = new Uint8Array(totalLength);
|
|
63
|
+
let offset = 0;
|
|
64
|
+
for (const chunk of chunks) {
|
|
65
|
+
result.set(chunk, offset);
|
|
66
|
+
offset += chunk.length;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function executeHttpCall(
|
|
72
|
+
opts: HttpCallOptions
|
|
73
|
+
): Promise<Uint8Array> {
|
|
74
|
+
opts.logger.debug('HTTP request', {
|
|
75
|
+
method: opts.request.method,
|
|
76
|
+
url: opts.request.url,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
let resp: HttpResponse;
|
|
80
|
+
try {
|
|
81
|
+
resp = await opts.httpClient.send(opts.request);
|
|
82
|
+
} catch (e: unknown) {
|
|
83
|
+
opts.logger.debug('HTTP request failed');
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const body = await readAll(resp.body);
|
|
88
|
+
|
|
89
|
+
opts.logger.debug('HTTP response', {
|
|
90
|
+
statusCode: resp.statusCode,
|
|
91
|
+
body: new TextDecoder().decode(body),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
|
|
95
|
+
if (apiErr !== undefined) {
|
|
96
|
+
throw apiErr;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return body;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function buildHttpRequest(
|
|
103
|
+
method: string,
|
|
104
|
+
url: string,
|
|
105
|
+
headers: Headers,
|
|
106
|
+
signal?: AbortSignal,
|
|
107
|
+
body?: string | ReadableStream<Uint8Array>
|
|
108
|
+
): HttpRequest {
|
|
109
|
+
const req: HttpRequest = {url, method, headers};
|
|
110
|
+
if (body !== undefined) {
|
|
111
|
+
req.body = body;
|
|
112
|
+
}
|
|
113
|
+
if (signal !== undefined) {
|
|
114
|
+
req.signal = signal;
|
|
115
|
+
}
|
|
116
|
+
return req;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T {
|
|
120
|
+
const text = new TextDecoder().decode(body);
|
|
121
|
+
const parsed: unknown = jsonBigint.parse(text);
|
|
122
|
+
return schema.parse(parsed);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function marshalRequest(data: unknown, schema: z.ZodType): string {
|
|
126
|
+
return jsonBigint.stringify(schema.parse(data));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function flattenQueryParams(
|
|
130
|
+
prefix: string,
|
|
131
|
+
value: unknown,
|
|
132
|
+
params: URLSearchParams
|
|
133
|
+
): void {
|
|
134
|
+
if (value === null || value === undefined) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (Array.isArray(value)) {
|
|
138
|
+
// arrays of objects are not yet supported
|
|
139
|
+
for (const item of value) {
|
|
140
|
+
params.append(prefix, String(item));
|
|
141
|
+
}
|
|
142
|
+
} else if (typeof value === 'object') {
|
|
143
|
+
for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
|
|
144
|
+
flattenQueryParams(`${prefix}.${key}`, val, params);
|
|
145
|
+
}
|
|
146
|
+
} else if (
|
|
147
|
+
typeof value === 'string' ||
|
|
148
|
+
typeof value === 'number' ||
|
|
149
|
+
typeof value === 'boolean' ||
|
|
150
|
+
typeof value === 'bigint'
|
|
151
|
+
) {
|
|
152
|
+
params.append(prefix, String(value));
|
|
153
|
+
} else {
|
|
154
|
+
throw new Error(`Unsupported query parameter type: ${typeof value}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is a placeholder release used to enable OIDC trusted publishing. Real code lands in a later version.
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|