Commit 4783d7dd62c990ab9fb7b68babec1e308688f7cd

Authored by Andrii Shvaika
2 parents 90f7ff57 b032b5ac

Merge with main branch

@@ -217,7 +217,7 @@ public class AlarmController extends BaseController { @@ -217,7 +217,7 @@ public class AlarmController extends BaseController {
217 @RequestMapping(value = "/alarm/{entityType}/{entityId}", method = RequestMethod.GET) 217 @RequestMapping(value = "/alarm/{entityType}/{entityId}", method = RequestMethod.GET)
218 @ResponseBody 218 @ResponseBody
219 public PageData<AlarmInfo> getAlarms( 219 public PageData<AlarmInfo> getAlarms(
220 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION) 220 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION)
221 @PathVariable(ENTITY_TYPE) String strEntityType, 221 @PathVariable(ENTITY_TYPE) String strEntityType,
222 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) 222 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION)
223 @PathVariable(ENTITY_ID) String strEntityId, 223 @PathVariable(ENTITY_ID) String strEntityId,
@@ -318,7 +318,7 @@ public class AlarmController extends BaseController { @@ -318,7 +318,7 @@ public class AlarmController extends BaseController {
318 @RequestMapping(value = "/alarm/highestSeverity/{entityType}/{entityId}", method = RequestMethod.GET) 318 @RequestMapping(value = "/alarm/highestSeverity/{entityType}/{entityId}", method = RequestMethod.GET)
319 @ResponseBody 319 @ResponseBody
320 public AlarmSeverity getHighestAlarmSeverity( 320 public AlarmSeverity getHighestAlarmSeverity(
321 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) 321 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true)
322 @PathVariable(ENTITY_TYPE) String strEntityType, 322 @PathVariable(ENTITY_TYPE) String strEntityType,
323 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) 323 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true)
324 @PathVariable(ENTITY_ID) String strEntityId, 324 @PathVariable(ENTITY_ID) String strEntityId,
@@ -172,7 +172,7 @@ public abstract class BaseController { @@ -172,7 +172,7 @@ public abstract class BaseController {
172 public static final String ASSET_ID_PARAM_DESCRIPTION = "A string value representing the asset id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 172 public static final String ASSET_ID_PARAM_DESCRIPTION = "A string value representing the asset id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
173 public static final String ALARM_ID_PARAM_DESCRIPTION = "A string value representing the alarm id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 173 public static final String ALARM_ID_PARAM_DESCRIPTION = "A string value representing the alarm id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
174 public static final String ENTITY_ID_PARAM_DESCRIPTION = "A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 174 public static final String ENTITY_ID_PARAM_DESCRIPTION = "A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
175 - public static final String ENTITY_TYPE_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'"; 175 + public static final String ENTITY_TYPE_PARAM_DESCRIPTION = "A string value representing the entity type. For example, 'DEVICE'";
176 176
177 protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page"; 177 protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
178 protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0"; 178 protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
@@ -105,11 +105,11 @@ public class EntityRelationController extends BaseController { @@ -105,11 +105,11 @@ public class EntityRelationController extends BaseController {
105 @RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE}) 105 @RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
106 @ResponseStatus(value = HttpStatus.OK) 106 @ResponseStatus(value = HttpStatus.OK)
107 public void deleteRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId, 107 public void deleteRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
108 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType, 108 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
109 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType, 109 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
110 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, 110 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
111 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId, 111 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
112 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException { 112 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
113 checkParameter(FROM_ID, strFromId); 113 checkParameter(FROM_ID, strFromId);
114 checkParameter(FROM_TYPE, strFromType); 114 checkParameter(FROM_TYPE, strFromType);
115 checkParameter(RELATION_TYPE, strRelationType); 115 checkParameter(RELATION_TYPE, strRelationType);
@@ -148,7 +148,7 @@ public class EntityRelationController extends BaseController { @@ -148,7 +148,7 @@ public class EntityRelationController extends BaseController {
148 @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"entityId", "entityType"}) 148 @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"entityId", "entityType"})
149 @ResponseStatus(value = HttpStatus.OK) 149 @ResponseStatus(value = HttpStatus.OK)
150 public void deleteRelations(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam("entityId") String strId, 150 public void deleteRelations(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam("entityId") String strId,
151 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam("entityType") String strType) throws ThingsboardException { 151 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam("entityType") String strType) throws ThingsboardException {
152 checkParameter("entityId", strId); 152 checkParameter("entityId", strId);
153 checkParameter("entityType", strType); 153 checkParameter("entityType", strType);
154 EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId); 154 EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId);
@@ -169,11 +169,11 @@ public class EntityRelationController extends BaseController { @@ -169,11 +169,11 @@ public class EntityRelationController extends BaseController {
169 @RequestMapping(value = "/relation", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE}) 169 @RequestMapping(value = "/relation", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
170 @ResponseBody 170 @ResponseBody
171 public EntityRelation getRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId, 171 public EntityRelation getRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
172 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType, 172 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
173 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType, 173 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
174 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, 174 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
175 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId, 175 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
176 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException { 176 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
177 try { 177 try {
178 checkParameter(FROM_ID, strFromId); 178 checkParameter(FROM_ID, strFromId);
179 checkParameter(FROM_TYPE, strFromType); 179 checkParameter(FROM_TYPE, strFromType);
@@ -199,7 +199,7 @@ public class EntityRelationController extends BaseController { @@ -199,7 +199,7 @@ public class EntityRelationController extends BaseController {
199 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE}) 199 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
200 @ResponseBody 200 @ResponseBody
201 public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId, 201 public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
202 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType, 202 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
203 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 203 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
204 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 204 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
205 checkParameter(FROM_ID, strFromId); 205 checkParameter(FROM_ID, strFromId);
@@ -222,7 +222,7 @@ public class EntityRelationController extends BaseController { @@ -222,7 +222,7 @@ public class EntityRelationController extends BaseController {
222 @RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE}) 222 @RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
223 @ResponseBody 223 @ResponseBody
224 public List<EntityRelationInfo> findInfoByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId, 224 public List<EntityRelationInfo> findInfoByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
225 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType, 225 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
226 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 226 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
227 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 227 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
228 checkParameter(FROM_ID, strFromId); 228 checkParameter(FROM_ID, strFromId);
@@ -245,7 +245,7 @@ public class EntityRelationController extends BaseController { @@ -245,7 +245,7 @@ public class EntityRelationController extends BaseController {
245 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE}) 245 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE})
246 @ResponseBody 246 @ResponseBody
247 public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId, 247 public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
248 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType, 248 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
249 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType, 249 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
250 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 250 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
251 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 251 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
@@ -270,7 +270,7 @@ public class EntityRelationController extends BaseController { @@ -270,7 +270,7 @@ public class EntityRelationController extends BaseController {
270 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE}) 270 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
271 @ResponseBody 271 @ResponseBody
272 public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId, 272 public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
273 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType, 273 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
274 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 274 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
275 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 275 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
276 checkParameter(TO_ID, strToId); 276 checkParameter(TO_ID, strToId);
@@ -293,7 +293,7 @@ public class EntityRelationController extends BaseController { @@ -293,7 +293,7 @@ public class EntityRelationController extends BaseController {
293 @RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE}) 293 @RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
294 @ResponseBody 294 @ResponseBody
295 public List<EntityRelationInfo> findInfoByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId, 295 public List<EntityRelationInfo> findInfoByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
296 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType, 296 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
297 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 297 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
298 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 298 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
299 checkParameter(TO_ID, strToId); 299 checkParameter(TO_ID, strToId);
@@ -316,7 +316,7 @@ public class EntityRelationController extends BaseController { @@ -316,7 +316,7 @@ public class EntityRelationController extends BaseController {
316 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE}) 316 @RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE})
317 @ResponseBody 317 @ResponseBody
318 public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId, 318 public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
319 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType, 319 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
320 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType, 320 @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
321 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) 321 @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
322 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { 322 @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
@@ -55,7 +55,7 @@ public class EventController extends BaseController { @@ -55,7 +55,7 @@ public class EventController extends BaseController {
55 @RequestMapping(value = "/events/{entityType}/{entityId}/{eventType}", method = RequestMethod.GET) 55 @RequestMapping(value = "/events/{entityType}/{entityId}/{eventType}", method = RequestMethod.GET)
56 @ResponseBody 56 @ResponseBody
57 public PageData<Event> getEvents( 57 public PageData<Event> getEvents(
58 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) 58 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true)
59 @PathVariable(ENTITY_TYPE) String strEntityType, 59 @PathVariable(ENTITY_TYPE) String strEntityType,
60 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) 60 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true)
61 @PathVariable(ENTITY_ID) String strEntityId, 61 @PathVariable(ENTITY_ID) String strEntityId,
@@ -98,7 +98,7 @@ public class EventController extends BaseController { @@ -98,7 +98,7 @@ public class EventController extends BaseController {
98 @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.GET) 98 @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.GET)
99 @ResponseBody 99 @ResponseBody
100 public PageData<Event> getEvents( 100 public PageData<Event> getEvents(
101 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) 101 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true)
102 @PathVariable(ENTITY_TYPE) String strEntityType, 102 @PathVariable(ENTITY_TYPE) String strEntityType,
103 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) 103 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true)
104 @PathVariable(ENTITY_ID) String strEntityId, 104 @PathVariable(ENTITY_ID) String strEntityId,
@@ -141,7 +141,7 @@ public class EventController extends BaseController { @@ -141,7 +141,7 @@ public class EventController extends BaseController {
141 @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.POST) 141 @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.POST)
142 @ResponseBody 142 @ResponseBody
143 public PageData<Event> getEvents( 143 public PageData<Event> getEvents(
144 - @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) 144 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true)
145 @PathVariable(ENTITY_TYPE) String strEntityType, 145 @PathVariable(ENTITY_TYPE) String strEntityType,
146 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) 146 @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true)
147 @PathVariable(ENTITY_ID) String strEntityId, 147 @PathVariable(ENTITY_ID) String strEntityId,
@@ -26,6 +26,8 @@ import com.google.common.util.concurrent.MoreExecutors; @@ -26,6 +26,8 @@ import com.google.common.util.concurrent.MoreExecutors;
26 import com.google.gson.JsonElement; 26 import com.google.gson.JsonElement;
27 import com.google.gson.JsonParseException; 27 import com.google.gson.JsonParseException;
28 import com.google.gson.JsonParser; 28 import com.google.gson.JsonParser;
  29 +import io.swagger.annotations.ApiOperation;
  30 +import io.swagger.annotations.ApiParam;
