Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Server Migration Service/ API Reference/ APIs V3.0/ Task Management/ Querying Details About a Migration Task

Querying Details About a Migration Task

Updated on 2025-01-24 GMT+08:00

Function

This API is used to query a migration task based on a specified ID.

Calling Method

For details, see Calling APIs.

URI

GET /v3/tasks/{task_id}

Table 1 Path parameter

Parameter

Mandatory

Type

Description

task_id

Yes

String

The migration task ID.

Minimum length: 0 characters

Maximum length: 255 characters

Request

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

The user token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Minimum length: 1 character

Maximum length: 16,384 characters

Response

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

name

String

The task name, which is defined by the user.

Minimum length: 0 characters

Maximum length: 255 characters

type

String

The task type. This parameter is mandatory for creating a task and optional for updating a task.

MIGRATE_FILE: file-level migration

MIGRATE_BLOCK: block-level migration

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • MIGRATE_FILE

  • MIGRATE_BLOCK

os_type

String

The OS type. This parameter is mandatory for creating a task and optional for updating a task.

The value can be:

  • WINDOWS

  • LINUX

id

String

The migration task ID.

Minimum length: 0 characters

Maximum length: 255 characters

priority

Integer

The migration process priority.

0: low

1: standard (default)

2: high

Minimum value: 0

Maximum value: 2

The value can be:

  • 0

  • 1

  • 2

speed_limit

Integer

The migration rate limit.

Minimum value: 0

Maximum value: 65535

region_id

String

The ID of the region where the target server is located.

Minimum length: 0 characters

Maximum length: 255 characters

start_target_server

Boolean

Indicates whether the target server is started after the migration is complete.

true: The target server is started after the migration is complete.

false: The target server is stopped after the migration is complete.

Default value: true

enterprise_project_id

String

The enterprise project ID.

Minimum length: 1 character

Maximum length: 255 characters

migration_ip

String

The IP address of the target server.

If you use a public network for migration, enter the EIP bound to the target server.

If you use a private line for migration, enter the private IP address of the target server.

Minimum length: 0 characters

Maximum length: 255 characters

region_name

String

The name of the region where the target server is located.

Minimum length: 0 characters

Maximum length: 255 characters

project_name

String

The name of the project to which the target server belongs.

Minimum length: 0 characters

Maximum length: 255 characters

project_id

String

The ID of the project to which the target server belongs.

Minimum length: 0 characters

Maximum length: 255 characters

vm_template_id

String

The template ID.

Minimum length: 0 characters

Maximum length: 255 characters

source_server

SourceServerResponse object

The source server information returned.

target_server

TaskTargetServer object

The information about the target server in the migration task.

state

String

The task status.

Minimum length: 0 characters

Maximum length: 255 characters

estimate_complete_time

Long

The estimated completion time.

Minimum value: 0

Maximum value: 9223372036854775807

connected

Boolean

The connection status.

create_date

Long

The task creation time.

Minimum value: 0

Maximum value: 9223372036854775807

start_date

Long

The task start time.

Minimum value: 0

Maximum value: 9223372036854775807

finish_date

Long

The task end time.

Minimum value: 0

Maximum value: 9223372036854775807

migrate_speed

Double

The migration rate, in MB/s.

Minimum value: 0

Maximum value: 10000

compress_rate

Double

The compression rate.

Minimum value: 0

Maximum value: 10000

error_json

String

The error message.

Minimum length: 0 characters

Maximum length: 1,024 characters

total_time

Long

The task duration.

Minimum value: 0

Maximum value: 9223372036854775807

float_ip

String

Retain this parameter temporarily to ensure the compatibility with the SMS-Agent of the earlier version.

Minimum length: 0 characters

Maximum length: 255 characters

remain_seconds

Long

The remaining migration time, in seconds.

Minimum value: 0

Maximum value: 9223372036854775807

target_snapshot_id

String

The ID of the snapshot for the target server.

Minimum length: 0 characters

Maximum length: 255 characters

clone_server

CloneServer object

The information about the cloned server.

sub_tasks

Array of SubTask objects

The list of subtasks contained in the migration task.

Array length: 0 to 65,535

network_check_info

NetworkCheckInfoRequestBody object

The network performance metrics and measurement results.

total_cpu_usage

Double

The CPU usage of the server, in percentage.

