IotHubConnectionString Class

public class IotHubConnectionString extends IotHubConnectionStringBuilder

Expose all connections string properties and methods for user, device and connection string serialization.

Method Summary

Modifier and Type Method and Description
AuthenticationMethod getAuthenticationMethod()

Getter for authenticationMethod

String getHostName()

Getter for hostName

String getIotHubName()

Getter for iotHubName

String getSharedAccessKey()

Getter for sharedAccessKey

String getSharedAccessKeyName()

Getter for sharedAccessKeyName

String getSharedAccessSignature()

Getter for sharedAccessSignature

URL getUrlApplyConfigurationContent(String deviceId)

Create the url needed to apply some configuration content to a device

URL getUrlApplyConfigurationContent(String hostName, String deviceId)

Create the url needed to apply some configuration content to a device

URL getUrlConfiguration(String configurationId)

Create url for requesting configuration data

URL getUrlConfiguration(String hostName, String configurationId)

Create url for requesting configuration data

URL getUrlConfigurationsList(Integer maxCount)

Create url for requesting configuration data

URL getUrlConfigurationsList(String hostName, Integer maxCount)

Create url for requesting configuration data

URL getUrlCreateExportImportJob()

Create url for processing a bulk import/export job

URL getUrlCreateExportImportJob(String hostName)

Create url for processing a bulk import/export job

URL getUrlDevice(String deviceId)

Create url for requesting device data

URL getUrlDevice(String hostName, String deviceId)

Create url for requesting device data

URL getUrlDeviceList(Integer maxCount)

Create url for requesting device list

URL getUrlDeviceList(String hostName, Integer maxCount)

Create url for requesting device list

URL getUrlDeviceStatistics()

Create url for requesting device statistics

URL getUrlDeviceStatistics(String hostName)

Create url for requesting device statistics

URL getUrlImportExportJob(String jobId)
URL getUrlImportExportJob(String hostName, String jobId)
URL getUrlJobs(String jobId)

Create url for requesting jobs

URL getUrlJobs(String hostName, String jobId)

Create url for requesting jobs

URL getUrlJobsCancel(String jobId)

Create url for cancelling jobs

URL getUrlJobsCancel(String hostName, String jobId)

Create url for cancelling jobs

URL getUrlMethod(String deviceId)

Create url for requesting device method

URL getUrlMethod(String hostName, String deviceId)

Create url for requesting device method

URL getUrlModule(String deviceId, String moduleId)

Create url for requesting module data

URL getUrlModule(String hostName, String deviceId, String moduleId)

Create url for requesting module data

URL getUrlModuleMethod(String deviceId, String moduleId)

Create url for requesting device method for module

URL getUrlModuleMethod(String hostName, String deviceId, String moduleId)

Create url for requesting device method for module

URL getUrlModulesOnDevice(String deviceId)

Create url for requesting all modules data on a device

URL getUrlModulesOnDevice(String hostName, String deviceId)

Create url for requesting all modules data on a device

URL getUrlModuleTwin(String deviceId, String moduleId)

Create url for requesting module twin

URL getUrlModuleTwin(String hostName, String deviceId, String moduleId)

Create url for requesting module twin

URL getUrlQuery(String jobType, String jobStatus)

Create url for querying

URL getUrlQuery(String hostName, String jobType, String jobStatus)

Create url for querying

URL getUrlTwin(String deviceId)

Create url for requesting device twin

URL getUrlTwin(String hostName, String deviceId)

Create url for requesting device twin

URL getUrlTwinQuery()

Create url for querying twin

URL getUrlTwinQuery(String hostName)

Create url for querying twin

String toString()

Serialize connection string

Inherited Members

Method Details

getAuthenticationMethod

public AuthenticationMethod getAuthenticationMethod()

Getter for authenticationMethod

Returns:

The authenticationMethod object

getHostName

public String getHostName()

Getter for hostName

Returns:

The hostName string

getIotHubName

public String getIotHubName()

Getter for iotHubName

Returns:

The iot hub name string

getSharedAccessKey

public String getSharedAccessKey()

Getter for sharedAccessKey

Returns:

The sharedAccessKey string

getSharedAccessKeyName

public String getSharedAccessKeyName()

Getter for sharedAccessKeyName

Returns:

The sharedAccessKeyName string

getSharedAccessSignature

