|
|
@ -19,22 +19,21 @@
|
|
|
|
package org.homeautomation.watertank.api;
|
|
|
|
package org.homeautomation.watertank.api;
|
|
|
|
|
|
|
|
|
|
|
|
import org.homeautomation.watertank.api.dto.DeviceJSON;
|
|
|
|
import org.homeautomation.watertank.api.dto.DeviceJSON;
|
|
|
|
|
|
|
|
|
|
|
|
import org.wso2.carbon.apimgt.annotations.api.API;
|
|
|
|
import org.wso2.carbon.apimgt.annotations.api.API;
|
|
|
|
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
|
|
|
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
|
|
|
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
|
|
|
|
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
|
|
|
|
import javax.ws.rs.DELETE;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.PUT;
|
|
|
|
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
import javax.ws.rs.PathParam;
|
|
|
|
import javax.ws.rs.PathParam;
|
|
|
|
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
import javax.ws.rs.PUT;
|
|
|
|
|
|
|
|
import javax.ws.rs.DELETE;
|
|
|
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
@ -58,34 +57,37 @@ interface DeviceTypeService {
|
|
|
|
Response registerDevice(final DeviceJSON agentInfo);
|
|
|
|
Response registerDevice(final DeviceJSON agentInfo);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param deviceId unique identifier for given device type
|
|
|
|
* @param deviceId unique identifier for given device type
|
|
|
|
* @param onLevel level to turn on the relay
|
|
|
|
* @param onLevel level to turn on the relay
|
|
|
|
* @param offLevel level to turn off thr relay
|
|
|
|
* @param offLevel level to turn off the relay
|
|
|
|
|
|
|
|
* @param sensorHeight height to water level sensor from bottom of the tank
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Path("device/{deviceId}/change-levels")
|
|
|
|
@Path("device/{deviceId}/change-levels")
|
|
|
|
@POST
|
|
|
|
@POST
|
|
|
|
@Feature(code = "change-levels", name = "Change on/off water levels",
|
|
|
|
@Feature(code = "change-levels", name = "Update configurations",
|
|
|
|
description = "Change on/off water levels")
|
|
|
|
description = "Change on/off water levels and set sensor height from the bottom of the tank")
|
|
|
|
@Permission(scope = "watertank_user", permissions = {"/permission/admin/device-mgt/change-levels"})
|
|
|
|
@Permission(scope = "watertank_user", permissions = {"/permission/admin/device-mgt/change-levels"})
|
|
|
|
Response changeOnOffLevels(@PathParam("deviceId") String deviceId,
|
|
|
|
Response updateConfigs(@PathParam("deviceId") String deviceId,
|
|
|
|
@QueryParam("on") int onLevel,
|
|
|
|
@QueryParam("on") int onLevel,
|
|
|
|
@QueryParam("off") int offLevel,
|
|
|
|
@QueryParam("off") int offLevel,
|
|
|
|
@Context HttpServletResponse response);
|
|
|
|
@QueryParam("height") int sensorHeight,
|
|
|
|
|
|
|
|
@Context HttpServletResponse response);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Retrieve Sensor data for the given time period
|
|
|
|
* Retrieve Sensor data for the given time period
|
|
|
|
* @param deviceId unique identifier for given device type instance
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param deviceId unique identifier for given device type instance
|
|
|
|
* @param sensorName name of the sensor
|
|
|
|
* @param sensorName name of the sensor
|
|
|
|
* @param from starting time
|
|
|
|
* @param from starting time
|
|
|
|
* @param to ending time
|
|
|
|
* @param to ending time
|
|
|
|
* @return response with List<SensorRecord> object which includes sensor data which is requested
|
|
|
|
* @return response with List<SensorRecord> object which includes sensor data which is requested
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Path("device/stats/{deviceId}/sensors/{sensorName}")
|
|
|
|
@Path("device/stats/{deviceId}/sensors/{sensorName}")
|
|
|
|
@GET
|
|
|
|
@GET
|
|
|
|
@Consumes("application/json")
|
|
|
|
@Consumes("application/json")
|
|
|
|
@Produces("application/json")
|
|
|
|
@Produces("application/json")
|
|
|
|
Response getSensorStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensorName,
|
|
|
|
Response getSensorStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensorName,
|
|
|
|
@QueryParam("from") long from, @QueryParam("to") long to);
|
|
|
|
@QueryParam("from") long from, @QueryParam("to") long to);
|
|
|
|
|
|
|
|
|
|
|
|
@Path("/device/{device_id}")
|
|
|
|
@Path("/device/{device_id}")
|
|
|
|
@DELETE
|
|
|
|
@DELETE
|
|
|
|