Minimum value: 0

Maximum value: 100

agent_cpu_usage

Double

The CPU usage of the Agent, in percentage.

Minimum value: 0

Maximum value: 100

total_mem_usage

Double

The memory usage of the server, in MB.

Minimum value: 0

Maximum value: 1048576.0

agent_mem_usage

Double

The memory usage of the Agent, in MB.

Minimum value: 0

Maximum value: 1048576.0

total_disk_io

Double

The disk I/O of the server, in MB/s.

Minimum value: 0

Maximum value: 10000.0

agent_disk_io

Double

The disk I/O of the Agent, in MB/s.

Minimum value: 0

Maximum value: 10000.0

Table 4 SourceServerResponse

Parameter

Type

Description

id

String

The ID of the source server in the SMS database.

Minimum length: 0 characters

Maximum length: 255 characters

ip

String

The IP address of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

name

String

The name of the source server displayed on the SMS console.

Minimum length: 0 characters

Maximum length: 255 characters

os_type

String

The OS type of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • WINDOWS

  • LINUX

os_version

String

The OS version. This parameter is mandatory for registration and optional for update.

Minimum length: 0 characters

Maximum length: 255 characters

oem_system

Boolean

Indicates whether the OS is an OEM OS (Windows).

state

String

The source server status.

unavailable: The source server fails the environment check.

waiting: The source server is waiting for migration.

initialize: The migration of the source server is being initialized.

replicate: The source server is being replicated.

syncing: The source server is being synchronized.

stopping: The migration of the source server is being stopped.

stopped: The migration of the source server is stopped.

deleting: The source server record is being deleted.

error: An error occurs during the migration of the source server.

cloning: The target server for the source server is being cloned.

testing: The test is in progress.

finished: The target server for the source server is launched.

The value can be:

  • unavailable

  • waiting

  • initialize

  • replicate

  • syncing

  • stopping

  • stopped

  • deleting

  • error

  • cloning

  • testing

  • finished

migration_cycle

String

The current migration stage of the source server.

cutovering: The target server for the source server is being launched.

cutovered: The target server for the source server is launched.

checking: The check is in progress.

setting: The configuration is in progress.

replicating: The data is being replicated.

syncing: The incremental data is being synchronized.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • cutovering

  • cutovered

  • checking

  • setting

  • replicating

  • syncing

Table 5 TaskTargetServer field description

Parameter

Type

Description

id

String

The ID of the target server in the SMS database.

Minimum length: 0 characters

Maximum length: 255 characters

vm_id

String

The ID of the target server. This parameter is not required for automatically created target servers.

Minimum length: 0 characters

Maximum length: 255 characters

name

String

The name of the target server.

Minimum length: 0 characters

Maximum length: 255 characters

ip

String

The IP address of the target server.

Minimum length: 0 characters

Maximum length: 255 characters

os_type

String

The OS type of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server.

Minimum length: 0 characters

Maximum length: 255 characters

The value can be:

  • WINDOWS

  • LINUX

os_version

String

The OS version. This parameter is mandatory for registration and optional for update.

Minimum length: 0 characters

Maximum length: 255 characters

system_dir

String

The system directory. This parameter is mandatory for Windows.

Minimum length: 0 characters

Maximum length: 255 characters

disks

Array of TargetDisk objects

The disk information of the target server, which is generally the same as that of the source server.

Array length: 0 to 65,535

volume_groups

Array of VolumeGroups objects

The logical volume information of the target server, which is generally the same as that on the source server.

Array length: 0 to 65,535

btrfs_list

Array of strings

The information about Btrfs file systems on the source server. This parameter is mandatory for Linux. If there are no Btrfs file systems on the source server, the value is an empty array [].

Minimum length: 0 characters

Maximum length: 255 characters

Array length: 0 to 65,535

image_disk_id

String

The ID of the disk that contains an agent image on the target server.

Minimum length: 0 characters

Maximum length: 255 characters

cutovered_snapshot_ids

String

The ID of the snapshot used for rollback on the target server.

Minimum length: 0 characters

Maximum length: 255 characters

Table 6 TargetDisk field description

Parameter

Type

Description

id

Long

The disk ID.

Minimum value: 0

Maximum value: 9223372036854775807

device_use

String

The partition function. The partition can be a general, boot, or OS partition.

BOOT: boot device