29 import lombok.extern.slf4j.Slf4j; 31 import lombok.extern.slf4j.Slf4j;
30 import org.springframework.beans.factory.annotation.Autowired; 32 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.beans.factory.annotation.Value; 33 import org.springframework.beans.factory.annotation.Value;
@@ -48,7 +50,6 @@ import org.thingsboard.server.common.data.EntityType; @@ -48,7 +50,6 @@ import org.thingsboard.server.common.data.EntityType;
48 import org.thingsboard.server.common.data.TenantProfile; 50 import org.thingsboard.server.common.data.TenantProfile;
49 import org.thingsboard.server.common.data.audit.ActionType; 51 import org.thingsboard.server.common.data.audit.ActionType;
50 import org.thingsboard.server.common.data.exception.ThingsboardException; 52 import org.thingsboard.server.common.data.exception.ThingsboardException;
51 -import org.thingsboard.server.common.data.id.CustomerId;  
52 import org.thingsboard.server.common.data.id.DeviceId; 53 import org.thingsboard.server.common.data.id.DeviceId;
53 import org.thingsboard.server.common.data.id.EntityId; 54 import org.thingsboard.server.common.data.id.EntityId;
54 import org.thingsboard.server.common.data.id.EntityIdFactory; 55 import org.thingsboard.server.common.data.id.EntityIdFactory;
@@ -108,6 +109,17 @@ import java.util.stream.Collectors; @@ -108,6 +109,17 @@ import java.util.stream.Collectors;
108 @Slf4j 109 @Slf4j
109 public class TelemetryController extends BaseController { 110 public class TelemetryController extends BaseController {
110 111
  112 + private static final String ATTRIBUTES_SCOPE_DESCRIPTION = "A string value representing the attributes scope. For example, 'SERVER_SCOPE'.";
  113 + private static final String ATTRIBUTES_KEYS_DESCRIPTION = "A string value representing the comma-separated list of attributes keys. For example, 'active,inactivityAlarmTime'.";
  114 + private static final String ATTRIBUTES_SCOPE_ALLOWED_VALUES = "SERVER_SCOPE, CLIENT_SCOPE, SHARED_SCOPE";
  115 + private static final String ATTRIBUTES_JSON_REQUEST_DESCRIPTION = "A string value representing the json object. For example, '{\"key\":\"value\"}'";
  116 +
  117 + private static final String TELEMETRY_KEYS_DESCRIPTION = "A string value representing the comma-separated list of timeseries keys. If keys are not selected, the result will return all latest timeseries. For example, 'temp,humidity'.";
  118 + private static final String TELEMETRY_SCOPE_DESCRIPTION = "Value is not used in the API call implementation";
  119 + private static final String TELEMETRY_JSON_REQUEST_DESCRIPTION = "A string value representing the json object. For example, '{\"key\":\"value\"}' or '{\"ts\":1527863043000,\"values\":{\"key1\":\"value1\",\"key2\":\"value2\"}}'";
  120 +
  121 + private static final String STRICT_DATA_TYPES_DESCRIPTION = "A boolean value to specify if values of selected timeseries keys will representing a string (by default) or use strict data type.";
  122 +
111 @Autowired 123 @Autowired
112 private TimeseriesService tsService; 124 private TimeseriesService tsService;
113 125
@@ -133,62 +145,81 @@ public class TelemetryController extends BaseController { @@ -133,62 +145,81 @@ public class TelemetryController extends BaseController {
133 } 145 }
134 } 146 }
135 147
  148 + @ApiOperation(value = "Get all attribute keys (getAttributeKeys)",
  149 + notes = "Returns key names for the selected entity.")
