Apama 10.3.1 | Apama Documentation | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The Cumulocity IoT Transport Connectivity Plug-in | Using managed objects | Querying for managed objects
 
Querying for managed objects
To search for a managed object or a collection of managed objects, send the com.apama.cumulocity.FindManagedObject event to Cumulocity IoT, with a unique reqId to the com.apama.cumulocity.FindManagedObject.CHANNEL channel.
The transport will then respond with zero or more com.apama.cumulocity.FindManagedObjectResponse events and then one com.apama.cumulocity.FindManagedObjectResponseAck event on the com.apama.cumulocity.FindManagedObjectResponse.CHANNEL channel.
Example:
integer reqId := integer.incrementCounter("CumulocityRequestId");
 
com.apama.cumulocity.FindManagedObject request :=
new com.apama.cumulocity.FindManagedObject;
request.reqId := reqId;
 
// Optionally provide the 'id' of the managed object
//request.deviceId := "<DEVICE_ID>";
 
// Filter based on fragmentType
request.params.add("fragmentType", "c8y_IsDevice");
 
// Subscribe to com.apama.cumulocity.FindManagedObjectResponse.CHANNEL to listen
// for responses
monitor.subscribe(com.apama.cumulocity.FindManagedObjectResponse.CHANNEL);
 
// Listen for responses based on reqId
on all com.apama.cumulocity.FindManagedObjectResponse(reqId=reqId) as response
// Avoid listener leaks by terminating the listener on completion of the request
and not com.apama.cumulocity.FindManagedObjectResponseAck(reqId=reqId)
{
log "Received ManagedObject " + response.toString() at INFO;
}
 
// Listen for com.apama.cumulocity.FindManagedObjectResponseAck,
// this indicates that all responses have been received
on com.apama.cumulocity.FindManagedObjectResponseAck(reqId=reqId)
as requestCompleted
{
log "Received all ManagedObject(s) for request "
+ requestCompleted.reqId.toString() at INFO;
 
// Request is completed and we can unsubscribe from this channel
monitor.unsubscribe(com.apama.cumulocity.FindManagedObjectResponse.CHANNEL);
}
 
// Send request to find available managed objects
send request to com.apama.cumulocity.FindManagedObject.CHANNEL;
Supported query parameters
You can provide the following query parameters with the request:
Parameter
Description
deviceId
Search for a managed object based on deviceId. When deviceId is populated in a FindManagedObject request, all the query parameters listed below are ignored.
fragmentType
Search for managed objects based on the fragment type.
type
Search for managed objects based on the type.
owner
Search for managed objects based on the owner.
text
Search for managed objects based on the text.
childAssetId
Search for managed objects based on the asset identifier of the child.
childDeviceId
Search for managed objects based on the device identifier of the child.
ids
Search for managed objects based a comma-separated list of device identifiers.
pageSize
Indicates how many entries of the collection are to be retrieved from Cumulocity IoT.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.