EnterpriseClient
public class EnterpriseClient : Client, Hashable
The EnterpriseClient is an enterprise application, client of the Oracle
IoT Cloud Service.
-
Creates an instance of
EnterpriseClientassociated with the specified IoT application and with platform specific context. The created instance will use a custom or defaultTrustedAssetsManagerto store, load and handle the client configuration.The
web apiwill be used make REST calls to the IoT Cloud Service.On success callback argument
EnterpriseClientis an instance to communicate with the specified IoT application On failure callback argumentClientErrormay be:ClientError.stateorClientError.fileif a TrustedAssetsManager instance cannot be created.ClientError.networkif an I/O error occurred when trying to retrieve data from serverClientError.securityif the trust material could not be loaded.Declaration
Swift
public static func newClient(appName:String, callback:@escaping (EnterpriseClient?,ClientError?)->())Parameters
appNamethe name of the IoT application to connect with, or
nil.contextan object (e.g. application context), that needs to be associated with this client.
-
Creates an instance of
EnterpriseClientassociated with the specified IoT application. The configuration will be loaded from the given path.If the
appNameis notnil, a REST call is performed to find the application-id matching with the specified name.If the
appNameisnil, 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
EnterpriseClientis an instance to communicate with the specified IoT application On failure callback argumentClientErrormay be:ClientError.argumentorClientError.fileif a TrustedAssetsManager instance cannot be created frompathandpasswordClientError.networkif an I/O error occurred when trying to retrieve data from serverClientError.securityif 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
paththe path of the configuration file
passwordthe configuration file password
appNamethe name of the IoT application to connect with, or
nil.contextan 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
callbackCalled with a
Pageable<String>containing the device model urns associated with thisEnterpriseClient. If an error occurspageis set tonilanderrorindicates the error. -
Get details on the IoT application for this client.
Declaration
Swift
public func getApplication() -> ApplicationReturn Value
Details on the specified application.
-
The
callbackis called with aPageablecollection ofDevice. The fields that will be available from returnedDeviceinstances will be limited to the one defined infields. UseDevice.Field.Valuesto get them all.The
filterforms a query. Only devices that satisfy thefilterand have a connectivity status ofstatusare returned.Declaration
Swift
public func getDevices(fields: [Device.Field.Values], filter: Filter, callback: @escaping (Pageable<Device>?, ClientError?) -> Void)Parameters
fieldsSet of fields
Device.Fieldto return for the selected devices. Can benil.filterA filter. Can be
nil.callbackCallback containing the
Pageable<Device>If an error occurspageis set tonilanderrorindicates the error. -
Get the
DeviceModelfor the device model urn.Throws
ClientError.stateifclosehas been called.Declaration
Swift
public func getDeviceModel(deviceModelUrn: String, callback: @escaping (DeviceModel?, ClientError?) -> Void) throwsParameters
deviceModelUrnThe URN of the device model
callbackCalled with the device model in the activated state. If activation fails then
deviceModelwill benilanderrorwill not beniland identify the error. If bothdeviceModelanderrorarenilthen 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
deviceModelThe URN of the device model.
callbackCalled with a
Pageable<Device>containing the devices associated with thisEnterpriseClient. If an error occurspageis set tonilanderrorindicates the error. -
Closes the resources used by this client.
Throws
ClientError.networkif theSecureConnectioncannot be closedDeclaration
Swift
public func close() throws -
Create a
VirtualDeviceinstance with the given device model for the given device identifier. This method creates a newVirtualDeviceinstance for the given parameters. The client library does not cache previously createdVirtualDeviceobjects.Declaration
Swift
public func createVirtualDevice(deviceId endpointId: String, deviceModel: DeviceModel) -> VirtualDeviceParameters
endpointIdThe application client identifier of the device being modeled.
deviceModelThe device model URN that this application implements.
Return Value
A new
VirtualDevice. -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Create a new
StorageObjectthat 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_PREFIXtotrue. IfcontentTypeisnil, the mime-type defaults to “application/octet-stream”.If
contentTypeis nil, the mime-type defaults to “application/octet-stream”.Throws
-
ClientError.networkif there is an exception raised by the runtime, or an abnormal response from the storage cloud -ClientError.securityif there is an exception establishing a secure connection to the storage cloudDeclaration
Swift
public func createStorageObject(name: String, contentType: String?) throws -> StorageObjectParameters
namethe unique name to be used to reference the content in storage
contentTypeThe mime-type of the content or
nilReturn Value
-
Create a new
StorageObjectfrom theurifor a named object in storage.Throws
ClientError.networkif there is an exception raised by the runtime, or a failure reported by the storage cloudClientError.securityif there is an exception establishing a secure connection to the storage cloudDeclaration
Swift
public func createStorageObject(uri:String, callback: @escaping (StorageObject?,ClientError?)->()) throwsParameters
urithe URI of the object in the storage cloud
callbackThis api is makes an asynchronous network call.
callbackis invoked when the network call completes.Return Value
a
StorageObjectfor the object in storage
EnterpriseClient Class Reference