syntax = "proto3";

package tidb_mgmt_service.v1;

import "global/common/v1/resources.proto";
import "global/common/v1/service_plan.proto";
import "global/dedicated/v1/compat.proto";
import "global/dedicated/v1/resources.proto";
import "global/nextgen/v1/region.proto";
import "global/serverless/v1/resources.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "tidb_cloud_open_api/dedicated/v1beta1/resources.proto";
import "tidb_mgmt_service/v1/resources.proto";

/**
   All APIs here are for global control plane **internal** use only.
*/

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  swagger: "2.0"
  host: ""
  base_path: "/inner/mgmt/v1"
  info: {
    version: "v1"
    title: "Control Plane Internal API"
    description: "Control Plane Internal API."
  }
  schemes: HTTPS
};

service ClusterService {
  rpc ListClusters(ListClustersRequest) returns (ListClustersResponse) {}

  rpc CountClusters(CountClustersRequest) returns (CountClustersResponse) {}

  // Success means deletion workflows were submitted for all matching clusters.
  // Resource deletion continues asynchronously.
  rpc CleanClusters(CleanClustersRequest) returns (google.protobuf.Empty) {}

  rpc CleanProjectResource(CleanProjectResourceRequest) returns (google.protobuf.Empty) {}

  rpc CleanOrganizationResource(CleanOrganizationResourceRequest) returns (google.protobuf.Empty) {}

  rpc ApplyCluster(ApplyClusterRequest) returns (Cluster) {}

  rpc ApplyGKEHeterogeneousDeploy(ApplyGKEHeterogeneousDeployRequest) returns (GKEHeterogeneousDeploy) {}

  rpc GetGKEHeterogeneousDeploy(GetGKEHeterogeneousDeployRequest) returns (GKEHeterogeneousDeploy) {}

  rpc DeleteGKEHeterogeneousDeploy(DeleteGKEHeterogeneousDeployRequest) returns (google.protobuf.Empty) {}

  rpc RestoreDedicatedCluster(RestoreDedicatedClusterRequest) returns (Cluster) {}

  rpc RestoreServerlessCluster(RestoreServerlessClusterRequest) returns (Cluster) {}

  rpc CreateServerlessCluster(CreateServerlessClusterRequest) returns (Cluster) {}

  // return basic view cluster
  rpc UpdateServerlessRegionalClusterAnnotations(UpdateServerlessRegionalClusterAnnotationsRequest) returns (Cluster) {}

  rpc DeleteCluster(DeleteClusterRequest) returns (Cluster) {}

  rpc ModifyClusterVolume(ModifyClusterVolumeRequest) returns (Cluster) {}

  rpc ScaleClusterPdComponent(ScaleClusterPdComponentRequest) returns (Cluster) {}

  rpc ScaleClusterTiProxyComponent(ScaleClusterTiProxyComponentRequest) returns (Cluster) {}

  rpc ScaleClusterComponents(ScaleClusterComponentsRequest) returns (Cluster) {}

  rpc CreateClusterWithClusterConfiguration(CreateClusterWithClusterConfigurationRequest) returns (Cluster) {}

  rpc ShowComponentNodeInfo(ShowComponentNodeInfoRequest) returns (ShowComponentNodeInfoResponse) {
    option (google.api.http) = {get: "/clusters/{cluster_id}:showComponentNodeInfo"};
  }

  rpc CountBillableClusters(CountBillableClustersRequest) returns (CountBillableClustersResponse) {
    option (google.api.http) = {
      post: "/clusters:countBillableClusters"
      body: "*"
    };
  }

  rpc BuildComponentSpecDiffReports(BuildComponentSpecDiffReportsRequest) returns (BuildComponentSpecDiffReportsResponse) {}

  rpc GetCloudIamInfo(GetCloudIamInfoRequest) returns (CloudIamInfo) {}

  // Update ru_version for a cluster (Essential or Premium). Internal ops only.
  rpc UpdateClusterRuVersion(UpdateClusterRuVersionRequest) returns (Cluster) {
    option (google.api.http) = {
      put: "/clusters/{cluster_id}:updateRuVersion"
      body: "*"
    };
  }

  rpc AddClusterLabels(AddClusterLabelsRequest) returns (Cluster) {
    option (google.api.http) = {
      patch: "/clusters/{cluster_id}:addLabels"
      body: "*"
    };
  }
}

