rpc.proto 34 KB

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