Client

public protocol Client

Client of the Oracle IoT Cloud Service. A client is a directly-connected device, a gateway, or an enterprise application.

  • Create an 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.

    Throws

    ClientError.network if a MessageDispatcher cannot be obtained.

    Declaration

    Swift

    func createVirtualDevice(deviceId: String,
                             deviceModel: DeviceModel) throws -> VirtualDevice

    Parameters

    deviceId

    The device identifier of the device being modeled

    deviceModel

    The device model URN that this device implements

    Return Value

    a new VirtualDevice

  • Get the DeviceModel for the device model URN. This method may return nil if there is no device model for the URN. nil 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.

    On error callback receives a ClientError.network error if: the object is not found (StatusCode.NOT_FOUND), the request fails (!StatusCode.OK), or the returned data is nil or JSON parsing fails

    Declaration

    Swift

    func getDeviceModel(deviceModelUrn: String,
            callback: @escaping (DeviceModel?, ClientError?) -> Void) throws

    Parameters

    deviceModelUrn

    The URN of the device model

    callback

    This function is called with the retrieved device model. If retrieving the device model is not successful then the object will be nil and an error object is passed in the form callback(device, error) and the reason can be taken from error

  • Release the resources held by the client. This call is idempotent

    Throws

    ClientError.network if a SecureConnection cannot be closed.

    Declaration

    Swift

    func close() throws
  • Create a new StorageObject with the given object name and mime-type. 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

    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

    Return Value

    a StorageObject