syntax = "proto3";

package tidb_cloud_open_api.nextgen.v1beta2;

import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.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/nextgen/v1beta2";

message Backup {
  // The trigger type of a backup.
  enum TriggerType {
    TRIGGER_TYPE_UNSPECIFIED = 0;
    // The backup is triggered automatically by TiDB Cloud.
    AUTO = 1;
    // The backup is triggered manually by a user.
    MANUAL = 2;
  }

  // The state of a backup.
  enum State {
    STATE_UNSPECIFIED = 0;
    // The backup state is unknown.
    UNKNOWN = 1;
    // The backup is pending.
    PENDING = 2;
    // The backup is in progress.
    RUNNING = 3;
    // The backup completed successfully.
    SUCCEEDED = 4;
    // The backup has failed.
    FAILED = 5;
    // The backup is cancelled.
    CANCELLED = 6;
  }

  // The type of a backup.
  enum Type {
    TYPE_UNSPECIFIED = 0;
    // A full snapshot backup.
    SNAPSHOT = 1;
  }

  // The unique identifier of the backup.
  string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The ID of the TiDB Cloud Premium instance to which the backup belongs.
  string tidb_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The ID of the organization to which the backup belongs.
  string organization_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The service plan of the backup. The possible value is `Premium`.
  common.v1beta1.ServicePlan service_plan = 4 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
      description: "The service plan of the backup. The possible value is `Premium`."
      example: "\"Premium\""
    }
  ];

  // The name of the backup.
  string display_name = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The description of the backup.
  string description = 6 [(google.api.field_behavior) = OPTIONAL];

  // The timestamp when the backup was created, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
  google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The size of the backup in bytes.
  int64 size_bytes = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The current state of the backup.
  State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The type of the backup.
  Type type = 10 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The trigger type of the backup.
  TriggerType trigger_type = 11 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The timestamp when the backup expires, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
  google.protobuf.Timestamp expiration_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The backup timestamp.
  string backup_ts = 13 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The ID of the region where the backup is stored.
  string region_id = 14 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Whether the source cluster used a customer-managed key at backup time.
  // Combine with `encryption_key_id`:
  // - `encryption_key_id == "0"`: backup was not encrypted
  // - `encryption_key_id != "0" && customer_managed == false`: backup used SMEK
  // - `encryption_key_id != "0" && customer_managed == true`: backup used CMEK
  bool customer_managed = 15 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Whether the source cluster used a customer-managed key at backup time. Combine with encryption_key_id: \"0\" means not encrypted; non-zero key id with false means SMEK; non-zero key id with true means CMEK."}
  ];

  // Source cluster encryption key ID at backup time. `"0"` means no encryption key was used.
  string encryption_key_id = 16 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Source cluster encryption key ID at backup time. \"0\" means no encryption key was used."}
  ];
}

message ConnectionReachability {
  // Indicates whether the endpoint is reachable.
  bool reachable = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  // The detailed reachability status of the endpoint connection.
  Detail detail = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  message Detail {
    // Indicates whether the service is active.
    bool service_active = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    // Indicates whether the endpoint is active.
    bool endpoint_active = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    // Indicates whether the DNS is reachable.
    bool dns_reachable = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
    // A human-readable message that describes the reachability status.
    string message = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  }
}