service ClusterCustomStatusService {
  rpc SetClusterCustomStatus(SetClusterCustomStatusRequest) returns (ClusterCustomStatus) {}

  rpc GetClusterCustomStatusByID(GetClusterCustomStatusByIDRequest) returns (ClusterCustomStatus) {}

  rpc GetClusterCustomStatusByName(GetClusterCustomStatusByNameRequest) returns (ClusterCustomStatus) {}

  rpc DeleteClusterCustomStatus(DeleteClusterCustomStatusRequest) returns (google.protobuf.Empty) {}

  rpc IsClusterCustomStatusExisted(IsClusterCustomStatusExistedRequest) returns (IsClusterCustomStatusExistedResponse) {}

  rpc ListClusterCustomStatus(ListClusterCustomStatusRequest) returns (ListClusterCustomStatusResponse) {}
}

service RegionService {
  rpc RegisterCloudProvider(RegisterCloudProviderRequest) returns (CloudProvider) {
    option (google.api.http) = {
      post: "/cloudProviders"
      body: "cloud_provider"
    };
  }

  rpc ListCloudProviders(ListCloudProvidersRequest) returns (ListCloudProvidersResponse) {
    option (google.api.http) = {get: "/cloudProviders"};
  }

  rpc RegisterRegion(RegisterRegionRequest) returns (Region) {
    option (google.api.http) = {
      post: "/regions"
      body: "region"
    };
  }

  rpc ListRegions(ListRegionsRequest) returns (ListRegionsResponse) {
    option (google.api.http) = {get: "/regions"};
  }

  rpc GetRegion(GetRegionRequest) returns (Region) {
    option (google.api.http) = {get: "/regions/{region_logical_name}"};
  }

  rpc SelectRegionByOrganizationId(SelectRegionByOrganizationIdRequest) returns (Region) {
    option (google.api.http) = {get: "/regions/{region_id}:selectByOrganization"};
  }

  rpc UpdateRegion(UpdateRegionRequest) returns (Region) {
    option (google.api.http) = {
      put: "/regions/{region.region.logical_name}"
      body: "region"
    };
  }

  rpc CheckRegionStatus(CheckRegionStatusRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {get: "/regions/{region_logical_name}:checkStatus"};
  }

  rpc DeleteRegion(DeleteRegionRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {delete: "/regions/{region_logical_name}"};
  }

  // only for byoc internal use
  rpc UpdateRegionOpsAuditLogSetting(UpdateRegionOpsAuditLogSettingRequest) returns (global.nextgen.v1.UpdateRegionOpsAuditLogSettingResponse) {
    option (google.api.http) = {patch: "/regions/{region_logical_name}/opsAuditLogSetting"};
  }

  // only for nextgen(premium and byoc) internal use
  rpc RegisterRegionProviderIdentity(RegisterRegionProviderIdentityRequest) returns (global.nextgen.v1.RegionProviderIdentity) {
    option (google.api.http) = {
      post: "/regions/{region_logical_name}/providerIdentities"
      body: "*"
    };
  }

  // only for nextgen(premium and byoc) internal use
  rpc ListRegionProviderIdentities(ListRegionProviderIdentitiesRequest) returns (global.nextgen.v1.ListRegionProviderIdentitiesResponse) {
    option (google.api.http) = {get: "/regions/{region_logical_name}/providerIdentities"};
  }
}

// only for internal use
// work with dedicated cluster service
service VpcPeeringService {
  rpc CreateVpcPeering(CreateVpcPeeringRequest) returns (CreateVpcPeeringResponse) {}

  rpc ListVpcPeerings(ListVpcPeeringsRequest) returns (ListVpcPeeringsResponse) {}

  rpc GetVpcPeering(GetVpcPeeringRequest) returns (GetVpcPeeringResponse) {}

  rpc DeleteVpcPeering(DeleteVpcPeeringRequest) returns (google.protobuf.Empty) {}
}

