更新时间:2024-02-19 GMT+08:00
分享

查询迁移任务列表

功能介绍

查询用户账户下的所有任务信息。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/tasks

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

最小长度:1

最大长度:1024

表2 Query参数

参数

是否必选

参数类型

描述

group_id

String

迁移任务组group_id

最小长度:1

最大长度:100

limit

Integer

查询返回迁移任务列表当前页面的数量,默认查询10条。 最多返回100条迁移任务信息。

最小值:1

最大值:100

缺省值:10

offset

Integer

起始的任务序号,默认为0。 取值大于等于0,取值为0时从第一条开始查询。

最小值:0

最大值:2147483647

缺省值:0

status

Integer

迁移任务状态(无该参数时代表查询所有状态的任务): 1:等待调度 2:正在执行 3:停止 4:失败 5:成功 7: 暂停中

最小值:1

最大值:7

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

IAM 鉴权 Token

最小长度:1

最大长度:16384

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

tasks

Array of TaskResp objects

查询的任务详情

数组长度:0 - 100

count

Long

满足查询条件的任务总数

最小值:0

最大值:9223372036854775807

表5 TaskResp

参数

参数类型

描述

bandwidth_policy

Array of BandwidthPolicyDto objects

流量控制策略,每个任务最多可设置5条限速策略。

数组长度:0 - 5

complete_size

Long

任务迁移完成大小(Byte)。

最小值:0

最大值:9223372036854775807

description

String

任务描述,没有设置时为空字符串。

最小长度:0

最大长度:255

dst_node

DstNodeResp object

目的端节点信息

enable_failed_object_recording

Boolean

是否记录失败对象。开启后,如果有迁移失败对象,会在目的端存储失败对象信息。

enable_kms

Boolean

存储入OBS时是否使用KMS加密。

enable_metadata_migration

Boolean

是否启用元数据迁移,默认否。不启用时,为保证迁移任务正常运行,仍将为您迁移ContentType元数据。

enable_restore

Boolean

是否自动解冻归档数据,(由于对象存储解冻需要源端存储等待一定时间,开启自动解冻会对迁移速度有较大影响,建议先完成归档存储数据解冻后再启动迁移)。开启后,如果遇到归档类型数据,会自动解冻再进行迁移;如果遇到归档类型的对象直接跳过相应对象,系统默认对象迁移失败并记录相关信息到失败对象列表中。

error_reason

ErrorReasonResp object

任务失败原因,非失败状态时该字段为空字符串。

failed_num

Long

迁移失败对象数量。

最小值:0

最大值:9223372036854775807

failed_object_record

FailedObjectRecordDto object

失败对象列表记录结果,记录成功时提供失败对象列表存放链接,记录失败时显示失败原因。

group_id

String

迁移任务组ID,当任务由迁移任务组创建时会包含迁移任务组的id信息。

最小长度:0

最大长度:36

id

Long

任务ID。

最小值:0

最大值:999999999999999

is_query_over

Boolean

迁移任务是否完成源端对象统计数据扫描。

left_time

Long

任务剩余时间(毫秒)。

最小值:0

最大值:9223372036854775807

migrate_since

Long

迁移指定时间(时间戳,毫秒),表示仅迁移在指定时间之后修改的源端待迁移对象。默认为0,表示不设置迁移指定时间。

最小值:0

最大值:9223372036854775807

migrate_speed

Long

任务迁移速度(Byte/s)。

最小值:0

最大值:9223372036854775807

name

String

任务名称。

最小长度:0

最大长度:10240

progress

Double

任务进度,例如:0.522代表任务进度为52.2%,1代表任务进度为100%。

最小值:0

最大值:1

real_size

Long

实际迁移对象总大小(Byte),忽略对象的大小不会统计在内。

最小值:0

最大值:9223372036854775807

skipped_num

Long

迁移忽略对象数(存在以下两种情况会自动跳过:1.源端对象最后修改时间在迁移指定时间前;2.目的端已有该对象。)

最小值:0

最大值:9223372036854775807

src_node

SrcNodeResp object

源端节点信息

start_time

Long

任务启动时间(Unix时间戳,毫秒)。

最小值:0

最大值:9223372036854775807

status

Integer

任务状态。 1:等待调度 2:正在执行 3:停止 4:失败 5:成功 7:等待中

