syntax = "proto3";

package global.nextgen.v1;

import "google/api/field_behavior.proto";

message Endpoint {
  uint64 tidb_group_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  PublicEndpoint public_endpoint = 2 [(google.api.field_behavior) = OPTIONAL];
  VpcPeeringEndpoint vpc_peering_endpoint = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // On GCP and Azure, different endpoints of a private link service have different hostnames.
  repeated PrivateLinkEndpoint private_link_endpoints = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  message PublicEndpoint {
    string host = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    uint32 port = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    repeated IpAddress ip_allow_list = 3 [(google.api.field_behavior) = OPTIONAL];
    optional bool enable_public_lb = 4 [(google.api.field_behavior) = OPTIONAL];
    ConnectionReachability reachability = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
    repeated string egress_ips = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  message IpAddress {
    string cidr_block = 1 [(google.api.field_behavior) = REQUIRED];
    string description = 2 [(google.api.field_behavior) = OPTIONAL];
  }

  message VpcPeeringEndpoint {
    string host = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    uint32 port = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    ConnectionReachability reachability = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  message PrivateLinkEndpoint {
    string host = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    uint32 port = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    ConnectionReachability reachability = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  }
}

message ConnectionReachability {
  bool reachable = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  Detail detail = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  message Detail {
    bool service_active = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    bool endpoint_active = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
    bool dns_reachable = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
    string message = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  }
}
