com.microsoft.azure.sdk.iot.service.digitaltwin.readme.md Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iot-service-client Show documentation
Show all versions of iot-service-client Show documentation
The Microsoft Azure IoT Service SDK for Java
The newest version!
## Examples
You can familiarize yourself with different APIs using [samples for DigitalTwinClient](https://github.com/Azure/azure-iot-sdk-java/tree/main/service/iot-service-samples/digitaltwin-service-samples).
## Source code folder structure
### /authentication
The code for generating shared access signature tokens, used for authentication Http requests against Azure IoT Hub service.
### /generated
The code generated by autorest using the swagger file defined under [DigitalTwin.json](https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/digitaltwin/swagger/digitalTwin.json).
### /src/Customized
The customzied code written to override the following behavior of auto-generated code:
- Rename some of the generated types, eg. [DigitalTwinGetHeaders](https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/digitaltwin/customized/DigitalTwinGetHeaders.java)
### /src/models
Model classes useful for use with the Digital Twin client operations.
### /src/serialization
Serialization helpers provided to help serialize/deserialize commonly used types when working with digital twins.
## Protocol layer generation:
- Go in folder ./swagger and run the powershell script [generateCode.ps1](https://github.com/Azure/azure-iot-sdk-java/blob/main/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/digitaltwin/swagger/generate.ps1). It will pick up the [autorest config](./swagger/readme.md) and output the results into [generated](./generated) folder. It will also make a few automated changes to the generated protocol layer, that are required for this client library.
## Troubleshooting
All service operations will throw RestException on failure reported by the service, with helpful error codes and other information.
```java
try
{
ServiceResponseWithHeaders commandResponse = client.invokeCommandWithResponse(digitalTwinid, commandName, commandInput, options);
}
catch (RestException ex)
{
if (ex.response().code() == 404)
{
System.out.println("404");
}
else
{
throw ex;
}
}
```