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

查询转储任务详情

功能介绍

查询转储任务详情。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/streams/{stream_name}/transfer-tasks/{task_name}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。

stream_name

String

已创建的通道的名称。

task_name

String

待删除的转储任务名称。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

stream_name

String

该转储任务所属通道名称。

task_name

String

转储任务名称。

state

String

转储任务状态。

  • ERROR:错误。

  • STARTING:启动中。

  • PAUSED:已停止。

  • RUNNING:运行中。

  • DELETE:已删除。

  • ABNORMAL:异常。

枚举值:

  • ERROR

  • STARTING

  • PAUSED

  • RUNNING

  • DELETE

  • ABNORMAL

destination_type

String

转储任务类型。

  • OBS:转储到OBS。

  • MRS:转储到MRS。

  • DLI:转储到DLI。

  • CLOUDTABLE:转储到CloudTable。

  • DWS:转储到DWS。

枚举值:

  • OBS

  • MRS

  • DLI

  • CLOUDTABLE

  • DWS

create_time

Long

转储任务创建时间。

last_transfer_timestamp

Long

转储任务最近一次转储时间。

partitions

Array of PartitionResult objects

分区转储详情列表。

obs_destination_description

OBSDestinationDescriptorRequest object

转储目的地为OBS的参数列表。

dws_destination_descripton

DWSDestinationDescriptorRequest object

转储目的地为DWS的参数列表。

mrs_destination_description

MRSDestinationDescriptorRequest object

转储目的地为MRS的参数列表。

dli_destination_description

DliDestinationDescriptorRequest object

转储目的地为DLI的参数列表。

cloudtable_destination_descripton

CloudtableDestinationDescriptorRequest object

转储目的地为CloudTable的参数列表。

表4 PartitionResult

参数

参数类型

描述

status

String

分区的当前状态。

  • CREATING:创建中

  • ACTIVE:可用

  • DELETED:删除中

  • EXPIRED:已过期

枚举值:

  • CREATING

  • ACTIVE

  • DELETED

  • EXPIRED

partition_id

String

分区的唯一标识符。

hash_range

String

分区的可能哈希键值范围。

sequence_number_range

String

分区的序列号范围。

parent_partitions

String

父分区。

表5 OBSDestinationDescriptorRequest

参数

参数类型

描述

task_name

String

转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。

agency_name

String

在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency

最大长度:64

deliver_time_interval

Integer

根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。

单位:秒

最小值:30

最大值:900

缺省值:300

consumer_strategy

String

偏移量。

  • LATEST:最大偏移量,即获取最新的数据。

  • TRIM_HORIZON:最小偏移量,即读取最早的数据。

缺省值:LATEST

枚举值:

  • LATEST

  • TRIM_HORIZON

file_prefix

String

在OBS中存储通道文件的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。

取值范围:英文字母、数字、下划线和斜杠,最大长度为50个字符。

默认配置为空。

最大长度:50

partition_format

String

将转储文件的生成时间使用“yyyy/MM/dd/HH/mm”格式生成分区字符串,用来定义写到OBS的Object文件所在的目录层次结构。- N/A:置空,不使用日期时间目录。- yyyy:年- yyyy/MM:年/- yyyy/MM/dd:年/月/日- yyyy/MM/dd/HH:年/月/日/时- yyyy/MM/dd/HH/mm:年/月/日/时/分例如:2017/11/10/14/49,目录结构就是“2017 > 11 > 10 > 14 > 49”,“2017”表示最外层文件夹。默认值:空说明:数据转储成功后,存储的目录结构为“obs_bucket_path/file_prefix/partition_format”。

枚举值:

  • yyyy

  • yyyy/MM

  • yyyy/MM/dd

  • yyyy/MM/dd/HH

  • yyyy/MM/dd/HH/mm

obs_bucket_path

String

存储该通道数据的OBS桶名称。

destination_file_type

String

转储文件格式。

  • text:转储目标格式为TEXT,缺省值

  • parquet:转储目标格式为Parquet

  • carbon:转储目标格式为Carbon

说明:

“源数据类型”为“JSON”,“转储服务类型”为“OBS”时才可选择“parquet”或“carbon”格式。

缺省值:text

