Create task¶
Select an existing file or directory from the connector and create an import task. Unstructured files are written to the data volume. Data rows for CSV, XLS, and XLSX are written to the target table.
POST $CLOUDSIGMA_API_BASE/task
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare personal access token and target workspace ID that can access the target workspace. Also prepare a connector for import, the connector file URI, and the target data volume or data table.
To upload local files, use Local Upload and create import task. To read data from a database object, use Create Database Structured Import Task.
Request body¶
Replace the connector, target resource, and field values in $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, and examples with actual values.
Import files into data volumes
curl -X POST "$CLOUDSIGMA_API_BASE/task" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"source_connector_id": "'"$CONNECTOR_ID"'",
"name": "'"$TASK_NAME"'",
"config_type": 1,
"source_config": {
"common_file_task_config": {
"uris": ["'"$CONNECTOR_DIRECTORY_URI"'"],
"load_mode_config": {
"load_interval_type": 4
},
"file_filter_config": {
"path_regex": ".*\\.(pdf|docx)$"
},
"unzip_keep_structure": false,
"dedup": {
"by": ["name", "md5"],
"strategy": "skip"
}
}
},
"volume_id": "'"$VOLUME_ID"'"
}'
Import CSV into existing data table
Structured files are written to data tables.
curl -X POST "$CLOUDSIGMA_API_BASE/task" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"source_connector_id": "'"$CONNECTOR_ID"'",
"name": "'"$TASK_NAME"'",
"config_type": 1,
"source_config": {
"common_file_task_config": {
"uris": ["'"$CONNECTOR_FILE_URI"'"],
"load_mode_config": {
"load_interval_type": 4
},
"table_config": {
"new_table": false,
"table_id": '"$TARGET_TABLE_ID"',
"isColumnName": true,
"columnNameRow": 1,
"rowStart": 2,
"csv": {
"separator": ","
},
"existed_table": [
{
"tableColumn": "'"$TARGET_COLUMN"'",
"column": "'"$FILE_COLUMN"'",
"col_num_in_file": 1
}
]
}
}
},
"volume_id": "'"$VOLUME_ID"'"
}'
Import files into data volumes
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Source connector ID, must be submitted as a JSON string. |
|
string |
Yes |
Task name. |
|
integer |
Yes |
File import is fixed to |
|
object |
Yes |
File sources and processing settings. File source and target table settings. |
|
array of string |
Yes |
File or directory URI in the connector. CSV file URI in the connector. |
|
integer |
Yes |
Execution frequency. |
|
string |
No |
Source path filter regular expression. |
|
boolean |
No |
Whether to preserve the directory structure when decompressing. |
|
array of string |
No |
Duplicate file judgment field. |
|
string |
No |
Duplicate file handling policy. |
|
string |
Yes |
Real non-empty volume ID. Even importing into a table requires this value and write permissions for the volume. |
|
boolean |
Yes |
|
|
integer |
Yes |
Target table ID already exists. |
|
boolean |
Yes |
Whether to use the specified row as a column name. |
|
integer |
Yes |
The row where the column name is located starts from 1. |
|
integer |
Yes |
The data starts from 1. |
|
string |
No |
CSV column separator. |
|
array of object |
Yes |
Mapping of file columns to target columns. |
|
string |
No |
Target table column name. |
|
string |
No |
Column names in the file. |
|
integer |
No |
Column number in the file. |
$VOLUME_ID in the example uses the actual volume ID that is writable in the current workspace. Table target configuration is preserved and cannot be filled with empty strings or invalid 0.
Requests can accept a legacy database one-time import or sync configuration for config_type=2, but these tasks are currently unavailable. Please use the database structured import interface. Connector file import and CSV file write tables are not subject to this restriction.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"task_id": "task_01"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Create a new import task ID. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "source_config is required",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Readable error message. |
|
null |
The error response is |