class ManagedObjectService : ConnectionRequest<User, ManagedObject>
Principal access point for all Cumulocity data represented as ManagedObject and accessed via API endpoint /inventory/managedObjects.
You will need to use either the internal id of the managed object or reference it via an external id that that has been pre-registered. The result is translated into a ManagedObject instance
e.g.
CumulocityConnectionFactory.connection(<tenant>, <instance e.g. cumulocity.com>).connect(<user>, <password>) { connection, responseInfo ->
ManagedObjectService(connection).get("12345") { result ->
if (status == 500) {
val failureReason: String? = results.reason
...
} else {
val device: 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 - ManagedObject
content - an instance of ManagedObject.
Use the ManagedObjectsService managedObjectsForQuery method if you do need to find the managed object via any other criteria.
ManagedObjectService(connection: Connection<User>)
Creates a single use instance that can be used to launch a query, do not reuse the same instance for multiple queries |
fun add(obj: ManagedObject, responder: RequestResponder<ManagedObject>): Unit
Adds the managed object to your cumulocity tenant. The internal id generated by Cumulocity will added to the managed object reference, which will be referenced in the callback function. |
|
fun assignToGroup(child: String, parentId: String, responder: RequestResponder<ManagedObject>?): Unit
Associates the given managed object withe the other. This is most often used to add a device 'c8y_Device' to a group 'c8y_DeviceGroup' |
|
fun delete(obj: ManagedObject, responder: RequestResponder<ManagedObject>): Unit
Deletes the given managed object |
|
fun get(id: String, responder: RequestResponder<ManagedObject>): Unit
Fetch the managed object using the cumulocity internal id fun get(id: String, type: String, responder: RequestResponder<ManagedObject>): Unit
Fetch the managed object using the external id for the given type. Refer to the Device Management console in cumulocity to find the details on an assets external ids and types. |
|
fun path(): String |
|
fun response(response: String): ManagedObject |
|
fun update(obj: ManagedObject, responder: RequestResponder<ManagedObject>): Unit
Updates the existing managed object. The id attribute must be provided in advance, it is recommended that you only use this method with a managed object that was returned by the aforementioned add method, get or query methods provided by the ManagedObjectsService class. |