Create a Migration Task Group
Function
This API is used to create a migration task group. After a migration task group is created, migration tasks are automatically created in the task group. You do not need to call APIs to create migration tasks.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
oms:taskgroup:create
Write
taskgroup *
-
-
-
URI
POST /v2/{project_id}/taskgroups
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
The project ID. Minimum: 1 Maximum: 1024 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
The token used for IAM authentication. Minimum: 1 Maximum: 16384 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
src_node |
Yes |
TaskGroupSrcNode object |
The source information. |
|
description |
No |
String |
The task group description, which cannot exceed 255 characters. The following special characters are not allowed: ^<>&"' Minimum: 0 Maximum: 255 |
|
dst_node |
Yes |
TaskGroupDstNode object |
The destination information. |
|
enable_metadata_migration |
No |
Boolean |
Whether metadata migration is enabled. This function is disabled by default. Even if this function is disabled, the Content-Type metadata will still be migrated to ensure a successful migration. Default: false |
|
enable_failed_object_recording |
No |
Boolean |
Whether the function of recording failed objects is enabled. Default: true |
|
enable_restore |
No |
Boolean |
Whether automatic restoration of archived data is enabled. This function is disabled by default. If this function is enabled, archived data is automatically restored and migrated. |
|
task_type |
No |
String |
The task type. The default value is PREFIX. LIST: migrates only the objects recorded in a predefined object list. URL_LIST: migrates only the objects recorded in a predefined URL list. PREFIX: migrates only the objects that match the specified prefixes. Enumeration values: |
|
bandwidth_policy |
No |
Array of BandwidthPolicyDto objects |
The traffic limiting rules. Each element in the array corresponds to the maximum bandwidth in a time period. A maximum of five periods are allowed, and the periods cannot overlap. Array Length: 0 - 5 |
|
smn_config |
No |
SmnConfig object |
The configuration of SMN message sending. |
|
source_cdn |
No |
SourceCdnReq object |
Whether migration from CDN is enabled. If this field is included, migration from CDN is supported. Otherwise, it is not supported. If migration from CDN is enabled, the source objects to be migrated are obtained from the specified CDN domain name during migration. |
|
migrate_since |
No |
Long |
A timestamp in seconds. Only source objects that are modified after the specified timestamp will be migrated. No time is specified by default. Minimum: 0 Maximum: 9223372036854775807 Default: 0 |
|
object_overwrite_mode |
No |
String |
How a source object handles its paired destination object, either overwriting the object or skipping the migration. The default value is SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE.NO_OVERWRITE indicates the system never allows overwriting. The system always skips source objects and keeps their paired destination objects.SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE: The system allows overwriting based on the results of size or modification time checks. This is the default value. If a source object has the same name as the paired destination object, the system compares the sizes and last modification time of the source and destination objects to determine whether to overwrite the destination object. The encryption status of the source and destination objects must be the same. If the source object has a different size or was last modified more recently than its paired destination object, the destination object will be overwritten.CRC64_COMPARISON_OVERWRITE: The system allows overwriting if the source and destination objects have different CRC64 checksums. This option is only available for migration within Huawei Cloud or from Alibaba Cloud or Tencent Cloud. If a source object has a CRC64 checksum different from its paired destination object, the destination object will be overwritten. The encryption status of the source and destination objects must be the same. If there are no CRC64 checksums in the metadata, the SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE value is used.FULL_OVERWRITE indicates the system always allows overwriting. The system always allows source objects to overwrite their paired destination objects. Enumeration values: |
|
dst_storage_policy |
No |
String |
The destination storage class. This parameter is required only when the destination is Huawei Cloud OBS. The default value is STANDARD. STANDARD: Huawei Cloud OBS Standard storage IA: Huawei Cloud OBS Infrequent Access storage ARCHIVE: Huawei Cloud OBS Archive storage DEEP_ARCHIVE: Huawei Cloud OBS Deep Archive storage SRC_STORAGE_MAPPING: The source storage class is retained and mapped to Huawei Cloud OBS storage class. Default: STANDARD Minimum: 0 Maximum: 128 Enumeration values: |
|
consistency_check |
No |
String |
The method for checking whether objects are consistent before and after migration. The encryption status of the source and destination objects must be the same. The check method and results will be recorded in the object list. The default value is size_last_modified.size_last_modified: The default value. The system checks object consistency with object size and last modification time. If the source and destination objects have the same size and the destination's last modification time is not earlier than the source's, the system considers the source object does not need to be migrated or has been already migrated successfully.crc64: This option is only available for migration on Huawei Cloud or from Alibaba Cloud or Tencent Cloud. If a source object and its paired destination object have CRC64 checksums in the metadata, the checksums are checked. Otherwise, their sizes and last modification times are checked.no_check: This option is only available for migration of HTTP/HTTPS data. This option takes effect for source objects whose sizes cannot be obtained from the Content-Length field in the standard HTTP protocol. In this case, the migration is considered successful once the data is downloaded successfully, without requiring additional data check. These source objects will overwrite their paired destination objects directly. If the size of a source object can be obtained from the Content-Length field in the standard HTTP protocol, its size and last modification time will be checked. Default: size_last_modified Enumeration values: |
|
enable_requester_pays |
No |
Boolean |
Whether Requester Pays is enabled. If this function is enabled, the requester pays for the request and data transmission. Default: false |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
ak |
No |
String |
The AK for accessing the source bucket. Enter a maximum of 100 characters. This parameter is mandatory when task_type is not url_list. Minimum: 0 Maximum: 100 |
|
sk |
No |
String |
The SK for accessing the destination bucket. Enter a maximum of 100 characters. This parameter is mandatory when task_type is not url_list. Minimum: 0 Maximum: 100 |
|
connection_string |
No |
String |
The connection string, which is used for Microsoft Azure Blob authentication. Minimum: 0 Maximum: 2048 |
|
json_auth_file |
No |
String |
The file used for Google Cloud Storage authentication. Minimum: 0 Maximum: 65535 |
|
app_id |
No |
String |
Tencent Cloud app ID. This parameter is mandatory when cloud_type is Tencent. You can obtain the value from the account information page on the Tencent Cloud console. Minimum: 0 Maximum: 255 |
|
region |
No |
String |
The region where the source bucket is located. region is mandatory when task_type is not url_list. Minimum: 0 Maximum: 100 |
|
object_key |
No |
Array of strings |
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: 0 Maximum: 1024 Array Length: 0 - 500 |
|
bucket |
No |
String |
The source bucket. Minimum: 0 Maximum: 1024 |
|
cloud_type |
No |
String |
The source cloud service provider. If task_type is URL_LIST, this parameter is mandatory and must be URLSource. The value can be AWS, Azure, Aliyun, Tencent, HuaweiCloud, QingCloud, KingsoftCloud, Baidu, Qiniu, URLSource, Google, or UCloud. The default value is Aliyun. Default: Aliyun Minimum: 0 Maximum: 100 |
|
list_file |
No |
ListFile object |
The list file configuration. list_file is mandatory when task_type is set to LIST* or URL_LIST. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
list_file_key |
Yes |
String |
The object names in the object list file or URL list file. Minimum: 1 Maximum: 1024 |
|
obs_bucket |
Yes |
String |
The name of the OBS bucket for storing the object list files. Ensure that this bucket is in the same region as the destination bucket, or the task creation will fail. Minimum: 0 Maximum: 1024 |
|
list_file_num |
No |
String |
The number of stored object list files. Minimum: 0 Maximum: 65535 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
ak |
Yes |
String |
The AK for accessing the destination bucket. Enter a maximum of 100 characters. Minimum: 0 Maximum: 100 |
|
sk |
Yes |
String |
The SK for accessing the destination bucket. Enter a maximum of 100 characters. Minimum: 0 Maximum: 100 |
|
region |
Yes |
String |
The region where the destination bucket is located. The value must be the same as that of the service endpoint. Minimum: 0 Maximum: 100 |
|
bucket |
Yes |
String |
The destination bucket. Minimum: 0 Maximum: 1024 |
|
cloud_type |
No |
String |
The destination cloud. Huawei Cloud is the destination by default. The default value is HEC. Default: HEC Minimum: 0 Maximum: 100 |
|
save_prefix |
No |
String |
The path prefix used to organize object locations in the destination bucket. The prefix is added before an object key to form a new key. The length of the new key cannot exceed 1,024 characters. Minimum: 0 Maximum: 1024 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
end |
Yes |
String |
The time when traffic limiting is ended. The format is hh:mm, for example, 12:03. |
|
max_bandwidth |
Yes |
Long |
The maximum traffic bandwidth allowed in the specified period. The unit is byte/s. The value ranges from 1,048,576 bytes/s (equivalent to 1 MB/s) to 209,715,200 bytes/s (equivalent to 200 MB/s). Minimum: 1048576 Maximum: 209715200 |
|
start |
Yes |
String |
The time when traffic limiting is started. The format is hh:mm, for example, 12:03. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
authentication_key |
No |
String |
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 authentication_type. KingsoftCloud: You do not need to set this parameter. Minimum: 0 Maximum: 255 |
|
authentication_type |
Yes |
String |
The authentication type. The value can be: NONE: public access without authentication type QINIU_PRIVATE_AUTHENTICATION: Qiniu private URL signature ALIYUN_OSS_A: Alibaba Cloud URL signature, simple and universal ALIYUN_OSS_B: Alibaba Cloud header signature, used for API calling ALIYUN_OSS_C: Alibaba Cloud STS temporary security token, the most secure KSYUN_PRIVATE_AUTHENTICATION: Kingsoft Cloud private URL signature AZURE_SAS_TOKEN: Microsoft Azure shared access signature, flexible and secure TENCENT_COS_A: Tencent Cloud multi-signature scenarios (not recommended) TENCENT_COS_B: Tencent Cloud single-signature scenarios, the most secure TENCENT_COS_C: Tencent Cloud header signature, used for API calling TENCENT_COS_D: Tencent Cloud header signature, used for API calling Default: NONE Enumeration values: |
|
domain |
Yes |
String |
The domain name used to obtain objects to be migrated. Minimum: 0 Maximum: 1024 |
|
protocol |
Yes |
String |
The protocol type. HTTP and HTTPS are supported. Enumeration values: |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
group_id |
String |
The ID of the created migration task group. Minimum: 1 Maximum: 100 |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_msg |
String |
Error message. |
|
error_code |
String |
Error code. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_msg |
String |
Error message. |
|
error_code |
String |
Error code. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_msg |
String |
Error message. |
|
error_code |
String |
Error code. |
Example Requests
-
This example creates a migration task group to migrate objects recorded in the TXT object list files stored in the hw/ directory to the destination bucket zzww.
POST https://{endpoint}/v2/{project_id}/taskgroups { "enable_failed_object_recording" : true, "src_node" : { "bucket" : "hw-src", "cloud_type" : "HuaweiCloud", "ak" : "******", "sk" : "******", "region" : "cn-north-7", "list_file" : { "obs_bucket" : "list-file-bucket", "list_file_key" : "hw/" } }, "task_type" : "LIST", "enable_restore" : false, "dst_node" : { "bucket" : "zzww", "cloud_type" : "HEC", "ak" : "******", "sk" : "******", "region" : "cn-north-7" }, "enable_metadata_migration" : true } -
This example creates a migration task group to migrate objects prefixed with Objectlist from the source bucket src-bucket to the destination bucket dst-bucket.
POST https://{endpoint}/v2/{project_id}/taskgroups { "src_node" : { "region" : "cn-north-4", "ak" : "******", "sk" : "******.", "bucket" : "src-bucket", "cloud_type" : "HuaweiCloud", "object_key" : [ "Objectlist" ] }, "dst_node" : { "region" : "cn-north-4", "ak" : "******", "sk" : "******", "bucket" : "dst-bucket" }, "task_type" : "PREFIX", "enable_failed_object_recording" : true, "bandwidth_policy" : [ { "max_bandwidth" : 1048576, "start" : "00:01", "end" : "23:59" } ] } -
This example creates a migration task group to migrate objects recorded in the TXT URL list files stored in the test01/ directory to the destination bucket jjyy.
POST https://{endpoint}/v2/{project_id}/taskgroups { "src_node" : { "cloud_type" : "URLSource", "list_file" : { "obs_bucket" : "url-file-bucket", "list_file_key" : "test01/" } }, "description" : "", "dst_node" : { "region" : "cn-north-4", "ak" : "******", "sk" : "******.", "bucket" : "jjyy", "cloud_type" : "HEC" }, "enable_failed_object_recording" : true, "enable_restore" : false, "enable_metadata_migration" : false, "task_type" : "URL_LIST" }
Example Responses
Status code: 200
Created
{
"group_id" : "9ad15f51-778f-4684-b47b-4c5109c0e105"
}
SDK Sample Code
The SDK sample code is as follows.
-
This example creates a migration task group to migrate objects recorded in the TXT object list files stored in the hw/ directory to the destination bucket zzww.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.oms.v2.region.OmsRegion; import com.huaweicloud.sdk.oms.v2.*; import com.huaweicloud.sdk.oms.v2.model.*; public class CreateTaskGroupSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); OmsClient client = OmsClient.newBuilder() .withCredential(auth) .withRegion(OmsRegion.valueOf("<YOUR REGION>")) .build(); CreateTaskGroupRequest request = new CreateTaskGroupRequest(); CreateTaskGroupReq body = new CreateTaskGroupReq(); TaskGroupDstNode dstNodebody = new TaskGroupDstNode(); dstNodebody.withAk("******") .withSk("******") .withRegion("cn-north-7") .withBucket("zzww") .withCloudType("HEC"); ListFile listFileSrcNode = new ListFile(); listFileSrcNode.withListFileKey("hw/") .withObsBucket("list-file-bucket"); TaskGroupSrcNode srcNodebody = new TaskGroupSrcNode(); srcNodebody.withAk("******") .withSk("******") .withRegion("cn-north-7") .withBucket("hw-src") .withCloudType("HuaweiCloud") .withListFile(listFileSrcNode); body.withTaskType(CreateTaskGroupReq.TaskTypeEnum.fromValue("LIST")); body.withEnableKms(false); body.withEnableRestore(false); body.withEnableFailedObjectRecording(true); body.withEnableMetadataMigration(true); body.withDstNode(dstNodebody); body.withSrcNode(srcNodebody); request.withBody(body); try { CreateTaskGroupResponse response = client.createTaskGroup(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
This example creates a migration task group to migrate objects prefixed with Objectlist from the source bucket src-bucket to the destination bucket dst-bucket.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.oms.v2.region.OmsRegion; import com.huaweicloud.sdk.oms.v2.*; import com.huaweicloud.sdk.oms.v2.model.*; import java.util.List; import java.util.ArrayList; public class CreateTaskGroupSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); OmsClient client = OmsClient.newBuilder() .withCredential(auth) .withRegion(OmsRegion.valueOf("<YOUR REGION>")) .build(); CreateTaskGroupRequest request = new CreateTaskGroupRequest(); CreateTaskGroupReq body = new CreateTaskGroupReq(); List<BandwidthPolicyDto> listbodyBandwidthPolicy = new ArrayList<>(); listbodyBandwidthPolicy.add( new BandwidthPolicyDto() .withEnd("23:59") .withMaxBandwidth(1048576L) .withStart("00:01") ); TaskGroupDstNode dstNodebody = new TaskGroupDstNode(); dstNodebody.withAk("******") .withSk("******") .withRegion("cn-north-4") .withBucket("dst-bucket"); List<String> listSrcNodeObjectKey = new ArrayList<>(); listSrcNodeObjectKey.add("Objectlist"); TaskGroupSrcNode srcNodebody = new TaskGroupSrcNode(); srcNodebody.withAk("******") .withSk("******.") .withRegion("cn-north-4") .withObjectKey(listSrcNodeObjectKey) .withBucket("src-bucket") .withCloudType("HuaweiCloud"); body.withBandwidthPolicy(listbodyBandwidthPolicy); body.withTaskType(CreateTaskGroupReq.TaskTypeEnum.fromValue("PREFIX")); body.withEnableKms(false); body.withEnableFailedObjectRecording(true); body.withDstNode(dstNodebody); body.withSrcNode(srcNodebody); request.withBody(body); try { CreateTaskGroupResponse response = client.createTaskGroup(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
This example creates a migration task group to migrate objects recorded in the TXT URL list files stored in the test01/ directory to the destination bucket jjyy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.oms.v2.region.OmsRegion; import com.huaweicloud.sdk.oms.v2.*; import com.huaweicloud.sdk.oms.v2.model.*; public class CreateTaskGroupSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); OmsClient client = OmsClient.newBuilder() .withCredential(auth) .withRegion(OmsRegion.valueOf("<YOUR REGION>")) .build(); CreateTaskGroupRequest request = new CreateTaskGroupRequest(); CreateTaskGroupReq body = new CreateTaskGroupReq(); TaskGroupDstNode dstNodebody = new TaskGroupDstNode(); dstNodebody.withAk("******") .withSk("******.") .withRegion("cn-north-4") .withBucket("jjyy") .withCloudType("HEC"); ListFile listFileSrcNode = new ListFile(); listFileSrcNode.withListFileKey("test01/") .withObsBucket("url-file-bucket"); TaskGroupSrcNode srcNodebody = new TaskGroupSrcNode(); srcNodebody.withCloudType("URLSource") .withListFile(listFileSrcNode); body.withTaskType(CreateTaskGroupReq.TaskTypeEnum.fromValue("URL_LIST")); body.withEnableKms(false); body.withEnableRestore(false); body.withEnableFailedObjectRecording(true); body.withEnableMetadataMigration(false); body.withDstNode(dstNodebody); body.withDescription(""); body.withSrcNode(srcNodebody); request.withBody(body); try { CreateTaskGroupResponse response = client.createTaskGroup(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
This example creates a migration task group to migrate objects recorded in the TXT object list files stored in the hw/ directory to the destination bucket zzww.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkoms.v2.region.oms_region import OmsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkoms.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = OmsClient.new_builder() \ .with_credentials(credentials) \ .with_region(OmsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateTaskGroupRequest() dstNodebody = TaskGroupDstNode( ak="******", sk="******", region="cn-north-7", bucket="zzww", cloud_type="HEC" ) listFileSrcNode = ListFile( list_file_key="hw/", obs_bucket="list-file-bucket" ) srcNodebody = TaskGroupSrcNode( ak="******", sk="******", region="cn-north-7", bucket="hw-src", cloud_type="HuaweiCloud", list_file=listFileSrcNode ) request.body = CreateTaskGroupReq( task_type="LIST", enable_kms=False, enable_restore=False, enable_failed_object_recording=True, enable_metadata_migration=True, dst_node=dstNodebody, src_node=srcNodebody ) response = client.create_task_group(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
This example creates a migration task group to migrate objects prefixed with Objectlist from the source bucket src-bucket to the destination bucket dst-bucket.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkoms.v2.region.oms_region import OmsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkoms.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = OmsClient.new_builder() \ .with_credentials(credentials) \ .with_region(OmsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateTaskGroupRequest() listBandwidthPolicybody = [ BandwidthPolicyDto( end="23:59", max_bandwidth=1048576, start="00:01" ) ] dstNodebody = TaskGroupDstNode( ak="******", sk="******", region="cn-north-4", bucket="dst-bucket" ) listObjectKeySrcNode = [ "Objectlist" ] srcNodebody = TaskGroupSrcNode( ak="******", sk="******.", region="cn-north-4", object_key=listObjectKeySrcNode, bucket="src-bucket", cloud_type="HuaweiCloud" ) request.body = CreateTaskGroupReq( bandwidth_policy=listBandwidthPolicybody, task_type="PREFIX", enable_kms=False, enable_failed_object_recording=True, dst_node=dstNodebody, src_node=srcNodebody ) response = client.create_task_group(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
This example creates a migration task group to migrate objects recorded in the TXT URL list files stored in the test01/ directory to the destination bucket jjyy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkoms.v2.region.oms_region import OmsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkoms.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = OmsClient.new_builder() \ .with_credentials(credentials) \ .with_region(OmsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateTaskGroupRequest() dstNodebody = TaskGroupDstNode( ak="******", sk="******.", region="cn-north-4", bucket="jjyy", cloud_type="HEC" ) listFileSrcNode = ListFile( list_file_key="test01/", obs_bucket="url-file-bucket" ) srcNodebody = TaskGroupSrcNode( cloud_type="URLSource", list_file=listFileSrcNode ) request.body = CreateTaskGroupReq( task_type="URL_LIST", enable_kms=False, enable_restore=False, enable_failed_object_recording=True, enable_metadata_migration=False, dst_node=dstNodebody, description="", src_node=srcNodebody ) response = client.create_task_group(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
This example creates a migration task group to migrate objects recorded in the TXT object list files stored in the hw/ directory to the destination bucket zzww.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" oms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := oms.NewOmsClient( oms.OmsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateTaskGroupRequest{} cloudTypeDstNode:= "HEC" dstNodebody := &model.TaskGroupDstNode{ Ak: "******", Sk: "******", Region: "cn-north-7", Bucket: "zzww", CloudType: &cloudTypeDstNode, } listFileSrcNode := &model.ListFile{ ListFileKey: "hw/", ObsBucket: "list-file-bucket", } akSrcNode:= "******" skSrcNode:= "******" regionSrcNode:= "cn-north-7" bucketSrcNode:= "hw-src" cloudTypeSrcNode:= "HuaweiCloud" srcNodebody := &model.TaskGroupSrcNode{ Ak: &akSrcNode, Sk: &skSrcNode, Region: ®ionSrcNode, Bucket: &bucketSrcNode, CloudType: &cloudTypeSrcNode, ListFile: listFileSrcNode, } taskTypeCreateTaskGroupReq:= model.GetCreateTaskGroupReqTaskTypeEnum().LIST enableRestoreCreateTaskGroupReq:= false enableFailedObjectRecordingCreateTaskGroupReq:= true enableMetadataMigrationCreateTaskGroupReq:= true request.Body = &model.CreateTaskGroupReq{ TaskType: &taskTypeCreateTaskGroupReq, EnableKms: false, EnableRestore: &enableRestoreCreateTaskGroupReq, EnableFailedObjectRecording: &enableFailedObjectRecordingCreateTaskGroupReq, EnableMetadataMigration: &enableMetadataMigrationCreateTaskGroupReq, DstNode: dstNodebody, SrcNode: srcNodebody, } response, err := client.CreateTaskGroup(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
This example creates a migration task group to migrate objects prefixed with Objectlist from the source bucket src-bucket to the destination bucket dst-bucket.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" oms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := oms.NewOmsClient( oms.OmsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateTaskGroupRequest{} var listBandwidthPolicybody = []model.BandwidthPolicyDto{ { End: "23:59", MaxBandwidth: int64(1048576), Start: "00:01", }, } dstNodebody := &model.TaskGroupDstNode{ Ak: "******", Sk: "******", Region: "cn-north-4", Bucket: "dst-bucket", } var listObjectKeySrcNode = []string{ "Objectlist", } akSrcNode:= "******" skSrcNode:= "******." regionSrcNode:= "cn-north-4" bucketSrcNode:= "src-bucket" cloudTypeSrcNode:= "HuaweiCloud" srcNodebody := &model.TaskGroupSrcNode{ Ak: &akSrcNode, Sk: &skSrcNode, Region: ®ionSrcNode, ObjectKey: &listObjectKeySrcNode, Bucket: &bucketSrcNode, CloudType: &cloudTypeSrcNode, } taskTypeCreateTaskGroupReq:= model.GetCreateTaskGroupReqTaskTypeEnum().PREFIX enableFailedObjectRecordingCreateTaskGroupReq:= true request.Body = &model.CreateTaskGroupReq{ BandwidthPolicy: &listBandwidthPolicybody, TaskType: &taskTypeCreateTaskGroupReq, EnableKms: false, EnableFailedObjectRecording: &enableFailedObjectRecordingCreateTaskGroupReq, DstNode: dstNodebody, SrcNode: srcNodebody, } response, err := client.CreateTaskGroup(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
This example creates a migration task group to migrate objects recorded in the TXT URL list files stored in the test01/ directory to the destination bucket jjyy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" oms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := oms.NewOmsClient( oms.OmsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateTaskGroupRequest{} cloudTypeDstNode:= "HEC" dstNodebody := &model.TaskGroupDstNode{ Ak: "******", Sk: "******.", Region: "cn-north-4", Bucket: "jjyy", CloudType: &cloudTypeDstNode, } listFileSrcNode := &model.ListFile{ ListFileKey: "test01/", ObsBucket: "url-file-bucket", } cloudTypeSrcNode:= "URLSource" srcNodebody := &model.TaskGroupSrcNode{ CloudType: &cloudTypeSrcNode, ListFile: listFileSrcNode, } taskTypeCreateTaskGroupReq:= model.GetCreateTaskGroupReqTaskTypeEnum().URL_LIST enableRestoreCreateTaskGroupReq:= false enableFailedObjectRecordingCreateTaskGroupReq:= true enableMetadataMigrationCreateTaskGroupReq:= false descriptionCreateTaskGroupReq:= "" request.Body = &model.CreateTaskGroupReq{ TaskType: &taskTypeCreateTaskGroupReq, EnableKms: false, EnableRestore: &enableRestoreCreateTaskGroupReq, EnableFailedObjectRecording: &enableFailedObjectRecordingCreateTaskGroupReq, EnableMetadataMigration: &enableMetadataMigrationCreateTaskGroupReq, DstNode: dstNodebody, Description: &descriptionCreateTaskGroupReq, SrcNode: srcNodebody, } response, err := client.CreateTaskGroup(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Created |
|
400 |
Bad Request |
|
403 |
Forbidden |
|
500 |
Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot