syntax = "proto3";

package global.nextgen.v1;

import "datatype/v1/enums.proto";
import "global/common/v1/resources.proto";
import "global/common/v1/service_plan.proto";
import "global/nextgen/v1/node_spec.proto";
import "global/nextgen/v1/reserved_capacity_template.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

service ResourcePoolService {
  rpc CreateResourcePool(CreateResourcePoolRequest) returns (ResourcePoolProfile);
  rpc ListResourcePools(ListResourcePoolsRequest) returns (ListResourcePoolsResponse);
  rpc UpdateResourcePoolName(UpdateResourcePoolNameRequest) returns (ResourcePool);
  rpc UpdateResourcePoolInstanceLimit(UpdateResourcePoolInstanceLimitRequest) returns (ResourcePool);

  rpc GetResourcePool(GetResourcePoolRequest) returns (ResourcePoolProfile);
  rpc DeleteResourcePool(DeleteResourcePoolRequest) returns (ResourcePool);

  rpc ListOwnerResourcePools(ListOwnerResourcePoolsRequest) returns (ListOwnerResourcePoolsResponse);
  rpc UpdateOrgDefaultResourcePool(UpdateOrgDefaultResourcePoolRequest) returns (ResourcePoolStrategy);

  rpc GetResourcePoolCapacityConstraints(GetResourcePoolCapacityConstraintsRequest) returns (ResourcePoolCapacityConstraints);
  rpc ResizeResourcePoolCapacity(ResizeResourcePoolCapacityRequest) returns (ResizeResourcePoolCapacityResponse);
  rpc UpsertResourcePoolCloudResourceTags(UpsertResourcePoolCloudResourceTagsRequest) returns (UpsertResourcePoolCloudResourceTagsResponse);

  // Resource Pool lifecycle control APIs are internal-only. They validate,
  // start, and monitor asynchronous Pause/Resume workflows. Once a workflow
  // is accepted, it cannot be canceled through the current contract; canceling
  // a caller-side DevOps operation does not cancel the Global or Regional
  // operation.
  rpc PauseResourcePool(PauseResourcePoolRequest) returns (PauseResourcePoolResponse);
  rpc BeginPauseResourcePoolAdmission(BeginPauseResourcePoolAdmissionRequest) returns (BeginPauseResourcePoolAdmissionResponse);
  rpc ResolvePauseResourcePoolAdmission(ResolvePauseResourcePoolAdmissionRequest) returns (ResolvePauseResourcePoolAdmissionResponse);
  rpc ResumeResourcePool(ResumeResourcePoolRequest) returns (ResumeResourcePoolResponse);
  // Queries the Regional Pause/Resume operation for an asynchronous request.
  // The same operation_id is used by Global and Regional services.
  rpc GetResourcePoolPauseResumeOperation(GetResourcePoolPauseResumeOperationRequest) returns (ResourcePoolPauseResumeOperation);
}

