rpc.proto 36 KB

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