MXS-1220: Add POST and DELETE documentation for servers

Added POST and DELETE documentation on the servers resource. Also cleaned
up formatting.
This commit is contained in:
Markus Mäkelä
2017-05-02 15:41:53 +03:00
parent a3ae9d5401
commit bcbff5da1b
2 changed files with 123 additions and 10 deletions

View File

@ -6,13 +6,16 @@ A server resource represents a backend database server.
### 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
```
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
```
@ -53,8 +56,11 @@ Status: 200 OK
}
```
**Note**: The _parameters_ field contains all custom parameters for
servers, including the server weighting parameters.
Server not found:
```
Status: 404 Not Found
```
#### Supported Request Parameter
@ -68,6 +74,8 @@ GET /servers
#### Response
Response contains an array of all servers.
```
Status: 200 OK
@ -141,17 +149,78 @@ Status: 200 OK
- `pretty`
### Create a server
```
POST /servers
```
Create a new server by defining the resource. The posted object must define the
_name_ field with the name of the server and the _parameters_ field with JSON
object containing values for the _address_ and _port_ parameters. The following
is the minimal required JSON object for defining a new server.
```
{
"name": "test-server",
"parameters": {
"address": "127.0.0.1",
"port": 3003
}
}
```
#### Response
Response contains the created resource.
```
Status: 200 OK
{
"name": "test-server",
"parameters": {
"address": "127.0.0.1",
"port": 3003,
"protocol": "MySQLBackend"
},
"status": "Running",
"node_id": -1,
"master_id": -1,
"replication_depth": -1,
"slaves": [],
"statictics": {
"connections": 0,
"total_connections": 0,
"active_operations": 0
},
"relationships": {
"self": "http://localhost:8989/servers/test-server"
}
}
```
Invalid JSON body:
```
Status: 400 Bad Request
```
#### Supported Request Parameter
- `pretty`
### Update a server
```
PUT /servers/:name
```
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.
```
PUT /servers/:name
```
### Modifiable Fields
The following standard server parameter can be modified.
@ -257,10 +326,54 @@ Status: 200 OK
}
```
Server not found:
```
Status: 404 Not Found
```
Invalid JSON body:
```
Status: 400 Bad Request
```
#### Supported Request Parameter
- `pretty`
### Destroy a server
```
DELETE /servers/:name
```
The _:name_ in the URI must map to a server name with all whitespace replaced
with hyphens.
A server can only be deleted if the only relations in the _relationships_ object
is the _self_ link.
#### Response
OK:
```
Status: 204 No Content
```
Server not found:
```
Status: 404 Not Found
```
Server is in use:
```
Status: 400 Bad Request
```
# **TODO:** Implement the following features
### Get all connections to a server