136 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 150 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
137 @RequestMapping(value = "/{entityType}/{entityId}/keys/attributes", method = RequestMethod.GET) 151 @RequestMapping(value = "/{entityType}/{entityId}/keys/attributes", method = RequestMethod.GET)
138 @ResponseBody 152 @ResponseBody
139 public DeferredResult<ResponseEntity> getAttributeKeys( 153 public DeferredResult<ResponseEntity> getAttributeKeys(
140 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr) throws ThingsboardException { 154 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  155 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr) throws ThingsboardException {
141 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr, this::getAttributeKeysCallback); 156 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr, this::getAttributeKeysCallback);
142 } 157 }
143 158
  159 + @ApiOperation(value = "Get all attributes by scope (getAttributeKeysByScope)",
  160 + notes = "Returns key names of specified scope for the selected entity.")
144 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 161 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
145 @RequestMapping(value = "/{entityType}/{entityId}/keys/attributes/{scope}", method = RequestMethod.GET) 162 @RequestMapping(value = "/{entityType}/{entityId}/keys/attributes/{scope}", method = RequestMethod.GET)
146 @ResponseBody 163 @ResponseBody
147 public DeferredResult<ResponseEntity> getAttributeKeysByScope( 164 public DeferredResult<ResponseEntity> getAttributeKeysByScope(
148 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr  
149 - , @PathVariable("scope") String scope) throws ThingsboardException { 165 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  166 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  167 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope) throws ThingsboardException {
150 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr, 168 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr,
151 (result, tenantId, entityId) -> getAttributeKeysCallback(result, tenantId, entityId, scope)); 169 (result, tenantId, entityId) -> getAttributeKeysCallback(result, tenantId, entityId, scope));
152 } 170 }
153 171
  172 + @ApiOperation(value = "Get attributes (getAttributes)",
  173 + notes = "Returns JSON array of AttributeData objects for the selected entity.")
