@scaleway/sdk-iot 1.2.0 → 2.1.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.
@@ -1,536 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const randomName = require("@scaleway/random-name");
4
- const sdkClient = require("@scaleway/sdk-client");
5
- const unmarshalDeviceMessageFiltersRule = (data) => {
6
- if (!sdkClient.isJSONObject(data)) {
7
- throw new TypeError(
8
- `Unmarshalling the type 'DeviceMessageFiltersRule' failed as data isn't a dictionary.`
9
- );
10
- }
11
- return {
12
- policy: data.policy,
13
- topics: data.topics
14
- };
15
- };
16
- const unmarshalDeviceMessageFilters = (data) => {
17
- if (!sdkClient.isJSONObject(data)) {
18
- throw new TypeError(
19
- `Unmarshalling the type 'DeviceMessageFilters' failed as data isn't a dictionary.`
20
- );
21
- }
22
- return {
23
- publish: data.publish ? unmarshalDeviceMessageFiltersRule(data.publish) : void 0,
24
- subscribe: data.subscribe ? unmarshalDeviceMessageFiltersRule(data.subscribe) : void 0
25
- };
26
- };
27
- const unmarshalDevice = (data) => {
28
- if (!sdkClient.isJSONObject(data)) {
29
- throw new TypeError(
30
- `Unmarshalling the type 'Device' failed as data isn't a dictionary.`
31
- );
32
- }
33
- return {
34
- allowInsecure: data.allow_insecure,
35
- allowMultipleConnections: data.allow_multiple_connections,
36
- createdAt: sdkClient.unmarshalDate(data.created_at),
37
- description: data.description,
38
- hasCustomCertificate: data.has_custom_certificate,
39
- hubId: data.hub_id,
40
- id: data.id,
41
- isConnected: data.is_connected,
42
- lastActivityAt: sdkClient.unmarshalDate(data.last_activity_at),
43
- messageFilters: data.message_filters ? unmarshalDeviceMessageFilters(data.message_filters) : void 0,
44
- name: data.name,
45
- region: data.region,
46
- status: data.status,
47
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
48
- };
49
- };
50
- const unmarshalNetwork = (data) => {
51
- if (!sdkClient.isJSONObject(data)) {
52
- throw new TypeError(
53
- `Unmarshalling the type 'Network' failed as data isn't a dictionary.`
54
- );
55
- }
56
- return {
57
- createdAt: sdkClient.unmarshalDate(data.created_at),
58
- endpoint: data.endpoint,
59
- hubId: data.hub_id,
60
- id: data.id,
61
- name: data.name,
62
- region: data.region,
63
- topicPrefix: data.topic_prefix,
64
- type: data.type
65
- };
66
- };
67
- const unmarshalHubTwinsGraphiteConfig = (data) => {
68
- if (!sdkClient.isJSONObject(data)) {
69
- throw new TypeError(
70
- `Unmarshalling the type 'HubTwinsGraphiteConfig' failed as data isn't a dictionary.`
71
- );
72
- }
73
- return {
74
- pushUri: data.push_uri
75
- };
76
- };
77
- const unmarshalHub = (data) => {
78
- if (!sdkClient.isJSONObject(data)) {
79
- throw new TypeError(
80
- `Unmarshalling the type 'Hub' failed as data isn't a dictionary.`
81
- );
82
- }
83
- return {
84
- connectedDeviceCount: data.connected_device_count,
85
- createdAt: sdkClient.unmarshalDate(data.created_at),
86
- deviceCount: data.device_count,
87
- disableEvents: data.disable_events,
88
- enableDeviceAutoProvisioning: data.enable_device_auto_provisioning,
89
- enabled: data.enabled,
90
- endpoint: data.endpoint,
91
- eventsTopicPrefix: data.events_topic_prefix,
92
- hasCustomCa: data.has_custom_ca,
93
- id: data.id,
94
- name: data.name,
95
- organizationId: data.organization_id,
96
- productPlan: data.product_plan,
97
- projectId: data.project_id,
98
- region: data.region,
99
- status: data.status,
100
- twinsGraphiteConfig: data.twins_graphite_config ? unmarshalHubTwinsGraphiteConfig(data.twins_graphite_config) : void 0,
101
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
102
- };
103
- };
104
- const unmarshalCertificate = (data) => {
105
- if (!sdkClient.isJSONObject(data)) {
106
- throw new TypeError(
107
- `Unmarshalling the type 'Certificate' failed as data isn't a dictionary.`
108
- );
109
- }
110
- return {
111
- crt: data.crt,
112
- key: data.key
113
- };
114
- };
115
- const unmarshalCreateDeviceResponse = (data) => {
116
- if (!sdkClient.isJSONObject(data)) {
117
- throw new TypeError(
118
- `Unmarshalling the type 'CreateDeviceResponse' failed as data isn't a dictionary.`
119
- );
120
- }
121
- return {
122
- certificate: data.certificate ? unmarshalCertificate(data.certificate) : void 0,
123
- device: data.device ? unmarshalDevice(data.device) : void 0
124
- };
125
- };
126
- const unmarshalCreateNetworkResponse = (data) => {
127
- if (!sdkClient.isJSONObject(data)) {
128
- throw new TypeError(
129
- `Unmarshalling the type 'CreateNetworkResponse' failed as data isn't a dictionary.`
130
- );
131
- }
132
- return {
133
- network: data.network ? unmarshalNetwork(data.network) : void 0,
134
- secret: data.secret
135
- };
136
- };
137
- const unmarshalGetDeviceCertificateResponse = (data) => {
138
- if (!sdkClient.isJSONObject(data)) {
139
- throw new TypeError(
140
- `Unmarshalling the type 'GetDeviceCertificateResponse' failed as data isn't a dictionary.`
141
- );
142
- }
143
- return {
144
- certificatePem: data.certificate_pem,
145
- device: data.device ? unmarshalDevice(data.device) : void 0
146
- };
147
- };
148
- const unmarshalGetDeviceMetricsResponse = (data) => {
149
- if (!sdkClient.isJSONObject(data)) {
150
- throw new TypeError(
151
- `Unmarshalling the type 'GetDeviceMetricsResponse' failed as data isn't a dictionary.`
152
- );
153
- }
154
- return {
155
- metrics: sdkClient.unmarshalArrayOfObject(data.metrics, sdkClient.unmarshalTimeSeries)
156
- };
157
- };
158
- const unmarshalGetHubCAResponse = (data) => {
159
- if (!sdkClient.isJSONObject(data)) {
160
- throw new TypeError(
161
- `Unmarshalling the type 'GetHubCAResponse' failed as data isn't a dictionary.`
162
- );
163
- }
164
- return {
165
- caCertPem: data.ca_cert_pem
166
- };
167
- };
168
- const unmarshalGetHubMetricsResponse = (data) => {
169
- if (!sdkClient.isJSONObject(data)) {
170
- throw new TypeError(
171
- `Unmarshalling the type 'GetHubMetricsResponse' failed as data isn't a dictionary.`
172
- );
173
- }
174
- return {
175
- metrics: sdkClient.unmarshalArrayOfObject(data.metrics, sdkClient.unmarshalTimeSeries)
176
- };
177
- };
178
- const unmarshalListDevicesResponse = (data) => {
179
- if (!sdkClient.isJSONObject(data)) {
180
- throw new TypeError(
181
- `Unmarshalling the type 'ListDevicesResponse' failed as data isn't a dictionary.`
182
- );
183
- }
184
- return {
185
- devices: sdkClient.unmarshalArrayOfObject(data.devices, unmarshalDevice),
186
- totalCount: data.total_count
187
- };
188
- };
189
- const unmarshalListHubsResponse = (data) => {
190
- if (!sdkClient.isJSONObject(data)) {
191
- throw new TypeError(
192
- `Unmarshalling the type 'ListHubsResponse' failed as data isn't a dictionary.`
193
- );
194
- }
195
- return {
196
- hubs: sdkClient.unmarshalArrayOfObject(data.hubs, unmarshalHub),
197
- totalCount: data.total_count
198
- };
199
- };
200
- const unmarshalListNetworksResponse = (data) => {
201
- if (!sdkClient.isJSONObject(data)) {
202
- throw new TypeError(
203
- `Unmarshalling the type 'ListNetworksResponse' failed as data isn't a dictionary.`
204
- );
205
- }
206
- return {
207
- networks: sdkClient.unmarshalArrayOfObject(data.networks, unmarshalNetwork),
208
- totalCount: data.total_count
209
- };
210
- };
211
- const unmarshalRouteSummary = (data) => {
212
- if (!sdkClient.isJSONObject(data)) {
213
- throw new TypeError(
214
- `Unmarshalling the type 'RouteSummary' failed as data isn't a dictionary.`
215
- );
216
- }
217
- return {
218
- createdAt: sdkClient.unmarshalDate(data.created_at),
219
- hubId: data.hub_id,
220
- id: data.id,
221
- name: data.name,
222
- region: data.region,
223
- topic: data.topic,
224
- type: data.type,
225
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
226
- };
227
- };
228
- const unmarshalListRoutesResponse = (data) => {
229
- if (!sdkClient.isJSONObject(data)) {
230
- throw new TypeError(
231
- `Unmarshalling the type 'ListRoutesResponse' failed as data isn't a dictionary.`
232
- );
233
- }
234
- return {
235
- routes: sdkClient.unmarshalArrayOfObject(data.routes, unmarshalRouteSummary),
236
- totalCount: data.total_count
237
- };
238
- };
239
- const unmarshalListTwinDocumentsResponseDocumentSummary = (data) => {
240
- if (!sdkClient.isJSONObject(data)) {
241
- throw new TypeError(
242
- `Unmarshalling the type 'ListTwinDocumentsResponseDocumentSummary' failed as data isn't a dictionary.`
243
- );
244
- }
245
- return {
246
- documentName: data.document_name
247
- };
248
- };
249
- const unmarshalListTwinDocumentsResponse = (data) => {
250
- if (!sdkClient.isJSONObject(data)) {
251
- throw new TypeError(
252
- `Unmarshalling the type 'ListTwinDocumentsResponse' failed as data isn't a dictionary.`
253
- );
254
- }
255
- return {
256
- documents: sdkClient.unmarshalArrayOfObject(
257
- data.documents,
258
- unmarshalListTwinDocumentsResponseDocumentSummary
259
- )
260
- };
261
- };
262
- const unmarshalRenewDeviceCertificateResponse = (data) => {
263
- if (!sdkClient.isJSONObject(data)) {
264
- throw new TypeError(
265
- `Unmarshalling the type 'RenewDeviceCertificateResponse' failed as data isn't a dictionary.`
266
- );
267
- }
268
- return {
269
- certificate: data.certificate ? unmarshalCertificate(data.certificate) : void 0,
270
- device: data.device ? unmarshalDevice(data.device) : void 0
271
- };
272
- };
273
- const unmarshalRouteDatabaseConfig = (data) => {
274
- if (!sdkClient.isJSONObject(data)) {
275
- throw new TypeError(
276
- `Unmarshalling the type 'RouteDatabaseConfig' failed as data isn't a dictionary.`
277
- );
278
- }
279
- return {
280
- dbname: data.dbname,
281
- engine: data.engine,
282
- host: data.host,
283
- password: data.password,
284
- port: data.port,
285
- query: data.query,
286
- username: data.username
287
- };
288
- };
289
- const unmarshalRouteRestConfig = (data) => {
290
- if (!sdkClient.isJSONObject(data)) {
291
- throw new TypeError(
292
- `Unmarshalling the type 'RouteRestConfig' failed as data isn't a dictionary.`
293
- );
294
- }
295
- return {
296
- headers: data.headers,
297
- uri: data.uri,
298
- verb: data.verb
299
- };
300
- };
301
- const unmarshalRouteS3Config = (data) => {
302
- if (!sdkClient.isJSONObject(data)) {
303
- throw new TypeError(
304
- `Unmarshalling the type 'RouteS3Config' failed as data isn't a dictionary.`
305
- );
306
- }
307
- return {
308
- bucketName: data.bucket_name,
309
- bucketRegion: data.bucket_region,
310
- objectPrefix: data.object_prefix,
311
- strategy: data.strategy
312
- };
313
- };
314
- const unmarshalRoute = (data) => {
315
- if (!sdkClient.isJSONObject(data)) {
316
- throw new TypeError(
317
- `Unmarshalling the type 'Route' failed as data isn't a dictionary.`
318
- );
319
- }
320
- return {
321
- createdAt: sdkClient.unmarshalDate(data.created_at),
322
- dbConfig: data.db_config ? unmarshalRouteDatabaseConfig(data.db_config) : void 0,
323
- hubId: data.hub_id,
324
- id: data.id,
325
- name: data.name,
326
- region: data.region,
327
- restConfig: data.rest_config ? unmarshalRouteRestConfig(data.rest_config) : void 0,
328
- s3Config: data.s3_config ? unmarshalRouteS3Config(data.s3_config) : void 0,
329
- topic: data.topic,
330
- type: data.type,
331
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
332
- };
333
- };
334
- const unmarshalSetDeviceCertificateResponse = (data) => {
335
- if (!sdkClient.isJSONObject(data)) {
336
- throw new TypeError(
337
- `Unmarshalling the type 'SetDeviceCertificateResponse' failed as data isn't a dictionary.`
338
- );
339
- }
340
- return {
341
- certificatePem: data.certificate_pem,
342
- device: data.device ? unmarshalDevice(data.device) : void 0
343
- };
344
- };
345
- const unmarshalTwinDocument = (data) => {
346
- if (!sdkClient.isJSONObject(data)) {
347
- throw new TypeError(
348
- `Unmarshalling the type 'TwinDocument' failed as data isn't a dictionary.`
349
- );
350
- }
351
- return {
352
- data: data.data,
353
- documentName: data.document_name,
354
- twinId: data.twin_id,
355
- version: data.version
356
- };
357
- };
358
- const marshalDeviceMessageFiltersRule = (request, defaults) => ({
359
- policy: request.policy,
360
- topics: request.topics
361
- });
362
- const marshalDeviceMessageFilters = (request, defaults) => ({
363
- publish: request.publish !== void 0 ? marshalDeviceMessageFiltersRule(request.publish) : void 0,
364
- subscribe: request.subscribe !== void 0 ? marshalDeviceMessageFiltersRule(request.subscribe) : void 0
365
- });
366
- const marshalCreateDeviceRequest = (request, defaults) => ({
367
- allow_insecure: request.allowInsecure,
368
- allow_multiple_connections: request.allowMultipleConnections,
369
- description: request.description,
370
- hub_id: request.hubId,
371
- message_filters: request.messageFilters !== void 0 ? marshalDeviceMessageFilters(request.messageFilters) : void 0,
372
- name: request.name || randomName("device")
373
- });
374
- const marshalHubTwinsGraphiteConfig = (request, defaults) => ({
375
- push_uri: request.pushUri
376
- });
377
- const marshalCreateHubRequest = (request, defaults) => ({
378
- disable_events: request.disableEvents,
379
- events_topic_prefix: request.eventsTopicPrefix,
380
- name: request.name || randomName("hub"),
381
- product_plan: request.productPlan,
382
- project_id: request.projectId ?? defaults.defaultProjectId,
383
- ...sdkClient.resolveOneOf([
384
- {
385
- param: "twins_graphite_config",
386
- value: request.twinsGraphiteConfig !== void 0 ? marshalHubTwinsGraphiteConfig(request.twinsGraphiteConfig) : void 0
387
- }
388
- ])
389
- });
390
- const marshalCreateNetworkRequest = (request, defaults) => ({
391
- hub_id: request.hubId,
392
- name: request.name || randomName("network"),
393
- topic_prefix: request.topicPrefix,
394
- type: request.type
395
- });
396
- const marshalCreateRouteRequestDatabaseConfig = (request, defaults) => ({
397
- dbname: request.dbname,
398
- engine: request.engine,
399
- host: request.host,
400
- password: request.password,
401
- port: request.port,
402
- query: request.query,
403
- username: request.username
404
- });
405
- const marshalCreateRouteRequestRestConfig = (request, defaults) => ({
406
- headers: request.headers,
407
- uri: request.uri,
408
- verb: request.verb
409
- });
410
- const marshalCreateRouteRequestS3Config = (request, defaults) => ({
411
- bucket_name: request.bucketName,
412
- bucket_region: request.bucketRegion,
413
- object_prefix: request.objectPrefix,
414
- strategy: request.strategy
415
- });
416
- const marshalCreateRouteRequest = (request, defaults) => ({
417
- hub_id: request.hubId,
418
- name: request.name || randomName("route"),
419
- topic: request.topic,
420
- ...sdkClient.resolveOneOf([
421
- {
422
- param: "s3_config",
423
- value: request.s3Config !== void 0 ? marshalCreateRouteRequestS3Config(request.s3Config) : void 0
424
- },
425
- {
426
- param: "db_config",
427
- value: request.dbConfig !== void 0 ? marshalCreateRouteRequestDatabaseConfig(request.dbConfig) : void 0
428
- },
429
- {
430
- param: "rest_config",
431
- value: request.restConfig !== void 0 ? marshalCreateRouteRequestRestConfig(request.restConfig) : void 0
432
- }
433
- ])
434
- });
435
- const marshalPatchTwinDocumentRequest = (request, defaults) => ({
436
- data: request.data,
437
- version: request.version
438
- });
439
- const marshalPutTwinDocumentRequest = (request, defaults) => ({
440
- data: request.data,
441
- version: request.version
442
- });
443
- const marshalSetDeviceCertificateRequest = (request, defaults) => ({
444
- certificate_pem: request.certificatePem
445
- });
446
- const marshalSetHubCARequest = (request, defaults) => ({
447
- ca_cert_pem: request.caCertPem,
448
- challenge_cert_pem: request.challengeCertPem
449
- });
450
- const marshalUpdateDeviceRequest = (request, defaults) => ({
451
- allow_insecure: request.allowInsecure,
452
- allow_multiple_connections: request.allowMultipleConnections,
453
- description: request.description,
454
- hub_id: request.hubId,
455
- message_filters: request.messageFilters !== void 0 ? marshalDeviceMessageFilters(request.messageFilters) : void 0
456
- });
457
- const marshalUpdateHubRequest = (request, defaults) => ({
458
- disable_events: request.disableEvents,
459
- enable_device_auto_provisioning: request.enableDeviceAutoProvisioning,
460
- events_topic_prefix: request.eventsTopicPrefix,
461
- name: request.name,
462
- product_plan: request.productPlan,
463
- ...sdkClient.resolveOneOf([
464
- {
465
- param: "twins_graphite_config",
466
- value: request.twinsGraphiteConfig !== void 0 ? marshalHubTwinsGraphiteConfig(request.twinsGraphiteConfig) : void 0
467
- }
468
- ])
469
- });
470
- const marshalUpdateRouteRequestDatabaseConfig = (request, defaults) => ({
471
- dbname: request.dbname,
472
- engine: request.engine,
473
- host: request.host,
474
- password: request.password,
475
- port: request.port,
476
- query: request.query,
477
- username: request.username
478
- });
479
- const marshalUpdateRouteRequestRestConfig = (request, defaults) => ({
480
- headers: request.headers,
481
- uri: request.uri,
482
- verb: request.verb
483
- });
484
- const marshalUpdateRouteRequestS3Config = (request, defaults) => ({
485
- bucket_name: request.bucketName,
486
- bucket_region: request.bucketRegion,
487
- object_prefix: request.objectPrefix,
488
- strategy: request.strategy
489
- });
490
- const marshalUpdateRouteRequest = (request, defaults) => ({
491
- name: request.name,
492
- topic: request.topic,
493
- ...sdkClient.resolveOneOf([
494
- {
495
- param: "s3_config",
496
- value: request.s3Config !== void 0 ? marshalUpdateRouteRequestS3Config(request.s3Config) : void 0
497
- },
498
- {
499
- param: "db_config",
500
- value: request.dbConfig !== void 0 ? marshalUpdateRouteRequestDatabaseConfig(request.dbConfig) : void 0
501
- },
502
- {
503
- param: "rest_config",
504
- value: request.restConfig !== void 0 ? marshalUpdateRouteRequestRestConfig(request.restConfig) : void 0
505
- }
506
- ])
507
- });
508
- exports.marshalCreateDeviceRequest = marshalCreateDeviceRequest;
509
- exports.marshalCreateHubRequest = marshalCreateHubRequest;
510
- exports.marshalCreateNetworkRequest = marshalCreateNetworkRequest;
511
- exports.marshalCreateRouteRequest = marshalCreateRouteRequest;
512
- exports.marshalPatchTwinDocumentRequest = marshalPatchTwinDocumentRequest;
513
- exports.marshalPutTwinDocumentRequest = marshalPutTwinDocumentRequest;
514
- exports.marshalSetDeviceCertificateRequest = marshalSetDeviceCertificateRequest;
515
- exports.marshalSetHubCARequest = marshalSetHubCARequest;
516
- exports.marshalUpdateDeviceRequest = marshalUpdateDeviceRequest;
517
- exports.marshalUpdateHubRequest = marshalUpdateHubRequest;
518
- exports.marshalUpdateRouteRequest = marshalUpdateRouteRequest;
519
- exports.unmarshalCreateDeviceResponse = unmarshalCreateDeviceResponse;
520
- exports.unmarshalCreateNetworkResponse = unmarshalCreateNetworkResponse;
521
- exports.unmarshalDevice = unmarshalDevice;
522
- exports.unmarshalGetDeviceCertificateResponse = unmarshalGetDeviceCertificateResponse;
523
- exports.unmarshalGetDeviceMetricsResponse = unmarshalGetDeviceMetricsResponse;
524
- exports.unmarshalGetHubCAResponse = unmarshalGetHubCAResponse;
525
- exports.unmarshalGetHubMetricsResponse = unmarshalGetHubMetricsResponse;
526
- exports.unmarshalHub = unmarshalHub;
527
- exports.unmarshalListDevicesResponse = unmarshalListDevicesResponse;
528
- exports.unmarshalListHubsResponse = unmarshalListHubsResponse;
529
- exports.unmarshalListNetworksResponse = unmarshalListNetworksResponse;
530
- exports.unmarshalListRoutesResponse = unmarshalListRoutesResponse;
531
- exports.unmarshalListTwinDocumentsResponse = unmarshalListTwinDocumentsResponse;
532
- exports.unmarshalNetwork = unmarshalNetwork;
533
- exports.unmarshalRenewDeviceCertificateResponse = unmarshalRenewDeviceCertificateResponse;
534
- exports.unmarshalRoute = unmarshalRoute;
535
- exports.unmarshalSetDeviceCertificateResponse = unmarshalSetDeviceCertificateResponse;
536
- exports.unmarshalTwinDocument = unmarshalTwinDocument;