Commit d7c09b9f6721d4b0f713a57058f0b5c8712aabb9
Committed by
Andrew Shvayka
1 parent
f47de8cf
Added Api swagger desc for assing*ToEdge and unassing*FromEdge
Showing
8 changed files
with
79 additions
and
7 deletions
... | ... | @@ -518,8 +518,11 @@ public class AssetController extends BaseController { |
518 | 518 | |
519 | 519 | @ApiOperation(value = "Assign asset to edge (assignAssetToEdge)", |
520 | 520 | notes = "Creates assignment of an existing asset to an instance of The Edge. " + |
521 | - "The Edge is a software product for edge computing. " + | |
522 | - "It allows bringing data analysis and management to the edge, while seamlessly synchronizing with the platform server (cloud). ", produces = MediaType.APPLICATION_JSON_VALUE) | |
521 | + EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
522 | + "Second, remote edge service will receive a copy of assignment asset " + | |
523 | + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
524 | + "Third, once asset will be delivered to edge service, it's going to be available for usage on remote edge instance.", | |
525 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
523 | 526 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
524 | 527 | @RequestMapping(value = "/edge/{edgeId}/asset/{assetId}", method = RequestMethod.POST) |
525 | 528 | @ResponseBody |
... | ... | @@ -554,7 +557,12 @@ public class AssetController extends BaseController { |
554 | 557 | } |
555 | 558 | |
556 | 559 | @ApiOperation(value = "Unassign asset from edge (unassignAssetFromEdge)", |
557 | - notes = "Clears assignment of the asset to the edge", produces = MediaType.APPLICATION_JSON_VALUE) | |
560 | + notes = "Clears assignment of the asset to the edge. " + | |
561 | + EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
562 | + "Second, remote edge service will receive an 'unassign' command to remove asset " + | |
563 | + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
564 | + "Third, once 'unassign' command will be delivered to edge service, it's going to remove asset locally.", | |
565 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
558 | 566 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
559 | 567 | @RequestMapping(value = "/edge/{edgeId}/asset/{assetId}", method = RequestMethod.DELETE) |
560 | 568 | @ResponseBody | ... | ... |
... | ... | @@ -219,6 +219,11 @@ public abstract class BaseController { |
219 | 219 | protected static final String EVENT_START_TIME_DESCRIPTION = "Timestamp. Events with creation time before it won't be queried."; |
220 | 220 | protected static final String EVENT_END_TIME_DESCRIPTION = "Timestamp. Events with creation time after it won't be queried."; |
221 | 221 | |
222 | + 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. "; | |
223 | + 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)" ; | |
224 | + 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. "; | |
225 | + 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)"; | |
226 | + | |
222 | 227 | protected static final String MARKDOWN_CODE_BLOCK_START = "```json\n"; |
223 | 228 | protected static final String MARKDOWN_CODE_BLOCK_END = "\n```"; |
224 | 229 | protected static final String EVENT_ERROR_FILTER_OBJ = MARKDOWN_CODE_BLOCK_START + "{ \"eventType\": \"ERROR\", \"server\": \"ip-172-31-24-152\", " + | ... | ... |
... | ... | @@ -805,6 +805,13 @@ public class DashboardController extends BaseController { |
805 | 805 | return null; |
806 | 806 | } |
807 | 807 | |
808 | + @ApiOperation(value = "Assign dashboard to edge (assignDashboardToEdge)", | |
809 | + notes = "Creates assignment of an existing dashboard to an instance of The Edge. " + | |
810 | + EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
811 | + "Second, remote edge service will receive a copy of assignment dashboard " + | |
812 | + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
813 | + "Third, once dashboard will be delivered to edge service, it's going to be available for usage on remote edge instance.", | |
814 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
808 | 815 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
809 | 816 | @RequestMapping(value = "/edge/{edgeId}/dashboard/{dashboardId}", method = RequestMethod.POST) |
810 | 817 | @ResponseBody |
... | ... | @@ -838,6 +845,13 @@ public class DashboardController extends BaseController { |
838 | 845 | } |
839 | 846 | } |
840 | 847 | |
848 | + @ApiOperation(value = "Unassign dashboard from edge (unassignDashboardFromEdge)", | |
849 | + notes = "Clears assignment of the dashboard to the edge. " + | |
850 | + EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
851 | + "Second, remote edge service will receive an 'unassign' command to remove dashboard " + | |
852 | + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
853 | + "Third, once 'unassign' command will be delivered to edge service, it's going to remove dashboard locally.", | |
854 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
841 | 855 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
842 | 856 | @RequestMapping(value = "/edge/{edgeId}/dashboard/{dashboardId}", method = RequestMethod.DELETE) |
843 | 857 | @ResponseBody | ... | ... |
... | ... | @@ -24,6 +24,7 @@ import io.swagger.annotations.ApiParam; |
24 | 24 | import lombok.RequiredArgsConstructor; |
25 | 25 | import lombok.extern.slf4j.Slf4j; |
26 | 26 | import org.springframework.http.HttpStatus; |
27 | +import org.springframework.http.MediaType; | |
27 | 28 | import org.springframework.http.ResponseEntity; |
28 | 29 | import org.springframework.security.access.prepost.PreAuthorize; |
29 | 30 | import org.springframework.web.bind.annotation.PathVariable; |
... | ... | @@ -782,8 +783,11 @@ public class DeviceController extends BaseController { |
782 | 783 | |
783 | 784 | @ApiOperation(value = "Assign device to edge (assignDeviceToEdge)", |
784 | 785 | notes = "Creates assignment of an existing device to an instance of The Edge. " + |
785 | - "The Edge is a software product for edge computing. " + | |
786 | - "It allows bringing data analysis and management to the edge, while seamlessly synchronizing with the platform server (cloud). ") | |
786 | + EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
787 | + "Second, remote edge service will receive a copy of assignment device " + | |
788 | + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
789 | + "Third, once device will be delivered to edge service, it's going to be available for usage on remote edge instance.", | |
790 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
787 | 791 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
788 | 792 | @RequestMapping(value = "/edge/{edgeId}/device/{deviceId}", method = RequestMethod.POST) |
789 | 793 | @ResponseBody |
... | ... | @@ -821,7 +825,12 @@ public class DeviceController extends BaseController { |
821 | 825 | } |
822 | 826 | |
823 | 827 | @ApiOperation(value = "Unassign device from edge (unassignDeviceFromEdge)", |
824 | - notes = "Clears assignment of the device to the edge") | |
828 | + notes = "Clears assignment of the device to the edge. " + | |
829 | + EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
830 | + "Second, remote edge service will receive an 'unassign' command to remove device " + | |
831 | + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
832 | + "Third, once 'unassign' command will be delivered to edge service, it's going to remove device locally.", | |
833 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
825 | 834 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
826 | 835 | @RequestMapping(value = "/edge/{edgeId}/device/{deviceId}", method = RequestMethod.DELETE) |
827 | 836 | @ResponseBody | ... | ... |
... | ... | @@ -142,7 +142,7 @@ public class EdgeController extends BaseController { |
142 | 142 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
143 | 143 | @RequestMapping(value = "/edge", method = RequestMethod.POST) |
144 | 144 | @ResponseBody |
145 | - public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.", required = true) | |
145 | + public Edge saveEdge(@ApiParam(value = "A JSON value representing the edge.", required = true) | |
146 | 146 | @RequestBody Edge edge) throws ThingsboardException { |
147 | 147 | try { |
148 | 148 | TenantId tenantId = getCurrentUser().getTenantId(); | ... | ... |
... | ... | @@ -20,9 +20,11 @@ import com.google.common.util.concurrent.Futures; |
20 | 20 | import com.google.common.util.concurrent.ListenableFuture; |
21 | 21 | import com.google.common.util.concurrent.MoreExecutors; |
22 | 22 | import com.google.common.util.concurrent.SettableFuture; |
23 | +import io.swagger.annotations.ApiOperation; | |
23 | 24 | import lombok.extern.slf4j.Slf4j; |
24 | 25 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 26 | import org.springframework.http.HttpStatus; |
27 | +import org.springframework.http.MediaType; | |
26 | 28 | import org.springframework.security.access.prepost.PreAuthorize; |
27 | 29 | import org.springframework.web.bind.annotation.PathVariable; |
28 | 30 | import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -611,6 +613,13 @@ public class EntityViewController extends BaseController { |
611 | 613 | } |
612 | 614 | } |
613 | 615 | |
616 | + @ApiOperation(value = "Assign entity view to edge (assignEntityViewToEdge)", | |
617 | + notes = "Creates assignment of an existing entity view to an instance of The Edge. " + | |
618 | + EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
619 | + "Second, remote edge service will receive a copy of assignment entity view " + | |
620 | + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
621 | + "Third, once entity view will be delivered to edge service, it's going to be available for usage on remote edge instance.", | |
622 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
614 | 623 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
615 | 624 | @RequestMapping(value = "/edge/{edgeId}/entityView/{entityViewId}", method = RequestMethod.POST) |
616 | 625 | @ResponseBody |
... | ... | @@ -641,6 +650,13 @@ public class EntityViewController extends BaseController { |
641 | 650 | } |
642 | 651 | } |
643 | 652 | |
653 | + @ApiOperation(value = "Unassign entity view from edge (unassignEntityViewFromEdge)", | |
654 | + notes = "Clears assignment of the entity view to the edge. " + | |
655 | + EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
656 | + "Second, remote edge service will receive an 'unassign' command to remove entity view " + | |
657 | + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
658 | + "Third, once 'unassign' command will be delivered to edge service, it's going to remove entity view locally.", | |
659 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
644 | 660 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
645 | 661 | @RequestMapping(value = "/edge/{edgeId}/entityView/{entityViewId}", method = RequestMethod.DELETE) |
646 | 662 | @ResponseBody | ... | ... |
... | ... | @@ -20,10 +20,12 @@ import com.fasterxml.jackson.databind.JsonNode; |
20 | 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
21 | 21 | import com.fasterxml.jackson.databind.node.ArrayNode; |
22 | 22 | import com.fasterxml.jackson.databind.node.ObjectNode; |
23 | +import io.swagger.annotations.ApiOperation; | |
23 | 24 | import lombok.extern.slf4j.Slf4j; |
24 | 25 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 26 | import org.springframework.beans.factory.annotation.Value; |
26 | 27 | import org.springframework.http.HttpStatus; |
28 | +import org.springframework.http.MediaType; | |
27 | 29 | import org.springframework.security.access.prepost.PreAuthorize; |
28 | 30 | import org.springframework.util.CollectionUtils; |
29 | 31 | import org.springframework.util.StringUtils; |
... | ... | @@ -494,6 +496,14 @@ public class RuleChainController extends BaseController { |
494 | 496 | return msgData; |
495 | 497 | } |
496 | 498 | |
499 | + @ApiOperation(value = "Assign rule chain to edge (assignRuleChainToEdge)", | |
500 | + notes = "Creates assignment of an existing rule chain to an instance of The Edge. " + | |
501 | + EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
502 | + "Second, remote edge service will receive a copy of assignment rule chain " + | |
503 | + EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
504 | + "Third, once rule chain will be delivered to edge service, it's going to start processing messages locally. " + | |
505 | + "\n\nOnly rule chain with type 'EDGE' can be assigned to edge.", | |
506 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
497 | 507 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
498 | 508 | @RequestMapping(value = "/edge/{edgeId}/ruleChain/{ruleChainId}", method = RequestMethod.POST) |
499 | 509 | @ResponseBody |
... | ... | @@ -527,6 +537,13 @@ public class RuleChainController extends BaseController { |
527 | 537 | } |
528 | 538 | } |
529 | 539 | |
540 | + @ApiOperation(value = "Unassign rule chain from edge (unassignRuleChainFromEdge)", | |
541 | + notes = "Clears assignment of the rule chain to the edge. " + | |
542 | + EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION + | |
543 | + "Second, remote edge service will receive an 'unassign' command to remove rule chain " + | |
544 | + EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION + ". " + | |
545 | + "Third, once 'unassign' command will be delivered to edge service, it's going to remove rule chain locally.", | |
546 | + produces = MediaType.APPLICATION_JSON_VALUE) | |
530 | 547 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
531 | 548 | @RequestMapping(value = "/edge/{edgeId}/ruleChain/{ruleChainId}", method = RequestMethod.DELETE) |
532 | 549 | @ResponseBody | ... | ... |
... | ... | @@ -544,6 +544,9 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC |
544 | 544 | if (!edge.getTenantId().equals(ruleChain.getTenantId())) { |
545 | 545 | throw new DataValidationException("Can't assign ruleChain to edge from different tenant!"); |
546 | 546 | } |
547 | + if (!RuleChainType.EDGE.equals(ruleChain.getType())) { | |
548 | + throw new DataValidationException("Can't assign non EDGE ruleChain to edge!"); | |
549 | + } | |
547 | 550 | try { |
548 | 551 | createRelation(tenantId, new EntityRelation(edgeId, ruleChainId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.EDGE)); |
549 | 552 | } catch (Exception e) { | ... | ... |