{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/60136310","id":60136310,"diff_hunk":"@@ -0,0 +1,183 @@\n+# Interacting with etcd\n+\n+Users mostly interact with etcd by putting or getting the value of a key. This section describes how to do that by using etcdctl, a command line tool for interacting with etcd server. The concepts described here should apply to the gRPC APIs or client library APIs.\n+\n+By default, etcdctl talks to the etcd server with the v2 API for backward compatibility. For etcdctl to speak to etcd using the v3 API, the API version must be set to version 3 via the `ETCDCTL_API` environment variable.\n+\n+``` bash\n+export ETCDCTL_API=3\n+```\n+\n+## Write a key\n+\n+Applications store keys into the etcd cluster by writing to keys. Every stored key is replicated to all etcd cluster members through raft to achieve consistency and reliability.\n+\n+Here is the command to set the value of key `foo` to `bar`:\n+\n+``` bash\n+$ etcdctl put foo bar\n+OK\n+```\n+\n+## Read keys\n+\n+Applications can read values of keys from etcd cluster. Both ranged queries and single-key queries are supported. \n+\n+Suppose we have keys already stored in etcd as blow:\n+\n+```\n+foo = bar\n+foo1 = bar1\n+foo3 = bar3\n+```\n+\n+Here is the command to read the value of key `foo`:\n+\n+```bash\n+$ etcdctl get foo\n+foo\n+bar\n+```\n+\n+Here is the command to range over the keys from `foo` to `foo9`:\n+\n+```bash\n+$ etcdctl get foo foo9\n+foo\n+bar\n+foo1\n+bar1\n+foo3\n+bar3\n+```\n+\n+## Read past version of keys\n+\n+Applications may want to read superseded versions of a key for various reasons. For example, an application may wish to rollback to an old configuration by accessing an early version of a key. Alternatively, an application may want a consistent view over multiple keys over multiple requests by accessing key history.\n+Since every modification to the etcd cluster key-value store increments the global revision of etcd cluster, an application can read superseded keys by providing a historical etcd revision.\n+\n+Suppose an etcd cluster already has the following keys:\n+\n+``` bash\n+$ etcdctl put foo bar         # revision = 2\n+$ etcdctl put foo1 bar1       # revision = 3\n+$ etcdctl put foo bar_new     # revision = 4 \n+$ etcdctl put foo1 bar1_new   # revision = 5\n+```\n+\n+Here are an example to access the past versions of keys:\n+\n+```bash\n+$ etcdctl get foo foo10 # access the most recent versions of keys\n+foo\n+bar_new\n+foo1\n+bar1_new\n+\n+$ etcdctl get --rev=4 foo foo10 # access the versions of keys at revision 4\n+foo\n+bar_new\n+foo1\n+bar1\n+\n+$ etcdctl get --rev=3 foo foo10 # access the versions of keys at revision 3\n+foo\n+bar\n+foo1\n+bar1\n+\n+$ etcdctl get --rev=2 foo foo10 # access the versions of keys at revision 2\n+foo\n+bar\n+\n+$ etcdctl get --rev=1 foo foo10 # access the versions of keys at revision 1\n+```\n+\n+## Delete keys\n+\n+Applications can delete a key or a range of keys from etcd cluster.\n+\n+Here is the command to delete key `foo`:\n+\n+```bash\n+$ etcdctl del foo\n+1 # one key is deleted\n+```\n+\n+Here is the command to delete keys ranging from `foo` to `foo10`:","path":"Documentation/interacting_v3.md","position":null,"original_position":107,"commit_id":"a2ac63917606bb8efabdcb42830e3c9dcba5d127","original_commit_id":"4a36fe525a573ef4445cc3080d54bded44a9b1b1","user":{"login":"joshix","id":72905,"avatar_url":"https://avatars.githubusercontent.com/u/72905?v=3","gravatar_id":"","url":"https://api.github.com/users/joshix","html_url":"https://github.com/joshix","followers_url":"https://api.github.com/users/joshix/followers","following_url":"https://api.github.com/users/joshix/following{/other_user}","gists_url":"https://api.github.com/users/joshix/gists{/gist_id}","starred_url":"https://api.github.com/users/joshix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshix/subscriptions","organizations_url":"https://api.github.com/users/joshix/orgs","repos_url":"https://api.github.com/users/joshix/repos","events_url":"https://api.github.com/users/joshix/events{/privacy}","received_events_url":"https://api.github.com/users/joshix/received_events","type":"User","site_admin":false},"body":"It is just for consistency across the examples - the first range example used `foo` through `foo9`.","created_at":"2016-04-18T21:20:20Z","updated_at":"2016-04-18T21:20:20Z","html_url":"https://github.com/coreos/etcd/pull/5105#discussion_r60136310","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/5105","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/60136310"},"html":{"href":"https://github.com/coreos/etcd/pull/5105#discussion_r60136310"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/5105"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/5105","id":66696861,"html_url":"https://github.com/coreos/etcd/pull/5105","diff_url":"https://github.com/coreos/etcd/pull/5105.diff","patch_url":"https://github.com/coreos/etcd/pull/5105.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/5105","number":5105,"state":"open","locked":false,"title":"doc: add write/read example for interact doc","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"body":"/cc @joshix @heyitsanthony ","created_at":"2016-04-15T20:01:46Z","updated_at":"2016-04-18T21:20:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6bee3953f29b5f3181f261949aa42ecdea5ab09a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/5105/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/5105/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/5105/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/a2ac63917606bb8efabdcb42830e3c9dcba5d127","head":{"label":"xiang90:get_started","ref":"get_started","sha":"a2ac63917606bb8efabdcb42830e3c9dcba5d127","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"repo":{"id":11245678,"name":"etcd","full_name":"xiang90/etcd","owner":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiang90/etcd","description":null,"fork":true,"url":"https://api.github.com/repos/xiang90/etcd","forks_url":"https://api.github.com/repos/xiang90/etcd/forks","keys_url":"https://api.github.com/repos/xiang90/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiang90/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiang90/etcd/teams","hooks_url":"https://api.github.com/repos/xiang90/etcd/hooks","issue_events_url":"https://api.github.com/repos/xiang90/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/xiang90/etcd/events","assignees_url":"https://api.github.com/repos/xiang90/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/xiang90/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/xiang90/etcd/tags","blobs_url":"https://api.github.com/repos/xiang90/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiang90/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiang90/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiang90/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiang90/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/xiang90/etcd/languages","stargazers_url":"https://api.github.com/repos/xiang90/etcd/stargazers","contributors_url":"https://api.github.com/repos/xiang90/etcd/contributors","subscribers_url":"https://api.github.com/repos/xiang90/etcd/subscribers","subscription_url":"https://api.github.com/repos/xiang90/etcd/subscription","commits_url":"https://api.github.com/repos/xiang90/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiang90/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiang90/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiang90/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiang90/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/xiang90/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiang90/etcd/merges","archive_url":"https://api.github.com/repos/xiang90/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiang90/etcd/downloads","issues_url":"https://api.github.com/repos/xiang90/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/xiang90/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/xiang90/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/xiang90/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiang90/etcd/labels{/name}","releases_url":"https://api.github.com/repos/xiang90/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/xiang90/etcd/deployments","created_at":"2013-07-08T04:17:14Z","updated_at":"2015-06-09T18:06:32Z","pushed_at":"2016-04-18T20:42:21Z","git_url":"git://github.com/xiang90/etcd.git","ssh_url":"git@github.com:xiang90/etcd.git","clone_url":"https://github.com/xiang90/etcd.git","svn_url":"https://github.com/xiang90/etcd","homepage":null,"size":23725,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"8a0fa5622edd84eb5458444fa3387716ddd42349","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"Distributed reliable key-value store for the most critical data of a distributed system","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd/deployments","created_at":"2013-07-06T21:57:21Z","updated_at":"2016-04-18T18:51:06Z","pushed_at":"2016-04-18T20:42:22Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"https://coreos.com/etcd/docs/latest/","size":30293,"stargazers_count":9310,"watchers_count":9310,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1547,"mirror_url":null,"open_issues_count":133,"forks":1547,"open_issues":133,"watchers":9310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/5105"},"html":{"href":"https://github.com/coreos/etcd/pull/5105"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/5105"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/5105/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/5105/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/5105/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/a2ac63917606bb8efabdcb42830e3c9dcba5d127"}}}}