public String getSharedAccessSignature()

Getter for sharedAccessSignature

Returns:

The sharedAccessSignature string

getUrlApplyConfigurationContent

public URL getUrlApplyConfigurationContent(String deviceId)

Create the url needed to apply some configuration content to a device

Parameters:

deviceId - The device to apply the configuration content to

Returns:

The device Url in the following format: "https:[hostname]/devices/[deviceId]/applyConfigurationContent?api-version=201X-XX-XX"

Throws:

MalformedURLException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it
IllegalArgumentException - if deviceId is null or empty

getUrlApplyConfigurationContent

public static URL getUrlApplyConfigurationContent(String hostName, String deviceId)

Create the url needed to apply some configuration content to a device

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The device to apply the configuration content to

Returns:

The device Url in the following format: "https:[hostname]/devices/[deviceId]/applyConfigurationContent?api-version=201X-XX-XX"

Throws:

MalformedURLException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it
IllegalArgumentException - if deviceId is null or empty

getUrlConfiguration

public URL getUrlConfiguration(String configurationId)

Create url for requesting configuration data

Parameters:

configurationId - The name of the configuration

Returns:

The device Url in the following format: "https:hostname/configurations/configurationId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlConfiguration

public static URL getUrlConfiguration(String hostName, String configurationId)

Create url for requesting configuration data

Parameters:

hostName - The hostname of the IoT Hub
configurationId - The name of the configuration

Returns:

The device Url in the following format: "https:hostname/configurations/configurationId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlConfigurationsList

public URL getUrlConfigurationsList(Integer maxCount)

Create url for requesting configuration data

Parameters:

maxCount - The maximum number of configuration data to return

Returns:

The Url in the following format: "https:hostname/configurations/?top=maxcount{@literal &}api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlConfigurationsList

public static URL getUrlConfigurationsList(String hostName, Integer maxCount)

Create url for requesting configuration data

Parameters:

hostName - The hostname of the IoT Hub
maxCount - The maximum number of configuration data to return

Returns:

The Url in the following format: "https:hostname/configurations/?top=maxcount{@literal &}api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlCreateExportImportJob

public URL getUrlCreateExportImportJob()

Create url for processing a bulk import/export job

Returns:

The import/export job URL in the following format: "https:hostname/jobs/create?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlCreateExportImportJob

public static URL getUrlCreateExportImportJob(String hostName)

Create url for processing a bulk import/export job

Parameters:

hostName - The hostname of the IoT Hub

Returns:

The import/export job URL in the following format: "https:hostname/jobs/create?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlDevice

public URL getUrlDevice(String deviceId)

Create url for requesting device data

Parameters:

deviceId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlDevice

public static URL getUrlDevice(String hostName, String deviceId)

Create url for requesting device data

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlDeviceList

public URL getUrlDeviceList(Integer maxCount)

Create url for requesting device list

Parameters:

maxCount - The number of requested devices

Returns:

URL string to get the device list from IotHub

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if maxCount is null or empty

getUrlDeviceList

public static URL getUrlDeviceList(String hostName, Integer maxCount)

Create url for requesting device list

Parameters:

hostName - The hostname of the IoT Hub
maxCount - The number of requested devices

Returns:

URL string to get the device list from IotHub

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if maxCount is null or empty

getUrlDeviceStatistics

public URL getUrlDeviceStatistics()

Create url for requesting device statistics

Returns:

The device statistics Url in the following format: "https:hostname/statistics/devices?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlDeviceStatistics

public static URL getUrlDeviceStatistics(String hostName)

Create url for requesting device statistics

Parameters:

hostName - The hostname of the IoT Hub

Returns:

The device statistics Url in the following format: "https:hostname/statistics/devices?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlImportExportJob

public URL getUrlImportExportJob(String jobId)

Parameters:

jobId - Create url for retrieving a bulk import/export job

Returns:

The import/export job URL in the following format: "https:hostname/jobs/jobId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlImportExportJob

public static URL getUrlImportExportJob(String hostName, String jobId)

Parameters:

hostName - The hostname of the IoT Hub
jobId - Create url for retrieving a bulk import/export job

Returns:

The import/export job URL in the following format: "https:hostname/jobs/jobId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlJobs

public URL getUrlJobs(String jobId)

Create url for requesting jobs

Parameters:

