Creating a Migration Task

Function

This API is used to create a migration task. After the migration task is created, it will be automatically started.

Constraints

  • A tenant can create a maximum of 1,500 migration tasks within 24 hours.
  • A tenant cannot create more migration tasks if the tenant already has 1,500 migration tasks in the Waiting to migrate state.

Debugging

You can debug this API in API Explorer.

URI

POST /v2/{project_id}/tasks

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Minimum length: 1 character

Maximum length: 1,024 characters

Request

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the token used for IAM authentication.

Minimum length: 1 character

Maximum length: 16,384 characters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

task_type

No

String

Specifies the task type.

list indicates migrating objects using an object list. url_list indicates migrating objects using a URL object list. object indicates migrating selected files or folders. prefix indicates migrating objects with specified prefixes.

Default value: object

Value options are as follows:

  • list
  • url_list
  • object
  • prefix

src_node

Yes

SrcNodeReq object

Specifies the source information.

dst_node

Yes

DstNodeReq object

Specifies the destination information.

enable_kms

No

Boolean

Specifies whether to enable the KMS encryption function. This function is disabled by default.

Default value: false

description

No

String

Provides supplementary information about the task, which cannot exceed 255 characters. The following special characters are not allowed: ^<>&"'

Minimum length: 0 characters

Maximum length: 255 characters

migrate_since

No

Long

Specifies a timestamp in second. The system migrates only the objects that are modified after the specified time. No time is specified by default.

Minimum value: 0

Maximum value: 9223372036854775807

Default value: 0

bandwidth_policy

No

Array of BandwidthPolicyDto objects

Specifies the traffic limit rules. Each element in the array corresponds to the maximum bandwidth of a time segment. A maximum of five time segments are allowed, and the time segments must not overlap.

source_cdn

No

SourceCdnReq object

Specifies whether to enable CDN support. If this parameter is contained, using CDN to download source data is supported. Otherwise, CDN is not supported. If CDN is enabled, the source objects to be migrated are obtained from the CDN domain name during migration.

smn_config

No

SmnConfig object

Specifies the SMN message sending configuration.

enable_restore

No

Boolean

Specifies whether to automatically restore the archive data.

If this function is enabled, archive data is automatically restored and migrated.

Default value: false

enable_failed_object_recording

No

Boolean

Specifies whether to record failed objects. This function is enabled by default.

If this function is enabled, information about objects that fail to be migrated will be stored in the destination bucket.

Default value: true

Table 4 SrcNodeReq field description

Parameter

Mandatory

Type

Description

cloud_type

No

String

Specifies the source cloud service provider. If task_type is not url_list, set this parameter to URLSource.

The value can be AWS, Azure, Aliyun, Tencent, HuaweiCloud, QingCloud, KingsoftCloud, Baidu, Qiniu, URLSource, or UCloud. The default value is Aliyun.

The default value is Aliyun.

region

No

String

Specifies the region where the source bucket is located. region is mandatory when task_type is not url_list.

Minimum length: 0 characters

Maximum length: 100 characters

ak

No

String

Specifies the AK for accessing the source bucket. This parameter is mandatory when task_type is not url_list.

Minimum length: 0 characters

Maximum length: 100 characters

sk

No

String

Specifies the SK for accessing the destination bucket. This parameter is mandatory when task_type is not url_list.

Minimum length: 0 characters

Maximum length: 100 characters

security_token

No

String

Specifies the temporary token for accessing the source bucket.

Minimum length: 0 characters

Maximum length: 16,384 characters

app_id

No

String

This parameter is mandatory when cloud_type is Tencent.

Minimum length: 0 characters

Maximum length: 255 characters

bucket

No

String

Specifies the name of the source bucket. bucket is mandatory when task_type is not url_list.

Minimum length: 0 characters

Maximum length: 1,024 characters

object_key

No

Array of strings

If task-type is set to object, this parameter specifies the names of the objects to be migrated. The character strings ending with a slash (/) indicate the folders to be migrated, and the character strings not ending with a slash (/) indicate the files to be migrated. If task_type is set to prefix, this parameter indicates the name prefixes of the objects to be migrated. If you want to migrate the entire bucket, set this parameter to [""].

Minimum length: 0 characters

Maximum length: 1,024 characters

list_file

No

ListFile object

Specifies the list file configuration. list_file is mandatory when task_type is set to list or url_list.

Table 5 ListFile field description

Parameter