枚举值:

  • text

  • parquet

  • carbon

processing_schema

ProcessingSchema object

根据源数据的时间戳和已配置的"partition_format"生成对应的转储时间目录。将源数据的时间戳使用“yyyy/MM/dd/HH/mm”格式生成分区字符串,用来定义写到OBS的Object文件所在的目录层次结构。

record_delimiter

String

转储文件的记录分隔符,用于分隔写入转储文件的用户数据。

取值范围:

  • 逗号 ",",默认值

  • 分号 ";"

  • 竖线 "|"

  • 换行符 "\n"

缺省值:\n

表6 ProcessingSchema

参数

参数类型

描述

timestamp_name

String

源数据时间戳的属性名称。

timestamp_type

String

源数据时间戳的类型。

  • String

  • Timestamp:Long类型的13位时间戳

timestamp_format

String

源数据时间戳的类型为String时必选,用于根据时间戳格式生成OBS的时间目录。

枚举值:

  • yyyy/MM/dd HH:mm:ss

  • MM/dd/yyyy HH:mm:ss

  • dd/MM/yyyy HH:mm:ss

  • yyyy-MM-dd HH:mm:ss

  • MM-dd-yyyy HH:mm:ss

  • dd-MM-yyyy HH:mm:ss

表7 DWSDestinationDescriptorRequest

参数

参数类型

描述

task_name

String

转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。

agency_name

String

在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency

最大长度:64

deliver_time_interval

Integer

根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。

单位:秒

最小值:30

最大值:900

缺省值:300

consumer_strategy

String

偏移量。

  • LATEST:最大偏移量,即获取最新的数据。

  • TRIM_HORIZON:最小偏移量,即读取最早的数据。

缺省值:LATEST

枚举值:

  • LATEST

  • TRIM_HORIZON

dws_cluster_name

String

存储该通道数据的DWS集群名称。

dws_cluster_id

String

存储该通道数据的DWS集群ID。

dws_database_name

String

存储该通道数据的DWS数据库名称。

dws_schema

String

存储该通道数据的DWS数据库模式。

dws_table_name

String

存储该通道数据的DWS数据库模式下的数据表。

dws_delimiter

String

用户数据的字段分隔符,根据此分隔符分隔用户数据插入DWS数据表的相应列。

取值范围:“,”、“;”和“|”三种字符中的一个。

user_name

String

存储该通道数据的DWS数据库的用户名。

user_password

String

存储该通道数据的DWS数据库的密码。

kms_user_key_name

String

用户在密钥管理服务(简称KMS)创建的用户主密钥名称,用于加密存储DWS数据库的密码。

kms_user_key_id

String

用户在密钥管理服务(简称KMS)创建的用户主密钥ID,用于加密存储DWS数据库的密码。

obs_bucket_path

String

临时存储该通道数据的OBS桶名称。

file_prefix

String

临时存储该通道数据的OBS桶下的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。

取值范围:英文字母、数字、下划线和斜杠,最大长度为50个字符。

默认配置为空。

retry_duration

String

用户数据导入DWS集群失败的重试失效时间。超出此配置项配置的时间,转储DWS失败的数据将备份至“OBS桶/ file_prefix/dws_error”目录下。取值范围: 0~7200。单位:秒。默认配置为1800。

dws_table_columns

String

指定要转储到DWS表中的列,为null或者为空则默认全列。比如“c1,c2”表示将Schema中c1和c2这两列转储到DWS。

默认为空。

options

Options object

DWS容错性选项(用于指定外表数据的各类参数)。

表8 Options

参数

参数类型

描述

fill_missing_fields

String

数据入库时,数据源文件中某行的最后一个字段缺失时,请选择是直接将字段设为Null,还是在错误表中报错提示。

取值范围:

  • true/on

  • false/off

缺省值:false/off

枚举值:

  • true/on

  • false/off

ignore_extra_data

String

数据源文件中的字段比外表定义列数多时,是否忽略多出的列。该参数只在数据导入过程中使用。

取值范围:

  • true/on

  • false/off

缺省值:false/off

枚举值:

  • true/on

  • false/off

compatible_illegal_chars

String

导入非法字符容错参数。是将非法字符按照转换规则转换后入库,还是报错中止导入。

