Search in sources :

Example 11 with DigitalTwinGetHeaders

use of com.microsoft.azure.sdk.iot.service.digitaltwin.customized.DigitalTwinGetHeaders in project azure-iot-sdk-java by Azure.

the class TemperatureController method GetDigitalTwin.

private static ServiceResponseWithHeaders<String, DigitalTwinGetHeaders> GetDigitalTwin() {
    ServiceResponseWithHeaders<String, DigitalTwinGetHeaders> getResponse = client.getDigitalTwinWithResponse(digitalTwinid, String.class);
    JsonObject jsonObject = new JsonParser().parse(getResponse.body()).getAsJsonObject();
    String modelId = jsonObject.getAsJsonObject("$metadata").get("$model").getAsString();
    System.out.println("Digital Twin Model Id:" + modelId);
    System.out.println("Digital Twin: " + prettyString(getResponse.body()));
    System.out.println("Digital Twin eTag: " + getResponse.headers().eTag());
    System.out.println("Digital Twin get response message: " + getResponse.response().message());
    return getResponse;
}
Also used : JsonObject(com.google.gson.JsonObject) DigitalTwinGetHeaders(com.microsoft.azure.sdk.iot.service.digitaltwin.customized.DigitalTwinGetHeaders) JsonParser(com.google.gson.JsonParser)

Aggregations

DigitalTwinGetHeaders (com.microsoft.azure.sdk.iot.service.digitaltwin.customized.DigitalTwinGetHeaders)11 BasicDigitalTwin (com.microsoft.azure.sdk.iot.service.digitaltwin.serialization.BasicDigitalTwin)9 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)8 DigitalTwinTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.DigitalTwinTest)8 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)8 Test (org.junit.Test)7 DeviceClient (com.microsoft.azure.sdk.iot.device.DeviceClient)4 MultiplexingClient (com.microsoft.azure.sdk.iot.device.MultiplexingClient)3 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)3 DigitalTwinClient (com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient)3 UpdateOperationUtility (com.microsoft.azure.sdk.iot.service.digitaltwin.UpdateOperationUtility)3 ArrayList (java.util.ArrayList)3 JsonObject (com.google.gson.JsonObject)2 ProxyOptions (com.microsoft.azure.sdk.iot.service.ProxyOptions)2 RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)2 DigitalTwinClientOptions (com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClientOptions)2 AzureSasCredential (com.azure.core.credential.AzureSasCredential)1 TokenCredential (com.azure.core.credential.TokenCredential)1 JsonParser (com.google.gson.JsonParser)1 ClientOptions (com.microsoft.azure.sdk.iot.device.ClientOptions)1