service DataPlaneService {
  rpc GetCompatCluster(GetCompatClusterRequest) returns (global.dedicated.v1.CompatCluster) {
    option (google.api.http) = {get: "/dataplane/clusters/{cluster_id}"};
  }

  rpc GetCompatNetwork(GetCompatNetworkRequest) returns (global.dedicated.v1.CompatNetwork) {
    option (google.api.http) = {get: "/dataplane/networks/{project_id}/{provider_name}/{region_name}"};
  }

  rpc GetCompatProvider(GetCompatProviderRequest) returns (global.dedicated.v1.CompatProvider) {
    option (google.api.http) = {get: "/dataplane/providers/{provider_name}"};
  }
}

// ListAllClustersService messages.
message ListClustersRequest {
  ClusterFilter filter = 1 [(google.api.field_behavior) = OPTIONAL];

  // The maximum number of clusters to return in each response.
  // The server may return fewer than this at its discretion.
  // If no value is specified, a default value of 100 will be used.
  uint32 page_size = 100 [(google.api.field_behavior) = OPTIONAL];
  uint32 page = 101 [(google.api.field_behavior) = OPTIONAL];
}

message ListClustersResponse {
  repeated Cluster clusters = 1;
  uint32 total = 2;
}

message CountClustersRequest {
  ClusterFilter filter = 1 [(google.api.field_behavior) = OPTIONAL];
}

message CountClustersResponse {
  uint32 count = 1;
}

message CleanClustersRequest {
  uint64 organization_id = 1 [(google.api.field_behavior) = REQUIRED];
  DeployType deploy_type = 2 [(google.api.field_behavior) = OPTIONAL]; // not set means all deploy types
  bool disable_final_backup = 3 [(google.api.field_behavior) = OPTIONAL]; // default enable final backup
}

message CleanProjectResourceRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
}

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

message ApplyClusterRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ClusterApplyMask cluster_apply_mask = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 status_id = 3 [(google.api.field_behavior) = REQUIRED];
}

message ApplyGKEHeterogeneousDeployRequest {
  reserved 7;
  reserved "count";
  uint64 tenant_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 cluster_id = 3 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ComponentType component_type = 4 [(google.api.field_behavior) = REQUIRED];
  string current_instance_type = 5 [(google.api.field_behavior) = REQUIRED];
  string alternative_instance_type = 6 [(google.api.field_behavior) = REQUIRED];
  uint64 tidb_group_id = 8 [(google.api.field_behavior) = OPTIONAL];
}

message GetGKEHeterogeneousDeployRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ComponentType component_type = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 tidb_group_id = 3 [(google.api.field_behavior) = OPTIONAL];
  uint64 tenant_id = 4 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 5 [(google.api.field_behavior) = REQUIRED];
}

message DeleteGKEHeterogeneousDeployRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ComponentType component_type = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 tidb_group_id = 3 [(google.api.field_behavior) = OPTIONAL];
  uint64 tenant_id = 4 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 5 [(google.api.field_behavior) = REQUIRED];
}

message GKEHeterogeneousDeploy {
  reserved 5;
  reserved "count";
  bool enabled = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  global.dedicated.v1.ComponentType component_type = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  string current_instance_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  string alternative_instance_type = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  uint64 tidb_group_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  string status = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  repeated global.dedicated.v1.GKEHeterogeneousDeployPodCount pod_counts = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
}

