added all methods for working with Edge
This commit is contained in:
parent
1cfb7fa501
commit
b38f8b61f4
@ -2015,6 +2015,42 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Edge> assignEdgeToPublicCustomer(EdgeId edgeId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<Edge> edge = restTemplate.postForEntity(baseURL + "/api/customer/public/edge/{edgeId}", null, Edge.class, edgeId.getId());
|
||||||
|
return Optional.ofNullable(edge.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<RuleChain> setRootRuleChain(RuleChainId ruleChainId, EdgeId edgeId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/{ruleChainId}/root", null, RuleChain.class, edgeId.getId(), 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> getEdges(TextPageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/edges?" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<TextPageData<Edge>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<Edge> unassignEdgeFromCustomer(EdgeId edgeId) {
|
public Optional<Edge> unassignEdgeFromCustomer(EdgeId edgeId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Edge> edge = restTemplate.exchange(baseURL + "/api/customer/edge/{edgeId}", HttpMethod.DELETE, HttpEntity.EMPTY, Edge.class, edgeId.getId());
|
ResponseEntity<Edge> edge = restTemplate.exchange(baseURL + "/api/customer/edge/{edgeId}", HttpMethod.DELETE, HttpEntity.EMPTY, Edge.class, edgeId.getId());
|
||||||
@ -2041,9 +2077,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Device> unassignDeviceFromEdge(DeviceId deviceId) {
|
public Optional<Device> unassignDeviceFromEdge(EdgeId edgeId, DeviceId deviceId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/edge/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId.getId());
|
ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/edge/{edgeId}/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, edgeId.getId(), deviceId.getId());
|
||||||
return Optional.ofNullable(device.getBody());
|
return Optional.ofNullable(device.getBody());
|
||||||
} catch (HttpClientErrorException exception) {
|
} catch (HttpClientErrorException exception) {
|
||||||
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
@ -2054,13 +2090,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextPageData<Device> getEdgeDevices(EdgeId edgeId, String deviceType, TextPageLink pageLink) {
|
public TextPageData<Device> getEdgeDevices(EdgeId edgeId, TextPageLink pageLink) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("edgeId", edgeId.getId().toString());
|
params.put("edgeId", edgeId.getId().toString());
|
||||||
params.put("type", deviceType);
|
|
||||||
addPageLinkToParam(params, pageLink);
|
addPageLinkToParam(params, pageLink);
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/edge/{edgeId}/devices?type={type}&" + getUrlParams(pageLink),
|
baseURL + "/api/edge/{edgeId}/devices?" + getUrlParams(pageLink),
|
||||||
HttpMethod.GET, HttpEntity.EMPTY,
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
new ParameterizedTypeReference<TextPageData<Device>>() {
|
new ParameterizedTypeReference<TextPageData<Device>>() {
|
||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
@ -2079,9 +2114,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Asset> unassignAssetFromEdge(AssetId assetId) {
|
public Optional<Asset> unassignAssetFromEdge(EdgeId edgeId, AssetId assetId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Asset> asset = restTemplate.exchange(baseURL + "/api/edge/asset/{assetId}", HttpMethod.DELETE, HttpEntity.EMPTY, Asset.class, assetId.getId());
|
ResponseEntity<Asset> asset = restTemplate.exchange(baseURL + "/api/edge/{edgeId}/asset/{assetId}", HttpMethod.DELETE, HttpEntity.EMPTY, Asset.class, edgeId.getId(), assetId.getId());
|
||||||
return Optional.ofNullable(asset.getBody());
|
return Optional.ofNullable(asset.getBody());
|
||||||
} catch (HttpClientErrorException exception) {
|
} catch (HttpClientErrorException exception) {
|
||||||
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
@ -2092,18 +2127,130 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextPageData<Asset> getEdgeAssets(EdgeId edgeId, String assetType, TextPageLink pageLink) {
|
public TextPageData<Asset> getEdgeAssets(EdgeId edgeId, TextPageLink pageLink) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("edgeId", edgeId.getId().toString());
|
params.put("edgeId", edgeId.getId().toString());
|
||||||
params.put("type", assetType);
|
|
||||||
addPageLinkToParam(params, pageLink);
|
addPageLinkToParam(params, pageLink);
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/edge/{edgeId}/assets?type={type}&" + getUrlParams(pageLink),
|
baseURL + "/api/edge/{edgeId}/assets?" + getUrlParams(pageLink),
|
||||||
HttpMethod.GET, HttpEntity.EMPTY,
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
new ParameterizedTypeReference<TextPageData<Asset>>() {
|
new ParameterizedTypeReference<TextPageData<Asset>>() {
|
||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Dashboard> assignDashboardToEdge(EdgeId edgeId, DashboardId dashboardId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/dashboard/{dashboardId}", null, Dashboard.class, edgeId.getId(), dashboardId.getId());
|
||||||
|
return Optional.ofNullable(dashboard.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Dashboard> unassignDashboardFromEdge(EdgeId edgeId, DashboardId dashboardId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/edge/{edgeId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, edgeId.getId(), dashboardId.getId());
|
||||||
|
return Optional.ofNullable(dashboard.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimePageData<DashboardInfo> getEdgeDashboards(EdgeId edgeId, TimePageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("edgeId", edgeId.getId().toString());
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/edge/{edgeId}/dashboards?" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<TimePageData<DashboardInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<EntityView> assignEntityViewToEdge(EdgeId edgeId, EntityViewId entityViewId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/entityView/{entityViewId}", null, EntityView.class, edgeId.getId(), entityViewId.getId());
|
||||||
|
return Optional.ofNullable(entityView.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<EntityView> unassignEntityViewFromEdge(EdgeId edgeId, EntityViewId entityViewId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<EntityView> entityView = restTemplate.exchange(baseURL + "/api/edge/{edgeId}/entityView/{entityViewId}", HttpMethod.DELETE, HttpEntity.EMPTY, EntityView.class, edgeId.getId(), entityViewId.getId());
|
||||||
|
return Optional.ofNullable(entityView.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextPageData<EntityView> getEdgeEntityViews(EdgeId edgeId, String entityViewType, TextPageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("edgeId", edgeId.getId().toString());
|
||||||
|
params.put("type", entityViewType);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/edge/{edgeId}/entityViews?type={type}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<TextPageData<EntityView>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<RuleChain> assignRuleChainToEdge(EdgeId edgeId, RuleChainId ruleChainId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/edge/{edgeId}/ruleChain/{ruleChainId}", null, RuleChain.class, edgeId.getId(), 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> unassignRuleChainFromEdge(EdgeId edgeId, RuleChainId ruleChainId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<RuleChain> ruleChain = restTemplate.exchange(baseURL + "/api/edge/{edgeId}/ruleChain/{ruleChainId}", HttpMethod.DELETE, HttpEntity.EMPTY, RuleChain.class, edgeId.getId(), ruleChainId.getId());
|
||||||
|
return Optional.ofNullable(ruleChain.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimePageData<RuleChain> getEdgeRuleChains(EdgeId edgeId, TimePageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("edgeId", edgeId.getId().toString());
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/edge/{edgeId}/ruleChains?" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<TimePageData<RuleChain>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public TextPageData<Edge> getTenantEdges(String type, TextPageLink pageLink) {
|
public TextPageData<Edge> getTenantEdges(String type, TextPageLink pageLink) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("type", type);
|
params.put("type", type);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user