Commit 3490045f964367f96bdc11a985a6704c4bef7dea

Authored by Andrew Shvayka
Committed by GitHub
2 parents ba9ad04a 757eef1c

Merge pull request #5461 from volodymyr-babak/master

[3.2.2] Edge Swagger docs - part 2
@@ -542,7 +542,7 @@ public class AssetController extends BaseController { @@ -542,7 +542,7 @@ public class AssetController extends BaseController {
542 notes = "Creates assignment of an existing asset to an instance of The Edge. " + 542 notes = "Creates assignment of an existing asset to an instance of The Edge. " +
543 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 543 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
544 "Second, remote edge service will receive a copy of assignment asset " + 544 "Second, remote edge service will receive a copy of assignment asset " +
545 - EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 545 + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION +
546 "Third, once asset will be delivered to edge service, it's going to be available for usage on remote edge instance.", 546 "Third, once asset will be delivered to edge service, it's going to be available for usage on remote edge instance.",
547 produces = MediaType.APPLICATION_JSON_VALUE) 547 produces = MediaType.APPLICATION_JSON_VALUE)
548 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 548 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -582,7 +582,7 @@ public class AssetController extends BaseController { @@ -582,7 +582,7 @@ public class AssetController extends BaseController {
582 notes = "Clears assignment of the asset to the edge. " + 582 notes = "Clears assignment of the asset to the edge. " +
583 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 583 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
584 "Second, remote edge service will receive an 'unassign' command to remove asset " + 584 "Second, remote edge service will receive an 'unassign' command to remove asset " +
585 - EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 585 + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION +
586 "Third, once 'unassign' command will be delivered to edge service, it's going to remove asset locally.", 586 "Third, once 'unassign' command will be delivered to edge service, it's going to remove asset locally.",
587 produces = MediaType.APPLICATION_JSON_VALUE) 587 produces = MediaType.APPLICATION_JSON_VALUE)
588 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 588 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -23,6 +23,7 @@ public class ControllerConstants { @@ -23,6 +23,7 @@ public class ControllerConstants {
23 protected static final String CUSTOMER_ID = "customerId"; 23 protected static final String CUSTOMER_ID = "customerId";
24 protected static final String TENANT_ID = "tenantId"; 24 protected static final String TENANT_ID = "tenantId";
25 protected static final String DEVICE_ID = "deviceId"; 25 protected static final String DEVICE_ID = "deviceId";
  26 + protected static final String EDGE_ID = "edgeId";
26 protected static final String RPC_ID = "rpcId"; 27 protected static final String RPC_ID = "rpcId";
27 protected static final String ENTITY_ID = "entityId"; 28 protected static final String ENTITY_ID = "entityId";
28 protected static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " + 29 protected static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " +
@@ -128,9 +129,9 @@ public class ControllerConstants { @@ -128,9 +129,9 @@ public class ControllerConstants {
128 protected static final String EVENT_END_TIME_DESCRIPTION = "Timestamp. Events with creation time after it won't be queried."; 129 protected static final String EVENT_END_TIME_DESCRIPTION = "Timestamp. Events with creation time after it won't be queried.";
129 130
130 protected static final String EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION = "Unassignment works in async way - first, 'unassign' notification event pushed to edge queue on platform. "; 131 protected static final String EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION = "Unassignment works in async way - first, 'unassign' notification event pushed to edge queue on platform. ";
131 - protected static final String EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION = "(Edge will receive this instantly, if it's currently connected, or once it's going to be connected to platform)"; 132 + protected static final String EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION = "(Edge will receive this instantly, if it's currently connected, or once it's going to be connected to platform). ";
132 protected static final String EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION = "Assignment works in async way - first, notification event pushed to edge service queue on platform. "; 133 protected static final String EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION = "Assignment works in async way - first, notification event pushed to edge service queue on platform. ";
133 - protected static final String EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION = "(Edge will receive this instantly, if it's currently connected, or once it's going to be connected to platform)"; 134 + protected static final String EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION = "(Edge will receive this instantly, if it's currently connected, or once it's going to be connected to platform). ";
134 135
135 protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n"; 136 protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n";
136 protected static final String MARKDOWN_CODE_BLOCK_END = "\n```"; 137 protected static final String MARKDOWN_CODE_BLOCK_END = "\n```";
@@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.id.EdgeId; @@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.id.EdgeId;
51 import org.thingsboard.server.common.data.id.TenantId; 51 import org.thingsboard.server.common.data.id.TenantId;
52 import org.thingsboard.server.common.data.page.PageData; 52 import org.thingsboard.server.common.data.page.PageData;
53 import org.thingsboard.server.common.data.page.PageLink; 53 import org.thingsboard.server.common.data.page.PageLink;
54 -import org.thingsboard.server.common.data.page.TimePageLink;  
55 import org.thingsboard.server.queue.util.TbCoreComponent; 54 import org.thingsboard.server.queue.util.TbCoreComponent;
56 import org.thingsboard.server.service.security.model.SecurityUser; 55 import org.thingsboard.server.service.security.model.SecurityUser;
57 import org.thingsboard.server.service.security.permission.Operation; 56 import org.thingsboard.server.service.security.permission.Operation;
@@ -69,6 +68,8 @@ import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_SO @@ -69,6 +68,8 @@ import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_SO
69 import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_TEXT_SEARCH_DESCRIPTION; 68 import static org.thingsboard.server.controller.ControllerConstants.DASHBOARD_TEXT_SEARCH_DESCRIPTION;
70 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; 69 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
71 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION; 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 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; 73 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
73 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION; 74 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION;
74 import static org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS; 75 import static org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS;
@@ -829,7 +830,7 @@ public class DashboardController extends BaseController { @@ -829,7 +830,7 @@ public class DashboardController extends BaseController {
829 notes = "Creates assignment of an existing dashboard to an instance of The Edge. " + 830 notes = "Creates assignment of an existing dashboard to an instance of The Edge. " +
830 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 831 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
831 "Second, remote edge service will receive a copy of assignment dashboard " + 832 "Second, remote edge service will receive a copy of assignment dashboard " +
832 - EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 833 + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION +
833 "Third, once dashboard will be delivered to edge service, it's going to be available for usage on remote edge instance." + 834 "Third, once dashboard will be delivered to edge service, it's going to be available for usage on remote edge instance." +
834 TENANT_AUTHORITY_PARAGRAPH, 835 TENANT_AUTHORITY_PARAGRAPH,
835 produces = MediaType.APPLICATION_JSON_VALUE) 836 produces = MediaType.APPLICATION_JSON_VALUE)
@@ -870,7 +871,7 @@ public class DashboardController extends BaseController { @@ -870,7 +871,7 @@ public class DashboardController extends BaseController {
870 notes = "Clears assignment of the dashboard to the edge. " + 871 notes = "Clears assignment of the dashboard to the edge. " +
871 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 872 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
872 "Second, remote edge service will receive an 'unassign' command to remove dashboard " + 873 "Second, remote edge service will receive an 'unassign' command to remove dashboard " +
873 - EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 874 + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION +
874 "Third, once 'unassign' command will be delivered to edge service, it's going to remove dashboard locally." + 875 "Third, once 'unassign' command will be delivered to edge service, it's going to remove dashboard locally." +
875 TENANT_AUTHORITY_PARAGRAPH, 876 TENANT_AUTHORITY_PARAGRAPH,
876 produces = MediaType.APPLICATION_JSON_VALUE) 877 produces = MediaType.APPLICATION_JSON_VALUE)
@@ -906,24 +907,32 @@ public class DashboardController extends BaseController { @@ -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 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 914 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
910 @RequestMapping(value = "/edge/{edgeId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) 915 @RequestMapping(value = "/edge/{edgeId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET)
911 @ResponseBody 916 @ResponseBody
912 public PageData<DashboardInfo> getEdgeDashboards( 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 @RequestParam int pageSize, 921 @RequestParam int pageSize,
  922 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
915 @RequestParam int page, 923 @RequestParam int page,
  924 + @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION)
916 @RequestParam(required = false) String textSearch, 925 @RequestParam(required = false) String textSearch,
  926 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES)
917 @RequestParam(required = false) String sortProperty, 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 checkParameter("edgeId", strEdgeId); 930 checkParameter("edgeId", strEdgeId);
922 try { 931 try {
923 TenantId tenantId = getCurrentUser().getTenantId(); 932 TenantId tenantId = getCurrentUser().getTenantId();
924 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 933 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
925 checkEdgeId(edgeId, Operation.READ); 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 PageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink); 936 PageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink);
928 List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboardInfo -> { 937 List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboardInfo -> {
929 try { 938 try {
@@ -849,7 +849,7 @@ public class DeviceController extends BaseController { @@ -849,7 +849,7 @@ public class DeviceController extends BaseController {
849 notes = "Creates assignment of an existing device to an instance of The Edge. " + 849 notes = "Creates assignment of an existing device to an instance of The Edge. " +
850 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 850 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
851 "Second, remote edge service will receive a copy of assignment device " + 851 "Second, remote edge service will receive a copy of assignment device " +
852 - EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 852 + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION +
853 "Third, once device will be delivered to edge service, it's going to be available for usage on remote edge instance." + TENANT_AUTHORITY_PARAGRAPH, 853 "Third, once device will be delivered to edge service, it's going to be available for usage on remote edge instance." + TENANT_AUTHORITY_PARAGRAPH,
854 produces = MediaType.APPLICATION_JSON_VALUE) 854 produces = MediaType.APPLICATION_JSON_VALUE)
855 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 855 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -892,7 +892,7 @@ public class DeviceController extends BaseController { @@ -892,7 +892,7 @@ public class DeviceController extends BaseController {
892 notes = "Clears assignment of the device to the edge. " + 892 notes = "Clears assignment of the device to the edge. " +
893 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 893 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
894 "Second, remote edge service will receive an 'unassign' command to remove device " + 894 "Second, remote edge service will receive an 'unassign' command to remove device " +
895 - EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 895 + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION +
896 "Third, once 'unassign' command will be delivered to edge service, it's going to remove device locally." + TENANT_AUTHORITY_PARAGRAPH, 896 "Third, once 'unassign' command will be delivered to edge service, it's going to remove device locally." + TENANT_AUTHORITY_PARAGRAPH,
897 produces = MediaType.APPLICATION_JSON_VALUE) 897 produces = MediaType.APPLICATION_JSON_VALUE)
898 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 898 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -452,17 +452,17 @@ public class EdgeController extends BaseController { @@ -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 notes = "Change root rule chain of the edge to the new provided rule chain. \n" + 456 notes = "Change root rule chain of the edge to the new provided rule chain. \n" +
457 "This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH, 457 "This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH,
458 produces = MediaType.APPLICATION_JSON_VALUE) 458 produces = MediaType.APPLICATION_JSON_VALUE)
459 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 459 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
460 @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) 460 @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
461 @ResponseBody 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 checkParameter(EDGE_ID, strEdgeId); 466 checkParameter(EDGE_ID, strEdgeId);
467 checkParameter("ruleChainId", strRuleChainId); 467 checkParameter("ruleChainId", strRuleChainId);
468 try { 468 try {
@@ -736,6 +736,9 @@ public class EdgeController extends BaseController { @@ -736,6 +736,9 @@ public class EdgeController extends BaseController {
736 edge.setEdgeLicenseKey(null); 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 @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) 742 @RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST)
740 @ResponseBody 743 @ResponseBody
741 public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException { 744 public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException {
@@ -748,6 +751,9 @@ public class EdgeController extends BaseController { @@ -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 @RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) 757 @RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST)
752 @ResponseBody 758 @ResponseBody
753 public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret, 759 public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret,
@@ -728,7 +728,7 @@ public class EntityViewController extends BaseController { @@ -728,7 +728,7 @@ public class EntityViewController extends BaseController {
728 notes = "Creates assignment of an existing entity view to an instance of The Edge. " + 728 notes = "Creates assignment of an existing entity view to an instance of The Edge. " +
729 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 729 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
730 "Second, remote edge service will receive a copy of assignment entity view " + 730 "Second, remote edge service will receive a copy of assignment entity view " +
731 - EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 731 + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION +
732 "Third, once entity view will be delivered to edge service, it's going to be available for usage on remote edge instance.", 732 "Third, once entity view will be delivered to edge service, it's going to be available for usage on remote edge instance.",
733 produces = MediaType.APPLICATION_JSON_VALUE) 733 produces = MediaType.APPLICATION_JSON_VALUE)
734 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 734 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -765,7 +765,7 @@ public class EntityViewController extends BaseController { @@ -765,7 +765,7 @@ public class EntityViewController extends BaseController {
765 notes = "Clears assignment of the entity view to the edge. " + 765 notes = "Clears assignment of the entity view to the edge. " +
766 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 766 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
767 "Second, remote edge service will receive an 'unassign' command to remove entity view " + 767 "Second, remote edge service will receive an 'unassign' command to remove entity view " +
768 - EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 768 + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION +
769 "Third, once 'unassign' command will be delivered to edge service, it's going to remove entity view locally.", 769 "Third, once 'unassign' command will be delivered to edge service, it's going to remove entity view locally.",
770 produces = MediaType.APPLICATION_JSON_VALUE) 770 produces = MediaType.APPLICATION_JSON_VALUE)
771 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 771 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -83,6 +83,8 @@ import java.util.stream.Collectors; @@ -83,6 +83,8 @@ import java.util.stream.Collectors;
83 83
84 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; 84 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
85 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION; 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 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION; 88 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
87 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION; 89 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION;
88 import static org.thingsboard.server.controller.ControllerConstants.MARKDOWN_CODE_BLOCK_END; 90 import static org.thingsboard.server.controller.ControllerConstants.MARKDOWN_CODE_BLOCK_END;
@@ -600,7 +602,7 @@ public class RuleChainController extends BaseController { @@ -600,7 +602,7 @@ public class RuleChainController extends BaseController {
600 notes = "Creates assignment of an existing rule chain to an instance of The Edge. " + 602 notes = "Creates assignment of an existing rule chain to an instance of The Edge. " +
601 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 603 EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
602 "Second, remote edge service will receive a copy of assignment rule chain " + 604 "Second, remote edge service will receive a copy of assignment rule chain " +
603 - EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 605 + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION +
604 "Third, once rule chain will be delivered to edge service, it's going to start processing messages locally. " + 606 "Third, once rule chain will be delivered to edge service, it's going to start processing messages locally. " +
605 "\n\nOnly rule chain with type 'EDGE' can be assigned to edge." + TENANT_AUTHORITY_PARAGRAPH, 607 "\n\nOnly rule chain with type 'EDGE' can be assigned to edge." + TENANT_AUTHORITY_PARAGRAPH,
606 produces = MediaType.APPLICATION_JSON_VALUE) 608 produces = MediaType.APPLICATION_JSON_VALUE)
@@ -641,7 +643,7 @@ public class RuleChainController extends BaseController { @@ -641,7 +643,7 @@ public class RuleChainController extends BaseController {
641 notes = "Clears assignment of the rule chain to the edge. " + 643 notes = "Clears assignment of the rule chain to the edge. " +
642 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + 644 EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION +
643 "Second, remote edge service will receive an 'unassign' command to remove rule chain " + 645 "Second, remote edge service will receive an 'unassign' command to remove rule chain " +
644 - EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + 646 + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION +
645 "Third, once 'unassign' command will be delivered to edge service, it's going to remove rule chain locally." + TENANT_AUTHORITY_PARAGRAPH, 647 "Third, once 'unassign' command will be delivered to edge service, it's going to remove rule chain locally." + TENANT_AUTHORITY_PARAGRAPH,
646 produces = MediaType.APPLICATION_JSON_VALUE) 648 produces = MediaType.APPLICATION_JSON_VALUE)
647 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 649 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
@@ -676,17 +678,25 @@ public class RuleChainController extends BaseController { @@ -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 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 683 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
680 @RequestMapping(value = "/edge/{edgeId}/ruleChains", params = {"pageSize", "page"}, method = RequestMethod.GET) 684 @RequestMapping(value = "/edge/{edgeId}/ruleChains", params = {"pageSize", "page"}, method = RequestMethod.GET)
681 @ResponseBody 685 @ResponseBody
682 public PageData<RuleChain> getEdgeRuleChains( 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 @RequestParam int pageSize, 690 @RequestParam int pageSize,
  691 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
685 @RequestParam int page, 692 @RequestParam int page,
  693 + @ApiParam(value = RULE_CHAIN_TEXT_SEARCH_DESCRIPTION)
686 @RequestParam(required = false) String textSearch, 694 @RequestParam(required = false) String textSearch,
  695 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = RULE_CHAIN_SORT_PROPERTY_ALLOWABLE_VALUES)
687 @RequestParam(required = false) String sortProperty, 696 @RequestParam(required = false) String sortProperty,
  697 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
688 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 698 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
689 - checkParameter("edgeId", strEdgeId); 699 + checkParameter(EDGE_ID, strEdgeId);
690 try { 700 try {
691 TenantId tenantId = getCurrentUser().getTenantId(); 701 TenantId tenantId = getCurrentUser().getTenantId();
692 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 702 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
@@ -698,10 +708,14 @@ public class RuleChainController extends BaseController { @@ -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 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 714 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
702 @RequestMapping(value = "/ruleChain/{ruleChainId}/edgeTemplateRoot", method = RequestMethod.POST) 715 @RequestMapping(value = "/ruleChain/{ruleChainId}/edgeTemplateRoot", method = RequestMethod.POST)
703 @ResponseBody 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 checkParameter(RULE_CHAIN_ID, strRuleChainId); 719 checkParameter(RULE_CHAIN_ID, strRuleChainId);
706 try { 720 try {
707 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); 721 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
@@ -717,10 +731,14 @@ public class RuleChainController extends BaseController { @@ -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 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 737 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
721 @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.POST) 738 @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.POST)
722 @ResponseBody 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 checkParameter(RULE_CHAIN_ID, strRuleChainId); 742 checkParameter(RULE_CHAIN_ID, strRuleChainId);
725 try { 743 try {
726 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); 744 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
@@ -736,10 +754,14 @@ public class RuleChainController extends BaseController { @@ -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 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 760 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
740 @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.DELETE) 761 @RequestMapping(value = "/ruleChain/{ruleChainId}/autoAssignToEdge", method = RequestMethod.DELETE)
741 @ResponseBody 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 checkParameter(RULE_CHAIN_ID, strRuleChainId); 765 checkParameter(RULE_CHAIN_ID, strRuleChainId);
744 try { 766 try {
745 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); 767 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
@@ -756,6 +778,8 @@ public class RuleChainController extends BaseController { @@ -756,6 +778,8 @@ public class RuleChainController extends BaseController {
756 } 778 }
757 779
758 // TODO: @voba refactor this - add new config to edge rule chain to set it as auto-assign 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 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 783 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
760 @RequestMapping(value = "/ruleChain/autoAssignToEdgeRuleChains", method = RequestMethod.GET) 784 @RequestMapping(value = "/ruleChain/autoAssignToEdgeRuleChains", method = RequestMethod.GET)
761 @ResponseBody 785 @ResponseBody
@@ -15,8 +15,9 @@ @@ -15,8 +15,9 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.edge; 16 package org.thingsboard.server.common.data.edge;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.EqualsAndHashCode; 20 import lombok.EqualsAndHashCode;
19 -import lombok.Getter;  
20 import lombok.Setter; 21 import lombok.Setter;
21 import lombok.ToString; 22 import lombok.ToString;
22 import org.thingsboard.server.common.data.HasCustomerId; 23 import org.thingsboard.server.common.data.HasCustomerId;
@@ -28,9 +29,9 @@ import org.thingsboard.server.common.data.id.EdgeId; @@ -28,9 +29,9 @@ import org.thingsboard.server.common.data.id.EdgeId;
28 import org.thingsboard.server.common.data.id.RuleChainId; 29 import org.thingsboard.server.common.data.id.RuleChainId;
29 import org.thingsboard.server.common.data.id.TenantId; 30 import org.thingsboard.server.common.data.id.TenantId;
30 31
  32 +@ApiModel
31 @EqualsAndHashCode(callSuper = true) 33 @EqualsAndHashCode(callSuper = true)
32 @ToString 34 @ToString
33 -@Getter  
34 @Setter 35 @Setter
35 public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements HasName, HasTenantId, HasCustomerId { 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,8 +83,77 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H
82 this.cloudEndpoint = edge.getCloudEndpoint(); 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 @Override 134 @Override
86 public String getSearchText() { 135 public String getSearchText() {
87 return getName(); 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,6 +15,7 @@
15 */ 15 */
16 package org.thingsboard.server.common.data.edge; 16 package org.thingsboard.server.common.data.edge;
17 17
  18 +import io.swagger.annotations.ApiModelProperty;
18 import lombok.Data; 19 import lombok.Data;
19 import org.thingsboard.server.common.data.EntityType; 20 import org.thingsboard.server.common.data.EntityType;
20 import org.thingsboard.server.common.data.relation.EntityRelation; 21 import org.thingsboard.server.common.data.relation.EntityRelation;
@@ -28,8 +29,11 @@ import java.util.List; @@ -28,8 +29,11 @@ import java.util.List;
28 @Data 29 @Data
29 public class EdgeSearchQuery { 30 public class EdgeSearchQuery {
30 31
  32 + @ApiModelProperty(position = 3, value = "Main search parameters.")
31 private RelationsSearchParameters parameters; 33 private RelationsSearchParameters parameters;
  34 + @ApiModelProperty(position = 1, value = "Type of the relation between root entity and edge (e.g. 'Contains' or 'Manages').")
32 private String relationType; 35 private String relationType;
  36 + @ApiModelProperty(position = 2, value = "Array of edge types to filter the related entities (e.g. 'Silos', 'Stores').")
33 private List<String> edgeTypes; 37 private List<String> edgeTypes;
34 38
35 public EntityRelationsQuery toEntitySearchQuery() { 39 public EntityRelationsQuery toEntitySearchQuery() {
@@ -737,7 +737,7 @@ @@ -737,7 +737,7 @@
737 "close": "Dialog schließen" 737 "close": "Dialog schließen"
738 }, 738 },
739 "edge": { 739 "edge": {
740 - "edge": "Rand", 740 + "edge": "Edge",
741 "edge-instances": "Kanteninstanzen", 741 "edge-instances": "Kanteninstanzen",
742 "edge-file": "Edge-Datei", 742 "edge-file": "Edge-Datei",
743 "management": "Rand verwalten", 743 "management": "Rand verwalten",