Mandatory

Type

Description

list_file_key

Yes

String

Specifies the object names in the object list file or URL list file.

Minimum length: 1 character

Maximum length: 1,024 characters

obs_bucket

Yes

String

Specifies the name of the OBS bucket for storing the object list files.

Ensure that the OBS bucket is in the same region as the destination bucket, or the task will fail to be created.

Minimum length: 0 characters

Maximum length: 1,024 characters

Table 6 DstNodeReq field description

Parameter

Mandatory

Type

Description

ak

Yes

String

Specifies the AK for accessing the destination bucket.

Minimum length: 0 characters

Maximum length: 100 characters

sk

Yes

String

Specifies the SK for accessing the destination bucket.

Minimum length: 0 characters

Maximum length: 100 characters

security_token

No

String

Specifies the temporary token for accessing the destination bucket.

Minimum length: 0 characters

Maximum length: 16,384 characters

bucket

Yes

String

Specifies the name of the destination bucket.

Minimum length: 0 characters

Maximum length: 1,024 characters

save_prefix

No

String

Specifies the path prefix in the destination bucket. The prefix is added before the object key to form a new key. The length of the new key cannot exceed 1,024 characters.

Minimum length: 0 characters

Maximum length: 1,024 characters

region

Yes

String

Specifies the region where the destination bucket is located.

The value must be the same as that of the service endpoint.

Minimum length: 0 characters

Maximum length: 100 characters

Table 7 BandwidthPolicyDto field description

Parameter

Mandatory

Type

Description

end

Yes

String

Specifies the end time of the traffic limit rule. The format is hh:mm, for example, 12:03.

max_bandwidth

Yes

Long

Specifies the maximum traffic bandwidth allowed in the specified time segment. The unit is byte/s. The value ranges from 1048576 bytes/s (equivalent to 1 MB/s) to 209715200 bytes/s (equivalent to 200 MB/s).

Minimum value: 1048576

Maximum value: 209715200

start

Yes

String

Specifies the start time of the traffic limit rule. The format is hh:mm, for example, 12:03.

Table 8 SourceCdnReq

Parameter

Mandatory

Type

Description

authentication_key

No

String

Specifies the CDN authentication key. If the CDN authentication is required, this parameter is mandatory.

If no authorization is required, do not set this parameter. Qiniu: You do not need to set this parameter. Aliyun: Set this parameter based on the value of authentication_type. KingsoftCloud: You do not need to set this parameter.

Minimum length: 0 characters

Maximum length: 255 characters

authentication_type

Yes

String

Specifies the authentication type.

Default value: None

Value options are as follows:

  • NONE
  • QINIU_PRIVATE_AUTHENTICATION
  • ALIYUN_OSS_A
  • ALIYUN_OSS_B
  • ALIYUN_OSS_C
  • KSYUN_PRIVATE_AUTHENTICATION

domain

Yes

String

Specifies the domain name from which to obtain objects to be migrated.

Minimum length: 0 characters

Maximum length: 1,024 characters

protocol

Yes

String

Specifies the protocol type.

Value options are as follows:

  • HTTP
  • HTTPS
Table 9 SmnConfig field description

Parameter

Mandatory

Type

Description

language

No

String

Specifies the management console language chosen by you.

The value can be zh-cn or en-us.

Default value: en-us

Value options are as follows:

  • zh-cn
  • en-us

topic_urn

Yes

String

Specifies the SMN message topic URN bound to a migration task.

Minimum length: 0 characters

Maximum length: 1,024 characters

trigger_conditions

Yes

Array of strings

Specifies the trigger conditions of sending messages using SMN. The message varies depending on the status of the migration task.

The migration task state can be SUCCESS or FAILURE.

  • FAILURE: indicates that an SMN message will be sent after the migration task fails.
  • SUCCESS: indicates that an SMN message will be sent after the migration task succeeds.

Response

Status code: 201

Table 10 Response body parameters

Parameter

Type

Description

id

Long

Specifies the task ID.

Minimum value: 0

Maximum value: 999999999999999

task_name

String

Specifies the task name.

Minimum length: 0 characters

Maximum length: 2,048 characters

Status code: 400

Table 11 Response body parameters

Parameter

Type

Description

error_msg

String

Specifies the error message.

error_code

String

Specifies the error code.

