# Adding DWS Dump Tasks

#### Function

This API is used to add DWS dump tasks.

#### URI

POST /v2/{project_id}/streams/{stream_name}/transfer-tasks

Table 1 Path parameters
Parameter | Mandatory | Type | Description
--- | --- | --- | ---
project_id | Yes | String | Project ID.
stream_name | Yes | String | Name of the stream. Maximum: 60

#### Request Parameters

Table 2 Request header parameters
Parameter | Mandatory | Type | Description
--- | --- | --- | ---
X-Auth-Token | Yes | String | User token. The token can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 3 Request body parameters
Parameter | Mandatory | Type | Description
--- | --- | --- | ---

destination_type

Yes

String

Dump destination. Possible values:

- OBS: Data is dumped to OBS.
- MRS: Data is dumped to MRS.
- DLI: Data is dumped to DLI.
- CLOUDTABLE: Data is dumped to CloudTable.
- DWS: Data is dumped to DWS.

Default: NOWHERE

Enumeration values:

- DWS

dws_destination_descriptor | No | DWSDestinationDescriptorRequest object | Parameter list of the DWS to which data in the DIS stream will be dumped.

Table 4 DWSDestinationDescriptorRequest
Parameter | Mandatory | Type | Description
--- | --- | --- | ---
task_name | Yes | String | Name of the dump task. The task name consists of letters, digits, hyphens (-), and underscores (_). It must be a string of 1 to 64 characters.

agency_name

Yes

String

Name of the agency created on IAM. DIS uses an agency to access your specified resources. The parameters for creating an agency are as follows:

- Agency Type: Cloud service
- Cloud Service: DIS
- Validity Period: unlimited
- Scope: Global service, Project: OBS. Select the Tenant Administrator role for the global service project.

If agencies have been created, you can obtain available agencies from the agency list by using the "Listing Agencies " API.

This parameter cannot be left blank and the parameter value cannot exceed 64 characters.

If there are dump tasks on the console, the system displays a message indicating that an agency will be automatically created. The name of the automatically created agency is dis_admin_agency.

Maximum: 64

deliver_time_interval | Yes | Integer | User-defined interval at which data is imported from the current DIS stream into OBS. If no data is pushed to the DIS stream during the current interval, no dump file package will be generated. Value range: 30-900 Default value: 300 Unit: second Minimum: 30 Maximum: 900 Default: 300

consumer_strategy

No

String

Offset.

- LATEST: Maximum offset, indicating that the latest data will be extracted.
- TRIM_HORIZON: Minimum offset, indicating that the earliest data will be extracted.

Default value: LATEST

Default: LATEST

Enumeration values:

- LATEST
- TRIM_HORIZON

dws_cluster_name | Yes | String | Name of the DWS cluster that stores the data in the stream.
dws_cluster_id | Yes | String | ID of the DWS cluster to which will be dumped.
dws_database_name | Yes | String | Name of the DWS database that stores the data in the stream.
dws_schema | Yes | String | Schema of the DWS database to which data will be dumped.
dws_table_name | Yes | String | Name of the DWS table that stores the data in the stream.
dws_delimiter | Yes | String | Delimiter used to separate the columns in the DWS tables. The value can be a comma (,), semicolon (;), or vertical bar (|).
user_name | Yes | String | Username of the DWS database to which data will be dumped.
user_password | Yes | String | Password of the DWS database to which data will be dumped.
kms_user_key_name | Yes | String | Key created in Key Management Service (KMS) and used to encrypt the password of the DWS database.
kms_user_key_id | Yes | String | ID of the key created in KMS and used to encrypt the password of the DWS database.
obs_bucket_path | Yes | String | Name of the OBS bucket used to temporarily store data in the DIS stream.
file_prefix | No | String | Self-defined directory created in the OBS bucket and used to temporarily store data in the DIS stream. Directory levels are separated by slashes (/) and cannot start with slashes. The value can contain a maximum of 50 characters, including letters, digits, underscores (_), and slashes (/). This parameter is left empty by default.
retry_duration | No | String | Duration when you can constantly retry dumping data to DWS after the dump fails. If the dump time exceeds the value of this parameter, the data that fails to be dumped to DWS will be backed up to the OBS bucket/file_prefix/dws_error directory. Value range: 0-7,200 Unit: second Default value: 1,800
dws_table_columns | No | String | Column to be dumped to the DWS table. If the value is null or empty, all columns are dumped by default. For example, c1,c2 indicates that columns c1 and c2 in the schema are dumped to DWS. This parameter is left blank by default.
options | No | Options object | DWS fault tolerance option (used to specify various parameters of foreign table data).

Table 5 Options
Parameter | Mandatory | Type | Description
--- | --- | --- | ---

fill_missing_fields

No

String

Specifies whether to set the field to Null or enable an error message to be displayed in the error table when the last field in a row of the data source file is missing during database import.

Value range:

- true/on
- false/off

Default value: false/off

Enumeration values:

- true/on
- false/off

ignore_extra_data

No

String

Specifies whether to ignore excessive columns when the number of columns in a source data file exceeds that defined in the foreign table. This parameter is used only during data import.

Value range:

- true/on
- false/off

Default value: false/off

Enumeration values:

- true/on
- false/off

compatible_illegal_chars

No

String

Specifies whether to tolerate invalid characters during data import. Specifies whether to convert invalid characters based on the conversion rule and import them to the database, or to report an error and stop the import.

Value range:

- true/on
- false/off

Default value: false/off

Enumeration values:

- true/on
- false/off

reject_limit

No

String

Maximum number of data format errors allowed during the data import. If the number of data format errors does not reach the maximum, the data import is successful.

Value range:

- integer
- unlimited

Default value: 0, indicating that error information is returned immediately

error_table_name | No | String | Name of the error table that records data format errors. After the parallel import is complete, you can query the error information table to obtain the detailed error information.

#### Response Parameters

None

#### Example Requests

Adding DWS Dump Tasks

    POST https://{Endpoint}/v2/{project_id}/streams/{stream_name}/transfer-tasks

    {
      "destination_type" : "DWS",
      "dws_destination_descriptor" : {
        "task_name" : "dwstask",
        "consumer_strategy" : "LATEST",
        "agency_name" : "dis_admin_agency",
        "dws_cluster_name" : "dwscluster",
        "dws_cluster_id" : "f82dc227-3691-47eb-bca7-e7851f509b2a",
        "dws_database_name" : "postgres",
        "dws_schema" : "dbadmin",
        "dws_table_name" : "dwstablename",
        "dws_delimiter" : "",
        "user_name" : "dbadmin",
        "user_password" : "userpassword",
        "kms_user_key_name" : "kmskey",
        "kms_user_key_id" : "1e759f06-9188-4d21-afab-a75e57c04d2b",
        "obs_bucket_path" : "obsbucket",
        "file_prefix" : "",
        "deliver_time_interval" : 60,
        "retry_duration" : 1800,
        "options" : {
          "fill_missing_fields" : "false",
          "ignore_extra_data" : "false",
          "compatible_illegal_chars" : "false"
        }
      }
    }

#### Example Responses

None

#### Status Codes

Status Code | Description
--- | ---
201 | Normal response.

#### Error Codes

See Error Codes.

Parent topic: Dump Task Management