syntax = "proto3";

package tidb_mgmt_service.v1;

import "global/common/v1/service_plan.proto";
import "global/nextgen/v1/reserved_capacity_template.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.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 ReservedCapacityTemplateService {
  rpc CreateReservedCapacityTemplate(CreateReservedCapacityTemplateRequest) returns (global.nextgen.v1.ReservedCapacityTemplate) {
    option (google.api.http) = {
      post: "/reservedCapacityTemplates"
      body: "reserved_capacity_template"
    };
  }

  rpc GetReservedCapacityTemplate(GetReservedCapacityTemplateRequest) returns (global.nextgen.v1.ReservedCapacityTemplate) {
    option (google.api.http) = {get: "/reservedCapacityTemplates/{capacity_template_id}"};
  }

  rpc ListReservedCapacityTemplates(ListReservedCapacityTemplatesRequest) returns (ListReservedCapacityTemplatesResponse) {
    option (google.api.http) = {get: "/reservedCapacityTemplates"};
  }

  rpc UpdateReservedCapacityTemplateStatus(UpdateReservedCapacityTemplateStatusRequest) returns (global.nextgen.v1.ReservedCapacityTemplate) {
    option (google.api.http) = {
      post: "/reservedCapacityTemplates/{capacity_template_id}:updateStatus"
      body: "*"
    };
  }

  rpc DeleteReservedCapacityTemplate(DeleteReservedCapacityTemplateRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {delete: "/reservedCapacityTemplates/{capacity_template_id}"};
  }
}

message CreateReservedCapacityTemplateRequest {
  global.nextgen.v1.ReservedCapacityTemplate reserved_capacity_template = 1 [(google.api.field_behavior) = REQUIRED];
}

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

message ListReservedCapacityTemplatesRequest {
  uint64 organization_id = 1 [(google.api.field_behavior) = OPTIONAL];
  global.nextgen.v1.ReservedCapacityTemplate.WorkloadType workload_type = 2 [(google.api.field_behavior) = OPTIONAL];
  int64 qps = 3 [(google.api.field_behavior) = OPTIONAL];
  int64 data_size_gib = 4 [(google.api.field_behavior) = OPTIONAL];
  int64 p99_response_latency = 5 [(google.api.field_behavior) = OPTIONAL];
  global.nextgen.v1.ReservedCapacityTemplate.Status status = 6 [(google.api.field_behavior) = OPTIONAL];
  global.nextgen.v1.ReservedCapacityTemplate.Scope scope = 7 [(google.api.field_behavior) = OPTIONAL];
  global.common.v1.ServicePlan service_plan = 8 [(google.api.field_behavior) = OPTIONAL];
  uint32 page_size = 100 [(google.api.field_behavior) = OPTIONAL];
  uint32 page = 101 [(google.api.field_behavior) = OPTIONAL];
}

message ListReservedCapacityTemplatesResponse {
  repeated global.nextgen.v1.ReservedCapacityTemplate reserved_capacity_templates = 1;
  uint32 total = 2;
}

message UpdateReservedCapacityTemplateStatusRequest {
  uint64 capacity_template_id = 1 [(google.api.field_behavior) = REQUIRED];
  global.nextgen.v1.ReservedCapacityTemplate.Status status = 2 [(google.api.field_behavior) = REQUIRED];
}

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