154 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 174 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
155 @RequestMapping(value = "/{entityType}/{entityId}/values/attributes", method = RequestMethod.GET) 175 @RequestMapping(value = "/{entityType}/{entityId}/values/attributes", method = RequestMethod.GET)
156 @ResponseBody 176 @ResponseBody
157 public DeferredResult<ResponseEntity> getAttributes( 177 public DeferredResult<ResponseEntity> getAttributes(
158 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
159 - @RequestParam(name = "keys", required = false) String keysStr) throws ThingsboardException { 178 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  179 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  180 + @ApiParam(value = ATTRIBUTES_KEYS_DESCRIPTION) @RequestParam(name = "keys", required = false) String keysStr) throws ThingsboardException {
160 SecurityUser user = getCurrentUser(); 181 SecurityUser user = getCurrentUser();
161 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr, 182 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr,
162 (result, tenantId, entityId) -> getAttributeValuesCallback(result, user, entityId, null, keysStr)); 183 (result, tenantId, entityId) -> getAttributeValuesCallback(result, user, entityId, null, keysStr));
163 } 184 }
164 185
  186 + @ApiOperation(value = "Get attributes by scope (getAttributesByScope)",
  187 + notes = "Returns JSON array of AttributeData objects for the selected entity.")
165 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 188 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
166 @RequestMapping(value = "/{entityType}/{entityId}/values/attributes/{scope}", method = RequestMethod.GET) 189 @RequestMapping(value = "/{entityType}/{entityId}/values/attributes/{scope}", method = RequestMethod.GET)
167 @ResponseBody 190 @ResponseBody
168 public DeferredResult<ResponseEntity> getAttributesByScope( 191 public DeferredResult<ResponseEntity> getAttributesByScope(
169 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
170 - @PathVariable("scope") String scope,  
171 - @RequestParam(name = "keys", required = false) String keysStr) throws ThingsboardException { 192 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  193 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  194 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  195 + @ApiParam(value = ATTRIBUTES_KEYS_DESCRIPTION) @RequestParam(name = "keys", required = false) String keysStr) throws ThingsboardException {
172 SecurityUser user = getCurrentUser(); 196 SecurityUser user = getCurrentUser();
173 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr, 197 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_ATTRIBUTES, entityType, entityIdStr,
174 (result, tenantId, entityId) -> getAttributeValuesCallback(result, user, entityId, scope, keysStr)); 198 (result, tenantId, entityId) -> getAttributeValuesCallback(result, user, entityId, scope, keysStr));
175 } 199 }
176 200
  201 + @ApiOperation(value = "Get timeseries keys (getTimeseriesKeys)",
  202 + notes = "Returns latest timeseries keys for selected entity.")
