{
  "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",
      "additionalProperties": {},
      "properties": {
        "@type": {
          "type": "string"
        }
      }
    },
    "AzureBlobTarget": {
      "type": "object",
      "properties": {
        "auth_type": {
          "description": "The Azure Blob URI of the export target.",
          "$ref": "#/definitions/ExportAzureBlobAuthType.Enum"
        },
        "sas_token": {
          "description": "The sas token. This field is input-only.",
          "type": "string"
        },
        "uri": {
          "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>.",
          "type": "string"
        }
      },
      "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": {
      "description": "Message for export resource.",
      "type": "object",
      "properties": {
        "export_id": {
          "description": "Output_only. The unique ID of the export.",
          "type": "string",
          "readOnly": true
        },
        "name": {
          "description": "Output_only. The unique name of the export.",
          "type": "string",
          "readOnly": true
        },
        "cluster_id": {
          "description": "Required. The cluster ID that export belong to.",
          "type": "string"
        },
        "created_by": {
          "description": "Output_only. The creator of the export.",
          "type": "string",
          "readOnly": true
        },
        "state": {
          "description": "Output_only. The state of the export.",
          "$ref": "#/definitions/ExportState.Enum",
          "readOnly": true
        },
        "export_options": {
          "description": "Optional. The options of the export.",
          "$ref": "#/definitions/ExportOptions"
        },
        "target": {
          "description": "Optional. The target of the export.",
          "$ref": "#/definitions/ExportTarget"
        },
        "reason": {
          "description": "Optional. The failed reason of the export.",
          "type": "string",
          "readOnly": true
        },
        "display_name": {
          "description": "Optional. The display name of the export. Default: SNAPSHOT_{snapshot_time}.",
          "type": "string"
        },
        "create_time": {
          "description": "Output_only. Timestamp when the export was created.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "update_time": {
          "description": "Output_only. Timestamp when the export was updated.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "complete_time": {
          "description": "Output_only. Timestamp when the export was completed.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "snapshot_time": {
          "description": "Output_only. Snapshot time of the export.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "expire_time": {
          "description": "Output_only. Expire time of the export.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      },
      "required": ["cluster_id"]
    },
    "ExportAzureBlobAuthType.Enum": {
      "description": " - SAS_TOKEN: The access method is sas token.",
      "type": "string",
      "enum": ["SAS_TOKEN"]
    },
    "ExportCompressionType.Enum": {
      "description": " - GZIP: Gzip compression.\n - SNAPPY: Snappy compression.\n - ZSTD: Zstd compression.\n - NONE: No compression.",
      "type": "string",
      "enum": ["GZIP", "SNAPPY", "ZSTD", "NONE"]
    },
    "ExportFileType.Enum": {
      "description": " - SQL: SQL type.\n - CSV: CSV type.\n - PARQUET: PARQUET type.",
      "type": "string",
      "enum": ["SQL", "CSV", "PARQUET"]
    },
    "ExportGcsAuthType.Enum": {
      "description": " - SERVICE_ACCOUNT_KEY: The access method is service account key.",
      "type": "string",
      "enum": ["SERVICE_ACCOUNT_KEY"]
    },
    "ExportOSSAuthType.Enum": {
      "description": " - ACCESS_KEY: The access method is access key.",
      "type": "string",
      "enum": ["ACCESS_KEY"]
    },
    "ExportOptions": {
      "type": "object",
      "properties": {
        "file_type": {
          "description": "Optional. The exported file type. Default: CSV.",
          "$ref": "#/definitions/ExportFileType.Enum"
        },
        "compression": {
          "description": "Optional. The compression of the export. Default is GZIP.",
          "$ref": "#/definitions/ExportCompressionType.Enum"
        },
        "filter": {
          "description": "Optional. The filter of the export. Default is whole cluster.",
          "$ref": "#/definitions/ExportOptions.Filter"
        },
        "csv_format": {
          "description": "Optional. The format of the csv.",
          "$ref": "#/definitions/ExportOptions.CSVFormat"
        },
        "parquet_format": {
          "description": "Optional. The format of the parquet.",
          "$ref": "#/definitions/ExportOptions.ParquetFormat"
        }
      }
    },
    "ExportOptions.CSVFormat": {
      "type": "object",
      "properties": {
        "separator": {
          "description": "Separator of each value in CSV files. It is recommended to use '|+|' or other uncommon character combinations. Default is ','.",
          "type": "string"
        },
        "delimiter": {
          "description": "Delimiter of string type variables in CSV files. Default is '\"'.",
          "type": "string"
        },
        "null_value": {
          "description": "Representation of null values in CSV files. Default is \"\\N\".",
          "type": "string"
        },
        "skip_header": {
          "description": "Export CSV files of the tables without header. Default is false.",
          "type": "boolean"
        }
      }
    },
    "ExportOptions.Filter": {
      "type": "object",
      "properties": {
        "sql": {
          "description": "Optional. Use SQL to filter the export.",
          "type": "string"
        },
        "table": {
          "description": "Optional. Use table-filter to filter the export.",
          "$ref": "#/definitions/ExportOptions.Filter.Table"
        }
      }
    },
    "ExportOptions.Filter.Table": {
      "type": "object",
      "properties": {
        "patterns": {
          "description": "Optional. The table-filter expressions.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "where": {
          "description": "Optional. Export only selected records.",
          "type": "string"
        },
        "partitions": {
          "description": "Optional. Export only selected partitions.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "ExportOptions.ParquetFormat": {
      "type": "object",
      "properties": {
        "compression": {
          "description": "Optional. The compression of the parquet. Default is ZSTD.",
          "$ref": "#/definitions/ExportParquetCompressionType.Enum"
        }
      }
    },
    "ExportParquetCompressionType.Enum": {
      "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.",
      "type": "string",
      "enum": ["GZIP", "SNAPPY", "ZSTD", "NONE"]
    },
    "ExportS3AuthType.Enum": {
      "description": " - ROLE_ARN: The access method is role arn.\n - ACCESS_KEY: The access method is access key.",
      "type": "string",
      "enum": ["ROLE_ARN", "ACCESS_KEY"]
    },
    "ExportService.CancelExportBody": {
      "type": "object"
    },
    "ExportService.CreateExportBody": {
      "type": "object",
      "properties": {
        "display_name": {
          "description": "Optional. The export display name. Default: SNAPSHOT_{snapshot_time}.",
          "type": "string"
        },
        "export_options": {
          "description": "Optional. The options of the export.",
          "$ref": "#/definitions/ExportOptions"
        },
        "target": {
          "description": "Optional. The target of the export.",
          "$ref": "#/definitions/ExportTarget"
        }
      }
    },
    "ExportState.Enum": {
      "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.",
      "type": "string",
      "enum": ["RUNNING", "SUCCEEDED", "FAILED", "CANCELED", "DELETED", "EXPIRED"]
    },
    "ExportTarget": {
      "type": "object",
      "properties": {
        "type": {
          "description": "Optional. The exported file type. Default is LOCAL.",
          "$ref": "#/definitions/ExportTargetType.Enum"
        },
        "s3": {
          "$ref": "#/definitions/S3Target"
        },
        "gcs": {
          "$ref": "#/definitions/GCSTarget"
        },
        "azure_blob": {
          "$ref": "#/definitions/AzureBlobTarget"
        },
        "oss": {
          "$ref": "#/definitions/OSSTarget"
        },
        "local_download_command": {
          "description": "Optional. The cli command to download the local export.",
          "type": "string",
          "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": {
          "description": "The GCS URI of the export target.",
          "type": "string"
        },
        "auth_type": {
          "description": "The auth method of the export target.",
          "$ref": "#/definitions/ExportGcsAuthType.Enum"
        },
        "service_account_key": {
          "type": "string",
          "title": "The service account key"
        }
      },
      "required": ["uri", "auth_type"]
    },
    "ListExportsResponse": {
      "type": "object",
      "properties": {
        "exports": {
          "description": "A list of exports.",
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/Export"
          }
        },
        "next_page_token": {
          "description": "Token provided to retrieve the next page of results.",
          "type": "string"
        },
        "total_size": {
          "description": "Total number of exports.",
          "type": "integer",
          "format": "int64"
        },
        "base_resp": {
          "$ref": "#/definitions/BaseResp"
        }
      }
    },
    "OSSTarget": {
      "type": "object",
      "properties": {
        "uri": {
          "description": "Required. The OSS URI, for example: oss://<bucket>/<path>.",
          "type": "string"
        },
        "auth_type": {
          "description": "Required. The auth method of the export target.",
          "$ref": "#/definitions/ExportOSSAuthType.Enum"
        },
        "access_key": {
          "description": "The access key.",
          "$ref": "#/definitions/OSSTarget.AccessKey"
        }
      },
      "required": ["uri", "auth_type"]
    },
    "OSSTarget.AccessKey": {
      "type": "object",
      "properties": {
        "id": {
          "description": "The access key id.",
          "type": "string"
        },
        "secret": {
          "description": "The access key secret. This field is input-only.",
          "type": "string"
        }
      },
      "required": ["id", "secret"]
    },
    "ParseTableFilterResponse": {
      "type": "object",
      "properties": {
        "tables": {
          "description": "The table list of the current cluster.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "S3Target": {
      "type": "object",
      "properties": {
        "uri": {
          "description": "Required. The URI of the s3 folder.",
          "type": "string"
        },
        "auth_type": {
          "description": "Required. The auth method of the export s3.",
          "$ref": "#/definitions/ExportS3AuthType.Enum"
        },
        "access_key": {
          "description": "Optional. The access key of the s3.",
          "$ref": "#/definitions/S3Target.AccessKey"
        },
        "role_arn": {
          "description": "Optional. The role arn of the s3.",
          "type": "string"
        }
      },
      "required": ["uri", "auth_type"]
    },
    "S3Target.AccessKey": {
      "type": "object",
      "properties": {
        "id": {
          "description": "The access key id of the s3.",
          "type": "string"
        },
        "secret": {
          "description": "Input_Only. The secret access key of the s3.",
          "type": "string"
        }
      },
      "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"
    }
  }
}
