Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
2.2.19, 2.3.2
-
None
-
MXS-SPRINT-75, MXS-SPRINT-76, MXS-SPRINT-77
Description
I think it would be helpful to document some examples on how to use the REST API with some popular REST clients, such as curl.
I did some testing myself.
First, I configured the following:
[maxscale]
|
...
|
admin_host=127.0.0.1
|
admin_port=8989
|
admin_auth=1
|
admin_enabled=1
|
And then I did some tests with the passive flag.
To read the value, I followed these directions:
https://mariadb.com/kb/en/mariadb-maxscale-23-maxscale-resource/#get-global-information
And did the following:
$ curl --include --basic --user "admin:mariadb" http://127.0.0.1:8989/v1/maxscale
|
HTTP/1.1 200 OK
|
Connection: Keep-Alive
|
Content-Length: 1876
|
Last-Modified: Fri, 11 Jan 2019 23:50:34 GMT
|
ETag: "1"
|
Date: Fri, 11 Jan 19 23:52:01 GMT
|
Content-Type: application/json
|
|
{
|
"links": {
|
"self": "http://127.0.0.1:8989/v1/maxscale/"
|
},
|
"data": {
|
"attributes": {
|
"parameters": {
|
"libdir": "/usr/lib64/maxscale",
|
"datadir": "/var/lib/maxscale",
|
"process_datadir": "/var/lib/maxscale/data2997",
|
"cachedir": "/var/cache/maxscale",
|
"configdir": "/etc",
|
"config_persistdir": "/var/lib/maxscale/maxscale.cnf.d",
|
"module_configdir": "/etc/maxscale.modules.d",
|
"piddir": "/var/run/maxscale",
|
"logdir": "/var/log/maxscale",
|
"langdir": "/var/lib/maxscale",
|
"execdir": "/usr/bin",
|
"connector_plugindir": "/var/lib/plugin",
|
"threads": 4,
|
"thread_stack_size": 8388608,
|
"writeq_high_water": 0,
|
"writeq_low_water": 0,
|
"auth_connect_timeout": 3,
|
"auth_read_timeout": 1,
|
"auth_write_timeout": 2,
|
"skip_permission_checks": false,
|
"admin_auth": true,
|
"admin_enabled": true,
|
"admin_log_auth_failures": true,
|
"admin_host": "127.0.0.1",
|
"admin_port": 8989,
|
"admin_ssl_key": "",
|
"admin_ssl_cert": "",
|
"admin_ssl_ca_cert": "",
|
"passive": true,
|
"query_classifier": "",
|
"query_classifier_cache_size": 415775129
|
},
|
"version": "2.3.2",
|
"commit": "1126c687a4570f60ee26a163520198a3263ccbbd",
|
"started_at": "Fri, 11 Jan 2019 23:21:26 GMT",
|
"activated_at": "Fri, 11 Jan 2019 23:21:26 GMT",
|
"uptime": 1835
|
},
|
"id": "maxscale",
|
"type": "maxscale"
|
}
|
}
|
And then to change the value, I followed these directions:
https://mariadb.com/kb/en/mariadb-maxscale-23-maxscale-resource/#update-maxscale-parameters
And did the following:
$ curl --include --request PATCH --basic --user "admin:mariadb" http://127.0.0.1:8989/v1/maxscale --data @- <<EOF
|
> {
|
> "data": {
|
> "attributes": {
|
> "parameters": {
|
> "passive": false
|
> }
|
> }
|
> }
|
> }
|
> EOF
|
HTTP/1.1 204 No Content
|
Connection: Keep-Alive
|
Date: Fri, 11 Jan 19 23:52:45 GMT
|
And then I confirmed that the value changed by reading it again:
$ curl --include --basic --user "admin:mariadb" http://127.0.0.1:8989/v1/maxscale
|
HTTP/1.1 200 OK
|
Connection: Keep-Alive
|
Content-Length: 1877
|
Last-Modified: Fri, 11 Jan 2019 23:52:45 GMT
|
ETag: "2"
|
Date: Fri, 11 Jan 19 23:53:17 GMT
|
Content-Type: application/json
|
|
{
|
"links": {
|
"self": "http://127.0.0.1:8989/v1/maxscale/"
|
},
|
"data": {
|
"attributes": {
|
"parameters": {
|
"libdir": "/usr/lib64/maxscale",
|
"datadir": "/var/lib/maxscale",
|
"process_datadir": "/var/lib/maxscale/data2997",
|
"cachedir": "/var/cache/maxscale",
|
"configdir": "/etc",
|
"config_persistdir": "/var/lib/maxscale/maxscale.cnf.d",
|
"module_configdir": "/etc/maxscale.modules.d",
|
"piddir": "/var/run/maxscale",
|
"logdir": "/var/log/maxscale",
|
"langdir": "/var/lib/maxscale",
|
"execdir": "/usr/bin",
|
"connector_plugindir": "/var/lib/plugin",
|
"threads": 4,
|
"thread_stack_size": 8388608,
|
"writeq_high_water": 0,
|
"writeq_low_water": 0,
|
"auth_connect_timeout": 3,
|
"auth_read_timeout": 1,
|
"auth_write_timeout": 2,
|
"skip_permission_checks": false,
|
"admin_auth": true,
|
"admin_enabled": true,
|
"admin_log_auth_failures": true,
|
"admin_host": "127.0.0.1",
|
"admin_port": 8989,
|
"admin_ssl_key": "",
|
"admin_ssl_cert": "",
|
"admin_ssl_ca_cert": "",
|
"passive": false,
|
"query_classifier": "",
|
"query_classifier_cache_size": 415775129
|
},
|
"version": "2.3.2",
|
"commit": "1126c687a4570f60ee26a163520198a3263ccbbd",
|
"started_at": "Fri, 11 Jan 2019 23:21:26 GMT",
|
"activated_at": "Fri, 11 Jan 2019 23:52:42 GMT",
|
"uptime": 1911
|
},
|
"id": "maxscale",
|
"type": "maxscale"
|
}
|
}
|