message ResourcePool {
  uint64 id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  string name = 2 [(google.api.field_behavior) = REQUIRED];
  common.v1.CloudProvider.Name provider_id = 3 [(google.api.field_behavior) = REQUIRED];
  common.v1.Region.Name region_id = 4 [(google.api.field_behavior) = REQUIRED];
  OwnerType owner_type = 5 [(google.api.field_behavior) = REQUIRED];
  uint64 owner_id = 6 [(google.api.field_behavior) = REQUIRED];
  string cidr = 7 [(google.api.field_behavior) = REQUIRED];
  common.v1.ServicePlan service_plan = 8 [(google.api.field_behavior) = REQUIRED];
  uint64 instance_limit = 9 [(google.api.field_behavior) = OPTIONAL];
  string k8s_service_cidr = 10 [(google.api.field_behavior) = OPTIONAL];
  string config_meta_profile_id = 11 [(google.api.field_behavior) = OPTIONAL];
  string dataplane_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  uint64 provider_identity_id = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
  uint64 vcpus_limit = 14 [(google.api.field_behavior) = OPTIONAL];
  string pca_arn = 15 [(google.api.field_behavior) = OPTIONAL];
  string provider_identity = 16 [(google.api.field_behavior) = INPUT_ONLY];
  // placement_group_enabled requests placement-group isolation for the underlying nodes.
  // Supported for AWS resource pools (SHARED with Essential_V2, or ORGANIZATION with BYOC/Premium). Immutable after create.
  bool placement_group_enabled = 17 [(google.api.field_behavior) = IMMUTABLE];
  // The availability scope requested for the resource pool placement.
  // Applies to any service plan that supports single-AZ or multi-AZ resource pools.
  HighAvailabilityType high_availability_type = 18 [(google.api.field_behavior) = OPTIONAL];
  // Optional placement details. If omitted, dataplane-manager chooses zones from its regional defaults.
  ZoneConfig zone_config = 19 [(google.api.field_behavior) = OPTIONAL];
  LifecycleState lifecycle_state = 20 [(google.api.field_behavior) = OUTPUT_ONLY];
  string state_message_code = 21 [(google.api.field_behavior) = OUTPUT_ONLY];
  VcpuLimitMode vcpu_limit_mode = 22 [(google.api.field_behavior) = OPTIONAL];
  map<string, string> cloud_resource_tags = 23 [(google.api.field_behavior) = OPTIONAL];
  string created_by = 24 [(google.api.field_behavior) = OUTPUT_ONLY];
  int64 instance_count = 25 [(google.api.field_behavior) = OUTPUT_ONLY];

  google.protobuf.Timestamp create_time = 100 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp update_time = 101 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp delete_time = 102 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp paused_at = 103 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp automatic_resume_at = 104 [(google.api.field_behavior) = OUTPUT_ONLY];

  enum OwnerType {
    OWNER_TYPE_UNSPECIFIED = 0;
    SHARED = 1;
    ORGANIZATION = 2;
  }

  enum HighAvailabilityType {
    HIGH_AVAILABILITY_TYPE_UNSPECIFIED = 0;
    REGIONAL = 1;
    ZONAL = 2;
  }

  enum LifecycleState {
    LIFECYCLE_STATE_UNSPECIFIED = 0;
    CREATING = 1;
    ACTIVE = 2;
    MODIFYING = 3;
    FAILED = 4;
    PAUSING = 5;
    PAUSED = 6;
    RESUMING = 7;
    // Internal preparation state used while optional pre-Pause manual backups
    // and the authoritative Pause precheck are running. Public APIs expose
    // this state as ACTIVE.
    PAUSE_PRECHECKING = 8;
  }

  enum VcpuLimitMode {
    VCPU_LIMIT_MODE_UNSPECIFIED = 0;
    INHERITED = 1;
    LIMITED = 2;
    UNLIMITED = 3;
  }

  message ZoneConfig {
    // Explicit node zones for the dataplane nodes.
    // Must contain exactly 1 zone for ZONAL pools or exactly 3 zones for REGIONAL pools.
    repeated string node_zones = 1 [(google.api.field_behavior) = OPTIONAL];
  }
}

message ResourcePoolProfile {
  ResourcePool resource_pool = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  bool is_default = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated Instance instances = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  string version = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  StorageType tikv_data_storage_type = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  StorageType tikv_raftlog_storage_type = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  StorageType tiflash_cn_storage_type = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  StorageType tiflash_wn_storage_type = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  common.v1.Region region = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  PdDeploymentMode pd_deployment_mode = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  // Enabled TiKV remote worker components.
  // Currently only TIKV_WORKER and COPROCESSOR_WORKER are supported.
  // If unset or empty, CSNG applies its default worker set.
  repeated ComponentType enabled_tikv_remote_workers = 11 [(google.api.field_behavior) = OUTPUT_ONLY];

  // For Essential_V2 shared pools, lists the organization IDs that have set
  // this pool as their org-level default.
  repeated string default_orgs = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  ResourcePoolCapacity capacity = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
  optional int64 provisioned_database_vcpus = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
  optional string o11y_cluster_cidr = 15 [(google.api.field_behavior) = OUTPUT_ONLY];

  enum StorageType {
    STORAGE_TYPE_UNSPECIFIED = 0;
    GP3 = 1 [(datatype.v1.name) = "gp3"];
    IO2 = 2 [(datatype.v1.name) = "io2"];
    LocalSSD = 3 [(datatype.v1.name) = "local-ssd"];
    CloudESSD = 4 [(datatype.v1.name) = "cloud-essd"];
    CloudAuto = 5 [(datatype.v1.name) = "cloud-auto"];
    PremiumSSDV2 = 6 [(datatype.v1.name) = "premiumssdv2"];
  }

  message Instance {
    uint64 cluster_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    string name = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  }
}

