rpc.proto 31 KB

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