rpc.proto 34 KB

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