{
    "schemes": [
        "http"
    ],
    "swagger": "2.0",
    "info": {
        "title": "Vercel Swagger API",
        "termsOfService": "http://swagger.io/terms/",
        "contact": {},
        "version": "1.0"
    },
    "host": "localhost:8080",
    "basePath": "/ecosystem/api/v1",
    "paths": {
        "/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/vercel/connections": {
            "get": {
                "description": "List connections between Vercel project and TiDB cluster By cluster id.",
                "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/vercel.ListConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            },
            "post": {
                "description": "Add connection between Vercel project and TiDB cluster",
                "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": "Vercel project information and integration configuration id",
                        "name": "vercel_project",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/vercel.AddConnectionRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.MessageResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            },
            "delete": {
                "description": "Delete connection between Vercel project and TiDB cluster",
                "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
                    },
                    {
                        "type": "string",
                        "name": "vercel_project_id",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "name": "vercel_project_name",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.MessageResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/orgs/{org_id}/projects/{project_id}/dataapps/{data_app_id}/vercel/connections": {
            "post": {
                "description": "Add connection between Vercel project and TiDB Data app",
                "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 Data App ID",
                        "name": "data_app_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Vercel project information and integration configuration id",
                        "name": "vercel_project",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/vercel.AddDataAppConnectionRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.MessageResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            },
            "delete": {
                "description": "Delete connection between Vercel project and TiDB data app",
                "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 Data App ID",
                        "name": "data_app_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "type": "string",
                        "name": "vercel_project_id",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "name": "vercel_project_name",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.MessageResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/orgs/{org_id}/projects/{project_id}/serverless/clusters": {
            "post": {
                "description": "Create serverless cluster, return success when the cluster is ready.",
                "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
                    },
                    {
                        "description": "Serverless cluster info",
                        "name": "vercel_project",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/vercel.CreateClusterRequest"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.MessageResp"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/orgs/{org_id}/vercel/connections": {
            "get": {
                "description": "List connections between Vercel project and (cluster or data app) By TiDB Org.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "TiDB org ID",
                        "name": "org_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.TiDBOrgVercelConnection"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/vercel/access_token": {
            "post": {
                "description": "Get Vercel access token. For the concern of security, we will store the long-lived access token in our database",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "The code received when adding integration.",
                        "name": "code",
                        "in": "query",
                        "required": true
                    },
                    {
                        "type": "string",
                        "description": "The configuration ID of the integration(absent with External installation).",
                        "name": "configurationId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "The ID of the created project(only exist when installing via Deploy Button).",
                        "name": "currentProjectId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "An external ID or reference(only exist when installing via Deploy Button).",
                        "name": "external-id",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "The URL to redirect to after the integration has been installed(absent with External installation).",
                        "name": "next",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "The ID of the team (only if a team is selected).",
                        "name": "teamId",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.AccessTokenResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.AccessTokenResponse"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.AccessTokenResponse"
                        }
                    }
                }
            }
        },
        "/vercel/integration/configurations/{configuration_id}/connections": {
            "get": {
                "description": "List connections between Vercel project and (cluster or data app) By integration configuration.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "Vercel integration configuration id",
                        "name": "configuration_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.ListConnectionResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/vercel/integration/configurations/{configuration_id}/projects": {
            "get": {
                "description": "List Vercel projects accessible to the integration configuration.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "Vercel integration configuration information",
                        "name": "configuration_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "$ref": "#/definitions/vercel.RetrieveProjectResponse"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "$ref": "#/definitions/vercel.BaseResp"
                        }
                    }
                }
            }
        },
        "/vercel/webhooks": {
            "post": {
                "description": "Webhook for Vercel event https://vercel.com/docs/integrations/webhooks-overview#",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "type": "string",
                        "description": "Webhook request",
                        "name": "x-vercel-signature",
                        "in": "header",
                        "required": true
                    },
                    {
                        "description": "Vercel event callback",
                        "name": "vercel_event",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/vercel.VercelEvent"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ok",
                        "schema": {
                            "type": "string"
                        }
                    },
                    "400": {
                        "description": "error",
                        "schema": {
                            "type": "string"
                        }
                    },
                    "403": {
                        "description": "error",
                        "schema": {
                            "type": "string"
                        }
                    },
                    "500": {
                        "description": "error",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "vercel.AccessTokenResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                },
                "redirectUrl": {
                    "type": "string"
                }
            }
        },
        "vercel.AddConnectionRequest": {
            "type": "object",
            "required": [
                "configuration_id",
                "framework_type",
                "vercel_project_id",
                "vercel_project_name"
            ],
            "properties": {
                "branch_enabled": {
                    "type": "boolean"
                },
                "configuration_id": {
                    "type": "string"
                },
                "database": {
                    "type": "string"
                },
                "framework_type": {
                    "type": "string",
                    "enum": [
                        "General",
                        "Prisma",
                        "TiDB Cloud Serverless Driver"
                    ]
                },
                "vercel_project_id": {
                    "type": "string"
                },
                "vercel_project_name": {
                    "type": "string"
                }
            }
        },
        "vercel.AddDataAppConnectionRequest": {
            "type": "object",
            "required": [
                "configuration_id",
                "vercel_project_id",
                "vercel_project_name"
            ],
            "properties": {
                "configuration_id": {
                    "type": "string"
                },
                "vercel_project_id": {
                    "type": "string"
                },
                "vercel_project_name": {
                    "type": "string"
                }
            }
        },
        "vercel.BaseResp": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                }
            }
        },
        "vercel.ConnectionTargetType": {
            "type": "string",
            "enum": [
                "cluster",
                "dataApp"
            ],
            "x-enum-varnames": [
                "TargetTypeCluster",
                "TargetTypeDataApp"
            ]
        },
        "vercel.CreateClusterRequest": {
            "type": "object",
            "required": [
                "cluster_name",
                "configuration_id",
                "selected_vercel_projects"
            ],
            "properties": {
                "cluster_name": {
                    "type": "string"
                },
                "configuration_id": {
                    "type": "string"
                },
                "selected_vercel_projects": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "vercel.EventType": {
            "type": "string",
            "enum": [
                "project-removed",
                "project.removed",
                "integration-configuration-removed",
                "integration-configuration.removed",
                "deployment.created",
                "deployment.ready",
                "deployment.error",
                "deployment.canceled"
            ],
            "x-enum-varnames": [
                "ProjectRemovedDeprecated",
                "ProjectRemoved",
                "IntegrationRemovedDeprecated",
                "IntegrationRemoved",
                "DeploymentCreated",
                "DeploymentReady",
                "DeploymentError",
                "DeploymentCanceled"
            ]
        },
        "vercel.ListConnectionResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                },
                "connections": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/vercel.TiDBVercelConnectionVO"
                    }
                }
            }
        },
        "vercel.MessageResp": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                },
                "message": {
                    "type": "string"
                }
            }
        },
        "vercel.ProjectVO": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "vercel.Resp": {
            "type": "object",
            "properties": {
                "err_code": {
                    "type": "integer"
                },
                "err_msg": {
                    "type": "string"
                }
            }
        },
        "vercel.RetrieveProjectResponse": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                },
                "projects": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/vercel.ProjectVO"
                    }
                }
            }
        },
        "vercel.TiDBOrgVercelConnection": {
            "type": "object",
            "properties": {
                "base_resp": {
                    "$ref": "#/definitions/vercel.Resp"
                },
                "connections_array": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/vercel.TiDBTargetVercelConnectionVO"
                    }
                }
            }
        },
        "vercel.TiDBTargetVercelConnectionVO": {
            "type": "object",
            "required": [
                "tidb_org_id",
                "tidb_project_id"
            ],
            "properties": {
                "branch_enabled": {
                    "type": "boolean"
                },
                "projects": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/vercel.VercelProject"
                    }
                },
                "target_id": {
                    "type": "string"
                },
                "target_name": {
                    "type": "string"
                },
                "target_type": {
                    "$ref": "#/definitions/vercel.ConnectionTargetType"
                },
                "tidb_org_id": {
                    "type": "string"
                },
                "tidb_org_name": {
                    "type": "string"
                },
                "tidb_project_id": {
                    "type": "string"
                },
                "tidb_project_name": {
                    "type": "string"
                }
            }
        },
        "vercel.TiDBVercelConnectionVO": {
            "type": "object",
            "required": [
                "tidb_org_id",
                "tidb_project_id",
                "vercel_project_id",
                "vercel_project_name"
            ],
            "properties": {
                "branch_enabled": {
                    "type": "boolean"
                },
                "target_id": {
                    "type": "string"
                },
                "target_name": {
                    "type": "string"
                },
                "target_type": {
                    "$ref": "#/definitions/vercel.ConnectionTargetType"
                },
                "tidb_org_id": {
                    "type": "string"
                },
                "tidb_org_name": {
                    "type": "string"
                },
                "tidb_project_id": {
                    "type": "string"
                },
                "tidb_project_name": {
                    "type": "string"
                },
                "vercel_project_id": {
                    "type": "string"
                },
                "vercel_project_name": {
                    "type": "string"
                }
            }
        },
        "vercel.VercelEvent": {
            "type": "object",
            "properties": {
                "createdAt": {
                    "type": "integer"
                },
                "id": {
                    "type": "string"
                },
                "payload": {},
                "type": {
                    "$ref": "#/definitions/vercel.EventType"
                }
            }
        },
        "vercel.VercelProject": {
            "type": "object",
            "required": [
                "vercel_project_id",
                "vercel_project_name"
            ],
            "properties": {
                "vercel_project_id": {
                    "type": "string"
                },
                "vercel_project_name": {
                    "type": "string"
                }
            }
        }
    }
}