message RestoreDedicatedClusterRequest {
  // Metadata of the cluster to be restored.
  string created_by = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 3 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 4 [(google.api.field_behavior) = REQUIRED];
  string region = 5 [(google.api.field_behavior) = REQUIRED];
  uint64 source_cluster_id = 6 [(google.api.field_behavior) = REQUIRED];
  uint64 restore_id = 7 [(google.api.field_behavior) = REQUIRED];

  // Configs.
  string cluster_name = 10 [(google.api.field_behavior) = REQUIRED];
  int32 port = 11 [(google.api.field_behavior) = REQUIRED];
  string root_password = 12 [(google.api.field_behavior) = OPTIONAL];
  // Version of TiDB kernel.
  string version = 13 [(google.api.field_behavior) = OPTIONAL];

  // Components.
  ComputeComp tidb_comp = 20 [(google.api.field_behavior) = REQUIRED];
  StorageComp tikv_comp = 21 [(google.api.field_behavior) = REQUIRED];
  StorageComp tiflash_comp = 22 [(google.api.field_behavior) = OPTIONAL];
  tidb_cloud_open_api.dedicated.v1beta1.TidbNodeGroup.TiProxySetting tiproxy_comp = 23 [(google.api.field_behavior) = OPTIONAL];

  // Cluster configuration including per-component image tag overrides.
  global.dedicated.v1.ClusterConfiguration cluster_configuration = 30 [(google.api.field_behavior) = OPTIONAL];

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

  message ComputeComp {
    string spu_name = 1 [(google.api.field_behavior) = REQUIRED];
    int32 count = 2 [(google.api.field_behavior) = REQUIRED];
  }

  message StorageComp {
    string spu_name = 1 [(google.api.field_behavior) = REQUIRED];
    // Count of TiFlash can be 0.
    int32 count = 2 [(google.api.field_behavior) = OPTIONAL];
    // If size not set, use default size in selected sku.
    int32 size_gi = 3 [(google.api.field_behavior) = OPTIONAL];
    // If storage_type not set, backend choose the default type of storage.
    tidb_cloud_open_api.dedicated.v1beta1.Cluster.StorageNodeSetting.StorageType storage_type = 4 [(google.api.field_behavior) = OPTIONAL];
    // IOPS of the TiKV DATA disk. Only for tikv, and only supported for AWS clusters with Plus storage type.
    int32 data_store_iops = 7 [(google.api.field_behavior) = OPTIONAL];
    // Only for tikv.
    int32 raft_iops = 5 [(google.api.field_behavior) = OPTIONAL];
    // Additional IOPS for DATA disk. Final IOPS = SKU base IOPS + additional_iops.
    int32 additional_iops = 6 [(google.api.field_behavior) = OPTIONAL];
  }
}

message RestoreServerlessClusterRequest {
  string cluster_name = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 3 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 4 [(google.api.field_behavior) = REQUIRED];
  string region = 5 [(google.api.field_behavior) = REQUIRED];
  global.serverless.v1.SpendLimit spending_limit = 6 [(google.api.field_behavior) = REQUIRED];
  global.serverless.v1.AutomatedBackupPolicy automated_backup_policy = 7 [(google.api.field_behavior) = OPTIONAL];
  global.serverless.v1.EncryptionConfig encryption_config = 8 [(google.api.field_behavior) = OPTIONAL];
  bool disable_public_endpoint = 9 [(google.api.field_behavior) = OPTIONAL];
  string created_by = 10 [(google.api.field_behavior) = REQUIRED];
  bool zone_redundant_enabled = 11 [(google.api.field_behavior) = OPTIONAL];
  string kubernetes = 12 [(google.api.field_behavior) = OPTIONAL];
  AutoScaling auto_scaling = 13 [(google.api.field_behavior) = OPTIONAL];
}

message CreateServerlessClusterRequest {
  string cluster_name = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 3 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 4 [(google.api.field_behavior) = REQUIRED];
  string region = 5 [(google.api.field_behavior) = REQUIRED];
  global.serverless.v1.SpendLimit spending_limit = 6 [(google.api.field_behavior) = REQUIRED];
  global.serverless.v1.AutomatedBackupPolicy automated_backup_policy = 7 [(google.api.field_behavior) = OPTIONAL];
  global.serverless.v1.EncryptionConfig encryption_config = 8 [(google.api.field_behavior) = OPTIONAL];
  bool disable_public_endpoint = 9 [(google.api.field_behavior) = OPTIONAL];
  string created_by = 10 [(google.api.field_behavior) = REQUIRED];
  bool zone_redundant_enabled = 11 [(google.api.field_behavior) = OPTIONAL];
  AutoScaling auto_scaling = 12 [(google.api.field_behavior) = OPTIONAL];
}