177 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 203 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
178 @RequestMapping(value = "/{entityType}/{entityId}/keys/timeseries", method = RequestMethod.GET) 204 @RequestMapping(value = "/{entityType}/{entityId}/keys/timeseries", method = RequestMethod.GET)
179 @ResponseBody 205 @ResponseBody
180 public DeferredResult<ResponseEntity> getTimeseriesKeys( 206 public DeferredResult<ResponseEntity> getTimeseriesKeys(
181 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr) throws ThingsboardException { 207 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  208 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr) throws ThingsboardException {
182 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr, 209 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr,
183 (result, tenantId, entityId) -> Futures.addCallback(tsService.findAllLatest(tenantId, entityId), getTsKeysToResponseCallback(result), MoreExecutors.directExecutor())); 210 (result, tenantId, entityId) -> Futures.addCallback(tsService.findAllLatest(tenantId, entityId), getTsKeysToResponseCallback(result), MoreExecutors.directExecutor()));
184 } 211 }
185 212
  213 + @ApiOperation(value = "Get latest timeseries (getLatestTimeseries)",
  214 + notes = "Returns JSON object with mapping latest timeseries keys to JSON arrays of TsData objects for the selected entity.")
186 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 215 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
187 @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET) 216 @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET)
188 @ResponseBody 217 @ResponseBody
189 public DeferredResult<ResponseEntity> getLatestTimeseries( 218 public DeferredResult<ResponseEntity> getLatestTimeseries(
190 - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
191 - @RequestParam(name = "keys", required = false) String keysStr, 219 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  220 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  221 + @ApiParam(value = TELEMETRY_KEYS_DESCRIPTION) @RequestParam(name = "keys", required = false) String keysStr,
  222 + @ApiParam(value = STRICT_DATA_TYPES_DESCRIPTION)
192 @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException { 223 @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException {
193 SecurityUser user = getCurrentUser(); 224 SecurityUser user = getCurrentUser();
194 225
@@ -196,20 +227,30 @@ public class TelemetryController extends BaseController { @@ -196,20 +227,30 @@ public class TelemetryController extends BaseController {
196 (result, tenantId, entityId) -> getLatestTimeseriesValuesCallback(result, user, entityId, keysStr, useStrictDataTypes)); 227 (result, tenantId, entityId) -> getLatestTimeseriesValuesCallback(result, user, entityId, keysStr, useStrictDataTypes));
197 } 228 }
198 229
199 - 230 + @ApiOperation(value = "Get timeseries (getTimeseries)",
  231 + notes = "Returns JSON object with mapping timeseries keys to JSON arrays of TsData objects based on specified filters for the selected entity.")
200 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 232 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
201 @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET, params = {"keys", "startTs", "endTs"}) 233 @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET, params = {"keys", "startTs", "endTs"})
202 @ResponseBody 234 @ResponseBody
203 public DeferredResult<ResponseEntity> getTimeseries( 235 public DeferredResult<ResponseEntity> getTimeseries(
204 - @PathVariable("entityType") String entityType,  
205 - @PathVariable("entityId") String entityIdStr,  
206 - @RequestParam(name = "keys") String keys, 236 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  237 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  238 + @ApiParam(value = TELEMETRY_KEYS_DESCRIPTION) @RequestParam(name = "keys") String keys,
  239 + @ApiParam(value = "A long value representing the start timestamp(milliseconds) of search time range.")
207 @RequestParam(name = "startTs") Long startTs, 240 @RequestParam(name = "startTs") Long startTs,
  241 + @ApiParam(value = "A long value representing the end timestamp(milliseconds) of search time range.")
208 @RequestParam(name = "endTs") Long endTs, 242 @RequestParam(name = "endTs") Long endTs,
  243 + @ApiParam(value = "A long value representing the aggregation interval(milliseconds) range.")
209 @RequestParam(name = "interval", defaultValue = "0") Long interval, 244 @RequestParam(name = "interval", defaultValue = "0") Long interval,
  245 + @ApiParam(value = "An integer value representing max number of selected data points.", defaultValue = "100")
210 @RequestParam(name = "limit", defaultValue = "100") Integer limit, 246 @RequestParam(name = "limit", defaultValue = "100") Integer limit,
  247 + @ApiParam(value = "A string value representing the aggregation function. " +
  248 + "If the interval is not specified, 'agg' parameter will be converted to 'NONE' value.",
  249 + allowableValues = "MIN, MAX, AVG, SUM, COUNT, NONE")
211 @RequestParam(name = "agg", defaultValue = "NONE") String aggStr, 250 @RequestParam(name = "agg", defaultValue = "NONE") String aggStr,
  251 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
212 @RequestParam(name = "orderBy", defaultValue = "DESC") String orderBy, 252 @RequestParam(name = "orderBy", defaultValue = "DESC") String orderBy,
  253 + @ApiParam(value = STRICT_DATA_TYPES_DESCRIPTION)
213 @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException { 254 @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException {
214 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr, 255 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr,
215 (result, tenantId, entityId) -> { 256 (result, tenantId, entityId) -> {
@@ -222,64 +263,89 @@ public class TelemetryController extends BaseController { @@ -222,64 +263,89 @@ public class TelemetryController extends BaseController {
222 }); 263 });
223 } 264 }
224 265
  266 + @ApiOperation(value = "Save or update device attributes (saveDeviceAttributes)")
225 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 267 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
226 @RequestMapping(value = "/{deviceId}/{scope}", method = RequestMethod.POST) 268 @RequestMapping(value = "/{deviceId}/{scope}", method = RequestMethod.POST)
227 @ResponseBody 269 @ResponseBody
228 - public DeferredResult<ResponseEntity> saveDeviceAttributes(@PathVariable("deviceId") String deviceIdStr, @PathVariable("scope") String scope,  
229 - @RequestBody JsonNode request) throws ThingsboardException { 270 + public DeferredResult<ResponseEntity> saveDeviceAttributes(
  271 + @ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION) @PathVariable("deviceId") String deviceIdStr,
  272 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  273 + @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION) @RequestBody JsonNode request) throws ThingsboardException {
230 EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr); 274 EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr);
231 return saveAttributes(getTenantId(), entityId, scope, request); 275 return saveAttributes(getTenantId(), entityId, scope, request);
232 } 276 }
233 277
  278 + @ApiOperation(value = "Save or update attributes (saveEntityAttributesV1)")
