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 default TrustedAssetsManager 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 argument ClientError may be: ClientError.state or ClientError.file if a TrustedAssetsManager instance cannot be created. ClientError.network if an I/O error occurred when trying to retrieve data from server ClientError.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 not nil, a REST call is performed to find the application-id matching with the specified name.

    If the appName is nil, 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.

    On success callback argument EnterpriseClient is an instance to communicate with the specified IoT application On failure callback argument ClientError may be: ClientError.argument or ClientError.file if a TrustedAssetsManager instance cannot be created from path and password ClientError.network if an I/O error occurred when trying to retrieve data from server ClientError.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 this EnterpriseClient. If an error occurs page is set to nil and error 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 a 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.Values to get them all.

    The filter forms a query. Only devices that satisfy the filter and have a connectivity status of status are returned.

    Seealso

    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 be nil.

    filter

    A filter. Can be nil.

    callback

    Callback containing the Pageable<Device> If an error occurs page is set to nil and error indicates the error.

  • Get the DeviceModel for the device model urn.

    Throws

    ClientError.state if close 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 be nil and error will not be nil and identify the error. If both deviceModel and error are nil 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 this EnterpriseClient. If an error occurs page is set to nil and error indicates the error.

  • Closes the resources used by this client.

    Throws

    ClientError.network if the SecureConnection cannot be closed

    Declaration

    Swift

    public func close() throws
  • Create a VirtualDevice 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.

    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 the Config.DISABLE_STORAGE_OBJECT_PREFIX to true. If contentType is nil, 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 cloud

    Declaration

    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

    a StorageObject

  • Create a new StorageObject from the uri 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 cloud ClientError.security if there is an exception establishing a secure connection to the storage cloud

    Declaration

    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