//client connectivity status getConnectionStates(){ this.log.debug("[ApiClient] getConnectionStates() - client connectivity"); return this.callApi('GET', 200, true, ["clientconnectionstates"], null); }
// ========================================================================== // Application Status // ========================================================================== subscribeToAppStatus(id, qos) { id = id || '+'; qos = qos || 0; var topic = "iot-2/app/" + id + "/mon"; this.log.debug("[ApplicationClient:subscribeToAppStatus] Calling subscribe with QoS " + qos); this._subscribe(topic, qos); return this; }
initiateDeviceManagementRequest(action, parameters, devices) { this.log.debug("[ApiClient] initiateDeviceManagementRequest(" + action + ", " + parameters + ", " + devices + ")"); let body = { action: action, parameters: parameters, devices: devices }; return this.callApi('POST', 202, true, ['mgmt', 'requests'], JSON.stringify(body)); }
//bulk apis getAllDevices(params) { this.log.debug("[ApiClient] getAllDevices() - BULK"); return this.callApi('GET', 200, true, ["bulk", "devices"], null, params); }
// Retrieving and updating device properties // Get the ID of the devices group of a gateway getAllDeviceAccessControlProperties(){ this.log.debug("[ApiClient] getAllDeviceAccessControlProperties()"); return this.callApi('GET', 200, true, ['authorization', 'devices' ], null); }
// Update device properties without affecting the access control properties updateDeviceAccessControlProperties(deviceId,deviceProps){ this.log.debug("[ApiClient] updateDeviceAccessControlProperties("+deviceId+")"); return this.callApi('PUT', 200, true, ['authorization', 'devices' , deviceId], deviceProps); }
//Usage Management getActiveDevices(start, end, detail) { this.log.debug("[ApiClient] getActiveDevices(" + start + ", " + end + ")"); detail = detail | false; let params = { start: start, end: end, detail: detail }; return this.callApi('GET', 200, true, ['usage', 'active-devices'], null, params); }
// Querying a resource group // Get unique identifiers of the members of the resource group getAllDeviceIdsInGroup(groupId){ this.log.debug("[ApiClient] getAllDeviceIdsInGroup("+groupId+")"); return this.callApi('GET', 200, true, ['bulk', 'devices' , groupId, "ids"], null); }
// Extending getAllGroups() to fetch individual Groups getGroups(groupId){ this.log.debug("[ApiClient] getGroups("+groupId+")"); return this.callApi('GET', 200, true, ['groups', groupId], null); }
// ========================================================================== // Rule Triggers // ========================================================================== subscribeToRuleTriggers(interfaceId, ruleId, qos){ interfaceId = interfaceId || '+'; ruleId = ruleId || '+'; qos = qos || 0; var topic = "iot-2/intf/" + interfaceId + "/rule/" + ruleId + "/evt/trigger"; this.log.debug("[ApplicationClient:subscribeToRuleTriggers] Calling subscribe with QoS "+qos); this._subscribe(topic, qos); return this; }
getHistoricalDataUsage(start, end, detail) { this.log.debug("[ApiClient] getHistoricalDataUsage(" + start + ", " + end + ")"); detail = detail | false; let params = { start: start, end: end, detail: detail }; return this.callApi('GET', 200, true, ['usage', 'historical-data'], null, params); }
// properties of the resource group getGroup(groupId){ this.log.debug("[ApiClient] getGroup("+groupId+")"); return this.callApi('GET', 200, true, ['groups', groupId], null); }
// Creating and deleting a resource group // Create a Resource Group createGroup(groupInfo){ this.log.debug("[ApiClient] createGroup()"); return this.callApi('POST', 201, true, ['groups'], groupInfo); }
// ========================================================================== // Device State Errors // ========================================================================== subscribeToDeviceErrors(type, id, qos){ type = type || '+'; id = id || '+'; qos = qos || 0; var topic = "iot-2/type/" + type + "/id/" + id + "/err/data"; this.log.debug("[ApplicationClient:subscribeToDeviceErrors] Calling subscribe with QoS "+qos); this._subscribe(topic, qos); return this; }
// ========================================================================== // Device Status // ========================================================================== subscribeToDeviceStatus(type, id, qos) { type = type || '+'; id = id || '+'; qos = qos || 0; var topic = "iot-2/type/" + type + "/id/" + id + "/mon"; this.log.debug("[ApplicationClient:subscribeToDeviceStatus] Calling subscribe with QoS " + qos); this._subscribe(topic, qos); return this; }