Search in sources :

Example 1 with WrappedDeviceTwinDevice

use of io.swagger.server.api.verticle.WrappedDeviceTwinDevice in project azure-iot-sdk-java by Azure.

the class RegistryGlue method getModuleTwin.

public void getModuleTwin(String connectionId, String deviceId, String moduleId, Handler<AsyncResult<Object>> handler) {
    System.out.printf("getModuleTwin called for %s with deviceId = %s and moduleId = %s%n", connectionId, deviceId, moduleId);
    DeviceTwin client = getClient(connectionId);
    if (client == null) {
        handler.handle(Future.failedFuture(new MainApiException(500, "invalid connection id")));
    } else {
        WrappedDeviceTwinDevice twin = new WrappedDeviceTwinDevice(deviceId, moduleId);
        try {
            client.getTwin(twin);
        } catch (IOException | IotHubException e) {
            handler.handle(Future.failedFuture(e));
        }
        handler.handle(Future.succeededFuture(twin.toJsonObject()));
    }
}
Also used : IOException(java.io.IOException) MainApiException(io.swagger.server.api.MainApiException) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException) DeviceTwin(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin) WrappedDeviceTwinDevice(io.swagger.server.api.verticle.WrappedDeviceTwinDevice)

Aggregations

DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)1 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)1 MainApiException (io.swagger.server.api.MainApiException)1 WrappedDeviceTwinDevice (io.swagger.server.api.verticle.WrappedDeviceTwinDevice)1 IOException (java.io.IOException)1