RegistryClient Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.registry.RegistryClient

public class RegistryClient

Use the RegistryClient to manage the identity registry in IoT hubs. To access twins, use the TwinClient.

Constructor Summary

Constructor Description
RegistryClient(String connectionString)

Constructor to create instance from connection string

RegistryClient(String hostName, AzureSasCredential azureSasCredential)

Create a new RegistryClient instance.

RegistryClient(String hostName, AzureSasCredential azureSasCredential, RegistryClientOptions options)

Create a new RegistryClient instance.

RegistryClient(String connectionString, RegistryClientOptions options)

Constructor to create instance from connection string

RegistryClient(String hostName, TokenCredential credential)

Create a new RegistryClient instance.

RegistryClient(String hostName, TokenCredential credential, RegistryClientOptions options)

Create a new RegistryClient instance.

Method Summary

Modifier and Type Method and Description
Device addDevice(Device device)

Add device using the given Device object Return with the response device object from IotHub

Module addModule(Module module)

Add module using the given Module object Return with the response module object from IotHub

RegistryJob exportDevices(RegistryJob exportDevicesParameters)

Create a bulk export job.

RegistryJob exportDevices(String exportBlobContainerUri, boolean excludeKeys)

Create a bulk export job.

Device getDevice(String deviceId)

Get device data by device Id from IotHub

RegistryJob getJob(String jobId)

Get the properties of an existing job.

Module getModule(String deviceId, String moduleId)

Get module data by device Id and module Id from IotHub

List<Module> getModulesOnDevice(String deviceId)

Get modules data by device Id from IotHub

RegistryStatistics getStatistics()

Get device statistics

RegistryJob importDevices(RegistryJob importDevicesParameters)

Create a bulk import job.

RegistryJob importDevices(String importBlobContainerUri, String outputBlobContainerUri)

Create a bulk import job.

void removeDevice(Device device)

Remove device

void removeDevice(String deviceId)

Remove device

void removeModule(Module module)

Remove module

void removeModule(String deviceId, String moduleId)

Remove module

Device updateDevice(Device device)

Update device not forced

Module updateModule(Module module)

Update module not forced

Constructor Details

RegistryClient

public RegistryClient(String connectionString)

Constructor to create instance from connection string

Parameters:

connectionString - The iot hub connection string

RegistryClient

public RegistryClient(String hostName, AzureSasCredential azureSasCredential)

Create a new RegistryClient instance.

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
azureSasCredential - The SAS token provider that will be used for authentication.

RegistryClient

public RegistryClient(String hostName, AzureSasCredential azureSasCredential, RegistryClientOptions options)

Create a new RegistryClient instance.

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
azureSasCredential - The SAS token provider that will be used for authentication.
options - The connection options to use when connecting to the service.

RegistryClient

public RegistryClient(String connectionString, RegistryClientOptions options)

Constructor to create instance from connection string

Parameters:

connectionString - The iot hub connection string
options - The connection options to use when connecting to the service.

RegistryClient

public RegistryClient(String hostName, TokenCredential credential)

Create a new RegistryClient instance.

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
credential - The custom TokenCredential that will provide authentication tokens to this library when they are needed. The provided tokens must be Json Web Tokens.

RegistryClient

public RegistryClient(String hostName, TokenCredential credential, RegistryClientOptions options)

Create a new RegistryClient instance.

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
credential - The custom TokenCredential that will provide authentication tokens to this library when they are needed. The provided tokens must be Json Web Tokens.
options - The connection options to use when connecting to the service.

Method Details

addDevice

public Device addDevice(Device device)

Add device using the given Device object Return with the response device object from IotHub

Parameters:

device - The device object to add

Returns:

The future object for the requested operation

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

addModule

public Module addModule(Module module)

Add module using the given Module object Return with the response module object from IotHub

Parameters:

module - The module object to add

Returns:

The module object for the requested operation

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

exportDevices

public RegistryJob exportDevices(RegistryJob exportDevicesParameters)

Create a bulk export job.

Parameters:

exportDevicesParameters - A RegistryJob object containing input parameters for export Devices job This API also supports identity based storage authentication, identity authentication support is currently available in limited regions. If a user wishes to try it out, they will need to set an Environment Variable of "EnabledStorageIdentity" and set it to "1" otherwise default key based authentication is used for storage More details here

Returns:

A RegistryJob object for the newly created bulk export job

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

exportDevices

public RegistryJob exportDevices(String exportBlobContainerUri, boolean excludeKeys)

Create a bulk export job.

Parameters:

exportBlobContainerUri - URI containing SAS token to a blob container where export data will be placed
excludeKeys - Whether the devices keys should be excluded from the exported data or not

Returns:

A RegistryJob object for the newly created bulk export job

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

getDevice

public Device getDevice(String deviceId)

Get device data by device Id from IotHub

Parameters:

deviceId - The id of requested device

Returns:

The device object of requested device

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

getJob

public RegistryJob getJob(String jobId)

Get the properties of an existing job.

Parameters:

jobId - The id of the import/export job to be retrieved.

Returns:

A RegistryJob object for the requested job id

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

getModule

public Module getModule(String deviceId, String moduleId)

Get module data by device Id and module Id from IotHub

Parameters:

deviceId - The id of requested device
moduleId - The id of requested module

Returns:

The module object of requested module on the specific device

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

getModulesOnDevice

public List getModulesOnDevice(String deviceId)

Get modules data by device Id from IotHub

Parameters:

deviceId - The id of requested device

Returns:

The module objects on the specific device

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

getStatistics

public RegistryStatistics getStatistics()

Get device statistics

Returns:

RegistryStatistics object containing the requested data

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

importDevices

public RegistryJob importDevices(RegistryJob importDevicesParameters)

Create a bulk import job.

Parameters:

importDevicesParameters - A RegistryJob object containing input parameters for import Devices job This API also supports identity based storage authentication, identity authentication support is currently available in limited regions. If a user wishes to try it out, they will need to set an Environment Variable of "EnabledStorageIdentity" and set it to "1" otherwise default key based authentication is used for storage More details here

Returns:

A RegistryJob object for the newly created bulk import job

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

importDevices

public RegistryJob importDevices(String importBlobContainerUri, String outputBlobContainerUri)

Create a bulk import job.

Parameters:

importBlobContainerUri - URI containing SAS token to a blob container that contains registry data to sync
outputBlobContainerUri - URI containing SAS token to a blob container where the result of the bulk import operation will be placed

Returns:

A RegistryJob object for the newly created bulk import job

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

removeDevice

public void removeDevice(Device device)

Remove device

Parameters:

device - The device name to remove

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

removeDevice

public void removeDevice(String deviceId)

Remove device

Parameters:

deviceId - The device name to remove

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

removeModule

public void removeModule(Module module)

Remove module

Parameters:

module - The module to be removed

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

removeModule

public void removeModule(String deviceId, String moduleId)

Remove module

Parameters:

deviceId - The device name associated with the module to be removed
moduleId - The module name to be removed

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

updateDevice

public Device updateDevice(Device device)

Update device not forced

Parameters:

device - The device object containing updated data

Returns:

The updated device object

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

updateModule

public Module updateModule(Module module)

Update module not forced

Parameters:

module - The module object containing updated data

Returns:

The updated module object

Throws:

IOException - This exception is thrown if the IO operation failed
IotHubException - This exception is thrown if the response verification failed

Applies to