use of com.microsoft.azure.sdk.iot.service.RegistryManager in project azure-iot-sdk-java by Azure.
the class DeviceManagerSample method GetDevice.
private static void GetDevice() throws Exception {
RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
Device returnDevice;
try {
returnDevice = registryManager.getDevice(SampleUtils.deviceId);
System.out.println("Device: " + returnDevice.getDeviceId());
System.out.println("Device primary key: " + returnDevice.getPrimaryKey());
System.out.println("Device secondary key: " + returnDevice.getSecondaryKey());
System.out.println("Device ETag: " + returnDevice.geteTag());
} catch (IotHubException | IOException iote) {
iote.printStackTrace();
}
registryManager.close();
}
use of com.microsoft.azure.sdk.iot.service.RegistryManager in project azure-iot-sdk-java by Azure.
the class DeviceManagerX509Sample method RemoveDevice.
private static void RemoveDevice() throws Exception {
RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
try {
registryManager.removeDevice(SampleUtils.deviceId);
System.out.println("Device removed: " + SampleUtils.deviceId);
} catch (IotHubException | IOException iote) {
iote.printStackTrace();
}
registryManager.close();
}
use of com.microsoft.azure.sdk.iot.service.RegistryManager in project azure-iot-sdk-java by Azure.
the class ModuleManagerSample method UpdateModule.
private static void UpdateModule() throws Exception {
String primaryKey = "[New primary key goes here]";
String secondaryKey = "[New secondary key goes here]";
RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
Module module = Module.createFromId(SampleUtils.deviceId, SampleUtils.moduleId0, null);
module.getSymmetricKey().setPrimaryKeyFinal(primaryKey);
module.getSymmetricKey().setSecondaryKeyFinal(secondaryKey);
try {
module = registryManager.updateModule(module);
System.out.println("Device updated: " + module.getId());
System.out.println("Device primary key: " + module.getPrimaryKey());
System.out.println("Device secondary key: " + module.getSecondaryKey());
} catch (IotHubException | IOException iote) {
iote.printStackTrace();
}
registryManager.close();
}
use of com.microsoft.azure.sdk.iot.service.RegistryManager in project azure-iot-sdk-java by Azure.
the class ModuleManagerSample method AddModule.
private static void AddModule(int n) throws Exception {
RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
String moduleId;
if (n == 0) {
moduleId = SampleUtils.moduleId0;
} else {
moduleId = SampleUtils.moduleId1;
}
Module module = Module.createFromId(SampleUtils.deviceId, moduleId, null);
try {
module = registryManager.addModule(module);
System.out.println("Module created: " + module.getId());
} catch (IotHubException | IOException iote) {
iote.printStackTrace();
}
registryManager.close();
}
Aggregations