jobId - is the name of the job

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/[jobId]?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if job id is null or empty

getUrlJobs

public static URL getUrlJobs(String hostName, String jobId)

Create url for requesting jobs

Parameters:

hostName - The hostname of the IoT Hub
jobId - is the name of the job

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/[jobId]?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if job id is null or empty

getUrlJobsCancel

public URL getUrlJobsCancel(String jobId)

Create url for cancelling jobs

Parameters:

jobId - is the name of the job

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/[jobId]/cancel?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if job id is null or empty

getUrlJobsCancel

public static URL getUrlJobsCancel(String hostName, String jobId)

Create url for cancelling jobs

Parameters:

hostName - The hostname of the IoT Hub
jobId - is the name of the job

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/[jobId]/cancel?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if job id is null or empty

getUrlMethod

public URL getUrlMethod(String deviceId)

Create url for requesting device method

Parameters:

deviceId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId/methods/"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlMethod

public static URL getUrlMethod(String hostName, String deviceId)

Create url for requesting device method

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId/methods/"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModule

public URL getUrlModule(String deviceId, String moduleId)

Create url for requesting module data

Parameters:

deviceId - The name of the device
moduleId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId/modules/moduleId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModule

public static URL getUrlModule(String hostName, String deviceId, String moduleId)

Create url for requesting module data

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device
moduleId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId/modules/moduleId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModuleMethod

public URL getUrlModuleMethod(String deviceId, String moduleId)

Create url for requesting device method for module

Parameters:

deviceId - The name of the device
moduleId - The name of the module

Returns:

The Url in the following format: "https:hostname/twins/deviceId/methods/"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModuleMethod

public static URL getUrlModuleMethod(String hostName, String deviceId, String moduleId)

Create url for requesting device method for module

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device
moduleId - The name of the module

Returns:

The Url in the following format: "https:hostname/twins/deviceId/methods/"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModulesOnDevice

public URL getUrlModulesOnDevice(String deviceId)

Create url for requesting all modules data on a device

Parameters:

deviceId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModulesOnDevice

public static URL getUrlModulesOnDevice(String hostName, String deviceId)

Create url for requesting all modules data on a device

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device

Returns:

The device Url in the following format: "https:hostname/devices/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModuleTwin

public URL getUrlModuleTwin(String deviceId, String moduleId)

Create url for requesting module twin

Parameters:

deviceId - The name of the device
moduleId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId/modules/moduleId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlModuleTwin

public static URL getUrlModuleTwin(String hostName, String deviceId, String moduleId)

Create url for requesting module twin

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device
moduleId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId/modules/moduleId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlQuery

public URL getUrlQuery(String jobType, String jobStatus)

Create url for querying

Parameters:

jobType - jobType as String
jobStatus - jobStatus as String

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/query?jobType=jobTypeValue&jobStatus=jobStatusValue&api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlQuery

public static URL getUrlQuery(String hostName, String jobType, String jobStatus)

Create url for querying

Parameters:

hostName - The hostname of the IoT Hub
jobType - jobType as String
jobStatus - jobStatus as String

Returns:

the URL in the follow format: "https:[hostname]/jobs/v2/query?jobType=jobTypeValue&jobStatus=jobStatusValue&api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlTwin

public URL getUrlTwin(String deviceId)

Create url for requesting device twin

Parameters:

deviceId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlTwin

public static URL getUrlTwin(String hostName, String deviceId)

Create url for requesting device twin

Parameters:

hostName - The hostname of the IoT Hub
deviceId - The name of the device

Returns:

The Url in the following format: "https:hostname/twins/deviceId?api-version=201X-XX-XX"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
IllegalArgumentException - This exception is thrown if device id is null or empty

getUrlTwinQuery

public URL getUrlTwinQuery()

Create url for querying twin

Returns:

the URL in the follow format: "https:[hostname]/devices/query?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

getUrlTwinQuery

public static URL getUrlTwinQuery(String hostName)

Create url for querying twin

Parameters:

hostName - The hostname of the IoT Hub

Returns:

the URL in the follow format: "https:[hostname]/devices/query?api-version=2016-11-14"

Throws:

MalformedURLException - This exception is thrown if the URL creation failed due to malformed string

toString

public String toString()

Serialize connection string

Returns:

Iot Hub connection string

Applies to