Classes

The following classes are available globally.

  • An Application lists the characteristics of an IoT CS application.

    See more

    Declaration

    Swift

    public class Application
  • A Device lists the characteristics of a device.

    See more

    Declaration

    Swift

    public class Device
  • The EnterpriseClient is an enterprise application, client of the Oracle IoT Cloud Service.

    See more

    Declaration

    Swift

    public class EnterpriseClient : Client, Hashable
  • A Filter that can be used for queries.

    Example:

    Devices activated in the last hour that implement a com:acme:device device model.

    The following code:

      f = Filter.and(
            Filter.gte(Device.Field.CREATED.alias(),
              (System.currentTimeMillis() - 3600000L)),
            Filter.eq(Device.Field.STATE.alias(), "ACTIVATED"),
            Filter.like(Device.Field.DEVICE_MODELS.alias() + ".urn",
              "urn:com:acme:device:%"));
    

    will create the following Json object:

     {"$and":[
        {"created":{"$gte":1457137772894}},
        {"state":{"$eq":"ACTIVATED"}},
       {"deviceModels.urn":{"$like":"urn:com:acme:device:%"}}]}
    
    See more

    Declaration

    Swift

    public class Filter
  • A Pageable instance is a cached view on a remote collection of elements of the specified type T.

    Notion of Pages The remote collection is not entirely loaded in memory but only a subset of the elements is loaded in the cache. This subset is called a page and has a configurable limit() limit and offset() offset to respectively control the maximum number of elements to fetch from the remote collection and the absolute offset of the first element to fetch. The elements loaded in the cache are accessed using elements().

    Navigation The Pageable instance is also used to navigate in the remote collection and access its elements. The navigation supports random access to any position in the remote collection and is performed by calling one of the following methods: next(callback:), first(callback:), last(callback:), at(offset:callback:). Navigation implies accessing the remote collection and may fail with an I/O error.

    Concurrent modifications of the remote collection The remote collection might be modified concurrently. Consequences:

    • Changes that occurred in the remote collection are not reflected in the elements in the cache accessed with elements()
    • The total size of the collection might have evolved since last access and may affect the result of next(callback:), at(offset:callback:) and last(callback:)
    See more

    Declaration

    Swift

    public class Pageable<T>
  • ExternalObject represents the value of a URI type in a data model. The application is responsible for uploading/downloading the content referred to by the URI.

    See more

    Declaration

    Swift

    public class ExternalObject : Hashable
  • A callback interface for receiving an event when content referred to by an attribute value has been successfully synchronized, or has failed to be synchronized. See setOnSync

    See more

    Declaration

    Swift

    open class SyncCallback
  • StorageObject provides information about content in cloud storage.

         // Upload example
         var lenna:StorageObject =
             directlyConnectedDevice.createStorageObject(name:"lenna.jpg",
                                                  contentType: "image/jpeg")
         lenna.setInputPath(inputPath:"images/lenna.jpg")
    
         // onSync is called when the content referenced by the storageObject
         // is in sync with the storage cloud, or the sync has failed.
         lenna.setOnSync(callback: { event in
             let storageObject:StorageObject = event.getSource()
             if storageObject.getSyncStatus() == SyncStatus.inSync {
                 // image was uploaded and can be deleted
             } else if storageObject.getSyncStatus() == SyncStatus.syncFailed {
                 // image was not uploaded, take action!
             }
         })
    
         virtualDevice.set(attributeName:"image", attributeValue:lenna)
    
         // Download example
         // onChange is called when the attribute value changes.
         virtualDevice.setOnChange(attributeName:"image", callback: { event in 
             var namedValue:NamedValue = event.getNamedValue()
             var storageObject:StorageObject = namedValue.getValue() as StorageObject
             if storageObject.getContentLength() < availableDiskSpace {
                 // syncTo will kick off the async download of the content
                 storageObject.setOnSync(callback: { event in
                     let storageObject:StorageObject = event.getSource()
                     if storageObject.getSyncStatus() == SyncStatus.inSync {
                         // image was downloaded and can now be used
                     } else if storageObject.getSyncStatus() == SyncStatus.syncFailed {
                         // image was not downloaded, take action!
                     }
                 }
                 storageObject.setOutputPath(outputPath:"downloads" +
                                                        storageObject.getName())
                 storageObject.sync()
             }
         })
     }
    
    See more

    Declaration

    Swift

    public class StorageObject : ExternalObject