Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Query via API using Tags
-
When requesting point values for a given datasource via API, is it possible to filter results by tags? An example tag being
"site":"Denver"
How would the request be appended to filter by Denver?
/rest/v1/point-values/DS_Example/latest-data-source-single-array?
Thank you.
-
Hi Wingnutz,
I would guess you've downloaded the 3.3 beta! Thanks for checking out the new features!
You should be able to use tags.tag in RQL expressions, like,
eq(tags.site,Denver)
I did notice in providing this answer that it won't work in the RQL DataPointQuery.query(rql) method in scripting environments in the beta, but i fixed it up so that this should be available in the release. It should be working in the API in your version, but you will need to use the V2 /rest/v2/data-points endpoints.
-
Sorry, I got caught up in the first part of the question and glossed past the second -
The
/rest/v1/{dataSourceXid}/latest-data-source-single-array
does not take RQL to filter down its result set. I do not believe any of the point values endpoints take an RQL query to describe the points values are sought from, but it's a good idea. I'll make mention of it. -
It sounds like the way to do this will be multiple requests. You will have to request the data points from the V2
/rest/v2/data-points
endpoint, then compose a list of their XIDs and either GET that from the V1 point-values endpoints or POST it (if the URL is too large) to the V2 point-values endpoints. -
Thank you, Phil. The query by dataSource certainly sounds more fun to me, but I appreciate you providing a complete solution.
The 3.3 beta is great - tags will open up a world of opportunities and the JWT functionality is appreciated by all.
-
Ha! Certainly! I can provide an even more complete solution, since it doesn't sound like it'll be implemented by us....
If one were to need such an endpoint, one could clone our ma-modules-public repo and modify the V2 point values endpoint by adding a function like
@ApiOperation( value = "Get point values arrays by RQL", notes = "Get multiple arrays of point values by an RQL query string", response = PointValueTimeModel.class, responseContainer = "Object") @RequestMapping(method = RequestMethod.POST, value = "/{rqlQuery}/multiple-arrays/latest") public ResponseEntity<PointValueTimeStream<PointValueTimeModel, LatestQueryInfo>> rqlLatestPointValuesAsMultipleArrays( HttpServletRequest request, @ApiParam(value = "RQL", required = true, allowMultiple = false) @PathVariable String rqlQuery, @ApiParam(value = "Query Information", required = true, allowMultiple = false) @RequestBody XidLatestQueryInfoModel info, @AuthenticationPrincipal User user) { List<String> xids = new ArrayList<>(); RQLParser rqlParser = new RQLParser(); ConditionSortLimitWithTagKeys conditions = DataPointDao.instance.rqlToCondition(rqlParser.parse(rqlQuery)); if(!user.isAdmin()) conditions.addCondition(DataPointDao.instance.userHasPermission(user)); DataPointDao.instance.customizedQuery(conditions, new MappedRowCallback<DataPointVO>() { @Override public void row(DataPointVO item, int index) { xids.add(item.getXid()); } }); if(info.getXids() != null) for(int k = 0; k < info.getXids().length; k+=1) { if(!xids.contains(info.getXids()[k])) xids.add(info.getXids()[k]); } return generateLatestStream(user, info.createLatestQueryInfo(request.getServerName(), request.getServerPort(), false, false), xids.toArray(new String[xids.size()])); }
to com.infiniteautomtion.mango.rest.v2.PointValueRestController.java in the Mango API project.
And then you could query at /rest/v2/point-values/{rqlQuery}/multiple-arrays/latest after building / installing that modified module. You would of course have to be mindful of this customization thereafter. But, it's possible.
-
Hello Phil,
With tags being available for a few months now, has any additional thought been given to adding this feature to the core?
Thank you
-
Hi Wingnut2.0,
I made an argument for it when this came up, but the pushback of "You can request those points, then compile a request for the values from them," was strong. If you can expand on the value of having it in a simple single request, you may find more traction for it than I did. That's why I just supplied the code here.