@wiotp/sdk 0.4.2 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +203 -203
  2. package/README.md +68 -68
  3. package/dist/BaseClient.js +259 -0
  4. package/dist/BaseConfig.js +194 -0
  5. package/dist/api/ApiClient.js +508 -0
  6. package/dist/api/ApiErrors.js +118 -0
  7. package/dist/api/DscClient.js +332 -0
  8. package/dist/api/LecClient.js +48 -0
  9. package/dist/api/MgmtClient.js +77 -0
  10. package/dist/api/RegistryClient.js +234 -0
  11. package/dist/api/RulesClient.js +105 -0
  12. package/dist/api/StateClient.js +738 -0
  13. package/dist/application/ApplicationClient.js +436 -0
  14. package/dist/application/ApplicationConfig.js +233 -0
  15. package/dist/application/index.js +23 -0
  16. package/dist/bundled/wiotp-bundle.js +35592 -0
  17. package/dist/bundled/wiotp-bundle.min.js +47 -0
  18. package/dist/device/DeviceClient.js +125 -0
  19. package/dist/device/DeviceConfig.js +216 -0
  20. package/dist/device/index.js +23 -0
  21. package/dist/gateway/GatewayClient.js +159 -0
  22. package/dist/gateway/GatewayConfig.js +52 -0
  23. package/dist/gateway/index.js +23 -0
  24. package/dist/index.js +55 -0
  25. package/dist/util.js +50 -0
  26. package/package.json +92 -84
  27. package/src/BaseClient.js +215 -215
  28. package/src/BaseConfig.js +157 -157
  29. package/src/api/ApiClient.js +454 -454
  30. package/src/api/ApiErrors.js +33 -33
  31. package/src/api/DscClient.js +164 -145
  32. package/src/api/LecClient.js +32 -32
  33. package/src/api/MgmtClient.js +57 -57
  34. package/src/api/RegistryClient.js +194 -194
  35. package/src/api/RulesClient.js +84 -84
  36. package/src/api/StateClient.js +650 -650
  37. package/src/application/ApplicationClient.js +348 -348
  38. package/src/application/ApplicationConfig.js +191 -191
  39. package/src/application/index.js +12 -12
  40. package/src/device/DeviceClient.js +78 -78
  41. package/src/device/DeviceConfig.js +175 -175
  42. package/src/device/index.js +14 -14
  43. package/src/gateway/GatewayClient.js +114 -114
  44. package/src/gateway/GatewayConfig.js +21 -21
  45. package/src/gateway/index.js +13 -13
  46. package/{index.js → src/index.js} +19 -19
  47. package/src/util.js +38 -38
  48. package/src/util/IoTFoundation.pem +0 -82
