class ManagedObjectsService : ConnectionRequest<User, List<ManagedObject>>
Principal access point for all Cumulocity data represented as ManagedObjects such as devices and groups and implemented through the API endpoint /inventory/managedObjects.
It translates the response content into a list of ManagedObject instances to simplify usage
e.g.
CumulocityConnectionFactory.connection(<tenant>, <instance e.g. cumulocity.com>).connect(<user>, <password>) { connection, responseInfo ->
ManagedObjectsService(connection).managedObjectsForType(0, "c8y_DeviceGroup") { results ->
val status: Int = results.status
val failureReason: String? = if (status == 500)
results.reason
else
null
val objects: List<ManagedObject> = results.content
}
}
The results instance consists of the following properties
status - HTTP response code
message - HTTP response message, most often null unless the request failed
headers - HTTP response headers
type - Indicates the content type that was returned
content - Optional content provided by Cumulocity and will be a list of 0 or ManagedObject objects.
ManagedObjectsService(connection: Connection<User>)
Creates a single use instance that cab be used to launch a query, do not reuse the same instance for multiple queries |
val connection: Connection<User>
Connection referencing cumulocity tenant, instance and credentials to use |
|
var lastPage: ManagedObjects?
Allows the last query results to be retrieved without having to resubmit the query |
|
var pageSize: Int
default is 50, ensures large queries can be broken down into separate requests via paged results. Each request will limited by this value and the request will have to be repeated along with incrementing the pageNum attribute. |
fun allManagedObject(pageNum: Int, responder: RequestResponder<List<ManagedObject>>): Unit
Returns all managed objects for the given page with the page size specified by the pageSize property of your instance. Invoke this method for successive page whilst incrementing the pageNum You will get a empty list once you go past the last page. |
|
fun managedObjectsForQuery(pageNum: Int, query: ManagedObjectQuery, responder: RequestResponder<List<ManagedObject>>): Unit
Returns all managed objects for the given page and queries with the page size specified by the @see pageSize property of your instance. Invoke this method for each successive page whilst incrementing the pageNum You will get a empty list once you go past the last page. |
|
fun managedObjectsForType(pageNum: Int, type: String, responder: RequestResponder<List<ManagedObject>>): Unit
Returns all managed objects for the given page and type with the page size specified by the @see pageSize property of your instance. Invoke this method for each successive page whilst incrementing the pageNum You will get a empty list once you go past the last page. |
|
fun path(): String |
|
fun response(response: String): List<ManagedObject> |