@databricks/sdk-notificationdestinations 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 -3
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +36 -33
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/model.d.ts +8 -7
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +10 -10
- 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 -248
- package/src/v1/index.ts +0 -23
- package/src/v1/model.ts +0 -447
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/src/v1/model.ts
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import {z} from 'zod';
|
|
4
|
-
|
|
5
|
-
export enum DestinationType {
|
|
6
|
-
SLACK = 'SLACK',
|
|
7
|
-
EMAIL = 'EMAIL',
|
|
8
|
-
WEBHOOK = 'WEBHOOK',
|
|
9
|
-
PAGERDUTY = 'PAGERDUTY',
|
|
10
|
-
MICROSOFT_TEAMS = 'MICROSOFT_TEAMS',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Config {
|
|
14
|
-
config?:
|
|
15
|
-
| {$case: 'slack'; slack: SlackConfig}
|
|
16
|
-
| {$case: 'email'; email: EmailConfig}
|
|
17
|
-
| {$case: 'genericWebhook'; genericWebhook: GenericWebhookConfig}
|
|
18
|
-
| {$case: 'pagerduty'; pagerduty: PagerdutyConfig}
|
|
19
|
-
| {$case: 'microsoftTeams'; microsoftTeams: MicrosoftTeamsConfig}
|
|
20
|
-
| undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CreateNotificationDestinationRequest {
|
|
24
|
-
/** The display name for the notification destination. */
|
|
25
|
-
displayName?: string | undefined;
|
|
26
|
-
/** The configuration for the notification destination. Must wrap EXACTLY one of the nested configs. */
|
|
27
|
-
config?: Config | undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface DeleteNotificationDestinationRequest {
|
|
31
|
-
id?: string | undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface EmailConfig {
|
|
35
|
-
/** Email addresses to notify. */
|
|
36
|
-
addresses?: string[] | undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
40
|
-
export interface Empty {}
|
|
41
|
-
|
|
42
|
-
export interface GenericWebhookConfig {
|
|
43
|
-
/** [Input-Only] URL for webhook. */
|
|
44
|
-
url?: string | undefined;
|
|
45
|
-
/** [Output-Only] Whether URL is set. */
|
|
46
|
-
urlSet?: boolean | undefined;
|
|
47
|
-
/** [Input-Only][Optional] Username for webhook. */
|
|
48
|
-
username?: string | undefined;
|
|
49
|
-
/** [Output-Only] Whether username is set. */
|
|
50
|
-
usernameSet?: boolean | undefined;
|
|
51
|
-
/** [Input-Only][Optional] Password for webhook. */
|
|
52
|
-
password?: string | undefined;
|
|
53
|
-
/** [Output-Only] Whether password is set. */
|
|
54
|
-
passwordSet?: boolean | undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface GetNotificationDestinationRequest {
|
|
58
|
-
id?: string | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface ListNotificationDestinationsRequest {
|
|
62
|
-
pageToken?: string | undefined;
|
|
63
|
-
pageSize?: bigint | undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface ListNotificationDestinationsResponse {
|
|
67
|
-
results?: ListNotificationDestinationsResult[] | undefined;
|
|
68
|
-
/** Page token for next of results. */
|
|
69
|
-
nextPageToken?: string | undefined;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface ListNotificationDestinationsResult {
|
|
73
|
-
/** UUID identifying notification destination. */
|
|
74
|
-
id?: string | undefined;
|
|
75
|
-
/** The display name for the notification destination. */
|
|
76
|
-
displayName?: string | undefined;
|
|
77
|
-
/** [Output-only] The type of the notification destination. The type can not be changed once set. */
|
|
78
|
-
destinationType?: DestinationType | undefined;
|
|
79
|
-
/** The configuration for the notification destination. Will be exactly one of the nested configs. Only returns for users with workspace admin permissions. */
|
|
80
|
-
config?: Config | undefined;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface MicrosoftTeamsConfig {
|
|
84
|
-
/** [Input-Only] URL for Microsoft Teams webhook. */
|
|
85
|
-
url?: string | undefined;
|
|
86
|
-
/** [Output-Only] Whether URL is set. */
|
|
87
|
-
urlSet?: boolean | undefined;
|
|
88
|
-
/** [Input-Only] App ID for Microsoft Teams App. */
|
|
89
|
-
appId?: string | undefined;
|
|
90
|
-
/** [Output-Only] Whether App ID is set. */
|
|
91
|
-
appIdSet?: boolean | undefined;
|
|
92
|
-
/** [Input-Only] Secret for Microsoft Teams App authentication. */
|
|
93
|
-
authSecret?: string | undefined;
|
|
94
|
-
/** [Output-Only] Whether secret is set. */
|
|
95
|
-
authSecretSet?: boolean | undefined;
|
|
96
|
-
/** [Input-Only] Channel URL for Microsoft Teams App. */
|
|
97
|
-
channelUrl?: string | undefined;
|
|
98
|
-
/** [Output-Only] Whether Channel URL is set. */
|
|
99
|
-
channelUrlSet?: boolean | undefined;
|
|
100
|
-
/** [Input-Only] Tenant ID for Microsoft Teams App. */
|
|
101
|
-
tenantId?: string | undefined;
|
|
102
|
-
/** [Output-Only] Whether Tenant ID is set. */
|
|
103
|
-
tenantIdSet?: boolean | undefined;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface NotificationDestination {
|
|
107
|
-
/** UUID identifying notification destination. */
|
|
108
|
-
id?: string | undefined;
|
|
109
|
-
/** The display name for the notification destination. */
|
|
110
|
-
displayName?: string | undefined;
|
|
111
|
-
/** [Output-only] The type of the notification destination. The type can not be changed once set. */
|
|
112
|
-
destinationType?: DestinationType | undefined;
|
|
113
|
-
/** The configuration for the notification destination. Will be exactly one of the nested configs. Only returns for users with workspace admin permissions. */
|
|
114
|
-
config?: Config | undefined;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface PagerdutyConfig {
|
|
118
|
-
/** [Input-Only] Integration key for PagerDuty. */
|
|
119
|
-
integrationKey?: string | undefined;
|
|
120
|
-
/** [Output-Only] Whether integration key is set. */
|
|
121
|
-
integrationKeySet?: boolean | undefined;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface SlackConfig {
|
|
125
|
-
/** [Input-Only] URL for Slack destination. */
|
|
126
|
-
url?: string | undefined;
|
|
127
|
-
/** [Output-Only] Whether URL is set. */
|
|
128
|
-
urlSet?: boolean | undefined;
|
|
129
|
-
/** [Input-Only] OAuth token for Slack authentication. */
|
|
130
|
-
oauthToken?: string | undefined;
|
|
131
|
-
/** [Output-Only] Whether OAuth token is set. */
|
|
132
|
-
oauthTokenSet?: boolean | undefined;
|
|
133
|
-
/** [Input-Only] Slack channel ID for notifications. */
|
|
134
|
-
channelId?: string | undefined;
|
|
135
|
-
/** [Output-Only] Whether channel ID is set. */
|
|
136
|
-
channelIdSet?: boolean | undefined;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface UpdateNotificationDestinationRequest {
|
|
140
|
-
/** UUID identifying notification destination. */
|
|
141
|
-
id?: string | undefined;
|
|
142
|
-
/** The display name for the notification destination. */
|
|
143
|
-
displayName?: string | undefined;
|
|
144
|
-
/** The configuration for the notification destination. Must wrap EXACTLY one of the nested configs. */
|
|
145
|
-
config?: Config | undefined;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export const unmarshalConfigSchema: z.ZodType<Config> = z
|
|
149
|
-
.object({
|
|
150
|
-
slack: z.lazy(() => unmarshalSlackConfigSchema).optional(),
|
|
151
|
-
email: z.lazy(() => unmarshalEmailConfigSchema).optional(),
|
|
152
|
-
generic_webhook: z
|
|
153
|
-
.lazy(() => unmarshalGenericWebhookConfigSchema)
|
|
154
|
-
.optional(),
|
|
155
|
-
pagerduty: z.lazy(() => unmarshalPagerdutyConfigSchema).optional(),
|
|
156
|
-
microsoft_teams: z
|
|
157
|
-
.lazy(() => unmarshalMicrosoftTeamsConfigSchema)
|
|
158
|
-
.optional(),
|
|
159
|
-
})
|
|
160
|
-
.transform(d => ({
|
|
161
|
-
config:
|
|
162
|
-
d.slack !== undefined
|
|
163
|
-
? {$case: 'slack' as const, slack: d.slack}
|
|
164
|
-
: d.email !== undefined
|
|
165
|
-
? {$case: 'email' as const, email: d.email}
|
|
166
|
-
: d.generic_webhook !== undefined
|
|
167
|
-
? {
|
|
168
|
-
$case: 'genericWebhook' as const,
|
|
169
|
-
genericWebhook: d.generic_webhook,
|
|
170
|
-
}
|
|
171
|
-
: d.pagerduty !== undefined
|
|
172
|
-
? {$case: 'pagerduty' as const, pagerduty: d.pagerduty}
|
|
173
|
-
: d.microsoft_teams !== undefined
|
|
174
|
-
? {
|
|
175
|
-
$case: 'microsoftTeams' as const,
|
|
176
|
-
microsoftTeams: d.microsoft_teams,
|
|
177
|
-
}
|
|
178
|
-
: undefined,
|
|
179
|
-
}));
|
|
180
|
-
|
|
181
|
-
export const unmarshalEmailConfigSchema: z.ZodType<EmailConfig> = z
|
|
182
|
-
.object({
|
|
183
|
-
addresses: z.array(z.string()).optional(),
|
|
184
|
-
})
|
|
185
|
-
.transform(d => ({
|
|
186
|
-
addresses: d.addresses,
|
|
187
|
-
}));
|
|
188
|
-
|
|
189
|
-
export const unmarshalEmptySchema: z.ZodType<Empty> = z.object({});
|
|
190
|
-
|
|
191
|
-
export const unmarshalGenericWebhookConfigSchema: z.ZodType<GenericWebhookConfig> =
|
|
192
|
-
z
|
|
193
|
-
.object({
|
|
194
|
-
url: z.string().optional(),
|
|
195
|
-
url_set: z.boolean().optional(),
|
|
196
|
-
username: z.string().optional(),
|
|
197
|
-
username_set: z.boolean().optional(),
|
|
198
|
-
password: z.string().optional(),
|
|
199
|
-
password_set: z.boolean().optional(),
|
|
200
|
-
})
|
|
201
|
-
.transform(d => ({
|
|
202
|
-
url: d.url,
|
|
203
|
-
urlSet: d.url_set,
|
|
204
|
-
username: d.username,
|
|
205
|
-
usernameSet: d.username_set,
|
|
206
|
-
password: d.password,
|
|
207
|
-
passwordSet: d.password_set,
|
|
208
|
-
}));
|
|
209
|
-
|
|
210
|
-
export const unmarshalListNotificationDestinationsResponseSchema: z.ZodType<ListNotificationDestinationsResponse> =
|
|
211
|
-
z
|
|
212
|
-
.object({
|
|
213
|
-
results: z
|
|
214
|
-
.array(z.lazy(() => unmarshalListNotificationDestinationsResultSchema))
|
|
215
|
-
.optional(),
|
|
216
|
-
next_page_token: z.string().optional(),
|
|
217
|
-
})
|
|
218
|
-
.transform(d => ({
|
|
219
|
-
results: d.results,
|
|
220
|
-
nextPageToken: d.next_page_token,
|
|
221
|
-
}));
|
|
222
|
-
|
|
223
|
-
export const unmarshalListNotificationDestinationsResultSchema: z.ZodType<ListNotificationDestinationsResult> =
|
|
224
|
-
z
|
|
225
|
-
.object({
|
|
226
|
-
id: z.string().optional(),
|
|
227
|
-
display_name: z.string().optional(),
|
|
228
|
-
destination_type: z.enum(DestinationType).optional(),
|
|
229
|
-
config: z.lazy(() => unmarshalConfigSchema).optional(),
|
|
230
|
-
})
|
|
231
|
-
.transform(d => ({
|
|
232
|
-
id: d.id,
|
|
233
|
-
displayName: d.display_name,
|
|
234
|
-
destinationType: d.destination_type,
|
|
235
|
-
config: d.config,
|
|
236
|
-
}));
|
|
237
|
-
|
|
238
|
-
export const unmarshalMicrosoftTeamsConfigSchema: z.ZodType<MicrosoftTeamsConfig> =
|
|
239
|
-
z
|
|
240
|
-
.object({
|
|
241
|
-
url: z.string().optional(),
|
|
242
|
-
url_set: z.boolean().optional(),
|
|
243
|
-
app_id: z.string().optional(),
|
|
244
|
-
app_id_set: z.boolean().optional(),
|
|
245
|
-
auth_secret: z.string().optional(),
|
|
246
|
-
auth_secret_set: z.boolean().optional(),
|
|
247
|
-
channel_url: z.string().optional(),
|
|
248
|
-
channel_url_set: z.boolean().optional(),
|
|
249
|
-
tenant_id: z.string().optional(),
|
|
250
|
-
tenant_id_set: z.boolean().optional(),
|
|
251
|
-
})
|
|
252
|
-
.transform(d => ({
|
|
253
|
-
url: d.url,
|
|
254
|
-
urlSet: d.url_set,
|
|
255
|
-
appId: d.app_id,
|
|
256
|
-
appIdSet: d.app_id_set,
|
|
257
|
-
authSecret: d.auth_secret,
|
|
258
|
-
authSecretSet: d.auth_secret_set,
|
|
259
|
-
channelUrl: d.channel_url,
|
|
260
|
-
channelUrlSet: d.channel_url_set,
|
|
261
|
-
tenantId: d.tenant_id,
|
|
262
|
-
tenantIdSet: d.tenant_id_set,
|
|
263
|
-
}));
|
|
264
|
-
|
|
265
|
-
export const unmarshalNotificationDestinationSchema: z.ZodType<NotificationDestination> =
|
|
266
|
-
z
|
|
267
|
-
.object({
|
|
268
|
-
id: z.string().optional(),
|
|
269
|
-
display_name: z.string().optional(),
|
|
270
|
-
destination_type: z.enum(DestinationType).optional(),
|
|
271
|
-
config: z.lazy(() => unmarshalConfigSchema).optional(),
|
|
272
|
-
})
|
|
273
|
-
.transform(d => ({
|
|
274
|
-
id: d.id,
|
|
275
|
-
displayName: d.display_name,
|
|
276
|
-
destinationType: d.destination_type,
|
|
277
|
-
config: d.config,
|
|
278
|
-
}));
|
|
279
|
-
|
|
280
|
-
export const unmarshalPagerdutyConfigSchema: z.ZodType<PagerdutyConfig> = z
|
|
281
|
-
.object({
|
|
282
|
-
integration_key: z.string().optional(),
|
|
283
|
-
integration_key_set: z.boolean().optional(),
|
|
284
|
-
})
|
|
285
|
-
.transform(d => ({
|
|
286
|
-
integrationKey: d.integration_key,
|
|
287
|
-
integrationKeySet: d.integration_key_set,
|
|
288
|
-
}));
|
|
289
|
-
|
|
290
|
-
export const unmarshalSlackConfigSchema: z.ZodType<SlackConfig> = z
|
|
291
|
-
.object({
|
|
292
|
-
url: z.string().optional(),
|
|
293
|
-
url_set: z.boolean().optional(),
|
|
294
|
-
oauth_token: z.string().optional(),
|
|
295
|
-
oauth_token_set: z.boolean().optional(),
|
|
296
|
-
channel_id: z.string().optional(),
|
|
297
|
-
channel_id_set: z.boolean().optional(),
|
|
298
|
-
})
|
|
299
|
-
.transform(d => ({
|
|
300
|
-
url: d.url,
|
|
301
|
-
urlSet: d.url_set,
|
|
302
|
-
oauthToken: d.oauth_token,
|
|
303
|
-
oauthTokenSet: d.oauth_token_set,
|
|
304
|
-
channelId: d.channel_id,
|
|
305
|
-
channelIdSet: d.channel_id_set,
|
|
306
|
-
}));
|
|
307
|
-
|
|
308
|
-
export const marshalConfigSchema: z.ZodType = z
|
|
309
|
-
.object({
|
|
310
|
-
config: z
|
|
311
|
-
.discriminatedUnion('$case', [
|
|
312
|
-
z.object({
|
|
313
|
-
$case: z.literal('slack'),
|
|
314
|
-
slack: z.lazy(() => marshalSlackConfigSchema),
|
|
315
|
-
}),
|
|
316
|
-
z.object({
|
|
317
|
-
$case: z.literal('email'),
|
|
318
|
-
email: z.lazy(() => marshalEmailConfigSchema),
|
|
319
|
-
}),
|
|
320
|
-
z.object({
|
|
321
|
-
$case: z.literal('genericWebhook'),
|
|
322
|
-
genericWebhook: z.lazy(() => marshalGenericWebhookConfigSchema),
|
|
323
|
-
}),
|
|
324
|
-
z.object({
|
|
325
|
-
$case: z.literal('pagerduty'),
|
|
326
|
-
pagerduty: z.lazy(() => marshalPagerdutyConfigSchema),
|
|
327
|
-
}),
|
|
328
|
-
z.object({
|
|
329
|
-
$case: z.literal('microsoftTeams'),
|
|
330
|
-
microsoftTeams: z.lazy(() => marshalMicrosoftTeamsConfigSchema),
|
|
331
|
-
}),
|
|
332
|
-
])
|
|
333
|
-
.optional(),
|
|
334
|
-
})
|
|
335
|
-
.transform(d => ({
|
|
336
|
-
...(d.config?.$case === 'slack' && {slack: d.config.slack}),
|
|
337
|
-
...(d.config?.$case === 'email' && {email: d.config.email}),
|
|
338
|
-
...(d.config?.$case === 'genericWebhook' && {
|
|
339
|
-
generic_webhook: d.config.genericWebhook,
|
|
340
|
-
}),
|
|
341
|
-
...(d.config?.$case === 'pagerduty' && {pagerduty: d.config.pagerduty}),
|
|
342
|
-
...(d.config?.$case === 'microsoftTeams' && {
|
|
343
|
-
microsoft_teams: d.config.microsoftTeams,
|
|
344
|
-
}),
|
|
345
|
-
}));
|
|
346
|
-
|
|
347
|
-
export const marshalCreateNotificationDestinationRequestSchema: z.ZodType = z
|
|
348
|
-
.object({
|
|
349
|
-
displayName: z.string().optional(),
|
|
350
|
-
config: z.lazy(() => marshalConfigSchema).optional(),
|
|
351
|
-
})
|
|
352
|
-
.transform(d => ({
|
|
353
|
-
display_name: d.displayName,
|
|
354
|
-
config: d.config,
|
|
355
|
-
}));
|
|
356
|
-
|
|
357
|
-
export const marshalEmailConfigSchema: z.ZodType = z
|
|
358
|
-
.object({
|
|
359
|
-
addresses: z.array(z.string()).optional(),
|
|
360
|
-
})
|
|
361
|
-
.transform(d => ({
|
|
362
|
-
addresses: d.addresses,
|
|
363
|
-
}));
|
|
364
|
-
|
|
365
|
-
export const marshalGenericWebhookConfigSchema: z.ZodType = z
|
|
366
|
-
.object({
|
|
367
|
-
url: z.string().optional(),
|
|
368
|
-
urlSet: z.boolean().optional(),
|
|
369
|
-
username: z.string().optional(),
|
|
370
|
-
usernameSet: z.boolean().optional(),
|
|
371
|
-
password: z.string().optional(),
|
|
372
|
-
passwordSet: z.boolean().optional(),
|
|
373
|
-
})
|
|
374
|
-
.transform(d => ({
|
|
375
|
-
url: d.url,
|
|
376
|
-
url_set: d.urlSet,
|
|
377
|
-
username: d.username,
|
|
378
|
-
username_set: d.usernameSet,
|
|
379
|
-
password: d.password,
|
|
380
|
-
password_set: d.passwordSet,
|
|
381
|
-
}));
|
|
382
|
-
|
|
383
|
-
export const marshalMicrosoftTeamsConfigSchema: z.ZodType = z
|
|
384
|
-
.object({
|
|
385
|
-
url: z.string().optional(),
|
|
386
|
-
urlSet: z.boolean().optional(),
|
|
387
|
-
appId: z.string().optional(),
|
|
388
|
-
appIdSet: z.boolean().optional(),
|
|
389
|
-
authSecret: z.string().optional(),
|
|
390
|
-
authSecretSet: z.boolean().optional(),
|
|
391
|
-
channelUrl: z.string().optional(),
|
|
392
|
-
channelUrlSet: z.boolean().optional(),
|
|
393
|
-
tenantId: z.string().optional(),
|
|
394
|
-
tenantIdSet: z.boolean().optional(),
|
|
395
|
-
})
|
|
396
|
-
.transform(d => ({
|
|
397
|
-
url: d.url,
|
|
398
|
-
url_set: d.urlSet,
|
|
399
|
-
app_id: d.appId,
|
|
400
|
-
app_id_set: d.appIdSet,
|
|
401
|
-
auth_secret: d.authSecret,
|
|
402
|
-
auth_secret_set: d.authSecretSet,
|
|
403
|
-
channel_url: d.channelUrl,
|
|
404
|
-
channel_url_set: d.channelUrlSet,
|
|
405
|
-
tenant_id: d.tenantId,
|
|
406
|
-
tenant_id_set: d.tenantIdSet,
|
|
407
|
-
}));
|
|
408
|
-
|
|
409
|
-
export const marshalPagerdutyConfigSchema: z.ZodType = z
|
|
410
|
-
.object({
|
|
411
|
-
integrationKey: z.string().optional(),
|
|
412
|
-
integrationKeySet: z.boolean().optional(),
|
|
413
|
-
})
|
|
414
|
-
.transform(d => ({
|
|
415
|
-
integration_key: d.integrationKey,
|
|
416
|
-
integration_key_set: d.integrationKeySet,
|
|
417
|
-
}));
|
|
418
|
-
|
|
419
|
-
export const marshalSlackConfigSchema: z.ZodType = z
|
|
420
|
-
.object({
|
|
421
|
-
url: z.string().optional(),
|
|
422
|
-
urlSet: z.boolean().optional(),
|
|
423
|
-
oauthToken: z.string().optional(),
|
|
424
|
-
oauthTokenSet: z.boolean().optional(),
|
|
425
|
-
channelId: z.string().optional(),
|
|
426
|
-
channelIdSet: z.boolean().optional(),
|
|
427
|
-
})
|
|
428
|
-
.transform(d => ({
|
|
429
|
-
url: d.url,
|
|
430
|
-
url_set: d.urlSet,
|
|
431
|
-
oauth_token: d.oauthToken,
|
|
432
|
-
oauth_token_set: d.oauthTokenSet,
|
|
433
|
-
channel_id: d.channelId,
|
|
434
|
-
channel_id_set: d.channelIdSet,
|
|
435
|
-
}));
|
|
436
|
-
|
|
437
|
-
export const marshalUpdateNotificationDestinationRequestSchema: z.ZodType = z
|
|
438
|
-
.object({
|
|
439
|
-
id: z.string().optional(),
|
|
440
|
-
displayName: z.string().optional(),
|
|
441
|
-
config: z.lazy(() => marshalConfigSchema).optional(),
|
|
442
|
-
})
|
|
443
|
-
.transform(d => ({
|
|
444
|
-
id: d.id,
|
|
445
|
-
display_name: d.displayName,
|
|
446
|
-
config: d.config,
|
|
447
|
-
}));
|
package/src/v1/transport.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import type {Options} from '@databricks/sdk-core/ops';
|
|
4
|
-
import {execute} from '@databricks/sdk-core/ops';
|
|
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: (signal?: AbortSignal) => Promise<void>,
|
|
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
|
-
}
|