234 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 279 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
235 @RequestMapping(value = "/{entityType}/{entityId}/{scope}", method = RequestMethod.POST) 280 @RequestMapping(value = "/{entityType}/{entityId}/{scope}", method = RequestMethod.POST)
236 @ResponseBody 281 @ResponseBody
237 - public DeferredResult<ResponseEntity> saveEntityAttributesV1(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
238 - @PathVariable("scope") String scope,  
239 - @RequestBody JsonNode request) throws ThingsboardException { 282 + public DeferredResult<ResponseEntity> saveEntityAttributesV1(
  283 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  284 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  285 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  286 + @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION) @RequestBody JsonNode request) throws ThingsboardException {
240 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 287 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
241 return saveAttributes(getTenantId(), entityId, scope, request); 288 return saveAttributes(getTenantId(), entityId, scope, request);
242 } 289 }
243 290
  291 + @ApiOperation(value = "Save or update attributes (saveEntityAttributesV2)")
244 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 292 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
245 @RequestMapping(value = "/{entityType}/{entityId}/attributes/{scope}", method = RequestMethod.POST) 293 @RequestMapping(value = "/{entityType}/{entityId}/attributes/{scope}", method = RequestMethod.POST)
246 @ResponseBody 294 @ResponseBody
247 - public DeferredResult<ResponseEntity> saveEntityAttributesV2(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
248 - @PathVariable("scope") String scope,  
249 - @RequestBody JsonNode request) throws ThingsboardException { 295 + public DeferredResult<ResponseEntity> saveEntityAttributesV2(
  296 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  297 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  298 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  299 + @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION) @RequestBody JsonNode request) throws ThingsboardException {
250 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 300 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
251 return saveAttributes(getTenantId(), entityId, scope, request); 301 return saveAttributes(getTenantId(), entityId, scope, request);
252 } 302 }
253 303
  304 + @ApiOperation(value = "Save or update telemetry (saveEntityTelemetry)")
