{
  "swagger": "2.0",
  "info": {
    "title": "Serverless Private Link Connection APIs for TiDB Cloud",
    "version": "alpha"
  },
  "tags": [
    {
      "name": "PrivateLinkConnectionService"
    }
  ],
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/privateLinkConnections": {
      "get": {
        "summary": "List private link connections.",
        "operationId": "PrivateLinkConnectionService_ListPrivateLinkConnections",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ListPrivateLinkConnectionsResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "page_size",
            "description": "The maximum number to return.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "page_token",
            "description": "The page token for pagination.",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "state",
            "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted.",
            "in": "query",
            "required": false,
            "type": "string",
            "enum": [
              "CREATING",
              "ACTIVE",
              "FAILED",
              "PENDING_ACCEPTANCE",
              "DELETING"
            ]
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      },
      "post": {
        "summary": "Create a private link connection.",
        "operationId": "PrivateLinkConnectionService_CreatePrivateLinkConnection",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnection"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnectionService.CreatePrivateLinkConnectionBody"
            }
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/privateLinkConnections/{private_link_connection_id}": {
      "get": {
        "summary": "Get a private link connection.",
        "operationId": "PrivateLinkConnectionService_GetPrivateLinkConnection",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnection"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "private_link_connection_id",
            "description": "The private link connection ID.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      },
      "delete": {
        "summary": "Delete a private link connection.",
        "operationId": "PrivateLinkConnectionService_DeletePrivateLinkConnection",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnection"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "private_link_connection_id",
            "description": "The private link connection ID.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/privateLinkConnections/{private_link_connection_id}:attachDomains": {
      "post": {
        "summary": "Attach domains for private link connection.",
        "operationId": "PrivateLinkConnectionService_AttachDomains",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/AttachDomain"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "private_link_connection_id",
            "description": "The private link connection ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnectionService.AttachDomainsBody"
            }
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/privateLinkConnections/{private_link_connection_id}:detachDomains": {
      "post": {
        "summary": "Detach domains for private link connection.",
        "operationId": "PrivateLinkConnectionService_DetachDomains",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/AttachDomain"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "private_link_connection_id",
            "description": "The private link connection ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PrivateLinkConnectionService.DetachDomainsBody"
            }
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/privateLinkConnections:getAvailabilityZones": {
      "get": {
        "summary": "Get account and availability zones information for private link connection.",
        "operationId": "PrivateLinkConnectionService_GetAvailabilityZones",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetAvailabilityZonesResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "The organize ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "The project ID",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "The cluster ID.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "PrivateLinkConnectionService"
        ]
      }
    }
  },
  "definitions": {
    "AlicloudEndpointService": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The endpoint service name."
        },
        "endpoint_id": {
          "type": "string",
          "description": "The endpoint ID.",
          "readOnly": true
        },
        "availability_zone_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The availability zones of the endpoint.",
          "readOnly": true
        }
      },
      "required": [
        "name"
      ]
    },
    "AmazonMSKProvisioned": {
      "type": "object",
      "properties": {
        "msk_arn": {
          "type": "string",
          "description": "The arn of Amazon MSK Provisioned."
        },
        "msk_vpc_connection_arn": {
          "type": "string",
          "description": "The arn of MSK VPC connection arn.",
          "readOnly": true
        },
        "availability_zone_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The availability zones of the connection.",
          "readOnly": true
        }
      },
      "required": [
        "msk_arn"
      ]
    },
    "Any": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "AttachDomain": {
      "type": "object",
      "properties": {
        "attach_domain_id": {
          "type": "string",
          "description": "The attach domain ID.",
          "readOnly": true
        },
        "cluster_id": {
          "type": "string",
          "description": "The cluster ID.",
          "readOnly": true
        },
        "private_link_connection_id": {
          "type": "string",
          "description": "The private link connection ID.",
          "readOnly": true
        },
        "type": {
          "$ref": "#/definitions/PrivateLinkConnectionDomainType.Enum",
          "description": "The domain type to attach."
        },
        "unique_name": {
          "type": "string",
          "description": "The unique name of the domain to attach, it can be empty only when type is TIDBCLOUD_MANAGED and validate_only is true."
        },
        "domains": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Domain"
          },
          "description": "The domains attached.",
          "readOnly": true
        },
        "created_by": {
          "type": "string",
          "description": "The user who attach the domain.",
          "readOnly": true
        },
        "create_time": {
          "type": "string",
          "format": "date-time",
          "title": "create time",
          "readOnly": true
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "type"
      ]
    },
    "AwsEndpointService": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The endpoint service name."
        },
        "region": {
          "type": "string",
          "title": "The region of endpoint service name, default to cluster's region"
        },
        "endpoint_id": {
          "type": "string",
          "description": "The endpoint ID.",
          "readOnly": true
        },
        "availability_zone_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The availability zones of the endpoint.",
          "readOnly": true
        }
      },
      "required": [
        "name"
      ]
    },
    "BaseResp": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "title": "such as: request_id, trace_id"
        },
        "err_code": {
          "type": "string",
          "format": "int64"
        },
        "err_msg": {
          "type": "string"
        }
      }
    },
    "Domain": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The domain name.",
          "readOnly": true
        },
        "state": {
          "type": "string",
          "title": "The domain state",
          "readOnly": true
        },
        "message": {
          "type": "string",
          "description": "Fail message if the domain is in failed state.",
          "readOnly": true
        }
      }
    },
    "GetAvailabilityZonesResponse": {
      "type": "object",
      "properties": {
        "account_id": {
          "type": "string",
          "description": "The account ID."
        },
        "az_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Availability zone ids."
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      }
    },
    "ListPrivateLinkConnectionsResponse": {
      "type": "object",
      "properties": {
        "private_link_connections": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/PrivateLinkConnection"
          }
        },
        "next_page_token": {
          "type": "string"
        },
        "total_size": {
          "type": "integer",
          "format": "int64"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      }
    },
    "PrivateLinkConnection": {
      "type": "object",
      "properties": {
        "private_link_connection_id": {
          "type": "string",
          "title": "The private link connection ID, format: plc-xxx",
          "readOnly": true
        },
        "cluster_id": {
          "type": "string",
          "description": "The ID of the cluster."
        },
        "display_name": {
          "type": "string",
          "description": "Display name for the private link connection."
        },
        "state": {
          "$ref": "#/definitions/PrivateLinkConnectionState.Enum",
          "description": "The state of the private link connection.",
          "readOnly": true
        },
        "message": {
          "type": "string",
          "description": "The message describing fail reason.",
          "readOnly": true
        },
        "created_by": {
          "type": "string",
          "description": "The user who created the private link connection.",
          "readOnly": true
        },
        "create_time": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the private link connection was created.",
          "readOnly": true
        },
        "update_time": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the private link connection was updated.",
          "readOnly": true
        },
        "type": {
          "$ref": "#/definitions/PrivateLinkConnectionType.Enum",
          "title": "The type of the private link connection"
        },
        "attached_domains": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/AttachDomain"
          },
          "title": "The attached domains for the private link connection, only display in Get API",
          "readOnly": true
        },
        "aws_endpoint_service": {
          "$ref": "#/definitions/AwsEndpointService"
        },
        "alicloud_endpoint_service": {
          "$ref": "#/definitions/AlicloudEndpointService"
        },
        "amazon_msk_provisioned": {
          "$ref": "#/definitions/AmazonMSKProvisioned"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": [
        "cluster_id",
        "display_name",
        "type"
      ]
    },
    "PrivateLinkConnectionDomainType.Enum": {
      "type": "string",
      "enum": [
        "TIDBCLOUD_MANAGED",
        "CONFLUENT"
      ],
      "description": " - TIDBCLOUD_MANAGED: The domain pattern is <provider>.plc.tidbcloud.com.\n - CONFLUENT: The domain pattern is <provider>.confluent.cloud."
    },
    "PrivateLinkConnectionService.AttachDomainsBody": {
      "type": "object",
      "properties": {
        "attach_domain": {
          "$ref": "#/definitions/AttachDomain",
          "description": "The domain to attach."
        },
        "validate_only": {
          "type": "boolean",
          "description": "Only validate the request and return the domains without attaching them."
        }
      },
      "required": [
        "attach_domain"
      ]
    },
    "PrivateLinkConnectionService.CreatePrivateLinkConnectionBody": {
      "type": "object",
      "properties": {
        "private_link_connection": {
          "$ref": "#/definitions/PrivateLinkConnection",
          "description": "The private link connection to create."
        }
      },
      "required": [
        "private_link_connection"
      ]
    },
    "PrivateLinkConnectionService.DetachDomainsBody": {
      "type": "object",
      "properties": {
        "attach_domain_id": {
          "type": "string",
          "description": "The attached domain ID to detach."
        }
      },
      "required": [
        "attach_domain_id"
      ]
    },
    "PrivateLinkConnectionState.Enum": {
      "type": "string",
      "enum": [
        "CREATING",
        "ACTIVE",
        "FAILED",
        "PENDING_ACCEPTANCE",
        "DELETING"
      ],
      "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted."
    },
    "PrivateLinkConnectionType.Enum": {
      "type": "string",
      "enum": [
        "AWS_ENDPOINT_SERVICE",
        "ALICLOUD_ENDPOINT_SERVICE",
        "AMAZON_MSK_PROVISIONED"
      ],
      "description": " - AWS_ENDPOINT_SERVICE: AWS endpoint service type.\n - ALICLOUD_ENDPOINT_SERVICE: Alicloud endpoint service type.\n - AMAZON_MSK_PROVISIONED: Amazon MSK Provisioned type."
    },
    "Status": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Any"
          }
        }
      }
    }
  },
  "securityDefinitions": {
    "bearer": {
      "type": "apiKey",
      "description": "Authentication token, prefixed by Bearer: 'Bearer token'",
      "name": "Authorization",
      "in": "header"
    }
  }
}
