syntax = "proto3";

package tidb_mgmt_service.v1;

import "global/common/v1/resources.proto";
import "global/dedicated/v1/resources.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "protoc-gen-openapiv2/options/annotations.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 VpcService {
  rpc ListVpcs(ListVpcsRequest) returns (ListVpcsResponse) {
    option (google.api.http) = {get: "/vpcs"};
  }

  rpc AddSecondaryCidr(AddSecondaryCidrRequest) returns (global.dedicated.v1.Vpc) {
    option (google.api.http) = {
      post: "/vpcs/{vpc_id}:addSecondaryCidr"
      body: "*"
    };
  }
}

message ListVpcsRequest {
  uint64 organization_id = 1 [(google.api.field_behavior) = OPTIONAL];
  uint64 project_id = 2 [(google.api.field_behavior) = OPTIONAL];
  repeated global.common.v1.CloudProvider.Name cloud_provider_ids = 3 [(google.api.field_behavior) = OPTIONAL];
  repeated global.common.v1.Region.Name region_ids = 4 [(google.api.field_behavior) = OPTIONAL];
}

message ListVpcsResponse {
  repeated global.dedicated.v1.Vpc vpcs = 1;
}

message AddSecondaryCidrRequest {
  string vpc_id = 1 [(google.api.field_behavior) = REQUIRED];
  string secondary_cidr = 2 [(google.api.field_behavior) = REQUIRED];
  uint64 project_id = 3 [(google.api.field_behavior) = REQUIRED];
  uint64 organization_id = 4 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.CloudProvider.Name cloud_provider_name = 5 [(google.api.field_behavior) = REQUIRED];
  global.common.v1.Region.Name region_name = 6 [(google.api.field_behavior) = REQUIRED];
  bool validate_only = 7 [(google.api.field_behavior) = OPTIONAL];
}