254 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 305 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
255 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/{scope}", method = RequestMethod.POST) 306 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/{scope}", method = RequestMethod.POST)
256 @ResponseBody 307 @ResponseBody
257 - public DeferredResult<ResponseEntity> saveEntityTelemetry(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
258 - @PathVariable("scope") String scope,  
259 - @RequestBody String requestBody) throws ThingsboardException { 308 + public DeferredResult<ResponseEntity> saveEntityTelemetry(
  309 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  310 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  311 + @ApiParam(value = TELEMETRY_SCOPE_DESCRIPTION) @PathVariable("scope") String scope,
  312 + @ApiParam(value = TELEMETRY_JSON_REQUEST_DESCRIPTION) @RequestBody String requestBody) throws ThingsboardException {
260 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 313 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
261 return saveTelemetry(getTenantId(), entityId, requestBody, 0L); 314 return saveTelemetry(getTenantId(), entityId, requestBody, 0L);
262 } 315 }
263 316
  317 + @ApiOperation(value = "Save or update telemetry with TTL (saveEntityTelemetryWithTTL)",
  318 + notes = "The TTL parameter is used to extract the number of days to store the data.")
264 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 319 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
265 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/{scope}/{ttl}", method = RequestMethod.POST) 320 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/{scope}/{ttl}", method = RequestMethod.POST)
266 @ResponseBody 321 @ResponseBody
267 - public DeferredResult<ResponseEntity> saveEntityTelemetryWithTTL(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
268 - @PathVariable("scope") String scope, @PathVariable("ttl") Long ttl,  
269 - @RequestBody String requestBody) throws ThingsboardException { 322 + public DeferredResult<ResponseEntity> saveEntityTelemetryWithTTL(
  323 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  324 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  325 + @ApiParam(value = TELEMETRY_SCOPE_DESCRIPTION) @PathVariable("scope") String scope,
  326 + @ApiParam(value = "A long value representing TTL(Time to Live) parameter.") @PathVariable("ttl") Long ttl,
  327 + @ApiParam(value = TELEMETRY_JSON_REQUEST_DESCRIPTION) @RequestBody String requestBody) throws ThingsboardException {
270 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 328 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
271 return saveTelemetry(getTenantId(), entityId, requestBody, ttl); 329 return saveTelemetry(getTenantId(), entityId, requestBody, ttl);
272 } 330 }
273 331
  332 + @ApiOperation(value = "Delete entity timeseries (deleteEntityTimeseries)",
  333 + notes = "Delete timeseries in the specified time range for selected entity.")
