Browse Source

sync edge api

pull/2436/head
Bohdan Smetaniuk 6 years ago
parent
commit
93363f81bb
  1. 8
      application/src/main/java/org/thingsboard/server/controller/BaseController.java
  2. 13
      application/src/main/java/org/thingsboard/server/controller/EdgeController.java
  3. 4
      rest-client/src/main/java/org/thingsboard/rest/client/RestClient.java

8
application/src/main/java/org/thingsboard/server/controller/BaseController.java

@ -104,6 +104,7 @@ import org.thingsboard.server.queue.provider.TbQueueProducerProvider;
import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.service.component.ComponentDiscoveryService;
import org.thingsboard.server.service.edge.EdgeNotificationService;
import org.thingsboard.server.service.edge.rpc.init.SyncEdgeService;
import org.thingsboard.server.service.queue.TbClusterService;
import org.thingsboard.server.service.security.model.SecurityUser;
import org.thingsboard.server.service.security.permission.AccessControlService;
@ -202,12 +203,15 @@ public abstract class BaseController {
@Autowired
protected TbQueueProducerProvider producerProvider;
@Autowired
@Autowired(required = false)
protected EdgeService edgeService;
@Autowired
@Autowired(required = false)
protected EdgeNotificationService edgeNotificationService;
@Autowired(required = false)
protected SyncEdgeService syncEdgeService;
@Value("${server.log_controller_error_stack_trace}")
@Getter
private boolean logControllerErrorStackTrace;

13
application/src/main/java/org/thingsboard/server/controller/EdgeController.java

@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.thingsboard.server.common.data.AdminSettings;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.EntitySubtype;
import org.thingsboard.server.common.data.EntityType;
@ -409,6 +410,18 @@ public class EdgeController extends BaseController {
}
}
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/edge/sync", method = RequestMethod.POST)
public void syncEdge(@RequestBody EdgeId edgeId) throws ThingsboardException {
try {
edgeId = checkNotNull(edgeId);
Edge edge = checkEdgeId(edgeId, Operation.READ);
syncEdgeService.sync(edge);
} catch (Exception e) {
throw handleException(e);
}
}
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST)
@ResponseBody
public Object checkInstance(@RequestBody Object request) throws ThingsboardException {

4
rest-client/src/main/java/org/thingsboard/rest/client/RestClient.java

@ -2372,6 +2372,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
params).getBody();
}
public void syncEdge(EdgeId edgeId) {
restTemplate.postForEntity(baseURL + "/api/edge/sync", edgeId, EdgeId.class);
}
@Deprecated
public Optional<JsonNode> getAttributes(String accessToken, String clientKeys, String sharedKeys) {
Map<String, String> params = new HashMap<>();

Loading…
Cancel
Save