rpc.proto 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  1. syntax = "proto3";
  2. package etcdserverpb;
  3. import "gogoproto/gogo.proto";
  4. import "etcd/mvcc/mvccpb/kv.proto";
  5. import "etcd/auth/authpb/auth.proto";
  6. // for grpc-gateway
  7. import "google/api/annotations.proto";
  8. option (gogoproto.marshaler_all) = true;
  9. option (gogoproto.unmarshaler_all) = true;
  10. service KV {
  11. // Range gets the keys in the range from the key-value store.
  12. rpc Range(RangeRequest) returns (RangeResponse) {
  13. option (google.api.http) = {
  14. post: "/v3alpha/kv/range"
  15. body: "*"
  16. };
  17. }
  18. // Put puts the given key into the key-value store.
  19. // A put request increments the revision of the key-value store
  20. // and generates one event in the event history.
  21. rpc Put(PutRequest) returns (PutResponse) {
  22. option (google.api.http) = {
  23. post: "/v3alpha/kv/put"
  24. body: "*"
  25. };
  26. }
  27. // DeleteRange deletes the given range from the key-value store.
  28. // A delete request increments the revision of the key-value store
  29. // and generates a delete event in the event history for every deleted key.
  30. rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {
  31. option (google.api.http) = {
  32. post: "/v3alpha/kv/deleterange"
  33. body: "*"
  34. };
  35. }
  36. // Txn processes multiple requests in a single transaction.
  37. // A txn request increments the revision of the key-value store
  38. // and generates events with the same revision for every completed request.
  39. // It is not allowed to modify the same key several times within one txn.
  40. rpc Txn(TxnRequest) returns (TxnResponse) {
  41. option (google.api.http) = {
  42. post: "/v3alpha/kv/txn"
  43. body: "*"
  44. };
  45. }
  46. // Compact compacts the event history in the etcd key-value store. The key-value
  47. // store should be periodically compacted or the event history will continue to grow
  48. // indefinitely.
  49. rpc Compact(CompactionRequest) returns (CompactionResponse) {
  50. option (google.api.http) = {
  51. post: "/v3alpha/kv/compaction"
  52. body: "*"
  53. };
  54. }
  55. }
  56. service Watch {
  57. // Watch watches for events happening or that have happened. Both input and output
  58. // are streams; the input stream is for creating and canceling watchers and the output
  59. // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
  60. // for several watches at once. The entire event history can be watched starting from the
  61. // last compaction revision.
  62. rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
  63. option (google.api.http) = {
  64. post: "/v3alpha/watch"
  65. body: "*"
  66. };
  67. }
  68. }
  69. service Lease {
  70. // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
  71. // within a given time to live period. All keys attached to the lease will be expired and
  72. // deleted if the lease expires. Each expired key generates a delete event in the event history.
  73. rpc LeaseGrant(LeaseGrantRequest) returns (LeaseGrantResponse) {
  74. option (google.api.http) = {
  75. post: "/v3alpha/lease/grant"
  76. body: "*"
  77. };
  78. }
  79. // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
  80. rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {
  81. option (google.api.http) = {
  82. post: "/v3alpha/kv/lease/revoke"
  83. body: "*"
  84. };
  85. }
  86. // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
  87. // to the server and streaming keep alive responses from the server to the client.
  88. rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {
  89. option (google.api.http) = {
  90. post: "/v3alpha/lease/keepalive"
  91. body: "*"
  92. };
  93. }
  94. // LeaseTimeToLive retrieves lease information.
  95. rpc LeaseTimeToLive(LeaseTimeToLiveRequest) returns (LeaseTimeToLiveResponse) {
  96. option (google.api.http) = {
  97. post: "/v3alpha/kv/lease/timetolive"
  98. body: "*"
  99. };
  100. }
  101. // LeaseLeases lists all existing leases.
  102. rpc LeaseLeases(LeaseLeasesRequest) returns (LeaseLeasesResponse) {
  103. option (google.api.http) = {
  104. post: "/v3alpha/kv/lease/leases"
  105. body: "*"
  106. };
  107. }
  108. }
  109. service Cluster {
  110. // MemberAdd adds a member into the cluster.
  111. rpc MemberAdd(MemberAddRequest) returns (MemberAddResponse) {
  112. option (google.api.http) = {
  113. post: "/v3alpha/cluster/member/add"
  114. body: "*"
  115. };
  116. }
  117. // MemberRemove removes an existing member from the cluster.
  118. rpc MemberRemove(MemberRemoveRequest) returns (MemberRemoveResponse) {
  119. option (google.api.http) = {
  120. post: "/v3alpha/cluster/member/remove"
  121. body: "*"
  122. };
  123. }
  124. // MemberUpdate updates the member configuration.
  125. rpc MemberUpdate(MemberUpdateRequest) returns (MemberUpdateResponse) {
  126. option (google.api.http) = {
  127. post: "/v3alpha/cluster/member/update"
  128. body: "*"
  129. };
  130. }
  131. // MemberList lists all the members in the cluster.
  132. rpc MemberList(MemberListRequest) returns (MemberListResponse) {
  133. option (google.api.http) = {
  134. post: "/v3alpha/cluster/member/list"
  135. body: "*"
  136. };
  137. }
  138. }
  139. service Maintenance {
  140. // Alarm activates, deactivates, and queries alarms regarding cluster health.
  141. rpc Alarm(AlarmRequest) returns (AlarmResponse) {
  142. option (google.api.http) = {
  143. post: "/v3alpha/maintenance/alarm"
  144. body: "*"
  145. };
  146. }
  147. // Status gets the status of the member.
  148. rpc Status(StatusRequest) returns (StatusResponse) {
  149. option (google.api.http) = {
  150. post: "/v3alpha/maintenance/status"
  151. body: "*"
  152. };
  153. }
  154. // Defragment defragments a member's backend database to recover storage space.
  155. rpc Defragment(DefragmentRequest) returns (DefragmentResponse) {
  156. option (google.api.http) = {
  157. post: "/v3alpha/maintenance/defragment"
  158. body: "*"
  159. };
  160. }
  161. // Hash computes the hash of the KV's backend.
  162. // This is designed for testing; do not use this in production when there
  163. // are ongoing transactions.
  164. rpc Hash(HashRequest) returns (HashResponse) {
  165. option (google.api.http) = {
  166. post: "/v3alpha/maintenance/hash"
  167. body: "*"
  168. };
  169. }
  170. // HashKV computes the hash of all MVCC keys up to a given revision.
  171. rpc HashKV(HashKVRequest) returns (HashKVResponse) {
  172. option (google.api.http) = {
  173. post: "/v3alpha/maintenance/hash"
  174. body: "*"
  175. };
  176. }
  177. // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
  178. rpc Snapshot(SnapshotRequest) returns (stream SnapshotResponse) {
  179. option (google.api.http) = {
  180. post: "/v3alpha/maintenance/snapshot"
  181. body: "*"
  182. };
  183. }
  184. // MoveLeader requests current leader node to transfer its leadership to transferee.
  185. rpc MoveLeader(MoveLeaderRequest) returns (MoveLeaderResponse) {
  186. option (google.api.http) = {
  187. post: "/v3alpha/maintenance/transfer-leadership"
  188. body: "*"
  189. };
  190. }
  191. }
  192. service Auth {
  193. // AuthEnable enables authentication.
  194. rpc AuthEnable(AuthEnableRequest) returns (AuthEnableResponse) {
  195. option (google.api.http) = {
  196. post: "/v3alpha/auth/enable"
  197. body: "*"
  198. };
  199. }
  200. // AuthDisable disables authentication.
  201. rpc AuthDisable(AuthDisableRequest) returns (AuthDisableResponse) {
  202. option (google.api.http) = {
  203. post: "/v3alpha/auth/disable"
  204. body: "*"
  205. };
  206. }
  207. // Authenticate processes an authenticate request.
  208. rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) {
  209. option (google.api.http) = {
  210. post: "/v3alpha/auth/authenticate"
  211. body: "*"
  212. };
  213. }
  214. // UserAdd adds a new user.
  215. rpc UserAdd(AuthUserAddRequest) returns (AuthUserAddResponse) {
  216. option (google.api.http) = {
  217. post: "/v3alpha/auth/user/add"
  218. body: "*"
  219. };
  220. }
  221. // UserGet gets detailed user information.
  222. rpc UserGet(AuthUserGetRequest) returns (AuthUserGetResponse) {
  223. option (google.api.http) = {
  224. post: "/v3alpha/auth/user/get"
  225. body: "*"
  226. };
  227. }
  228. // UserList gets a list of all users.
  229. rpc UserList(AuthUserListRequest) returns (AuthUserListResponse) {
  230. option (google.api.http) = {
  231. post: "/v3alpha/auth/user/list"
  232. body: "*"
  233. };
  234. }
  235. // UserDelete deletes a specified user.
  236. rpc UserDelete(AuthUserDeleteRequest) returns (AuthUserDeleteResponse) {
  237. option (google.api.http) = {
  238. post: "/v3alpha/auth/user/delete"
  239. body: "*"
  240. };
  241. }
  242. // UserChangePassword changes the password of a specified user.
  243. rpc UserChangePassword(AuthUserChangePasswordRequest) returns (AuthUserChangePasswordResponse) {
  244. option (google.api.http) = {
  245. post: "/v3alpha/auth/user/changepw"
  246. body: "*"
  247. };
  248. }
  249. // UserGrant grants a role to a specified user.
  250. rpc UserGrantRole(AuthUserGrantRoleRequest) returns (AuthUserGrantRoleResponse) {
  251. option (google.api.http) = {
  252. post: "/v3alpha/auth/user/grant"
  253. body: "*"
  254. };
  255. }
  256. // UserRevokeRole revokes a role of specified user.
  257. rpc UserRevokeRole(AuthUserRevokeRoleRequest) returns (AuthUserRevokeRoleResponse) {
  258. option (google.api.http) = {
  259. post: "/v3alpha/auth/user/revoke"
  260. body: "*"
  261. };
  262. }
  263. // RoleAdd adds a new role.
  264. rpc RoleAdd(AuthRoleAddRequest) returns (AuthRoleAddResponse) {
  265. option (google.api.http) = {
  266. post: "/v3alpha/auth/role/add"
  267. body: "*"
  268. };
  269. }
  270. // RoleGet gets detailed role information.
  271. rpc RoleGet(AuthRoleGetRequest) returns (AuthRoleGetResponse) {
  272. option (google.api.http) = {
  273. post: "/v3alpha/auth/role/get"
  274. body: "*"
  275. };
  276. }
  277. // RoleList gets lists of all roles.
  278. rpc RoleList(AuthRoleListRequest) returns (AuthRoleListResponse) {
  279. option (google.api.http) = {
  280. post: "/v3alpha/auth/role/list"
  281. body: "*"
  282. };
  283. }
  284. // RoleDelete deletes a specified role.
  285. rpc RoleDelete(AuthRoleDeleteRequest) returns (AuthRoleDeleteResponse) {
  286. option (google.api.http) = {
  287. post: "/v3alpha/auth/role/delete"
  288. body: "*"
  289. };
  290. }
  291. // RoleGrantPermission grants a permission of a specified key or range to a specified role.
  292. rpc RoleGrantPermission(AuthRoleGrantPermissionRequest) returns (AuthRoleGrantPermissionResponse) {
  293. option (google.api.http) = {
  294. post: "/v3alpha/auth/role/grant"
  295. body: "*"
  296. };
  297. }
  298. // RoleRevokePermission revokes a key or range permission of a specified role.
  299. rpc RoleRevokePermission(AuthRoleRevokePermissionRequest) returns (AuthRoleRevokePermissionResponse) {
  300. option (google.api.http) = {
  301. post: "/v3alpha/auth/role/revoke"
  302. body: "*"
  303. };
  304. }
  305. }
  306. message ResponseHeader {
  307. // cluster_id is the ID of the cluster which sent the response.
  308. uint64 cluster_id = 1;
  309. // member_id is the ID of the member which sent the response.
  310. uint64 member_id = 2;
  311. // revision is the key-value store revision when the request was applied.
  312. int64 revision = 3;
  313. // raft_term is the raft term when the request was applied.
  314. uint64 raft_term = 4;
  315. }
  316. message RangeRequest {
  317. enum SortOrder {
  318. NONE = 0; // default, no sorting
  319. ASCEND = 1; // lowest target value first
  320. DESCEND = 2; // highest target value first
  321. }
  322. enum SortTarget {
  323. KEY = 0;
  324. VERSION = 1;
  325. CREATE = 2;
  326. MOD = 3;
  327. VALUE = 4;
  328. }
  329. // key is the first key for the range. If range_end is not given, the request only looks up key.
  330. bytes key = 1;
  331. // range_end is the upper bound on the requested range [key, range_end).
  332. // If range_end is '\0', the range is all keys >= key.
  333. // If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"),
  334. // then the range request gets all keys prefixed with key.
  335. // If both key and range_end are '\0', then the range request returns all keys.
  336. bytes range_end = 2;
  337. // limit is a limit on the number of keys returned for the request. When limit is set to 0,
  338. // it is treated as no limit.
  339. int64 limit = 3;
  340. // revision is the point-in-time of the key-value store to use for the range.
  341. // If revision is less or equal to zero, the range is over the newest key-value store.
  342. // If the revision has been compacted, ErrCompacted is returned as a response.
  343. int64 revision = 4;
  344. // sort_order is the order for returned sorted results.
  345. SortOrder sort_order = 5;
  346. // sort_target is the key-value field to use for sorting.
  347. SortTarget sort_target = 6;
  348. // serializable sets the range request to use serializable member-local reads.
  349. // Range requests are linearizable by default; linearizable requests have higher
  350. // latency and lower throughput than serializable requests but reflect the current
  351. // consensus of the cluster. For better performance, in exchange for possible stale reads,
  352. // a serializable range request is served locally without needing to reach consensus
  353. // with other nodes in the cluster.
  354. bool serializable = 7;
  355. // keys_only when set returns only the keys and not the values.
  356. bool keys_only = 8;
  357. // count_only when set returns only the count of the keys in the range.
  358. bool count_only = 9;
  359. // min_mod_revision is the lower bound for returned key mod revisions; all keys with
  360. // lesser mod revisions will be filtered away.
  361. int64 min_mod_revision = 10;
  362. // max_mod_revision is the upper bound for returned key mod revisions; all keys with
  363. // greater mod revisions will be filtered away.
  364. int64 max_mod_revision = 11;
  365. // min_create_revision is the lower bound for returned key create revisions; all keys with
  366. // lesser create trevisions will be filtered away.
  367. int64 min_create_revision = 12;
  368. // max_create_revision is the upper bound for returned key create revisions; all keys with
  369. // greater create revisions will be filtered away.
  370. int64 max_create_revision = 13;
  371. }
  372. message RangeResponse {
  373. ResponseHeader header = 1;
  374. // kvs is the list of key-value pairs matched by the range request.
  375. // kvs is empty when count is requested.
  376. repeated mvccpb.KeyValue kvs = 2;
  377. // more indicates if there are more keys to return in the requested range.
  378. bool more = 3;
  379. // count is set to the number of keys within the range when requested.
  380. int64 count = 4;
  381. }
  382. message PutRequest {
  383. // key is the key, in bytes, to put into the key-value store.
  384. bytes key = 1;
  385. // value is the value, in bytes, to associate with the key in the key-value store.
  386. bytes value = 2;
  387. // lease is the lease ID to associate with the key in the key-value store. A lease
  388. // value of 0 indicates no lease.
  389. int64 lease = 3;
  390. // If prev_kv is set, etcd gets the previous key-value pair before changing it.
  391. // The previous key-value pair will be returned in the put response.
  392. bool prev_kv = 4;
  393. // If ignore_value is set, etcd updates the key using its current value.
  394. // Returns an error if the key does not exist.
  395. bool ignore_value = 5;
  396. // If ignore_lease is set, etcd updates the key using its current lease.
  397. // Returns an error if the key does not exist.
  398. bool ignore_lease = 6;
  399. }
  400. message PutResponse {
  401. ResponseHeader header = 1;
  402. // if prev_kv is set in the request, the previous key-value pair will be returned.
  403. mvccpb.KeyValue prev_kv = 2;
  404. }
  405. message DeleteRangeRequest {
  406. // key is the first key to delete in the range.
  407. bytes key = 1;
  408. // range_end is the key following the last key to delete for the range [key, range_end).
  409. // If range_end is not given, the range is defined to contain only the key argument.
  410. // If range_end is one bit larger than the given key, then the range is all the keys
  411. // with the prefix (the given key).
  412. // If range_end is '\0', the range is all keys greater than or equal to the key argument.
  413. bytes range_end = 2;
  414. // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
  415. // The previous key-value pairs will be returned in the delete response.
  416. bool prev_kv = 3;
  417. }
  418. message DeleteRangeResponse {
  419. ResponseHeader header = 1;
  420. // deleted is the number of keys deleted by the delete range request.
  421. int64 deleted = 2;
  422. // if prev_kv is set in the request, the previous key-value pairs will be returned.
  423. repeated mvccpb.KeyValue prev_kvs = 3;
  424. }
  425. message RequestOp {
  426. // request is a union of request types accepted by a transaction.
  427. oneof request {
  428. RangeRequest request_range = 1;
  429. PutRequest request_put = 2;
  430. DeleteRangeRequest request_delete_range = 3;
  431. TxnRequest request_txn = 4;
  432. }
  433. }
  434. message ResponseOp {
  435. // response is a union of response types returned by a transaction.
  436. oneof response {
  437. RangeResponse response_range = 1;
  438. PutResponse response_put = 2;
  439. DeleteRangeResponse response_delete_range = 3;
  440. TxnResponse response_txn = 4;
  441. }
  442. }
  443. message Compare {
  444. enum CompareResult {
  445. EQUAL = 0;
  446. GREATER = 1;
  447. LESS = 2;
  448. NOT_EQUAL = 3;
  449. }
  450. enum CompareTarget {
  451. VERSION = 0;
  452. CREATE = 1;
  453. MOD = 2;
  454. VALUE= 3;
  455. LEASE = 4;
  456. }
  457. // result is logical comparison operation for this comparison.
  458. CompareResult result = 1;
  459. // target is the key-value field to inspect for the comparison.
  460. CompareTarget target = 2;
  461. // key is the subject key for the comparison operation.
  462. bytes key = 3;
  463. oneof target_union {
  464. // version is the version of the given key
  465. int64 version = 4;
  466. // create_revision is the creation revision of the given key
  467. int64 create_revision = 5;
  468. // mod_revision is the last modified revision of the given key.
  469. int64 mod_revision = 6;
  470. // value is the value of the given key, in bytes.
  471. bytes value = 7;
  472. // lease is the lease id of the given key.
  473. int64 lease = 8;
  474. // leave room for more target_union field tags, jump to 64
  475. }
  476. // range_end compares the given target to all keys in the range [key, range_end).
  477. // See RangeRequest for more details on key ranges.
  478. bytes range_end = 64;
  479. // TODO: fill out with most of the rest of RangeRequest fields when needed.
  480. }
  481. // From google paxosdb paper:
  482. // Our implementation hinges around a powerful primitive which we call MultiOp. All other database
  483. // operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
  484. // and consists of three components:
  485. // 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
  486. // for the absence or presence of a value, or compare with a given value. Two different tests in the guard
  487. // may apply to the same or different entries in the database. All tests in the guard are applied and
  488. // MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
  489. // it executes f op (see item 3 below).
  490. // 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
  491. // lookup operation, and applies to a single database entry. Two different operations in the list may apply
  492. // to the same or different entries in the database. These operations are executed
  493. // if guard evaluates to
  494. // true.
  495. // 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
  496. message TxnRequest {
  497. // compare is a list of predicates representing a conjunction of terms.
  498. // If the comparisons succeed, then the success requests will be processed in order,
  499. // and the response will contain their respective responses in order.
  500. // If the comparisons fail, then the failure requests will be processed in order,
  501. // and the response will contain their respective responses in order.
  502. repeated Compare compare = 1;
  503. // success is a list of requests which will be applied when compare evaluates to true.
  504. repeated RequestOp success = 2;
  505. // failure is a list of requests which will be applied when compare evaluates to false.
  506. repeated RequestOp failure = 3;
  507. }
  508. message TxnResponse {
  509. ResponseHeader header = 1;
  510. // succeeded is set to true if the compare evaluated to true or false otherwise.
  511. bool succeeded = 2;
  512. // responses is a list of responses corresponding to the results from applying
  513. // success if succeeded is true or failure if succeeded is false.
  514. repeated ResponseOp responses = 3;
  515. }
  516. // CompactionRequest compacts the key-value store up to a given revision. All superseded keys
  517. // with a revision less than the compaction revision will be removed.
  518. message CompactionRequest {
  519. // revision is the key-value store revision for the compaction operation.
  520. int64 revision = 1;
  521. // physical is set so the RPC will wait until the compaction is physically
  522. // applied to the local database such that compacted entries are totally
  523. // removed from the backend database.
  524. bool physical = 2;
  525. }
  526. message CompactionResponse {
  527. ResponseHeader header = 1;
  528. }
  529. message HashRequest {
  530. }
  531. message HashKVRequest {
  532. // revision is the key-value store revision for the hash operation.
  533. int64 revision = 1;
  534. }
  535. message HashKVResponse {
  536. ResponseHeader header = 1;
  537. // hash is the hash value computed from the responding member's MVCC keys up to a given revision.
  538. uint32 hash = 2;
  539. // compact_revision is the compacted revision of key-value store when hash begins.
  540. int64 compact_revision = 3;
  541. }
  542. message HashResponse {
  543. ResponseHeader header = 1;
  544. // hash is the hash value computed from the responding member's KV's backend.
  545. uint32 hash = 2;
  546. }
  547. message SnapshotRequest {
  548. }
  549. message SnapshotResponse {
  550. // header has the current key-value store information. The first header in the snapshot
  551. // stream indicates the point in time of the snapshot.
  552. ResponseHeader header = 1;
  553. // remaining_bytes is the number of blob bytes to be sent after this message
  554. uint64 remaining_bytes = 2;
  555. // blob contains the next chunk of the snapshot in the snapshot stream.
  556. bytes blob = 3;
  557. }
  558. message WatchRequest {
  559. // request_union is a request to either create a new watcher or cancel an existing watcher.
  560. oneof request_union {
  561. WatchCreateRequest create_request = 1;
  562. WatchCancelRequest cancel_request = 2;
  563. }
  564. }
  565. message WatchCreateRequest {
  566. // key is the key to register for watching.
  567. bytes key = 1;
  568. // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
  569. // only the key argument is watched. If range_end is equal to '\0', all keys greater than
  570. // or equal to the key argument are watched.
  571. // If the range_end is one bit larger than the given key,
  572. // then all keys with the prefix (the given key) will be watched.
  573. bytes range_end = 2;
  574. // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
  575. int64 start_revision = 3;
  576. // progress_notify is set so that the etcd server will periodically send a WatchResponse with
  577. // no events to the new watcher if there are no recent events. It is useful when clients
  578. // wish to recover a disconnected watcher starting from a recent known revision.
  579. // The etcd server may decide how often it will send notifications based on current load.
  580. bool progress_notify = 4;
  581. enum FilterType {
  582. // filter out put event.
  583. NOPUT = 0;
  584. // filter out delete event.
  585. NODELETE = 1;
  586. }
  587. // filters filter the events at server side before it sends back to the watcher.
  588. repeated FilterType filters = 5;
  589. // If prev_kv is set, created watcher gets the previous KV before the event happens.
  590. // If the previous KV is already compacted, nothing will be returned.
  591. bool prev_kv = 6;
  592. }
  593. message WatchCancelRequest {
  594. // watch_id is the watcher id to cancel so that no more events are transmitted.
  595. int64 watch_id = 1;
  596. }
  597. message WatchResponse {
  598. ResponseHeader header = 1;
  599. // watch_id is the ID of the watcher that corresponds to the response.
  600. int64 watch_id = 2;
  601. // created is set to true if the response is for a create watch request.
  602. // The client should record the watch_id and expect to receive events for
  603. // the created watcher from the same stream.
  604. // All events sent to the created watcher will attach with the same watch_id.
  605. bool created = 3;
  606. // canceled is set to true if the response is for a cancel watch request.
  607. // No further events will be sent to the canceled watcher.
  608. bool canceled = 4;
  609. // compact_revision is set to the minimum index if a watcher tries to watch
  610. // at a compacted index.
  611. //
  612. // This happens when creating a watcher at a compacted revision or the watcher cannot
  613. // catch up with the progress of the key-value store.
  614. //
  615. // The client should treat the watcher as canceled and should not try to create any
  616. // watcher with the same start_revision again.
  617. int64 compact_revision = 5;
  618. // cancel_reason indicates the reason for canceling the watcher.
  619. string cancel_reason = 6;
  620. repeated mvccpb.Event events = 11;
  621. }
  622. message LeaseGrantRequest {
  623. // TTL is the advisory time-to-live in seconds.
  624. int64 TTL = 1;
  625. // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
  626. int64 ID = 2;
  627. }
  628. message LeaseGrantResponse {
  629. ResponseHeader header = 1;
  630. // ID is the lease ID for the granted lease.
  631. int64 ID = 2;
  632. // TTL is the server chosen lease time-to-live in seconds.
  633. int64 TTL = 3;
  634. string error = 4;
  635. }
  636. message LeaseRevokeRequest {
  637. // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
  638. int64 ID = 1;
  639. }
  640. message LeaseRevokeResponse {
  641. ResponseHeader header = 1;
  642. }
  643. message LeaseKeepAliveRequest {
  644. // ID is the lease ID for the lease to keep alive.
  645. int64 ID = 1;
  646. }
  647. message LeaseKeepAliveResponse {
  648. ResponseHeader header = 1;
  649. // ID is the lease ID from the keep alive request.
  650. int64 ID = 2;
  651. // TTL is the new time-to-live for the lease.
  652. int64 TTL = 3;
  653. }
  654. message LeaseTimeToLiveRequest {
  655. // ID is the lease ID for the lease.
  656. int64 ID = 1;
  657. // keys is true to query all the keys attached to this lease.
  658. bool keys = 2;
  659. }
  660. message LeaseTimeToLiveResponse {
  661. ResponseHeader header = 1;
  662. // ID is the lease ID from the keep alive request.
  663. int64 ID = 2;
  664. // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
  665. int64 TTL = 3;
  666. // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
  667. int64 grantedTTL = 4;
  668. // Keys is the list of keys attached to this lease.
  669. repeated bytes keys = 5;
  670. }
  671. message LeaseLeasesRequest {
  672. }
  673. message LeaseStatus {
  674. int64 ID = 1;
  675. // TODO: int64 TTL = 2;
  676. }
  677. message LeaseLeasesResponse {
  678. ResponseHeader header = 1;
  679. repeated LeaseStatus leases = 2;
  680. }
  681. message Member {
  682. // ID is the member ID for this member.
  683. uint64 ID = 1;
  684. // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
  685. string name = 2;
  686. // peerURLs is the list of URLs the member exposes to the cluster for communication.
  687. repeated string peerURLs = 3;
  688. // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
  689. repeated string clientURLs = 4;
  690. }
  691. message MemberAddRequest {
  692. // peerURLs is the list of URLs the added member will use to communicate with the cluster.
  693. repeated string peerURLs = 1;
  694. }
  695. message MemberAddResponse {
  696. ResponseHeader header = 1;
  697. // member is the member information for the added member.
  698. Member member = 2;
  699. // members is a list of all members after adding the new member.
  700. repeated Member members = 3;
  701. }
  702. message MemberRemoveRequest {
  703. // ID is the member ID of the member to remove.
  704. uint64 ID = 1;
  705. }
  706. message MemberRemoveResponse {
  707. ResponseHeader header = 1;
  708. // members is a list of all members after removing the member.
  709. repeated Member members = 2;
  710. }
  711. message MemberUpdateRequest {
  712. // ID is the member ID of the member to update.
  713. uint64 ID = 1;
  714. // peerURLs is the new list of URLs the member will use to communicate with the cluster.
  715. repeated string peerURLs = 2;
  716. }
  717. message MemberUpdateResponse{
  718. ResponseHeader header = 1;
  719. // members is a list of all members after updating the member.
  720. repeated Member members = 2;
  721. }
  722. message MemberListRequest {
  723. }
  724. message MemberListResponse {
  725. ResponseHeader header = 1;
  726. // members is a list of all members associated with the cluster.
  727. repeated Member members = 2;
  728. }
  729. message DefragmentRequest {
  730. }
  731. message DefragmentResponse {
  732. ResponseHeader header = 1;
  733. }
  734. message MoveLeaderRequest {
  735. // targetID is the node ID for the new leader.
  736. uint64 targetID = 1;
  737. }
  738. message MoveLeaderResponse {
  739. ResponseHeader header = 1;
  740. }
  741. enum AlarmType {
  742. NONE = 0; // default, used to query if any alarm is active
  743. NOSPACE = 1; // space quota is exhausted
  744. CORRUPT = 2; // kv store corruption detected
  745. }
  746. message AlarmRequest {
  747. enum AlarmAction {
  748. GET = 0;
  749. ACTIVATE = 1;
  750. DEACTIVATE = 2;
  751. }
  752. // action is the kind of alarm request to issue. The action
  753. // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
  754. // raised alarm.
  755. AlarmAction action = 1;
  756. // memberID is the ID of the member associated with the alarm. If memberID is 0, the
  757. // alarm request covers all members.
  758. uint64 memberID = 2;
  759. // alarm is the type of alarm to consider for this request.
  760. AlarmType alarm = 3;
  761. }
  762. message AlarmMember {
  763. // memberID is the ID of the member associated with the raised alarm.
  764. uint64 memberID = 1;
  765. // alarm is the type of alarm which has been raised.
  766. AlarmType alarm = 2;
  767. }
  768. message AlarmResponse {
  769. ResponseHeader header = 1;
  770. // alarms is a list of alarms associated with the alarm request.
  771. repeated AlarmMember alarms = 2;
  772. }
  773. message StatusRequest {
  774. }
  775. message StatusResponse {
  776. ResponseHeader header = 1;
  777. // version is the cluster protocol version used by the responding member.
  778. string version = 2;
  779. // dbSize is the size of the backend database, in bytes, of the responding member.
  780. int64 dbSize = 3;
  781. // leader is the member ID which the responding member believes is the current leader.
  782. uint64 leader = 4;
  783. // raftIndex is the current raft index of the responding member.
  784. uint64 raftIndex = 5;
  785. // raftTerm is the current raft term of the responding member.
  786. uint64 raftTerm = 6;
  787. }
  788. message AuthEnableRequest {
  789. }
  790. message AuthDisableRequest {
  791. }
  792. message AuthenticateRequest {
  793. string name = 1;
  794. string password = 2;
  795. }
  796. message AuthUserAddRequest {
  797. string name = 1;
  798. string password = 2;
  799. }
  800. message AuthUserGetRequest {
  801. string name = 1;
  802. }
  803. message AuthUserDeleteRequest {
  804. // name is the name of the user to delete.
  805. string name = 1;
  806. }
  807. message AuthUserChangePasswordRequest {
  808. // name is the name of the user whose password is being changed.
  809. string name = 1;
  810. // password is the new password for the user.
  811. string password = 2;
  812. }
  813. message AuthUserGrantRoleRequest {
  814. // user is the name of the user which should be granted a given role.
  815. string user = 1;
  816. // role is the name of the role to grant to the user.
  817. string role = 2;
  818. }
  819. message AuthUserRevokeRoleRequest {
  820. string name = 1;
  821. string role = 2;
  822. }
  823. message AuthRoleAddRequest {
  824. // name is the name of the role to add to the authentication system.
  825. string name = 1;
  826. }
  827. message AuthRoleGetRequest {
  828. string role = 1;
  829. }
  830. message AuthUserListRequest {
  831. }
  832. message AuthRoleListRequest {
  833. }
  834. message AuthRoleDeleteRequest {
  835. string role = 1;
  836. }
  837. message AuthRoleGrantPermissionRequest {
  838. // name is the name of the role which will be granted the permission.
  839. string name = 1;
  840. // perm is the permission to grant to the role.
  841. authpb.Permission perm = 2;
  842. }
  843. message AuthRoleRevokePermissionRequest {
  844. string role = 1;
  845. string key = 2;
  846. string range_end = 3;
  847. }
  848. message AuthEnableResponse {
  849. ResponseHeader header = 1;
  850. }
  851. message AuthDisableResponse {
  852. ResponseHeader header = 1;
  853. }
  854. message AuthenticateResponse {
  855. ResponseHeader header = 1;
  856. // token is an authorized token that can be used in succeeding RPCs
  857. string token = 2;
  858. }
  859. message AuthUserAddResponse {
  860. ResponseHeader header = 1;
  861. }
  862. message AuthUserGetResponse {
  863. ResponseHeader header = 1;
  864. repeated string roles = 2;
  865. }
  866. message AuthUserDeleteResponse {
  867. ResponseHeader header = 1;
  868. }
  869. message AuthUserChangePasswordResponse {
  870. ResponseHeader header = 1;
  871. }
  872. message AuthUserGrantRoleResponse {
  873. ResponseHeader header = 1;
  874. }
  875. message AuthUserRevokeRoleResponse {
  876. ResponseHeader header = 1;
  877. }
  878. message AuthRoleAddResponse {
  879. ResponseHeader header = 1;
  880. }
  881. message AuthRoleGetResponse {
  882. ResponseHeader header = 1;
  883. repeated authpb.Permission perm = 2;
  884. }
  885. message AuthRoleListResponse {
  886. ResponseHeader header = 1;
  887. repeated string roles = 2;
  888. }
  889. message AuthUserListResponse {
  890. ResponseHeader header = 1;
  891. repeated string users = 2;
  892. }
  893. message AuthRoleDeleteResponse {
  894. ResponseHeader header = 1;
  895. }
  896. message AuthRoleGrantPermissionResponse {
  897. ResponseHeader header = 1;
  898. }
  899. message AuthRoleRevokePermissionResponse {
  900. ResponseHeader header = 1;
  901. }