$ curl http://192.168.X.Y:5002/unifi_event/mac?max_results=2 | python -m json.tool
{ "_items": [ { "_id": "c0:f8:da:a5:bc:8d", "count": 2, "last_at": "Sat, 16 Mar 2019 14:05:21 GMT" }, { "_id": "00:ee:13:00:18:f1", "count": 1, "last_at": "Sat, 16 Mar 2019 15:59:27 GMT" } ]}$ curl 2>/dev/null http://192.168.X.Y:5002/unifi_event?max_results=1 | python -m json.tool
{ "_items": [ { "MAC": "b4:9c:df:7c:34:23", "_created": "Thu, 01 Jan 1970 00:00:00 GMT", "_id": "5c7e6f7f2f77d616ba356b5c", "_links": { "self": { "href": "unifi_event/5c7e6f7f2f77d616ba356b5c", "title": "Unifi_event" } }, "_updated": "Thu, 01 Jan 1970 00:00:00 GMT", "created_at": "Tue, 05 Mar 2019 12:45:51 GMT" } ], "_links": { "last": { "href": "unifi_event?max_results=1&page=698", "title": "last page" }, "next": { "href": "unifi_event?max_results=1&page=2", "title": "next page" }, "parent": { "href": "/", "title": "home" }, "self": { "href": "unifi_event?max_results=1", "title": "unifi_event" } }, "_meta": { "max_results": 1, "page": 1, "total": 698 }}
MONGO_HOST = '192.168.3.20'
MONGO_PORT = 27017
MONGO_DBNAME = 'wifi-tracking'
RESOURCE_METHODS = ['GET', 'POST']
ITEM_METHODS = ['GET', 'PATCH', 'DELETE', 'PUT']
IF_MATCH = False
DEBUG = True
PAGINATION = True
unifi_event_mac_count = {
'url': 'unifi_event/mac',
'datasource': {
'source':"unifi_event",
'aggregation': {
'pipeline': [
{"$group": {"_id": "$MAC", "count": {"$sum": 1}, "last_at":{"$max":"$created_at"}}},
]
}
}
}
unifi_event = { 'schema': {
'MAC': { 'type': 'string', 'minlength': 1, 'maxlength': 17 }, 'type': { 'type': 'string' }, 'created_at': { 'type': 'integer' }, }}
DOMAIN = {"unifi_event_mac_count":unifi_event_mac_count, 'unifi_event':unifi_event,}
$ pip list
Package Version
------------- -------
Cerberus 1.2
Click 7.0
Eve 0.8.1
Events 0.3
Flask 1.0.2
itsdangerous 1.1.0
Jinja2 2.10
MarkupSafe 1.1.1
pip 19.0.3
pkg-resources 0.0.0
pymongo 3.7.2
setuptools 40.8.0
simplejson 3.16.0
Werkzeug 0.14.1
wheel 0.33.1