rpc.proto 35 KB

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