274 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 334 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
275 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/delete", method = RequestMethod.DELETE) 335 @RequestMapping(value = "/{entityType}/{entityId}/timeseries/delete", method = RequestMethod.DELETE)
276 @ResponseBody 336 @ResponseBody
277 - public DeferredResult<ResponseEntity> deleteEntityTimeseries(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
278 - @RequestParam(name = "keys") String keysStr,  
279 - @RequestParam(name = "deleteAllDataForKeys", defaultValue = "false") boolean deleteAllDataForKeys,  
280 - @RequestParam(name = "startTs", required = false) Long startTs,  
281 - @RequestParam(name = "endTs", required = false) Long endTs,  
282 - @RequestParam(name = "rewriteLatestIfDeleted", defaultValue = "false") boolean rewriteLatestIfDeleted) throws ThingsboardException { 337 + public DeferredResult<ResponseEntity> deleteEntityTimeseries(
  338 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  339 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  340 + @ApiParam(value = TELEMETRY_KEYS_DESCRIPTION) @RequestParam(name = "keys") String keysStr,
  341 + @ApiParam(value = "A boolean value to specify if should be deleted all data for selected keys or only data that are in the selected time range.")
  342 + @RequestParam(name = "deleteAllDataForKeys", defaultValue = "false") boolean deleteAllDataForKeys,
  343 + @ApiParam(value = "A long value representing the start timestamp(milliseconds) of removal time range.")
  344 + @RequestParam(name = "startTs", required = false) Long startTs,
  345 + @ApiParam(value = "A long value representing the end timestamp(milliseconds) of removal time range.")
  346 + @RequestParam(name = "endTs", required = false) Long endTs,
  347 + @ApiParam(value = "If the parameter is set to true, the latest telemetry will be rewritten if the current latest value was removed, otherwise, the new latest value will not set.")
  348 + @RequestParam(name = "rewriteLatestIfDeleted", defaultValue = "false") boolean rewriteLatestIfDeleted) throws ThingsboardException {
283 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 349 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
284 return deleteTimeseries(entityId, keysStr, deleteAllDataForKeys, startTs, endTs, rewriteLatestIfDeleted); 350 return deleteTimeseries(entityId, keysStr, deleteAllDataForKeys, startTs, endTs, rewriteLatestIfDeleted);
285 } 351 }
@@ -311,7 +377,6 @@ public class TelemetryController extends BaseController { @@ -311,7 +377,6 @@ public class TelemetryController extends BaseController {
311 for (String key : keys) { 377 for (String key : keys) {
312 deleteTsKvQueries.add(new BaseDeleteTsKvQuery(key, deleteFromTs, deleteToTs, rewriteLatestIfDeleted)); 378 deleteTsKvQueries.add(new BaseDeleteTsKvQuery(key, deleteFromTs, deleteToTs, rewriteLatestIfDeleted));
313 } 379 }
314 -  
315 ListenableFuture<List<Void>> future = tsService.remove(user.getTenantId(), entityId, deleteTsKvQueries); 380 ListenableFuture<List<Void>> future = tsService.remove(user.getTenantId(), entityId, deleteTsKvQueries);
316 Futures.addCallback(future, new FutureCallback<List<Void>>() { 381 Futures.addCallback(future, new FutureCallback<List<Void>>() {
317 @Override 382 @Override
@@ -329,22 +394,29 @@ public class TelemetryController extends BaseController { @@ -329,22 +394,29 @@ public class TelemetryController extends BaseController {
329 }); 394 });
330 } 395 }
331 396
  397 + @ApiOperation(value = "Delete device attributes (deleteEntityAttributes)",
  398 + notes = "Delete attributes of specified scope for selected device.")
332 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 399 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
333 @RequestMapping(value = "/{deviceId}/{scope}", method = RequestMethod.DELETE) 400 @RequestMapping(value = "/{deviceId}/{scope}", method = RequestMethod.DELETE)
334 @ResponseBody 401 @ResponseBody
335 - public DeferredResult<ResponseEntity> deleteEntityAttributes(@PathVariable("deviceId") String deviceIdStr,  
336 - @PathVariable("scope") String scope,  
337 - @RequestParam(name = "keys") String keysStr) throws ThingsboardException { 402 + public DeferredResult<ResponseEntity> deleteEntityAttributes(
  403 + @ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION) @PathVariable("deviceId") String deviceIdStr,
  404 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  405 + @ApiParam(value = ATTRIBUTES_KEYS_DESCRIPTION) @RequestParam(name = "keys") String keysStr) throws ThingsboardException {
338 EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr); 406 EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr);
339 return deleteAttributes(entityId, scope, keysStr); 407 return deleteAttributes(entityId, scope, keysStr);
340 } 408 }
341 409
  410 + @ApiOperation(value = "Delete entity attributes (deleteEntityAttributes)",
  411 + notes = "Delete attributes of specified scope for selected entity.")
342 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 412 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
343 @RequestMapping(value = "/{entityType}/{entityId}/{scope}", method = RequestMethod.DELETE) 413 @RequestMapping(value = "/{entityType}/{entityId}/{scope}", method = RequestMethod.DELETE)
344 @ResponseBody 414 @ResponseBody
345 - public DeferredResult<ResponseEntity> deleteEntityAttributes(@PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr,  
346 - @PathVariable("scope") String scope,  
347 - @RequestParam(name = "keys") String keysStr) throws ThingsboardException { 415 + public DeferredResult<ResponseEntity> deleteEntityAttributes(
  416 + @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION) @PathVariable("entityType") String entityType,
  417 + @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @PathVariable("entityId") String entityIdStr,
  418 + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope,
  419 + @ApiParam(value = ATTRIBUTES_KEYS_DESCRIPTION) @RequestParam(name = "keys") String keysStr) throws ThingsboardException {
348 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); 420 EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
349 return deleteAttributes(entityId, scope, keysStr); 421 return deleteAttributes(entityId, scope, keysStr);
350 } 422 }