Merge pull request #1368 from xiangli-cmu/doc

doc: add admin api doc
This commit is contained in:
Xiang Li 2014-10-24 10:42:14 -07:00
commit e081ad7298
2 changed files with 93 additions and 69 deletions

View File

@ -0,0 +1,93 @@
## Admin API
### GET /v2/admin/members/:id
Returns an HTTP 200 OK response code and a representation of the requested member; returns a 404 status code and an error message if the id does not exist.
```
Example Request: GET
http://localhost:2379/v2/admin/members/272e204152
Response formats: JSON
Example Response:
```
```json
[
{
"ID":"272e204152",
"Name":"node1",
"PeerURLs":[
"http://10.0.0.10:2379"
],
"ClientURLs":[
"http://10.0.0.10:2380"
]
},
]
```
### GET /v2/admin/members/
Return an HTTP 200 OK response code and a representation of all the members;
```
Example Request: GET
http://localhost:2379/v2/admin/members/
Response formats: JSON
Example Response:
```
```json
[
{
"ID":"272e204152",
"Name":"node1",
"PeerURLs":[
"http://10.0.0.10:2379"
],
"ClientURLs":[
"http://10.0.0.10:2380"
]
},
{
"ID":"2225373f43",
"Name":"node2",
"PeerURLs":[
"http://127.0.0.11:2379"
],
"ClientURLs":[
"http://127.0.0.11:2380"
]
},
]
```
### POST /v2/admin/members/
Add a member to the cluster.
Returns an HTTP 201 response code and the representation of added member with a newly generated a memberID when successful. Returns a string describing the failure condition when unsuccessful.
If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
```
Example Request: POST
http://localhost:2379/v2/admin/members/
Body:
[{"PeerURLs":["http://10.0.0.10:2379"]}]
Respose formats: JSON
Example Response:
```
```json
[
{
"id":"3777296169",
"PeerURLs":[
"http://10.0.0.10:2379"
],
},
]
```
### DELETE /v2/admin/members/:id
Remove a member from the cluster.
Returns empty when successful. Returns a string describing the failure condition when unsuccessful.
If the member does not exist in the cluster an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
```
Response formats: JSON
Example Request: DELETE
http://localhost:2379/v2/admin/members/272e204152
Example Response: Empty
```

View File

@ -1,69 +0,0 @@
/*
Copyright 2014 CoreOS, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
## Add Member
### Request
`curl http://${remote_client_url}/v2/admin/members/{$id} -XPUT -d 'PeerURLs=${peer_url_1}&PeerURLs=${peer_url_2}'`
Parameter `remote_client_url` is serving client url of the cluster.
Parameter `id` is the identification of new member in hexadecimal.
Parameter `peer_url_` is peer urls of the new member.
### Response
Categorized by HTTP status code.
#### HTTP 201
The member is created successfully.
#### HTTP 400
etcd cannot parse out the request.
#### HTTP 500
etcd fails to create the new member.
## Remove Member
### Request
`curl http://${remote_client_url}/v2/admin/members/{$id} -XDELETE`
Parameter `remote_client_url` is serving client url of the cluster.
Parameter `id` is the identification of member to be removed in hexadecimal.
### Response
#### HTTP 204
The member is removed successfully.
#### HTTP 400
etcd cannot parse out the request.
#### HTTP 500
etcd fails to remove the member.
*/
package etcdhttp