public class EnterpriseClient extends Client<VirtualDevice>
EnterpriseClient
is a enterprise application, client of the Oracle IoT Cloud Service.Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the resources used by this client.
|
StorageObject |
createStorageObject(java.lang.String uri)
Create a new
StorageObject from the URI for a named object in storage. |
StorageObject |
createStorageObject(java.lang.String name,
java.lang.String contentType)
Create a new
StorageObject that will have a name with the given
object name prefixed with the application's ID and a directory
separator. |
VirtualDevice |
createVirtualDevice(java.lang.String endpointId,
DeviceModel deviceModel)
Create an
AbstractVirtualDevice instance with the given device model
for the given device identifier. |
Pageable<Device> |
getActiveDevices(java.lang.String deviceModel)
Get the active devices implementing the specified device model.
|
Application |
getApplication()
Get details on the IoT application for this client.
|
DeviceModel |
getDeviceModel(java.lang.String deviceModelUrn)
Get the
DeviceModel for the device model urn. |
Pageable<java.lang.String> |
getDeviceModels()
Get the list of device models available for this application.
|
Pageable<Device> |
getDevices(java.util.Set<Device.Field> fields,
Filter filter)
|
static EnterpriseClient |
newClient(java.lang.String appName)
Creates an instance of
EnterpriseClient associated with the
specified IoT application. |
static EnterpriseClient |
newClient(java.lang.String appName,
java.lang.Object context)
Creates an instance of
EnterpriseClient associated with
the specified IoT application and with platform specific context. |
static EnterpriseClient |
newClient(java.lang.String configFilePath,
java.lang.String configFilePassword)
Creates an instance of
EnterpriseClient using the configuration
from the given file path and password. |
static EnterpriseClient |
newClient(java.lang.String configFilePath,
java.lang.String configFilePassword,
java.lang.String appName,
java.lang.Object context)
Creates an instance of
EnterpriseClient associated with the
specified IoT application. |
public static EnterpriseClient newClient(java.lang.String appName) throws java.io.IOException, java.security.GeneralSecurityException
EnterpriseClient
associated with the
specified IoT application.
The created instance will use a custom or default TrustedAssetsManager
to store, load and handle the client configuration.
See configuration for details.appName
- the name of the IoT application to connect with.
null
, a REST call is performed to find the application-id matching with the
specified name.null
, a REST call is performed to find the application that has, in its list of
integrations identifier, the one retrieved from the TrustedAssetsManager
.EnterpriseClient
instance to communicate with the specified IoT applicationjava.io.IOException
- if an I/O error occurred when trying to retrieve data from serverjava.security.GeneralSecurityException
- if the trust material could not be
loaded. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.getApplication()
public static EnterpriseClient newClient(java.lang.String appName, java.lang.Object context) throws java.io.IOException, java.security.GeneralSecurityException
EnterpriseClient
associated with
the specified IoT application and with platform specific context.
The created instance will use a custom or default TrustedAssetsManager
to store, load and handle the client configuration.
See configuration for details.
If the appName
is not null
, a REST call is performed to find the
application-id matching with the specified name.
If the appName
is null
, a REST call is performed to find the application that has, in its list of
integrations identifier, the one retrieved from the TrustedAssetsManager
.
The specified context (if any) could be used by platform specific implementation to retrieve information like internal storage area.
appName
- the name of the IoT application to connect with, or null
.context
- a platform specific object (e.g. application context),
that needs to be associated with this client. In
the case of Android, this is an android.content.Context
provided by the application or service. In the case of Java SE,
the parameter is not used and the value may be null
.EnterpriseClient
instance to communicate with the specified IoT applicationjava.io.IOException
- if an I/O error occurred when trying to retrieve data from serverjava.security.GeneralSecurityException
- if the trust material could not be
loaded. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public static EnterpriseClient newClient(java.lang.String configFilePath, java.lang.String configFilePassword, java.lang.String appName, java.lang.Object context) throws java.io.IOException, java.security.GeneralSecurityException
EnterpriseClient
associated with the
specified IoT application. The configuration will be loaded from the
given path.
See configuration for details.
If the appName
is not null
, a REST call is performed to
find the application-id matching with the specified name.
If the appName
is null
, a REST call is performed to find
the application that has, in its list of
integrations identifier, the one retrieved from the TrustedAssetsManager
.
The specified context (if any) could be used by platform specific implementation to retrieve information like internal storage area.
configFilePath
- the path of the configuration file and may not be null
configFilePassword
- the configuration file password,
or null
if the configurationFile is not encryptedappName
- the name of the IoT application to connect with, or
null
.context
- a platform specific object (e.g. application context),
that needs to be associated with this client. In
the case of Android, this is an android.content.Context
provided by the application or service. In the case of Java SE,
the parameter is not used and the value may be null
.EnterpriseClient
instance to communicate with the
specified IoT applicationjava.io.IOException
- if an I/O error occurred when trying
to retrieve data from serverjava.security.GeneralSecurityException
- if the trust material could not be
loaded. If User Authentication is used,
then UserAuthenticationException
will be
thrown if the session cookie has
expired.java.lang.IllegalArgumentException
- if configFilePath is nullpublic static EnterpriseClient newClient(java.lang.String configFilePath, java.lang.String configFilePassword) throws java.io.IOException, java.security.GeneralSecurityException
EnterpriseClient
using the configuration
from the given file path and password.
See configuration for details.configFilePath
- the path of the configuration fileconfigFilePassword
- the configuration file password,
or null
if the configurationFile is not encryptedEnterpriseClient
instance to communicate with the
specified IoT applicationjava.io.IOException
- if an I/O error occurred when trying
to retrieve data from serverjava.security.GeneralSecurityException
- if the trust material could not be
loaded. If User Authentication is used,
then UserAuthenticationException
will be
thrown if the session cookie has
expired.public VirtualDevice createVirtualDevice(java.lang.String endpointId, DeviceModel deviceModel)
AbstractVirtualDevice
instance with the given device model
for the given device identifier. This method creates a new VirtualDevice
instance for the given parameters. The client library does not
cache previously created VirtualDevice objects.createVirtualDevice
in class Client<VirtualDevice>
endpointId
- The device identifier of the device being modeleddeviceModel
- The device model URN that this device implementsjava.lang.RuntimeException
- if the network request to initialize the
device with its current state fails and an IOException or
GeneralSecurityException occurs. The cause will reflect the relevant
exception.public void close() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic Application getApplication()
public Pageable<java.lang.String> getDeviceModels() throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
- if an I/O error occurred when trying to retrieve data from serverjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public DeviceModel getDeviceModel(java.lang.String deviceModelUrn) throws java.io.IOException, java.security.GeneralSecurityException
DeviceModel
for the device model urn. This method may
return null
if there is no device model for the URN. Null may also be
returned if the device model is a "draft" and the property
com.oracle.iot.client.device.allow_draft_device_models
is set to
false
, which is the default.getDeviceModel
in class Client<VirtualDevice>
deviceModelUrn
- the URN of the device modelnull
if it does not existjava.lang.NullPointerException
- if deviceModel is null
java.io.IOException
- if there is an I/O error when communicating
with the serverjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public Pageable<Device> getActiveDevices(java.lang.String deviceModel) throws java.io.IOException, java.security.GeneralSecurityException
deviceModel
- the URN of the device modeljava.io.IOException
- if an I/O error occurred when trying to retrieve data from serverjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public Pageable<Device> getDevices(java.util.Set<Device.Field> fields, Filter filter) throws java.io.IOException, java.security.GeneralSecurityException
Pageable
collection of Device
.
The fields that will be available from returned Device
instances will be limited to the one
defined in fields
. Use Device.Field.all()
to get them all.
The filter
forms a query. Only devices that satisfy the filter
and have a connectivity status of
status
are returned.fields
- set of fields Device.Field
to return for the selected devices. Can be null
.filter
- A filter. Can be null
.Pageable
collection of Device
that satisfy the filter
and status
.
If no matching device is found, an Pageable
with no elements is returned.java.io.IOException
- if an I/O error occurred when trying to retrieve data from serverjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public StorageObject createStorageObject(java.lang.String name, java.lang.String contentType) throws java.io.IOException, java.security.GeneralSecurityException
StorageObject
that will have a name with the given
object name prefixed with the application's ID and a directory
separator. The prefix addition can be disabled by setting the
com.oracle.iot.client.disable_storage_object_prefix
to true
.
If contentType
is null, the mime-type defaults to
"application/octet-stream".
createStorageObject
in class Client<VirtualDevice>
name
- the unique name to be used to reference the content in
storagecontentType
- The mime-type of the content or null
java.io.IOException
- if there is an IOException
raised by the
runtime, or an abnormal response from the storage cloudjava.security.GeneralSecurityException
- if there is an exception establishing
a secure connection to the storage cloudpublic StorageObject createStorageObject(java.lang.String uri) throws java.io.IOException, java.security.GeneralSecurityException
StorageObject
from the URI for a named object in storage.uri
- the URI of the object in the storage cloudjava.io.IOException
- if there is an IOException
raised by the runtime,
or a failure reported by the storage cloudjava.security.GeneralSecurityException
- if there is an exception establishing a secure connection to the storage cloud