Freigeben über


IotHubConnectionString Class

public class IotHubConnectionString
extends IotHubConnectionStringBuilder

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

Field Summary

Modifier and Type Field and Description
protected static final java.lang.String HOST_NAME_PROPERTY_NAME
protected static final java.lang.String HOST_NAME_SEPARATOR
protected static final java.lang.String SHARED_ACCESS_KEY_NAME_PROPERTY_NAME
protected static final java.lang.String SHARED_ACCESS_KEY_PROPERTY_NAME
protected static final java.lang.String SHARED_ACCESS_SIGNATURE_PROPERTY_NAME
protected static final java.lang.String VALUE_PAIR_DELIMITER
protected static final java.lang.String VALUE_PAIR_SEPARATOR
protected AuthenticationMethod authenticationMethod
protected java.lang.String hostName
protected java.lang.String iotHubName
protected java.lang.String sharedAccessKey
protected java.lang.String sharedAccessKeyName
protected java.lang.String sharedAccessSignature

Constructor Summary

Modifier Constructor Description
protected IotHubConnectionString()

Method Summary

Modifier and Type Method and Description
AuthenticationMethod getAuthenticationMethod()

Getter for authenticationMethod

java.lang.String getHostName()

Getter for hostName

java.lang.String getIotHubName()

Getter for iotHubName

java.lang.String getSharedAccessKey()

Getter for sharedAccessKey

java.lang.String getSharedAccessKeyName()

Getter for sharedAccessKeyName

java.lang.String getSharedAccessSignature()

Getter for sharedAccessSignature

java.net.URL getUrlApplyConfigurationContent(String deviceId)

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

static java.net.URL getUrlApplyConfigurationContent(String hostName, String deviceId)

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

java.net.URL getUrlConfiguration(String configurationId)

Create url for requesting configuration data

static java.net.URL getUrlConfiguration(String hostName, String configurationId)

Create url for requesting configuration data

java.net.URL getUrlConfigurationsList(Integer maxCount)

Create url for requesting configuration data

static java.net.URL getUrlConfigurationsList(String hostName, Integer maxCount)

Create url for requesting configuration data

java.net.URL getUrlCreateExportImportJob()

Create url for processing a bulk import/export job

static java.net.URL getUrlCreateExportImportJob(String hostName)

Create url for processing a bulk import/export job

java.net.URL getUrlDevice(String deviceId)

Create url for requesting device data

static java.net.URL getUrlDevice(String hostName, String deviceId)

Create url for requesting device data

java.net.URL getUrlDeviceList(Integer maxCount)

Create url for requesting device list

static java.net.URL getUrlDeviceList(String hostName, Integer maxCount)

Create url for requesting device list

java.net.URL getUrlDeviceStatistics()

Create url for requesting device statistics

static java.net.URL getUrlDeviceStatistics(String hostName)

Create url for requesting device statistics

java.net.URL getUrlImportExportJob(String jobId)
static java.net.URL getUrlImportExportJob(String hostName, String jobId)
java.net.URL getUrlJobs(String jobId)

Create url for requesting jobs

static java.net.URL getUrlJobs(String hostName, String jobId)

Create url for requesting jobs

java.net.URL getUrlJobsCancel(String jobId)

Create url for cancelling jobs

static java.net.URL getUrlJobsCancel(String hostName, String jobId)

Create url for cancelling jobs

java.net.URL getUrlMethod(String deviceId)

Create url for requesting device method

static java.net.URL getUrlMethod(String hostName, String deviceId)

Create url for requesting device method

java.net.URL getUrlModule(String deviceId, String moduleId)

Create url for requesting module data

static java.net.URL getUrlModule(String hostName, String deviceId, String moduleId)

Create url for requesting module data

java.net.URL getUrlModuleMethod(String deviceId, String moduleId)

Create url for requesting device method for module

static java.net.URL getUrlModuleMethod(String hostName, String deviceId, String moduleId)

Create url for requesting device method for module

java.net.URL getUrlModuleTwin(String deviceId, String moduleId)

Create url for requesting module twin

