rpc.proto 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  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. LEASE = 4;
  450. }
  451. // result is logical comparison operation for this comparison.
  452. CompareResult result = 1;
  453. // target is the key-value field to inspect for the comparison.
  454. CompareTarget target = 2;
  455. // key is the subject key for the comparison operation.
  456. bytes key = 3;
  457. oneof target_union {
  458. // version is the version of the given key
  459. int64 version = 4;
  460. // create_revision is the creation revision of the given key
  461. int64 create_revision = 5;
  462. // mod_revision is the last modified revision of the given key.
  463. int64 mod_revision = 6;
  464. // value is the value of the given key, in bytes.
  465. bytes value = 7;
  466. // lease is the lease id of the given key.
  467. int64 lease = 8;
  468. // leave room for more target_union field tags, jump to 64
  469. }
  470. // range_end compares the given target to all keys in the range [key, range_end).
  471. // See RangeRequest for more details on key ranges.
  472. bytes range_end = 64;
  473. // TODO: fill out with most of the rest of RangeRequest fields when needed.
  474. }
  475. // From google paxosdb paper:
  476. // Our implementation hinges around a powerful primitive which we call MultiOp. All other database
  477. // operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
  478. // and consists of three components:
  479. // 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
  480. // for the absence or presence of a value, or compare with a given value. Two different tests in the guard
  481. // may apply to the same or different entries in the database. All tests in the guard are applied and
  482. // MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
  483. // it executes f op (see item 3 below).
  484. // 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
  485. // lookup operation, and applies to a single database entry. Two different operations in the list may apply
  486. // to the same or different entries in the database. These operations are executed
  487. // if guard evaluates to
  488. // true.
  489. // 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
  490. message TxnRequest {
  491. // compare is a list of predicates representing a conjunction of terms.
  492. // If the comparisons succeed, then the success requests will be processed in order,
  493. // and the response will contain their respective responses in order.
  494. // If the comparisons fail, then the failure requests will be processed in order,
  495. // and the response will contain their respective responses in order.
  496. repeated Compare compare = 1;
  497. // success is a list of requests which will be applied when compare evaluates to true.
  498. repeated RequestOp success = 2;
  499. // failure is a list of requests which will be applied when compare evaluates to false.
  500. repeated RequestOp failure = 3;
  501. }
  502. message TxnResponse {
  503. ResponseHeader header = 1;
  504. // succeeded is set to true if the compare evaluated to true or false otherwise.
  505. bool succeeded = 2;
  506. // responses is a list of responses corresponding to the results from applying
  507. // success if succeeded is true or failure if succeeded is false.
  508. repeated ResponseOp responses = 3;
  509. }
  510. // CompactionRequest compacts the key-value store up to a given revision. All superseded keys
  511. // with a revision less than the compaction revision will be removed.
  512. message CompactionRequest {
  513. // revision is the key-value store revision for the compaction operation.
  514. int64 revision = 1;
  515. // physical is set so the RPC will wait until the compaction is physically
  516. // applied to the local database such that compacted entries are totally
  517. // removed from the backend database.
  518. bool physical = 2;
  519. }
  520. message CompactionResponse {
  521. ResponseHeader header = 1;
  522. }
  523. message HashRequest {
  524. }
  525. message HashKVRequest {
  526. // revision is the key-value store revision for the hash operation.
  527. int64 revision = 1;
  528. }
  529. message HashKVResponse {
  530. ResponseHeader header = 1;
  531. // hash is the hash value computed from the responding member's MVCC keys up to a given revision.
  532. uint32 hash = 2;
  533. // compact_revision is the compacted revision of key-value store when hash begins.
  534. int64 compact_revision = 3;
  535. }
  536. message HashResponse {
  537. ResponseHeader header = 1;
  538. // hash is the hash value computed from the responding member's KV's backend.
  539. uint32 hash = 2;
  540. }
  541. message SnapshotRequest {
  542. }
  543. message SnapshotResponse {
  544. // header has the current key-value store information. The first header in the snapshot
  545. // stream indicates the point in time of the snapshot.
  546. ResponseHeader header = 1;
  547. // remaining_bytes is the number of blob bytes to be sent after this message
  548. uint64 remaining_bytes = 2;
  549. // blob contains the next chunk of the snapshot in the snapshot stream.
  550. bytes blob = 3;
  551. }
  552. message WatchRequest {
  553. // request_union is a request to either create a new watcher or cancel an existing watcher.
  554. oneof request_union {
  555. WatchCreateRequest create_request = 1;
  556. WatchCancelRequest cancel_request = 2;
  557. }
  558. }
  559. message WatchCreateRequest {
  560. // key is the key to register for watching.
  561. bytes key = 1;
  562. // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
  563. // only the key argument is watched. If range_end is equal to '\0', all keys greater than
  564. // or equal to the key argument are watched.
  565. // If the range_end is one bit larger than the given key,
  566. // then all keys with the prefix (the given key) will be watched.
  567. bytes range_end = 2;
  568. // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
  569. int64 start_revision = 3;
  570. // progress_notify is set so that the etcd server will periodically send a WatchResponse with
  571. // no events to the new watcher if there are no recent events. It is useful when clients
  572. // wish to recover a disconnected watcher starting from a recent known revision.
  573. // The etcd server may decide how often it will send notifications based on current load.
  574. bool progress_notify = 4;
  575. enum FilterType {
  576. // filter out put event.
  577. NOPUT = 0;
  578. // filter out delete event.
  579. NODELETE = 1;
  580. }
  581. // filters filter the events at server side before it sends back to the watcher.
  582. repeated FilterType filters = 5;
  583. // If prev_kv is set, created watcher gets the previous KV before the event happens.
  584. // If the previous KV is already compacted, nothing will be returned.
  585. bool prev_kv = 6;
  586. }
  587. message WatchCancelRequest {
  588. // watch_id is the watcher id to cancel so that no more events are transmitted.
  589. int64 watch_id = 1;
  590. }
  591. message WatchResponse {
  592. ResponseHeader header = 1;
  593. // watch_id is the ID of the watcher that corresponds to the response.
  594. int64 watch_id = 2;
  595. // created is set to true if the response is for a create watch request.
  596. // The client should record the watch_id and expect to receive events for
  597. // the created watcher from the same stream.
  598. // All events sent to the created watcher will attach with the same watch_id.
  599. bool created = 3;
  600. // canceled is set to true if the response is for a cancel watch request.
  601. // No further events will be sent to the canceled watcher.
  602. bool canceled = 4;
  603. // compact_revision is set to the minimum index if a watcher tries to watch
  604. // at a compacted index.
  605. //
  606. // This happens when creating a watcher at a compacted revision or the watcher cannot
  607. // catch up with the progress of the key-value store.
  608. //
  609. // The client should treat the watcher as canceled and should not try to create any
  610. // watcher with the same start_revision again.
  611. int64 compact_revision = 5;
  612. // cancel_reason indicates the reason for canceling the watcher.
  613. string cancel_reason = 6;
  614. repeated mvccpb.Event events = 11;
  615. }
  616. message LeaseGrantRequest {
  617. // TTL is the advisory time-to-live in seconds.
  618. int64 TTL = 1;
  619. // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
  620. int64 ID = 2;
  621. }
  622. message LeaseGrantResponse {
  623. ResponseHeader header = 1;
  624. // ID is the lease ID for the granted lease.
  625. int64 ID = 2;
  626. // TTL is the server chosen lease time-to-live in seconds.
  627. int64 TTL = 3;
  628. string error = 4;
  629. }
  630. message LeaseRevokeRequest {
  631. // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
  632. int64 ID = 1;
  633. }
  634. message LeaseRevokeResponse {
  635. ResponseHeader header = 1;
  636. }
  637. message LeaseKeepAliveRequest {
  638. // ID is the lease ID for the lease to keep alive.
  639. int64 ID = 1;
  640. }
  641. message LeaseKeepAliveResponse {
  642. ResponseHeader header = 1;
  643. // ID is the lease ID from the keep alive request.
  644. int64 ID = 2;
  645. // TTL is the new time-to-live for the lease.
  646. int64 TTL = 3;
  647. }
  648. message LeaseTimeToLiveRequest {
  649. // ID is the lease ID for the lease.
  650. int64 ID = 1;
  651. // keys is true to query all the keys attached to this lease.
  652. bool keys = 2;
  653. }
  654. message LeaseTimeToLiveResponse {
  655. ResponseHeader header = 1;
  656. // ID is the lease ID from the keep alive request.
  657. int64 ID = 2;
  658. // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
  659. int64 TTL = 3;
  660. // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
  661. int64 grantedTTL = 4;
  662. // Keys is the list of keys attached to this lease.
  663. repeated bytes keys = 5;
  664. }
  665. message Member {
  666. // ID is the member ID for this member.
  667. uint64 ID = 1;
  668. // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
  669. string name = 2;
  670. // peerURLs is the list of URLs the member exposes to the cluster for communication.
  671. repeated string peerURLs = 3;
  672. // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
  673. repeated string clientURLs = 4;
  674. }
  675. message MemberAddRequest {
  676. // peerURLs is the list of URLs the added member will use to communicate with the cluster.
  677. repeated string peerURLs = 1;
  678. }
  679. message MemberAddResponse {
  680. ResponseHeader header = 1;
  681. // member is the member information for the added member.
  682. Member member = 2;
  683. // members is a list of all members after adding the new member.
  684. repeated Member members = 3;
  685. }
  686. message MemberRemoveRequest {
  687. // ID is the member ID of the member to remove.
  688. uint64 ID = 1;
  689. }
  690. message MemberRemoveResponse {
  691. ResponseHeader header = 1;
  692. // members is a list of all members after removing the member.
  693. repeated Member members = 2;
  694. }
  695. message MemberUpdateRequest {
  696. // ID is the member ID of the member to update.
  697. uint64 ID = 1;
  698. // peerURLs is the new list of URLs the member will use to communicate with the cluster.
  699. repeated string peerURLs = 2;
  700. }
  701. message MemberUpdateResponse{
  702. ResponseHeader header = 1;
  703. // members is a list of all members after updating the member.
  704. repeated Member members = 2;
  705. }
  706. message MemberListRequest {
  707. }
  708. message MemberListResponse {
  709. ResponseHeader header = 1;
  710. // members is a list of all members associated with the cluster.
  711. repeated Member members = 2;
  712. }
  713. message DefragmentRequest {
  714. }
  715. message DefragmentResponse {
  716. ResponseHeader header = 1;
  717. }
  718. message MoveLeaderRequest {
  719. // targetID is the node ID for the new leader.
  720. uint64 targetID = 1;
  721. }
  722. message MoveLeaderResponse {
  723. ResponseHeader header = 1;
  724. }
  725. enum AlarmType {
  726. NONE = 0; // default, used to query if any alarm is active
  727. NOSPACE = 1; // space quota is exhausted
  728. }
  729. message AlarmRequest {
  730. enum AlarmAction {
  731. GET = 0;
  732. ACTIVATE = 1;
  733. DEACTIVATE = 2;
  734. }
  735. // action is the kind of alarm request to issue. The action
  736. // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
  737. // raised alarm.
  738. AlarmAction action = 1;
  739. // memberID is the ID of the member associated with the alarm. If memberID is 0, the
  740. // alarm request covers all members.
  741. uint64 memberID = 2;
  742. // alarm is the type of alarm to consider for this request.
  743. AlarmType alarm = 3;
  744. }
  745. message AlarmMember {
  746. // memberID is the ID of the member associated with the raised alarm.
  747. uint64 memberID = 1;
  748. // alarm is the type of alarm which has been raised.
  749. AlarmType alarm = 2;
  750. }
  751. message AlarmResponse {
  752. ResponseHeader header = 1;
  753. // alarms is a list of alarms associated with the alarm request.
  754. repeated AlarmMember alarms = 2;
  755. }
  756. message StatusRequest {
  757. }
  758. message StatusResponse {
  759. ResponseHeader header = 1;
  760. // version is the cluster protocol version used by the responding member.
  761. string version = 2;
  762. // dbSize is the size of the backend database, in bytes, of the responding member.
  763. int64 dbSize = 3;
  764. // leader is the member ID which the responding member believes is the current leader.
  765. uint64 leader = 4;
  766. // raftIndex is the current raft index of the responding member.
  767. uint64 raftIndex = 5;
  768. // raftTerm is the current raft term of the responding member.
  769. uint64 raftTerm = 6;
  770. }
  771. message AuthEnableRequest {
  772. }
  773. message AuthDisableRequest {
  774. }
  775. message AuthenticateRequest {
  776. string name = 1;
  777. string password = 2;
  778. }
  779. message AuthUserAddRequest {
  780. string name = 1;
  781. string password = 2;
  782. }
  783. message AuthUserGetRequest {
  784. string name = 1;
  785. }
  786. message AuthUserDeleteRequest {
  787. // name is the name of the user to delete.
  788. string name = 1;
  789. }
  790. message AuthUserChangePasswordRequest {
  791. // name is the name of the user whose password is being changed.
  792. string name = 1;
  793. // password is the new password for the user.
  794. string password = 2;
  795. }
  796. message AuthUserGrantRoleRequest {
  797. // user is the name of the user which should be granted a given role.
  798. string user = 1;
  799. // role is the name of the role to grant to the user.
  800. string role = 2;
  801. }
  802. message AuthUserRevokeRoleRequest {
  803. string name = 1;
  804. string role = 2;
  805. }
  806. message AuthRoleAddRequest {
  807. // name is the name of the role to add to the authentication system.
  808. string name = 1;
  809. }
  810. message AuthRoleGetRequest {
  811. string role = 1;
  812. }
  813. message AuthUserListRequest {
  814. }
  815. message AuthRoleListRequest {
  816. }
  817. message AuthRoleDeleteRequest {
  818. string role = 1;
  819. }
  820. message AuthRoleGrantPermissionRequest {
  821. // name is the name of the role which will be granted the permission.
  822. string name = 1;
  823. // perm is the permission to grant to the role.
  824. authpb.Permission perm = 2;
  825. }
  826. message AuthRoleRevokePermissionRequest {
  827. string role = 1;
  828. string key = 2;
  829. string range_end = 3;
  830. }
  831. message AuthEnableResponse {
  832. ResponseHeader header = 1;
  833. }
  834. message AuthDisableResponse {
  835. ResponseHeader header = 1;
  836. }
  837. message AuthenticateResponse {
  838. ResponseHeader header = 1;
  839. // token is an authorized token that can be used in succeeding RPCs
  840. string token = 2;
  841. }
  842. message AuthUserAddResponse {
  843. ResponseHeader header = 1;
  844. }
  845. message AuthUserGetResponse {
  846. ResponseHeader header = 1;
  847. repeated string roles = 2;
  848. }
  849. message AuthUserDeleteResponse {
  850. ResponseHeader header = 1;
  851. }
  852. message AuthUserChangePasswordResponse {
  853. ResponseHeader header = 1;
  854. }
  855. message AuthUserGrantRoleResponse {
  856. ResponseHeader header = 1;
  857. }
  858. message AuthUserRevokeRoleResponse {
  859. ResponseHeader header = 1;
  860. }
  861. message AuthRoleAddResponse {
  862. ResponseHeader header = 1;
  863. }
  864. message AuthRoleGetResponse {
  865. ResponseHeader header = 1;
  866. repeated authpb.Permission perm = 2;
  867. }
  868. message AuthRoleListResponse {
  869. ResponseHeader header = 1;
  870. repeated string roles = 2;
  871. }
  872. message AuthUserListResponse {
  873. ResponseHeader header = 1;
  874. repeated string users = 2;
  875. }
  876. message AuthRoleDeleteResponse {
  877. ResponseHeader header = 1;
  878. }
  879. message AuthRoleGrantPermissionResponse {
  880. ResponseHeader header = 1;
  881. }
  882. message AuthRoleRevokePermissionResponse {
  883. ResponseHeader header = 1;
  884. }