message CreateResourcePoolRequest {
  ResourcePool resource_pool = 1 [(google.api.field_behavior) = REQUIRED];
  Demand demand = 2 [(google.api.field_behavior) = REQUIRED];
  // If unset, RCU-driven shared pools default to monolithic.
  // Topology-driven shared pools keep the regional default.
  PdDeploymentMode pd_deployment_mode = 3 [(google.api.field_behavior) = OPTIONAL];
  // Enabled TiKV remote worker components.
  // Currently only TIKV_WORKER and COPROCESSOR_WORKER are supported.
  // If unset or empty, CSNG applies its default worker set.
  repeated ComponentType enabled_tikv_remote_workers = 4 [(google.api.field_behavior) = OPTIONAL];
  // Requested TiFlash architecture for the regional shared pool creation.
  // If unset or AUTO, CSNG selects the effective architecture.
  TiflashMode tiflash_mode = 5 [(google.api.field_behavior) = OPTIONAL];
  // logical_region disambiguates the target logical region when multiple logical
  // regions share the same physical cloud-provider region (region_id).
  // Particularly useful for Essential_V2 shared pools created in private logical regions.
  // When set, the region is resolved by matching both the physical region_id and this
  // logical name. When unset, any active region matching the physical region_id is selected.
  string logical_region = 6 [(google.api.field_behavior) = OPTIONAL];
  ResourcePoolBootstrapCapacity bootstrap_capacity = 7 [(google.api.field_behavior) = OPTIONAL];
  ResourcePool.VcpuLimitMode vcpu_limit_mode = 8 [(google.api.field_behavior) = OPTIONAL];
  string created_by = 9 [(google.api.field_behavior) = INPUT_ONLY];
  // Install Capacity Planner for an RCU-driven shared pool.
  bool enable_capacity_planner = 10 [(google.api.field_behavior) = OPTIONAL];

  bool validate_only = 100 [(google.api.field_behavior) = OPTIONAL];

  message Demand {
    uint32 initial_rcu = 1 [(google.api.field_behavior) = REQUIRED];
    Storage tikv_data = 2 [(google.api.field_behavior) = REQUIRED];
    Storage tikv_raftlog = 3 [(google.api.field_behavior) = REQUIRED];
    Storage tiflash_cn = 4 [(google.api.field_behavior) = REQUIRED];
    Storage tiflash_wn = 5 [(google.api.field_behavior) = REQUIRED];
  }

  message Storage {
    ResourcePoolProfile.StorageType storage_type = 1 [(google.api.field_behavior) = REQUIRED];
    uint32 disk_size_gi = 2 [(google.api.field_behavior) = OPTIONAL];
    uint32 disk_iops = 3 [(google.api.field_behavior) = OPTIONAL];
    uint32 disk_throughput_mbps = 4 [(google.api.field_behavior) = OPTIONAL];
  }
}

message UpdateResourcePoolNameRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  string name = 2 [(google.api.field_behavior) = REQUIRED];

  bool validate_only = 100 [(google.api.field_behavior) = OPTIONAL];
}

message UpdateResourcePoolInstanceLimitRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  // At least one of instance_limit or vcpus_limit must be provided.
  // Requests with both instance_limit and vcpus_limit unset are invalid.
  uint64 instance_limit = 2 [(google.api.field_behavior) = OPTIONAL];
  optional uint64 vcpus_limit = 3 [(google.api.field_behavior) = OPTIONAL];
  ResourcePool.VcpuLimitMode vcpu_limit_mode = 4 [(google.api.field_behavior) = OPTIONAL];

  bool validate_only = 100 [(google.api.field_behavior) = OPTIONAL];
}

message GetResourcePoolRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  bool show_deleted = 2 [(google.api.field_behavior) = OPTIONAL];
}

message DeleteResourcePoolRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL];
}

