Showing
7 changed files
with
133 additions
and
19 deletions
... | ... | @@ -23,6 +23,7 @@ public class ControllerConstants { |
23 | 23 | protected static final String CUSTOMER_ID = "customerId"; |
24 | 24 | protected static final String TENANT_ID = "tenantId"; |
25 | 25 | protected static final String DEVICE_ID = "deviceId"; |
26 | + protected static final String EDGE_ID = "edgeId"; | |
26 | 27 | protected static final String RPC_ID = "rpcId"; |
27 | 28 | protected static final String ENTITY_ID = "entityId"; |
28 | 29 | protected static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " + | ... | ... |
... | ... | @@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.id.EdgeId; |
51 | 51 | import org.thingsboard.server.common.data.id.TenantId; |
52 | 52 | import org.thingsboard.server.common.data.page.PageData; |
53 | 53 | import org.thingsboard.server.common.data.page.PageLink; |
54 | -import org.thingsboard.server.common.data.page.TimePageLink; | |
55 | 54 | import org.thingsboard.server.queue.util.TbCoreComponent; |
56 | 55 | import org.thingsboard.server.service.security.model.SecurityUser; |
57 | 56 | import org.thingsboard.server.service.security.permission.Operation; |
... | ... | @@ -69,6 +68,8 @@ import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_SO |
69 | 68 | import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_TEXT_SEARCH_DESCRIPTION; |
70 | 69 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; |
71 | 70 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION; |
71 | +import static org.thingsboard.server.controller.ControllerConstants.EDGE_ID; | |
72 | +import static org.thingsboard.server.controller.ControllerConstants.EDGE_ID_PARAM_DESCRIPTION; | |
72 | 73 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; |
73 | 74 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION; |
74 | 75 | import static org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS; |
... | ... | @@ -906,24 +907,32 @@ public class DashboardController extends BaseController { |
906 | 907 | } |
907 | 908 | } |
908 | 909 | |
910 | + @ApiOperation(value = "Get Edge Dashboards (getEdgeDashboards)", | |
911 | + notes = "Returns a page of dashboard info objects assigned to the specified edge. " | |
912 | + + DASHBOARD_INFO_DEFINITION + " " + PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, | |
913 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
909 | 914 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
910 | 915 | @RequestMapping(value = "/edge/{edgeId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) |
911 | 916 | @ResponseBody |
912 | 917 | public PageData<DashboardInfo> getEdgeDashboards( |
913 | - @PathVariable("edgeId") String strEdgeId, | |
918 | + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) | |
919 | + @PathVariable(EDGE_ID) String strEdgeId, | |
920 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) | |
914 | 921 | @RequestParam int pageSize, |
922 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | |
915 | 923 | @RequestParam int page, |
924 | + @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION) | |
916 | 925 | @RequestParam(required = false) String textSearch, |
926 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) | |
917 | 927 | @RequestParam(required = false) String sortProperty, |
918 | - @RequestParam(required = false) String sortOrder, | |
919 | - @RequestParam(required = false) Long startTime, | |
920 | - @RequestParam(required = false) Long endTime) throws ThingsboardException { | |
928 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
929 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
921 | 930 | checkParameter("edgeId", strEdgeId); |
922 | 931 | try { |
923 | 932 | TenantId tenantId = getCurrentUser().getTenantId(); |
924 | 933 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
925 | 934 | checkEdgeId(edgeId, Operation.READ); |
926 | - TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime); | |
935 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
927 | 936 | PageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink); |
928 | 937 | List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboardInfo -> { |
929 | 938 | try { | ... | ... |
... | ... | @@ -452,17 +452,17 @@ public class EdgeController extends BaseController { |
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | - @ApiOperation(value = "Set root rule chain for provided edge (setRootRuleChain)", | |
455 | + @ApiOperation(value = "Set root rule chain for provided edge (setEdgeRootRuleChain)", | |
456 | 456 | notes = "Change root rule chain of the edge to the new provided rule chain. \n" + |
457 | 457 | "This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH, |
458 | 458 | produces = MediaType.APPLICATION_JSON_VALUE) |
459 | 459 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
460 | 460 | @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) |
461 | 461 | @ResponseBody |
462 | - public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) | |
463 | - @PathVariable(EDGE_ID) String strEdgeId, | |
464 | - @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true) | |
465 | - @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException { | |
462 | + public Edge setEdgeRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) | |
463 | + @PathVariable(EDGE_ID) String strEdgeId, | |
464 | + @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true) | |
465 | + @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException { | |
466 | 466 | checkParameter(EDGE_ID, strEdgeId); |
467 | 467 | checkParameter("ruleChainId", strRuleChainId); |
468 | 468 | try { |
... | ... | @@ -736,6 +736,9 @@ public class EdgeController extends BaseController { |
736 | 736 | edge.setEdgeLicenseKey(null); |
737 | 737 | } |
738 | 738 | |
739 | + @ApiOperation(value = "Check edge license (checkInstance)", | |
740 | + notes = "Checks license request from edge service by forwarding request to license portal.", | |
741 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
739 | 742 | @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) |
740 | 743 | @ResponseBody |
741 | 744 | public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException { |
... | ... | @@ -748,6 +751,9 @@ public class EdgeController extends BaseController { |
748 | 751 | } |
749 | 752 | } |
750 | 753 | |
754 | + @ApiOperation(value = "Activate edge instance (activateInstance)", | |
755 | + notes = "Activates edge license on license portal.", | |
756 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
751 | 757 | @RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) |
752 | 758 | @ResponseBody |
753 | 759 | public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret, | ... | ... |
... | ... | @@ -83,6 +83,8 @@ import java.util.stream.Collectors; |
83 | 83 | |
84 | 84 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; |
85 | 85 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION; |
86 | +import static org.thingsboard.server.controller.ControllerConstants.EDGE_ID; | |
87 | +import static org.thingsboard.server.controller.ControllerConstants.EDGE_ID_PARAM_DESCRIPTION; | |
86 | 88 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; |
87 | 89 | import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION; |
88 | 90 | import static org.thingsboard.server.controller.ControllerConstants.MARKDOWN_CODE_BLOCK_END; |
... | ... | @@ -676,17 +678,25 @@ public class RuleChainController extends BaseController { |
676 | 678 | } |
677 | 679 | } |
678 | 680 | |
681 | + @ApiOperation(value = "Get Edge Rule Chains (getEdgeRuleChains)", | |
682 | + notes = "Returns a page of Rule Chains assigned to the specified edge. " + RULE_CHAIN_DESCRIPTION + PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH) | |
679 | 683 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
680 | 684 | @RequestMapping(value = "/edge/{edgeId}/ruleChains", params = {"pageSize", "page"}, method = RequestMethod.GET) |
681 | 685 | @ResponseBody |
682 | 686 | public PageData<RuleChain> getEdgeRuleChains( |
683 | - @PathVariable("edgeId") String strEdgeId, | |
687 | + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) | |
688 | + @PathVariable(EDGE_ID) String strEdgeId, | |
689 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) | |
684 | 690 | @RequestParam int pageSize, |
691 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | |
685 | 692 | @RequestParam int page, |
693 | + @ApiParam(value = RULE_CHAIN_TEXT_SEARCH_DESCRIPTION) | |
686 | 694 | @RequestParam(required = false) String textSearch, |
695 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = RULE_CHAIN_SORT_PROPERTY_ALLOWABLE_VALUES) | |
687 | 696 | @RequestParam(required = false) String sortProperty, |
697 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
688 | 698 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
689 | - checkParameter("edgeId", strEdgeId); | |
699 | + checkParameter(EDGE_ID, strEdgeId); | |
690 | 700 | try { |
691 | 701 | TenantId tenantId = getCurrentUser().getTenantId(); |
692 | 702 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -698,10 +708,14 @@ public class RuleChainController extends BaseController { |
698 | 708 | } |
699 | 709 | } |
700 | 710 | |
711 | + @ApiOperation(value = "Set Edge Template Root Rule Chain (setEdgeTemplateRootRuleChain)", | |
712 | + notes = "Makes the rule chain to be root rule chain for any new edge that will be created. " + | |
713 | + "Does not update root rule chain for already created edges. " + TENANT_AUTHORITY_PARAGRAPH) | |
701 | 714 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
702 | 715 | @RequestMapping(value = "/ruleChain/{ruleChainId}/edgeTemplateRoot", method = RequestMethod.POST) |
703 | 716 | @ResponseBody |
704 | - public RuleChain setEdgeTemplateRootRuleChain(@PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
717 | + public RuleChain setEdgeTemplateRootRuleChain(@ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION) | |
718 | + @PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
705 | 719 | checkParameter(RULE_CHAIN_ID, strRuleChainId); |
706 | 720 | try { |
707 | 721 | RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); |
... | ... | @@ -717,10 +731,14 @@ public class RuleChainController extends BaseController { |
717 | 731 | } |
718 | 732 | } |
719 | 733 | |
734 | + @ApiOperation(value = "Set Auto Assign To Edge Rule Chain (setAutoAssignToEdgeRuleChain)", | |
735 | + notes = "Makes the rule chain to be automatically assigned for any new edge that will be created. " + | |
736 | + "Does not assign this rule chain for already created edges. " + TENANT_AUTHORITY_PARAGRAPH) | |
720 | 737 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
721 | 738 | @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.POST) |
722 | 739 | @ResponseBody |
723 | - public RuleChain setAutoAssignToEdgeRuleChain(@PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
740 | + public RuleChain setAutoAssignToEdgeRuleChain(@ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION) | |
741 | + @PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
724 | 742 | checkParameter(RULE_CHAIN_ID, strRuleChainId); |
725 | 743 | try { |
726 | 744 | RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); |
... | ... | @@ -736,10 +754,14 @@ public class RuleChainController extends BaseController { |
736 | 754 | } |
737 | 755 | } |
738 | 756 | |
757 | + @ApiOperation(value = "Unset Auto Assign To Edge Rule Chain (unsetAutoAssignToEdgeRuleChain)", | |
758 | + notes = "Removes the rule chain from the list of rule chains that are going to be automatically assigned for any new edge that will be created. " + | |
759 | + "Does not unassign this rule chain for already assigned edges. " + TENANT_AUTHORITY_PARAGRAPH) | |
739 | 760 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
740 | 761 | @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.DELETE) |
741 | 762 | @ResponseBody |
742 | - public RuleChain unsetAutoAssignToEdgeRuleChain(@PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
763 | + public RuleChain unsetAutoAssignToEdgeRuleChain(@ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION) | |
764 | + @PathVariable(RULE_CHAIN_ID) String strRuleChainId) throws ThingsboardException { | |
743 | 765 | checkParameter(RULE_CHAIN_ID, strRuleChainId); |
744 | 766 | try { |
745 | 767 | RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); |
... | ... | @@ -756,6 +778,8 @@ public class RuleChainController extends BaseController { |
756 | 778 | } |
757 | 779 | |
758 | 780 | // TODO: @voba refactor this - add new config to edge rule chain to set it as auto-assign |
781 | + @ApiOperation(value = "Get Auto Assign To Edge Rule Chains (getAutoAssignToEdgeRuleChains)", | |
782 | + notes = "Returns a list of Rule Chains that will be assigned to a newly created edge. " + RULE_CHAIN_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH) | |
759 | 783 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
760 | 784 | @RequestMapping(value = "/ruleChain/autoAssignToEdgeRuleChains", method = RequestMethod.GET) |
761 | 785 | @ResponseBody | ... | ... |
... | ... | @@ -15,8 +15,9 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | |
18 | +import io.swagger.annotations.ApiModel; | |
19 | +import io.swagger.annotations.ApiModelProperty; | |
18 | 20 | import lombok.EqualsAndHashCode; |
19 | -import lombok.Getter; | |
20 | 21 | import lombok.Setter; |
21 | 22 | import lombok.ToString; |
22 | 23 | import org.thingsboard.server.common.data.HasCustomerId; |
... | ... | @@ -28,9 +29,9 @@ import org.thingsboard.server.common.data.id.EdgeId; |
28 | 29 | import org.thingsboard.server.common.data.id.RuleChainId; |
29 | 30 | import org.thingsboard.server.common.data.id.TenantId; |
30 | 31 | |
32 | +@ApiModel | |
31 | 33 | @EqualsAndHashCode(callSuper = true) |
32 | 34 | @ToString |
33 | -@Getter | |
34 | 35 | @Setter |
35 | 36 | public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements HasName, HasTenantId, HasCustomerId { |
36 | 37 | |
... | ... | @@ -82,8 +83,77 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H |
82 | 83 | this.cloudEndpoint = edge.getCloudEndpoint(); |
83 | 84 | } |
84 | 85 | |
86 | + @ApiModelProperty(position = 1, value = "JSON object with the Edge Id. " + | |
87 | + "Specify this field to update the Edge. " + | |
88 | + "Referencing non-existing Edge Id will cause error. " + | |
89 | + "Omit this field to create new Edge." ) | |
90 | + @Override | |
91 | + public EdgeId getId() { | |
92 | + return super.getId(); | |
93 | + } | |
94 | + | |
95 | + @ApiModelProperty(position = 2, value = "Timestamp of the edge creation, in milliseconds", example = "1609459200000", readOnly = true) | |
96 | + @Override | |
97 | + public long getCreatedTime() { | |
98 | + return super.getCreatedTime(); | |
99 | + } | |
100 | + | |
101 | + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id. Use 'assignDeviceToTenant' to change the Tenant Id.", readOnly = true) | |
102 | + @Override | |
103 | + public TenantId getTenantId() { | |
104 | + return this.tenantId; | |
105 | + } | |
106 | + | |
107 | + @ApiModelProperty(position = 4, value = "JSON object with Customer Id. Use 'assignEdgeToCustomer' to change the Customer Id.", readOnly = true) | |
108 | + @Override | |
109 | + public CustomerId getCustomerId() { | |
110 | + return this.customerId; | |
111 | + } | |
112 | + | |
113 | + @ApiModelProperty(position = 5, value = "JSON object with Root Rule Chain Id. Use 'setEdgeRootRuleChain' to change the Root Rule Chain Id.", readOnly = true) | |
114 | + public RuleChainId getRootRuleChainId() { | |
115 | + return this.rootRuleChainId; | |
116 | + } | |
117 | + | |
118 | + @ApiModelProperty(position = 6, required = true, value = "Unique Edge Name in scope of Tenant", example = "Silo_A_Edge") | |
119 | + @Override | |
120 | + public String getName() { | |
121 | + return this.name; | |
122 | + } | |
123 | + | |
124 | + @ApiModelProperty(position = 7, required = true, value = "Edge type", example = "Silos") | |
125 | + public String getType() { | |
126 | + return this.type; | |
127 | + } | |
128 | + | |
129 | + @ApiModelProperty(position = 8, value = "Label that may be used in widgets", example = "Silo Edge on far field") | |
130 | + public String getLabel() { | |
131 | + return this.label; | |
132 | + } | |
133 | + | |
85 | 134 | @Override |
86 | 135 | public String getSearchText() { |
87 | 136 | return getName(); |
88 | 137 | } |
138 | + | |
139 | + @ApiModelProperty(position = 9, required = true, value = "Edge routing key ('username') to authorize on cloud") | |
140 | + public String getRoutingKey() { | |
141 | + return this.routingKey; | |
142 | + } | |
143 | + | |
144 | + @ApiModelProperty(position = 10, required = true, value = "Edge secret ('password') to authorize on cloud") | |
145 | + public String getSecret() { | |
146 | + return this.secret; | |
147 | + } | |
148 | + | |
149 | + @ApiModelProperty(position = 11, required = true, value = "Edge license key obtained from license portal", example = "AgcnI24Z06XC&m6Sxsdgf") | |
150 | + public String getEdgeLicenseKey() { | |
151 | + return this.edgeLicenseKey; | |
152 | + } | |
153 | + | |
154 | + @ApiModelProperty(position = 12, required = true, value = "Edge uses this cloud URL to activate and periodically check it's license", example = "https://thingsboard.cloud") | |
155 | + public String getCloudEndpoint() { | |
156 | + return this.cloudEndpoint; | |
157 | + } | |
158 | + | |
89 | 159 | } | ... | ... |
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | |
18 | +import io.swagger.annotations.ApiModelProperty; | |
18 | 19 | import lombok.Data; |
19 | 20 | import org.thingsboard.server.common.data.EntityType; |
20 | 21 | import org.thingsboard.server.common.data.relation.EntityRelation; |
... | ... | @@ -28,8 +29,11 @@ import java.util.List; |
28 | 29 | @Data |
29 | 30 | public class EdgeSearchQuery { |
30 | 31 | |
32 | + @ApiModelProperty(position = 3, value = "Main search parameters.") | |
31 | 33 | private RelationsSearchParameters parameters; |
34 | + @ApiModelProperty(position = 1, value = "Type of the relation between root entity and edge (e.g. 'Contains' or 'Manages').") | |
32 | 35 | private String relationType; |
36 | + @ApiModelProperty(position = 2, value = "Array of edge types to filter the related entities (e.g. 'Silos', 'Stores').") | |
33 | 37 | private List<String> edgeTypes; |
34 | 38 | |
35 | 39 | public EntityRelationsQuery toEntitySearchQuery() { | ... | ... |