basePath: /ecosystem/api/v1
definitions:
  git.AccountsVO:
    properties:
      installation_id:
        type: integer
      name:
        type: string
      owner_type:
        type: string
    type: object
  git.AddConnectionRequest:
    properties:
      git_provider:
        enum:
        - github
        type: string
      repo_name:
        type: string
    required:
    - git_provider
    - repo_name
    type: object
  git.AddConnectionResponse:
    properties:
      base_resp:
        $ref: '#/definitions/git.Resp'
      id:
        type: integer
    type: object
  git.BaseResp:
    properties:
      base_resp:
        $ref: '#/definitions/git.Resp'
    type: object
  git.ExchangeGitHubTokenResponse:
    properties:
      access_token:
        type: string
      base_resp:
        $ref: '#/definitions/git.Resp'
      refresh_token:
        type: string
    type: object
  git.GetConnectionResponse:
    properties:
      base_resp:
        $ref: '#/definitions/git.Resp'
      connection:
        $ref: '#/definitions/git.TiDBGitConnectionVO'
    type: object
  git.GetGitHubInstallAccountsResponse:
    properties:
      access_token:
        type: string
      accounts:
        items:
          $ref: '#/definitions/git.AccountsVO'
        type: array
      base_resp:
        $ref: '#/definitions/git.Resp'
      refresh_token:
        type: string
    type: object
  git.GetGitHubRepoResponse:
    properties:
      base_resp:
        $ref: '#/definitions/git.Resp'
      repositories:
        items:
          $ref: '#/definitions/git.RepositoriesVO'
        type: array
      total:
        type: integer
    type: object
  git.ListConnectionResponse:
    properties:
      base_resp:
        $ref: '#/definitions/git.Resp'
      connections:
        items:
          $ref: '#/definitions/git.TiDBGitConnectionVO'
        type: array
    type: object
  git.RepositoriesVO:
    properties:
      full_name:
        type: string
      id:
        type: integer
      name:
        type: string
    type: object
  git.Resp:
    properties:
      err_code:
        type: integer
      err_msg:
        type: string
    type: object
  git.TiDBGitConnectionVO:
    properties:
      git_provider:
        type: string
      repo_name:
        type: string
      tidb_cluster_id:
        type: string
      tidb_cluster_name:
        type: string
    type: object
host: localhost:8080
info:
  contact: {}
  termsOfService: http://swagger.io/terms/
  title: Git Swagger API
  version: "1.0"
paths:
  /integration/github/accounts:
    get:
      consumes:
      - application/json
      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.
      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:
      consumes:
      - application/json
      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
      parameters:
      - description: The code you received in the previous step.
        in: query
        name: code
        required: true
        type: string
      produces:
      - application/json
      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:
      consumes:
      - application/json
      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.
      parameters:
      - description: GitHub account installation_id
        in: query
        name: installation_id
        required: true
        type: string
      - description: GitHub repository name
        in: query
        name: repo_name
        type: string
      - description: page
        in: query
        name: page
        type: integer
      - description: per_page
        in: query
        name: per_page
        type: integer
      produces:
      - application/json
      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:
    delete:
      consumes:
      - application/json
      description: Delete Connections between TIDB Cloud cluster and Git.
      parameters:
      - description: TiDB Org ID
        in: path
        name: org_id
        required: true
        type: string
      - description: TiDB Project ID
        in: path
        name: project_id
        required: true
        type: string
      - description: TiDB Cluster ID
        in: path
        name: cluster_id
        required: true
        type: string
      produces:
      - application/json
      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'
    get:
      consumes:
      - application/json
      description: List Connections between TIDB Cloud cluster and Git.
      parameters:
      - description: TiDB Org ID
        in: path
        name: org_id
        required: true
        type: string
      - description: TiDB Project ID
        in: path
        name: project_id
        required: true
        type: string
      - description: TiDB Cluster ID
        in: path
        name: cluster_id
        required: true
        type: string
      produces:
      - application/json
      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:
      consumes:
      - application/json
      description: Add Connections between TIDB Cloud cluster and Git.
      parameters:
      - description: TiDB Org ID
        in: path
        name: org_id
        required: true
        type: string
      - description: TiDB Project ID
        in: path
        name: project_id
        required: true
        type: string
      - description: TiDB Cluster ID
        in: path
        name: cluster_id
        required: true
        type: string
      - description: Git information
        in: body
        name: git
        required: true
        schema:
          $ref: '#/definitions/git.AddConnectionRequest'
      produces:
      - application/json
      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'
  /orgs/{org_id}/projects/{project_id}/git/connections:
    get:
      consumes:
      - application/json
      description: List Connections between TIDB Cloud cluster and Git.
      parameters:
      - description: TiDB Org ID
        in: path
        name: org_id
        required: true
        type: string
      - description: TiDB Project ID
        in: path
        name: project_id
        required: true
        type: string
      produces:
      - application/json
      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'
schemes:
- http
swagger: "2.0"
