Add master extraction via REST API

The master server of a monitor can now be extracted with the
mon_get_external_master function. It uses the REST API to find a master
server in the set of servers monitored by a monitor.
This commit is contained in:
Markus Mäkelä
2018-08-19 20:35:41 +03:00
parent 934600f8fc
commit 13c04324cf
2 changed files with 69 additions and 0 deletions

View File

@ -338,4 +338,18 @@ MXS_MONITOR_API MonitorApi<MonitorInstance>::s_api =
&MonitorApi<MonitorInstance>::diagnostics_json,
};
/**
* Get the master server of the monitor pointed by @c url
*
* The URL must be in `http://hostname-of-maxscale:<rest-api-port>/v1/monitors/<name-of-monitor>`
* format and must point to a single monitor resource.
*
* TODO: Move the base URL and credentials into a global parameter
*
* @param url URL to a REST API endpoint for a monitor
*
* @return The host and port of the monitor or an empty string and 0 if an error occurred
*/
std::pair<std::string, int> mon_get_external_master(const std::string& url);
}