Example Request

  • Create an object list migration task, use CDN to migrate data, enable traffic limit by time segment, and enable migration result notification.
    POST https://{endpoint}/v2/{project_id}/tasks
    
    {
      "task_type" : "list",
      "src_node" : {
        "cloud_type" : "HuaweiCloud",
        "region" : "cn-north-1",
        "bucket" : "src_bucket",
        "ak" : "src_ak",
        "sk" : "src_sk",
        "list_file" : {
          "obs_bucket" : "list_file_bucket",
          "list_file_key" : "object_list_file.txt"
        }
      },
      "dst_node" : {
        "region" : "cn-north-1",
        "ak" : "dst_ak",
        "sk" : "dst_sk",
        "bucket" : "dst_bucket"
      },
      "enable_kms" : false,
      "enable_failed_object_recording" : true,
      "description" : "xxx",
      "migrate_since" : 123456789,
      "bandwidth_policy" : [ {
        "start" : "00:00",
        "end" : "23:59",
        "max_bandwidth" : 50000000
      } ],
      "source_cdn" : {
        "protocol" : "https",
        "domain" : "xxx.xxx.xxx",
        "authentication_type" : "ALIYUN_OSS_A",
        "authentication_key" : "xxx"
      },
      "smn_config" : {
        "topic_urn" : "urn:smn:region:4cf2090802d94440b4cdd72ef26857b2:OMS",
        "trigger_conditions" : [ "SUCCESS", "FAILURE" ],
        "language" : "en-us"
      }
    }
  • Create an object list migration task, use CDN to migrate data, enable traffic limit by time segment, and enable migration result notification.
    POST https://{endpoint}/v2/{project_id}/tasks
    
    {
      "task_type" : "object",
      "src_node" : {
        "cloud_type" : "HuaweiCloud",
        "region" : "cn-north-1",
        "bucket" : "src_bucket",
        "ak" : "src_ak",
        "sk" : "src_sk",
        "object_key" : [ "file1.xxx", "file2.xxx", "path1/" ]
      },
      "dst_node" : {
        "region" : "cn-north-1",
        "ak" : "dst_ak",
        "sk" : "dst_sk",
        "bucket" : "dst_bucket"
      },
      "enable_kms" : false,
      "enable_failed_object_recording" : true,
      "description" : "xxx",
      "migrate_since" : 123456789,
      "bandwidth_policy" : [ {
        "start" : "00:00",
        "end" : "23:59",
        "max_bandwidth" : 50000000
      } ],
      "source_cdn" : {
        "protocol" : "https",
        "domain" : "xxx.xxx.xxx",
        "authentication_type" : "ALIYUN_OSS_A",
        "authentication_key" : "xxx"
      },
      "smn_config" : {
        "topic_urn" : "urn:smn:region:4cf2090802d94440b4cdd72ef26857b2:OMS",
        "trigger_conditions" : [ "SUCCESS", "FAILURE" ],
        "language" : "en-us"
      }
    }
  • Create a URL list migration task.
    POST https://{endpoint}/v2/{project_id}/tasks
    
    {
      "task_type" : "url_list",
      "src_node" : {
        "cloud_type" : "URLSource",
        "list_file" : {
          "obs_bucket" : "list_file_bucket",
          "list_file_key" : "object_list_file.txt"
        }
      },
      "dst_node" : {
        "region" : "cn-north-1",
        "ak" : "dst_ak",
        "sk" : "dst_sk",
        "bucket" : "dst_bucket"
      },
      "enable_kms" : false,
      "enable_failed_object_recording" : true,
      "description" : "xxx"
    }
  • Create a prefix migration task.
    POST https://{endpoint}/v2/{project_id}/tasks
    
    {
      "task_type" : "prefix",
      "src_node" : {
        "cloud_type" : "HuaweiCloud",
        "region" : "cn-north-1",
        "bucket" : "src_bucket",
        "ak" : "src_ak",
        "sk" : "src_sk",
        "object_key" : [ "abc", "123", "prefix3", "path/prefix4" ]
      },
      "dst_node" : {
        "region" : "cn-north-1",
        "ak" : "dst_ak",
        "sk" : "dst_sk",
        "bucket" : "dst_bucket"
      },
      "enable_kms" : false,
      "enable_failed_object_recording" : true,
      "description" : "xxx"
    }

Example Response

Status code: 201

Created

{
  "id" : 200429548242937,
  "task_name" : "task_name"
}

Status Codes

Status Code

Description

201

Created

400

Bad Request

Error Codes

See Error Codes.