{
  "swagger": "2.0",
  "info": {
    "title": "Export APIs for TiDB Cloud",
    "version": "alpha"
  },
  "tags": [
    {
      "name": "ExportService"
    }
  ],
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/exports": {
      "get": {
        "summary": "Provides a list of export jobs.",
        "operationId": "ExportService_ListExports",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ListExportsResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required.  The organize ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The cluster ID to list exports for.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "page_size",
            "description": "Optional. The maximum number of clusters to return. Default is 10.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "page_token",
            "description": "Optional. The page token from the previous response for pagination.",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "order_by",
            "description": "Optional. List exports order by, separated by comma, default is ascending. Example: \"foo, bar desc\". Supported field: create_time",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "display_name_like",
            "description": "Optional. List exports with filter",
            "in": "query",
            "required": false,
            "type": "string"
          }
        ],
        "tags": [
          "ExportService"
        ]
      },
      "post": {
        "summary": "Create an export job",
        "operationId": "ExportService_CreateExport",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Export"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required.  The organize ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ExportService.CreateExportBody"
            }
          }
        ],
        "tags": [
          "ExportService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/exports/{export_id}": {
      "get": {
        "summary": "Retrieves details of an export job.",
        "operationId": "ExportService_GetExport",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Export"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required.  The organize ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "export_id",
            "description": "Required. The ID of the export to be retrieved.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "ExportService"
        ]
      },
      "delete": {
        "summary": "Delete an export job",
        "operationId": "ExportService_DeleteExport",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Export"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required.  The organize ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "export_id",
            "description": "Required. The ID of the export to be retrieved.",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "tags": [
          "ExportService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}/exports/{export_id}:cancel": {
      "post": {
        "summary": "Cancel a specific export job.",
        "operationId": "ExportService_CancelExport",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Export"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required.  The organize ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID of export",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "export_id",
            "description": "Required. The ID of the export to be retrieved.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ExportService.CancelExportBody"
            }
          }
        ],
        "tags": [
          "ExportService"
        ]
      }
    },
    "/api/v1/serverless/orgs/{org_id}/projects/{project_id}/clusters/{cluster_id}:parseFilter": {
      "get": {
        "operationId": "ExportService_ParseTableFilter",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/ParseTableFilterResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/Status"
            }
          }
        },
        "parameters": [
          {
            "name": "org_id",
            "description": "Required. The organize ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "project_id",
            "description": "Required. The project ID.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "cluster_id",
            "description": "Required. The ID of the cluster.",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "patterns",
            "description": "Required. The table-filter expressions.",
            "in": "query",
            "required": true,
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "multi"
          }
        ],
        "tags": [
          "ExportService"
        ]
      }
    }
  },
  "definitions": {
    "Any": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "AzureBlobTarget": {
      "type": "object",
      "properties": {
        "auth_type": {
          "$ref": "#/definitions/ExportAzureBlobAuthType.Enum",
          "description": "The Azure Blob URI of the export target."
        },
        "sas_token": {
          "type": "string",
          "description": "The sas token. This field is input-only."
        },
        "uri": {
          "type": "string",
          "description": "The Azure Blob URI of the export target. For example: azure://<account>.blob.core.windows.net/<container>/<path> or https://<account>.blob.core.windows.net/<container>/<path>."
        }
      },
      "required": [
        "auth_type",
        "uri"
      ]
    },
    "BaseResp": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "title": "such as: request_id, trace_id"
        },
        "err_code": {
          "type": "string",
          "format": "int64"
        },
        "err_msg": {
          "type": "string"
        }
      }
    },
    "Export": {
      "type": "object",
      "properties": {
        "export_id": {
          "type": "string",
          "description": "Output_only. The unique ID of the export.",
          "readOnly": true
        },
        "name": {
          "type": "string",
          "description": "Output_only. The unique name of the export.",
          "readOnly": true
        },
        "cluster_id": {
          "type": "string",
          "description": "Required. The cluster ID that export belong to."
        },
        "created_by": {
          "type": "string",
          "description": "Output_only. The creator of the export.",
          "readOnly": true
        },
        "state": {
          "$ref": "#/definitions/ExportState.Enum",
          "description": "Output_only. The state of the export.",
          "readOnly": true
        },
        "export_options": {
          "$ref": "#/definitions/ExportOptions",
          "description": "Optional. The options of the export."
        },
        "target": {
          "$ref": "#/definitions/ExportTarget",
          "description": "Optional. The target of the export."
        },
        "reason": {
          "type": "string",
          "description": "Optional. The failed reason of the export.",
          "readOnly": true
        },
        "display_name": {
          "type": "string",
          "description": "Optional. The display name of the export. Default: SNAPSHOT_{snapshot_time}."
        },
        "create_time": {
          "type": "string",
          "format": "date-time",
          "description": "Output_only. Timestamp when the export was created.",
          "readOnly": true
        },
        "update_time": {
          "type": "string",
          "format": "date-time",
          "description": "Output_only. Timestamp when the export was updated.",
          "readOnly": true
        },
        "complete_time": {
          "type": "string",
          "format": "date-time",
          "description": "Output_only. Timestamp when the export was completed.",
          "readOnly": true
        },
        "snapshot_time": {
          "type": "string",
          "format": "date-time",
          "description": "Output_only. Snapshot time of the export.",
          "readOnly": true
        },
        "expire_time": {
          "type": "string",
          "format": "date-time",
          "description": "Output_only. Expire time of the export.",
          "readOnly": true
        },
        "snapshot_tso": {
          "type": "string",
          "description": "Output_only. The TiDB TSO (timestamp oracle) of the data snapshot captured\nfor this export, encoded as a string-formatted uint64. Use this exact value\nas the start position of a changefeed to get a consistent snapshot and\nincremental handoff with no gap or overlap.",
          "readOnly": true
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "description": "Message for export resource.",
      "required": [
        "cluster_id"
      ]
    },
    "ExportAzureBlobAuthType.Enum": {
      "type": "string",
      "enum": [
        "SAS_TOKEN"
      ],
      "description": " - SAS_TOKEN: The access method is sas token."
    },
    "ExportCSVDialect.Enum": {
      "type": "string",
      "enum": [
        "DEFAULT",
        "SNOWFLAKE",
        "BIGQUERY",
        "REDSHIFT"
      ],
      "description": " - DEFAULT: The standard CSV dialect.\n - SNOWFLAKE: The Snowflake CSV dialect.\n - BIGQUERY: The BigQuery CSV dialect.\n - REDSHIFT: The Redshift CSV dialect."
    },
    "ExportCompressionType.Enum": {
      "type": "string",
      "enum": [
        "GZIP",
        "SNAPPY",
        "ZSTD",
        "NONE"
      ],
      "description": " - GZIP: Gzip compression.\n - SNAPPY: Snappy compression.\n - ZSTD: Zstd compression.\n - NONE: No compression."
    },
    "ExportFileType.Enum": {
      "type": "string",
      "enum": [
        "SQL",
        "CSV",
        "PARQUET"
      ],
      "description": " - SQL: SQL type.\n - CSV: CSV type.\n - PARQUET: PARQUET type."
    },
    "ExportGcsAuthType.Enum": {
      "type": "string",
      "enum": [
        "SERVICE_ACCOUNT_KEY"
      ],
      "description": " - SERVICE_ACCOUNT_KEY: The access method is service account key."
    },
    "ExportOSSAuthType.Enum": {
      "type": "string",
      "enum": [
        "ACCESS_KEY"
      ],
      "description": " - ACCESS_KEY: The access method is access key."
    },
    "ExportOptions": {
      "type": "object",
      "properties": {
        "file_type": {
          "$ref": "#/definitions/ExportFileType.Enum",
          "description": "Optional. The exported file type. Default: CSV."
        },
        "compression": {
          "$ref": "#/definitions/ExportCompressionType.Enum",
          "description": "Optional. The compression of the export. Default is GZIP."
        },
        "filter": {
          "$ref": "#/definitions/ExportOptions.Filter",
          "description": "Optional. The filter of the export. Default is whole cluster."
        },
        "csv_format": {
          "$ref": "#/definitions/ExportOptions.CSVFormat",
          "description": "Optional. The format of the csv."
        },
        "parquet_format": {
          "$ref": "#/definitions/ExportOptions.ParquetFormat",
          "description": "Optional. The format of the parquet."
        },
        "snapshot_tso": {
          "type": "string",
          "description": "Optional. The TiDB TSO (timestamp oracle) at which to take the snapshot,\nencoded as a string-formatted uint64. When set, the export reads data as of\nthis exact TSO. This lets you pin a downstream changefeed to the same point\nso that the snapshot and the incremental stream hand off consistently with\nno gap or overlap. When not set, the snapshot is taken at the time the\nexport is created. The effective TSO is returned as `snapshot_tso` in the\nexport resource."
        },
        "escape_backslash": {
          "type": "boolean",
          "description": "Optional. Controls whether special characters are escaped with a backslash\n(\\) in the export file. When not set, the server default is used (escaping\nenabled)."
        },
        "column_selectors": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/ExportOptions.ColumnSelector"
          },
          "description": "Optional. Selects columns in the exported data for matching tables. When\nomitted, all columns are exported. Rules use Dumpling/TiCDC\ncolumn-selector syntax."
        }
      }
    },
    "ExportOptions.CSVFormat": {
      "type": "object",
      "properties": {
        "separator": {
          "type": "string",
          "description": "Separator of each value in CSV files. It is recommended to use '|+|' or other uncommon character combinations. Default is ','."
        },
        "delimiter": {
          "type": "string",
          "description": "Delimiter of string type variables in CSV files. Default is '\"'."
        },
        "null_value": {
          "type": "string",
          "description": "Representation of null values in CSV files. Default is \"\\N\"."
        },
        "skip_header": {
          "type": "boolean",
          "description": "Export CSV files of the tables without header. Default is false."
        },
        "dialect": {
          "$ref": "#/definitions/ExportCSVDialect.Enum",
          "description": "Optional. The CSV output dialect of the export. Default value is `DEFAULT`,\nwhich uses the standard CSV format. Set a warehouse-specific dialect (for\nexample `SNOWFLAKE`) so the exported CSV can be loaded losslessly."
        }
      }
    },
    "ExportOptions.ColumnSelector": {
      "type": "object",
      "properties": {
        "matcher": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Required. Table-filter patterns identifying the tables to which this rule applies."
        },
        "columns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Required. Column selection rules, such as [\"*\", \"!phone_number\"]."
        }
      },
      "required": [
        "matcher",
        "columns"
      ]
    },
    "ExportOptions.Filter": {
      "type": "object",
      "properties": {
        "sql": {
          "type": "string",
          "description": "Optional. Use SQL to filter the export."
        },
        "table": {
          "$ref": "#/definitions/ExportOptions.Filter.Table",
          "description": "Optional. Use table-filter to filter the export."
        }
      }
    },
    "ExportOptions.Filter.Table": {
      "type": "object",
      "properties": {
        "patterns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional. The table-filter expressions."
        },
        "where": {
          "type": "string",
          "description": "Optional. Export only selected records."
        },
        "partitions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional. Export only selected partitions."
        }
      }
    },
    "ExportOptions.ParquetFormat": {
      "type": "object",
      "properties": {
        "compression": {
          "$ref": "#/definitions/ExportParquetCompressionType.Enum",
          "description": "Optional. The compression of the parquet. Default is ZSTD."
        }
      }
    },
    "ExportParquetCompressionType.Enum": {
      "type": "string",
      "enum": [
        "GZIP",
        "SNAPPY",
        "ZSTD",
        "NONE"
      ],
      "description": " - GZIP: The parquet compression type is GZIP.\n - SNAPPY: The parquet compression type is SNAPPY.\n - ZSTD: The parquet compression type is ZSTD.\n - NONE: No compression."
    },
    "ExportS3AuthType.Enum": {
      "type": "string",
      "enum": [
        "ROLE_ARN",
        "ACCESS_KEY"
      ],
      "description": " - ROLE_ARN: The access method is role arn.\n - ACCESS_KEY: The access method is access key."
    },
    "ExportService.CancelExportBody": {
      "type": "object"
    },
    "ExportService.CreateExportBody": {
      "type": "object",
      "properties": {
        "display_name": {
          "type": "string",
          "description": "Optional. The export display name. Default: SNAPSHOT_{snapshot_time}."
        },
        "export_options": {
          "$ref": "#/definitions/ExportOptions",
          "description": "Optional. The options of the export."
        },
        "target": {
          "$ref": "#/definitions/ExportTarget",
          "description": "Optional. The target of the export."
        }
      }
    },
    "ExportState.Enum": {
      "type": "string",
      "enum": [
        "RUNNING",
        "SUCCEEDED",
        "FAILED",
        "CANCELED",
        "DELETED",
        "EXPIRED"
      ],
      "description": "Output Only. Export State.\n\n - RUNNING: The export job is being created.\n - SUCCEEDED: The export job is success.\n - FAILED: The export job is failed.\n - CANCELED: The export job is canceled.\n - DELETED: The export job is deleted.\n - EXPIRED: The export is expired, only local export will be expired."
    },
    "ExportTarget": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/ExportTargetType.Enum",
          "description": "Optional. The exported file type. Default is LOCAL."
        },
        "s3": {
          "$ref": "#/definitions/S3Target"
        },
        "gcs": {
          "$ref": "#/definitions/GCSTarget"
        },
        "azure_blob": {
          "$ref": "#/definitions/AzureBlobTarget"
        },
        "oss": {
          "$ref": "#/definitions/OSSTarget"
        },
        "local_download_command": {
          "type": "string",
          "description": "Optional. The cli command to download the local export.",
          "readOnly": true
        }
      }
    },
    "ExportTargetType.Enum": {
      "type": "string",
      "enum": [
        "LOCAL",
        "S3",
        "GCS",
        "AZURE_BLOB",
        "OSS"
      ],
      "title": "- LOCAL: Local target.\n - S3: S3 target.\n - GCS: gcs target\n - AZURE_BLOB: azure blob target\n - OSS: OSS target"
    },
    "GCSTarget": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "The GCS URI of the export target."
        },
        "auth_type": {
          "$ref": "#/definitions/ExportGcsAuthType.Enum",
          "description": "The auth method of the export target."
        },
        "service_account_key": {
          "type": "string",
          "title": "The service account key"
        }
      },
      "required": [
        "uri",
        "auth_type"
      ]
    },
    "ListExportsResponse": {
      "type": "object",
      "properties": {
        "exports": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Export"
          },
          "description": "A list of exports."
        },
        "next_page_token": {
          "type": "string",
          "description": "Token provided to retrieve the next page of results."
        },
        "total_size": {
          "type": "integer",
          "format": "int64",
          "description": "Total number of exports."
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      }
    },
    "OSSTarget": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "Required. The OSS URI, for example: oss://<bucket>/<path>."
        },
        "auth_type": {
          "$ref": "#/definitions/ExportOSSAuthType.Enum",
          "description": "Required. The auth method of the export target."
        },
        "access_key": {
          "$ref": "#/definitions/OSSTarget.AccessKey",
          "description": "The access key."
        }
      },
      "required": [
        "uri",
        "auth_type"
      ]
    },
    "OSSTarget.AccessKey": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The access key id."
        },
        "secret": {
          "type": "string",
          "description": "The access key secret. This field is input-only."
        }
      },
      "required": [
        "id",
        "secret"
      ]
    },
    "ParseTableFilterResponse": {
      "type": "object",
      "properties": {
        "tables": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The table list of the current cluster."
        }
      }
    },
    "S3Target": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "Required. The URI of the s3 folder."
        },
        "auth_type": {
          "$ref": "#/definitions/ExportS3AuthType.Enum",
          "description": "Required. The auth method of the export s3."
        },
        "access_key": {
          "$ref": "#/definitions/S3Target.AccessKey",
          "description": "Optional. The access key of the s3."
        },
        "role_arn": {
          "type": "string",
          "description": "Optional. The role arn of the s3."
        }
      },
      "required": [
        "uri",
        "auth_type"
      ]
    },
    "S3Target.AccessKey": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The access key id of the s3."
        },
        "secret": {
          "type": "string",
          "description": "Input_Only. The secret access key of the s3."
        }
      },
      "required": [
        "id",
        "secret"
      ]
    },
    "Status": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Any"
          }
        }
      }
    }
  },
  "securityDefinitions": {
    "bearer": {
      "type": "apiKey",
      "description": "Authentication token, prefixed by Bearer: 'Bearer token'",
      "name": "Authorization",
      "in": "header"
    }
  }
}