OS: system device

NORMAL: general device

Default value: NORMAL

The value can be:

  • NORMAL

  • OS

  • BOOT

disk_id

String

The disk ID.

Minimum length: 0 characters

Maximum length: 255 characters

name

String

The disk name.

Minimum length: 0 characters

Maximum length: 255 characters

physical_volumes

Array of TargetPhysicalVolumes objects

The logical volume information.

Array length: 0 to 65,535

size

Long

The size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

disk_index

String

The disk index.

Minimum length: 0 characters

Maximum length: 255 characters

os_disk

Boolean

Indicates whether the disk is the system disk.

partition_style

String

The disk partition type. This parameter is mandatory for source server registration.

MBR: Master Boot Record (MBR)

GPT: GUID Partition Table (GPT)

The value can be:

  • MBR

  • GPT

relation_name

String

The name of the paired target server disk in Linux.

Minimum length: 0 characters

Maximum length: 255 characters

Table 7 TargetPhysicalVolumes field description

Parameter

Type

Description

id

Long

The logical volume ID.

Minimum value: 0

Maximum value: 9223372036854775807

device_use

String

The partition function.

NORMAL: general device

OS: system device

BOOT: boot device

Default value: NORMAL

The value can be:

  • NORMAL

  • OS

  • BOOT

file_system

String

The file system.

Minimum length: 0 characters

Maximum length: 255 characters

index

Integer

The serial number.

Minimum value: 0

Maximum value: 2147483647

mount_point

String

The mount point.

Minimum length: 0 characters

Maximum length: 255 characters

name

String

The name.

Minimum length: 0 characters

Maximum length: 255 characters

size

Long

The size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

uuid

String

The UUID.

Minimum length: 0 characters

Maximum length: 255 characters

relation_name

String

The name of the paired target server disk in Linux.

Minimum length: 0 characters

Maximum length: 255 characters

free_size

Long

The idle partition space.

Minimum value: 0

Maximum value: 9223372036854775807

Table 8 VolumeGroups field description

Parameter

Type

Description

components

String

The physical volume information.

Minimum length: 0 characters

Maximum length: 255 characters

free_size

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

logical_volumes

Array of LogicalVolumes objects

The logical volume information.

Array length: 0 to 255

name

String

The name.

Minimum length: 0 characters

Maximum length: 255 characters

size

Long

The size.

Minimum value: 0

Maximum value: 9223372036854775807

Table 9 LogicalVolumes field description

Parameter

Type

Description

block_count

Integer

The number of blocks.

Minimum value: 0

Maximum value: 2147483647

Default value: 0

block_size

Long

The block size.

Minimum value: 0

Maximum value: 1048576

Default value: 0

file_system

String

The file system.

Minimum length: 0 characters

Maximum length: 255 characters

inode_size

Integer

The number of inodes.

Minimum value: 0

Maximum value: 2147483647

inode_nums

Long

The number of inodes.

Minimum value: 0

Maximum value: 9223372036854775807

device_use

String

The partition function. The partition can be a general, boot or OS partition.

Minimum length: 0 characters

Maximum length: 255 characters

mount_point

String

The mount point.

Minimum length: 0 characters

Maximum length: 256 characters

name

String

The name.

Minimum length: 0 characters

Maximum length: 1,024 characters

size

Long

The size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

free_size

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

Table 10 CloneServer field description

Parameter

Type

Description

vm_id

String

The cloned server ID.

Minimum length: 0 characters

Maximum length: 255 characters

name

String

The name of the cloned server.

Minimum length: 0 characters

Maximum length: 255 characters

clone_error

String

The error returned for a clone failure.

Minimum length: 0 characters

Maximum length: 255 characters

clone_state

String

The clone status.

Minimum length: 0 characters

Maximum length: 255 characters

error_msg

String

The error returned for a clone failure.

Minimum length: 0 characters

Maximum length: 1,024 characters

Table 11 SubTask field description

Parameter

Type

Description

id

Long

The subtask ID.

Minimum value: 0

Maximum value: 9223372036854775807

name

String

The subtask name.

Minimum length: 0 characters

Maximum length: 255 characters

progress

Integer

The progress of the subtask. The value is an integer ranging from 0 to 100.

Minimum value: 0

Maximum value: 100

start_date

Long

The start time of the subtask.

