@scaleway/sdk-cockpit 1.1.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.
@@ -0,0 +1,445 @@
1
+ import { resolveOneOf, isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ const unmarshalContactPointEmail = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'ContactPointEmail' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ to: data.to
10
+ };
11
+ };
12
+ const unmarshalContactPoint = (data) => {
13
+ if (!isJSONObject(data)) {
14
+ throw new TypeError(
15
+ `Unmarshalling the type 'ContactPoint' failed as data isn't a dictionary.`
16
+ );
17
+ }
18
+ return {
19
+ email: data.email ? unmarshalContactPointEmail(data.email) : void 0,
20
+ region: data.region,
21
+ sendResolvedNotifications: data.send_resolved_notifications
22
+ };
23
+ };
24
+ const unmarshalDataSource = (data) => {
25
+ if (!isJSONObject(data)) {
26
+ throw new TypeError(
27
+ `Unmarshalling the type 'DataSource' failed as data isn't a dictionary.`
28
+ );
29
+ }
30
+ return {
31
+ createdAt: unmarshalDate(data.created_at),
32
+ id: data.id,
33
+ name: data.name,
34
+ origin: data.origin,
35
+ projectId: data.project_id,
36
+ region: data.region,
37
+ retentionDays: data.retention_days,
38
+ synchronizedWithGrafana: data.synchronized_with_grafana,
39
+ type: data.type,
40
+ updatedAt: unmarshalDate(data.updated_at),
41
+ url: data.url
42
+ };
43
+ };
44
+ const unmarshalGrafanaProductDashboard = (data) => {
45
+ if (!isJSONObject(data)) {
46
+ throw new TypeError(
47
+ `Unmarshalling the type 'GrafanaProductDashboard' failed as data isn't a dictionary.`
48
+ );
49
+ }
50
+ return {
51
+ name: data.name,
52
+ tags: data.tags,
53
+ title: data.title,
54
+ url: data.url,
55
+ variables: data.variables
56
+ };
57
+ };
58
+ const unmarshalGrafanaUser = (data) => {
59
+ if (!isJSONObject(data)) {
60
+ throw new TypeError(
61
+ `Unmarshalling the type 'GrafanaUser' failed as data isn't a dictionary.`
62
+ );
63
+ }
64
+ return {
65
+ id: data.id,
66
+ login: data.login,
67
+ password: data.password,
68
+ role: data.role
69
+ };
70
+ };
71
+ const unmarshalPlan = (data) => {
72
+ if (!isJSONObject(data)) {
73
+ throw new TypeError(
74
+ `Unmarshalling the type 'Plan' failed as data isn't a dictionary.`
75
+ );
76
+ }
77
+ return {
78
+ logsIngestionPrice: data.logs_ingestion_price,
79
+ monthlyPrice: data.monthly_price,
80
+ name: data.name,
81
+ retentionLogsInterval: data.retention_logs_interval,
82
+ retentionMetricsInterval: data.retention_metrics_interval,
83
+ retentionTracesInterval: data.retention_traces_interval,
84
+ sampleIngestionPrice: data.sample_ingestion_price,
85
+ tracesIngestionPrice: data.traces_ingestion_price
86
+ };
87
+ };
88
+ const unmarshalToken = (data) => {
89
+ if (!isJSONObject(data)) {
90
+ throw new TypeError(
91
+ `Unmarshalling the type 'Token' failed as data isn't a dictionary.`
92
+ );
93
+ }
94
+ return {
95
+ createdAt: unmarshalDate(data.created_at),
96
+ id: data.id,
97
+ name: data.name,
98
+ projectId: data.project_id,
99
+ region: data.region,
100
+ scopes: data.scopes,
101
+ secretKey: data.secret_key,
102
+ updatedAt: unmarshalDate(data.updated_at)
103
+ };
104
+ };
105
+ const unmarshalAlertManager = (data) => {
106
+ if (!isJSONObject(data)) {
107
+ throw new TypeError(
108
+ `Unmarshalling the type 'AlertManager' failed as data isn't a dictionary.`
109
+ );
110
+ }
111
+ return {
112
+ alertManagerEnabled: data.alert_manager_enabled,
113
+ alertManagerUrl: data.alert_manager_url,
114
+ managedAlertsEnabled: data.managed_alerts_enabled,
115
+ region: data.region
116
+ };
117
+ };
118
+ const unmarshalDisableAlertRulesResponse = (data) => {
119
+ if (!isJSONObject(data)) {
120
+ throw new TypeError(
121
+ `Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary.`
122
+ );
123
+ }
124
+ return {
125
+ disabledRuleIds: data.disabled_rule_ids
126
+ };
127
+ };
128
+ const unmarshalEnableAlertRulesResponse = (data) => {
129
+ if (!isJSONObject(data)) {
130
+ throw new TypeError(
131
+ `Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary.`
132
+ );
133
+ }
134
+ return {
135
+ enabledRuleIds: data.enabled_rule_ids
136
+ };
137
+ };
138
+ const unmarshalGetConfigResponseRetention = (data) => {
139
+ if (!isJSONObject(data)) {
140
+ throw new TypeError(
141
+ `Unmarshalling the type 'GetConfigResponseRetention' failed as data isn't a dictionary.`
142
+ );
143
+ }
144
+ return {
145
+ defaultDays: data.default_days,
146
+ maxDays: data.max_days,
147
+ minDays: data.min_days
148
+ };
149
+ };
150
+ const unmarshalGetConfigResponse = (data) => {
151
+ if (!isJSONObject(data)) {
152
+ throw new TypeError(
153
+ `Unmarshalling the type 'GetConfigResponse' failed as data isn't a dictionary.`
154
+ );
155
+ }
156
+ return {
157
+ customLogsRetention: data.custom_logs_retention ? unmarshalGetConfigResponseRetention(data.custom_logs_retention) : void 0,
158
+ customMetricsRetention: data.custom_metrics_retention ? unmarshalGetConfigResponseRetention(data.custom_metrics_retention) : void 0,
159
+ customTracesRetention: data.custom_traces_retention ? unmarshalGetConfigResponseRetention(data.custom_traces_retention) : void 0,
160
+ productLogsRetention: data.product_logs_retention ? unmarshalGetConfigResponseRetention(data.product_logs_retention) : void 0,
161
+ productMetricsRetention: data.product_metrics_retention ? unmarshalGetConfigResponseRetention(data.product_metrics_retention) : void 0
162
+ };
163
+ };
164
+ const unmarshalGrafana = (data) => {
165
+ if (!isJSONObject(data)) {
166
+ throw new TypeError(
167
+ `Unmarshalling the type 'Grafana' failed as data isn't a dictionary.`
168
+ );
169
+ }
170
+ return {
171
+ grafanaUrl: data.grafana_url
172
+ };
173
+ };
174
+ const unmarshalPreconfiguredAlertData = (data) => {
175
+ if (!isJSONObject(data)) {
176
+ throw new TypeError(
177
+ `Unmarshalling the type 'PreconfiguredAlertData' failed as data isn't a dictionary.`
178
+ );
179
+ }
180
+ return {
181
+ displayDescription: data.display_description,
182
+ displayName: data.display_name,
183
+ preconfiguredRuleId: data.preconfigured_rule_id
184
+ };
185
+ };
186
+ const unmarshalAlert = (data) => {
187
+ if (!isJSONObject(data)) {
188
+ throw new TypeError(
189
+ `Unmarshalling the type 'Alert' failed as data isn't a dictionary.`
190
+ );
191
+ }
192
+ return {
193
+ annotations: data.annotations,
194
+ duration: data.duration,
195
+ enabled: data.enabled,
196
+ name: data.name,
197
+ preconfigured: data.preconfigured,
198
+ preconfiguredData: data.preconfigured_data ? unmarshalPreconfiguredAlertData(data.preconfigured_data) : void 0,
199
+ region: data.region,
200
+ rule: data.rule,
201
+ state: data.state ? data.state : void 0
202
+ };
203
+ };
204
+ const unmarshalListAlertsResponse = (data) => {
205
+ if (!isJSONObject(data)) {
206
+ throw new TypeError(
207
+ `Unmarshalling the type 'ListAlertsResponse' failed as data isn't a dictionary.`
208
+ );
209
+ }
210
+ return {
211
+ alerts: unmarshalArrayOfObject(data.alerts, unmarshalAlert),
212
+ totalCount: data.total_count
213
+ };
214
+ };
215
+ const unmarshalListContactPointsResponse = (data) => {
216
+ if (!isJSONObject(data)) {
217
+ throw new TypeError(
218
+ `Unmarshalling the type 'ListContactPointsResponse' failed as data isn't a dictionary.`
219
+ );
220
+ }
221
+ return {
222
+ contactPoints: unmarshalArrayOfObject(
223
+ data.contact_points,
224
+ unmarshalContactPoint
225
+ ),
226
+ hasAdditionalContactPoints: data.has_additional_contact_points,
227
+ hasAdditionalReceivers: data.has_additional_receivers,
228
+ totalCount: data.total_count
229
+ };
230
+ };
231
+ const unmarshalListDataSourcesResponse = (data) => {
232
+ if (!isJSONObject(data)) {
233
+ throw new TypeError(
234
+ `Unmarshalling the type 'ListDataSourcesResponse' failed as data isn't a dictionary.`
235
+ );
236
+ }
237
+ return {
238
+ dataSources: unmarshalArrayOfObject(data.data_sources, unmarshalDataSource),
239
+ totalCount: data.total_count
240
+ };
241
+ };
242
+ const unmarshalListGrafanaProductDashboardsResponse = (data) => {
243
+ if (!isJSONObject(data)) {
244
+ throw new TypeError(
245
+ `Unmarshalling the type 'ListGrafanaProductDashboardsResponse' failed as data isn't a dictionary.`
246
+ );
247
+ }
248
+ return {
249
+ dashboards: unmarshalArrayOfObject(
250
+ data.dashboards,
251
+ unmarshalGrafanaProductDashboard
252
+ ),
253
+ totalCount: data.total_count
254
+ };
255
+ };
256
+ const unmarshalListGrafanaUsersResponse = (data) => {
257
+ if (!isJSONObject(data)) {
258
+ throw new TypeError(
259
+ `Unmarshalling the type 'ListGrafanaUsersResponse' failed as data isn't a dictionary.`
260
+ );
261
+ }
262
+ return {
263
+ grafanaUsers: unmarshalArrayOfObject(
264
+ data.grafana_users,
265
+ unmarshalGrafanaUser
266
+ ),
267
+ totalCount: data.total_count
268
+ };
269
+ };
270
+ const unmarshalListPlansResponse = (data) => {
271
+ if (!isJSONObject(data)) {
272
+ throw new TypeError(
273
+ `Unmarshalling the type 'ListPlansResponse' failed as data isn't a dictionary.`
274
+ );
275
+ }
276
+ return {
277
+ plans: unmarshalArrayOfObject(data.plans, unmarshalPlan),
278
+ totalCount: data.total_count
279
+ };
280
+ };
281
+ const unmarshalListTokensResponse = (data) => {
282
+ if (!isJSONObject(data)) {
283
+ throw new TypeError(
284
+ `Unmarshalling the type 'ListTokensResponse' failed as data isn't a dictionary.`
285
+ );
286
+ }
287
+ return {
288
+ tokens: unmarshalArrayOfObject(data.tokens, unmarshalToken),
289
+ totalCount: data.total_count
290
+ };
291
+ };
292
+ const unmarshalUsage = (data) => {
293
+ if (!isJSONObject(data)) {
294
+ throw new TypeError(
295
+ `Unmarshalling the type 'Usage' failed as data isn't a dictionary.`
296
+ );
297
+ }
298
+ return {
299
+ dataSourceId: data.data_source_id,
300
+ dataSourceOrigin: data.data_source_origin,
301
+ dataSourceType: data.data_source_type,
302
+ interval: data.interval,
303
+ projectId: data.project_id,
304
+ quantityOverInterval: data.quantity_over_interval,
305
+ region: data.region,
306
+ unit: data.unit
307
+ };
308
+ };
309
+ const unmarshalUsageOverview = (data) => {
310
+ if (!isJSONObject(data)) {
311
+ throw new TypeError(
312
+ `Unmarshalling the type 'UsageOverview' failed as data isn't a dictionary.`
313
+ );
314
+ }
315
+ return {
316
+ externalLogsUsage: data.external_logs_usage ? unmarshalUsage(data.external_logs_usage) : void 0,
317
+ externalMetricsUsage: data.external_metrics_usage ? unmarshalUsage(data.external_metrics_usage) : void 0,
318
+ externalTracesUsage: data.external_traces_usage ? unmarshalUsage(data.external_traces_usage) : void 0,
319
+ scalewayLogsUsage: data.scaleway_logs_usage ? unmarshalUsage(data.scaleway_logs_usage) : void 0,
320
+ scalewayMetricsUsage: data.scaleway_metrics_usage ? unmarshalUsage(data.scaleway_metrics_usage) : void 0
321
+ };
322
+ };
323
+ const marshalGlobalApiCreateGrafanaUserRequest = (request, defaults) => ({
324
+ login: request.login,
325
+ project_id: request.projectId ?? defaults.defaultProjectId,
326
+ role: request.role
327
+ });
328
+ const marshalGlobalApiResetGrafanaUserPasswordRequest = (request, defaults) => ({
329
+ project_id: request.projectId ?? defaults.defaultProjectId
330
+ });
331
+ const marshalGlobalApiSelectPlanRequest = (request, defaults) => ({
332
+ plan_name: request.planName,
333
+ project_id: request.projectId ?? defaults.defaultProjectId
334
+ });
335
+ const marshalGlobalApiSyncGrafanaDataSourcesRequest = (request, defaults) => ({
336
+ project_id: request.projectId ?? defaults.defaultProjectId
337
+ });
338
+ const marshalContactPointEmail = (request, defaults) => ({
339
+ to: request.to
340
+ });
341
+ const marshalRegionalApiCreateContactPointRequest = (request, defaults) => ({
342
+ project_id: request.projectId ?? defaults.defaultProjectId,
343
+ send_resolved_notifications: request.sendResolvedNotifications,
344
+ ...resolveOneOf([
345
+ {
346
+ param: "email",
347
+ value: request.email !== void 0 ? marshalContactPointEmail(request.email) : void 0
348
+ }
349
+ ])
350
+ });
351
+ const marshalRegionalApiCreateDataSourceRequest = (request, defaults) => ({
352
+ name: request.name,
353
+ project_id: request.projectId ?? defaults.defaultProjectId,
354
+ retention_days: request.retentionDays,
355
+ type: request.type
356
+ });
357
+ const marshalRegionalApiCreateTokenRequest = (request, defaults) => ({
358
+ name: request.name,
359
+ project_id: request.projectId ?? defaults.defaultProjectId,
360
+ token_scopes: request.tokenScopes !== void 0 ? request.tokenScopes : void 0
361
+ });
362
+ const marshalRegionalApiDeleteContactPointRequest = (request, defaults) => ({
363
+ project_id: request.projectId ?? defaults.defaultProjectId,
364
+ ...resolveOneOf([
365
+ {
366
+ param: "email",
367
+ value: request.email !== void 0 ? marshalContactPointEmail(request.email) : void 0
368
+ }
369
+ ])
370
+ });
371
+ const marshalRegionalApiDisableAlertManagerRequest = (request, defaults) => ({
372
+ project_id: request.projectId ?? defaults.defaultProjectId
373
+ });
374
+ const marshalRegionalApiDisableAlertRulesRequest = (request, defaults) => ({
375
+ project_id: request.projectId ?? defaults.defaultProjectId,
376
+ rule_ids: request.ruleIds
377
+ });
378
+ const marshalRegionalApiDisableManagedAlertsRequest = (request, defaults) => ({
379
+ project_id: request.projectId ?? defaults.defaultProjectId
380
+ });
381
+ const marshalRegionalApiEnableAlertManagerRequest = (request, defaults) => ({
382
+ project_id: request.projectId ?? defaults.defaultProjectId
383
+ });
384
+ const marshalRegionalApiEnableAlertRulesRequest = (request, defaults) => ({
385
+ project_id: request.projectId ?? defaults.defaultProjectId,
386
+ rule_ids: request.ruleIds
387
+ });
388
+ const marshalRegionalApiEnableManagedAlertsRequest = (request, defaults) => ({
389
+ project_id: request.projectId ?? defaults.defaultProjectId
390
+ });
391
+ const marshalRegionalApiTriggerTestAlertRequest = (request, defaults) => ({
392
+ project_id: request.projectId ?? defaults.defaultProjectId
393
+ });
394
+ const marshalRegionalApiUpdateContactPointRequest = (request, defaults) => ({
395
+ project_id: request.projectId ?? defaults.defaultProjectId,
396
+ send_resolved_notifications: request.sendResolvedNotifications,
397
+ ...resolveOneOf([
398
+ {
399
+ param: "email",
400
+ value: request.email !== void 0 ? marshalContactPointEmail(request.email) : void 0
401
+ }
402
+ ])
403
+ });
404
+ const marshalRegionalApiUpdateDataSourceRequest = (request, defaults) => ({
405
+ name: request.name,
406
+ retention_days: request.retentionDays
407
+ });
408
+ export {
409
+ marshalGlobalApiCreateGrafanaUserRequest,
410
+ marshalGlobalApiResetGrafanaUserPasswordRequest,
411
+ marshalGlobalApiSelectPlanRequest,
412
+ marshalGlobalApiSyncGrafanaDataSourcesRequest,
413
+ marshalRegionalApiCreateContactPointRequest,
414
+ marshalRegionalApiCreateDataSourceRequest,
415
+ marshalRegionalApiCreateTokenRequest,
416
+ marshalRegionalApiDeleteContactPointRequest,
417
+ marshalRegionalApiDisableAlertManagerRequest,
418
+ marshalRegionalApiDisableAlertRulesRequest,
419
+ marshalRegionalApiDisableManagedAlertsRequest,
420
+ marshalRegionalApiEnableAlertManagerRequest,
421
+ marshalRegionalApiEnableAlertRulesRequest,
422
+ marshalRegionalApiEnableManagedAlertsRequest,
423
+ marshalRegionalApiTriggerTestAlertRequest,
424
+ marshalRegionalApiUpdateContactPointRequest,
425
+ marshalRegionalApiUpdateDataSourceRequest,
426
+ unmarshalAlertManager,
427
+ unmarshalContactPoint,
428
+ unmarshalDataSource,
429
+ unmarshalDisableAlertRulesResponse,
430
+ unmarshalEnableAlertRulesResponse,
431
+ unmarshalGetConfigResponse,
432
+ unmarshalGrafana,
433
+ unmarshalGrafanaProductDashboard,
434
+ unmarshalGrafanaUser,
435
+ unmarshalListAlertsResponse,
436
+ unmarshalListContactPointsResponse,
437
+ unmarshalListDataSourcesResponse,
438
+ unmarshalListGrafanaProductDashboardsResponse,
439
+ unmarshalListGrafanaUsersResponse,
440
+ unmarshalListPlansResponse,
441
+ unmarshalListTokensResponse,
442
+ unmarshalPlan,
443
+ unmarshalToken,
444
+ unmarshalUsageOverview
445
+ };