Added ApiParam to edge controller methods
This commit is contained in:
parent
427e7ac094
commit
1c5ca328e9
@ -162,6 +162,7 @@ public abstract class BaseController {
|
||||
public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
|
||||
public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
|
||||
public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
|
||||
public static final String RULE_CHAIN_ID_PARAM_DESCRIPTION = "A string value representing the rule chain id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
|
||||
|
||||
protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
|
||||
protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
|
||||
@ -174,7 +175,8 @@ public abstract class BaseController {
|
||||
protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC";
|
||||
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. ";
|
||||
|
||||
protected final String EDGE_EVENT_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge event type name.";
|
||||
protected final String EDGE_TYPE_DESCRIPTION = "A string value representing the edge type. For example, 'default'";
|
||||
protected final String EDGE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the edge name.";
|
||||
|
||||
public static final String INCORRECT_TENANT_ID = "Incorrect tenantId ";
|
||||
protected static final String DEFAULT_DASHBOARD = "defaultDashboardId";
|
||||
|
||||
@ -18,6 +18,7 @@ package org.thingsboard.server.controller;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -93,7 +94,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Edge getEdgeById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
public Edge getEdgeById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
@ -112,7 +114,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||
@RequestMapping(value = "/edge/info/{edgeId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public EdgeInfo getEdgeInfoById(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
public EdgeInfo getEdgeInfoById(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
@ -133,7 +136,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Edge saveEdge(@RequestBody Edge edge) throws ThingsboardException {
|
||||
public Edge saveEdge(@ApiParam(value = "A JSON value representing the ed.")
|
||||
@RequestBody Edge edge) throws ThingsboardException {
|
||||
try {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
edge.setTenantId(tenantId);
|
||||
@ -181,7 +185,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge/{edgeId}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void deleteEdge(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
public void deleteEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
@ -212,10 +217,15 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public PageData<Edge> getEdges(@RequestParam int pageSize,
|
||||
public PageData<Edge> getEdges(@ApiParam(value = PAGE_SIZE_DESCRIPTION)
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
try {
|
||||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
||||
@ -231,7 +241,9 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/customer/{customerId}/edge/{edgeId}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Edge assignEdgeToCustomer(@PathVariable("customerId") String strCustomerId,
|
||||
public Edge assignEdgeToCustomer(@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("customerId") String strCustomerId,
|
||||
@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter("customerId", strCustomerId);
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
@ -268,7 +280,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/customer/edge/{edgeId}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public Edge unassignEdgeFromCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
public Edge unassignEdgeFromCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
@ -306,7 +319,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/customer/public/edge/{edgeId}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Edge assignEdgeToPublicCustomer(@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
public Edge assignEdgeToPublicCustomer(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
@ -337,11 +351,17 @@ public class EdgeController extends BaseController {
|
||||
@RequestMapping(value = "/tenant/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public PageData<Edge> getTenantEdges(
|
||||
@ApiParam(value = PAGE_SIZE_DESCRIPTION)
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
||||
@RequestParam(required = false) String type,
|
||||
@ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
try {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
@ -363,11 +383,17 @@ public class EdgeController extends BaseController {
|
||||
@RequestMapping(value = "/tenant/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public PageData<EdgeInfo> getTenantEdgeInfos(
|
||||
@ApiParam(value = PAGE_SIZE_DESCRIPTION)
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
||||
@RequestParam(required = false) String type,
|
||||
@ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
try {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
@ -388,7 +414,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/tenant/edges", params = {"edgeName"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Edge getTenantEdge(@RequestParam String edgeName) throws ThingsboardException {
|
||||
public Edge getTenantEdge(@ApiParam(value = "Unique name of the edge")
|
||||
@RequestParam String edgeName) throws ThingsboardException {
|
||||
try {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
return checkNotNull(edgeService.findEdgeByTenantIdAndName(tenantId, edgeName));
|
||||
@ -403,7 +430,9 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Edge setRootRuleChain(@PathVariable(EDGE_ID) String strEdgeId,
|
||||
public Edge setRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(EDGE_ID) String strEdgeId,
|
||||
@ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException {
|
||||
checkParameter(EDGE_ID, strEdgeId);
|
||||
checkParameter("ruleChainId", strRuleChainId);
|
||||
@ -439,12 +468,19 @@ public class EdgeController extends BaseController {
|
||||
@RequestMapping(value = "/customer/{customerId}/edges", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public PageData<Edge> getCustomerEdges(
|
||||
@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("customerId") String strCustomerId,
|
||||
@ApiParam(value = PAGE_SIZE_DESCRIPTION)
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
||||
@RequestParam(required = false) String type,
|
||||
@ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
checkParameter("customerId", strCustomerId);
|
||||
try {
|
||||
@ -477,12 +513,19 @@ public class EdgeController extends BaseController {
|
||||
@RequestMapping(value = "/customer/{customerId}/edgeInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public PageData<EdgeInfo> getCustomerEdgeInfos(
|
||||
@ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("customerId") String strCustomerId,
|
||||
@ApiParam(value = PAGE_SIZE_DESCRIPTION)
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_TYPE_DESCRIPTION)
|
||||
@RequestParam(required = false) String type,
|
||||
@ApiParam(value = EDGE_TEXT_SEARCH_DESCRIPTION)
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
checkParameter("customerId", strCustomerId);
|
||||
try {
|
||||
@ -514,6 +557,7 @@ public class EdgeController extends BaseController {
|
||||
@RequestMapping(value = "/edges", params = {"edgeIds"}, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public List<Edge> getEdgesByIds(
|
||||
@ApiParam(value = "A list of edges ids, separated by comma ','")
|
||||
@RequestParam("edgeIds") String[] strEdgeIds) throws ThingsboardException {
|
||||
checkArrayParameter("edgeIds", strEdgeIds);
|
||||
try {
|
||||
@ -598,7 +642,8 @@ public class EdgeController extends BaseController {
|
||||
"All entities that are assigned to particular edge are going to be send to remote edge service.")
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge/sync/{edgeId}", method = RequestMethod.POST)
|
||||
public void syncEdge(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||
public void syncEdge(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||
checkParameter("edgeId", strEdgeId);
|
||||
try {
|
||||
if (isEdgesEnabled()) {
|
||||
@ -620,7 +665,8 @@ public class EdgeController extends BaseController {
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String findMissingToRelatedRuleChains(@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||
public String findMissingToRelatedRuleChains(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable("edgeId") String strEdgeId) throws ThingsboardException {
|
||||
try {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
edgeId = checkNotNull(edgeId);
|
||||
|
||||
@ -60,7 +60,7 @@ public class EdgeEventController extends BaseController {
|
||||
@RequestParam int pageSize,
|
||||
@ApiParam(value = PAGE_NUMBER_DESCRIPTION)
|
||||
@RequestParam int page,
|
||||
@ApiParam(value = EDGE_EVENT_TEXT_SEARCH_DESCRIPTION)
|
||||
@ApiParam(value = "The case insensitive 'startsWith' filter based on the edge event type name.")
|
||||
@RequestParam(required = false) String textSearch,
|
||||
@ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user