取值范围:

  • true/on

  • false/off

缺省值:false/off

枚举值:

  • true/on

  • false/off

reject_limit

String

指定本次数据导入允许出现的数据格式错误个数,当导入过程中出现的数据格式错误未达到限定值时,本次数据导入可以成功。

取值范围:

  • 整型值

  • unlimited(无限制)

缺省值为0,有错误信息立即返回。

error_table_name

String

用于记录数据格式错误信息的错误表表名。并行导入结束后查询此错误信息表,能够获取详细的错误信息。

表9 MRSDestinationDescriptorRequest

参数

参数类型

描述

task_name

String

转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。

agency_name

String

在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency

最大长度:64

deliver_time_interval

Integer

根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。

单位:秒

最小值:30

最大值:900

缺省值:300

consumer_strategy

String

偏移量。

  • LATEST:最大偏移量,即获取最新的数据。

  • TRIM_HORIZON:最小偏移量,即读取最早的数据。

缺省值:LATEST

枚举值:

  • LATEST

  • TRIM_HORIZON

mrs_cluster_name

String

存储该通道数据的MRS集群名称。

说明:

仅支持非Kerberos认证的MRS集群。

mrs_cluster_id

String

存储该通道数据的MRS集群ID。

mrs_hdfs_path

String

存储该通道数据的MRS集群的HDFS路径。

file_prefix

String

临时存储该通道数据的OBS桶下的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。

取值范围:英文字母、数字、下划线和斜杠,最大长度为50个字符。

默认配置为空。

hdfs_prefix_folder

String

在MRS集群HDFS中存储通道文件的自定义目录,多级目录可用"/"进行分隔。

取值范围:0~50个字符。

默认配置为空。

obs_bucket_path

String

临时存储该通道数据的OBS桶名称。

retry_duration

String

用户数据转储失败的失效重试时间。重试时间超过该配置项配置的值,则将转储失败的数据备份至“OBS桶/ file_prefix/mrs_error”目录下。

取值范围:0~7200。

单位:秒。

默认配置为1800。

配置为“0”表示DIS服务不会在转储失败时进行重试。

表10 DliDestinationDescriptorRequest

参数

参数类型

描述

task_name

String

转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。

agency_name

String

在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency

最大长度:64

deliver_time_interval

Integer

根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。

单位:秒

最小值:30

最大值:900

缺省值:300

consumer_strategy

String

偏移量。

  • LATEST:最大偏移量,即获取最新的数据。

  • TRIM_HORIZON:最小偏移量,即读取最早的数据。

缺省值:LATEST

枚举值:

  • LATEST

  • TRIM_HORIZON

dli_database_name

String

存储该通道数据的DLI数据库名称。

dli_table_name

String

存储该通道数据的DLI表名称。

说明:

仅支持数据位置为DLI的表,且用户需具有该表的插入权限。

obs_bucket_path

String

临时存储该通道数据的OBS桶名称。

file_prefix

String

临时存储该通道数据的OBS桶下的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。

取值范围:英文字母、数字、下划线和斜杠,最大长度为50个字符。

默认配置为空。

retry_duration

String

用户数据导入DLI失败的失效重试时间。重试时间超过该配置项配置的值,则将转储失败的数据备份至“OBS桶/ file_prefix/dli_error”目录下。取值范围:0~7200。单位:秒。默认配置为1800。配置为“0”表示DIS服务不会在转储失败时进行重试。

表11 CloudtableDestinationDescriptorRequest

参数

参数类型

描述

task_name

String

转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。

agency_name

String

在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency

最大长度:64

deliver_time_interval

Integer

根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。

单位:秒

最小值:30

最大值:900

缺省值:300

consumer_strategy

String

偏移量。

  • LATEST:最大偏移量,即获取最新的数据。

  • TRIM_HORIZON:最小偏移量,即读取最早的数据。

缺省值:LATEST

枚举值:

  • LATEST

  • TRIM_HORIZON

cloudtable_cluster_name

String

存储该通道数据的CloudTable集群名称。

如果选择转储OpenTSDB,则集群必须开启OpenTSDB。

cloudtable_cluster_id

String

存储该通道数据的CloudTable集群ID。

如果选择转储OpenTSDB,则集群必须开启OpenTSDB。

