Feature #4366
closed
Implement API access to event database
Added by Jan Mach about 6 years ago.
Updated about 6 years ago.
Category:
Development - GUI
Description
It would be useful for many applications that the event database is be accessible via some kind of HTTPS API. For starters just implement the API_TOKEN authentication mechanism and provide the same interface as in the event search page, but this time returning JSON responses.
- Status changed from New to In Progress
- % Done changed from 0 to 30
- Related to Feature #4235: Hawat: Improve propagation of view metadata into templates added
- Status changed from In Progress to Feedback
- % Done changed from 30 to 90
Radko Krkoš wrote:
I am probably not the one you are asking, but I like it a lot.
I have just one remark.
Jan Mach wrote:
Valid search:
https://mentat-alt.cesnet.cz/mentat/api/events/search?dt_from=2018-10-19+00%3A00%3A00&dt_to=&source_addrs=&source_ports=&submit=Search
The sqlquery
is returned as:
[...]
I would prefer a version without all the horrible escaping, like this:
[...]
That version can be used directly for all derived uses I can think of.
Thank you for the remark. I have fixed it to the following form:
"SELECT * FROM events WHERE \"detecttime\" >= '2018-10-22T00:00:00+00:00'::timestamptz ORDER BY \"detecttime\" DESC LIMIT 100"
Sadly there is nothing more that can be done with the escaping of "
character, because it is a valid SQL syntax for column names as it is printed by psycopg and it being rendered into JSON and then displayed as part of that JSON, so the escaping is necessary. I could of course strip all "
characters from that string, but I consider that a bad idea, because it alters the original SQL command. I think, that the main purpose of this feature is to know the exact SQL command that is being executed, not a mangled version.
Jan Mach wrote:
Sadly there is nothing more that can be done with the escaping of "
character, because it is a valid SQL syntax for column names as it is printed by psycopg and it being rendered into JSON and then displayed as part of that JSON, so the escaping is necessary. I could of course strip all "
characters from that string, but I consider that a bad idea, because it alters the original SQL command. I think, that the main purpose of this feature is to know the exact SQL command that is being executed, not a mangled version.
This is more than enough for me. I was also unsure about the column name escaping and I am happy with the solution.
- Status changed from Feedback to Closed
- % Done changed from 90 to 100
Also available in: Atom
PDF