diff --git a/Documentation/REST-API/API.md b/Documentation/REST-API/API.md index c9a7b6010..1a297126d 100644 --- a/Documentation/REST-API/API.md +++ b/Documentation/REST-API/API.md @@ -435,7 +435,7 @@ objects. This closely resembles the JSON API definition of links. In the _relationships_ objects, all resources have a _self_ link that points to the resource itself. This allows for easier updating of resources as the reply -URL is included in the request itself. +URL is included in the response itself. The following lists the resources and the types of links each resource can have in addition to the _self_ link. diff --git a/Documentation/REST-API/Resources-Server.md b/Documentation/REST-API/Resources-Server.md index 9fd9b28a1..b2bc34569 100644 --- a/Documentation/REST-API/Resources-Server.md +++ b/Documentation/REST-API/Resources-Server.md @@ -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