Commit 1c5ca328e9859b580d8bc1c670e1f1938f81a0dc
1 parent
427e7ac0
Added ApiParam to edge controller methods
Showing
3 changed files
with
62 additions
and
14 deletions
... | ... | @@ -162,6 +162,7 @@ public abstract class BaseController { |
162 | 162 | public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
163 | 163 | public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
164 | 164 | public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
165 | + public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | |
165 | 166 | |
166 | 167 | protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page"; |
167 | 168 | protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0"; |
... | ... | @@ -174,7 +175,8 @@ public abstract class BaseController { |
174 | 175 | protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC"; |
175 | 176 | protected final String DEVICE_INFO_DESCRIPTION = "Device Info is an extension of the default Device object that contains information about the assigned customer name and device profile name. "; |
176 | 177 | |
177 | - protected final String EDGE_EVENT_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge event type name."; | |
178 | + protected final String EDGE_TYPE_DESCRIPTION = "A string value representing the edge type. For example, 'default'"; | |
179 | + protected final String EDGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge name."; | |
178 | 180 | |
179 | 181 | public static final String INCORRECT_TENANT_ID = "Incorrect tenantId "; |
180 | 182 | protected static final String DEFAULT_DASHBOARD = "defaultDashboardId"; | ... | ... |
... | ... | @@ -18,6 +18,7 @@ package org.thingsboard.server.controller; |
18 | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | 20 | import io.swagger.annotations.ApiOperation; |
21 | +import io.swagger.annotations.ApiParam; | |
21 | 22 | import lombok.RequiredArgsConstructor; |
22 | 23 | import lombok.extern.slf4j.Slf4j; |
23 | 24 | import org.springframework.http.HttpStatus; |
... | ... | @@ -93,7 +94,8 @@ public class EdgeController extends BaseController { |
93 | 94 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
94 | 95 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET) |
95 | 96 | @ResponseBody |
96 | - public Edge getEdgeById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
97 | + public Edge getEdgeById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
98 | + @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
97 | 99 | checkParameter(EDGE_ID, strEdgeId); |
98 | 100 | try { |
99 | 101 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -112,7 +114,8 @@ public class EdgeController extends BaseController { |
112 | 114 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
113 | 115 | @RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET) |
114 | 116 | @ResponseBody |
115 | - public EdgeInfo getEdgeInfoById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
117 | + public EdgeInfo getEdgeInfoById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
118 | + @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
116 | 119 | checkParameter(EDGE_ID, strEdgeId); |
117 | 120 | try { |
118 | 121 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -133,7 +136,8 @@ public class EdgeController extends BaseController { |
133 | 136 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
134 | 137 | @RequestMapping(value = "/edge", method = RequestMethod.POST) |
135 | 138 | @ResponseBody |
136 | - public Edge saveEdge(@RequestBody Edge edge) throws ThingsboardException { | |
139 | + public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.") | |
140 | + @RequestBody Edge edge) throws ThingsboardException { | |
137 | 141 | try { |
138 | 142 | TenantId tenantId = getCurrentUser().getTenantId(); |
139 | 143 | edge.setTenantId(tenantId); |
... | ... | @@ -181,7 +185,8 @@ public class EdgeController extends BaseController { |
181 | 185 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
182 | 186 | @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE) |
183 | 187 | @ResponseStatus(value = HttpStatus.OK) |
184 | - public void deleteEdge(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
188 | + public void deleteEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
189 | + @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
185 | 190 | checkParameter(EDGE_ID, strEdgeId); |
186 | 191 | try { |
187 | 192 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -212,10 +217,15 @@ public class EdgeController extends BaseController { |
212 | 217 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
213 | 218 | @RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
214 | 219 | @ResponseBody |
215 | - public PageData<Edge> getEdges(@RequestParam int pageSize, | |
220 | + public PageData<Edge> getEdges(@ApiParam(value = PAGE_SIZE_DESCRIPTION) | |
221 | + @RequestParam int pageSize, | |
222 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | |
216 | 223 | @RequestParam int page, |
224 | + @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) | |
217 | 225 | @RequestParam(required = false) String textSearch, |
226 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) | |
218 | 227 | @RequestParam(required = false) String sortProperty, |
228 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
219 | 229 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
220 | 230 | try { |
221 | 231 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
... | ... | @@ -231,7 +241,9 @@ public class EdgeController extends BaseController { |
231 | 241 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
232 | 242 | @RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST) |
233 | 243 | @ResponseBody |
234 | - public Edge assignEdgeToCustomer(@PathVariable("customerId") String strCustomerId, | |
244 | + public Edge assignEdgeToCustomer(@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) | |
245 | + @PathVariable("customerId") String strCustomerId, | |
246 | + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
235 | 247 | @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { |
236 | 248 | checkParameter("customerId", strCustomerId); |
237 | 249 | checkParameter(EDGE_ID, strEdgeId); |
... | ... | @@ -268,7 +280,8 @@ public class EdgeController extends BaseController { |
268 | 280 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
269 | 281 | @RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE) |
270 | 282 | @ResponseBody |
271 | - public Edge unassignEdgeFromCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
283 | + public Edge unassignEdgeFromCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
284 | + @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
272 | 285 | checkParameter(EDGE_ID, strEdgeId); |
273 | 286 | try { |
274 | 287 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -306,7 +319,8 @@ public class EdgeController extends BaseController { |
306 | 319 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
307 | 320 | @RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST) |
308 | 321 | @ResponseBody |
309 | - public Edge assignEdgeToPublicCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
322 | + public Edge assignEdgeToPublicCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
323 | + @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { | |
310 | 324 | checkParameter(EDGE_ID, strEdgeId); |
311 | 325 | try { |
312 | 326 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
... | ... | @@ -337,11 +351,17 @@ public class EdgeController extends BaseController { |
337 | 351 | @RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
338 | 352 | @ResponseBody |
339 | 353 | public PageData<Edge> getTenantEdges( |
354 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION) | |
340 | 355 | @RequestParam int pageSize, |
356 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | |
341 | 357 | @RequestParam int page, |
358 | + @ApiParam(value = EDGE_TYPE_DESCRIPTION) | |
342 | 359 | @RequestParam(required = false) String type, |
360 | + @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) | |
343 | 361 | @RequestParam(required = false) String textSearch, |
362 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) | |
344 | 363 | @RequestParam(required = false) String sortProperty, |
364 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
345 | 365 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
346 | 366 | try { |
347 | 367 | TenantId tenantId = getCurrentUser().getTenantId(); |
... | ... | @@ -363,11 +383,17 @@ public class EdgeController extends BaseController { |
363 | 383 | @RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
364 | 384 | @ResponseBody |
365 | 385 | public PageData<EdgeInfo> getTenantEdgeInfos( |
386 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION) | |
366 | 387 | @RequestParam int pageSize, |
388 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | |
367 | 389 | @RequestParam int page, |
390 | + @ApiParam(value = EDGE_TYPE_DESCRIPTION) | |
368 | 391 | @RequestParam(required = false) String type, |
392 | + @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) | |
369 | 393 | @RequestParam(required = false) String textSearch, |
394 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) | |
370 | 395 | @RequestParam(required = false) String sortProperty, |
396 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
371 | 397 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
372 | 398 | try { |
373 | 399 | TenantId tenantId = getCurrentUser().getTenantId(); |
... | ... | @@ -388,7 +414,8 @@ public class EdgeController extends BaseController { |
388 | 414 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
389 | 415 | @RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET) |
390 | 416 | @ResponseBody |
391 | - public Edge getTenantEdge(@RequestParam String edgeName) throws ThingsboardException { | |
417 | + public Edge getTenantEdge(@ApiParam(value = "Unique name of the edge") | |
418 | + @RequestParam String edgeName) throws ThingsboardException { | |
392 | 419 | try { |
393 | 420 | TenantId tenantId = getCurrentUser().getTenantId(); |
394 | 421 | return checkNotNull(edgeService.findEdgeByTenantIdAndName(tenantId, edgeName)); |
... | ... | @@ -403,7 +430,9 @@ public class EdgeController extends BaseController { |
403 | 430 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
404 | 431 | @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) |
405 | 432 | @ResponseBody |
406 | - public Edge setRootRuleChain(@PathVariable(EDGE_ID) String strEdgeId, | |
433 | + public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
434 | + @PathVariable(EDGE_ID) String strEdgeId, | |
435 | + @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION) | |
407 | 436 | @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException { |
408 | 437 | checkParameter(EDGE_ID, strEdgeId); |
409 | 438 | checkParameter("ruleChainId", strRuleChainId); |
... | ... | @@ -439,12 +468,19 @@ public class EdgeController extends BaseController { |
439 | 468 | @RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) |
440 | 469 | @ResponseBody |
441 | 470 | public PageData<Edge> getCustomerEdges( |
471 | + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) | |
442 | 472 | @PathVariable("customerId") String strCustomerId, |
473 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION) | |
443 | 474 | @RequestParam int pageSize, |
475 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | |
444 | 476 | @RequestParam int page, |
477 | + @ApiParam(value = EDGE_TYPE_DESCRIPTION) | |
445 | 478 | @RequestParam(required = false) String type, |
479 | + @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) | |
446 | 480 | @RequestParam(required = false) String textSearch, |
481 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) | |
447 | 482 | @RequestParam(required = false) String sortProperty, |
483 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
448 | 484 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
449 | 485 | checkParameter("customerId", strCustomerId); |
450 | 486 | try { |
... | ... | @@ -477,12 +513,19 @@ public class EdgeController extends BaseController { |
477 | 513 | @RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
478 | 514 | @ResponseBody |
479 | 515 | public PageData<EdgeInfo> getCustomerEdgeInfos( |
516 | + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) | |
480 | 517 | @PathVariable("customerId") String strCustomerId, |
518 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION) | |
481 | 519 | @RequestParam int pageSize, |
520 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | |
482 | 521 | @RequestParam int page, |
522 | + @ApiParam(value = EDGE_TYPE_DESCRIPTION) | |
483 | 523 | @RequestParam(required = false) String type, |
524 | + @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) | |
484 | 525 | @RequestParam(required = false) String textSearch, |
526 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) | |
485 | 527 | @RequestParam(required = false) String sortProperty, |
528 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | |
486 | 529 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
487 | 530 | checkParameter("customerId", strCustomerId); |
488 | 531 | try { |
... | ... | @@ -514,6 +557,7 @@ public class EdgeController extends BaseController { |
514 | 557 | @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET) |
515 | 558 | @ResponseBody |
516 | 559 | public List<Edge> getEdgesByIds( |
560 | + @ApiParam(value = "A list of edges ids, separated by comma ','") | |
517 | 561 | @RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException { |
518 | 562 | checkArrayParameter("edgeIds", strEdgeIds); |
519 | 563 | try { |
... | ... | @@ -598,7 +642,8 @@ public class EdgeController extends BaseController { |
598 | 642 | "All entities that are assigned to particular edge are going to be send to remote edge service.") |
599 | 643 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
600 | 644 | @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST) |
601 | - public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException { | |
645 | + public void syncEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
646 | + @PathVariable("edgeId") String strEdgeId) throws ThingsboardException { | |
602 | 647 | checkParameter("edgeId", strEdgeId); |
603 | 648 | try { |
604 | 649 | if (isEdgesEnabled()) { |
... | ... | @@ -620,7 +665,8 @@ public class EdgeController extends BaseController { |
620 | 665 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
621 | 666 | @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) |
622 | 667 | @ResponseBody |
623 | - public String findMissingToRelatedRuleChains(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException { | |
668 | + public String findMissingToRelatedRuleChains(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | |
669 | + @PathVariable("edgeId") String strEdgeId) throws ThingsboardException { | |
624 | 670 | try { |
625 | 671 | EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); |
626 | 672 | edgeId = checkNotNull(edgeId); | ... | ... |
... | ... | @@ -60,7 +60,7 @@ public class EdgeEventController extends BaseController { |
60 | 60 | @RequestParam int pageSize, |
61 | 61 | @ApiParam(value = PAGE_NUMBER_DESCRIPTION) |
62 | 62 | @RequestParam int page, |
63 | - @ApiParam(value = EDGE_EVENT_TEXT_SEARCH_DESCRIPTION) | |
63 | + @ApiParam(value = "The case insensitive 'startsWith' filter based on the edge event type name.") | |
64 | 64 | @RequestParam(required = false) String textSearch, |
65 | 65 | @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) |
66 | 66 | @RequestParam(required = false) String sortProperty, | ... | ... |