syntax = "proto3";

package tidb_cloud_open_api.common.v1beta1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "tidb_cloud_open_api/common/v1beta1/service_plan.proto";

option go_package = "tidb_cloud_open_api/common/v1beta1";

// A representation of a region for deploying TiDB clusters.
message Region {
  option (google.api.resource) = {
    type: "tidb_cloud_open_api.common.v1beta1/Region"
    pattern: "regions/{region}"
  };

  string name = 1 [
    (google.api.field_behavior) = IDENTIFIER,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      pattern: "^regions/(aws|gcp|azure)-(.+)$"
      example: "\"regions/aws-us-west-2\""
      description: "The unique name of the region, in the format of `regions/{region_id}`. For example, `regions/aws-us-west-2`."
    }
  ];

  string region_id = 2 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      pattern: "^(aws|gcp|azure|alicloud)-[a-z0-9-]+$"
      example: "\"aws-us-west-2\""
      description: "The unique identifier for the region, in the format of `{cloud_provider}-{region_code}`. For example, `aws-us-west-2`."
    }
  ];

  CloudProvider cloud_provider = 3 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      example: "\"aws\""
      description: "The cloud provider that offers the region.\n\n- `\"aws\"`: Amazon Web Services\n\n- `\"gcp\"`: Google Cloud\n\n- `\"azure\"`: Microsoft Azure\n\n- `\"alicloud\"`: Alibaba Cloud"
    }
  ];

  string display_name = 4 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      example: "\"Oregon (us-west-2)\""
      description: "A human-readable name for the region. For example, `Oregon (us-west-2)`."
    }
  ];

  optional string provider = 5 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    deprecated = true,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      example: "\"aws\""
      title: "Deprecated"
      description: "**Deprecated.** Use `cloudProvider` instead. The name of the cloud provider. For example, `aws`, `gcp`, `azure`, or `alicloud`."
    }
  ];

  repeated ServicePlan service_plans = 6 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      example: "[\"Premium\", \"Essential_V2\", \"Premium_Reserved\"]"
      description: "The service plans available in this region. Premium, Essential_V2, and Premium_Reserved can appear together in the same logical region. Starter, Essential, and BYOC are standalone service plans and cannot share a logical region with any other service plan."
      title: "ServicePlan"
    }
  ];

  repeated ServicePlanInfo supported_service_plans = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Enum of cloud provider names.
  enum CloudProvider {
    // Unspecified cloud provider.
    CLOUD_PROVIDER_UNSPECIFIED = 0;

    // Amazon Web Services.
    aws = 1;

    // Google Cloud Platform.
    gcp = 2;

    // Microsoft Azure.
    azure = 3;

    // Alibaba Cloud.
    alicloud = 4;
  }
}
