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.
Note: The parameters field contains all custom parameters for servers, including the server weighting parameters.
Response
Status: 200 OK
Get all servers
Response
Response contains a resource collection with all servers.
Status: 200 OK
Create a server
Create a new server by defining the resource. The posted object must define at least the following fields.
data.id
Name of the server
data.type
Type of the object, must be
servers
data.attributes.parameters.protocol
The protocol to use. Must be defined.
data.attributes.parameters.address
ORdata.attributes.parameters.socket
data.attributes.parameters.port
The port to use. Needs to be defined if the
address
field is defined.
The following is the minimal required JSON object for defining a new server.
The relationships of a server can also be defined at creation time. This allows new servers to be created and immediately taken into use.
The following parameters can be defined when a server is being created.
Response
Server created:
Status: 204 No Content
Invalid JSON body:
Status: 403 Forbidden
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 document representing the modified server. If the server in question is not found, a 404 Not Found response is returned.
Modifiable Fields
The following standard server parameters can be modified.
Refer to the documentation on these parameters for valid values.
The server weighting parameters can also be added, removed and updated. To
remove a parameter, define the value of that parameter as the null JSON type
e.g. { "my-param": null }
. To add a parameter, add a new key-value pair to
the parameters object with a name that does not conflict with the standard
parameters. To modify a weighting parameter, simply change the value.
In addition to standard parameters, the services and monitors fields of therelationships object can be modified. Removal, addition and modification of the links will change which service and monitors use this server.
For example, removing the first value in the services list in therelationships object from the following JSON document will remove theserver1 from the service RW-Split-Router.
Removing a service from a server is analogous to removing the server from the service. Both unlink the two objects from each other.
Response to GET /v1/servers/server1
:
Request for PATCH /v1/servers/server1
:
If parts of the resource are not defined (e.g. the attributes
field in the
above example), those parts of the resource are not modified. All parts that are
defined are interpreted as the new definition of those part of the resource. In
the above example, the relationships
of the resource are completely redefined.
Response
Server modified:
Status: 204 No Content
Invalid JSON body:
Status: 403 Forbidden
Update server relationships
The :name in the URI must map to a server name with all whitespace replaced with hyphens. The :type in the URI must be either services, for service relationships, or monitors, for monitor relationships.
The request body must be a JSON object that defines only the data field. The value of the data field must be an array of relationship objects that define the id and type fields of the relationship. This object will replace the existing relationships of the particular type from the server.
The following is an example request and request body that defines a single service relationship for a server.
All relationships for a server can be deleted by sending an empty array as thedata field value. The following example removes the server from all services.
Response
Server relationships modified:
Status: 204 No Content
Invalid JSON body:
Status: 403 Forbidden
Destroy a server
The :name in the URI must map to a server name with all whitespace replaced with hyphens.
A server can only be deleted if it is not used by any services or monitors.
Response
Server is destroyed:
Status: 204 No Content
Server is in use:
Status: 403 Forbidden
Set server state
The :name in the URI must map to a server name with all whitespace replaced
with hyphens. This endpoint requires that the state
parameter is passed with
the request. The value of state
must be one of the following values.
Value
State Description
master
Server is a Master
slave
Server is a Slave
maintenance
Server is put into maintenance
running
Server is up and running
synced
Server is a Galera node
drain
Server is drained of connections
For example, to set the server db-server-1 into maintenance mode, a request to the following URL must be made:
This endpoint also supports the force=yes
parameter that will cause all
connections to the server to be closed if state=maintenance
is also set. By
default setting a server into maintenance mode will cause connections to be
closed only after the next request is sent.
The following example forcefully closes all connections to server db-server-1 and sets it into maintenance mode:
Response
Server state modified:
Status: 204 No Content
Missing or invalid parameter:
Status: 403 Forbidden
Clear server state
The :name in the URI must map to a server name with all whitespace replaced
with hyphens. This endpoint requires that the state
parameter is passed with
the request. The value of state
must be one of the values defined in theset endpoint documentation.
Response
Server state modified:
Status: 204 No Content
Missing or invalid parameter:
Status: 403 Forbidden
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?