Product/components used and version/fix level:
1017.73.0
Detailed explanation of the problem:
I have API <url>/managedObjects?type=sol_AlarmFlow&deviceId=1942089
,getting correct response in postman with get like
{
"next": "https://<url>/inventory/managedObjects?pageSize=5&type=sol_AlarmFlow¤tPage=2&deviceId=1942089",
"self": "https://<url>/inventory/managedObjects?pageSize=5&type=sol_AlarmFlow¤tPage=1&deviceId=1942089",
"managedObjects": [
{
"additionParents": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/additionParents"
},
"owner": "",
"alarmFlows": [
{
"email_to": "",
"alarm_flow_name": "First Alarm flow 05dec23",
}
]
}
],
"statistics": {
"pageSize": 5,
"currentPage": 1
}
}
But Same thing applied using Java sdk while following Best-Practices to use the Microservice SDK for Java for custom API queries not able to get correct response here is code
CustomQueryParam.java
public enum CustomQueryParam implements Param {
WITH_TOTAL_PAGES("withTotalPages"),
PAGE_SIZE("pageSize"),
QUERY("query"),
DEVICE_QUERY("q"),
DATE_FROM("dateFrom"),
STATUS("status"),
FRAGMENT_TYPE("fragmentType"),
DEVICE_ID("deviceId"),
REVERT("revert"),
TYPE("type")
;
private String name;
private String value;
public String getValue() {
return value;
}
private CustomQueryParam(final String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
public CustomQueryParam setValue(final String value) {
this.value = value;
return this;
}
public QueryParam toQueryParam() {
return new QueryParam(this, Filter.encode(value));
}
}
Implentation class
int pageSize = 5000;
InventoryFilter deviceFilter = new InventoryFilter().byType("sol_AlarmFlow");
QueryParam creationDeviceQuery = CustomQueryParam.DEVICE_ID.setValue("1942089").toQueryParam();
Iterable<ManagedObjectRepresentation> managedObjects = inventory
.getManagedObjectsByFilter(deviceFilter)
.get(pageSize, creationDeviceQuery)
.allPages();
while (managedObjects.iterator().hasNext()) {
ManagedObjectRepresentation managedObjectRepresentation = managedObjects.iterator().next();
try {
LOG.info(String.format("Fteched managed object with id %s from tenant %s",
managedObjectRepresentation.getId().getValue(),
new ObjectMapper().writeValueAsString(managedObjectRepresentation)));
} catch (JsonProcessingException e) {
LOG.error("Error writing JSON string", e);
}
}
its always giving this response not where manageObject should come
{
"owner": "",
"additionParents": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/additionParents"
},
"childDevices": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/childDevices"
},
"childAssets": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/childAssets"
},
"creationTime": "2023-12-05T16:02:06.801Z",
"type": "sol_AlarmFlow",
"lastUpdated": "2023-12-05T16:02:07.136Z",
"childAdditions": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/childAdditions"
},
"deviceParents": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/deviceParents"
},
"assetParents": {
"references": [],
"self": "https://<url>/inventory/managedObjects/55328249458/assetParents"
},
"id": "55328249458",
"alarmFlows": [
{
"email_to": "",
}
]
}