Minimum value: 0

Maximum value: 9223372036854775807

end_date

Long

The end time of the subtask. If the subtask is not complete, this parameter is left blank.

Minimum value: 0

Maximum value: 9223372036854775807

migrate_speed

Double

The migration speed, in Mbit/s.

Minimum value: 0

Maximum value: 10000

user_op

String

The user operation that triggers the subtask.

Minimum length: 0 characters

Maximum length: 50 characters

process_trace

String

The detailed progress of the migration or synchronization.

Minimum length: 0 characters

Maximum length: 2,048 characters

Table 12 NetworkCheckInfoRequestBody field description

Parameter

Type

Description

domain_connectivity

Boolean

The connectivity to domain names.

destination_connectivity

Boolean

The connectivity to the target server.

network_delay

Double

The network latency.

Minimum value: 0

Maximum value: 10000.0

network_jitter

Double

The network jitter.

Minimum value: 0

Maximum value: 10000

migration_speed

Double

The bandwidth.

Minimum value: 0

Maximum value: 10000

loss_percentage

Double

The packet loss rate.

Minimum value: 0

Maximum value: 100

cpu_usage

Double

The CPU usage.

Minimum value: 0

Maximum value: 100

mem_usage

Double

The memory usage.

Minimum value: 0

Maximum value: 100

evaluation_result

String

The network evaluation result.

Minimum length: 6 characters

Maximum length: 8 characters

Status code: 403

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

The error code.

Minimum length: 0 characters

Maximum length: 255 characters

error_msg

String

The error message.

Minimum length: 0 characters

Maximum length: 255 characters

encoded_authorization_message

String

Encrypted authorization information.

Minimum length: 0 characters

Maximum length: 65,535 characters

error_param

Array of strings

Invalid parameter.

Minimum length: 0 characters

Maximum length: 65,535 characters

Array length: 1 to 20

details

Array of details objects

The error message.

Array length: 1 to 20

Table 14 details field description

Parameter

Type

Description

error_code

String

The SMS error code.

Minimum length: 0 characters

Maximum length: 65,535 characters

error_msg

String

The SMS error message.

Minimum length: 0 characters

Maximum length: 65,535 characters

Example Request

This example queries a migration task with a specified ID.

GET https://{endpoint}/v3/tasks/ef3b9722-07a0-40ae-89b0-889ee96dfc56

Example Response

Status code: 200

The migration task with a specified ID was queried successfully.

{
  "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
  "name" : "MigrationTask",
  "type" : "MIGRATE_BLOCK",
  "os_type" : "WINDOWS",
  "state" : "RUNNING",
  "estimate_complete_time" : null,
  "create_date" : 1598435778000,
  "start_date" : 1598435784000,
  "finish_date" : null,
  "priority" : 1,
  "speed_limit" : 0,
  "migrate_speed" : 0.0,
  "start_target_server" : true,
  "error_json" : "",
  "total_time" : 115,
  "float_ip" : null,
  "migration_ip" : null,
  "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
  "region_name" : "region name",
  "region_id" : "region id",
  "project_name" : "project name",
  "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
  "sub_tasks" : [ {
    "id" : 7278,
    "name" : "CREATE_CLOUD_SERVER",
    "progress" : 0,
    "start_date" : 1598435802000,
    "end_date" : null,
    "user_op" : "REPLICATE",
    "process_trace" : null
  }, {
    "id" : 7279,
    "name" : "SSL_CONFIG",
    "progress" : 0,
    "start_date" : null,
    "end_date" : null,
    "user_op" : "REPLICATE",
    "process_trace" : null
  }, {
    "id" : 7280,
    "name" : "ATTACH_AGENT_IMAGE",
    "progress" : 0,
    "start_date" : null,
    "end_date" : null,
    "user_op" : "REPLICATE",
    "process_trace" : null
  }, {
    "id" : 7281,
    "name" : "FORMAT_DISK_WINDOWS",
    "progress" : 0,
    "start_date" : null,
    "end_date" : null,
    "user_op" : "REPLICATE",
    "process_trace" : null
  }, {
    "id" : 7282,
    "name" : "MIGRATE_WINDOWS_BLOCK",
    "progress" : 0,
    "start_date" : null,
    "end_date" : null,
    "user_op" : "REPLICATE",
    "process_trace" : null
  } ],
  "source_server" : {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "ip" : "192.168.0.154",
    "name" : "name-win16",
    "os_type" : "WINDOWS",
    "os_version" : "WINDOWS2016_64BIT",
    "oem_system" : false,
    "state" : "initialize",
    "migration_cycle" : "replicating"
  },
  "target_server" : {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "vm_id" : "",
    "name" : "",
    "ip" : null,
    "os_type" : "WINDOWS",
    "os_version" : "WINDOWS2016_64BIT",
    "system_dir" : "Y:\\Windows\\System32",
    "disks" : [ {
      "id" : 88008,
      "name" : "Disk 1",
      "relation_name" : null,
      "disk_id" : "0",
      "partition_style" : "MBR",
      "size" : 42949672960,
      "used_size" : 42947575808,
      "device_use" : "OS",
      "os_disk" : true,
      "physical_volumes" : [ {
        "id" : 135055,
        "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-100000000000}\\",
        "index" : 1,
        "name" : "Z:",
        "relation_name" : null,
        "device_use" : "BOOT",
        "file_system" : "NTFS",
        "mount_point" : null,
        "size" : 524288000,
        "used_size" : 410275840,
        "free_size" : 114012160
      }, {
        "id" : 135056,
        "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-501f00000000}\\",
        "index" : 2,
        "name" : "Y:",
        "relation_name" : null,
        "device_use" : "OS",
        "file_system" : "NTFS",
        "mount_point" : null,
        "size" : 42423287808,
        "used_size" : 23170301952,
        "free_size" : 19252985856
      } ],
      "disk_index" : "0"
    } ],
    "volume_groups" : [ ],
    "image_disk_id" : null,
    "cutovered_snapshot_ids" : null
  },
  "clone_server" : null
}