最小值:1

最大值:7

successful_num

Long

迁移成功对象数量。

最小值:0

最大值:9223372036854775807

task_type

String

任务类型,为空默认设置为object。 list:对象列表迁移 object:文件/文件夹迁移 prefix:对象前缀迁移 url_list: url对象列表

缺省值:object

枚举值:

  • list

  • object

  • prefix

  • url_list

group_type

String

分组类型 NORMAL_TASK:一般迁移任务 SYNC_TASK:同步任务所属迁移任务 GROUP_TASK:任务组所属迁移任务

缺省值:NORMAL_TASK

枚举值:

  • NORMAL_TASK

  • SYNC_TASK

  • GROUP_TASK

total_num

Long

迁移任务对象总数量。

最小值:0

最大值:9223372036854775807

total_size

Long

任务迁移总大小(Byte)。

最小值:0

最大值:9223372036854775807

total_time

Long

任务总耗时(毫秒)。

最小值:0

最大值:9223372036854775807

smn_info

SmnInfo object

SMN消息通知结果

source_cdn

SourceCdnResp object

指定是否启用CDN迁移支持。启用CDN迁移支持后,迁移时将从CDN域名获取源端对象。若包含此字段则为支持,否则为不支持。

success_record_error_reason

String

迁移成功对象列表记录失败错误码,记录成功时为空

最小长度:0

最大长度:255

skip_record_error_reason

String

迁移忽略对象列表记录失败错误码,记录记录成功时为空。

最小长度:0

最大长度:255

object_overwrite_mode

String

迁移前同名对象覆盖方式,用于迁移前判断源端与目的端有同名对象时,覆盖目的端或跳过迁移。默认SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE。NO_OVERWRITE:不覆盖。迁移前源端对象与目的端对象同名时,不做对比直接跳过迁移。SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE:大小/最后修改时间对比覆盖。默认配置。迁移前源端对象与目的端对象同名时,通过对比源端和目的端对象大小和最后修改时间,判断是否覆盖目的端,需满足源端/目的端对象的加密状态一致。源端与目的端同名对象大小不相同,或目的端对象的最后修改时间晚于源端对象的最后修改时间(源端较新),覆盖目的端。 CRC64_COMPARISON_OVERWRITE:CRC64对比覆盖。目前仅支持华为/阿里/腾讯。迁移前源端对象与目的端对象同名时,通过对比源端和目的端对象元数据中CRC64值是否相同,判断是否覆盖目的端,需满足源端/目的端对象的加密状态一致。如果源端与目的端对象元数据中不存在CRC64值,则系统会默认使用SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE(大小/最后修改时间对比覆盖)来对比进行覆盖判断。FULL_OVERWRITE:全覆盖。迁移前源端对象与目的端对象同名时,不做对比覆盖目的端。

枚举值:

  • NO_OVERWRITE

  • SIZE_LAST_MODIFIED_COMPARISON_OVERWRITE

  • CRC64_COMPARISON_OVERWRITE

  • FULL_OVERWRITE

dst_storage_policy

String

目的端存储类型设置,当且仅当目的端为华为云OBS时需要,默认为标准存储 STANDARD:华为云OBS标准存储 IA:华为云OBS低频存储 ARCHIVE:华为云OBS归档存储 DEEP_ARCHIVE:华为云OBS深度归档存储 SRC_STORAGE_MAPPING:保留源端存储类型,将源端存储类型映射为华为云OBS存储类型

缺省值:STANDARD

最小长度:0

最大长度:128

枚举值:

  • STANDARD

  • IA

  • ARCHIVE

  • DEEP_ARCHIVE

  • SRC_STORAGE_MAPPING

consistency_check

String

