Browse Source

Merge pull request #49 from BohdanSmetanyuk/rest_methods

Last rest-client methods
pull/2436/head
VoBa 6 years ago
committed by GitHub
parent
commit
95ae5474fe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 51
      rest-client/src/main/java/org/thingsboard/rest/client/RestClient.java

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

@ -2029,9 +2029,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
}
}
public Optional<RuleChain> setRootRuleChain(RuleChainId ruleChainId, EdgeId edgeId) {
public Optional<Edge> setRootRuleChain(EdgeId edgeId, RuleChainId ruleChainId) {
try {
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/{ruleChainId}/root", null, RuleChain.class, edgeId.getId(), ruleChainId.getId());
ResponseEntity<Edge> ruleChain = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/{ruleChainId}/root", null, Edge.class, edgeId.getId(), ruleChainId.getId());
return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -2251,6 +2251,53 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
}, params).getBody();
}
public Optional<RuleChain> addDefaultEdgeRuleChain(RuleChainId ruleChainId) {
try {
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/defaultEdge", null, RuleChain.class, ruleChainId.getId());
return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
} else {
throw exception;
}
}
}
public Optional<RuleChain> removeDefaultEdgeRuleChain(RuleChainId ruleChainId) {
try {
ResponseEntity<RuleChain> ruleChain = restTemplate.exchange(baseURL + "/api/ruleChain/{ruleChainId}/defaultEdge", HttpMethod.DELETE, HttpEntity.EMPTY, RuleChain.class, ruleChainId.getId());
return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
} else {
throw exception;
}
}
}
public List<RuleChain> getDefaultEdgeRuleChains() {
return restTemplate.exchange(baseURL + "/api/ruleChain/defaultEdgeRuleChains",
HttpMethod.GET,
HttpEntity.EMPTY,
new ParameterizedTypeReference<List<RuleChain>>() {
}).getBody();
}
public Optional<RuleChain> setDefaultRootEdgeRuleChain(RuleChainId ruleChainId) {
try {
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/defaultRootEdge", null, RuleChain.class, ruleChainId.getId());
return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
} else {
throw exception;
}
}
}
public TextPageData<Edge> getTenantEdges(String type, TextPageLink pageLink) {
Map<String, String> params = new HashMap<>();
params.put("type", type);

Loading…
Cancel
Save