static java.net.URL getUrlModuleTwin(String hostName, String deviceId, String moduleId)

Create url for requesting module twin

java.net.URL getUrlModulesOnDevice(String deviceId)

Create url for requesting all modules data on a device

static java.net.URL getUrlModulesOnDevice(String hostName, String deviceId)

Create url for requesting all modules data on a device

java.net.URL getUrlQuery(String jobType, String jobStatus)

Create url for querying

static java.net.URL getUrlQuery(String hostName, String jobType, String jobStatus)

Create url for querying

java.net.URL getUrlTwin(String deviceId)

Create url for requesting device twin

static java.net.URL getUrlTwin(String hostName, String deviceId)

Create url for requesting device twin

java.net.URL getUrlTwinQuery()

Create url for querying twin

static java.net.URL getUrlTwinQuery(String hostName)

Create url for querying twin

java.lang.String getUserString()

Serialize user string

protected void setSharedAccessKey(String sharedAccessKey)

Setter for sharedAccessKey

protected void setSharedAccessKeyName(String sharedAccessKeyName)

Setter for sharedAccessKeyName

protected void setSharedAccessSignature(String sharedAccessSignature)

Setter for sharedAccessSignature

java.lang.String toString()

Serialize connection string

Methods inherited from IotHubConnectionStringBuilder

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

HOST_NAME_PROPERTY_NAME

protected static final String HOST_NAME_PROPERTY_NAME

HOST_NAME_SEPARATOR

protected static final String HOST_NAME_SEPARATOR

SHARED_ACCESS_KEY_NAME_PROPERTY_NAME

protected static final String SHARED_ACCESS_KEY_NAME_PROPERTY_NAME

SHARED_ACCESS_KEY_PROPERTY_NAME

protected static final String SHARED_ACCESS_KEY_PROPERTY_NAME

SHARED_ACCESS_SIGNATURE_PROPERTY_NAME

protected static final String SHARED_ACCESS_SIGNATURE_PROPERTY_NAME

VALUE_PAIR_DELIMITER

protected static final String VALUE_PAIR_DELIMITER

VALUE_PAIR_SEPARATOR

protected static final String VALUE_PAIR_SEPARATOR

authenticationMethod

protected AuthenticationMethod authenticationMethod

hostName

protected String hostName

iotHubName

protected String iotHubName

sharedAccessKey

protected String sharedAccessKey

sharedAccessKeyName

protected String sharedAccessKeyName

sharedAccessSignature

protected String sharedAccessSignature

Constructor Details

IotHubConnectionString

protected IotHubConnectionString()

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:

java.net.MalformedURLException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it
java.lang.IllegalArgumentException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it

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:

java.net.MalformedURLException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it
java.lang.IllegalArgumentException - if the deviceId contains unexpected characters, and a URL cannot be constructed using it

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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&api-version=201X-XX-XX"

Throws:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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&api-version=201X-XX-XX"

Throws:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.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:

java.net.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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.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:

java.net.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:

java.net.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:

java.net.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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.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:

java.net.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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.MalformedURLException - This exception is thrown if the URL creation failed due to malformed string
java.lang.IllegalArgumentException - This exception is thrown if the URL creation failed due to malformed string

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:

java.net.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:

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

getUserString

public String getUserString()

Serialize user string

Returns:

The user string in the following format: "SharedAccessKeyName@SAS.root.IotHubName"

setSharedAccessKey

protected void setSharedAccessKey(String sharedAccessKey)

Setter for sharedAccessKey

Parameters:

sharedAccessKey - The value of the signature to set

setSharedAccessKeyName

protected void setSharedAccessKeyName(String sharedAccessKeyName)

Setter for sharedAccessKeyName

Parameters:

sharedAccessKeyName - The value of the signature to set

setSharedAccessSignature

protected void setSharedAccessSignature(String sharedAccessSignature)

Setter for sharedAccessSignature

Parameters:

sharedAccessSignature - The value of the signature to set

toString

public String toString()

Serialize connection string

Overrides:

IotHubConnectionString.toString()

Returns:

Iot Hub connection string

Applies to