cloudtable_table_name

String

转储HBase时必选,表示存储该通道数据的CloudTable集群HBase表名称。

cloudtable_schema

CloudtableSchema object

转储HBase时必选,与“opentsdb_schema”二选一,表示CloudTable集群HBase数据的Schema配置。用于将通道内的JSON数据进行格式转换并导入Cloudtable的HBase表中。

opentsdb_schema

Array of OpenTSDBSchema objects

转储OpenTSDB时必选,与“cloudtable_schema”二选一,表示CloudTable集群OpenTSDB数据的Schema配置。用于将通道内的JSON数据进行格式转换并导入Cloudtable的OpenTSDB。

cloudtable_row_key_delimiter

String

转储HBase的rowkey分隔符,用于分隔生成rowKey的用户数据。取值范围:”, ”、 ”. ”、 ”|”、 ”; ”、 ”\”、 ”-”、 ”_”、 ”~”缺省值:”.”

obs_backup_bucket_path

String

用户数据转储CloudTable服务失败时,可选择将转储失败的数据备份至OBS服务,此参数为OBS服务的桶名称。

backup_file_prefix

String

用户数据转储CloudTable服务失败时,可选择将转储失败的数据备份至OBS服务,此参数为OBS桶下的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。取值范围:英文字母、数字和下划线。最大长度:最大长度为50个字符。默认配置为空。

retry_duration

String

用户数据导入CloudTable服务失败的失效重试时间。超出此时效,转储CloudTable失败的数据将备份至“OBS桶/ backup_file_prefix /cloudtable_error”或“OBS桶/ backup_file_prefix /opentsdb_error”目录下。取值范围: 0~7200。单位:秒。默认配置为1800。

表12 CloudtableSchema

参数

参数类型

描述

row_key

Array of RowKey objects

CloudTable集群HBase数据rowkey的Schema配置,用于将通道内的JSON数据生成HBase数据的rowkey。

取值范围:1~64。

columns

Array of Column objects

CloudTable集群HBase数据列的Schema配置,用于将通道内的JSON数据生成HBase数据的列。

取值范围:1~4096。

表13 RowKey

参数

参数类型

描述

value

String

通道内JSON数据的JSON属性名,用于生成HBase数据的rowkey。

type

String

通道内JSON数据的JSON属性的类型名称。

枚举值:

  • Bigint

  • Double

  • Boolean

  • Timestamp

  • String

  • Decimal

表14 Column

参数

参数类型

描述

column_family_name

String

存储该通道数据的HBase表数据的列族名称。

column_name

String

存储该通道数据的HBase表数据的列名称。

取值范围:1~32,只能包含英文字母、数字和下划线。

value

String

通道内JSON数据的JSON属性名,用于生成HBase数据的列值。

type

String

通道内JSON数据的JSON属性的类型名称。

枚举值:

  • Bigint

  • Double

  • Boolean

  • Timestamp

  • String

  • Decimal

表15 OpenTSDBSchema

参数

参数类型

描述

metric

Array of OpenTSDBMetric objects

CloudTable集群OpenTSDB数据metric的Schema配置,用于将通道内的JSON数据进行格式转换生成OpenTSDB数据的metric。

timestamp

OpenTSDBTimestamp object

CloudTable集群OpenTSDB 数据timestamp的Schema配置,用于将通道内的JSON数据进行格式转换生成OpenTSDB数据的timestamp。

value

OpenTSDBValue object

CloudTable集群OpenTSDB 数据value的Schema配置,用于将通道内的JSON数据进行格式转换生成OpenTSDB 数据的value。

tags

Array of OpenTSDBTags objects

CloudTable集群OpenTSDB数据tags的Schema配置,用于将通道内的JSON数据进行格式转换生成OpenTSDB数据的tags。

表16 OpenTSDBMetric

参数

参数类型

描述

type

String

  • Constant表示metric为常量value的值。

  • String表示metric为通道内用户数据对应JSON属性的取值,且该JOSN属性的取值为String。

枚举值:

  • Constant

  • String

value

String

常量或通道内用户数据的JSON属性名称。

取值范围:1~32,只能包含英文字母、数字和点。

表17 OpenTSDBTimestamp

