MXS-1220: Express relations in JSON API style
The JSON API (http://jsonapi.org/) specifies a way to express relations in a somewhat generic way. By moving towards a more generic schema for the resources, it will be easier to handle the modification of the relations between these resources.
This commit is contained in:
committed by
Markus Mäkelä
parent
5b9c276123
commit
b6add43bd2
@ -1553,6 +1553,8 @@ json_t* monitor_to_json(const MXS_MONITOR* monitor, const char* host)
|
||||
json_object_set_new(rval, "write_timeout", json_integer(monitor->write_timeout));
|
||||
json_object_set_new(rval, "connect_attempts", json_integer(monitor->connect_attempts));
|
||||
|
||||
json_t* rel = json_object();
|
||||
|
||||
if (monitor->databases)
|
||||
{
|
||||
json_t* arr = json_array();
|
||||
@ -1565,9 +1567,10 @@ json_t* monitor_to_json(const MXS_MONITOR* monitor, const char* host)
|
||||
json_array_append_new(arr, json_string(s.c_str()));
|
||||
}
|
||||
|
||||
json_object_set_new(rval, "servers", arr);
|
||||
json_object_set_new(rel, "servers", arr);
|
||||
}
|
||||
|
||||
json_object_set_new(rval, "relationships", rel);
|
||||
|
||||
if (monitor->handle && monitor->module->diagnostics)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user