message ListResourcePoolsRequest {
  repeated uint64 resource_pool_ids = 1 [(google.api.field_behavior) = OPTIONAL];
  string resource_pool_name = 2 [(google.api.field_behavior) = OPTIONAL];

  repeated common.v1.CloudProvider.Name provider_ids = 3 [(google.api.field_behavior) = OPTIONAL];
  repeated common.v1.Region.Name region_ids = 4 [(google.api.field_behavior) = OPTIONAL];
  ResourcePool.OwnerType owner_type = 5 [(google.api.field_behavior) = OPTIONAL];
  repeated uint64 owner_ids = 6 [(google.api.field_behavior) = OPTIONAL];

  google.protobuf.Timestamp created_after = 7 [(google.api.field_behavior) = OPTIONAL];
  google.protobuf.Timestamp created_before = 8 [(google.api.field_behavior) = OPTIONAL];
  common.v1.ServicePlan service_plan = 9 [(google.api.field_behavior) = OPTIONAL];
  repeated ResourcePool.LifecycleState lifecycle_states = 10 [(google.api.field_behavior) = OPTIONAL];

  uint32 page_size = 100 [(google.api.field_behavior) = OPTIONAL];
  uint32 page = 101 [(google.api.field_behavior) = OPTIONAL];

  bool show_deleted = 102 [(google.api.field_behavior) = OPTIONAL];
  View view = 103 [(google.api.field_behavior) = OPTIONAL];
  string page_token = 104 [(google.api.field_behavior) = OPTIONAL];

  enum View {
    VIEW_UNSPECIFIED = 0;
    BASIC = 1;
    DETAIL = 2;
  }
}

message ListResourcePoolsResponse {
  repeated ResourcePoolProfile resource_pools = 1;

  int32 total_size = 100;
  string next_page_token = 101;
}

message ListOwnerResourcePoolsRequest {
  repeated common.v1.CloudProvider.Name provider_ids = 1 [(google.api.field_behavior) = OPTIONAL];
  repeated common.v1.Region.Name region_ids = 2 [(google.api.field_behavior) = OPTIONAL];
  ResourcePool.OwnerType owner_type = 3 [(google.api.field_behavior) = REQUIRED];
  uint64 owner_id = 4 [(google.api.field_behavior) = REQUIRED];
  common.v1.ServicePlan service_plan = 5 [(google.api.field_behavior) = OPTIONAL];
}

message ListOwnerResourcePoolsResponse {
  repeated RegionResourcePools region_resource_pools = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  message RegionResourcePools {
    common.v1.CloudProvider.Name provider_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    common.v1.Region.Name region_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    repeated ResourcePoolProfile resource_pools = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
    ResourcePoolStrategy strategy = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
    common.v1.ServicePlan service_plan = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  }
}

