1 Star 0 Fork 0

shan123 / etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
members_api.md 3.22 KB
一键复制 编辑 原始数据 按行查看 历史

Members API

List members

Return an HTTP 200 OK response code and a representation of all members in the etcd cluster.

Request

GET /v2/members HTTP/1.1

Example

curl http://10.0.0.10:2379/v2/members
{
    "members": [
        {
            "id": "272e204152",
            "name": "infra1",
            "peerURLs": [
                "http://10.0.0.10:2380"
            ],
            "clientURLs": [
                "http://10.0.0.10:2379"
            ]
        },
        {
            "id": "2225373f43",
            "name": "infra2",
            "peerURLs": [
                "http://10.0.0.11:2380"
            ],
            "clientURLs": [
                "http://10.0.0.11:2379"
            ]
        },
    ]
}

Add a member

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 409 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 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.

Request

POST /v2/members HTTP/1.1

{"peerURLs": ["http://10.0.0.10:2380"]}

Example

curl http://10.0.0.10:2379/v2/members -XPOST \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
{
    "id": "3777296169",
    "peerURLs": [
        "http://10.0.0.10:2380"
    ]
}

Delete a member

Remove a member from the cluster. The member ID must be a hex-encoded uint64. Returns 204 with empty content 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.

Request

DELETE /v2/members/<id> HTTP/1.1

Example

curl http://10.0.0.10:2379/v2/members/272e204152 -XDELETE

Change the peer urls of a member

Change the peer urls of a given member. The member ID must be a hex-encoded uint64. Returns 204 with empty content 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 does not exist in the cluster an HTTP 404 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 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.

Request

PUT /v2/members/<id> HTTP/1.1

{"peerURLs": ["http://10.0.0.10:2380"]}

Example

curl http://10.0.0.10:2379/v2/members/272e204152 -XPUT \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shanmenghao/etcd.git
git@gitee.com:shanmenghao/etcd.git
shanmenghao
etcd
etcd
v2.3.7

搜索帮助

344bd9b3 5694891 D2dac590 5694891