|
|
|
@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.relation.EntityRelation; |
|
|
|
import org.thingsboard.server.common.data.security.DeviceCredentials; |
|
|
|
import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Collections; |
|
|
|
@ -120,6 +121,21 @@ public class RestClient implements ClientHttpRequestInterceptor { |
|
|
|
return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public void deleteDevice(DeviceId deviceId) { |
|
|
|
restTemplate.delete(baseURL + "/api/device/" + deviceId.getId().toString()); |
|
|
|
} |
|
|
|
|
|
|
|
public DeviceCredentials updateDeviceCredentials(DeviceId deviceId, String token) { |
|
|
|
DeviceCredentials deviceCredentials = getCredentials(deviceId); |
|
|
|
deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN); |
|
|
|
deviceCredentials.setCredentialsId(token); |
|
|
|
return saveDeviceCredentials(deviceCredentials); |
|
|
|
} |
|
|
|
|
|
|
|
public DeviceCredentials saveDeviceCredentials(DeviceCredentials deviceCredentials) { |
|
|
|
return restTemplate.postForEntity(baseURL + "/api/device/credentials", deviceCredentials, DeviceCredentials.class).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public Asset createAsset(String name, String type) { |
|
|
|
Asset asset = new Asset(); |
|
|
|
asset.setName(name); |
|
|
|
|