Commit d6370ed64d4baa1610a0fb215f707366167791ec
1 parent
bcac3aae
Documentation for PageData, DeviceSearchQuery and DeviceInfo
Showing
6 changed files
with
39 additions
and
5 deletions
... | ... | @@ -154,7 +154,9 @@ import static org.thingsboard.server.dao.service.Validator.validateId; |
154 | 154 | public abstract class BaseController { |
155 | 155 | |
156 | 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 | 160 | public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
159 | 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 | 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 | 363 | |
364 | 364 | @ApiOperation(value = "Get Tenant Devices (getEdgeDevices)", |
365 | 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 | 367 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
368 | 368 | @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) |
369 | 369 | @ResponseBody |
... | ... | @@ -527,7 +527,7 @@ public class DeviceController extends BaseController { |
527 | 527 | } |
528 | 528 | |
529 | 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 | 531 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
532 | 532 | @RequestMapping(value = "/devices", params = {"deviceIds"}, method = RequestMethod.GET) |
533 | 533 | @ResponseBody |
... | ... | @@ -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 | 562 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
559 | 563 | @RequestMapping(value = "/devices", method = RequestMethod.POST) |
560 | 564 | @ResponseBody |
... | ... | @@ -580,7 +584,7 @@ public class DeviceController extends BaseController { |
580 | 584 | } |
581 | 585 | |
582 | 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 | 588 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
585 | 589 | @RequestMapping(value = "/device/types", method = RequestMethod.GET) |
586 | 590 | @ResponseBody |
... | ... | @@ -846,7 +850,7 @@ public class DeviceController extends BaseController { |
846 | 850 | |
847 | 851 | @ApiOperation(value = "Get devices assigned to edge (getEdgeDevices)", |
848 | 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 | 854 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
851 | 855 | @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) |
852 | 856 | @ResponseBody | ... | ... |
... | ... | @@ -15,14 +15,20 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data; |
17 | 17 | |
18 | +import io.swagger.annotations.ApiModel; | |
19 | +import io.swagger.annotations.ApiModelProperty; | |
18 | 20 | import lombok.Data; |
19 | 21 | import org.thingsboard.server.common.data.id.DeviceId; |
20 | 22 | |
23 | +@ApiModel | |
21 | 24 | @Data |
22 | 25 | public class DeviceInfo extends Device { |
23 | 26 | |
27 | + @ApiModelProperty(position = 13, value = "Title of the Customer that owns the device.", readOnly = true) | |
24 | 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 | 30 | private boolean customerIsPublic; |
31 | + @ApiModelProperty(position = 15, value = "Name of the corresponding Device Profile.", readOnly = true) | |
26 | 32 | private String deviceProfileName; |
27 | 33 | |
28 | 34 | public DeviceInfo() { | ... | ... |
... | ... | @@ -15,6 +15,8 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.device; |
17 | 17 | |
18 | +import io.swagger.annotations.ApiModel; | |
19 | +import io.swagger.annotations.ApiModelProperty; | |
18 | 20 | import lombok.Data; |
19 | 21 | import org.thingsboard.server.common.data.EntityType; |
20 | 22 | import org.thingsboard.server.common.data.relation.EntityRelation; |
... | ... | @@ -25,11 +27,15 @@ import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
25 | 27 | import java.util.Collections; |
26 | 28 | import java.util.List; |
27 | 29 | |
30 | +@ApiModel | |
28 | 31 | @Data |
29 | 32 | public class DeviceSearchQuery { |
30 | 33 | |
34 | + @ApiModelProperty(position = 3, value = "Main search parameters.") | |
31 | 35 | private RelationsSearchParameters parameters; |
36 | + @ApiModelProperty(position = 1, value = "Type of the relation between root entity and device (e.g. 'Contains' or 'Manages').") | |
32 | 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 | 39 | private List<String> deviceTypes; |
34 | 40 | |
35 | 41 | public EntityRelationsQuery toEntitySearchQuery() { | ... | ... |
... | ... | @@ -17,12 +17,15 @@ package org.thingsboard.server.common.data.page; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | +import io.swagger.annotations.ApiModel; | |
21 | +import io.swagger.annotations.ApiModelProperty; | |
20 | 22 | |
21 | 23 | import java.util.Collections; |
22 | 24 | import java.util.List; |
23 | 25 | import java.util.function.Function; |
24 | 26 | import java.util.stream.Collectors; |
25 | 27 | |
28 | +@ApiModel | |
26 | 29 | public class PageData<T> { |
27 | 30 | |
28 | 31 | private final List<T> data; |
... | ... | @@ -45,18 +48,22 @@ public class PageData<T> { |
45 | 48 | this.hasNext = hasNext; |
46 | 49 | } |
47 | 50 | |
51 | + @ApiModelProperty(position = 1, value = "Array of the entities.", readOnly = true) | |
48 | 52 | public List<T> getData() { |
49 | 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 | 57 | public int getTotalPages() { |
53 | 58 | return totalPages; |
54 | 59 | } |
55 | 60 | |
61 | + @ApiModelProperty(position = 3, value = "Total number of elements in all available pages.", readOnly = true) | |
56 | 62 | public long getTotalElements() { |
57 | 63 | return totalElements; |
58 | 64 | } |
59 | 65 | |
66 | + @ApiModelProperty(position = 4, value = "'false' value indicates the end of the result set.", readOnly = true) | |
60 | 67 | @JsonProperty("hasNext") |
61 | 68 | public boolean hasNext() { |
62 | 69 | return hasNext; | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/relation/RelationsSearchParameters.java
... | ... | @@ -15,6 +15,8 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.relation; |
17 | 17 | |
18 | +import io.swagger.annotations.ApiModel; | |
19 | +import io.swagger.annotations.ApiModelProperty; | |
18 | 20 | import lombok.AllArgsConstructor; |
19 | 21 | import lombok.Data; |
20 | 22 | import org.thingsboard.server.common.data.EntityType; |
... | ... | @@ -26,15 +28,22 @@ import java.util.UUID; |
26 | 28 | /** |
27 | 29 | * Created by ashvayka on 03.05.17. |
28 | 30 | */ |
31 | +@ApiModel | |
29 | 32 | @Data |
30 | 33 | @AllArgsConstructor |
31 | 34 | public class RelationsSearchParameters { |
32 | 35 | |
36 | + @ApiModelProperty(position = 1, value = "Root entity id to start search from.") | |
33 | 37 | private UUID rootId; |
38 | + @ApiModelProperty(position = 2, value = "Type of the root entity.") | |
34 | 39 | private EntityType rootType; |
40 | + @ApiModelProperty(position = 3, value = "Type of the root entity.") | |
35 | 41 | private EntitySearchDirection direction; |
42 | + @ApiModelProperty(position = 4, value = "Type of the relation.") | |
36 | 43 | private RelationTypeGroup relationTypeGroup; |
44 | + @ApiModelProperty(position = 5, value = "Maximum level of the search depth.") | |
37 | 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 | 47 | private boolean fetchLastLevelOnly; |
39 | 48 | |
40 | 49 | public RelationsSearchParameters(EntityId entityId, EntitySearchDirection direction, int maxLevel, boolean fetchLastLevelOnly) { | ... | ... |