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
AbstractVirtualDeviceinstance 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 created VirtualDevice objects.Throws
ClientError.networkif aMessageDispatchercannot be obtained.Declaration
Swift
func createVirtualDevice(deviceId: String, deviceModel: DeviceModel) throws -> VirtualDeviceParameters
deviceIdThe device identifier of the device being modeled
deviceModelThe device model URN that this device implements
Return Value
a new
VirtualDevice -
Get the
DeviceModelfor the device model URN. This method may returnnilif 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_modelsis set tofalse, which is the default.On error
callbackreceives aClientError.networkerror if: the object is not found (StatusCode.NOT_FOUND), the request fails (!StatusCode.OK), or the returned data isnilor JSON parsing failsDeclaration
Swift
func getDeviceModel(deviceModelUrn: String, callback: @escaping (DeviceModel?, ClientError?) -> Void) throwsParameters
deviceModelUrnThe URN of the device model
callbackThis function is called with the retrieved device model. If retrieving the device model is not successful then the object will be
niland 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.networkif aSecureConnectioncannot be closed.Declaration
Swift
func close() throws -
Create a new
StorageObjectwith the given object name and mime-type. IfcontentTypeisnil, 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 cloudClientError.securityif there is an exception establishing a secure connection to the storage cloud
Declaration
Swift
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
Return Value
Client Protocol Reference