Commit 626437117de2d6b01fb4f32f4a733682ca00be11

Authored by Volodymyr Babak
1 parent 318dc282

Added required config. Added produces config

@@ -194,12 +194,14 @@ public abstract class BaseController { @@ -194,12 +194,14 @@ public abstract class BaseController {
194 protected final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle"; 194 protected final String ASSET_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
195 protected final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status"; 195 protected final String ALARM_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, startTs, endTs, type, ackTs, clearTs, severity, status";
196 protected final String EVENT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, id"; 196 protected final String EVENT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, id";
  197 + protected final String EDGE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, label, customerTitle";
197 protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESC (DESCENDING)"; 198 protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESC (DESCENDING)";
198 protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC"; 199 protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC";
199 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. "; 200 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. ";
200 protected final String ASSET_INFO_DESCRIPTION = "Asset Info is an extension of the default Asset object that contains information about the assigned customer name. "; 201 protected final String ASSET_INFO_DESCRIPTION = "Asset Info is an extension of the default Asset object that contains information about the assigned customer name. ";
201 protected final String ALARM_INFO_DESCRIPTION = "Alarm Info is an extension of the default Alarm object that also contains name of the alarm originator."; 202 protected final String ALARM_INFO_DESCRIPTION = "Alarm Info is an extension of the default Alarm object that also contains name of the alarm originator.";
202 protected final String RELATION_INFO_DESCRIPTION = "Relation Info is an extension of the default Relation object that contains information about the 'from' and 'to' entity names. "; 203 protected final String RELATION_INFO_DESCRIPTION = "Relation Info is an extension of the default Relation object that contains information about the 'from' and 'to' entity names. ";
  204 + protected final String EDGE_INFO_DESCRIPTION = "Edge Info is an extension of the default Edge object that contains information about the assigned customer name. ";
203 205
204 protected final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name."; 206 protected final String DEVICE_NAME_DESCRIPTION = "A string value representing the Device name.";
205 protected final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name."; 207 protected final String ASSET_NAME_DESCRIPTION = "A string value representing the Asset name.";
@@ -22,6 +22,7 @@ import io.swagger.annotations.ApiParam; @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiParam;
22 import lombok.RequiredArgsConstructor; 22 import lombok.RequiredArgsConstructor;
23 import lombok.extern.slf4j.Slf4j; 23 import lombok.extern.slf4j.Slf4j;
24 import org.springframework.http.HttpStatus; 24 import org.springframework.http.HttpStatus;
  25 +import org.springframework.http.MediaType;
25 import org.springframework.http.ResponseEntity; 26 import org.springframework.http.ResponseEntity;
26 import org.springframework.security.access.prepost.PreAuthorize; 27 import org.springframework.security.access.prepost.PreAuthorize;
27 import org.springframework.web.bind.annotation.PathVariable; 28 import org.springframework.web.bind.annotation.PathVariable;
@@ -90,11 +91,12 @@ public class EdgeController extends BaseController { @@ -90,11 +91,12 @@ public class EdgeController extends BaseController {
90 } 91 }
91 92
92 @ApiOperation(value = "Get Edge (getEdgeById)", 93 @ApiOperation(value = "Get Edge (getEdgeById)",
93 - notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK) 94 + notes = "Get the Edge object based on the provided Edge Id. " + EDGE_SECURITY_CHECK,
  95 + produces = MediaType.APPLICATION_JSON_VALUE)
94 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 96 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
95 @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET) 97 @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
96 @ResponseBody 98 @ResponseBody
97 - public Edge getEdgeById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 99 + public Edge getEdgeById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
98 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 100 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
99 checkParameter(EDGE_ID, strEdgeId); 101 checkParameter(EDGE_ID, strEdgeId);
100 try { 102 try {
@@ -110,11 +112,12 @@ public class EdgeController extends BaseController { @@ -110,11 +112,12 @@ public class EdgeController extends BaseController {
110 } 112 }
111 113
112 @ApiOperation(value = "Get Edge Info (getEdgeInfoById)", 114 @ApiOperation(value = "Get Edge Info (getEdgeInfoById)",
113 - notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK) 115 + notes = "Get the Edge Info object based on the provided Edge Id. " + EDGE_SECURITY_CHECK,
  116 + produces = MediaType.APPLICATION_JSON_VALUE)
114 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 117 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
115 @RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET) 118 @RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET)
116 @ResponseBody 119 @ResponseBody
117 - public EdgeInfo getEdgeInfoById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 120 + public EdgeInfo getEdgeInfoById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
118 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 121 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
119 checkParameter(EDGE_ID, strEdgeId); 122 checkParameter(EDGE_ID, strEdgeId);
120 try { 123 try {
@@ -130,13 +133,16 @@ public class EdgeController extends BaseController { @@ -130,13 +133,16 @@ public class EdgeController extends BaseController {
130 } 133 }
131 134
132 @ApiOperation(value = "Create Or Update Edge (saveEdge)", 135 @ApiOperation(value = "Create Or Update Edge (saveEdge)",
133 - notes = "Creates or Updates the Edge. Platform generates random Edge Id during edge creation. " +  
134 - "The edge id will be present in the response. " +  
135 - "Specify the Edge id when you would like to update the edge. Referencing non-existing edge Id will cause an error.") 136 + notes = "Create or update the Edge. When creating edge, platform generates Edge Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
  137 + "The newly created edge id will be present in the response. " +
  138 + "Specify existing Edge id to update the edge. " +
  139 + "Referencing non-existing Edge Id will cause 'Not Found' error." +
  140 + "\n\nEdge name is unique in the scope of tenant. Use unique identifiers like MAC or IMEI for the edge names and non-unique 'label' field for user-friendly visualization purposes.",
  141 + produces = MediaType.APPLICATION_JSON_VALUE)
136 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 142 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
137 @RequestMapping(value = "/edge", method = RequestMethod.POST) 143 @RequestMapping(value = "/edge", method = RequestMethod.POST)
138 @ResponseBody 144 @ResponseBody
139 - public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.") 145 + public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.", required = true)
140 @RequestBody Edge edge) throws ThingsboardException { 146 @RequestBody Edge edge) throws ThingsboardException {
141 try { 147 try {
142 TenantId tenantId = getCurrentUser().getTenantId(); 148 TenantId tenantId = getCurrentUser().getTenantId();
@@ -185,7 +191,7 @@ public class EdgeController extends BaseController { @@ -185,7 +191,7 @@ public class EdgeController extends BaseController {
185 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 191 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
186 @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE) 192 @RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE)
187 @ResponseStatus(value = HttpStatus.OK) 193 @ResponseStatus(value = HttpStatus.OK)
188 - public void deleteEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 194 + public void deleteEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
189 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 195 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
190 checkParameter(EDGE_ID, strEdgeId); 196 checkParameter(EDGE_ID, strEdgeId);
191 try { 197 try {
@@ -213,17 +219,17 @@ public class EdgeController extends BaseController { @@ -213,17 +219,17 @@ public class EdgeController extends BaseController {
213 219
214 @ApiOperation(value = "Get Tenant Edges (getEdges)", 220 @ApiOperation(value = "Get Tenant Edges (getEdges)",
215 notes = "Returns a page of edges owned by tenant. " + 221 notes = "Returns a page of edges owned by tenant. " +
216 - PAGE_DATA_PARAMETERS) 222 + PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
217 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 223 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
218 @RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) 224 @RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
219 @ResponseBody 225 @ResponseBody
220 - public PageData<Edge> getEdges(@ApiParam(value = PAGE_SIZE_DESCRIPTION) 226 + public PageData<Edge> getEdges(@ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
221 @RequestParam int pageSize, 227 @RequestParam int pageSize,
222 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 228 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
223 @RequestParam int page, 229 @RequestParam int page,
224 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) 230 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
225 @RequestParam(required = false) String textSearch, 231 @RequestParam(required = false) String textSearch,
226 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 232 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
227 @RequestParam(required = false) String sortProperty, 233 @RequestParam(required = false) String sortProperty,
228 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 234 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
229 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 235 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
@@ -237,13 +243,14 @@ public class EdgeController extends BaseController { @@ -237,13 +243,14 @@ public class EdgeController extends BaseController {
237 } 243 }
238 244
239 @ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)", 245 @ApiOperation(value = "Assign edge to customer (assignEdgeToCustomer)",
240 - notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards.") 246 + notes = "Creates assignment of the edge to customer. Customer will be able to query edge afterwards.",
  247 + produces = MediaType.APPLICATION_JSON_VALUE)
241 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 248 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
242 @RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST) 249 @RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST)
243 @ResponseBody 250 @ResponseBody
244 - public Edge assignEdgeToCustomer(@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) 251 + public Edge assignEdgeToCustomer(@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
245 @PathVariable("customerId") String strCustomerId, 252 @PathVariable("customerId") String strCustomerId,
246 - @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 253 + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
247 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 254 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
248 checkParameter("customerId", strCustomerId); 255 checkParameter("customerId", strCustomerId);
249 checkParameter(EDGE_ID, strEdgeId); 256 checkParameter(EDGE_ID, strEdgeId);
@@ -276,11 +283,12 @@ public class EdgeController extends BaseController { @@ -276,11 +283,12 @@ public class EdgeController extends BaseController {
276 } 283 }
277 284
278 @ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)", 285 @ApiOperation(value = "Unassign edge from customer (unassignEdgeFromCustomer)",
279 - notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards.") 286 + notes = "Clears assignment of the edge to customer. Customer will not be able to query edge afterwards.",
  287 + produces = MediaType.APPLICATION_JSON_VALUE)
280 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 288 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
281 @RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE) 289 @RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE)
282 @ResponseBody 290 @ResponseBody
283 - public Edge unassignEdgeFromCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 291 + public Edge unassignEdgeFromCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
284 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 292 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
285 checkParameter(EDGE_ID, strEdgeId); 293 checkParameter(EDGE_ID, strEdgeId);
286 try { 294 try {
@@ -315,11 +323,12 @@ public class EdgeController extends BaseController { @@ -315,11 +323,12 @@ public class EdgeController extends BaseController {
315 @ApiOperation(value = "Make edge publicly available (assignEdgeToPublicCustomer)", 323 @ApiOperation(value = "Make edge publicly available (assignEdgeToPublicCustomer)",
316 notes = "Edge will be available for non-authorized (not logged-in) users. " + 324 notes = "Edge will be available for non-authorized (not logged-in) users. " +
317 "This is useful to create dashboards that you plan to share/embed on a publicly available website. " + 325 "This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
318 - "However, users that are logged-in and belong to different tenant will not be able to access the edge.") 326 + "However, users that are logged-in and belong to different tenant will not be able to access the edge.",
  327 + produces = MediaType.APPLICATION_JSON_VALUE)
319 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 328 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
320 @RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST) 329 @RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST)
321 @ResponseBody 330 @ResponseBody
322 - public Edge assignEdgeToPublicCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 331 + public Edge assignEdgeToPublicCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
323 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException { 332 @PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
324 checkParameter(EDGE_ID, strEdgeId); 333 checkParameter(EDGE_ID, strEdgeId);
325 try { 334 try {
@@ -346,20 +355,20 @@ public class EdgeController extends BaseController { @@ -346,20 +355,20 @@ public class EdgeController extends BaseController {
346 355
347 @ApiOperation(value = "Get Tenant Edges (getTenantEdges)", 356 @ApiOperation(value = "Get Tenant Edges (getTenantEdges)",
348 notes = "Returns a page of edges owned by tenant. " + 357 notes = "Returns a page of edges owned by tenant. " +
349 - PAGE_DATA_PARAMETERS) 358 + PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
350 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 359 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
351 @RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) 360 @RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
352 @ResponseBody 361 @ResponseBody
353 public PageData<Edge> getTenantEdges( 362 public PageData<Edge> getTenantEdges(
354 - @ApiParam(value = PAGE_SIZE_DESCRIPTION) 363 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
355 @RequestParam int pageSize, 364 @RequestParam int pageSize,
356 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 365 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
357 @RequestParam int page, 366 @RequestParam int page,
358 @ApiParam(value = EDGE_TYPE_DESCRIPTION) 367 @ApiParam(value = EDGE_TYPE_DESCRIPTION)
359 @RequestParam(required = false) String type, 368 @RequestParam(required = false) String type,
360 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) 369 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
361 @RequestParam(required = false) String textSearch, 370 @RequestParam(required = false) String textSearch,
362 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 371 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
363 @RequestParam(required = false) String sortProperty, 372 @RequestParam(required = false) String sortProperty,
364 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 373 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
365 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 374 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
@@ -378,20 +387,21 @@ public class EdgeController extends BaseController { @@ -378,20 +387,21 @@ public class EdgeController extends BaseController {
378 387
379 @ApiOperation(value = "Get Tenant Edge Infos (getTenantEdgeInfos)", 388 @ApiOperation(value = "Get Tenant Edge Infos (getTenantEdgeInfos)",
380 notes = "Returns a page of edges info objects owned by tenant. " + 389 notes = "Returns a page of edges info objects owned by tenant. " +
381 - PAGE_DATA_PARAMETERS + DEVICE_INFO_DESCRIPTION) 390 + PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION,
  391 + produces = MediaType.APPLICATION_JSON_VALUE)
382 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 392 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
383 @RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) 393 @RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
384 @ResponseBody 394 @ResponseBody
385 public PageData<EdgeInfo> getTenantEdgeInfos( 395 public PageData<EdgeInfo> getTenantEdgeInfos(
386 - @ApiParam(value = PAGE_SIZE_DESCRIPTION) 396 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
387 @RequestParam int pageSize, 397 @RequestParam int pageSize,
388 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 398 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
389 @RequestParam int page, 399 @RequestParam int page,
390 @ApiParam(value = EDGE_TYPE_DESCRIPTION) 400 @ApiParam(value = EDGE_TYPE_DESCRIPTION)
391 @RequestParam(required = false) String type, 401 @RequestParam(required = false) String type,
392 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) 402 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
393 @RequestParam(required = false) String textSearch, 403 @RequestParam(required = false) String textSearch,
394 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 404 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
395 @RequestParam(required = false) String sortProperty, 405 @RequestParam(required = false) String sortProperty,
396 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 406 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
397 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 407 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
@@ -410,11 +420,12 @@ public class EdgeController extends BaseController { @@ -410,11 +420,12 @@ public class EdgeController extends BaseController {
410 420
411 @ApiOperation(value = "Get Tenant Edge (getTenantEdge)", 421 @ApiOperation(value = "Get Tenant Edge (getTenantEdge)",
412 notes = "Requested edge must be owned by tenant or customer that the user belongs to. " + 422 notes = "Requested edge must be owned by tenant or customer that the user belongs to. " +
413 - "Edge name is an unique property of edge. So it can be used to identify the edge.") 423 + "Edge name is an unique property of edge. So it can be used to identify the edge.",
  424 + produces = MediaType.APPLICATION_JSON_VALUE)
414 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 425 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
415 @RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET) 426 @RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET)
416 @ResponseBody 427 @ResponseBody
417 - public Edge getTenantEdge(@ApiParam(value = "Unique name of the edge") 428 + public Edge getTenantEdge(@ApiParam(value = "Unique name of the edge", required = true)
418 @RequestParam String edgeName) throws ThingsboardException { 429 @RequestParam String edgeName) throws ThingsboardException {
419 try { 430 try {
420 TenantId tenantId = getCurrentUser().getTenantId(); 431 TenantId tenantId = getCurrentUser().getTenantId();
@@ -425,14 +436,15 @@ public class EdgeController extends BaseController { @@ -425,14 +436,15 @@ public class EdgeController extends BaseController {
425 } 436 }
426 437
427 @ApiOperation(value = "Set root rule chain for provided edge (setRootRuleChain)", 438 @ApiOperation(value = "Set root rule chain for provided edge (setRootRuleChain)",
428 - notes = "Change root rule chain of the edge from the current to the new provided rule chain. \n" +  
429 - "This operation will send a notification to remote edge service to update root rule chain remotely.") 439 + notes = "Change root rule chain of the edge to the new provided rule chain. \n" +
  440 + "This operation will send a notification to update root rule chain on remote edge service.",
  441 + produces = MediaType.APPLICATION_JSON_VALUE)
430 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 442 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
431 @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST) 443 @RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
432 @ResponseBody 444 @ResponseBody
433 - public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 445 + public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
434 @PathVariable(EDGE_ID) String strEdgeId, 446 @PathVariable(EDGE_ID) String strEdgeId,
435 - @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION) 447 + @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true)
436 @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException { 448 @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException {
437 checkParameter(EDGE_ID, strEdgeId); 449 checkParameter(EDGE_ID, strEdgeId);
438 checkParameter("ruleChainId", strRuleChainId); 450 checkParameter("ruleChainId", strRuleChainId);
@@ -463,22 +475,22 @@ public class EdgeController extends BaseController { @@ -463,22 +475,22 @@ public class EdgeController extends BaseController {
463 475
464 @ApiOperation(value = "Get Customer Edges (getCustomerEdges)", 476 @ApiOperation(value = "Get Customer Edges (getCustomerEdges)",
465 notes = "Returns a page of edges objects assigned to customer. " + 477 notes = "Returns a page of edges objects assigned to customer. " +
466 - PAGE_DATA_PARAMETERS) 478 + PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
467 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 479 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
468 @RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET) 480 @RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
469 @ResponseBody 481 @ResponseBody
470 public PageData<Edge> getCustomerEdges( 482 public PageData<Edge> getCustomerEdges(
471 @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) 483 @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
472 @PathVariable("customerId") String strCustomerId, 484 @PathVariable("customerId") String strCustomerId,
473 - @ApiParam(value = PAGE_SIZE_DESCRIPTION) 485 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
474 @RequestParam int pageSize, 486 @RequestParam int pageSize,
475 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 487 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
476 @RequestParam int page, 488 @RequestParam int page,
477 @ApiParam(value = EDGE_TYPE_DESCRIPTION) 489 @ApiParam(value = EDGE_TYPE_DESCRIPTION)
478 @RequestParam(required = false) String type, 490 @RequestParam(required = false) String type,
479 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) 491 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
480 @RequestParam(required = false) String textSearch, 492 @RequestParam(required = false) String textSearch,
481 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 493 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
482 @RequestParam(required = false) String sortProperty, 494 @RequestParam(required = false) String sortProperty,
483 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 495 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
484 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 496 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
@@ -508,22 +520,22 @@ public class EdgeController extends BaseController { @@ -508,22 +520,22 @@ public class EdgeController extends BaseController {
508 520
509 @ApiOperation(value = "Get Customer Edge Infos (getCustomerEdgeInfos)", 521 @ApiOperation(value = "Get Customer Edge Infos (getCustomerEdgeInfos)",
510 notes = "Returns a page of edges info objects assigned to customer. " + 522 notes = "Returns a page of edges info objects assigned to customer. " +
511 - PAGE_DATA_PARAMETERS + DEVICE_INFO_DESCRIPTION) 523 + PAGE_DATA_PARAMETERS + EDGE_INFO_DESCRIPTION, produces = MediaType.APPLICATION_JSON_VALUE)
512 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 524 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
513 @RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) 525 @RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
514 @ResponseBody 526 @ResponseBody
515 public PageData<EdgeInfo> getCustomerEdgeInfos( 527 public PageData<EdgeInfo> getCustomerEdgeInfos(
516 @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) 528 @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
517 @PathVariable("customerId") String strCustomerId, 529 @PathVariable("customerId") String strCustomerId,
518 - @ApiParam(value = PAGE_SIZE_DESCRIPTION) 530 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
519 @RequestParam int pageSize, 531 @RequestParam int pageSize,
520 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 532 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
521 @RequestParam int page, 533 @RequestParam int page,
522 @ApiParam(value = EDGE_TYPE_DESCRIPTION) 534 @ApiParam(value = EDGE_TYPE_DESCRIPTION)
523 @RequestParam(required = false) String type, 535 @RequestParam(required = false) String type,
524 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION) 536 @ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
525 @RequestParam(required = false) String textSearch, 537 @RequestParam(required = false) String textSearch,
526 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 538 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
527 @RequestParam(required = false) String sortProperty, 539 @RequestParam(required = false) String sortProperty,
528 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 540 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
529 @RequestParam(required = false) String sortOrder) throws ThingsboardException { 541 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
@@ -552,12 +564,13 @@ public class EdgeController extends BaseController { @@ -552,12 +564,13 @@ public class EdgeController extends BaseController {
552 } 564 }
553 565
554 @ApiOperation(value = "Get Edges By Ids (getEdgesByIds)", 566 @ApiOperation(value = "Get Edges By Ids (getEdgesByIds)",
555 - notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request. ") 567 + notes = "Requested edges must be owned by tenant or assigned to customer which user is performing the request.",
  568 + produces = MediaType.APPLICATION_JSON_VALUE)
556 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 569 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
557 @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET) 570 @RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET)
558 @ResponseBody 571 @ResponseBody
559 public List<Edge> getEdgesByIds( 572 public List<Edge> getEdgesByIds(
560 - @ApiParam(value = "A list of edges ids, separated by comma ','") 573 + @ApiParam(value = "A list of edges ids, separated by comma ','", required = true)
561 @RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException { 574 @RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException {
562 checkArrayParameter("edgeIds", strEdgeIds); 575 checkArrayParameter("edgeIds", strEdgeIds);
563 try { 576 try {
@@ -588,8 +601,9 @@ public class EdgeController extends BaseController { @@ -588,8 +601,9 @@ public class EdgeController extends BaseController {
588 601
589 @ApiOperation(value = "Find related edges (findByQuery)", 602 @ApiOperation(value = "Find related edges (findByQuery)",
590 notes = "Returns all edges that are related to the specific entity. " + 603 notes = "Returns all edges that are related to the specific entity. " +
591 - "The entity id, relation type, device types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " +  
592 - "See 'Model' tab of the Parameters for more info.") 604 + "The entity id, relation type, edge types, depth of the search, and other query parameters defined using complex 'EdgeSearchQuery' object. " +
  605 + "See 'Model' tab of the Parameters for more info.",
  606 + produces = MediaType.APPLICATION_JSON_VALUE)
593 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 607 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
594 @RequestMapping(value = "/edges", method = RequestMethod.POST) 608 @RequestMapping(value = "/edges", method = RequestMethod.POST)
595 @ResponseBody 609 @ResponseBody
@@ -622,7 +636,8 @@ public class EdgeController extends BaseController { @@ -622,7 +636,8 @@ public class EdgeController extends BaseController {
622 } 636 }
623 637
624 @ApiOperation(value = "Get Edge Types (getEdgeTypes)", 638 @ApiOperation(value = "Get Edge Types (getEdgeTypes)",
625 - 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.") 639 + 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.",
  640 + produces = MediaType.APPLICATION_JSON_VALUE)
626 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 641 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
627 @RequestMapping(value = "/edge/types", method = RequestMethod.GET) 642 @RequestMapping(value = "/edge/types", method = RequestMethod.GET)
628 @ResponseBody 643 @ResponseBody
@@ -642,7 +657,7 @@ public class EdgeController extends BaseController { @@ -642,7 +657,7 @@ public class EdgeController extends BaseController {
642 "All entities that are assigned to particular edge are going to be send to remote edge service.") 657 "All entities that are assigned to particular edge are going to be send to remote edge service.")
643 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 658 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
644 @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST) 659 @RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
645 - public void syncEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 660 + public void syncEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
646 @PathVariable("edgeId") String strEdgeId) throws ThingsboardException { 661 @PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
647 checkParameter("edgeId", strEdgeId); 662 checkParameter("edgeId", strEdgeId);
648 try { 663 try {
@@ -661,11 +676,11 @@ public class EdgeController extends BaseController { @@ -661,11 +676,11 @@ public class EdgeController extends BaseController {
661 } 676 }
662 677
663 @ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)", 678 @ApiOperation(value = "Find missing rule chains (findMissingToRelatedRuleChains)",
664 - 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") 679 + 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.")
665 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 680 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
666 @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) 681 @RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
667 @ResponseBody 682 @ResponseBody
668 - public String findMissingToRelatedRuleChains(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 683 + public String findMissingToRelatedRuleChains(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
669 @PathVariable("edgeId") String strEdgeId) throws ThingsboardException { 684 @PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
670 try { 685 try {
671 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 686 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
@@ -679,7 +694,8 @@ public class EdgeController extends BaseController { @@ -679,7 +694,8 @@ public class EdgeController extends BaseController {
679 } 694 }
680 695
681 @ApiOperation(value = "Import the bulk of edges (processEdgesBulkImport)", 696 @ApiOperation(value = "Import the bulk of edges (processEdgesBulkImport)",
682 - notes = "There's an ability to import the bulk of edges using the only .csv file.") 697 + notes = "There's an ability to import the bulk of edges using the only .csv file.",
  698 + produces = MediaType.APPLICATION_JSON_VALUE)
683 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") 699 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
684 @PostMapping("/edge/bulk_import") 700 @PostMapping("/edge/bulk_import")
685 public BulkImportResult<Edge> processEdgesBulkImport(@RequestBody BulkImportRequest request) throws Exception { 701 public BulkImportResult<Edge> processEdgesBulkImport(@RequestBody BulkImportRequest request) throws Exception {
@@ -19,6 +19,7 @@ import io.swagger.annotations.ApiOperation; @@ -19,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
19 import io.swagger.annotations.ApiParam; 19 import io.swagger.annotations.ApiParam;
20 import lombok.extern.slf4j.Slf4j; 20 import lombok.extern.slf4j.Slf4j;
21 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.http.MediaType;
22 import org.springframework.security.access.prepost.PreAuthorize; 23 import org.springframework.security.access.prepost.PreAuthorize;
23 import org.springframework.web.bind.annotation.PathVariable; 24 import org.springframework.web.bind.annotation.PathVariable;
24 import org.springframework.web.bind.annotation.RequestMapping; 25 import org.springframework.web.bind.annotation.RequestMapping;
@@ -49,20 +50,20 @@ public class EdgeEventController extends BaseController { @@ -49,20 +50,20 @@ public class EdgeEventController extends BaseController {
49 50
50 @ApiOperation(value = "Get Edge Events (getEdgeEvents)", 51 @ApiOperation(value = "Get Edge Events (getEdgeEvents)",
51 notes = "Returns a page of edge events for the requested edge. " + 52 notes = "Returns a page of edge events for the requested edge. " +
52 - PAGE_DATA_PARAMETERS) 53 + PAGE_DATA_PARAMETERS, produces = MediaType.APPLICATION_JSON_VALUE)
53 @PreAuthorize("hasAuthority('TENANT_ADMIN')") 54 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
54 @RequestMapping(value = "/edge/{edgeId}/events", method = RequestMethod.GET) 55 @RequestMapping(value = "/edge/{edgeId}/events", method = RequestMethod.GET)
55 @ResponseBody 56 @ResponseBody
56 public PageData<EdgeEvent> getEdgeEvents( 57 public PageData<EdgeEvent> getEdgeEvents(
57 - @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) 58 + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
58 @PathVariable(EDGE_ID) String strEdgeId, 59 @PathVariable(EDGE_ID) String strEdgeId,
59 - @ApiParam(value = PAGE_SIZE_DESCRIPTION) 60 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
60 @RequestParam int pageSize, 61 @RequestParam int pageSize,
61 - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) 62 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
62 @RequestParam int page, 63 @RequestParam int page,
63 @ApiParam(value = "The case insensitive 'startsWith' filter based on the edge event type name.") 64 @ApiParam(value = "The case insensitive 'startsWith' filter based on the edge event type name.")
64 @RequestParam(required = false) String textSearch, 65 @RequestParam(required = false) String textSearch,
65 - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES) 66 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = EDGE_SORT_PROPERTY_ALLOWABLE_VALUES)
66 @RequestParam(required = false) String sortProperty, 67 @RequestParam(required = false) String sortProperty,
67 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) 68 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
68 @RequestParam(required = false) String sortOrder, 69 @RequestParam(required = false) String sortOrder,