syntax = "proto3";
package etcdserverpb;

import "gogoproto/gogo.proto";
import "etcdserver.proto";
import "rpc.proto";
import "etcd/api/versionpb/version.proto";
import "etcd/api/membershippb/membership.proto";

option go_package = "go.etcd.io/etcd/api/v3/etcdserverpb";

option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_getters_all) = false;

message RequestHeader {
  option (versionpb.etcd_version_msg) = "3.0";

  uint64 ID = 1;
  // username is a username that is associated with an auth token of gRPC connection
  string username = 2;
  // auth_revision is a revision number of auth.authStore. It is not related to mvcc
  uint64 auth_revision = 3 [(versionpb.etcd_version_field) = "3.1"];
}

// An InternalRaftRequest is the union of all requests which can be
// sent via raft.
message InternalRaftRequest {
  option (versionpb.etcd_version_msg) = "3.0";

  RequestHeader header = 100;
  uint64 ID = 1;

  Request v2 = 2;

  RangeRequest range = 3;
  PutRequest put = 4;
  DeleteRangeRequest delete_range = 5;
  TxnRequest txn = 6;
  CompactionRequest compaction = 7;

  LeaseGrantRequest lease_grant = 8;
  LeaseRevokeRequest lease_revoke = 9;

  AlarmRequest alarm = 10;

  LeaseCheckpointRequest lease_checkpoint = 11 [(versionpb.etcd_version_field) = "3.4"];

  AuthEnableRequest auth_enable = 1000;
  AuthDisableRequest auth_disable = 1011;
  AuthStatusRequest auth_status = 1013 [(versionpb.etcd_version_field) = "3.5"];

  InternalAuthenticateRequest authenticate = 1012;

  AuthUserAddRequest auth_user_add = 1100;
  AuthUserDeleteRequest auth_user_delete = 1101;
  AuthUserGetRequest auth_user_get = 1102;
  AuthUserChangePasswordRequest auth_user_change_password = 1103;
  AuthUserGrantRoleRequest auth_user_grant_role = 1104;
  AuthUserRevokeRoleRequest auth_user_revoke_role = 1105;
  AuthUserListRequest auth_user_list = 1106;
  AuthRoleListRequest auth_role_list = 1107;

  AuthRoleAddRequest auth_role_add = 1200;
  AuthRoleDeleteRequest auth_role_delete = 1201;
  AuthRoleGetRequest auth_role_get = 1202;
  AuthRoleGrantPermissionRequest auth_role_grant_permission = 1203;
  AuthRoleRevokePermissionRequest auth_role_revoke_permission = 1204;

  membershippb.ClusterVersionSetRequest cluster_version_set = 1300 [(versionpb.etcd_version_field) = "3.5"];
  membershippb.ClusterMemberAttrSetRequest cluster_member_attr_set = 1301 [(versionpb.etcd_version_field) = "3.5"];
  membershippb.DowngradeInfoSetRequest  downgrade_info_set = 1302 [(versionpb.etcd_version_field) = "3.5"];

  DowngradeVersionTestRequest downgrade_version_test = 9900 [(versionpb.etcd_version_field) = "3.6"];
}

message EmptyResponse {
}

// What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest?
// InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing.
// For avoiding misusage the field, we have an internal version of AuthenticateRequest.
message InternalAuthenticateRequest {
  option (versionpb.etcd_version_msg) = "3.0";
  string name = 1;
  string password = 2;

  // simple_token is generated in API layer (etcdserver/v3_server.go)
  string simple_token = 3;
}
