@scaleway/sdk-iot 1.2.0 → 2.2.0

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 ADDED
@@ -0,0 +1,96 @@
1
+ # @scaleway/sdk-iot
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@scaleway/sdk-iot.svg)](https://www.npmjs.com/package/@scaleway/sdk-iot)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@scaleway/sdk-iot.svg)](https://www.npmjs.com/package/@scaleway/sdk-iot)
5
+ [![license](https://img.shields.io/npm/l/@scaleway/sdk-iot.svg)](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE)
6
+
7
+ Scaleway SDK for Iot API.
8
+
9
+ > **Note**
10
+ > This is an automatically generated package that is part of the [Scaleway SDK for JavaScript](https://github.com/scaleway/scaleway-sdk-js).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @scaleway/sdk-iot @scaleway/sdk-client
16
+ ```
17
+
18
+ or with pnpm:
19
+
20
+ ```bash
21
+ pnpm add @scaleway/sdk-iot @scaleway/sdk-client
22
+ ```
23
+
24
+ or with yarn:
25
+
26
+ ```bash
27
+ yarn add @scaleway/sdk-iot @scaleway/sdk-client
28
+ ```
29
+
30
+ ## Getting Started
31
+
32
+ You'll need a pair of access and secret keys to connect to Scaleway API. Please check the [documentation](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) on how to retrieve them.
33
+
34
+ ### Basic Usage
35
+
36
+ ```typescript
37
+ import { createClient } from '@scaleway/sdk-client'
38
+ import { Iot } from '@scaleway/sdk-iot'
39
+
40
+ const client = createClient({
41
+ accessKey: 'SCWXXXXXXXXXXXXXXXXX',
42
+ secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
43
+ defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
44
+ defaultRegion: 'fr-par',
45
+ defaultZone: 'fr-par-1',
46
+ })
47
+
48
+ const api = new Iot.v1.API(client)
49
+
50
+ // Use the API
51
+ // Example: await api.listServers()
52
+ ```
53
+
54
+ ### Using Configuration Loader
55
+
56
+ For a simpler setup, you can load credentials from the configuration file or environment variables:
57
+
58
+ ```typescript
59
+ import { createClient } from '@scaleway/sdk-client'
60
+ import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
61
+ import { Iot } from '@scaleway/sdk-iot'
62
+
63
+ const profile = loadProfileFromConfigurationFile()
64
+ const client = createClient(profile)
65
+ const api = new Iot.v1.API(client)
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ - 📚 [Scaleway SDK Reference Documentation](https://scaleway.github.io/scaleway-sdk-js)
71
+ - 🌐 [Scaleway Iot API Documentation](https://www.scaleway.com/en/developers/api/iot/)
72
+ - 📖 [Main Repository](https://github.com/scaleway/scaleway-sdk-js)
73
+ - 💡 [Example Projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
74
+
75
+ ## Features
76
+
77
+ - ✅ Full TypeScript support with complete type definitions
78
+ - ✅ Promise-based API
79
+ - ✅ Automatic pagination helpers
80
+ - ✅ Built-in error handling
81
+ - ✅ Compatible with Node.js ≥ 20
82
+
83
+ ## Support
84
+
85
+ We love feedback! Feel free to reach us on:
86
+ - [Scaleway Slack community](https://slack.scaleway.com/) - Join us on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource)
87
+ - [GitHub Issues](https://github.com/scaleway/scaleway-sdk-js/issues)
88
+
89
+ ## Contributing
90
+
91
+ This repository is at its early stage and is still in active development. If you are looking for a way to contribute, please read [CONTRIBUTING.md](https://github.com/scaleway/scaleway-sdk-js/blob/master/CONTRIBUTING.md).
92
+
93
+ ## License
94
+
95
+ This project is Apache 2.0 licensed. See the [LICENSE](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE) file for details.
96
+
@@ -1,5 +1,5 @@
1
- import { API as ParentAPI } from '@scaleway/sdk-client';
2
1
  import type { ApiLocality, WaitForOptions } from '@scaleway/sdk-client';
2
+ import { API as ParentAPI } from '@scaleway/sdk-client';
3
3
  import type { CreateDeviceRequest, CreateDeviceResponse, CreateHubRequest, CreateNetworkRequest, CreateNetworkResponse, CreateRouteRequest, DeleteDeviceRequest, DeleteHubRequest, DeleteNetworkRequest, DeleteRouteRequest, DeleteTwinDocumentRequest, DeleteTwinDocumentsRequest, Device, DisableDeviceRequest, DisableHubRequest, EnableDeviceRequest, EnableHubRequest, GetDeviceCertificateRequest, GetDeviceCertificateResponse, GetDeviceMetricsRequest, GetDeviceMetricsResponse, GetDeviceRequest, GetHubCARequest, GetHubCAResponse, GetHubMetricsRequest, GetHubMetricsResponse, GetHubRequest, GetNetworkRequest, GetRouteRequest, GetTwinDocumentRequest, Hub, ListDevicesRequest, ListDevicesResponse, ListHubsRequest, ListHubsResponse, ListNetworksRequest, ListNetworksResponse, ListRoutesRequest, ListRoutesResponse, ListTwinDocumentsRequest, ListTwinDocumentsResponse, Network, PatchTwinDocumentRequest, PutTwinDocumentRequest, RenewDeviceCertificateRequest, RenewDeviceCertificateResponse, Route, SetDeviceCertificateRequest, SetDeviceCertificateResponse, SetHubCARequest, TwinDocument, UpdateDeviceRequest, UpdateHubRequest, UpdateRouteRequest } from './types.gen.js';
4
4
  /**
5
5
  * IoT Hub API.
@@ -214,7 +214,7 @@ export interface Hub {
214
214
  */
215
215
  organizationId: string;
216
216
  /**
217
- * When an unknown device connects to your hub using a valid certificate chain, it will be automatically provisioned inside your Hub. The Hub uses the common name of the device certifcate to find out if a device with the same name already exists. This setting can only be enabled on a hub with a custom certificate authority.
217
+ * When an unknown device connects to your hub using a valid certificate chain, it will be automatically provisioned inside your Hub. The Hub uses the common name of the device certificate to find out if a device with the same name already exists. This setting can only be enabled on a hub with a custom certificate authority.
218
218
  */
219
219
  enableDeviceAutoProvisioning: boolean;
220
220
  /**
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-iot",
3
- "version": "1.2.0",
3
+ "version": "2.2.0",
4
4
  "description": "Scaleway SDK iot",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
+ "README.md",
7
8
  "dist"
8
9
  ],
9
10
  "type": "module",
10
11
  "exports": {
11
12
  ".": {
12
13
  "types": "./dist/index.gen.d.ts",
13
- "import": "./dist/index.gen.js",
14
- "require": "./dist/index.gen.cjs",
15
14
  "default": "./dist/index.gen.js"
16
15
  },
17
16
  "./*": {
18
17
  "types": "./dist/*/index.gen.d.ts",
19
- "import": "./dist/*/index.gen.js",
20
- "require": "./dist/*/index.gen.cjs",
21
18
  "default": "./dist/*/index.gen.js"
22
19
  }
23
20
  },
@@ -26,17 +23,17 @@
26
23
  "directory": "packages_generated/iot"
27
24
  },
28
25
  "engines": {
29
- "node": ">=20.19.4"
26
+ "node": ">=20.19.6"
30
27
  },
31
28
  "dependencies": {
32
29
  "@scaleway/random-name": "5.1.2",
33
- "@scaleway/sdk-std": "1.2.0"
30
+ "@scaleway/sdk-std": "2.1.0"
34
31
  },
35
32
  "peerDependencies": {
36
- "@scaleway/sdk-client": "^1.3.3"
33
+ "@scaleway/sdk-client": "^2.1.0"
37
34
  },
38
35
  "devDependencies": {
39
- "@scaleway/sdk-client": "^1.3.3"
36
+ "@scaleway/sdk-client": "^2.1.0"
40
37
  },
41
38
  "scripts": {
42
39
  "package:check": "pnpm publint",
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index_gen = require("./v1/index.gen.cjs");
4
- exports.Iotv1 = index_gen;
@@ -1,591 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const sdkClient = require("@scaleway/sdk-client");
4
- const content_gen = require("./content.gen.cjs");
5
- const marshalling_gen = require("./marshalling.gen.cjs");
6
- const jsonContentHeaders = {
7
- "Content-Type": "application/json; charset=utf-8"
8
- };
9
- class API extends sdkClient.API {
10
- /**
11
- * Locality of this API.
12
- * type ∈ {'zone','region','global','unspecified'}
13
- */
14
- static LOCALITY = sdkClient.toApiLocality({
15
- regions: ["fr-par"]
16
- });
17
- pageOfListHubs = (request = {}) => this.client.fetch(
18
- {
19
- method: "GET",
20
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`,
21
- urlParams: sdkClient.urlParams(
22
- ["name", request.name],
23
- ["order_by", request.orderBy],
24
- ["organization_id", request.organizationId],
25
- ["page", request.page],
26
- [
27
- "page_size",
28
- request.pageSize ?? this.client.settings.defaultPageSize
29
- ],
30
- ["project_id", request.projectId]
31
- )
32
- },
33
- marshalling_gen.unmarshalListHubsResponse
34
- );
35
- /**
36
- * List hubs. List all Hubs in the specified zone. By default, returned Hubs are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
37
- *
38
- * @param request - The request {@link ListHubsRequest}
39
- * @returns A Promise of ListHubsResponse
40
- */
41
- listHubs = (request = {}) => sdkClient.enrichForPagination("hubs", this.pageOfListHubs, request);
42
- /**
43
- * Create a hub. Create a new Hub in the targeted region, specifying its configuration including name and product plan.
44
- *
45
- * @param request - The request {@link CreateHubRequest}
46
- * @returns A Promise of Hub
47
- */
48
- createHub = (request) => this.client.fetch(
49
- {
50
- body: JSON.stringify(
51
- marshalling_gen.marshalCreateHubRequest(request, this.client.settings)
52
- ),
53
- headers: jsonContentHeaders,
54
- method: "POST",
55
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`
56
- },
57
- marshalling_gen.unmarshalHub
58
- );
59
- /**
60
- * Get a hub. Retrieve information about an existing IoT Hub, specified by its Hub ID. Its full details, including name, status and endpoint, are returned in the response object.
61
- *
62
- * @param request - The request {@link GetHubRequest}
63
- * @returns A Promise of Hub
64
- */
65
- getHub = (request) => this.client.fetch(
66
- {
67
- method: "GET",
68
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}`
69
- },
70
- marshalling_gen.unmarshalHub
71
- );
72
- /**
73
- * Waits for {@link Hub} to be in a final state.
74
- *
75
- * @param request - The request {@link GetHubRequest}
76
- * @param options - The waiting options
77
- * @returns A Promise of Hub
78
- */
79
- waitForHub = (request, options) => sdkClient.waitForResource(
80
- options?.stop ?? ((res) => Promise.resolve(!content_gen.HUB_TRANSIENT_STATUSES.includes(res.status))),
81
- this.getHub,
82
- request,
83
- options
84
- );
85
- /**
86
- * Update a hub. Update the parameters of an existing IoT Hub, specified by its Hub ID.
87
- *
88
- * @param request - The request {@link UpdateHubRequest}
89
- * @returns A Promise of Hub
90
- */
91
- updateHub = (request) => this.client.fetch(
92
- {
93
- body: JSON.stringify(
94
- marshalling_gen.marshalUpdateHubRequest(request, this.client.settings)
95
- ),
96
- headers: jsonContentHeaders,
97
- method: "PATCH",
98
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}`
99
- },
100
- marshalling_gen.unmarshalHub
101
- );
102
- /**
103
- * Enable a hub. Enable an existing IoT Hub, specified by its Hub ID.
104
- *
105
- * @param request - The request {@link EnableHubRequest}
106
- * @returns A Promise of Hub
107
- */
108
- enableHub = (request) => this.client.fetch(
109
- {
110
- body: "{}",
111
- headers: jsonContentHeaders,
112
- method: "POST",
113
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}/enable`
114
- },
115
- marshalling_gen.unmarshalHub
116
- );
117
- /**
118
- * Disable a hub. Disable an existing IoT Hub, specified by its Hub ID.
119
- *
120
- * @param request - The request {@link DisableHubRequest}
121
- * @returns A Promise of Hub
122
- */
123
- disableHub = (request) => this.client.fetch(
124
- {
125
- body: "{}",
126
- headers: jsonContentHeaders,
127
- method: "POST",
128
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}/disable`
129
- },
130
- marshalling_gen.unmarshalHub
131
- );
132
- /**
133
- * Delete a hub. Delete an existing IoT Hub, specified by its Hub ID. Deleting a Hub is permanent, and cannot be undone.
134
- *
135
- * @param request - The request {@link DeleteHubRequest}
136
- */
137
- deleteHub = (request) => this.client.fetch({
138
- method: "DELETE",
139
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}`,
140
- urlParams: sdkClient.urlParams(["delete_devices", request.deleteDevices])
141
- });
142
- /**
143
- * Get a hub's metrics. Get the metrics of an existing IoT Hub, specified by its Hub ID.
144
- *
145
- * @deprecated
146
- * @param request - The request {@link GetHubMetricsRequest}
147
- * @returns A Promise of GetHubMetricsResponse
148
- */
149
- getHubMetrics = (request) => this.client.fetch(
150
- {
151
- method: "GET",
152
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}/metrics`,
153
- urlParams: sdkClient.urlParams(["start_date", request.startDate])
154
- },
155
- marshalling_gen.unmarshalGetHubMetricsResponse
156
- );
157
- /**
158
- * Set the certificate authority of a hub. Set a particular PEM-encoded certificate, specified by the Hub ID.
159
- *
160
- * @param request - The request {@link SetHubCARequest}
161
- * @returns A Promise of Hub
162
- */
163
- setHubCA = (request) => this.client.fetch(
164
- {
165
- body: JSON.stringify(
166
- marshalling_gen.marshalSetHubCARequest(request, this.client.settings)
167
- ),
168
- headers: jsonContentHeaders,
169
- method: "POST",
170
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}/ca`
171
- },
172
- marshalling_gen.unmarshalHub
173
- );
174
- /**
175
- * Get the certificate authority of a hub. Get information for a particular PEM-encoded certificate, specified by the Hub ID.
176
- *
177
- * @param request - The request {@link GetHubCARequest}
178
- * @returns A Promise of GetHubCAResponse
179
- */
180
- getHubCA = (request) => this.client.fetch(
181
- {
182
- method: "GET",
183
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${sdkClient.validatePathParam("hubId", request.hubId)}/ca`
184
- },
185
- marshalling_gen.unmarshalGetHubCAResponse
186
- );
187
- pageOfListDevices = (request = {}) => this.client.fetch(
188
- {
189
- method: "GET",
190
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`,
191
- urlParams: sdkClient.urlParams(
192
- ["allow_insecure", request.allowInsecure],
193
- ["hub_id", request.hubId],
194
- ["name", request.name],
195
- ["order_by", request.orderBy],
196
- ["page", request.page],
197
- [
198
- "page_size",
199
- request.pageSize ?? this.client.settings.defaultPageSize
200
- ],
201
- ["status", request.status]
202
- )
203
- },
204
- marshalling_gen.unmarshalListDevicesResponse
205
- );
206
- /**
207
- * List devices. List all devices in the specified region. By default, returned devices are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
208
- *
209
- * @param request - The request {@link ListDevicesRequest}
210
- * @returns A Promise of ListDevicesResponse
211
- */
212
- listDevices = (request = {}) => sdkClient.enrichForPagination("devices", this.pageOfListDevices, request);
213
- /**
214
- * Add a device. Attach a device to a given Hub.
215
- *
216
- * @param request - The request {@link CreateDeviceRequest}
217
- * @returns A Promise of CreateDeviceResponse
218
- */
219
- createDevice = (request) => this.client.fetch(
220
- {
221
- body: JSON.stringify(
222
- marshalling_gen.marshalCreateDeviceRequest(request, this.client.settings)
223
- ),
224
- headers: jsonContentHeaders,
225
- method: "POST",
226
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`
227
- },
228
- marshalling_gen.unmarshalCreateDeviceResponse
229
- );
230
- /**
231
- * Get a device. Retrieve information about an existing device, specified by its device ID. Its full details, including name, status and ID, are returned in the response object.
232
- *
233
- * @param request - The request {@link GetDeviceRequest}
234
- * @returns A Promise of Device
235
- */
236
- getDevice = (request) => this.client.fetch(
237
- {
238
- method: "GET",
239
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}`
240
- },
241
- marshalling_gen.unmarshalDevice
242
- );
243
- /**
244
- * Update a device. Update the parameters of an existing device, specified by its device ID.
245
- *
246
- * @param request - The request {@link UpdateDeviceRequest}
247
- * @returns A Promise of Device
248
- */
249
- updateDevice = (request) => this.client.fetch(
250
- {
251
- body: JSON.stringify(
252
- marshalling_gen.marshalUpdateDeviceRequest(request, this.client.settings)
253
- ),
254
- headers: jsonContentHeaders,
255
- method: "PATCH",
256
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}`
257
- },
258
- marshalling_gen.unmarshalDevice
259
- );
260
- /**
261
- * Enable a device. Enable a specific device, specified by its device ID.
262
- *
263
- * @param request - The request {@link EnableDeviceRequest}
264
- * @returns A Promise of Device
265
- */
266
- enableDevice = (request) => this.client.fetch(
267
- {
268
- body: "{}",
269
- headers: jsonContentHeaders,
270
- method: "POST",
271
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/enable`
272
- },
273
- marshalling_gen.unmarshalDevice
274
- );
275
- /**
276
- * Disable a device. Disable an existing device, specified by its device ID.
277
- *
278
- * @param request - The request {@link DisableDeviceRequest}
279
- * @returns A Promise of Device
280
- */
281
- disableDevice = (request) => this.client.fetch(
282
- {
283
- body: "{}",
284
- headers: jsonContentHeaders,
285
- method: "POST",
286
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/disable`
287
- },
288
- marshalling_gen.unmarshalDevice
289
- );
290
- /**
291
- * Renew a device certificate. Renew the certificate of an existing device, specified by its device ID.
292
- *
293
- * @param request - The request {@link RenewDeviceCertificateRequest}
294
- * @returns A Promise of RenewDeviceCertificateResponse
295
- */
296
- renewDeviceCertificate = (request) => this.client.fetch(
297
- {
298
- body: "{}",
299
- headers: jsonContentHeaders,
300
- method: "POST",
301
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/renew-certificate`
302
- },
303
- marshalling_gen.unmarshalRenewDeviceCertificateResponse
304
- );
305
- /**
306
- * Set a custom certificate on a device. Switch the existing certificate of a given device with an EM-encoded custom certificate.
307
- *
308
- * @param request - The request {@link SetDeviceCertificateRequest}
309
- * @returns A Promise of SetDeviceCertificateResponse
310
- */
311
- setDeviceCertificate = (request) => this.client.fetch(
312
- {
313
- body: JSON.stringify(
314
- marshalling_gen.marshalSetDeviceCertificateRequest(request, this.client.settings)
315
- ),
316
- headers: jsonContentHeaders,
317
- method: "PUT",
318
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/certificate`
319
- },
320
- marshalling_gen.unmarshalSetDeviceCertificateResponse
321
- );
322
- /**
323
- * Get a device's certificate. Get information for a particular PEM-encoded certificate, specified by the device ID. The response returns full details of the device, including its type of certificate.
324
- *
325
- * @param request - The request {@link GetDeviceCertificateRequest}
326
- * @returns A Promise of GetDeviceCertificateResponse
327
- */
328
- getDeviceCertificate = (request) => this.client.fetch(
329
- {
330
- method: "GET",
331
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/certificate`
332
- },
333
- marshalling_gen.unmarshalGetDeviceCertificateResponse
334
- );
335
- /**
336
- * Remove a device. Remove a specific device from the specific Hub it is attached to.
337
- *
338
- * @param request - The request {@link DeleteDeviceRequest}
339
- */
340
- deleteDevice = (request) => this.client.fetch({
341
- method: "DELETE",
342
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}`
343
- });
344
- /**
345
- * Get a device's metrics. Get the metrics of an existing device, specified by its device ID.
346
- *
347
- * @deprecated
348
- * @param request - The request {@link GetDeviceMetricsRequest}
349
- * @returns A Promise of GetDeviceMetricsResponse
350
- */
351
- getDeviceMetrics = (request) => this.client.fetch(
352
- {
353
- method: "GET",
354
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${sdkClient.validatePathParam("deviceId", request.deviceId)}/metrics`,
355
- urlParams: sdkClient.urlParams(["start_date", request.startDate])
356
- },
357
- marshalling_gen.unmarshalGetDeviceMetricsResponse
358
- );
359
- pageOfListRoutes = (request = {}) => this.client.fetch(
360
- {
361
- method: "GET",
362
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`,
363
- urlParams: sdkClient.urlParams(
364
- ["hub_id", request.hubId],
365
- ["name", request.name],
366
- ["order_by", request.orderBy],
367
- ["page", request.page],
368
- [
369
- "page_size",
370
- request.pageSize ?? this.client.settings.defaultPageSize
371
- ]
372
- )
373
- },
374
- marshalling_gen.unmarshalListRoutesResponse
375
- );
376
- /**
377
- * List routes. List all routes in the specified region. By default, returned routes are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
378
- *
379
- * @param request - The request {@link ListRoutesRequest}
380
- * @returns A Promise of ListRoutesResponse
381
- */
382
- listRoutes = (request = {}) => sdkClient.enrichForPagination("routes", this.pageOfListRoutes, request);
383
- /**
384
- * Create a route. Multiple kinds of routes can be created, such as:
385
- - Database Route
386
- Create a route that will record subscribed MQTT messages into your database.
387
- <b>You need to manage the database by yourself</b>.
388
- - REST Route.
389
- Create a route that will call a REST API on received subscribed MQTT messages.
390
- - Amazon S3 Routes.
391
- Create a route that will put subscribed MQTT messages into an Object Storage bucket.
392
- You need to create the bucket yourself and grant write access.
393
- Granting can be done with s3cmd (`s3cmd setacl s3://<my-bucket> --acl-grant=write:555c69c3-87d0-4bf8-80f1-99a2f757d031:555c69c3-87d0-4bf8-80f1-99a2f757d031`).
394
- *
395
- * @param request - The request {@link CreateRouteRequest}
396
- * @returns A Promise of Route
397
- */
398
- createRoute = (request) => this.client.fetch(
399
- {
400
- body: JSON.stringify(
401
- marshalling_gen.marshalCreateRouteRequest(request, this.client.settings)
402
- ),
403
- headers: jsonContentHeaders,
404
- method: "POST",
405
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`
406
- },
407
- marshalling_gen.unmarshalRoute
408
- );
409
- /**
410
- * Update a route. Update the parameters of an existing route, specified by its route ID.
411
- *
412
- * @param request - The request {@link UpdateRouteRequest}
413
- * @returns A Promise of Route
414
- */
415
- updateRoute = (request) => this.client.fetch(
416
- {
417
- body: JSON.stringify(
418
- marshalling_gen.marshalUpdateRouteRequest(request, this.client.settings)
419
- ),
420
- headers: jsonContentHeaders,
421
- method: "PATCH",
422
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${sdkClient.validatePathParam("routeId", request.routeId)}`
423
- },
424
- marshalling_gen.unmarshalRoute
425
- );
426
- /**
427
- * Get a route. Get information for a particular route, specified by the route ID. The response returns full details of the route, including its type, the topic it subscribes to and its configuration.
428
- *
429
- * @param request - The request {@link GetRouteRequest}
430
- * @returns A Promise of Route
431
- */
432
- getRoute = (request) => this.client.fetch(
433
- {
434
- method: "GET",
435
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${sdkClient.validatePathParam("routeId", request.routeId)}`
436
- },
437
- marshalling_gen.unmarshalRoute
438
- );
439
- /**
440
- * Delete a route. Delete an existing route, specified by its route ID. Deleting a route is permanent, and cannot be undone.
441
- *
442
- * @param request - The request {@link DeleteRouteRequest}
443
- */
444
- deleteRoute = (request) => this.client.fetch({
445
- method: "DELETE",
446
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${sdkClient.validatePathParam("routeId", request.routeId)}`
447
- });
448
- pageOfListNetworks = (request = {}) => this.client.fetch(
449
- {
450
- method: "GET",
451
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`,
452
- urlParams: sdkClient.urlParams(
453
- ["hub_id", request.hubId],
454
- ["name", request.name],
455
- ["order_by", request.orderBy],
456
- ["page", request.page],
457
- [
458
- "page_size",
459
- request.pageSize ?? this.client.settings.defaultPageSize
460
- ],
461
- ["topic_prefix", request.topicPrefix]
462
- )
463
- },
464
- marshalling_gen.unmarshalListNetworksResponse
465
- );
466
- /**
467
- * List the networks.
468
- *
469
- * @param request - The request {@link ListNetworksRequest}
470
- * @returns A Promise of ListNetworksResponse
471
- */
472
- listNetworks = (request = {}) => sdkClient.enrichForPagination("networks", this.pageOfListNetworks, request);
473
- /**
474
- * Create a new network. Create a new network for an existing hub. Beside the default network, you can add networks for different data providers. Possible network types are Sigfox and REST.
475
- *
476
- * @param request - The request {@link CreateNetworkRequest}
477
- * @returns A Promise of CreateNetworkResponse
478
- */
479
- createNetwork = (request) => this.client.fetch(
480
- {
481
- body: JSON.stringify(
482
- marshalling_gen.marshalCreateNetworkRequest(request, this.client.settings)
483
- ),
484
- headers: jsonContentHeaders,
485
- method: "POST",
486
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`
487
- },
488
- marshalling_gen.unmarshalCreateNetworkResponse
489
- );
490
- /**
491
- * Retrieve a specific network. Retrieve an existing network, specified by its network ID. The response returns full details of the network, including its type, the topic prefix and its endpoint.
492
- *
493
- * @param request - The request {@link GetNetworkRequest}
494
- * @returns A Promise of Network
495
- */
496
- getNetwork = (request) => this.client.fetch(
497
- {
498
- method: "GET",
499
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${sdkClient.validatePathParam("networkId", request.networkId)}`
500
- },
501
- marshalling_gen.unmarshalNetwork
502
- );
503
- /**
504
- * Delete a Network. Delete an existing network, specified by its network ID. Deleting a network is permanent, and cannot be undone.
505
- *
506
- * @param request - The request {@link DeleteNetworkRequest}
507
- */
508
- deleteNetwork = (request) => this.client.fetch({
509
- method: "DELETE",
510
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${sdkClient.validatePathParam("networkId", request.networkId)}`
511
- });
512
- /**
513
- * BETA - Get a Cloud Twin Document.
514
- *
515
- * @param request - The request {@link GetTwinDocumentRequest}
516
- * @returns A Promise of TwinDocument
517
- */
518
- getTwinDocument = (request) => this.client.fetch(
519
- {
520
- method: "GET",
521
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}/documents/${sdkClient.validatePathParam("documentName", request.documentName)}`
522
- },
523
- marshalling_gen.unmarshalTwinDocument
524
- );
525
- /**
526
- * BETA - Update a Cloud Twin Document.
527
- *
528
- * @param request - The request {@link PutTwinDocumentRequest}
529
- * @returns A Promise of TwinDocument
530
- */
531
- putTwinDocument = (request) => this.client.fetch(
532
- {
533
- body: JSON.stringify(
534
- marshalling_gen.marshalPutTwinDocumentRequest(request, this.client.settings)
535
- ),
536
- headers: jsonContentHeaders,
537
- method: "PUT",
538
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}/documents/${sdkClient.validatePathParam("documentName", request.documentName)}`
539
- },
540
- marshalling_gen.unmarshalTwinDocument
541
- );
542
- /**
543
- * BETA - Patch a Cloud Twin Document.
544
- *
545
- * @param request - The request {@link PatchTwinDocumentRequest}
546
- * @returns A Promise of TwinDocument
547
- */
548
- patchTwinDocument = (request) => this.client.fetch(
549
- {
550
- body: JSON.stringify(
551
- marshalling_gen.marshalPatchTwinDocumentRequest(request, this.client.settings)
552
- ),
553
- headers: jsonContentHeaders,
554
- method: "PATCH",
555
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}/documents/${sdkClient.validatePathParam("documentName", request.documentName)}`
556
- },
557
- marshalling_gen.unmarshalTwinDocument
558
- );
559
- /**
560
- * BETA - Delete a Cloud Twin Document.
561
- *
562
- * @param request - The request {@link DeleteTwinDocumentRequest}
563
- */
564
- deleteTwinDocument = (request) => this.client.fetch({
565
- method: "DELETE",
566
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}/documents/${sdkClient.validatePathParam("documentName", request.documentName)}`
567
- });
568
- /**
569
- * BETA - List the documents of a Cloud Twin.
570
- *
571
- * @param request - The request {@link ListTwinDocumentsRequest}
572
- * @returns A Promise of ListTwinDocumentsResponse
573
- */
574
- listTwinDocuments = (request) => this.client.fetch(
575
- {
576
- method: "GET",
577
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}`
578
- },
579
- marshalling_gen.unmarshalListTwinDocumentsResponse
580
- );
581
- /**
582
- * BETA - Delete all the documents of a Cloud Twin.
583
- *
584
- * @param request - The request {@link DeleteTwinDocumentsRequest}
585
- */
586
- deleteTwinDocuments = (request) => this.client.fetch({
587
- method: "DELETE",
588
- path: `/iot/v1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${sdkClient.validatePathParam("twinId", request.twinId)}`
589
- });
590
- }
591
- exports.API = API;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const HUB_TRANSIENT_STATUSES = ["enabling", "disabling"];
4
- exports.HUB_TRANSIENT_STATUSES = HUB_TRANSIENT_STATUSES;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const api_gen = require("./api.gen.cjs");
4
- const content_gen = require("./content.gen.cjs");
5
- const marshalling_gen = require("./marshalling.gen.cjs");
6
- exports.API = api_gen.API;
7
- exports.HUB_TRANSIENT_STATUSES = content_gen.HUB_TRANSIENT_STATUSES;
8
- exports.marshalCreateDeviceRequest = marshalling_gen.marshalCreateDeviceRequest;
9
- exports.marshalCreateHubRequest = marshalling_gen.marshalCreateHubRequest;
10
- exports.marshalCreateNetworkRequest = marshalling_gen.marshalCreateNetworkRequest;
11
- exports.marshalCreateRouteRequest = marshalling_gen.marshalCreateRouteRequest;
12
- exports.marshalPatchTwinDocumentRequest = marshalling_gen.marshalPatchTwinDocumentRequest;
13
- exports.marshalPutTwinDocumentRequest = marshalling_gen.marshalPutTwinDocumentRequest;
14
- exports.marshalSetDeviceCertificateRequest = marshalling_gen.marshalSetDeviceCertificateRequest;
15
- exports.marshalSetHubCARequest = marshalling_gen.marshalSetHubCARequest;
16
- exports.marshalUpdateDeviceRequest = marshalling_gen.marshalUpdateDeviceRequest;
17
- exports.marshalUpdateHubRequest = marshalling_gen.marshalUpdateHubRequest;
18
- exports.marshalUpdateRouteRequest = marshalling_gen.marshalUpdateRouteRequest;
19
- exports.unmarshalCreateDeviceResponse = marshalling_gen.unmarshalCreateDeviceResponse;
20
- exports.unmarshalCreateNetworkResponse = marshalling_gen.unmarshalCreateNetworkResponse;
21
- exports.unmarshalDevice = marshalling_gen.unmarshalDevice;
22
- exports.unmarshalGetDeviceCertificateResponse = marshalling_gen.unmarshalGetDeviceCertificateResponse;
23
- exports.unmarshalGetDeviceMetricsResponse = marshalling_gen.unmarshalGetDeviceMetricsResponse;
24
- exports.unmarshalGetHubCAResponse = marshalling_gen.unmarshalGetHubCAResponse;
25
- exports.unmarshalGetHubMetricsResponse = marshalling_gen.unmarshalGetHubMetricsResponse;
26
- exports.unmarshalHub = marshalling_gen.unmarshalHub;
27
- exports.unmarshalListDevicesResponse = marshalling_gen.unmarshalListDevicesResponse;
28
- exports.unmarshalListHubsResponse = marshalling_gen.unmarshalListHubsResponse;
29
- exports.unmarshalListNetworksResponse = marshalling_gen.unmarshalListNetworksResponse;
30
- exports.unmarshalListRoutesResponse = marshalling_gen.unmarshalListRoutesResponse;
31
- exports.unmarshalListTwinDocumentsResponse = marshalling_gen.unmarshalListTwinDocumentsResponse;
32
- exports.unmarshalNetwork = marshalling_gen.unmarshalNetwork;
33
- exports.unmarshalRenewDeviceCertificateResponse = marshalling_gen.unmarshalRenewDeviceCertificateResponse;
34
- exports.unmarshalRoute = marshalling_gen.unmarshalRoute;
35
- exports.unmarshalSetDeviceCertificateResponse = marshalling_gen.unmarshalSetDeviceCertificateResponse;
36
- exports.unmarshalTwinDocument = marshalling_gen.unmarshalTwinDocument;
@@ -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;