message UpdateServerlessRegionalClusterAnnotationsRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  // The underlying regional cluster annotations to update, originally from the cluster cr
  map<string, string> annotations = 2 [(google.api.field_behavior) = REQUIRED];
}

message DeleteClusterRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  DeployType deploy_type = 2 [(google.api.field_behavior) = REQUIRED];
}

message ModifyClusterVolumeRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ComponentType component_type = 2 [(google.api.field_behavior) = REQUIRED];
  optional uint32 storage_size = 3 [(google.api.field_behavior) = OPTIONAL];
  optional uint32 storage_iops = 4 [(google.api.field_behavior) = OPTIONAL];
  optional uint32 storage_throughput = 5 [(google.api.field_behavior) = OPTIONAL];
  optional global.dedicated.v1.StorageMu.VolumeType volume_type = 6 [(google.api.field_behavior) = OPTIONAL];
  global.dedicated.v1.Sku.DiskType disk_type = 7 [(google.api.field_behavior) = REQUIRED];
  optional uint32 additional_iops = 8 [(google.api.field_behavior) = OPTIONAL];
}

message ScaleClusterPdComponentRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  string spu_name = 2 [(google.api.field_behavior) = REQUIRED];
}

message ScaleClusterComponentsRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  repeated global.dedicated.v1.Cluster.ClusterComponent cluster_components = 2 [(google.api.field_behavior) = REQUIRED];
  // The storage change only takes effect when force_scale is set to true, otherwise, the storage change will be ignored.
  // Cluster state will be ignored, too.
  bool force_scale = 3 [(google.api.field_behavior) = OPTIONAL];
}

message ScaleClusterTiProxyComponentRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  // If not set, the default tidb group will be used.
  uint64 tidb_node_group_id = 2 [(google.api.field_behavior) = OPTIONAL];
  string spu_name = 3 [(google.api.field_behavior) = REQUIRED];
  optional uint32 count = 4 [(google.api.field_behavior) = REQUIRED];
}

message CreateClusterWithClusterConfigurationRequest {
  Cluster cluster = 1 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.ClusterConfiguration cluster_configuration = 2 [(google.api.field_behavior) = REQUIRED];
}

message ShowComponentNodeInfoRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = OPTIONAL];
  uint64 project_id = 3 [(google.api.field_behavior) = OPTIONAL];
}

message ShowComponentNodeInfoResponse {
  global.dedicated.v1.ComponentNodeInfo component_node_info = 1;
}

message CountBillableClustersRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  google.protobuf.Timestamp start_time = 3 [(google.api.field_behavior) = REQUIRED];
  google.protobuf.Timestamp end_time = 4 [(google.api.field_behavior) = REQUIRED];
}

message CountBillableClustersResponse {
  uint32 billable_clusters_count = 1;
}

message BuildComponentSpecDiffReportsRequest {
  repeated uint64 tenant_ids = 1 [(google.api.field_behavior) = OPTIONAL];
  repeated uint64 project_ids = 2 [(google.api.field_behavior) = OPTIONAL];
  repeated global.common.v1.CloudProvider.Name cloud_providers = 3 [(google.api.field_behavior) = OPTIONAL];
  repeated global.common.v1.Region.Name regions = 4 [(google.api.field_behavior) = OPTIONAL];
  repeated uint64 cluster_ids = 5 [(google.api.field_behavior) = OPTIONAL];

  // The maximum number of clusters to return in each response.
  // If no value is specified, a default value of 100 will be used.
  uint32 page_size = 100 [(google.api.field_behavior) = OPTIONAL];
  uint32 page = 101 [(google.api.field_behavior) = OPTIONAL];
}

message BuildComponentSpecDiffReportsResponse {
  repeated Report clusters = 1;

  message Report {
    uint64 tenant_id = 1;
    uint64 project_id = 2;
    uint64 cluster_id = 3;
    string cluster_name = 4;

    // Effective and default are derived from whether the provisioned value is customized or SKU default.

    repeated global.dedicated.v1.Cluster.ClusterComponent current_default_components = 5;

    repeated global.dedicated.v1.Cluster.ClusterComponent current_effective_components = 6;
  }
}