一致性校验方式,用于迁移前/后校验对象是否一致,所有校验方式需满足源端/目的端对象的加密状态一致,具体校验方式和校验结果可通过对象列表查看。默认size_last_modified。size_last_modified:默认配置。迁移前后,通过对比源端和目的端对象大小+最后修改时间,判断对象是否已存在或迁移后数据是否完整。源端与目的端同名对象大小相同,且目的端对象的最后修改时间不早于源端对象的最后修改时间,则代表该对象已存在/迁移成功。crc64:目前仅支持华为/阿里/腾讯。迁移前后,通过对比源端和目的端对象元数据中CRC64值是否相同,判断对象是否已存在/迁移完成。如果源端与目的端对象元数据中不存在CRC64值,则系统会默认使用大小/最后修改时间校验方式来校验。no_check:目前仅支持HTTP/HTTPS数据源。当源端对象无法通过标准http协议中content-length字段获取数据大小时,默认数据下载成功即迁移成功,不对数据做额外校验,且迁移时源端对象默认覆盖目的端同名对象。当源端对象能正常通过标准http协议中content-length字段获取数据大小时,则采用大小/最后修改时间校验方式来校验。

枚举值:

  • size_last_modified

  • crc64

  • no_check

enable_requester_pays

Boolean

是否开启请求者付款,在启用后,请求者支付请求和数据传输费用。

表6 BandwidthPolicyDto

参数

参数类型

描述

end

String

流量控制结束时间(包含),格式为“hh:mm”。例如“12:03”表示12时03分。

max_bandwidth

Long

时段内允许的最大流量带宽,单位Byte/s,取值范围为>= 1048576Byte/s(相当于1MB/s)且<=209715200Byte/s(相当于200MB/s)。

最小值:1048576

最大值:209715200

start

String

流量控制开始时间(包含),格式为“hh:mm”。例如“12:03”表示12时03分。

表7 DstNodeResp

参数

参数类型

描述

bucket

String

目的端桶的名称。

最大长度:1024

region

String

目的端桶所处的区域。

请与Endpoint对应的区域保持一致。

最小长度:0

最大长度:100

save_prefix

String

目的端桶内路径前缀(拼接在对象key前面,组成新的key,拼接后不能超过1024个字符)。

最小长度:0

最大长度:1024

表8 ErrorReasonResp

参数

参数类型

描述

error_code

String

迁移失败的错误码。

最小长度:0

最大长度:10

error_msg

String

迁移失败的原因。

最小长度:0

最大长度:1024

表9 FailedObjectRecordDto

参数

参数类型

描述

result

Boolean

是否支持失败对象重传。

list_file_key

String

失败对象列表文件路径。

最小长度:0

最大长度:1024

error_code

String

失败对象列表上传失败的错误码。

最小长度:0

最大长度:10

表10 SrcNodeResp

参数

参数类型

描述

bucket

String

源端桶的名称。

最小长度:0

最大长度:1024

cloud_type

String

源端云服务提供商。可选值有AWS、Azure、Aliyun、Tencent、HuaweiCloud、QingCloud、KingsoftCloud、Baidu、Google、Qiniu、URLSource或者UCloud。默认值为Aliyun。

枚举值:

  • AWS

  • Azure

  • Aliyun

  • Tencent

  • HuaweiCloud

  • QingCloud

  • KingsoftCloud

  • Baidu

  • Qiniu

  • URLSource

  • UCloud

  • Google

region

String

源端桶所处的区域。

最小长度:0

最大长度:100

app_id

String

当源端为腾讯云时,会返回此参数。

最小长度:0

最大长度:255

object_key

Array of strings

任务类型为对象迁移任务时,表示待迁移对象名称; 任务类型为前缀迁移任务时,表示待迁移前缀。

最小长度:0

最大长度:1024

数组长度:0 - 500

list_file

ListFile object

列表文件配置,当task_type为list或url_list时,list_file为必选参数。

表11 ListFile

参数

参数类型

描述

list_file_key

String

对象列表文件或URL列表文件对象名。

最小长度:1

最大长度:1024

obs_bucket

String

存放对象列表文件的OBS桶名。

请确保与目的端桶处于同一区域,否则将导致任务创建失败。

最小长度:0

最大长度:1024

list_file_num

String

存放对象列表文件的数量

最小长度:0

最大长度:65535

表12 SmnInfo

参数

参数类型

描述

notify_result

Boolean

记录迁移任务执行完毕后SMN消息是否发送成功。

notify_error_message

String

记录SMN消息发送失败原因的错误码(迁移任务成功时为空)。

最小长度:0

最大长度:1024

topic_name

String

SMN Topic的名称(SMN消息发送成功时为空)。

最小长度:0

最大长度:5120

表13 SourceCdnResp

参数

参数类型

描述

domain

String

从指定域名获取对象。