message ResourcePoolStrategy {
  uint64 id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 default_resource_pool_id = 3 [(google.api.field_behavior) = REQUIRED];
  common.v1.CloudProvider.Name provider_id = 4 [(google.api.field_behavior) = REQUIRED];
  common.v1.Region.Name region_id = 5 [(google.api.field_behavior) = REQUIRED];
  common.v1.ServicePlan service_plan = 6 [(google.api.field_behavior) = REQUIRED];

  google.protobuf.Timestamp create_time = 100 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp update_time = 101 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp delete_time = 102 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message UpdateOrgDefaultResourcePoolRequest {
  ResourcePoolStrategy strategy = 1 [(google.api.field_behavior) = REQUIRED];
}

message ResourcePoolCapacity {
  ComponentCapacity tikv = 1;
  ComponentCapacity tiflash = 2;
}

message ComponentCapacity {
  NodeSpecSelection node_spec = 1;
  optional int64 node_count = 2;
  repeated Storage storages = 3;
}

message NodeSpecSelection {
  int64 cpu = 1;
  int64 memory_gi = 2;
}

message Storage {
  string name = 1;
  int64 size_gi = 2;
}

message ResourcePoolBootstrapCapacity {
  ComponentCapacity tikv = 1 [(google.api.field_behavior) = REQUIRED];
  ComponentCapacity tiflash = 2 [(google.api.field_behavior) = OPTIONAL];
}

message GetResourcePoolCapacityConstraintsRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message ResourcePoolCapacityConstraints {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  ResourcePoolCapacity current_capacity = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  ComponentCapacityConstraints tikv = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  ComponentCapacityConstraints tiflash = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message ComponentCapacityConstraints {
  repeated CapacityConstraintReason blocking_reasons = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  NodeCountConstraints node_count = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  NodeSpecConstraints node_spec = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message NodeCountConstraints {
  int64 current = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  int64 min = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  int64 max = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  NodeCountRule rule = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  bool allow_cross_zero = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message NodeSpecConstraints {
  ResourcePoolNodeSpec current = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated NodeSpecCandidate candidates = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message NodeSpecCandidate {
  ResourcePoolNodeSpec node_spec = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  bool available = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated CapacityConstraintReason reasons = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message CapacityConstraintReason {
  string code = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  string message = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message ResizeResourcePoolCapacityRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  ResourcePoolCapacity target_capacity = 3 [(google.api.field_behavior) = REQUIRED];
  bool validate_only = 100 [(google.api.field_behavior) = OPTIONAL];
}

message ResizeResourcePoolCapacityResponse {
  ResourcePoolCapacity current_capacity = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  ResourcePoolCapacity target_capacity = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message UpsertResourcePoolCloudResourceTagsRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  map<string, string> cloud_resource_tags = 3 [(google.api.field_behavior) = OPTIONAL];
  repeated string remove_cloud_resource_tag_keys = 4 [(google.api.field_behavior) = OPTIONAL];
}

message UpsertResourcePoolCloudResourceTagsResponse {
  map<string, string> cloud_resource_tags = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message ResourcePoolPauseValidationResult {
  // A stable code from Global or the authoritative Regional validation owner.
  // For the minimal Ops-only contract, Regional codes may be returned as-is.
  string check_code = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  // A safe detail that can be shown to the Ops caller.
  string detail = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message PauseResourcePoolRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  // Required unless validate_only is true.
  string operation_id = 2 [(google.api.field_behavior) = OPTIONAL];
  // Creates one manual backup for every Instance in the Resource Pool before
  // running Pause validation. The Pause request stops if any backup fails.
  bool create_manual_backup_before_pause = 3 [(google.api.field_behavior) = OPTIONAL];
  // Runs Pause validation without changing lifecycle state or starting a workflow.
  bool validate_only = 100 [(google.api.field_behavior) = OPTIONAL];
}

message PauseResourcePoolResponse {
  // Populated only when Pause is accepted and its workflow is created or replayed.
  string operation_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  // Populated when validation finds blockers, including for an actual Pause request.
  // An empty list means Pause is currently allowed or has been accepted.
  repeated ResourcePoolPauseValidationResult validation_results = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message ResumeResourcePoolRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  string operation_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message ResumeResourcePoolResponse {
  string operation_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message GetResourcePoolPauseResumeOperationRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  string operation_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message ResourcePoolPauseResumeOperation {
  string operation_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  uint64 resource_pool_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  Type type = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  Status status = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  string result_summary = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp created_at = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp updated_at = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  google.protobuf.Timestamp completed_at = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  enum Type {
    TYPE_UNSPECIFIED = 0;
    OPERATION_PAUSE = 1;
    OPERATION_RESUME = 2;
  }

  enum Status {
    STATUS_UNSPECIFIED = 0;
    RUNNING = 1;
    SUCCEEDED = 2;
    FAILED = 3;
  }
}

enum PdDeploymentMode {
  PD_DEPLOYMENT_MODE_UNSPECIFIED = 0;
  PD_DEPLOYMENT_MODE_MICROSERVICE = 1;
  PD_DEPLOYMENT_MODE_MONOLITHIC = 2;
}

enum TiflashMode {
  TIFLASH_MODE_UNSPECIFIED = 0;
  TIFLASH_MODE_AUTO = 1;
  TIFLASH_MODE_LEGACY = 2;
  TIFLASH_MODE_COLUMNAR = 3;
}

message BeginPauseResourcePoolAdmissionRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  string operation_id = 2 [(google.api.field_behavior) = REQUIRED];
  bool create_manual_backup_before_pause = 3 [(google.api.field_behavior) = OPTIONAL];
}

message BeginPauseResourcePoolAdmissionResponse {
  string operation_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated ResourcePoolPauseValidationResult validation_results = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message ResolvePauseResourcePoolAdmissionRequest {
  uint64 resource_pool_id = 1 [(google.api.field_behavior) = REQUIRED];
  string operation_id = 2 [(google.api.field_behavior) = REQUIRED];
  bool proceed = 3 [(google.api.field_behavior) = REQUIRED];
  repeated ResourcePoolPauseValidationResult validation_results = 4 [(google.api.field_behavior) = OPTIONAL];
}

message ResolvePauseResourcePoolAdmissionResponse {
  string operation_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated ResourcePoolPauseValidationResult validation_results = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}
