rpc.proto 33 KB

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