// ClusterCustomStatusService messages.

message SetClusterCustomStatusRequest {
  ClusterCustomStatus custom_status = 1 [(google.api.field_behavior) = REQUIRED];
}

message GetClusterCustomStatusByIDRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 status_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message GetClusterCustomStatusByNameRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  string status_name = 2 [(google.api.field_behavior) = REQUIRED];
  CustomStatusType status_type = 3 [(google.api.field_behavior) = REQUIRED];
}

message DeleteClusterCustomStatusRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 status_id = 2 [(google.api.field_behavior) = REQUIRED];
}

message IsClusterCustomStatusExistedRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  CustomStatusType status_type = 2 [(google.api.field_behavior) = REQUIRED];
}

message IsClusterCustomStatusExistedResponse {
  bool is_existed = 1;
  repeated ClusterCustomStatus existed_custom_statuses = 2;
}

message ListClusterCustomStatusRequest {
  repeated uint64 cluster_ids = 1 [(google.api.field_behavior) = REQUIRED];
  repeated CustomStatusType status_types = 2 [(google.api.field_behavior) = REQUIRED];
  optional bool include_deleted = 3 [(google.api.field_behavior) = OPTIONAL];
}

message ListClusterCustomStatusResponse {
  repeated ClusterCustomStatus custom_statuses = 1;
}

// Region service messages

message RegisterCloudProviderRequest {
  CloudProvider cloud_provider = 1 [(google.api.field_behavior) = REQUIRED];
}

message ListCloudProvidersRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = OPTIONAL];
  global.common.v1.ServicePlan service_plan = 2 [(google.api.field_behavior) = OPTIONAL];
  uint64 organization_id = 3 [(google.api.field_behavior) = OPTIONAL];

  // The maximum number of cloud providers to return in each response.
  // The server may return fewer than this at its discretion.
  // If no value is specified, a default value of 100 will be used.
  uint32 page_size = 100 [(google.api.field_behavior) = OPTIONAL];
  uint32 page = 101 [(google.api.field_behavior) = OPTIONAL];
}

message ListCloudProvidersResponse {
  repeated CloudProvider cloud_providers = 1;
}

message RegisterRegionRequest {
  Region region = 1 [(google.api.field_behavior) = REQUIRED];
}

message ListRegionsRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = OPTIONAL];

  global.common.v1.ServicePlan service_plan = 2 [(google.api.field_behavior) = OPTIONAL];
  uint64 organization_id = 3 [(google.api.field_behavior) = OPTIONAL];
  string engine_type = 4 [(google.api.field_behavior) = OPTIONAL];

  // The maximum number of regions to return in each response.
  // The server may return fewer than this at its discretion.
  // If no value is specified, a default value of 100 will be used.
  uint32 page_size = 100;
  uint32 page = 101;
}

message GetRegionRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.CloudProvider.Name cloud_provider_id = 2 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 4 [(google.api.field_behavior) = OPTIONAL];
  global.common.v1.ServicePlan service_plan = 5 [(google.api.field_behavior) = OPTIONAL];
  string engine_type = 6 [(google.api.field_behavior) = OPTIONAL];
}

message SelectRegionByOrganizationIdRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.CloudProvider.Name cloud_provider_id = 2 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.Region.Name region_id = 3 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 4 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.ServicePlan service_plan = 5 [(google.api.field_behavior) = OPTIONAL];
}

message ListRegionsResponse {
  repeated Region regions = 1;
}

message UpdateRegionRequest {
  Region region = 1 [(google.api.field_behavior) = REQUIRED];
}

message CheckRegionStatusRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.CloudProvider.Name cloud_provider_id = 2 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 3 [(google.api.field_behavior) = REQUIRED];
}

message DeleteRegionRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.CloudProvider.Name cloud_provider_id = 2 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 4 [(google.api.field_behavior) = OPTIONAL];
  global.common.v1.ServicePlan service_plan = 5 [(google.api.field_behavior) = OPTIONAL];
  string engine_type = 6 [(google.api.field_behavior) = OPTIONAL];
}

