Commit 8e0b76fb7a292001867037956966ce4075dc5a2c
1 parent
e6e05c9b
Added Swagger API documentation for Edge Controller
Showing
1 changed file
with
57 additions
and
1 deletions
@@ -17,6 +17,7 @@ package org.thingsboard.server.controller; | @@ -17,6 +17,7 @@ package org.thingsboard.server.controller; | ||
17 | 17 | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | +import io.swagger.annotations.ApiOperation; | ||
20 | import lombok.RequiredArgsConstructor; | 21 | import lombok.RequiredArgsConstructor; |
21 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
22 | import org.springframework.http.HttpStatus; | 23 | import org.springframework.http.HttpStatus; |
@@ -75,6 +76,8 @@ public class EdgeController extends BaseController { | @@ -75,6 +76,8 @@ public class EdgeController extends BaseController { | ||
75 | private final EdgeBulkImportService edgeBulkImportService; | 76 | private final EdgeBulkImportService edgeBulkImportService; |
76 | 77 | ||
77 | public static final String EDGE_ID = "edgeId"; | 78 | public static final String EDGE_ID = "edgeId"; |
79 | + public static final String EDGE_SECURITY_CHECK = "If the user has the authority of 'Tenant Administrator', the server checks that the edge is owned by the same tenant. " + | ||
80 | + "If the user has the authority of 'Customer User', the server checks that the edge is assigned to the same customer."; | ||
78 | 81 | ||
79 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") | 82 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
80 | @RequestMapping(value = "/edges/enabled", method = RequestMethod.GET) | 83 | @RequestMapping(value = "/edges/enabled", method = RequestMethod.GET) |
@@ -83,6 +86,8 @@ public class EdgeController extends BaseController { | @@ -83,6 +86,8 @@ public class EdgeController extends BaseController { | ||
83 | return edgesEnabled; | 86 | return edgesEnabled; |
84 | } | 87 | } |
85 | 88 | ||
89 | + @ApiOperation(value = "Get Edge (getEdgeById)", | ||
90 | + notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK) | ||
86 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 91 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
87 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET) | 92 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET) |
88 | @ResponseBody | 93 | @ResponseBody |
@@ -100,6 +105,8 @@ public class EdgeController extends BaseController { | @@ -100,6 +105,8 @@ public class EdgeController extends BaseController { | ||
100 | } | 105 | } |
101 | } | 106 | } |
102 | 107 | ||
108 | + @ApiOperation(value = "Get Edge Info (getEdgeInfoById)", | ||
109 | + notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK) | ||
103 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 110 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
104 | @RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET) | 111 | @RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET) |
105 | @ResponseBody | 112 | @ResponseBody |
@@ -117,6 +124,10 @@ public class EdgeController extends BaseController { | @@ -117,6 +124,10 @@ public class EdgeController extends BaseController { | ||
117 | } | 124 | } |
118 | } | 125 | } |
119 | 126 | ||
127 | + @ApiOperation(value = "Create Or Update Edge (saveEdge)", | ||
128 | + notes = "Creates or Updates the Edge. Platform generates random Edge Id during edge creation. " + | ||
129 | + "The edge id will be present in the response. " + | ||
130 | + "Specify the Edge id when you would like to update the edge. Referencing non-existing edge Id will cause an error.") | ||
120 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 131 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
121 | @RequestMapping(value = "/edge", method = RequestMethod.POST) | 132 | @RequestMapping(value = "/edge", method = RequestMethod.POST) |
122 | @ResponseBody | 133 | @ResponseBody |
@@ -163,6 +174,8 @@ public class EdgeController extends BaseController { | @@ -163,6 +174,8 @@ public class EdgeController extends BaseController { | ||
163 | logEntityAction(edge.getId(), edge, null, updated ? ActionType.UPDATED : ActionType.ADDED, null); | 174 | logEntityAction(edge.getId(), edge, null, updated ? ActionType.UPDATED : ActionType.ADDED, null); |
164 | } | 175 | } |
165 | 176 | ||
177 | + @ApiOperation(value = "Delete edge (deleteEdge)", | ||
178 | + notes = "Deletes the edge. Referencing non-existing edge Id will cause an error.") | ||
166 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 179 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
167 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE) | 180 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE) |
168 | @ResponseStatus(value = HttpStatus.OK) | 181 | @ResponseStatus(value = HttpStatus.OK) |
@@ -191,6 +204,9 @@ public class EdgeController extends BaseController { | @@ -191,6 +204,9 @@ public class EdgeController extends BaseController { | ||
191 | } | 204 | } |
192 | } | 205 | } |
193 | 206 | ||
207 | + @ApiOperation(value = "Get Tenant Edges (getEdges)", | ||
208 | + notes = "Returns a page of edges owned by tenant. " + | ||
209 | + PAGE_DATA_PARAMETERS) | ||
194 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 210 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
195 | @RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) | 211 | @RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
196 | @ResponseBody | 212 | @ResponseBody |
@@ -208,6 +224,8 @@ public class EdgeController extends BaseController { | @@ -208,6 +224,8 @@ public class EdgeController extends BaseController { | ||
208 | } | 224 | } |
209 | } | 225 | } |
210 | 226 | ||
227 | + @ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)", | ||
228 | + notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards.") | ||
211 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 229 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
212 | @RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST) | 230 | @RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST) |
213 | @ResponseBody | 231 | @ResponseBody |
@@ -243,6 +261,8 @@ public class EdgeController extends BaseController { | @@ -243,6 +261,8 @@ public class EdgeController extends BaseController { | ||
243 | } | 261 | } |
244 | } | 262 | } |
245 | 263 | ||
264 | + @ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)", | ||
265 | + notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards.") | ||
246 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 266 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
247 | @RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE) | 267 | @RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE) |
248 | @ResponseBody | 268 | @ResponseBody |
@@ -277,6 +297,10 @@ public class EdgeController extends BaseController { | @@ -277,6 +297,10 @@ public class EdgeController extends BaseController { | ||
277 | } | 297 | } |
278 | } | 298 | } |
279 | 299 | ||
300 | + @ApiOperation(value = "Make edge publicly available (assignEdgeToPublicCustomer)", | ||
301 | + notes = "Edge will be available for non-authorized (not logged-in) users. " + | ||
302 | + "This is useful to create dashboards that you plan to share/embed on a publicly available website. " + | ||
303 | + "However, users that are logged-in and belong to different tenant will not be able to access the edge.") | ||
280 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 304 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
281 | @RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST) | 305 | @RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST) |
282 | @ResponseBody | 306 | @ResponseBody |
@@ -304,6 +328,9 @@ public class EdgeController extends BaseController { | @@ -304,6 +328,9 @@ public class EdgeController extends BaseController { | ||
304 | } | 328 | } |
305 | } | 329 | } |
306 | 330 | ||
331 | + @ApiOperation(value = "Get Tenant Edges (getTenantEdges)", | ||
332 | + notes = "Returns a page of edges owned by tenant. " + | ||
333 | + PAGE_DATA_PARAMETERS) | ||
307 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 334 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
308 | @RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) | 335 | @RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
309 | @ResponseBody | 336 | @ResponseBody |
@@ -327,6 +354,9 @@ public class EdgeController extends BaseController { | @@ -327,6 +354,9 @@ public class EdgeController extends BaseController { | ||
327 | } | 354 | } |
328 | } | 355 | } |
329 | 356 | ||
357 | + @ApiOperation(value = "Get Tenant Edge Infos (getTenantEdgeInfos)", | ||
358 | + notes = "Returns a page of edges info objects owned by tenant. " + | ||
359 | + PAGE_DATA_PARAMETERS + DEVICE_INFO_DESCRIPTION) | ||
330 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 360 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
331 | @RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) | 361 | @RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
332 | @ResponseBody | 362 | @ResponseBody |
@@ -350,6 +380,9 @@ public class EdgeController extends BaseController { | @@ -350,6 +380,9 @@ public class EdgeController extends BaseController { | ||
350 | } | 380 | } |
351 | } | 381 | } |
352 | 382 | ||
383 | + @ApiOperation(value = "Get Tenant Edge (getTenantEdge)", | ||
384 | + notes = "Requested edge must be owned by tenant or customer that the user belongs to. " + | ||
385 | + "Edge name is an unique property of edge. So it can be used to identify the edge.") | ||
353 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 386 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
354 | @RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET) | 387 | @RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET) |
355 | @ResponseBody | 388 | @ResponseBody |
@@ -362,6 +395,9 @@ public class EdgeController extends BaseController { | @@ -362,6 +395,9 @@ public class EdgeController extends BaseController { | ||
362 | } | 395 | } |
363 | } | 396 | } |
364 | 397 | ||
398 | + @ApiOperation(value = "Set root rule chain for provided edge (setRootRuleChain)", | ||
399 | + notes = "Change root rule chain of the edge from the current to the new provided rule chain. \n" + | ||
400 | + "This operation will send an notification to remote edge service to update root rule chain remotely.") | ||
365 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") | 401 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
366 | @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) | 402 | @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) |
367 | @ResponseBody | 403 | @ResponseBody |
@@ -394,6 +430,9 @@ public class EdgeController extends BaseController { | @@ -394,6 +430,9 @@ public class EdgeController extends BaseController { | ||
394 | } | 430 | } |
395 | } | 431 | } |
396 | 432 | ||
433 | + @ApiOperation(value = "Get Customer Edges (getCustomerEdges)", | ||
434 | + notes = "Returns a page of edges objects assigned to customer. " + | ||
435 | + PAGE_DATA_PARAMETERS) | ||
397 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 436 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
398 | @RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) | 437 | @RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
399 | @ResponseBody | 438 | @ResponseBody |
@@ -429,6 +468,9 @@ public class EdgeController extends BaseController { | @@ -429,6 +468,9 @@ public class EdgeController extends BaseController { | ||
429 | } | 468 | } |
430 | } | 469 | } |
431 | 470 | ||
471 | + @ApiOperation(value = "Get Customer Edge Infos (getCustomerEdgeInfos)", | ||
472 | + notes = "Returns a page of edges info objects assigned to customer. " + | ||
473 | + PAGE_DATA_PARAMETERS + DEVICE_INFO_DESCRIPTION) | ||
432 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 474 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
433 | @RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) | 475 | @RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
434 | @ResponseBody | 476 | @ResponseBody |
@@ -464,6 +506,8 @@ public class EdgeController extends BaseController { | @@ -464,6 +506,8 @@ public class EdgeController extends BaseController { | ||
464 | } | 506 | } |
465 | } | 507 | } |
466 | 508 | ||
509 | + @ApiOperation(value = "Get Edges By Ids (getEdgesByIds)", | ||
510 | + notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request. ") | ||
467 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 511 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
468 | @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET) | 512 | @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET) |
469 | @ResponseBody | 513 | @ResponseBody |
@@ -496,6 +540,10 @@ public class EdgeController extends BaseController { | @@ -496,6 +540,10 @@ public class EdgeController extends BaseController { | ||
496 | } | 540 | } |
497 | } | 541 | } |
498 | 542 | ||
543 | + @ApiOperation(value = "Find related edges (findByQuery)", | ||
544 | + notes = "Returns all edges that are related to the specific entity. " + | ||
545 | + "The entity id, relation type, device types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " + | ||
546 | + "See 'Model' tab of the Parameters for more info.") | ||
499 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 547 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
500 | @RequestMapping(value = "/edges", method = RequestMethod.POST) | 548 | @RequestMapping(value = "/edges", method = RequestMethod.POST) |
501 | @ResponseBody | 549 | @ResponseBody |
@@ -527,6 +575,8 @@ public class EdgeController extends BaseController { | @@ -527,6 +575,8 @@ public class EdgeController extends BaseController { | ||
527 | } | 575 | } |
528 | } | 576 | } |
529 | 577 | ||
578 | + @ApiOperation(value = "Get Edge Types (getEdgeTypes)", | ||
579 | + notes = "Returns a set of unique edge types based on edges that are either owned by the tenant or assigned to the customer which user is performing the request.") | ||
530 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 580 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
531 | @RequestMapping(value = "/edge/types", method = RequestMethod.GET) | 581 | @RequestMapping(value = "/edge/types", method = RequestMethod.GET) |
532 | @ResponseBody | 582 | @ResponseBody |
@@ -541,6 +591,8 @@ public class EdgeController extends BaseController { | @@ -541,6 +591,8 @@ public class EdgeController extends BaseController { | ||
541 | } | 591 | } |
542 | } | 592 | } |
543 | 593 | ||
594 | + @ApiOperation(value = "Sync edge (syncEdge)", | ||
595 | + notes = "Starts synchronization process between edge and cloud - all entities that are assigned to particular edge are going to be send to remote edge service.") | ||
544 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 596 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
545 | @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST) | 597 | @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST) |
546 | public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException { | 598 | public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException { |
@@ -560,6 +612,8 @@ public class EdgeController extends BaseController { | @@ -560,6 +612,8 @@ public class EdgeController extends BaseController { | ||
560 | } | 612 | } |
561 | } | 613 | } |
562 | 614 | ||
615 | + @ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)", | ||
616 | + notes = "Returns list of rule chains IDs that are not assigned to particular edge, but these rule chains are present in the already assigned rule chains to edge") | ||
563 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 617 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
564 | @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) | 618 | @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) |
565 | @ResponseBody | 619 | @ResponseBody |
@@ -575,9 +629,11 @@ public class EdgeController extends BaseController { | @@ -575,9 +629,11 @@ public class EdgeController extends BaseController { | ||
575 | } | 629 | } |
576 | } | 630 | } |
577 | 631 | ||
632 | + @ApiOperation(value = "Import the bulk of edges (processEdgesBulkImport)", | ||
633 | + notes = "There's an ability to import the bulk of edges using the only .csv file.") | ||
578 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") | 634 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
579 | @PostMapping("/edge/bulk_import") | 635 | @PostMapping("/edge/bulk_import") |
580 | - public BulkImportResult<Edge> processEdgeBulkImport(@RequestBody BulkImportRequest request) throws Exception { | 636 | + public BulkImportResult<Edge> processEdgesBulkImport(@RequestBody BulkImportRequest request) throws Exception { |
581 | SecurityUser user = getCurrentUser(); | 637 | SecurityUser user = getCurrentUser(); |
582 | RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(user.getTenantId()); | 638 | RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(user.getTenantId()); |
583 | if (edgeTemplateRootRuleChain == null) { | 639 | if (edgeTemplateRootRuleChain == null) { |