Status code: 403

Authentication failed.

{
  "error_code" : "SMS.9004",
  "error_msg" : "The current account does not have the permission to execute policy You do not have permission to perform action XXX on resource XXX.",
  "encoded_authorization_message" : "XXXXXX",
  "error_param" : [ "You do not have permission to perform action XXX on resource XXX." ],
  "details" : [ {
    "error_code" : "SMS.9004",
    "error_msg" : "You do not have permission to perform action XXX on resource XXX."
  } ]
}

SDK Sample Code

The sample code is as follows.

 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
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
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.sms.v3.region.SmsRegion;
import com.huaweicloud.sdk.sms.v3.*;
import com.huaweicloud.sdk.sms.v3.model.*;


public class ShowTaskSolution {

    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 GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        SmsClient client = SmsClient.newBuilder()
                .withCredential(auth)
                .withRegion(SmsRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowTaskRequest request = new ShowTaskRequest();
        request.withTaskId("{task_id}");
        try {
            ShowTaskResponse response = client.showTask(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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdksms.v3.region.sms_region import SmsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksms.v3 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"]

    credentials = GlobalCredentials(ak, sk)

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

    try:
        request = ShowTaskRequest()
        request.task_id = "{task_id}"
        response = client.show_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)
 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    sms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/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 := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := sms.NewSmsClient(
        sms.SmsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

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

For more SDK sample code of programming languages, visit API Explorer and click the Sample Code tab. Example code can be automatically generated.

 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
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
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.sms.v3.region.SmsRegion;
import com.huaweicloud.sdk.sms.v3.*;
import com.huaweicloud.sdk.sms.v3.model.*;


public class ShowTaskSolution {

    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 GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        SmsClient client = SmsClient.newBuilder()
                .withCredential(auth)
                .withRegion(SmsRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowTaskRequest request = new ShowTaskRequest();
        request.withTaskId("{task_id}");
        try {
            ShowTaskResponse response = client.showTask(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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdksms.v3.region.sms_region import SmsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksms.v3 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"]

    credentials = GlobalCredentials(ak, sk)

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

    try:
        request = ShowTaskRequest()
        request.task_id = "{task_id}"
        response = client.show_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)
 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    sms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/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 := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := sms.NewSmsClient(
        sms.SmsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

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

For more SDK sample code of programming languages, visit API Explorer and click the Sample Code tab. Example code can be automatically generated.

Status Codes

Status Code

Description

200

The migration task with a specified ID was queried successfully.

403

Authentication failed.

Error Codes

For details, see Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback