@scaleway/sdk-iot 2.4.0 → 2.6.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.
@@ -2,434 +2,207 @@ import { HUB_TRANSIENT_STATUSES } from "./content.gen.js";
2
2
  import { marshalCreateDeviceRequest, marshalCreateHubRequest, marshalCreateNetworkRequest, marshalCreateRouteRequest, marshalPatchTwinDocumentRequest, marshalPutTwinDocumentRequest, marshalSetDeviceCertificateRequest, marshalSetHubCARequest, marshalUpdateDeviceRequest, marshalUpdateHubRequest, marshalUpdateRouteRequest, unmarshalCreateDeviceResponse, unmarshalCreateNetworkResponse, unmarshalDevice, unmarshalGetDeviceCertificateResponse, unmarshalGetDeviceMetricsResponse, unmarshalGetHubCAResponse, unmarshalGetHubMetricsResponse, unmarshalHub, unmarshalListDevicesResponse, unmarshalListHubsResponse, unmarshalListNetworksResponse, unmarshalListRoutesResponse, unmarshalListTwinDocumentsResponse, unmarshalNetwork, unmarshalRenewDeviceCertificateResponse, unmarshalRoute, unmarshalSetDeviceCertificateResponse, unmarshalTwinDocument } from "./marshalling.gen.js";
3
3
  import { API as API$1, enrichForPagination, toApiLocality, urlParams, validatePathParam, waitForResource } from "@scaleway/sdk-client";
4
4
  //#region src/v1/api.gen.ts
5
- var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ const jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
6
6
  /**
7
7
  * IoT Hub API.
8
8
 
9
9
  This API allows you to manage your IoT hubs and devices.
10
10
  */
