{
    "schemes": [
        "http"
    ],
    "swagger": "2.0",
    "info": {
        "title": "Git Swagger API",
        "termsOfService": "http://swagger.io/terms/",
        "contact": {},
        "version": "1.0"
    },
    "host": "localhost:8080",
    "basePath": "/ecosystem/api/v1",
    "paths": {
        "/integration/github/accounts": {
            "get": {
                "description": "Get TiDB Cloud App installation information, please pass GITHUB_ACCESS_TOKEN and GITHUB_REFRESH_TOKEN with header. We may refresh token if access_token is expired and refresh_token is passed.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.GetGitHubInstallAccountsResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            }
        },
        "/integration/github/exchange-token": {
            "get": {
                "description": "Exchange GitHub token with code. See https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#using-the-web-application-flow-to-generate-a-user-access-token",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "The code you received in the previous step.",
                        "name": "code",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.ExchangeGitHubTokenResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            }
        },
        "/integration/github/search-repo-v2": {
            "get": {
                "description": "List repositories that the TiDB Cloud App installation can access with a safer way. installation_id is not reliable, we need to judge whether the installation_id belongs to the user who provided the access_token. Please pass GITHUB_ACCESS_TOKEN and GITHUB_REFRESH_TOKEN with header.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "GitHub account installation_id",
                        "name": "installation_id",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "GitHub repository name",
                        "name": "repo_name",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "page",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "per_page",
                        "name": "per_page",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.GetGitHubRepoResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            }
        },
        "/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/git/connections": {
            "get": {
                "description": "List Connections between TIDB Cloud cluster and Git.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "TiDB Org ID",
                        "name": "org_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Project ID",
                        "name": "project_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Cluster ID",
                        "name": "cluster_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.GetConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            },
            "post": {
                "description": "Add Connections between TIDB Cloud cluster and Git.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "TiDB Org ID",
                        "name": "org_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Project ID",
                        "name": "project_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Cluster ID",
                        "name": "cluster_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Git information",
                        "name": "git",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/git.AddConnectionRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.AddConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            },
            "delete": {
                "description": "Delete Connections between TIDB Cloud cluster and Git.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "TiDB Org ID",
                        "name": "org_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Project ID",
                        "name": "project_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Cluster ID",
                        "name": "cluster_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            }
        },
        "/orgs/{org_id}/projects/{project_id}/git/connections": {
            "get": {
                "description": "List Connections between TIDB Cloud cluster and Git.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "TiDB Org ID",
                        "name": "org_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "TiDB Project ID",
                        "name": "project_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/git.ListConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/git.BaseResp"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "git.AccountsVO": {
            "type": "object",
            "properties": {
                "installation_id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                },
                "owner_type": {
                    "type": "string"
                }
            }
        },
        "git.AddConnectionRequest": {
            "type": "object",
            "required": [
                "git_provider",
                "repo_name"
            ],
            "properties": {
                "git_provider": {
                    "type": "string",
                    "enum": [
                        "github"
                    ]
                },
                "repo_name": {
                    "type": "string"
                }
            }
        },
        "git.AddConnectionResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "id": {
                    "type": "integer"
                }
            }
        },
        "git.BaseResp": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                }
            }
        },
        "git.ExchangeGitHubTokenResponse": {
            "type": "object",
            "properties": {
                "access_token": {
                    "type": "string"
                },
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "refresh_token": {
                    "type": "string"
                }
            }
        },
        "git.GetConnectionResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "connection": {
                    "$ref": "#/definitions/git.TiDBGitConnectionVO"
                }
            }
        },
        "git.GetGitHubInstallAccountsResponse": {
            "type": "object",
            "properties": {
                "access_token": {
                    "type": "string"
                },
                "accounts": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/git.AccountsVO"
                    }
                },
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "refresh_token": {
                    "type": "string"
                }
            }
        },
        "git.GetGitHubRepoResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "repositories": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/git.RepositoriesVO"
                    }
                },
                "total": {
                    "type": "integer"
                }
            }
        },
        "git.ListConnectionResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/git.Resp"
                },
                "connections": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/git.TiDBGitConnectionVO"
                    }
                }
            }
        },
        "git.RepositoriesVO": {
            "type": "object",
            "properties": {
                "full_name": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "git.Resp": {
            "type": "object",
            "properties": {
                "err_code": {
                    "type": "integer"
                },
                "err_msg": {
                    "type": "string"
                }
            }
        },
        "git.TiDBGitConnectionVO": {
            "type": "object",
            "properties": {
                "git_provider": {
                    "type": "string"
                },
                "repo_name": {
                    "type": "string"
                },
                "tidb_cluster_id": {
                    "type": "string"
                },
                "tidb_cluster_name": {
                    "type": "string"
                }
            }
        }
    }
}