added new APIs
This commit is contained in:
parent
2b3a1ce818
commit
b0126a9d47
@ -38,10 +38,18 @@ import org.thingsboard.server.common.data.Customer;
|
|||||||
import org.thingsboard.server.common.data.Dashboard;
|
import org.thingsboard.server.common.data.Dashboard;
|
||||||
import org.thingsboard.server.common.data.DashboardInfo;
|
import org.thingsboard.server.common.data.DashboardInfo;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
|
import org.thingsboard.server.common.data.DeviceInfo;
|
||||||
|
import org.thingsboard.server.common.data.DeviceProfile;
|
||||||
|
import org.thingsboard.server.common.data.DeviceProfileInfo;
|
||||||
|
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||||
|
import org.thingsboard.server.common.data.EntityInfo;
|
||||||
import org.thingsboard.server.common.data.EntitySubtype;
|
import org.thingsboard.server.common.data.EntitySubtype;
|
||||||
import org.thingsboard.server.common.data.EntityView;
|
import org.thingsboard.server.common.data.EntityView;
|
||||||
|
import org.thingsboard.server.common.data.EntityViewInfo;
|
||||||
import org.thingsboard.server.common.data.Event;
|
import org.thingsboard.server.common.data.Event;
|
||||||
import org.thingsboard.server.common.data.Tenant;
|
import org.thingsboard.server.common.data.Tenant;
|
||||||
|
import org.thingsboard.server.common.data.TenantInfo;
|
||||||
|
import org.thingsboard.server.common.data.TenantProfile;
|
||||||
import org.thingsboard.server.common.data.UpdateMessage;
|
import org.thingsboard.server.common.data.UpdateMessage;
|
||||||
import org.thingsboard.server.common.data.User;
|
import org.thingsboard.server.common.data.User;
|
||||||
import org.thingsboard.server.common.data.alarm.Alarm;
|
import org.thingsboard.server.common.data.alarm.Alarm;
|
||||||
@ -50,6 +58,7 @@ import org.thingsboard.server.common.data.alarm.AlarmSearchStatus;
|
|||||||
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
|
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
|
||||||
import org.thingsboard.server.common.data.alarm.AlarmStatus;
|
import org.thingsboard.server.common.data.alarm.AlarmStatus;
|
||||||
import org.thingsboard.server.common.data.asset.Asset;
|
import org.thingsboard.server.common.data.asset.Asset;
|
||||||
|
import org.thingsboard.server.common.data.asset.AssetInfo;
|
||||||
import org.thingsboard.server.common.data.asset.AssetSearchQuery;
|
import org.thingsboard.server.common.data.asset.AssetSearchQuery;
|
||||||
import org.thingsboard.server.common.data.audit.ActionType;
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
import org.thingsboard.server.common.data.audit.AuditLog;
|
import org.thingsboard.server.common.data.audit.AuditLog;
|
||||||
@ -60,28 +69,41 @@ import org.thingsboard.server.common.data.id.AssetId;
|
|||||||
import org.thingsboard.server.common.data.id.CustomerId;
|
import org.thingsboard.server.common.data.id.CustomerId;
|
||||||
import org.thingsboard.server.common.data.id.DashboardId;
|
import org.thingsboard.server.common.data.id.DashboardId;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
|
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||||
|
import org.thingsboard.server.common.data.id.OAuth2ClientRegistrationTemplateId;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
import org.thingsboard.server.common.data.id.RuleNodeId;
|
import org.thingsboard.server.common.data.id.RuleNodeId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
import org.thingsboard.server.common.data.id.TenantProfileId;
|
||||||
import org.thingsboard.server.common.data.id.UserId;
|
import org.thingsboard.server.common.data.id.UserId;
|
||||||
import org.thingsboard.server.common.data.id.WidgetTypeId;
|
import org.thingsboard.server.common.data.id.WidgetTypeId;
|
||||||
import org.thingsboard.server.common.data.id.WidgetsBundleId;
|
import org.thingsboard.server.common.data.id.WidgetsBundleId;
|
||||||
import org.thingsboard.server.common.data.kv.Aggregation;
|
import org.thingsboard.server.common.data.kv.Aggregation;
|
||||||
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
||||||
import org.thingsboard.server.common.data.kv.TsKvEntry;
|
import org.thingsboard.server.common.data.kv.TsKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo;
|
||||||
|
import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistrationTemplate;
|
||||||
|
import org.thingsboard.server.common.data.oauth2.OAuth2ClientsParams;
|
||||||
import org.thingsboard.server.common.data.page.PageData;
|
import org.thingsboard.server.common.data.page.PageData;
|
||||||
import org.thingsboard.server.common.data.page.PageLink;
|
import org.thingsboard.server.common.data.page.PageLink;
|
||||||
import org.thingsboard.server.common.data.page.SortOrder;
|
import org.thingsboard.server.common.data.page.SortOrder;
|
||||||
import org.thingsboard.server.common.data.page.TimePageLink;
|
import org.thingsboard.server.common.data.page.TimePageLink;
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentDescriptor;
|
import org.thingsboard.server.common.data.plugin.ComponentDescriptor;
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentType;
|
import org.thingsboard.server.common.data.plugin.ComponentType;
|
||||||
|
import org.thingsboard.server.common.data.query.AlarmData;
|
||||||
|
import org.thingsboard.server.common.data.query.AlarmDataQuery;
|
||||||
|
import org.thingsboard.server.common.data.query.EntityCountQuery;
|
||||||
|
import org.thingsboard.server.common.data.query.EntityData;
|
||||||
|
import org.thingsboard.server.common.data.query.EntityDataQuery;
|
||||||
import org.thingsboard.server.common.data.relation.EntityRelation;
|
import org.thingsboard.server.common.data.relation.EntityRelation;
|
||||||
import org.thingsboard.server.common.data.relation.EntityRelationInfo;
|
import org.thingsboard.server.common.data.relation.EntityRelationInfo;
|
||||||
import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
|
import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
|
||||||
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
||||||
|
import org.thingsboard.server.common.data.rule.DefaultRuleChainCreateRequest;
|
||||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||||
|
import org.thingsboard.server.common.data.rule.RuleChainData;
|
||||||
import org.thingsboard.server.common.data.rule.RuleChainMetaData;
|
import org.thingsboard.server.common.data.rule.RuleChainMetaData;
|
||||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||||
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
|
||||||
@ -325,6 +347,19 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<AssetInfo> getAssetInfoById(AssetId assetId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<AssetInfo> asset = restTemplate.getForEntity(baseURL + "/api/asset/info/{assetId}", AssetInfo.class, assetId.getId());
|
||||||
|
return Optional.ofNullable(asset.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Asset saveAsset(Asset asset) {
|
public Asset saveAsset(Asset asset) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/asset", asset, Asset.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/asset", asset, Asset.class).getBody();
|
||||||
}
|
}
|
||||||
@ -390,6 +425,20 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
return assets.getBody();
|
return assets.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<AssetInfo> getTenantAssetInfos(PageLink pageLink, String assetType) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("type", assetType);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
|
||||||
|
ResponseEntity<PageData<AssetInfo>> assets = restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenant/assetInfos?type={type}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<AssetInfo>>() {
|
||||||
|
},
|
||||||
|
params);
|
||||||
|
return assets.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<Asset> getTenantAsset(String assetName) {
|
public Optional<Asset> getTenantAsset(String assetName) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Asset> asset = restTemplate.getForEntity(baseURL + "/api/tenant/assets?assetName={assetName}", Asset.class, assetName);
|
ResponseEntity<Asset> asset = restTemplate.getForEntity(baseURL + "/api/tenant/assets?assetName={assetName}", Asset.class, assetName);
|
||||||
@ -419,6 +468,22 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
return assets.getBody();
|
return assets.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<AssetInfo> getCustomerAssetInfos(CustomerId customerId, PageLink pageLink, String assetType) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("customerId", customerId.getId().toString());
|
||||||
|
params.put("type", assetType);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
|
||||||
|
ResponseEntity<PageData<AssetInfo>> assets = restTemplate.exchange(
|
||||||
|
baseURL + "/api/customer/{customerId}/assetInfos?type={type}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<AssetInfo>>() {
|
||||||
|
},
|
||||||
|
params);
|
||||||
|
return assets.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Asset> getAssetsByIds(List<AssetId> assetIds) {
|
public List<Asset> getAssetsByIds(List<AssetId> assetIds) {
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/assets?assetIds={assetIds}",
|
baseURL + "/api/assets?assetIds={assetIds}",
|
||||||
@ -593,11 +658,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<JsonNode> activateUser(UserId userId, String password) {
|
public Optional<JsonNode> activateUser(UserId userId, String password) {
|
||||||
|
return activateUser(userId, password, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<JsonNode> activateUser(UserId userId, String password, boolean sendActivationMail) {
|
||||||
ObjectNode activateRequest = objectMapper.createObjectNode();
|
ObjectNode activateRequest = objectMapper.createObjectNode();
|
||||||
activateRequest.put("activateToken", getActivateToken(userId));
|
activateRequest.put("activateToken", getActivateToken(userId));
|
||||||
activateRequest.put("password", password);
|
activateRequest.put("password", password);
|
||||||
try {
|
try {
|
||||||
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/activate", activateRequest, JsonNode.class);
|
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/activate?sendActivationMail={sendActivationMail}", activateRequest, JsonNode.class, sendActivationMail);
|
||||||
return Optional.ofNullable(jsonNode.getBody());
|
return Optional.ofNullable(jsonNode.getBody());
|
||||||
} catch (HttpClientErrorException exception) {
|
} catch (HttpClientErrorException exception) {
|
||||||
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
@ -936,8 +1005,25 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<DeviceInfo> getDeviceInfoById(DeviceId deviceId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<DeviceInfo> device = restTemplate.getForEntity(baseURL + "/api/device/info/{deviceId}", DeviceInfo.class, deviceId);
|
||||||
|
return Optional.ofNullable(device.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Device saveDevice(Device device) {
|
public Device saveDevice(Device device) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody();
|
return saveDevice(device, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Device saveDevice(Device device, String accessToken) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/device?accessToken={accessToken}", device, Device.class, accessToken).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteDevice(DeviceId deviceId) {
|
public void deleteDevice(DeviceId deviceId) {
|
||||||
@ -1011,6 +1097,18 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<DeviceInfo> getTenantDeviceInfos(String type, DeviceProfileId deviceProfileId, PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("type", type);
|
||||||
|
params.put("deviceProfileId", deviceProfileId != null ? deviceProfileId.toString() : null);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenant/deviceInfos?type={type}&deviceProfileId={deviceProfileId}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<DeviceInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<Device> getTenantDevice(String deviceName) {
|
public Optional<Device> getTenantDevice(String deviceName) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/tenant/devices?deviceName={deviceName}", Device.class, deviceName);
|
ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/tenant/devices?deviceName={deviceName}", Device.class, deviceName);
|
||||||
@ -1036,6 +1134,19 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<DeviceInfo> getCustomerDeviceInfos(CustomerId customerId, String deviceType, DeviceProfileId deviceProfileId, PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("customerId", customerId.toString());
|
||||||
|
params.put("type", deviceType);
|
||||||
|
params.put("deviceProfileId", deviceProfileId != null ? deviceProfileId.toString() : null);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/customer/{customerId}/devices?type={type}&deviceProfileId={deviceProfileId}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<DeviceInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Device> getDevicesByIds(List<DeviceId> deviceIds) {
|
public List<Device> getDevicesByIds(List<DeviceId> deviceIds) {
|
||||||
return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}",
|
return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}",
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
@ -1074,6 +1185,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
restTemplate.delete(baseURL + "/api/customer/device/{deviceName}/claim", deviceName);
|
restTemplate.delete(baseURL + "/api/customer/device/{deviceName}/claim", deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Device assignDeviceToTenant(TenantId tenantId, DeviceId deviceId) {
|
||||||
|
return restTemplate.postForEntity(
|
||||||
|
baseURL + "/api/tenant/{tenantId}/device/{deviceId}",
|
||||||
|
HttpEntity.EMPTY, Device.class, tenantId, deviceId).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Device createDevice(String name, String type) {
|
public Device createDevice(String name, String type) {
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
@ -1138,6 +1255,91 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
customerId.toString(), deviceId.toString()).getBody();
|
customerId.toString(), deviceId.toString()).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<DeviceProfile> getDeviceProfileById(DeviceProfileId deviceProfileId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<DeviceProfile> deviceProfile = restTemplate.getForEntity(baseURL + "/api/deviceProfile/{deviceProfileId}", DeviceProfile.class, deviceProfileId);
|
||||||
|
return Optional.ofNullable(deviceProfile.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<DeviceProfileInfo> getDeviceProfileInfoById(DeviceProfileId deviceProfileId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<DeviceProfileInfo> deviceProfileInfo = restTemplate.getForEntity(baseURL + "/api/deviceProfileInfo/{deviceProfileId}", DeviceProfileInfo.class, deviceProfileId);
|
||||||
|
return Optional.ofNullable(deviceProfileInfo.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceProfileInfo getDefaultDeviceProfileInfo() {
|
||||||
|
return restTemplate.getForEntity(baseURL + "/api/deviceProfileInfo/default", DeviceProfileInfo.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceProfile saveDeviceProfile(DeviceProfile deviceProfile) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/deviceProfile", deviceProfile, DeviceProfile.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteDeviceProfile(DeviceProfileId deviceProfileId) {
|
||||||
|
restTemplate.delete(baseURL + "/api/deviceProfile/{deviceProfileId}", deviceProfileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceProfile setDefaultDeviceProfile(DeviceProfileId deviceProfileId) {
|
||||||
|
return restTemplate.postForEntity(
|
||||||
|
baseURL + "/api/deviceProfile/{deviceProfileId}/default",
|
||||||
|
HttpEntity.EMPTY, DeviceProfile.class, deviceProfileId).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<DeviceProfile> getTenantDevices(PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/deviceProfiles?" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<DeviceProfile>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<DeviceProfileInfo> getDeviceProfileInfos(PageLink pageLink, DeviceTransportType deviceTransportType) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("deviceTransportType", deviceTransportType != null ? deviceTransportType.name() : null);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/deviceProfileInfos?deviceTransportType={deviceTransportType}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET, HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<DeviceProfileInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long countEntitiesByQuery(EntityCountQuery query) {
|
||||||
|
return restTemplate.postForObject(baseURL + "/api/entitiesQuery/count", query, Long.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<EntityData> findEntityDataByQuery(EntityDataQuery query) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/entitiesQuery/find",
|
||||||
|
HttpMethod.POST, new HttpEntity<>(query),
|
||||||
|
new ParameterizedTypeReference<PageData<EntityData>>() {
|
||||||
|
}).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<AlarmData> findAlarmDataByQuery(AlarmDataQuery query) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/alarmsQuery/find",
|
||||||
|
HttpMethod.POST, new HttpEntity<>(query),
|
||||||
|
new ParameterizedTypeReference<PageData<AlarmData>>() {
|
||||||
|
}).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public void saveRelation(EntityRelation relation) {
|
public void saveRelation(EntityRelation relation) {
|
||||||
restTemplate.postForLocation(baseURL + "/api/relation", relation);
|
restTemplate.postForLocation(baseURL + "/api/relation", relation);
|
||||||
}
|
}
|
||||||
@ -1313,6 +1515,19 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<EntityViewInfo> getEntityViewInfoById(EntityViewId entityViewId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<EntityViewInfo> entityView = restTemplate.getForEntity(baseURL + "/api/entityView/info/{entityViewId}", EntityViewInfo.class, entityViewId);
|
||||||
|
return Optional.ofNullable(entityView.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public EntityView saveEntityView(EntityView entityView) {
|
public EntityView saveEntityView(EntityView entityView) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/entityView", entityView, EntityView.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/entityView", entityView, EntityView.class).getBody();
|
||||||
}
|
}
|
||||||
@ -1373,6 +1588,19 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<EntityViewInfo> getCustomerEntityViewInfos(CustomerId customerId, String entityViewType, PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("customerId", customerId.toString());
|
||||||
|
params.put("type", entityViewType);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/customer/{customerId}/entityViewInfos?type={type}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<EntityViewInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public PageData<EntityView> getTenantEntityViews(String entityViewType, PageLink pageLink) {
|
public PageData<EntityView> getTenantEntityViews(String entityViewType, PageLink pageLink) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("type", entityViewType);
|
params.put("type", entityViewType);
|
||||||
@ -1385,6 +1613,18 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<EntityViewInfo> getTenantEntityViewInfos(String entityViewType, PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("type", entityViewType);
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenant/entityViewInfos?type={type}&" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<EntityViewInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public List<EntityView> findByQuery(EntityViewSearchQuery query) {
|
public List<EntityView> findByQuery(EntityViewSearchQuery query) {
|
||||||
return restTemplate.exchange(baseURL + "/api/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() {
|
return restTemplate.exchange(baseURL + "/api/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() {
|
||||||
}).getBody();
|
}).getBody();
|
||||||
@ -1437,8 +1677,41 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
HttpEntity.EMPTY,
|
HttpEntity.EMPTY,
|
||||||
new ParameterizedTypeReference<PageData<Event>>() {
|
new ParameterizedTypeReference<PageData<Event>>() {
|
||||||
},
|
}, params).getBody();
|
||||||
params).getBody();
|
}
|
||||||
|
|
||||||
|
public OAuth2ClientRegistrationTemplate saveClientRegistrationTemplate(OAuth2ClientRegistrationTemplate clientRegistrationTemplate) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/oauth2/config/template", clientRegistrationTemplate, OAuth2ClientRegistrationTemplate.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteClientRegistrationTemplate(OAuth2ClientRegistrationTemplateId oAuth2ClientRegistrationTemplateId) {
|
||||||
|
restTemplate.delete(baseURL + "/api/oauth2/config/template/{clientRegistrationTemplateId}", oAuth2ClientRegistrationTemplateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OAuth2ClientRegistrationTemplate> getClientRegistrationTemplates() {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/oauth2/config/template",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<OAuth2ClientRegistrationTemplate>>() {
|
||||||
|
}).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OAuth2ClientInfo> getOAuth2Clients() {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/noauth/oauth2Clients",
|
||||||
|
HttpMethod.POST,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<OAuth2ClientInfo>>() {
|
||||||
|
}).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuth2ClientsParams getCurrentOAuth2Params() {
|
||||||
|
return restTemplate.getForEntity(baseURL + "/api/oauth2/config", OAuth2ClientsParams.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuth2ClientsParams saveOAuth2Params(OAuth2ClientsParams oauth2Params) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/oauth2/config", oauth2Params, OAuth2ClientsParams.class).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleOneWayDeviceRPCRequest(DeviceId deviceId, JsonNode requestBody) {
|
public void handleOneWayDeviceRPCRequest(DeviceId deviceId, JsonNode requestBody) {
|
||||||
@ -1485,6 +1758,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RuleChain saveRuleChain(DefaultRuleChainCreateRequest request) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/ruleChain/device/default", request, RuleChain.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<RuleChain> setRootRuleChain(RuleChainId ruleChainId) {
|
public Optional<RuleChain> setRootRuleChain(RuleChainId ruleChainId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId.getId());
|
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId.getId());
|
||||||
@ -1544,6 +1821,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RuleChainData exportRuleChains(int limit) {
|
||||||
|
return restTemplate.getForEntity(baseURL + "/api/ruleChains/export?limit=" + limit, RuleChainData.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importRuleChains(RuleChainData ruleChainData, boolean overwrite) {
|
||||||
|
restTemplate.postForLocation(baseURL + "/api/ruleChains/import?overwrite=" + overwrite, ruleChainData);
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getAttributeKeys(EntityId entityId) {
|
public List<String> getAttributeKeys(EntityId entityId) {
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/plugins/telemetry/{entityType}/{entityId}/keys/attributes",
|
baseURL + "/api/plugins/telemetry/{entityType}/{entityId}/keys/attributes",
|
||||||
@ -1805,6 +2090,19 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<TenantInfo> getTenantInfoById(TenantId tenantId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<TenantInfo> tenant = restTemplate.getForEntity(baseURL + "/api/tenant/info/{tenantId}", TenantInfo.class, tenantId);
|
||||||
|
return Optional.ofNullable(tenant.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Tenant saveTenant(Tenant tenant) {
|
public Tenant saveTenant(Tenant tenant) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody();
|
||||||
}
|
}
|
||||||
@ -1824,6 +2122,81 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}, params).getBody();
|
}, params).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<TenantInfo> getTenantInfos(PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenantInfos?" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<TenantInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<TenantProfile> getTenantProfileById(TenantProfileId tenantProfileId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<TenantProfile> tenantProfile = restTemplate.getForEntity(baseURL + "/api/tenantProfile/{tenantProfileId}", TenantProfile.class, tenantProfileId);
|
||||||
|
return Optional.ofNullable(tenantProfile.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<EntityInfo> getTenantProfileInfoById(TenantProfileId tenantProfileId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<EntityInfo> entityInfo = restTemplate.getForEntity(baseURL + "/api/tenantProfileInfo/{tenantProfileId}", EntityInfo.class, tenantProfileId);
|
||||||
|
return Optional.ofNullable(entityInfo.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityInfo getDefaultTenantProfileInfo() {
|
||||||
|
return restTemplate.getForEntity(baseURL + "/api/tenantProfileInfo/default", EntityInfo.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TenantProfile saveTenantProfile(TenantProfile tenantProfile) {
|
||||||
|
return restTemplate.postForEntity(baseURL + "/api/tenantProfile", tenantProfile, TenantProfile.class).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteTenantProfile(TenantProfileId tenantProfileId) {
|
||||||
|
restTemplate.delete(baseURL + "/api/tenantProfile/{tenantProfileId}", tenantProfileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TenantProfile setDefaultTenantProfile(TenantProfileId tenantProfileId) {
|
||||||
|
return restTemplate.exchange(baseURL + "/api/tenantProfile/{tenantProfileId}/default", HttpMethod.POST, HttpEntity.EMPTY, TenantProfile.class, tenantProfileId).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<TenantProfile> getTenantProfiles(PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenantProfiles" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<TenantProfile>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageData<EntityInfo> getTenantProfileInfos(PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/tenantProfileInfos" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<EntityInfo>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<User> getUserById(UserId userId) {
|
public Optional<User> getUserById(UserId userId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId.getId());
|
ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId.getId());
|
||||||
@ -1870,6 +2243,17 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
restTemplate.delete(baseURL + "/api/user/{userId}", userId.getId());
|
restTemplate.delete(baseURL + "/api/user/{userId}", userId.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<User> getUsers(PageLink pageLink) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/users" + getUrlParams(pageLink),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<User>>() {
|
||||||
|
}, params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public PageData<User> getTenantAdmins(TenantId tenantId, PageLink pageLink) {
|
public PageData<User> getTenantAdmins(TenantId tenantId, PageLink pageLink) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("tenantId", tenantId.getId().toString());
|
params.put("tenantId", tenantId.getId().toString());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user