最小长度:0

最大长度:1024

protocol

String

协议类型,支持http和https协议。

枚举值:

  • http

  • https

authentication_type

String

鉴权类型: NONE, QINIU_PRIVATE_AUTHENTICATION, ALIYUN_OSS_A, ALIYUN_OSS_B, ALIYUN_OSS_C, KSYUN_PRIVATE_AUTHENTICATION, AZURE_SAS_TOKEN,TENCENT_COS_A,TENCENT_COS_B,TENCENT_COS_C,TENCENT_COS_D

枚举值:

  • NONE

  • QINIU_PRIVATE_AUTHENTICATION

  • ALIYUN_OSS_A

  • ALIYUN_OSS_B

  • ALIYUN_OSS_C

  • KSYUN_PRIVATE_AUTHENTICATION

  • AZURE_SAS_TOKEN

  • TENCENT_COS_A

  • TENCENT_COS_B

  • TENCENT_COS_C

  • TENCENT_COS_D

状态码: 400

表14 响应Body参数

参数

参数类型

描述

error_msg

String

错误信息。

error_code

String

错误码。

请求示例

查询2c0689c860ad4728a497c91ec0844383项目下10条失败的任务

GET https://{endpoint}/v2/2c0689c860ad4728a497c91ec0844383/tasks?offset=0&limit=10&status=4

响应示例

状态码: 200

OK

{
  "tasks" : [ {
    "bandwidth_policy" : [ {
      "end" : "23:59",
      "max_bandwidth" : 0,
      "start" : "00:00"
    } ],
    "complete_size" : 0,
    "description" : "test log",
    "dst_node" : {
      "bucket" : "dst_bucket",
      "region" : "cn-north-1"
    },
    "enable_failed_object_recording" : true,
    "enable_kms" : true,
    "enable_restore" : false,
    "error_reason" : {
      "error_code" : "string",
      "error_msg" : "string"
    },
    "failed_num" : 0,
    "failed_object_record" : {
      "result" : true,
      "list_file_key" : "string",
      "error_code" : "string"
    },
    "group_id" : "string",
    "id" : 0,
    "is_query_over" : true,
    "left_time" : 0,
    "migrate_since" : 0,
    "migrate_speed" : 0,
    "name" : "string",
    "progress" : 0,
    "real_size" : 0,
    "skipped_num" : 0,
    "src_node" : {
      "bucket" : "src_bucket",
      "cloud_type" : "AWS",
      "region" : "cn-north-1",
      "app_id" : "string",
      "object_key" : [ "string", "string" ],
      "list_file" : {
        "list_file_key" : "object_list_file.txt",
        "obs_bucket" : "obs_bucket"
      }
    },
    "start_time" : 0,
    "status" : 0,
    "successful_num" : 0,
    "task_type" : "list",
    "total_num" : 0,
    "total_size" : 0,
    "total_time" : 0,
    "smn_info" : {
      "notify_result" : true,
      "notify_error_message" : "string",
      "topic_name" : "string"
    },
    "source_cdn" : {
      "domain" : "xxx.xxx.xxx",
      "protocol" : "http",
      "authentication_type" : "string"
    }
  } ],
  "count" : 1
}

SDK代码示例

SDK代码示例如下。

 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
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 ListTasksSolution {

    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");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        OmsClient client = OmsClient.newBuilder()
                .withCredential(auth)
                .withRegion(OmsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListTasksRequest request = new ListTasksRequest();
        request.withGroupId("<group_id>");
        request.withLimit(<limit>);
        request.withOffset(<offset>);
        request.withStatus(<status>);
        try {
            ListTasksResponse response = client.listTasks(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());
        }
    }
}
 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
# coding: utf-8

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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = OmsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(OmsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListTasksRequest()
        request.group_id = "<group_id>"
        request.limit = <limit>
        request.offset = <offset>
        request.status = <status>
        response = client.list_tasks(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := oms.NewOmsClient(
        oms.OmsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListTasksRequest{}
	groupIdRequest:= "<group_id>"
	request.GroupId = &groupIdRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	statusRequest:= int32(<status>)
	request.Status = &statusRequest
	response, err := client.ListTasks(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

400

Bad Request

错误码

请参见错误码

分享:

    相关文档

    相关产品