Updated on 2024-07-18 GMT+08:00

Creating a Migration Task

Function

This API is used to create a migration task. After a migration task is created, it automatically starts.

Precautions:

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

URI

POST /v1/{project_id}/objectstorage/task

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

Request

Request parameters

Table 2 Parameter description

Parameter

Mandatory

Type

Description

src_node

Yes

JSONObject

Specifies the source node information. For details, see Table 3.

dst_node

Yes

JSONObject

Specifies the destination node information. For details, see Table 6.

enableKMS

Yes

boolean

Specifies whether to use KMS encryption.

thread_num

Yes

int

Specifies the number of threads used by the migration task. The value cannot exceed 50.

description

No

String

Describes the task, which cannot exceed 255 characters. The following special characters are not allowed: <>()"'&

smnInfo

No

JSONObject

Specifies the field used for sending messages using the SMN service. For details, see Table 7.

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.

source_cdn

No

JSONObject

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. For details, see Table 8.

auto_restore

No

boolean

Specifies whether to automatically restore the archived data. The default value is No.

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

bandwidth_policy

No

JSONArray

Specifies the traffic limit rule. 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. For details, see Table 9.

task_type

No

String

Specifies the task type. The default value is object.

  • list: indicates that the system will migrate the objects in the object list file.
  • object: indicates that the system will migrate the selected objects and folders.
  • prefix: indicates that the system will migrate the objects with a specified prefix.
  • url_list: indicates that the system will migrate the objects in the URL list file.
    NOTE:

    When task_type is set to list or url_list, list_file in Table 3 is mandatory. When task_type is set to object or prefix, object_key in Table 3 is mandatory.

enable_failed_object_recording

No

Boolean

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

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

Table 3 src_node field description

Parameter

Mandatory

Type

Description

region

Yes

String

Specifies the region where the source bucket locates.

ak

Yes

String

Specifies the source bucket AK. Enter a maximum of 100 characters.

NOTE:

If task_type in Table 2 is set to url_list, ak is optional. For other task types, ak is mandatory.

sk

Yes

String

Specifies the source bucket SK. Enter a maximum of 100 characters.

NOTE:

If task_type in Table 2 is set to url_list, sk is optional. For other task types, sk is mandatory.

list_file

No

JSONObject

Specifies the object list file configuration. For details, see Table 4.

NOTE:

When task_type in Table 2 is set to list or url_list, list_file is mandatory.

object_key

No

String/JSONObject

Specifies the name of the object to be selected in the source bucket. The object name can be in the JSONObject format or a string.

If multiple source objects are selected, use JSONObject. For details, see Table 5.

NOTE:

When task_type in Table 2 is set to object or prefix, object_key is mandatory.

bucket

Yes

String

Specifies the name of the source bucket.

NOTE:

If task_type in Table 2 is set to url_list, bucket is optional. For other task types, bucket is mandatory.

app_id

No

String

app_id is mandatory only when the account of another cloud service provider has the appID identifier.

cloud_type

No

String

Specifies the source cloud service provider.

The value can be AWS, Aliyun, Tencent, HuaweiCloud, QingCloud, KingsoftCloud, Baidu, Qiniu, or URLSource (HTTP/HTTPS data source). The default value is Aliyun.

The default value is used if this parameter is not set or is left blank.

NOTE:

If task_type in Table 2 is set to url_list, cloud_type must be set to URLSource.

Table 4 list_file field description

Parameter

Mandatory

Type

Description

obs_bucket

Yes

String

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

NOTE:

Ensure that the selected list file is in the same region as the destination bucket. Otherwise, the task will fail to be created.

list_file_key

Yes

String

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

Table 5 object_key field description

Parameter

Mandatory

Type

Description

path

No

String

Specifies the root path of the cloud service provider, which is represented by an empty character string "". If this parameter is used, set this parameter to "". Otherwise, an error is reported.

keys

Yes

JSONArray

Specifies the source object parameter. The meaning of keys depends on the value of task_type.

  • When task_type is set to prefix, the character string in keys indicates the prefix of the object to be migrated.
  • When task_type is set to object, the character string ending with a slash (/) in keys indicates the folder to be migrated, and the character string not ending with a slash (/) indicates the file to be migrated.
Table 6 dst_node field description

Parameter

Mandatory

Type

Description

region

Yes

String

Specifies the region where the destination bucket locates.

NOTE:

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

ak

Yes

String

Specifies the destination bucket AK. Enter a maximum of 100 characters.

sk

Yes

String

Specifies the destination bucket SK. Enter a maximum of 100 characters.

object_key

Yes

String

Specifies the name of the object selected in the destination bucket. The value contains a maximum of 1024 characters.

bucket

Yes

String

Specifies the name of the destination bucket.

cloud_type

No

String

Specifies the destination cloud service provider.

The default value is HUAWEI CLOUD. The default value is used if this parameter is not set or is left blank.

Table 7 smnInfo field description

Parameter

Mandatory

Type

Description

topicUrn

Yes

String

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

NOTE:

The region to which topicUrn belongs must be the same as the region corresponding to the endpoint.

language

No

String

Specifies the management console language used by the current users.

Users can select zh-cn or en-us.

triggerConditions

Yes

JSONArray

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

The migration task state can be SUCCESS or FAIL.

  • FAIL: 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.
Table 8 source_cdn field structure

Parameter

Mandatory

Type

Description

protocol

Yes

String

Specifies the protocol type. The value can be HTTPS or HTTP.

domain

Yes

String

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

authentication_type

Yes

String

Specifies the authentication method.

  • If no authentication is required, set it to NONE.
  • Qiniu: QINIU_PRIVATE_AUTHENTICATION
  • Aliyun:

    ALIYUN_OSS_A, ALIYUN_OSS_B, and ALIYUN_OSS_C

  • KingsoftCloud: KSYUN_PRIVATE_AUTHENTICATION

authentication_key

No

String

Specifies the CDN authentication key.

  • 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.
Table 9 bandwidth_policy field description

Parameter

Mandatory

Type

Description

start

Yes

String

Specifies the start time of traffic limit. Format: hh:mm Example: 10:03

end

Yes

String

Specifies the end time of a traffic limit rule. Format: hh:mm

max_bandwidth

Yes

int

Specifies the maximum bandwidth (byte/s) allowed in a time segment. The value range is from 5 MB/s to 10 GB/s.

Response

Response parameters

Table 10 Response parameters

Parameter

Type

Description

id

long

Specifies the migration task ID.

task_name

String

Specifies the migration task name.

Examples

Example request

POST /v1/{project_id}/objectstorage/task

{
	"src_node": {
		"region": "source_region",
		"ak": "source_ak",
		"sk": "source_sk",
		"list_file": {
			"obs_bucket": "oms-file",
			"list_file_key": "object-keys.txt"
		},
		"bucket": "source_bucket",
		"cloud_type": XXX
	},
	"thread_num": 50,
	"enableKMS": true,
	"description": "xxx",
	"dst_node": {
		"region": "target_region",
		"ak": "target_ak",
		"sk": "target_sk",
		"object_key": "targetkey",
		"bucket": "targetbucket",
		"cloud_type": XXX
	},
	"smnInfo": {
		"topicUrn": "urn:smn:region:3cfb09080bd944d0b4cdd72ef26857bd:OMS",
		"triggerConditions": ["SUCCESS", "FAIL"],
		"language": "en-us"
	},
	"task_type": "list",
	"migrate_since": 123456789
}

Or

POST /v1/{project_id}/objectstorage/task
{
	"src_node": {
		"region": "source_region",
		"ak": "source_ak",
		"sk": "source_sk",
		"object_key": {
			"path": "",
			"keys": ["object1", "object2"]
		},
		"bucket": "source_bucket",
		"cloud_type": "XXX"
	},
	"thread_num": 50,
	"enableKMS": true,
	"description": "xxx",
	"dst_node": {
		"region": "target_region",
		"ak": "target_ak",
		"sk": "target_sk",
		"object_key": "targetkey",
		"bucket": "targetbucket",
		"cloud_type": "XXX"
	},
	"smnInfo": {
		"topicUrn": "urn:smn:region:3cfb09080bd944d0b4cdd72ef26857bd:OMS",
		"triggerConditions": ["SUCCESS", "FAIL"],
		"language": "en-us"
	},
	"source_cdn": {
		"protocol": "https",
		"domain": "xxx.xxx.xxx",
		"authentication_type": "NONE"
	},
        "bandwidth_policy": [ 
        { 
                "start": "00:00", 
                "end": "23:59", 
                "max_bandwidth": 50000000
        }
       ]
}

or (Specified URL list migration method)

POST /v1/{project_id}/objectstorage/task

{
    "src_node": {
           "list_file": {
                  "obs_bucket": "oms-file",
                  "list_file_key": "url-list.txt"
           },
           "cloud_type": "URLSource"
    },
    "thread_num": 50,
    "enableKMS": true,
    "description": "xxx",
    "dst_node": {
           "region": "target_region",
           "ak": "target_ak",
           "sk": "target_sk",
           "object_key": "targetkey",
           "bucket": "targetbucket"
    },
    "smnInfo": {
           "topicUrn": "urn:smn:region:3cfb09080bd944d0b4cdd72ef26857bd:OMS",
           "triggerConditions": ["SUCCESS", "FAIL"],
           "language": "en-us"
    },
    "task_type": "url_list",
    "migrate_since": 123456789
}

Example response

{
  "id": 16,
  "task_name": "task_name"
}

Status Codes

See Status Code.