参数

参数类型

描述

type

String

  • Timestamp类型表示通道内用户数据对应JSON属性的取值为Timestamp类型,不需要进行数据格式转换就可以生成OpenTSDB的timestamp。- String类型表示通道内用户数据对应JSON属性的取值为Date格式,需要进行数据格式转换才能生成OpenTSDB的timestamp。

value

String

通道内用户数据的JSON属性名称。

取值范围:1~32,只能包含英文字母、数字和下划线。

format

String

“type”为“String”类型时必选。表示通道内用户数据对应JSON属性的取值为Date格式,需要根据format字段进行数据格式转换生成OpenTSDB的timestamp。取值范围:- yyyy/MM/dd HH:mm:ss- MM/dd/yyyy HH:mm:ss- dd/MM/yyyy HH:mm:ss- yyyy-MM-dd HH:mm:ss- MM-dd-yyyy HH:mm:ss- dd-MM-yyyy HH:mm:ss

枚举值:

  • yyyy/MM/dd HH:mm:ss

  • MM/dd/yyyy HH:mm:ss

  • dd/MM/yyyy HH:mm:ss

  • yyyy-MM-dd HH:mm:ss

  • MM-dd-yyyy HH:mm:ss

  • dd-MM-yyyy HH:mm:ss

表18 OpenTSDBValue

参数

参数类型

描述

type

String

通道内用户JSON数据对应JSON属性的类型名称。

取值范围:

  • Bigint

  • Double

  • Boolean

  • Timestamp

  • String

  • Decimal

value

String

常量或通道内用户数据的JSON属性名称。

取值范围:1~32,只能包含英文字母、数字和下划线。

表19 OpenTSDBTags

参数

参数类型

描述

name

String

存储该通道数据的OpenTSDB数据的tag名称。

取值范围:1~32,只能包含英文字母、数字和下划线。

type

String

通道内用户JSON数据对应JSON属性的类型名称。

取值范围:

  • Bigint

  • Double

  • Boolean

  • Timestamp

  • String

  • Decimal

value

String

常量或通道内用户数据的JSON属性名称。

取值范围:1~32,只能包含英文字母、数字和下划线。

请求示例

查询转储任务详情

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

响应示例

状态码: 200

正常返回

{
  "stream_id" : "RdMFID6edQdf8eDzc9e",
  "stream_name" : "newstream",
  "task_name" : "newtask",
  "task_id" : "As805BudhcH1lDs6gbn",
  "destination_type" : "OBS",
  "state" : "RUNNING",
  "create_time" : 1606554932552,
  "last_transfer_timestamp" : 1606984428612,
  "obs_destination_description" : {
    "agency_name" : "dis_admin_agency",
    "file_prefix\"" : "",
    "partition_format" : "yyyy/MM/dd",
    "obs_bucket_path" : "obsbucket",
    "deliver_time_interval" : 60,
    "consumer_strategy" : "LATEST",
    "retry_duration" : 0,
    "destination_file_type" : "text",
    "record_delimiter" : "\n\n"
  },
  "partitions" : [ {
    "partitionId" : "shardId-0000000000",
    "discard" : 0,
    "state" : "RUNNING",
    "last_transfer_timestamp" : 1606984428612,
    "last_transfer_offset" : 289897
  } ]
}

SDK代码示例

SDK代码示例如下。

Java

 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
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.dis.v2.region.disRegion;
import com.huaweicloud.sdk.dis.v2.*;
import com.huaweicloud.sdk.dis.v2.model.*;


public class ShowTransferTaskSolution {

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

        disClient client = disClient.newBuilder()
                .withCredential(auth)
                .withRegion(disRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowTransferTaskRequest request = new ShowTransferTaskRequest();
        try {
            ShowTransferTaskResponse response = client.showTransferTask(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());
        }
    }
}

Python

 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
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdis.v2.region.dis_region import disRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdis.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 = disClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(disRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowTransferTaskRequest()
        response = client.show_transfer_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dis "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/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 := dis.NewdisClient(
        dis.disClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowTransferTaskRequest{}
	response, err := client.ShowTransferTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

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

状态码

状态码

描述

200

正常返回

错误码

请参见错误码

分享:

    相关文档

    相关产品