MaxScale/Documentation/REST-API/Resources-Server.md
Markus Makela 59e615eb3c Create initial REST API documentation
The Resources document lists all currently known resources and will be converted
to a list of separate resource documents once the individual resource documents
are done. The Headers and Response Codes document contains a list of request and
response headers and the HTTP return codes. This is a work in progress and will
be expanded upon.

Added initial versions of the filter, monitor, session and user resource
documents. These provide information about various parts of MaxScale and
allow interaction.

All PATCH operations expect a JSON Patch type document in the request
body. Examples modified accordingly.

Add MaxScale resource document which describes the resources that give the
global configuration options and show statistics.

The resources that link to other resources provide values as a list of
relative links. This reduces the amount of sent data when the client
doesn't require all parts of the resource.

Since the updating is not yet implement, it should be stated that the update API
will most likely be modified at some point.

The module resource is similar to `maxadmin show modules` and the log
resource contains status information about logs. The log resource also has
an "action" resource at `/maxscale/logs/flush` which flushes logs to disk
and rotates them.

Added start and stop entry points for services and monitors. Also added
missing service parameters to the list of parameters that can be updated.

The documentation lists listeners as a sub-resource of the
service. This allows the listeners of a particular service to be queried.
2016-11-07 14:20:44 +02:00

4.4 KiB

Server Resource

A server resource represents a backend database server.

Resource Operations

Get a server

Get a single server. The :name in the URI must be a valid server name with all whitespace replaced with hyphens. The server names are case-insensitive.

GET /servers/:name

Response

Status: 200 OK

{
    "name": "db-serv-1",
    "address": "192.168.121.58",
    "port": 3306,
    "protocol": "MySQLBackend",
    "status": [
        "master",
        "running"
    ],
    "parameters": {
        "report_weight": 10,
        "app_weight": 2
    }
}

Note: The parameters field contains all custom parameters for servers, including the server weighting parameters.

Supported Request Parameter

  • fields

Get all servers

GET /servers

Response

Status: 200 OK

[
    {
        "name": "db-serv-1",
        "address": "192.168.121.58",
        "port": 3306,
        "protocol": "MySQLBackend",
        "status": [
            "master",
            "running"
        ],
        "parameters": {
            "report_weight": 10,
            "app_weight": 2
        }
    },
    {
        "name": "db-serv-2",
        "address": "192.168.121.175",
        "port": 3306,
        "status": [
            "slave",
            "running"
        ],
        "protocol": "MySQLBackend",
        "parameters": {
            "app_weight": 6
        }
    }
]

Supported Request Parameter

  • fields
  • range

Update a server

Note: The update mechanisms described here are provisional and most likely will change in the future. This description is only for design purposes and does not yet work.

Partially update a server. The :name in the URI must map to a server name with all whitespace replaced with hyphens and the request body must be a valid JSON Patch document which is applied to the resource.

PATCH /servers/:name

Modifiable Fields

Field Type Description
address string Server address
port number Server port
parameters object Server extra parameters
state string array Server state, array of master, slave, synced, running or maintenance. An empty array is interpreted as a server that is down.
{
    { "op": "replace", "path": "/address", "value": "192.168.0.100" },
    { "op": "replace", "path": "/port", "value": 4006 },
    { "op": "add", "path": "/state/0", "value": "maintenance" },
    { "op": "replace", "path": "/parameters/report_weight", "value": 1 }
}

Response

Response contains the modified resource.

Status: 200 OK

{
    "name": "db-serv-1",
    "protocol": "MySQLBackend",
    "address": "192.168.0.100",
    "port": 4006,
    "state": [
        "maintenance",
        "running"
    ],
    "parameters": {
        "report_weight": 1,
        "app_weight": 2
    }
}

Get all connections to a server

Get all connections that are connected to a server.

GET /servers/:name/connections

Response

Status: 200 OK

[
    {
        "state": "DCB in the polling loop",
        "role": "Backend Request Handler",
        "server": "/servers/db-serv-01",
        "service": "/services/my-service",
        "statistics": {
            "reads":             2197
            "writes":            1562
            "buffered_writes":   0
            "high_water_events": 0
            "low_water_events":  0
        }
    },
    {
        "state": "DCB in the polling loop",
        "role": "Backend Request Handler",
        "server": "/servers/db-serv-01",
        "service": "/services/my-second-service"
        "statistics": {
            "reads":             0
            "writes":            0
            "buffered_writes":   0
            "high_water_events": 0
            "low_water_events":  0
        }
    }
]

Supported Request Parameter

  • fields
  • range

Close all connections to a server

Close all connections to a particular server. This will forcefully close all backend connections.

DELETE /servers/:name/connections

Response

Status: 204 No Content