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 newVirtualDevice
instance for the given parameters. The client library does not cache previously created VirtualDevice objects.Throws
ClientError.network
if aMessageDispatcher
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 returnnil
if there is no device model for the URN. nil may also be returned if the device model is a “draft” and the propertycom.oracle.iot.client.device.allow_draft_device_models
is set tofalse
, which is the default.On error
callback
receives aClientError.network
error if: the object is not found (StatusCode.NOT_FOUND
), the request fails (!StatusCode.OK
), or the returned data isnil
or JSON parsing failsDeclaration
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 formcallback(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 aSecureConnection
cannot be closed.Declaration
Swift
func close() throws
-
Create a new
StorageObject
with the given object name and mime-type. IfcontentType
isnil
, 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 cloudClientError.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