rpc.proto 31 KB

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