11
11
  var API = class extends API$1 {
12
- /**
13
- * Locality of this API.
14
- * type {'zone','region','global','unspecified'}
15
- */
16
- static LOCALITY = toApiLocality({ regions: ["fr-par"] });
17
- pageOfListHubs = (request = {}) => this.client.fetch({
18
- method: "GET",
19
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`,
20
- urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
21
- }, unmarshalListHubsResponse);
22
- /**
23
- * 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.
24
- *
25
- * @param request - The request {@link ListHubsRequest}
26
- * @returns A Promise of ListHubsResponse
27
- */
28
- listHubs = (request = {}) => enrichForPagination("hubs", this.pageOfListHubs, request);
29
- /**
30
- * Create a hub. Create a new Hub in the targeted region, specifying its configuration including name and product plan.
31
- *
32
- * @param request - The request {@link CreateHubRequest}
33
- * @returns A Promise of Hub
34
- */
35
- createHub = (request) => this.client.fetch({
36
- body: JSON.stringify(marshalCreateHubRequest(request, this.client.settings)),
37
- headers: jsonContentHeaders,
38
- method: "POST",
39
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`
40
- }, unmarshalHub);
41
- /**
42
- * 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.
43
- *
44
- * @param request - The request {@link GetHubRequest}
45
- * @returns A Promise of Hub
46
- */
47
- getHub = (request) => this.client.fetch({
48
- method: "GET",
49
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`
50
- }, unmarshalHub);
51
- /**
52
- * Waits for {@link Hub} to be in a final state.
53
- *
54
- * @param request - The request {@link GetHubRequest}
55
- * @param options - The waiting options
56
- * @returns A Promise of Hub
57
- */
58
- waitForHub = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!HUB_TRANSIENT_STATUSES.includes(res.status))), this.getHub, request, options);
59
- /**
60
- * Update a hub. Update the parameters of an existing IoT Hub, specified by its Hub ID.
61
- *
62
- * @param request - The request {@link UpdateHubRequest}
63
- * @returns A Promise of Hub
64
- */
65
- updateHub = (request) => this.client.fetch({
66
- body: JSON.stringify(marshalUpdateHubRequest(request, this.client.settings)),
67
- headers: jsonContentHeaders,
68
- method: "PATCH",
69
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`
70
- }, unmarshalHub);
71
- /**
72
- * Enable a hub. Enable an existing IoT Hub, specified by its Hub ID.
73
- *
74
- * @param request - The request {@link EnableHubRequest}
75
- * @returns A Promise of Hub
76
- */
77
- enableHub = (request) => this.client.fetch({
78
- body: "{}",
79
- headers: jsonContentHeaders,
80
- method: "POST",
81
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/enable`
82
- }, unmarshalHub);
83
- /**
84
- * Disable a hub. Disable an existing IoT Hub, specified by its Hub ID.
85
- *
86
- * @param request - The request {@link DisableHubRequest}
87
- * @returns A Promise of Hub
88
- */
89
- disableHub = (request) => this.client.fetch({
90
- body: "{}",
91
- headers: jsonContentHeaders,
92
- method: "POST",
93
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/disable`
94
- }, unmarshalHub);
95
- /**
96
- * Delete a hub. Delete an existing IoT Hub, specified by its Hub ID. Deleting a Hub is permanent, and cannot be undone.
97
- *
98
- * @param request - The request {@link DeleteHubRequest}
99
- */
100
- deleteHub = (request) => this.client.fetch({
101
- method: "DELETE",
102
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`,
103
- urlParams: urlParams(["delete_devices", request.deleteDevices])
104
- });
105
- /**
106
- * Get a hub's metrics. Get the metrics of an existing IoT Hub, specified by its Hub ID.
107
- *
108
- * @deprecated
109
- * @param request - The request {@link GetHubMetricsRequest}
110
- * @returns A Promise of GetHubMetricsResponse
111
- */
112
- getHubMetrics = (request) => this.client.fetch({
113
- method: "GET",
114
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/metrics`,
115
- urlParams: urlParams(["start_date", request.startDate])
116
- }, unmarshalGetHubMetricsResponse);
117
- /**
118
- * Set the certificate authority of a hub. Set a particular PEM-encoded certificate, specified by the Hub ID.
119
- *
120
- * @param request - The request {@link SetHubCARequest}
121
- * @returns A Promise of Hub
122
- */
123
- setHubCA = (request) => this.client.fetch({
124
- body: JSON.stringify(marshalSetHubCARequest(request, this.client.settings)),
125
- headers: jsonContentHeaders,
126
- method: "POST",
127
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/ca`
128
- }, unmarshalHub);
129
- /**
130
- * Get the certificate authority of a hub. Get information for a particular PEM-encoded certificate, specified by the Hub ID.
131
- *
132
- * @param request - The request {@link GetHubCARequest}
133
- * @returns A Promise of GetHubCAResponse
134
- */
135
- getHubCA = (request) => this.client.fetch({
136
- method: "GET",
137
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/ca`
138
- }, unmarshalGetHubCAResponse);
139
- pageOfListDevices = (request = {}) => this.client.fetch({
140
- method: "GET",
141
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`,
142
- urlParams: urlParams(["allow_insecure", request.allowInsecure], ["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["status", request.status])
143
- }, unmarshalListDevicesResponse);
144
- /**
145
- * 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.
146
- *
147
- * @param request - The request {@link ListDevicesRequest}
148
- * @returns A Promise of ListDevicesResponse
149
- */
150
- listDevices = (request = {}) => enrichForPagination("devices", this.pageOfListDevices, request);
151
- /**
152
- * Add a device. Attach a device to a given Hub.
153
- *
154
- * @param request - The request {@link CreateDeviceRequest}
155
- * @returns A Promise of CreateDeviceResponse
156
- */
157
- createDevice = (request) => this.client.fetch({
158
- body: JSON.stringify(marshalCreateDeviceRequest(request, this.client.settings)),
159
- headers: jsonContentHeaders,
160
- method: "POST",
161
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`
162
- }, unmarshalCreateDeviceResponse);
163
- /**
164
- * 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.
165
- *
166
- * @param request - The request {@link GetDeviceRequest}
167
- * @returns A Promise of Device
168
- */
169
- getDevice = (request) => this.client.fetch({
170
- method: "GET",
171
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
172
- }, unmarshalDevice);
173
- /**
174
- * Update a device. Update the parameters of an existing device, specified by its device ID.
175
- *
176
- * @param request - The request {@link UpdateDeviceRequest}
177
- * @returns A Promise of Device
178
- */
179
- updateDevice = (request) => this.client.fetch({
180
- body: JSON.stringify(marshalUpdateDeviceRequest(request, this.client.settings)),
181
- headers: jsonContentHeaders,
182
- method: "PATCH",
183
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
184
- }, unmarshalDevice);
185
- /**
186
- * Enable a device. Enable a specific device, specified by its device ID.
187
- *
188
- * @param request - The request {@link EnableDeviceRequest}
189
- * @returns A Promise of Device
190
- */
191
- enableDevice = (request) => this.client.fetch({
192
- body: "{}",
193
- headers: jsonContentHeaders,
194
- method: "POST",
195
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/enable`
196
- }, unmarshalDevice);
197
- /**
198
- * Disable a device. Disable an existing device, specified by its device ID.
199
- *
200
- * @param request - The request {@link DisableDeviceRequest}
201
- * @returns A Promise of Device
202
- */
203
- disableDevice = (request) => this.client.fetch({
204
- body: "{}",
205
- headers: jsonContentHeaders,
206
- method: "POST",
207
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/disable`
208
- }, unmarshalDevice);
209
- /**
210
- * Renew a device certificate. Renew the certificate of an existing device, specified by its device ID.
211
- *
212
- * @param request - The request {@link RenewDeviceCertificateRequest}
213
- * @returns A Promise of RenewDeviceCertificateResponse
214
- */
215
- renewDeviceCertificate = (request) => this.client.fetch({
216
- body: "{}",
217
- headers: jsonContentHeaders,
218
- method: "POST",
219
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/renew-certificate`
220
- }, unmarshalRenewDeviceCertificateResponse);
221
- /**
222
- * Set a custom certificate on a device. Switch the existing certificate of a given device with an EM-encoded custom certificate.
223
- *
224
- * @param request - The request {@link SetDeviceCertificateRequest}
225
- * @returns A Promise of SetDeviceCertificateResponse
226
- */
227
- setDeviceCertificate = (request) => this.client.fetch({
228
- body: JSON.stringify(marshalSetDeviceCertificateRequest(request, this.client.settings)),
229
- headers: jsonContentHeaders,
230
- method: "PUT",
231
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/certificate`
232
- }, unmarshalSetDeviceCertificateResponse);
233
- /**
234
- * 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.
235
- *
236
- * @param request - The request {@link GetDeviceCertificateRequest}
237
- * @returns A Promise of GetDeviceCertificateResponse
238
- */
239
- getDeviceCertificate = (request) => this.client.fetch({
240
- method: "GET",
241
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/certificate`
242
- }, unmarshalGetDeviceCertificateResponse);
243
- /**
244
- * Remove a device. Remove a specific device from the specific Hub it is attached to.
245
- *
246
- * @param request - The request {@link DeleteDeviceRequest}
247
- */
248
- deleteDevice = (request) => this.client.fetch({
249
- method: "DELETE",
250
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
251
- });
252
- /**
253
- * Get a device's metrics. Get the metrics of an existing device, specified by its device ID.
254
- *
255
- * @deprecated
256
- * @param request - The request {@link GetDeviceMetricsRequest}
257
- * @returns A Promise of GetDeviceMetricsResponse
258
- */
259
- getDeviceMetrics = (request) => this.client.fetch({
260
- method: "GET",
261
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/metrics`,
262
- urlParams: urlParams(["start_date", request.startDate])
263
- }, unmarshalGetDeviceMetricsResponse);
264
- pageOfListRoutes = (request = {}) => this.client.fetch({
265
- method: "GET",
266
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`,
267
- urlParams: urlParams(["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
268
- }, unmarshalListRoutesResponse);
269
- /**
270
- * 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.
271
- *
272
- * @param request - The request {@link ListRoutesRequest}
273
- * @returns A Promise of ListRoutesResponse
274
- */
275
- listRoutes = (request = {}) => enrichForPagination("routes", this.pageOfListRoutes, request);
276
- /**
277
- * Create a route. Multiple kinds of routes can be created, such as:
278
- - Database Route
279
- Create a route that will record subscribed MQTT messages into your database.
280
- <b>You need to manage the database by yourself</b>.
281
- - REST Route.
282
- Create a route that will call a REST API on received subscribed MQTT messages.
283
- - Amazon S3 Routes.
284
- Create a route that will put subscribed MQTT messages into an Object Storage bucket.
285
- You need to create the bucket yourself and grant write access.
286
- Granting can be done with s3cmd (`s3cmd setacl s3://<my-bucket> --acl-grant=write:555c69c3-87d0-4bf8-80f1-99a2f757d031:555c69c3-87d0-4bf8-80f1-99a2f757d031`).
287
- *
288
- * @param request - The request {@link CreateRouteRequest}
289
- * @returns A Promise of Route
290
- */
291
- createRoute = (request) => this.client.fetch({
292
- body: JSON.stringify(marshalCreateRouteRequest(request, this.client.settings)),
293
- headers: jsonContentHeaders,
294
- method: "POST",
295
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`
296
- }, unmarshalRoute);
297
- /**
298
- * Update a route. Update the parameters of an existing route, specified by its route ID.
299
- *
300
- * @param request - The request {@link UpdateRouteRequest}
301
- * @returns A Promise of Route
302
- */
303
- updateRoute = (request) => this.client.fetch({
304
- body: JSON.stringify(marshalUpdateRouteRequest(request, this.client.settings)),
305
- headers: jsonContentHeaders,
306
- method: "PATCH",
307
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
308
- }, unmarshalRoute);
309
- /**
310
- * 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.
311
- *
312
- * @param request - The request {@link GetRouteRequest}
313
- * @returns A Promise of Route
314
- */
315
- getRoute = (request) => this.client.fetch({
316
- method: "GET",
317
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
318
- }, unmarshalRoute);
319
- /**
320
- * Delete a route. Delete an existing route, specified by its route ID. Deleting a route is permanent, and cannot be undone.
321
- *
322
- * @param request - The request {@link DeleteRouteRequest}
323
- */
324
- deleteRoute = (request) => this.client.fetch({
325
- method: "DELETE",
326
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
327
- });
328
- pageOfListNetworks = (request = {}) => this.client.fetch({
329
- method: "GET",
330
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`,
331
- urlParams: urlParams(["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["topic_prefix", request.topicPrefix])
332
- }, unmarshalListNetworksResponse);
333
- /**
334
- * List the networks.
335
- *
336
- * @param request - The request {@link ListNetworksRequest}
337
- * @returns A Promise of ListNetworksResponse
338
- */
339
- listNetworks = (request = {}) => enrichForPagination("networks", this.pageOfListNetworks, request);
340
- /**
341
- * 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.
342
- *
343
- * @param request - The request {@link CreateNetworkRequest}
344
- * @returns A Promise of CreateNetworkResponse
345
- */
346
- createNetwork = (request) => this.client.fetch({
347
- body: JSON.stringify(marshalCreateNetworkRequest(request, this.client.settings)),
348
- headers: jsonContentHeaders,
349
- method: "POST",
350
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`
351
- }, unmarshalCreateNetworkResponse);
352
- /**
353
- * 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.
354
- *
355
- * @param request - The request {@link GetNetworkRequest}
356
- * @returns A Promise of Network
357
- */
358
- getNetwork = (request) => this.client.fetch({
359
- method: "GET",
360
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${validatePathParam("networkId", request.networkId)}`
361
- }, unmarshalNetwork);
362
- /**
363
- * Delete a Network. Delete an existing network, specified by its network ID. Deleting a network is permanent, and cannot be undone.
364
- *
365
- * @param request - The request {@link DeleteNetworkRequest}
366
- */
367
- deleteNetwork = (request) => this.client.fetch({
368
- method: "DELETE",
369
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${validatePathParam("networkId", request.networkId)}`
370
- });
371
- /**
372
- * BETA - Get a Cloud Twin Document.
373
- *
374
- * @param request - The request {@link GetTwinDocumentRequest}
375
- * @returns A Promise of TwinDocument
376
- */
377
- getTwinDocument = (request) => this.client.fetch({
378
- method: "GET",
379
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
380
- }, unmarshalTwinDocument);
381
- /**
382
- * BETA - Update a Cloud Twin Document.
383
- *
384
- * @param request - The request {@link PutTwinDocumentRequest}
385
- * @returns A Promise of TwinDocument
386
- */
387
- putTwinDocument = (request) => this.client.fetch({
388
- body: JSON.stringify(marshalPutTwinDocumentRequest(request, this.client.settings)),
389
- headers: jsonContentHeaders,
390
- method: "PUT",
391
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
392
- }, unmarshalTwinDocument);
393
- /**
394
- * BETA - Patch a Cloud Twin Document.
395
- *
396
- * @param request - The request {@link PatchTwinDocumentRequest}
397
- * @returns A Promise of TwinDocument
398
- */
399
- patchTwinDocument = (request) => this.client.fetch({
400
- body: JSON.stringify(marshalPatchTwinDocumentRequest(request, this.client.settings)),
401
- headers: jsonContentHeaders,
402
- method: "PATCH",
403
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
404
- }, unmarshalTwinDocument);
405
- /**
406
- * BETA - Delete a Cloud Twin Document.
407
- *
408
- * @param request - The request {@link DeleteTwinDocumentRequest}
409
- */
410
- deleteTwinDocument = (request) => this.client.fetch({
411
- method: "DELETE",
412
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
413
- });
414
- /**
415
- * BETA - List the documents of a Cloud Twin.
416
- *
417
- * @param request - The request {@link ListTwinDocumentsRequest}
418
- * @returns A Promise of ListTwinDocumentsResponse
419
- */
420
- listTwinDocuments = (request) => this.client.fetch({
421
- method: "GET",
422
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}`
423
- }, unmarshalListTwinDocumentsResponse);
424
- /**
425
- * BETA - Delete all the documents of a Cloud Twin.
426
- *
427
- * @param request - The request {@link DeleteTwinDocumentsRequest}
428
- */
429
- deleteTwinDocuments = (request) => this.client.fetch({
430
- method: "DELETE",
431
- path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}`
432
- });
12
+ constructor(..._args) {
13
+ super(..._args);
14
+ this.pageOfListHubs = (request = {}) => this.client.fetch({
15
+ method: "GET",
16
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`,
17
+ urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
18
+ }, unmarshalListHubsResponse);
19
+ this.listHubs = (request = {}) => enrichForPagination("hubs", this.pageOfListHubs, request);
20
+ this.createHub = (request) => this.client.fetch({
21
+ body: JSON.stringify(marshalCreateHubRequest(request, this.client.settings)),
22
+ headers: jsonContentHeaders,
23
+ method: "POST",
24
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs`
25
+ }, unmarshalHub);
26
+ this.getHub = (request) => this.client.fetch({
27
+ method: "GET",
28
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`
29
+ }, unmarshalHub);
30
+ this.waitForHub = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!HUB_TRANSIENT_STATUSES.includes(res.status))), this.getHub, request, options);
31
+ this.updateHub = (request) => this.client.fetch({
32
+ body: JSON.stringify(marshalUpdateHubRequest(request, this.client.settings)),
33
+ headers: jsonContentHeaders,
34
+ method: "PATCH",
35
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`
36
+ }, unmarshalHub);
37
+ this.enableHub = (request) => this.client.fetch({
38
+ body: "{}",
39
+ headers: jsonContentHeaders,
40
+ method: "POST",
41
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/enable`
42
+ }, unmarshalHub);
43
+ this.disableHub = (request) => this.client.fetch({
44
+ body: "{}",
45
+ headers: jsonContentHeaders,
46
+ method: "POST",
47
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/disable`
48
+ }, unmarshalHub);
49
+ this.deleteHub = (request) => this.client.fetch({
50
+ method: "DELETE",
51
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}`,
52
+ urlParams: urlParams(["delete_devices", request.deleteDevices])
53
+ });
54
+ this.getHubMetrics = (request) => this.client.fetch({
55
+ method: "GET",
56
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/metrics`,
57
+ urlParams: urlParams(["start_date", request.startDate])
58
+ }, unmarshalGetHubMetricsResponse);
59
+ this.setHubCA = (request) => this.client.fetch({
60
+ body: JSON.stringify(marshalSetHubCARequest(request, this.client.settings)),
61
+ headers: jsonContentHeaders,
62
+ method: "POST",
63
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/ca`
64
+ }, unmarshalHub);
65
+ this.getHubCA = (request) => this.client.fetch({
66
+ method: "GET",
67
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hubs/${validatePathParam("hubId", request.hubId)}/ca`
68
+ }, unmarshalGetHubCAResponse);
69
+ this.pageOfListDevices = (request = {}) => this.client.fetch({
70
+ method: "GET",
71
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`,
72
+ urlParams: urlParams(["allow_insecure", request.allowInsecure], ["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["status", request.status])
73
+ }, unmarshalListDevicesResponse);
74
+ this.listDevices = (request = {}) => enrichForPagination("devices", this.pageOfListDevices, request);
75
+ this.createDevice = (request) => this.client.fetch({
76
+ body: JSON.stringify(marshalCreateDeviceRequest(request, this.client.settings)),
77
+ headers: jsonContentHeaders,
78
+ method: "POST",
79
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices`
80
+ }, unmarshalCreateDeviceResponse);
81
+ this.getDevice = (request) => this.client.fetch({
82
+ method: "GET",
83
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
84
+ }, unmarshalDevice);
85
+ this.updateDevice = (request) => this.client.fetch({
86
+ body: JSON.stringify(marshalUpdateDeviceRequest(request, this.client.settings)),
87
+ headers: jsonContentHeaders,
88
+ method: "PATCH",
89
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
90
+ }, unmarshalDevice);
91
+ this.enableDevice = (request) => this.client.fetch({
92
+ body: "{}",
93
+ headers: jsonContentHeaders,
94
+ method: "POST",
95
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/enable`
96
+ }, unmarshalDevice);
97
+ this.disableDevice = (request) => this.client.fetch({
98
+ body: "{}",
99
+ headers: jsonContentHeaders,
100
+ method: "POST",
101
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/disable`
102
+ }, unmarshalDevice);
103
+ this.renewDeviceCertificate = (request) => this.client.fetch({
104
+ body: "{}",
105
+ headers: jsonContentHeaders,
106
+ method: "POST",
107
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/renew-certificate`
108
+ }, unmarshalRenewDeviceCertificateResponse);
109
+ this.setDeviceCertificate = (request) => this.client.fetch({
110
+ body: JSON.stringify(marshalSetDeviceCertificateRequest(request, this.client.settings)),
111
+ headers: jsonContentHeaders,
112
+ method: "PUT",
113
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/certificate`
114
+ }, unmarshalSetDeviceCertificateResponse);
115
+ this.getDeviceCertificate = (request) => this.client.fetch({
116
+ method: "GET",
117
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/certificate`
118
+ }, unmarshalGetDeviceCertificateResponse);
119
+ this.deleteDevice = (request) => this.client.fetch({
120
+ method: "DELETE",
121
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}`
122
+ });
123
+ this.getDeviceMetrics = (request) => this.client.fetch({
124
+ method: "GET",
125
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/devices/${validatePathParam("deviceId", request.deviceId)}/metrics`,
126
+ urlParams: urlParams(["start_date", request.startDate])
127
+ }, unmarshalGetDeviceMetricsResponse);
128
+ this.pageOfListRoutes = (request = {}) => this.client.fetch({
129
+ method: "GET",
130
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`,
131
+ urlParams: urlParams(["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
132
+ }, unmarshalListRoutesResponse);
133
+ this.listRoutes = (request = {}) => enrichForPagination("routes", this.pageOfListRoutes, request);
134
+ this.createRoute = (request) => this.client.fetch({
135
+ body: JSON.stringify(marshalCreateRouteRequest(request, this.client.settings)),
136
+ headers: jsonContentHeaders,
137
+ method: "POST",
138
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes`
139
+ }, unmarshalRoute);
140
+ this.updateRoute = (request) => this.client.fetch({
141
+ body: JSON.stringify(marshalUpdateRouteRequest(request, this.client.settings)),
142
+ headers: jsonContentHeaders,
143
+ method: "PATCH",
144
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
145
+ }, unmarshalRoute);
146
+ this.getRoute = (request) => this.client.fetch({
147
+ method: "GET",
148
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
149
+ }, unmarshalRoute);
150
+ this.deleteRoute = (request) => this.client.fetch({
151
+ method: "DELETE",
152
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam("routeId", request.routeId)}`
153
+ });
154
+ this.pageOfListNetworks = (request = {}) => this.client.fetch({
155
+ method: "GET",
156
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`,
157
+ urlParams: urlParams(["hub_id", request.hubId], ["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["topic_prefix", request.topicPrefix])
158
+ }, unmarshalListNetworksResponse);
159
+ this.listNetworks = (request = {}) => enrichForPagination("networks", this.pageOfListNetworks, request);
160
+ this.createNetwork = (request) => this.client.fetch({
161
+ body: JSON.stringify(marshalCreateNetworkRequest(request, this.client.settings)),
162
+ headers: jsonContentHeaders,
163
+ method: "POST",
164
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks`
165
+ }, unmarshalCreateNetworkResponse);
166
+ this.getNetwork = (request) => this.client.fetch({
167
+ method: "GET",
168
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${validatePathParam("networkId", request.networkId)}`
169
+ }, unmarshalNetwork);
170
+ this.deleteNetwork = (request) => this.client.fetch({
171
+ method: "DELETE",
172
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/networks/${validatePathParam("networkId", request.networkId)}`
173
+ });
174
+ this.getTwinDocument = (request) => this.client.fetch({
175
+ method: "GET",
176
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
177
+ }, unmarshalTwinDocument);
178
+ this.putTwinDocument = (request) => this.client.fetch({
179
+ body: JSON.stringify(marshalPutTwinDocumentRequest(request, this.client.settings)),
180
+ headers: jsonContentHeaders,
181
+ method: "PUT",
182
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
183
+ }, unmarshalTwinDocument);
184
+ this.patchTwinDocument = (request) => this.client.fetch({
185
+ body: JSON.stringify(marshalPatchTwinDocumentRequest(request, this.client.settings)),
186
+ headers: jsonContentHeaders,
187
+ method: "PATCH",
188
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
189
+ }, unmarshalTwinDocument);
190
+ this.deleteTwinDocument = (request) => this.client.fetch({
191
+ method: "DELETE",
192
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}/documents/${validatePathParam("documentName", request.documentName)}`
193
+ });
194
+ this.listTwinDocuments = (request) => this.client.fetch({
195
+ method: "GET",
196
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}`
197
+ }, unmarshalListTwinDocumentsResponse);
198
+ this.deleteTwinDocuments = (request) => this.client.fetch({
199
+ method: "DELETE",
200
+ path: `/iot/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/twins/${validatePathParam("twinId", request.twinId)}`
201
+ });
202
+ }
203
+ static {
204
+ this.LOCALITY = toApiLocality({ regions: ["fr-par"] });
205
+ }
433
206
  };
434
207
  //#endregion
435
208
  export { API };