Commit d6370ed64d4baa1610a0fb215f707366167791ec

Authored by Andrii Shvaika
1 parent bcac3aae

Documentation for PageData, DeviceSearchQuery and DeviceInfo

@@ -154,7 +154,9 @@ import static org.thingsboard.server.dao.service.Validator.validateId; @@ -154,7 +154,9 @@ import static org.thingsboard.server.dao.service.Validator.validateId;
154 public abstract class BaseController { 154 public abstract class BaseController {
155 155
156 /*Swagger UI description*/ 156 /*Swagger UI description*/
157 - public static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. "; 157 + public static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " +
  158 + "The result is wrapped with PageData object that allows you to iterate over result set using pagination. " +
  159 + "See the 'Model' tab of the Response Class for more details. ";
158 public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 160 public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
159 public static final String DEVICE_PROFILE_ID_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 161 public static final String DEVICE_PROFILE_ID_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
160 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; 162 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
@@ -363,7 +363,7 @@ public class DeviceController extends BaseController { @@ -363,7 +363,7 @@ public class DeviceController extends BaseController {
363 363
364 @ApiOperation(value = "Get Tenant Devices (getEdgeDevices)", 364 @ApiOperation(value = "Get Tenant Devices (getEdgeDevices)",
365 notes = "Returns a page of devices owned by tenant. " + 365 notes = "Returns a page of devices owned by tenant. " +
366 - "You can specify number of parameters to filter the result set of devices. ") 366 + PAGE_DATA_PARAMETERS)
367 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 367 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
368 @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) 368 @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
369 @ResponseBody 369 @ResponseBody
@@ -527,7 +527,7 @@ public class DeviceController extends BaseController { @@ -527,7 +527,7 @@ public class DeviceController extends BaseController {
527 } 527 }
528 528
529 @ApiOperation(value = "Get Devices By Ids (getDevicesByIds)", 529 @ApiOperation(value = "Get Devices By Ids (getDevicesByIds)",
530 - notes = "Requested devices must be in the possession of tenant or customer that performs request. ") 530 + notes = "Requested devices must be owned by tenant or assigned to customer which user is performing the request. ")
531 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 531 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
532 @RequestMapping(value = "/devices", params = {"deviceIds"}, method = RequestMethod.GET) 532 @RequestMapping(value = "/devices", params = {"deviceIds"}, method = RequestMethod.GET)
533 @ResponseBody 533 @ResponseBody
@@ -555,6 +555,10 @@ public class DeviceController extends BaseController { @@ -555,6 +555,10 @@ public class DeviceController extends BaseController {
555 } 555 }
556 } 556 }
557 557
  558 + @ApiOperation(value = "Find related devices (findByQuery)",
  559 + notes = "Returns all devices that are related to the specific entity. " +
  560 + "The entity id, relation type, device types, depth of the search, and other query parameters defined using complex 'DeviceSearchQuery' object. " +
  561 + "See 'Model' tab of the Parameters for more info.")
558 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 562 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
559 @RequestMapping(value = "/devices", method = RequestMethod.POST) 563 @RequestMapping(value = "/devices", method = RequestMethod.POST)
560 @ResponseBody 564 @ResponseBody
@@ -580,7 +584,7 @@ public class DeviceController extends BaseController { @@ -580,7 +584,7 @@ public class DeviceController extends BaseController {
580 } 584 }
581 585
582 @ApiOperation(value = "Get Device Types (getDeviceTypes)", 586 @ApiOperation(value = "Get Device Types (getDeviceTypes)",
583 - notes = "Returns all device profile names of all devices in the possession of user that is performing request.") 587 + notes = "Returns a set of unique device profile names based on devices that are either owned by the tenant or assigned to the customer which user is performing the request.")
584 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 588 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
585 @RequestMapping(value = "/device/types", method = RequestMethod.GET) 589 @RequestMapping(value = "/device/types", method = RequestMethod.GET)
586 @ResponseBody 590 @ResponseBody
@@ -846,7 +850,7 @@ public class DeviceController extends BaseController { @@ -846,7 +850,7 @@ public class DeviceController extends BaseController {
846 850
847 @ApiOperation(value = "Get devices assigned to edge (getEdgeDevices)", 851 @ApiOperation(value = "Get devices assigned to edge (getEdgeDevices)",
848 notes = "Returns a page of devices assigned to edge. " + 852 notes = "Returns a page of devices assigned to edge. " +
849 - "You can specify number of parameters to filter the result set of devices. ") 853 + PAGE_DATA_PARAMETERS)
850 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 854 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
851 @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) 855 @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
852 @ResponseBody 856 @ResponseBody
@@ -15,14 +15,20 @@ @@ -15,14 +15,20 @@
15 */ 15 */
16 package org.thingsboard.server.common.data; 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 20 import lombok.Data;
19 import org.thingsboard.server.common.data.id.DeviceId; 21 import org.thingsboard.server.common.data.id.DeviceId;
20 22
  23 +@ApiModel
21 @Data 24 @Data
22 public class DeviceInfo extends Device { 25 public class DeviceInfo extends Device {
23 26
  27 + @ApiModelProperty(position = 13, value = "Title of the Customer that owns the device.", readOnly = true)
24 private String customerTitle; 28 private String customerTitle;
  29 + @ApiModelProperty(position = 14, value = "Indicates special 'Public' Customer that is auto-generated to use the devices on public dashboards.", readOnly = true)
25 private boolean customerIsPublic; 30 private boolean customerIsPublic;
  31 + @ApiModelProperty(position = 15, value = "Name of the corresponding Device Profile.", readOnly = true)
26 private String deviceProfileName; 32 private String deviceProfileName;
27 33
28 public DeviceInfo() { 34 public DeviceInfo() {
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.device; 16 package org.thingsboard.server.common.data.device;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 20 import lombok.Data;
19 import org.thingsboard.server.common.data.EntityType; 21 import org.thingsboard.server.common.data.EntityType;
20 import org.thingsboard.server.common.data.relation.EntityRelation; 22 import org.thingsboard.server.common.data.relation.EntityRelation;
@@ -25,11 +27,15 @@ import org.thingsboard.server.common.data.relation.RelationsSearchParameters; @@ -25,11 +27,15 @@ import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
25 import java.util.Collections; 27 import java.util.Collections;
26 import java.util.List; 28 import java.util.List;
27 29
  30 +@ApiModel
28 @Data 31 @Data
29 public class DeviceSearchQuery { 32 public class DeviceSearchQuery {
30 33
  34 + @ApiModelProperty(position = 3, value = "Main search parameters.")
31 private RelationsSearchParameters parameters; 35 private RelationsSearchParameters parameters;
  36 + @ApiModelProperty(position = 1, value = "Type of the relation between root entity and device (e.g. 'Contains' or 'Manages').")
32 private String relationType; 37 private String relationType;
  38 + @ApiModelProperty(position = 2, value = "Array of device types to filter the related entities (e.g. 'Temperature Sensor', 'Smoke Sensor').")
33 private List<String> deviceTypes; 39 private List<String> deviceTypes;
34 40
35 public EntityRelationsQuery toEntitySearchQuery() { 41 public EntityRelationsQuery toEntitySearchQuery() {
@@ -17,12 +17,15 @@ package org.thingsboard.server.common.data.page; @@ -17,12 +17,15 @@ package org.thingsboard.server.common.data.page;
17 17
18 import com.fasterxml.jackson.annotation.JsonCreator; 18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonProperty; 19 import com.fasterxml.jackson.annotation.JsonProperty;
  20 +import io.swagger.annotations.ApiModel;
  21 +import io.swagger.annotations.ApiModelProperty;
20 22
21 import java.util.Collections; 23 import java.util.Collections;
22 import java.util.List; 24 import java.util.List;
23 import java.util.function.Function; 25 import java.util.function.Function;
24 import java.util.stream.Collectors; 26 import java.util.stream.Collectors;
25 27
  28 +@ApiModel
26 public class PageData<T> { 29 public class PageData<T> {
27 30
28 private final List<T> data; 31 private final List<T> data;
@@ -45,18 +48,22 @@ public class PageData<T> { @@ -45,18 +48,22 @@ public class PageData<T> {
45 this.hasNext = hasNext; 48 this.hasNext = hasNext;
46 } 49 }
47 50
  51 + @ApiModelProperty(position = 1, value = "Array of the entities.", readOnly = true)
48 public List<T> getData() { 52 public List<T> getData() {
49 return data; 53 return data;
50 } 54 }
51 55
  56 + @ApiModelProperty(position = 2, value = "Total number of available pages. Calculated based on the 'pageSize' request parameter and total number of entities that match search criteria.", readOnly = true)
52 public int getTotalPages() { 57 public int getTotalPages() {
53 return totalPages; 58 return totalPages;
54 } 59 }
55 60
  61 + @ApiModelProperty(position = 3, value = "Total number of elements in all available pages.", readOnly = true)
56 public long getTotalElements() { 62 public long getTotalElements() {
57 return totalElements; 63 return totalElements;
58 } 64 }
59 65
  66 + @ApiModelProperty(position = 4, value = "'false' value indicates the end of the result set.", readOnly = true)
60 @JsonProperty("hasNext") 67 @JsonProperty("hasNext")
61 public boolean hasNext() { 68 public boolean hasNext() {
62 return hasNext; 69 return hasNext;
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.relation; 16 package org.thingsboard.server.common.data.relation;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.AllArgsConstructor; 20 import lombok.AllArgsConstructor;
19 import lombok.Data; 21 import lombok.Data;
20 import org.thingsboard.server.common.data.EntityType; 22 import org.thingsboard.server.common.data.EntityType;
@@ -26,15 +28,22 @@ import java.util.UUID; @@ -26,15 +28,22 @@ import java.util.UUID;
26 /** 28 /**
27 * Created by ashvayka on 03.05.17. 29 * Created by ashvayka on 03.05.17.
28 */ 30 */
  31 +@ApiModel
29 @Data 32 @Data
30 @AllArgsConstructor 33 @AllArgsConstructor
31 public class RelationsSearchParameters { 34 public class RelationsSearchParameters {
32 35
  36 + @ApiModelProperty(position = 1, value = "Root entity id to start search from.")
33 private UUID rootId; 37 private UUID rootId;
  38 + @ApiModelProperty(position = 2, value = "Type of the root entity.")
34 private EntityType rootType; 39 private EntityType rootType;
  40 + @ApiModelProperty(position = 3, value = "Type of the root entity.")
35 private EntitySearchDirection direction; 41 private EntitySearchDirection direction;
  42 + @ApiModelProperty(position = 4, value = "Type of the relation.")
36 private RelationTypeGroup relationTypeGroup; 43 private RelationTypeGroup relationTypeGroup;
  44 + @ApiModelProperty(position = 5, value = "Maximum level of the search depth.")
37 private int maxLevel = 1; 45 private int maxLevel = 1;
  46 + @ApiModelProperty(position = 6, value = "Fetch entities that match the last level of search. Useful to find Devices that are strictly 'maxLevel' relations away from the root entity.")
38 private boolean fetchLastLevelOnly; 47 private boolean fetchLastLevelOnly;
39 48
40 public RelationsSearchParameters(EntityId entityId, EntitySearchDirection direction, int maxLevel, boolean fetchLastLevelOnly) { 49 public RelationsSearchParameters(EntityId entityId, EntitySearchDirection direction, int maxLevel, boolean fetchLastLevelOnly) {