{
  "swagger": "2.0",
  "info": {
    "title": "Branch OpenAPIs for TiDB Cloud",
    "description": "The TiDB Cloud API uses HTTP Digest Authentication. It protects your private key from being sent over the network.The API key contains a public key and a private key, which act as the username and password required in the HTTP Digest Authentication. The private key only displays upon the key creation.",
    "version": "v1beta"
  },
  "tags": [
    {
      "name": "BranchService"
    }
  ],
  "host": "api.tidbcloud.com",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1beta/clusters/{cluster_id}/branches": {
      "get": {
        "summary": "List all branches in the cluster.",
        "operationId": "ListBranches",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1beta.ListBranchesResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "page_token",
            "description": "The number of pages.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int64",
            "default": 1
          },
          {
            "name": "page_size",
            "description": "The size of a page.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int64",
            "default": 10
          }
        ],
        "tags": [
          "BranchService"
        ]
      },
      "post": {
        "summary": "Create a branch.",
        "operationId": "CreateBranch",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1beta.CreateBranchResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/v1beta.BranchService.CreateBranchBody"
            }
          }
        ],
        "tags": [
          "BranchService"
        ]
      }
    },
    "/api/v1beta/clusters/{cluster_id}/branches/{branch_id}": {
      "get": {
        "summary": "Get a branch.",
        "operationId": "GetBranch",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1beta.Branch"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "branch_id",
            "description": "The ID of the branch.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "BranchService"
        ]
      },
      "delete": {
        "summary": "Delete a branch.",
        "operationId": "DeleteBranch",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "type": "object",
              "properties": {}
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "branch_id",
            "description": "The ID of the branch.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "BranchService"
        ]
      }
    }
  },
  "definitions": {
    "Any": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "Status": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Any"
          }
        }
      }
    },
    "v1beta.BasicBranch": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the branch."
        },
        "name": {
          "type": "string",
          "description": "The name of the branch."
        },
        "display_name": {
          "type": "string",
          "description": "The display name of the branch."
        },
        "cluster_id": {
          "type": "string",
          "description": "The ID of the cluster."
        },
        "parent_id": {
          "type": "string",
          "description": "The ID of the parent branch."
        },
        "state": {
          "$ref": "#/definitions/v1beta.BranchState",
          "description": "The status of the branch."
        },
        "create_time": {
          "type": "string",
          "format": "date-time",
          "description": "The creation timestamp of the branch."
        },
        "update_time": {
          "type": "string",
          "format": "date-time",
          "description": "The update timestamp of the branch."
        }
      },
      "description": "BranchItem is the information of branch.",
      "title": "BranchItem",
      "required": [
        "id",
        "name",
        "display_name",
        "cluster_id",
        "parent_id",
        "state",
        "create_time",
        "update_time"
      ]
    },
    "v1beta.Branch": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the branch."
        },
        "name": {
          "type": "string",
          "description": "The name of the branch."
        },
        "display_name": {
          "type": "string",
          "description": "The display name of the branch."
        },
        "cluster_id": {
          "type": "string",
          "description": "The ID of the cluster."
        },
        "parent_id": {
          "type": "string",
          "description": "The ID of the parent branch."
        },
        "state": {
          "$ref": "#/definitions/v1beta.BranchState",
          "description": "The status of the branch."
        },
        "endpoints": {
          "$ref": "#/definitions/v1beta.Endpoints",
          "description": "The endpoint of the branch."
        },
        "user_prefix": {
          "type": "string",
          "description": "The userPrefix of the branch."
        },
        "create_time": {
          "type": "string",
          "format": "date-time",
          "description": "The creation timestamp of the branch."
        },
        "update_time": {
          "type": "string",
          "format": "date-time",
          "description": "The update timestamp of the branch."
        },
        "annotations": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "The annotations of the branch."
        }
      },
      "description": "BranchItem is the information of branch.",
      "title": "BranchItem",
      "required": [
        "id",
        "name",
        "display_name",
        "cluster_id",
        "parent_id",
        "state",
        "endpoints",
        "user_prefix",
        "create_time",
        "update_time",
        "annotations"
      ]
    },
    "v1beta.BranchService.CreateBranchBody": {
      "type": "object",
      "properties": {
        "display_name": {
          "type": "string",
          "description": "The name of creating branch. It must be 1-64 characters long."
        }
      },
      "description": "CreateBranchReq is the request message for CreateBranch.",
      "required": [
        "display_name"
      ]
    },
    "v1beta.BranchState": {
      "type": "string",
      "enum": [
        "CREATING",
        "READY",
        "DELETED",
        "MAINTENANCE",
        "ACTIVE",
        "RESTORING"
      ]
    },
    "v1beta.CreateBranchResp": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "example": "branch-SDUAOISD",
          "description": "The ID of the branch."
        }
      },
      "description": "CreateBranchResp is the response message for CreateBranch.",
      "required": [
        "id"
      ]
    },
    "v1beta.Endpoints": {
      "type": "object",
      "properties": {
        "public_endpoint": {
          "$ref": "#/definitions/v1beta.PublicEndpoint",
          "description": "The public endpoint of the branch."
        },
        "private_endpoint": {
          "$ref": "#/definitions/v1beta.PrivateEndpoint"
        }
      },
      "description": "Endpoints is the endpoint of the branch."
    },
    "v1beta.ListBranchesResp": {
      "type": "object",
      "properties": {
        "branches": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1beta.BasicBranch"
          },
          "description": "The items of branches in the cluster."
        },
        "total": {
          "type": "integer",
          "format": "int64",
          "description": "The total number of branches in the cluster."
        }
      },
      "description": "ListBranchesResp is the response of ListBranches.",
      "required": [
        "branches",
        "total"
      ]
    },
    "v1beta.PrivateEndpoint": {
      "type": "object",
      "properties": {
        "host": {
          "type": "string",
          "description": "The host of the private endpoint."
        },
        "port": {
          "type": "integer",
          "format": "int32",
          "description": "The port of the private endpoint."
        },
        "disabled": {
          "type": "boolean",
          "description": "The disabled of the private endpoint."
        },
        "aws": {
          "$ref": "#/definitions/v1beta.PrivateEndpointAws",
          "description": "The provider of the private endpoint is AWS."
        },
        "gcp": {
          "$ref": "#/definitions/v1beta.PrivateEndpointGcp",
          "description": "The provider of the private endpoint is GCP."
        }
      },
      "description": "PrivateEndpoint is the private endpoint of the branch."
    },
    "v1beta.PrivateEndpointAws": {
      "type": "object",
      "properties": {
        "service_mame": {
          "type": "string",
          "description": "The service name of the branch on AWS."
        },
        "availability_zone": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "PrivateEndpointAws is the private endpoint of the branch on AWS."
    },
    "v1beta.PrivateEndpointGcp": {
      "type": "object",
      "properties": {
        "target_service_attachment": {
          "type": "string",
          "description": "The service name of the branch on GCP."
        }
      },
      "description": "PrivateEndpointGcp is the private endpoint of the branch on GCP."
    },
    "v1beta.PublicEndpoint": {
      "type": "object",
      "properties": {
        "host": {
          "type": "string",
          "description": "The host of the public endpoint."
        },
        "port": {
          "type": "integer",
          "format": "int32",
          "description": "The port of the public endpoint."
        },
        "disabled": {
          "type": "boolean",
          "description": "The disabled of the public endpoint."
        }
      },
      "description": "PublicEndpoint is the public endpoint of the branch."
    }
  }
}
