rpc.proto 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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. }
  615. message WatchCancelRequest {
  616. // watch_id is the watcher id to cancel so that no more events are transmitted.
  617. int64 watch_id = 1;
  618. }
  619. message WatchResponse {
  620. ResponseHeader header = 1;
  621. // watch_id is the ID of the watcher that corresponds to the response.
  622. int64 watch_id = 2;
  623. // created is set to true if the response is for a create watch request.
  624. // The client should record the watch_id and expect to receive events for
  625. // the created watcher from the same stream.
  626. // All events sent to the created watcher will attach with the same watch_id.
  627. bool created = 3;
  628. // canceled is set to true if the response is for a cancel watch request.
  629. // No further events will be sent to the canceled watcher.
  630. bool canceled = 4;
  631. // compact_revision is set to the minimum index if a watcher tries to watch
  632. // at a compacted index.
  633. //
  634. // This happens when creating a watcher at a compacted revision or the watcher cannot
  635. // catch up with the progress of the key-value store.
  636. //
  637. // The client should treat the watcher as canceled and should not try to create any
  638. // watcher with the same start_revision again.
  639. int64 compact_revision = 5;
  640. // cancel_reason indicates the reason for canceling the watcher.
  641. string cancel_reason = 6;
  642. repeated mvccpb.Event events = 11;
  643. }
  644. message LeaseGrantRequest {
  645. // TTL is the advisory time-to-live in seconds. Expired lease will return -1.
  646. int64 TTL = 1;
  647. // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
  648. int64 ID = 2;
  649. }
  650. message LeaseGrantResponse {
  651. ResponseHeader header = 1;
  652. // ID is the lease ID for the granted lease.
  653. int64 ID = 2;
  654. // TTL is the server chosen lease time-to-live in seconds.
  655. int64 TTL = 3;
  656. string error = 4;
  657. }
  658. message LeaseRevokeRequest {
  659. // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
  660. int64 ID = 1;
  661. }
  662. message LeaseRevokeResponse {
  663. ResponseHeader header = 1;
  664. }
  665. message LeaseKeepAliveRequest {
  666. // ID is the lease ID for the lease to keep alive.
  667. int64 ID = 1;
  668. }
  669. message LeaseKeepAliveResponse {
  670. ResponseHeader header = 1;
  671. // ID is the lease ID from the keep alive request.
  672. int64 ID = 2;
  673. // TTL is the new time-to-live for the lease.
  674. int64 TTL = 3;
  675. }
  676. message LeaseTimeToLiveRequest {
  677. // ID is the lease ID for the lease.
  678. int64 ID = 1;
  679. // keys is true to query all the keys attached to this lease.
  680. bool keys = 2;
  681. }
  682. message LeaseTimeToLiveResponse {
  683. ResponseHeader header = 1;
  684. // ID is the lease ID from the keep alive request.
  685. int64 ID = 2;
  686. // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
  687. int64 TTL = 3;
  688. // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
  689. int64 grantedTTL = 4;
  690. // Keys is the list of keys attached to this lease.
  691. repeated bytes keys = 5;
  692. }
  693. message LeaseLeasesRequest {
  694. }
  695. message LeaseStatus {
  696. int64 ID = 1;
  697. // TODO: int64 TTL = 2;
  698. }
  699. message LeaseLeasesResponse {
  700. ResponseHeader header = 1;
  701. repeated LeaseStatus leases = 2;
  702. }
  703. message Member {
  704. // ID is the member ID for this member.
  705. uint64 ID = 1;
  706. // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
  707. string name = 2;
  708. // peerURLs is the list of URLs the member exposes to the cluster for communication.
  709. repeated string peerURLs = 3;
  710. // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
  711. repeated string clientURLs = 4;
  712. }
  713. message MemberAddRequest {
  714. // peerURLs is the list of URLs the added member will use to communicate with the cluster.
  715. repeated string peerURLs = 1;
  716. }
  717. message MemberAddResponse {
  718. ResponseHeader header = 1;
  719. // member is the member information for the added member.
  720. Member member = 2;
  721. // members is a list of all members after adding the new member.
  722. repeated Member members = 3;
  723. }
  724. message MemberRemoveRequest {
  725. // ID is the member ID of the member to remove.
  726. uint64 ID = 1;
  727. }
  728. message MemberRemoveResponse {
  729. ResponseHeader header = 1;
  730. // members is a list of all members after removing the member.
  731. repeated Member members = 2;
  732. }
  733. message MemberUpdateRequest {
  734. // ID is the member ID of the member to update.
  735. uint64 ID = 1;
  736. // peerURLs is the new list of URLs the member will use to communicate with the cluster.
  737. repeated string peerURLs = 2;
  738. }
  739. message MemberUpdateResponse{
  740. ResponseHeader header = 1;
  741. // members is a list of all members after updating the member.
  742. repeated Member members = 2;
  743. }
  744. message MemberListRequest {
  745. }
  746. message MemberListResponse {
  747. ResponseHeader header = 1;
  748. // members is a list of all members associated with the cluster.
  749. repeated Member members = 2;
  750. }
  751. message DefragmentRequest {
  752. }
  753. message DefragmentResponse {
  754. ResponseHeader header = 1;
  755. }
  756. message MoveLeaderRequest {
  757. // targetID is the node ID for the new leader.
  758. uint64 targetID = 1;
  759. }
  760. message MoveLeaderResponse {
  761. ResponseHeader header = 1;
  762. }
  763. enum AlarmType {
  764. NONE = 0; // default, used to query if any alarm is active
  765. NOSPACE = 1; // space quota is exhausted
  766. CORRUPT = 2; // kv store corruption detected
  767. }
  768. message AlarmRequest {
  769. enum AlarmAction {
  770. GET = 0;
  771. ACTIVATE = 1;
  772. DEACTIVATE = 2;
  773. }
  774. // action is the kind of alarm request to issue. The action
  775. // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
  776. // raised alarm.
  777. AlarmAction action = 1;
  778. // memberID is the ID of the member associated with the alarm. If memberID is 0, the
  779. // alarm request covers all members.
  780. uint64 memberID = 2;
  781. // alarm is the type of alarm to consider for this request.
  782. AlarmType alarm = 3;
  783. }
  784. message AlarmMember {
  785. // memberID is the ID of the member associated with the raised alarm.
  786. uint64 memberID = 1;
  787. // alarm is the type of alarm which has been raised.
  788. AlarmType alarm = 2;
  789. }
  790. message AlarmResponse {
  791. ResponseHeader header = 1;
  792. // alarms is a list of alarms associated with the alarm request.
  793. repeated AlarmMember alarms = 2;
  794. }
  795. message StatusRequest {
  796. }
  797. message StatusResponse {
  798. ResponseHeader header = 1;
  799. // version is the cluster protocol version used by the responding member.
  800. string version = 2;
  801. // dbSize is the size of the backend database physically allocated, in bytes, of the responding member.
  802. int64 dbSize = 3;
  803. // leader is the member ID which the responding member believes is the current leader.
  804. uint64 leader = 4;
  805. // raftIndex is the current raft committed index of the responding member.
  806. uint64 raftIndex = 5;
  807. // raftTerm is the current raft term of the responding member.
  808. uint64 raftTerm = 6;
  809. // raftAppliedIndex is the current raft applied index of the responding member.
  810. uint64 raftAppliedIndex = 7;
  811. // errors contains alarm/health information and status.
  812. repeated string errors = 8;
  813. // dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member.
  814. int64 dbSizeInUse = 9;
  815. }
  816. message AuthEnableRequest {
  817. }
  818. message AuthDisableRequest {
  819. }
  820. message AuthenticateRequest {
  821. string name = 1;
  822. string password = 2;
  823. }
  824. message AuthUserAddRequest {
  825. string name = 1;
  826. string password = 2;
  827. }
  828. message AuthUserGetRequest {
  829. string name = 1;
  830. }
  831. message AuthUserDeleteRequest {
  832. // name is the name of the user to delete.
  833. string name = 1;
  834. }
  835. message AuthUserChangePasswordRequest {
  836. // name is the name of the user whose password is being changed.
  837. string name = 1;
  838. // password is the new password for the user.
  839. string password = 2;
  840. }
  841. message AuthUserGrantRoleRequest {
  842. // user is the name of the user which should be granted a given role.
  843. string user = 1;
  844. // role is the name of the role to grant to the user.
  845. string role = 2;
  846. }
  847. message AuthUserRevokeRoleRequest {
  848. string name = 1;
  849. string role = 2;
  850. }
  851. message AuthRoleAddRequest {
  852. // name is the name of the role to add to the authentication system.
  853. string name = 1;
  854. }
  855. message AuthRoleGetRequest {
  856. string role = 1;
  857. }
  858. message AuthUserListRequest {
  859. }
  860. message AuthRoleListRequest {
  861. }
  862. message AuthRoleDeleteRequest {
  863. string role = 1;
  864. }
  865. message AuthRoleGrantPermissionRequest {
  866. // name is the name of the role which will be granted the permission.
  867. string name = 1;
  868. // perm is the permission to grant to the role.
  869. authpb.Permission perm = 2;
  870. }
  871. message AuthRoleRevokePermissionRequest {
  872. string role = 1;
  873. bytes key = 2;
  874. bytes range_end = 3;
  875. }
  876. message AuthEnableResponse {
  877. ResponseHeader header = 1;
  878. }
  879. message AuthDisableResponse {
  880. ResponseHeader header = 1;
  881. }
  882. message AuthenticateResponse {
  883. ResponseHeader header = 1;
  884. // token is an authorized token that can be used in succeeding RPCs
  885. string token = 2;
  886. }
  887. message AuthUserAddResponse {
  888. ResponseHeader header = 1;
  889. }
  890. message AuthUserGetResponse {
  891. ResponseHeader header = 1;
  892. repeated string roles = 2;
  893. }
  894. message AuthUserDeleteResponse {
  895. ResponseHeader header = 1;
  896. }
  897. message AuthUserChangePasswordResponse {
  898. ResponseHeader header = 1;
  899. }
  900. message AuthUserGrantRoleResponse {
  901. ResponseHeader header = 1;
  902. }
  903. message AuthUserRevokeRoleResponse {
  904. ResponseHeader header = 1;
  905. }
  906. message AuthRoleAddResponse {
  907. ResponseHeader header = 1;
  908. }
  909. message AuthRoleGetResponse {
  910. ResponseHeader header = 1;
  911. repeated authpb.Permission perm = 2;
  912. }
  913. message AuthRoleListResponse {
  914. ResponseHeader header = 1;
  915. repeated string roles = 2;
  916. }
  917. message AuthUserListResponse {
  918. ResponseHeader header = 1;
  919. repeated string users = 2;
  920. }
  921. message AuthRoleDeleteResponse {
  922. ResponseHeader header = 1;
  923. }
  924. message AuthRoleGrantPermissionResponse {
  925. ResponseHeader header = 1;
  926. }
  927. message AuthRoleRevokePermissionResponse {
  928. ResponseHeader header = 1;
  929. }