EnterpriseClient
public class EnterpriseClient : Client, Hashable
The EnterpriseClient
is an enterprise application, client of the Oracle
IoT Cloud Service.
-
Creates an instance of
EnterpriseClient
associated with the specified IoT application and with platform specific context. The created instance will use a custom or defaultTrustedAssetsManager
to store, load and handle the client configuration.The
web api
will be used make REST calls to the IoT Cloud Service.On success callback argument
EnterpriseClient
is an instance to communicate with the specified IoT application On failure callback argumentClientError
may be:ClientError.state
orClientError.file
if a TrustedAssetsManager instance cannot be created.ClientError.network
if an I/O error occurred when trying to retrieve data from serverClientError.security
if the trust material could not be loaded.Declaration
Swift
public static func newClient(appName:String, callback:@escaping (EnterpriseClient?,ClientError?)->())
Parameters
appName
the name of the IoT application to connect with, or
nil
.context
an object (e.g. application context), that needs to be associated with this client.
-
Creates an instance of
EnterpriseClient
associated with the specified IoT application. The configuration will be loaded from the given path.If the
appName
is notnil
, a REST call is performed to find the application-id matching with the specified name.If the
appName
isnil
, a REST call is performed to find the application that has, in its list of integrations identifier, the one retrieved from theTrustedAssetsManager
.The specified context (if any) could be used by platform specific implementation to retrieve information like internal storage area.
On success callback argument
EnterpriseClient
is an instance to communicate with the specified IoT application On failure callback argumentClientError
may be:ClientError.argument
orClientError.file
if a TrustedAssetsManager instance cannot be created frompath
andpassword
ClientError.network
if an I/O error occurred when trying to retrieve data from serverClientError.security
if the trust material could not be loaded.Declaration
Swift
public static func newClient(appName:String?=nil, path:String, password:String, callback: @escaping (EnterpriseClient?,ClientError?)->())
Parameters
path
the path of the configuration file
password
the configuration file password
appName
the name of the IoT application to connect with, or
nil
.context
an application context, that needs to be associated with this client, or
nil
. -
Get the list of device models available for this application. The callback is called with a
DeviceModelIterator
.Declaration
Swift
public func getDeviceModels(callback: @escaping (Pageable<String>?, ClientError?) -> Void)
Parameters
callback
Called with a
Pageable<String>
containing the device model urns associated with thisEnterpriseClient
. If an error occurspage
is set tonil
anderror
indicates the error. -
Get details on the IoT application for this client.
Declaration
Swift
public func getApplication() -> Application
Return Value
Details on the specified application.
-
The
callback
is called with aPageable
collection ofDevice
. The fields that will be available from returnedDevice
instances will be limited to the one defined infields
. UseDevice.Field.Values
to get them all.The
filter
forms a query. Only devices that satisfy thefilter
and have a connectivity status ofstatus
are returned.Declaration
Swift
public func getDevices(fields: [Device.Field.Values], filter: Filter, callback: @escaping (Pageable<Device>?, ClientError?) -> Void)
Parameters
fields
Set of fields
Device.Field
to return for the selected devices. Can benil
.filter
A filter. Can be
nil
.callback
Callback containing the
Pageable<Device>
If an error occurspage
is set tonil
anderror
indicates the error. -
Get the
DeviceModel
for the device model urn.Throws
ClientError.state
ifclose
has been called.Declaration
Swift
public func getDeviceModel(deviceModelUrn: String, callback: @escaping (DeviceModel?, ClientError?) -> Void) throws
Parameters
deviceModelUrn
The URN of the device model
callback
Called with the device model in the activated state. If activation fails then
deviceModel
will benil
anderror
will not benil
and identify the error. If bothdeviceModel
anderror
arenil
then the device model does not exist. -
Get the active devices implementing the specified device model.
Declaration
Swift
public func getActiveDevices(deviceModel: String, callback: @escaping (Pageable<Device>?, ClientError?) -> Void)
Parameters
deviceModel
The URN of the device model.
callback
Called with a
Pageable<Device>
containing the devices associated with thisEnterpriseClient
. If an error occurspage
is set tonil
anderror
indicates the error. -
Closes the resources used by this client.
Throws
ClientError.network
if theSecureConnection
cannot be closedDeclaration
Swift
public func close() throws
-
Create a
VirtualDevice
instance with the given device model for the given device identifier. This method creates a newVirtualDevice
instance for the given parameters. The client library does not cache previously createdVirtualDevice
objects.Declaration
Swift
public func createVirtualDevice(deviceId endpointId: String, deviceModel: DeviceModel) -> VirtualDevice
Parameters
endpointId
The application client identifier of the device being modeled.
deviceModel
The device model URN that this application implements.
Return Value
A new
VirtualDevice
. -
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Create a new
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 theConfig.DISABLE_STORAGE_OBJECT_PREFIX
totrue
. IfcontentType
isnil
, the mime-type defaults to “application/octet-stream”.If
contentType
is nil, the mime-type defaults to “application/octet-stream”.Throws
-
ClientError.network
if there is an exception raised by the runtime, or an abnormal response from the storage cloud -ClientError.security
if there is an exception establishing a secure connection to the storage cloudDeclaration
Swift
public func createStorageObject(name: String, contentType: String?) throws -> StorageObject
Parameters
name
the unique name to be used to reference the content in storage
contentType
The mime-type of the content or
nil
Return Value
-
Create a new
StorageObject
from theuri
for a named object in storage.Throws
ClientError.network
if there is an exception raised by the runtime, or a failure reported by the storage cloudClientError.security
if there is an exception establishing a secure connection to the storage cloudDeclaration
Swift
public func createStorageObject(uri:String, callback: @escaping (StorageObject?,ClientError?)->()) throws
Parameters
uri
the URI of the object in the storage cloud
callback
This api is makes an asynchronous network call.
callback
is invoked when the network call completes.Return Value
a
StorageObject
for the object in storage