@@ -1,34 +1,34 @@
1
-
2
- export class WiotpError extends Error {
3
- constructor(message, cause) {
4
- super(message);
5
- this.cause = cause;
6
- this.name = this.constructor.name;
7
- }
8
- }
9
-
10
- export class InvalidServiceCredentials extends WiotpError {}
11
-
12
- export class DestinationAlreadyExists extends WiotpError {}
13
-
14
- export class ServiceNotFound extends WiotpError {}
15
-
16
-
17
- export const handleError = (err, errorMappings) => {
18
- if(err && err.response && err.response.data && err.response.data.exception && err.response.data.exception.id) {
19
- if(errorMappings && errorMappings[err.response.data.exception.id]) {
20
- throw new errorMappings[err.response.data.exception.id](err.response.data.message, err);
21
- } else {
22
- throw new WiotpError(err.response.data.message, err);
23
- }
24
- } else {
25
- throw err;
26
- }
27
- }
28
-
29
- export default {
30
- WiotpError,
31
- InvalidServiceCredentials,
32
- DestinationAlreadyExists,
33
- ServiceNotFound,
1
+
2
+ export class WiotpError extends Error {
3
+ constructor(message, cause) {
4
+ super(message);
5
+ this.cause = cause;
6
+ this.name = this.constructor.name;
7
+ }
8
+ }
9
+
10
+ export class InvalidServiceCredentials extends WiotpError {}
11
+
12
+ export class DestinationAlreadyExists extends WiotpError {}
13
+
14
+ export class ServiceNotFound extends WiotpError {}
15
+
16
+
17
+ export const handleError = (err, errorMappings) => {
18
+ if(err && err.response && err.response.data && err.response.data.exception && err.response.data.exception.id) {
19
+ if(errorMappings && errorMappings[err.response.data.exception.id]) {
20
+ throw new errorMappings[err.response.data.exception.id](err.response.data.message, err);
21
+ } else {
22
+ throw new WiotpError(err.response.data.message, err);
23
+ }
24
+ } else {
25
+ throw err;
26
+ }
27
+ }
28
+
29
+ export default {
30
+ WiotpError,
31
+ InvalidServiceCredentials,
32
+ DestinationAlreadyExists,
33
+ ServiceNotFound,
34
34
  }
@@ -1,146 +1,165 @@
1
- /**
2
- *****************************************************************************
3
- Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
- All rights reserved. This program and the accompanying materials
5
- are made available under the terms of the Eclipse Public License v1.0
6
- which accompanies this distribution, and is available at
7
- http://www.eclipse.org/legal/epl-v10.html
8
- *****************************************************************************
9
- *
10
- */
11
- import log from 'loglevel';
12
-
13
- import * as errors from './ApiErrors';
14
-
15
-
16
- export default class DscClient {
17
- constructor(apiClient) {
18
- this.log = log;
19
-
20
- // callApi(method, expectedHttpCode, expectJsonContent, paths, body, params) {
21
- this.apiClient = apiClient;
22
- }
23
-
24
-
25
-
26
- /**************************************
27
- ** Services
28
- **************************************/
29
-
30
- // {name, description, type, credentials}
31
- createService(service) {
32
- return this.apiClient.callApi('POST', 201, true, ['s2s', 'services'], service)
33
- .catch(err => errors.handleError(err, {CUDSS0026E: errors.InvalidServiceCredentials}));
34
- }
35
-
36
-
37
- createCloudantService({name, description, username, password, host=`${username}.cloudant.com`, port=443, url=`https://${username}:${password}@${host}`}) {
38
- return this.createService({name, description, type: 'cloudant', credentials: {username, password, host, port, url}})
39
- }
40
-
41
- createEventstreamsService({name, description, apiKey, adminUrl, brokers, user, password}) {
42
- return this.createService({name, description, type: 'eventstreams', credentials: {api_key: apiKey, kafka_admin_url: adminUrl, kafka_brokers_sasl: brokers, user, password}})
43
- }
44
-
45
- getService(serviceId) {
46
- return this.apiClient.callApi('GET', 200, true, ['s2s', 'services', serviceId])
47
- .catch(err => errors.handleError(err, {CUDSS0019E: errors.ServiceNotFound}));
48
- }
49
-
50
- getServices(serviceType) {
51
- return this.apiClient.callApi('GET', 200, true, ['s2s', 'services'], null, { bindingMode:'manual', serviceType })
52
- .catch(err => errors.handleError(err, {}));
53
- }
54
-
55
-
56
- deleteService(serviceId) {
57
- return this.apiClient.callApi('DELETE', 204, false, ['s2s', 'services', serviceId])
58
- .catch(err => errors.handleError(err, {}));
59
- }
60
-
61
-
62
- /**************************************
63
- ** Historian Connectors
64
- **************************************/
65
-
66
- // {name, description, serviceId, timezone, enabled}
67
- createConnector({name, type, description=undefined, serviceId, timezone='UTC', enabled=true}) {
68
- return this.apiClient.callApi('POST', 201, true, ['historianconnectors'], {name, description, type, serviceId, timezone, enabled})
69
- .catch(err => errors.handleError(err, {}));
70
- }
71
-
72
- getConnectors({name, serviceType, enabled, serviceId}) {
73
- return this.apiClient.callApi('GET', 200, true, ['historianconnectors'], null, {
74
- name: name ? name : undefined,
75
- type: serviceType ? serviceType : undefined,
76
- enabled: enabled === undefined ? undefined : enabled,
77
- serviceId: serviceId ? serviceId : undefined,
78
- })
79
- .catch(err => errors.handleError(err, {}));
80
- }
81
-
82
- deleteConnector(connectorId) {
83
- return this.apiClient.callApi('DELETE', 204, false, ['historianconnectors', connectorId])
84
- .catch(err => errors.handleError(err, {}));
85
- }
86
-
87
-
88
- /**************************************
89
- ** Destinations
90
- **************************************/
91
- // {name, type, configuration}
92
- createDestination(connectorId, destination) {
93
- return this.apiClient.callApi('POST', 201, true, ['historianconnectors', connectorId, 'destinations'], destination)
94
- .catch(err => errors.handleError(err, {CUDDSC0103E: errors.DestinationAlreadyExists}));
95
- }
96
-
97
- createCloudantDestination(connectorId, {name, bucketInterval}) {
98
- return this.createDestination(connectorId, {name, type: 'cloudant', configuration: { bucketInterval }});
99
- }
100
-
101
- createEventstreamsDestination(connectorId, {name, partitions=1}) {
102
- return this.createDestination(connectorId, {name, type: 'eventstreams', configuration: { partitions }});
103
- }
104
-
105
- getDestinations(connectorId, params={name:undefined}) {
106
- const {name} = params;
107
- return this.apiClient.callApi('GET', 200, true, ['historianconnectors', connectorId, 'destinations'], null, {
108
- name: name ? name : undefined,
109
- })
110
- .catch(err => errors.handleError(err, {}));
111
- }
112
-
113
- deleteDestination(connectorId, destinationName) {
114
- return this.apiClient.callApi('DELETE', [200, 204], false, ['historianconnectors', connectorId, 'destinations', destinationName])
115
- .catch(err => errors.handleError(err, {}));
116
- }
117
-
118
-
119
- /**************************************
120
- ** Forwarding Rules
121
- **************************************/
122
-
123
- // {name, destinationName, type:event, selector: {deviceType, eventId}}
124
- // {name, destinationName, type:state, selector: {logicalInterfaceId}}
125
- createForwardingRule(connectorId, forwardingrule) {
126
- return this.apiClient.callApi('POST', 201, true, ['historianconnectors', connectorId, 'forwardingrules'], forwardingrule)
127
- .catch(err => errors.handleError(err, {}));
128
- }
129
-
130
- createEventForwardingRule(connectorId, {name, destinationName, deviceType='*', eventId='*'}) {
131
- return this.createForwardingRule(connectorId, {name, destinationName, type: 'event', selector: {deviceType, eventId}})
132
- }
133
-
134
- getForwardingRules(connectorId) {
135
- // TODO: QS params
136
- return this.apiClient.callApi('GET', 200, true, ['historianconnectors', connectorId, 'forwardingrules'])
137
- .catch(err => errors.handleError(err, {}));
138
- }
139
-
140
- deleteForwardingRule(connectorId, forwardingRuleId) {
141
- return this.apiClient.callApi('DELETE', 204, false, ['historianconnectors', connectorId, 'forwardingrules', forwardingRuleId])
142
- .catch(err => errors.handleError(err, {}));
143
- }
144
-
145
-
1
+ /**
2
+ *****************************************************************************
3
+ Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
+ All rights reserved. This program and the accompanying materials
5
+ are made available under the terms of the Eclipse Public License v1.0
6
+ which accompanies this distribution, and is available at
7
+ http://www.eclipse.org/legal/epl-v10.html
8
+ *****************************************************************************
9
+ *
10
+ */
11
+ import log from 'loglevel';
12
+
13
+ import * as errors from './ApiErrors';
14
+
15
+
16
+ export default class DscClient {
17
+ constructor(apiClient) {
18
+ this.log = log;
19
+
20
+ // callApi(method, expectedHttpCode, expectJsonContent, paths, body, params) {
21
+ this.apiClient = apiClient;
22
+ }
23
+
24
+
25
+
26
+ /**************************************
27
+ ** Services
28
+ **************************************/
29
+
30
+ // {name, description, type, credentials}
31
+ createService(service) {
32
+ return this.apiClient.callApi('POST', 201, true, ['s2s', 'services'], service)
33
+ .catch(err => errors.handleError(err, {CUDSS0026E: errors.InvalidServiceCredentials}));
34
+ }
35
+
36
+
37
+ createCloudantService({
38
+ name, description,
39
+ username, password, host=`${username}.cloudant.com`, port=443, url=`https://${username}:${password}@${host}`,
40
+ apikey, iam_apikey_name, iam_apikey_description, iam_role_crn, iam_serviceid_crn
41
+ }) {
42
+ return this.createService({name, description, type: 'cloudant', credentials: {
43
+ username, password, host, port, url,
44
+ apikey, iam_apikey_name, iam_apikey_description, iam_role_crn, iam_serviceid_crn
45
+ }})
46
+ }
47
+
48
+ createEventstreamsService({name, description,
49
+ api_key, kafka_admin_url, kafka_brokers_sasl, user, password,
50
+ apikey, iam_apikey_name, iam_apikey_description, iam_role_crn, iam_serviceid_crn
51
+ }) {
52
+ return this.createService({name, description, type: 'eventstreams', credentials: {
53
+ api_key, kafka_admin_url, kafka_brokers_sasl, user, password,
54
+ apikey, iam_apikey_name, iam_apikey_description, iam_role_crn, iam_serviceid_crn
55
+ }})
56
+ }
57
+
58
+ getService(serviceId) {
59
+ return this.apiClient.callApi('GET', 200, true, ['s2s', 'services', serviceId])
60
+ .catch(err => errors.handleError(err, {CUDSS0019E: errors.ServiceNotFound}));
61
+ }
62
+
63
+ getServices(serviceType) {
64
+ return this.apiClient.callApi('GET', 200, true, ['s2s', 'services'], null, { bindingMode:'manual', serviceType })
65
+ .catch(err => errors.handleError(err, {}));
66
+ }
67
+
68
+
69
+ deleteService(serviceId) {
70
+ return this.apiClient.callApi('DELETE', 204, false, ['s2s', 'services', serviceId])
71
+ .catch(err => errors.handleError(err, {}));
72
+ }
73
+
74
+
75
+ /**************************************
76
+ ** Historian Connectors
77
+ **************************************/
78
+
79
+ // {name, description, serviceId, timezone, enabled}
80
+ createConnector({name, type, description=undefined, serviceId, timezone='UTC', enabled=true}) {
81
+ return this.apiClient.callApi('POST', 201, true, ['historianconnectors'], {name, description, type, serviceId, timezone, enabled})
82
+ .catch(err => errors.handleError(err, {}));
83
+ }
84
+
85
+
86
+ updateConnector({id, name, description, serviceId, type, enabled, timezone}) {
87
+ return this.apiClient.callApi('PUT', 200, true, ['historianconnectors', id], {id, name, description, serviceId, type, enabled, timezone})
88
+ .catch(err => errors.handleError(err, {}));
89
+ }
90
+
91
+ getConnectors({name, serviceType, enabled, serviceId}) {
92
+ return this.apiClient.callApi('GET', 200, true, ['historianconnectors'], null, {
93
+ name: name ? name : undefined,
94
+ type: serviceType ? serviceType : undefined,
95
+ enabled: enabled === undefined ? undefined : enabled,
96
+ serviceId: serviceId ? serviceId : undefined,
97
+ })
98
+ .catch(err => errors.handleError(err, {}));
99
+ }
100
+
101
+ deleteConnector(connectorId) {
102
+ return this.apiClient.callApi('DELETE', 204, false, ['historianconnectors', connectorId])
103
+ .catch(err => errors.handleError(err, {}));
104
+ }
105
+
106
+
107
+ /**************************************
108
+ ** Destinations
109
+ **************************************/
110
+ // {name, type, configuration}
111
+ createDestination(connectorId, destination) {
112
+ return this.apiClient.callApi('POST', 201, true, ['historianconnectors', connectorId, 'destinations'], destination)
113
+ .catch(err => errors.handleError(err, {CUDDSC0103E: errors.DestinationAlreadyExists}));
114
+ }
115
+
116
+ createCloudantDestination(connectorId, {name, bucketInterval}) {
117
+ return this.createDestination(connectorId, {name, type: 'cloudant', configuration: { bucketInterval }});
118
+ }
119
+
120
+ createEventstreamsDestination(connectorId, {name, partitions=1}) {
121
+ return this.createDestination(connectorId, {name, type: 'eventstreams', configuration: { partitions }});
122
+ }
123
+
124
+ getDestinations(connectorId, params={name:undefined}) {
125
+ const {name} = params;
126
+ return this.apiClient.callApi('GET', 200, true, ['historianconnectors', connectorId, 'destinations'], null, {
127
+ name: name ? name : undefined,
128
+ })
129
+ .catch(err => errors.handleError(err, {}));
130
+ }
131
+
132
+ deleteDestination(connectorId, destinationName) {
133
+ return this.apiClient.callApi('DELETE', [200, 204], false, ['historianconnectors', connectorId, 'destinations', destinationName])
134
+ .catch(err => errors.handleError(err, {}));
135
+ }
136
+
137
+
138
+ /**************************************
139
+ ** Forwarding Rules
140
+ **************************************/
141
+
142
+ // {name, destinationName, type:event, selector: {deviceType, eventId}}
143
+ // {name, destinationName, type:state, selector: {logicalInterfaceId}}
144
+ createForwardingRule(connectorId, forwardingrule) {
145
+ return this.apiClient.callApi('POST', 201, true, ['historianconnectors', connectorId, 'forwardingrules'], forwardingrule)
146
+ .catch(err => errors.handleError(err, {}));
147
+ }
148
+
149
+ createEventForwardingRule(connectorId, {name, destinationName, deviceType='*', eventId='*'}) {
150
+ return this.createForwardingRule(connectorId, {name, destinationName, type: 'event', selector: {deviceType, eventId}})
151
+ }
152
+
153
+ getForwardingRules(connectorId) {
154
+ // TODO: QS params
155
+ return this.apiClient.callApi('GET', 200, true, ['historianconnectors', connectorId, 'forwardingrules'])
156
+ .catch(err => errors.handleError(err, {}));
157
+ }
158
+
159
+ deleteForwardingRule(connectorId, forwardingRuleId) {
160
+ return this.apiClient.callApi('DELETE', 204, false, ['historianconnectors', connectorId, 'forwardingrules', forwardingRuleId])
161
+ .catch(err => errors.handleError(err, {}));
162
+ }
163
+
164
+
146
165
  }
@@ -1,33 +1,33 @@
1
- /**
2
- *****************************************************************************
3
- Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
- All rights reserved. This program and the accompanying materials
5
- are made available under the terms of the Eclipse Public License v1.0
6
- which accompanies this distribution, and is available at
7
- http://www.eclipse.org/legal/epl-v10.html
8
- *****************************************************************************
9
- *
10
- */
11
- import log from 'loglevel';
12
-
13
- export default class LecClient {
14
- constructor(apiClient) {
15
- this.log = log;
16
-
17
- this.apiClient = apiClient;
18
-
19
- // Create an alias to the apiClient's callApi
20
- this.callApi = this.apiClient.callApi.bind(this.apiClient);
21
- }
22
-
23
- getLastEvents(type, id) {
24
- this.log.debug("[ApiClient] getLastEvents() - event cache");
25
- return this.callApi('GET', 200, true, ["device", "types", type, "devices", id, "events"], null);
26
- }
27
-
28
- getLastEventsByEventType(type, id, eventType) {
29
- this.log.debug("[ApiClient] getLastEventsByEventType() - event cache");
30
- return this.callApi('GET', 200, true, ["device", "types", type, "devices", id, "events", eventType], null);
31
- }
32
-
1
+ /**
2
+ *****************************************************************************
3
+ Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
+ All rights reserved. This program and the accompanying materials
5
+ are made available under the terms of the Eclipse Public License v1.0
6
+ which accompanies this distribution, and is available at
7
+ http://www.eclipse.org/legal/epl-v10.html
8
+ *****************************************************************************
9
+ *
10
+ */
11
+ import log from 'loglevel';
12
+
13
+ export default class LecClient {
14
+ constructor(apiClient) {
15
+ this.log = log;
16
+
17
+ this.apiClient = apiClient;
18
+
19
+ // Create an alias to the apiClient's callApi
20
+ this.callApi = this.apiClient.callApi.bind(this.apiClient);
21
+ }
22
+
23
+ getLastEvents(type, id) {
24
+ this.log.debug("[ApiClient] getLastEvents() - event cache");
25
+ return this.callApi('GET', 200, true, ["device", "types", type, "devices", id, "events"], null);
26
+ }
27
+
28
+ getLastEventsByEventType(type, id, eventType) {
29
+ this.log.debug("[ApiClient] getLastEventsByEventType() - event cache");
30
+ return this.callApi('GET', 200, true, ["device", "types", type, "devices", id, "events", eventType], null);
31
+ }
32
+
33
33
  };
@@ -1,58 +1,58 @@
1
- /**
2
- *****************************************************************************
3
- Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
- All rights reserved. This program and the accompanying materials
5
- are made available under the terms of the Eclipse Public License v1.0
6
- which accompanies this distribution, and is available at
7
- http://www.eclipse.org/legal/epl-v10.html
8
- *****************************************************************************
9
- *
10
- */
11
- import log from 'loglevel';
12
-
13
- export default class MgmtClient {
14
- constructor(apiClient) {
15
- this.log = log;
16
-
17
- this.apiClient = apiClient;
18
-
19
- // Create an alias to the apiClient's callApi
20
- this.callApi = this.apiClient.callApi.bind(this.apiClient);
21
- }
22
-
23
- getAllDeviceManagementRequests() {
24
- this.log.debug("[ApiClient] getAllDeviceManagementRequests()");
25
- return this.callApi('GET', 200, true, ['mgmt', 'requests'], null);
26
- }
27
-
28
- initiateDeviceManagementRequest(action, parameters, devices) {
29
- this.log.debug("[ApiClient] initiateDeviceManagementRequest(" + action + ", " + parameters + ", " + devices + ")");
30
- let body = {
31
- action: action,
32
- parameters: parameters,
33
- devices: devices
34
- };
35
- return this.callApi('POST', 202, true, ['mgmt', 'requests'], JSON.stringify(body));
36
- }
37
-
38
- getDeviceManagementRequest(requestId) {
39
- this.log.debug("[ApiClient] getDeviceManagementRequest(" + requestId + ")");
40
- return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId], null);
41
- }
42
-
43
- deleteDeviceManagementRequest(requestId) {
44
- this.log.debug("[ApiClient] deleteDeviceManagementRequest(" + requestId + ")");
45
- return this.callApi('DELETE', 204, false, ['mgmt', 'requests', requestId], null);
46
- }
47
-
48
- getDeviceManagementRequestStatus(requestId) {
49
- this.log.debug("[ApiClient] getDeviceManagementRequestStatus(" + requestId + ")");
50
- return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId, 'deviceStatus'], null);
51
- }
52
-
53
- getDeviceManagementRequestStatusByDevice(requestId, typeId, deviceId) {
54
- this.log.debug("[ApiClient] getDeviceManagementRequestStatusByDevice(" + requestId + ", " + typeId + ", " + deviceId + ")");
55
- return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId, 'deviceStatus', typeId, deviceId], null);
56
- }
57
-
1
+ /**
2
+ *****************************************************************************
3
+ Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
4
+ All rights reserved. This program and the accompanying materials
5
+ are made available under the terms of the Eclipse Public License v1.0
6
+ which accompanies this distribution, and is available at
7
+ http://www.eclipse.org/legal/epl-v10.html
8
+ *****************************************************************************
9
+ *
10
+ */
11
+ import log from 'loglevel';
12
+
13
+ export default class MgmtClient {
14
+ constructor(apiClient) {
15
+ this.log = log;
16
+
17
+ this.apiClient = apiClient;
18
+
19
+ // Create an alias to the apiClient's callApi
20
+ this.callApi = this.apiClient.callApi.bind(this.apiClient);
21
+ }
22
+
23
+ getAllDeviceManagementRequests() {
24
+ this.log.debug("[ApiClient] getAllDeviceManagementRequests()");
25
+ return this.callApi('GET', 200, true, ['mgmt', 'requests'], null);
26
+ }
27
+
28
+ initiateDeviceManagementRequest(action, parameters, devices) {
29
+ this.log.debug("[ApiClient] initiateDeviceManagementRequest(" + action + ", " + parameters + ", " + devices + ")");
30
+ let body = {
31
+ action: action,
32
+ parameters: parameters,
33
+ devices: devices
34
+ };
35
+ return this.callApi('POST', 202, true, ['mgmt', 'requests'], JSON.stringify(body));
36
+ }
37
+
38
+ getDeviceManagementRequest(requestId) {
39
+ this.log.debug("[ApiClient] getDeviceManagementRequest(" + requestId + ")");
40
+ return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId], null);
41
+ }
42
+
43
+ deleteDeviceManagementRequest(requestId) {
44
+ this.log.debug("[ApiClient] deleteDeviceManagementRequest(" + requestId + ")");
45
+ return this.callApi('DELETE', 204, false, ['mgmt', 'requests', requestId], null);
46
+ }
47
+
48
+ getDeviceManagementRequestStatus(requestId) {
49
+ this.log.debug("[ApiClient] getDeviceManagementRequestStatus(" + requestId + ")");
50
+ return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId, 'deviceStatus'], null);
51
+ }
52
+
53
+ getDeviceManagementRequestStatusByDevice(requestId, typeId, deviceId) {
54
+ this.log.debug("[ApiClient] getDeviceManagementRequestStatusByDevice(" + requestId + ", " + typeId + ", " + deviceId + ")");
55
+ return this.callApi('GET', 200, true, ['mgmt', 'requests', requestId, 'deviceStatus', typeId, deviceId], null);
56
+ }
57
+
58
58
  };