{
  "swagger": "2.0",
  "info": {
    "title": "Internal 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": "alpha"
  },
  "tags": [
    {
      "name": "BranchService"
    }
  ],
  "host": "api.tidbcloud.com",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/internal/projects/{project_id}/clusters/{cluster_id}/branches": {
      "get": {
        "summary": "List all branches in the cluster.",
        "operationId": "ListBranches",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/openapiListBranchesResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/googlerpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "project_id",
            "description": "The ID of the project.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "root_branch_id",
            "description": "The id of the root branch.",
            "in": "query",
            "required": true,
            "type": "string"
          },
          {
            "name": "page",
            "description": "The number of pages.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32",
            "default": 1
          },
          {
            "name": "page_size",
            "description": "The size of a page.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32",
            "default": 10
          }
        ],
        "tags": [
          "BranchService"
        ]
      },
      "post": {
        "summary": "Create a branch.",
        "operationId": "CreateBranch",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/openapiCreateBranchResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/googlerpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "project_id",
            "description": "The ID of the project.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "parent_branch_id": {
                  "type": "string",
                  "description": "The id of the parent branch. If the parent is a cluster, provide the cluster id."
                },
                "branch_name": {
                  "type": "string",
                  "description": "The name of creating branch."
                }
              },
              "required": [
                "parent_branch_id",
                "branch_name"
              ]
            }
          }
        ],
        "tags": [
          "BranchService"
        ]
      }
    },
    "/api/internal/projects/{project_id}/clusters/{cluster_id}/branches/{branch_name}": {
      "get": {
        "summary": "Get a branch.",
        "operationId": "GetBranch",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/openapiGetBranchResp"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/googlerpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "project_id",
            "description": "The ID of the project.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "branch_name",
            "description": "The name of creating branch.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "root_branch_id",
            "description": "The id of the root branch.",
            "in": "query",
            "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/googlerpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "project_id",
            "description": "The ID of the project.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "cluster_id",
            "description": "The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string",
            "format": "uint64"
          },
          {
            "name": "branch_name",
            "description": "The name of creating branch.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "root_branch_id",
            "description": "The id of the root branch.",
            "in": "query",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "BranchService"
        ]
      }
    }
  },
  "definitions": {
    "googlerpcStatus": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/protobufAny"
          }
        }
      }
    },
    "openapiCreateBranchResp": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "example": "branch-SDUAOISD",
          "description": "The ID of the branch."
        }
      },
      "required": [
        "id"
      ]
    },
    "openapiGetBranchResp": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the branch."
        },
        "name": {
          "type": "string",
          "description": "The name of the branch."
        },
        "status": {
          "$ref": "#/definitions/openapiGetBranchRespStatus",
          "description": "The status of the branch."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "The creation timestamp of the branch."
        },
        "tenant_id": {
          "type": "string",
          "format": "uint64",
          "example": "1",
          "description": "The ID of the tenant."
        },
        "project_id": {
          "type": "string",
          "format": "uint64",
          "example": "1",
          "description": "The ID of the project."
        },
        "created_by_id": {
          "type": "string",
          "format": "uint64",
          "example": "1",
          "description": "The ID of the user who created the branch."
        },
        "cloud_provider_name": {
          "type": "string",
          "description": "The name of cloud provider."
        },
        "region_name": {
          "type": "string",
          "description": "The name of cloud provider."
        },
        "parent_branch_id": {
          "type": "string",
          "description": "The ID of the parent branch."
        },
        "root_branch_id": {
          "type": "string",
          "description": "The ID of the root branch."
        },
        "creation_finished_time": {
          "type": "string",
          "format": "date-time",
          "description": "The creation finished timestamp of the branch."
        }
      },
      "description": "BranchItem is the information of branch.",
      "title": "BranchItem",
      "required": [
        "id",
        "name",
        "status",
        "created_at",
        "tenant_id",
        "project_id",
        "created_by_id",
        "cloud_provider_name",
        "region_name",
        "parent_branch_id",
        "root_branch_id"
      ]
    },
    "openapiGetBranchRespStatus": {
      "type": "string",
      "enum": [
        "creating",
        "running",
        "deleted"
      ]
    },
    "openapiListBranchesResp": {
      "type": "object",
      "properties": {
        "branches": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/openapiGetBranchResp"
          },
          "description": "The items of branches in the cluster."
        },
        "total": {
          "type": "string",
          "format": "int64",
          "description": "The total number of branches in the cluster."
        }
      },
      "required": [
        "branches",
        "total"
      ]
    },
    "protobufAny": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    }
  }
}