message CreateVpcPeeringRequest {
  uint64 project_id = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 3 [(google.api.field_behavior) = REQUIRED];
  global.dedicated.v1.VpcPeering.Type type = 5 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 4 [(google.api.field_behavior) = REQUIRED];
  string source_region = 6 [(google.api.field_behavior) = REQUIRED];
  string target_region = 7 [(google.api.field_behavior) = REQUIRED];
}

message CreateVpcPeeringResponse {
  uint64 peering_id = 1;
}

message ListVpcPeeringsRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 3 [(google.api.field_behavior) = OPTIONAL];
  repeated string regions = 4 [(google.api.field_behavior) = OPTIONAL];
  repeated global.dedicated.v1.VpcPeering.Type types = 5 [(google.api.field_behavior) = OPTIONAL];
  repeated global.dedicated.v1.VpcPeering.State states = 6 [(google.api.field_behavior) = OPTIONAL];
}

message ListVpcPeeringsResponse {
  repeated global.dedicated.v1.VpcPeering vpc_peerings = 1;
}

message GetVpcPeeringRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 3 [(google.api.field_behavior) = REQUIRED];
  uint64 vpc_peering_id = 4 [(google.api.field_behavior) = REQUIRED];
}

message GetVpcPeeringResponse {
  global.dedicated.v1.VpcPeering vpc_peering = 1;
}

message DeleteVpcPeeringRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 2 [(google.api.field_behavior) = REQUIRED];
  string cloud_provider = 3 [(google.api.field_behavior) = REQUIRED];
  uint64 vpc_peering_id = 4 [(google.api.field_behavior) = REQUIRED];
}

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

message GetCompatNetworkRequest {
  uint64 project_id = 1 [(google.api.field_behavior) = REQUIRED];
  string provider_name = 2 [(google.api.field_behavior) = REQUIRED];
  string region_name = 3 [(google.api.field_behavior) = REQUIRED];
}

message GetCompatProviderRequest {
  string provider_name = 1 [(google.api.field_behavior) = REQUIRED];
}

message GetCloudIamInfoRequest {
  string cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
}

message UpdateRegionOpsAuditLogSettingRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 2 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.RegionOpsAuditLogSetting ops_audit_log_setting = 3 [(google.api.field_behavior) = REQUIRED];
}

message RegisterRegionProviderIdentityRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 2 [(google.api.field_behavior) = REQUIRED];
  global.nextgen.v1.RegionProviderIdentity region_provider_identity = 3 [(google.api.field_behavior) = REQUIRED];
}

message ListRegionProviderIdentitiesRequest {
  DeployType deploy_type = 1 [(google.api.field_behavior) = REQUIRED];
  string region_logical_name = 2 [(google.api.field_behavior) = REQUIRED];
}

// OrganizationConfigService manages organization-level configurations.
// Internal ops only.
service OrganizationConfigService {
  // Set default ru_version for an organization. Affects future cluster creation only.
  rpc UpdateOrganizationDefaultRuVersion(UpdateOrganizationDefaultRuVersionRequest) returns (OrganizationRuConfig) {
    option (google.api.http) = {
      put: "/organizationConfigs/{organization_id}/ruVersion"
      body: "*"
    };
  }

  // Get default ru_version for an organization.
  rpc GetOrganizationDefaultRuVersion(GetOrganizationDefaultRuVersionRequest) returns (OrganizationRuConfig) {
    option (google.api.http) = {get: "/organizationConfigs/{organization_id}/ruVersion"};
  }
}

message UpdateOrganizationDefaultRuVersionRequest {
  uint64 organization_id = 1 [(google.api.field_behavior) = REQUIRED];
  int32 default_ru_version = 2 [(google.api.field_behavior) = REQUIRED];
}

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

message OrganizationRuConfig {
  uint64 organization_id = 1;
  int32 default_ru_version = 2;
}

message UpdateClusterRuVersionRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  int32 ru_version = 2 [(google.api.field_behavior) = REQUIRED];
}

message AddClusterLabelsRequest {
  uint64 cluster_id = 1 [(google.api.field_behavior) = REQUIRED];
  map<string, string> labels = 2 [(google.api.field_behavior) = REQUIRED];
}
