Updated on 2026-01-28 GMT+08:00

Querying a Source Server

Function

After the migration Agent reports the source server information to SMS, SMS checks the migration feasibility. This API returns the basic information and check results of the source server.

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

    sms:server:get

    Read

    server *

    -

    sms:server:queryServer

    -

    -

    g:EnterpriseProjectId

URI

GET /v3/sources/{source_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

source_id

Yes

String

The ID of the source server in SMS.

Minimum: 1

Maximum: 36

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

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

Minimum: 1

Maximum: 16384

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

id

String

The source server ID.

Minimum: 0

Maximum: 255

ip

String

The IP address of the source server.

Minimum: 0

Maximum: 255

name

String

The source server name in SMS.

Minimum: 0

Maximum: 255

hostname

String

The hostname of the source server. This parameter is mandatory for source server registration and optional for source server updates.

Minimum: 0

Maximum: 255

enterprise_project_id

String

Enterprise project ID.

Minimum: 1

Maximum: 255

add_date

Long

The time when the source server was registered.

Minimum: 0

Maximum: 9223372036854775807

os_type

String

The OS type of the source server, which can be Windows or Linux. This parameter is mandatory for source server registration and optional for source server updates.

Minimum: 0

Maximum: 255

os_version

String

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

Minimum: 0

Maximum: 255

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

initialize

replicate

syncing

stopping

stopped

skipping

deleting

clearing

cleared (snapshot resources cleared)

clearfailed (snapshot resource clearing failed)

premigready (migration drill ready)

premiged (migration drill completed)

premigfailed (migration drill failed)

cloning

cutovering (target server being launched)

finished (target server launched)

error

Enumeration values:

  • unavailable

  • waiting

  • initialize

  • replicate

  • syncing

  • stopping

  • stopped

  • skipping

  • deleting

  • clearing

  • cleared

  • clearfailed

  • premigready

  • premiged

  • premigfailed

  • cloning

  • cutovering

  • finished

  • error

connected

Boolean

Indicate whether the Agent installed on the source server is connected to SMS.

firmware

String

The boot mode of the source server, which can be BIOS or UEFI.

Enumeration values:

  • BIOS

  • UEFI

init_target_server

InitTargetServer object

The recommended target server configuration.

cpu_quantity

Integer

The number of CPUs on the source server.

Minimum: 0

Maximum: 65535

memory

Long

The physical memory size (MB) of the source server.

Minimum: 0

Maximum: 9223372036854775807

current_task

TaskByServerSource object

The migration task associated with the source server.

disks

Array of ServerDisk objects

The information about source server disks.

Array Length: 0 - 65535

volume_groups

Array of VolumeGroups objects

The volume group information of the source server. This parameter is mandatory for Linux. If there are no volume groups, the value is an empty array [].

Array Length: 0 - 65535

btrfs_list

Array of BtrfsFileSystem objects

The information about the 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 [].

Array Length: 0 - 65535

networks

Array of NetWork objects

The information about NICs on the source server.

Array Length: 0 - 65535

checks

Array of EnvironmentCheck objects

The environment check information for the source server.

Array Length: 0 - 65535

migration_cycle

String

The migration stage.

cutovering (target server being launched)

cutovered (target server launched)

checking

setting

replicating

syncing

Minimum: 0

Maximum: 255

Enumeration values:

  • cutovering

  • cutovered

  • checking

  • setting

  • replicating

  • syncing

state_action_time

Long

The timestamp when the status of the source server last changed. The source server status is defined by state.

Minimum: 0

Maximum: 9223372036854775807

replicatesize

Long

The amount of data that has been migrated, in bytes.

Minimum: 0

Maximum: 9223372036854775807

totalsize

Long

The total amount of data to be migrated, in bytes.

Minimum: 0

Maximum: 9223372036854775807

last_visit_time

Long

The timestamp when the Agent connection status last changed.

Minimum: 0

Maximum: 9223372036854775807

stage_action_time

Long

The timestamp when the migration stage of the source server last changed. The migration stage is defined by migration_cycle.

Minimum: 0

Maximum: 9223372036854775807

agent_version

String

The Agent version.

Minimum: 0

Maximum: 255

has_tc

Boolean

Indicates whether TC is installed. This parameter is mandatory for Linux.

Table 4 InitTargetServer

Parameter

Type

Description

disks

Array of DiskIntargetServer objects

The information about the recommended target server disks.

Array Length: 0 - 65535

volume_groups

Array of VolumeGroups objects

This parameter is mandatory for Linux. If there are no volume groups, the value is an empty array [].

Array Length: 0 - 65535

Table 5 DiskIntargetServer

Parameter

Type

Description

name

String

The disk name.

Minimum: 0

Maximum: 255

size

Long

The disk size, in bytes.

Minimum: 0

Maximum: 9223372036854775807

device_use

String

The disk function.

BOOT: boot device

OS: system device

NORMAL: general device

Minimum: 0

Maximum: 255

Enumeration values:

  • BOOT

  • OS

  • NORMAL

used_size

Long

The used disk space, in bytes.

Minimum: 0

Maximum: 9223372036854775807

physical_volumes

Array of PhysicalVolumes objects

The physical volume information.

Array Length: 0 - 65535

Table 6 PhysicalVolumes

Parameter

Type

Description

device_use

String

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

Minimum: 0

Maximum: 255

file_system

String

The file system type.

Minimum: 0

Maximum: 255

index

Integer

The serial number.

Minimum: 0

Maximum: 2147483647

mount_point

String

The mount point.

Minimum: 0

Maximum: 255

name

String

The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID.

Minimum: 0

Maximum: 255

size

Long

The size.

Minimum: 0

Maximum: 9223372036854775807

inode_size

Long

The number of inodes.

Minimum: 0

Maximum: 9223372036854775807

used_size

Long

The used space.

Minimum: 0

Maximum: 9223372036854775807

uuid

String

The GUID, which can be obtained from the source server.

Minimum: 0

Maximum: 255

Table 7 TaskByServerSource

Parameter

Type

Description

id

String

The task ID.

Minimum: 0

Maximum: 255

name

String

The task name.

Minimum: 0

Maximum: 255

type

String

The migration project type.

MIGRATE_BLOCK

MIGRATE_FILE

Enumeration values:

  • MIGRATE_BLOCK

  • MIGRATE_FILE

state

String

The task status.

Minimum: 0

Maximum: 255

start_date

Long

The start time.

Minimum: 0

Maximum: 9223372036854775807

speed_limit

Integer

The migration rate limit.

Minimum: 0

Maximum: 10000

migrate_speed

Double

The migration speed.

Minimum: 0

Maximum: 10000

start_target_server

Boolean

Indicates whether the target server is started.

vm_template_id

String

The server template ID.

Minimum: 0

Maximum: 255

region_id

String

region_id

Minimum: 0

Maximum: 255

project_name

String

The project name.

Minimum: 0

Maximum: 255

project_id

String

The project ID.

Minimum: 0

Maximum: 255

target_server

TargetServerById object

Destination.

log_collect_status

String

The log collection status.

INIT (ready)

UPLOADING

UPLOAD_FAIL

UPLOADED

Enumeration values:

  • INIT

  • UPLOADING

  • UPLOAD_FAIL

  • UPLOADED

exist_server

Boolean

Indicates whether an existing server is used as the target server.

use_public_ip

Boolean

Indicates whether a public IP address is used for migration.

clone_server

CloneServer object

The information about the cloned server.

subtask_info

String

The current subtask and progress.

Minimum: 0

Maximum: 255

Table 8 TargetServerById

Parameter

Type

Description

vm_id

String

The target server ID.

Minimum: 0

Maximum: 255

name

String

The name of the target server.

Minimum: 0

Maximum: 255

Table 9 CloneServer

Parameter

Type

Description

vm_id

String

The ID of the cloned server.

Minimum: 0

Maximum: 255

name

String

The name of the cloned server.

Minimum: 0

Maximum: 255

clone_error

String

The error code returned for a clone failure.

Minimum: 0

Maximum: 255

clone_state

String

The clone status.

NOT_READY

READY

PREPARING

CREATING

ERROR

FINISHED

Enumeration values:

  • NOT_READY

  • READY

  • PREPARING

  • CREATING

  • ERROR

  • FINISHED

error_msg

String

The error message returned for a clone failure.

Minimum: 0

Maximum: 1024

Table 10 ServerDisk

Parameter

Type

Description

name

String

The disk name.

Minimum: 0

Maximum: 255

partition_style

String

Disk partition type. This parameter is mandatory when the source server is added. Otherwise, the subsequent environment check will fail.

Options (required by EVS):

MBR: Master Boot Record

GPT: GUID Partition Table**

Partition Table

For details, see the description of differences between MBR and GPT in the EVS API document.

Minimum: 0

Maximum: 255

device_use

String

Disk type.

This is not mandatory and can be left blank. The common values are as follows:

NORMAL

OS: system device

BOOT

VOLUME_GROUP

BTRFS

Minimum: 0

Maximum: 255

size

Long

The disk size, in bytes.

Minimum: 0

Maximum: 9223372036854775807

used_size

Long

The used disk space, in bytes.

Minimum: 0

Maximum: 9223372036854775807

physical_volumes

Array of PhysicalVolume objects

The information about physical partitions on the disk.

Array Length: 0 - 50

os_disk

Boolean

Indicates whether the disk is the system disk.

relation_name

String

The name of the paired disk on the Linux target ECS server.

Minimum: 0

Maximum: 255

inode_size

Integer

The inode size.

Minimum: 0

Maximum: 2147483647

Table 11 PhysicalVolume

Parameter

Type

Description

device_use

String

Disk type.

This is not mandatory and can be left blank. The common values are as follows:

NORMAL

OS: system device

BOOT

VOLUME_GROUP

BTRFS

Minimum: 0

Maximum: 255

file_system

String

The file system type.

Minimum: 0

Maximum: 255

index

Integer

The serial number.

Minimum: 0

Maximum: 2147483647

mount_point

String

The mount point.

Minimum: 0

Maximum: 255

name

String

The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID.

Minimum: 0

Maximum: 255

size

Long

The size.

Minimum: 0

Maximum: 9223372036854775807

used_size

Long

The used space.

Minimum: 0

Maximum: 9223372036854775807

inode_size

Integer

The number of inodes.

Minimum: 0

Maximum: 2147483647

inode_nums

Long

The number of inodes.

Minimum: 0

Maximum: 9223372036854775807

uuid

String

The GUID, which can be obtained from the source server.

Minimum: 0

Maximum: 255

size_per_cluster

Integer

The size of each cluster.

Minimum: 0

Maximum: 2147483647

Table 12 VolumeGroups

Parameter

Type

Description

components

String

The physical volume information.

Minimum: 0

Maximum: 255

free_size

Long

The available space.

Minimum: 0

Maximum: 9223372036854775807

logical_volumes

Array of LogicalVolumes objects

The logical volume information.

Array Length: 0 - 50

name

String

Name.

Minimum: 0

Maximum: 255

size

Long

Size.

Minimum: 0

Maximum: 9223372036854775807

Table 13 LogicalVolumes

Parameter

Type

Description

block_count

Integer

The number of blocks.

Minimum: 0

Maximum: 2147483647

Default: 0

block_size

Long

Block size.

Minimum: 0

Maximum: 1048576

Default: 0

file_system

String

The file system.

Minimum: 0

Maximum: 255

inode_size

Integer

The number of inodes.

Minimum: 0

Maximum: 2147483647

inode_nums

Long

The number of inodes.

Minimum: 0

Maximum: 9223372036854775807

device_use

String

Partition type.

This is not mandatory and can be left blank. The common values are as follows:

NORMAL

OS: system device

BOOT

VOLUME_GROUP

BTRFS

Minimum: 0

Maximum: 255

mount_point

String

The mount point.

Minimum: 0

Maximum: 256

name

String

Name.

Minimum: 0

Maximum: 1024

size

Long

The size.

Minimum: 0

Maximum: 9223372036854775807

used_size

Long

The used space.

Minimum: 0

Maximum: 9223372036854775807

free_size

Long

The available space.

Minimum: 0

Maximum: 9223372036854775807

Table 14 BtrfsFileSystem

Parameter

Type

Description

name

String

The file system name.

Minimum: 0

Maximum: 255

label

String

The file system tags. If no tag exists, the value is an empty string.

Minimum: 0

Maximum: 255

uuid

String

The file system UUID.

Minimum: 0

Maximum: 255

device

String

The device names of the Btrfs file system.

Minimum: 0

Maximum: 255

size

Long

The space occupied by the file system data.

Minimum: 0

Maximum: 9223372036854775807

nodesize

Long

The Btrfs node size.

Minimum: 0

Maximum: 9223372036854775807

sectorsize

Integer

The sector size.

Minimum: 0

Maximum: 2147483647

data_profile

String

The data profile (RAD).

Minimum: 0

Maximum: 255

system_profile

String

The file system profile (RAD).

Minimum: 0

Maximum: 255

metadata_profile

String

The metadata profile (RAD).

Minimum: 0

Maximum: 255

global_reserve1

String

The Btrfs file system information.

Minimum: 0

Maximum: 255

g_vol_used_size

Long

The used space of the Btrfs volume.

Minimum: 0

Maximum: 9223372036854775807

default_subvolid

String

The ID of the default subvolume.

Minimum: 0

Maximum: 255

default_subvol_name

String

The name of the default subvolume.

Minimum: 0

Maximum: 255

default_subvol_mountpath

String

The mount path of the default subvolume or Btrfs file system.

Minimum: 0

Maximum: 255

subvolumn

Array of BtrfsSubvolumn objects

The subvolume information.

Array Length: 0 - 65535

Table 15 BtrfsSubvolumn

Parameter

Type

Description

uuid

String

The UUID of the parent volume.

Minimum: 0

Maximum: 255

is_snapshot

String

Indicates whether the subvolume is a snapshot.

Minimum: 0

Maximum: 255

subvol_id

String

The subvolume ID.

Minimum: 0

Maximum: 255

parent_id

String

The parent volume ID.

Minimum: 0

Maximum: 255

subvol_name

String

The subvolume name.

Minimum: 0

Maximum: 255

subvol_mount_path

String

The mount path of the subvolume.

Minimum: 0

Maximum: 255

Table 16 NetWork

Parameter

Type

Description

name

String

The NIC name.

Minimum: 0

Maximum: 255

ip

String

The IP address bound to the NIC.

Minimum: 0

Maximum: 255

ipv6

String

The IPv6 address.

Minimum: 0

Maximum: 255

netmask

String

The subnet mask.

Minimum: 0

Maximum: 255

gateway

String

Gateway.

Minimum: 0

Maximum: 255

mtu

Integer

The NIC MTU. This parameter is mandatory for Linux.

Minimum: 0

Maximum: 2147483647

mac

String

The first MAC address in the list must not be empty.

Minimum: 0

Maximum: 255

id

String

The database record ID.

Minimum: 0

Maximum: 255

Table 17 EnvironmentCheck

Parameter

Type

Description

id

Long

The check item ID.

Minimum: 0

Maximum: 9223372036854775807

params

Array of strings

Parameters.

Minimum: 0

Maximum: 255

Array Length: 0 - 65535

name

String

The check item name.

Minimum: 0

Maximum: 255

result

String

The check result.

OK: The check is passed.

WARN: A warning is generated.

ERROR: The check fails.

Minimum: 0

Maximum: 255

Enumeration values:

  • OK

  • WARN

  • ERROR

error_code

String

The returned error code.

Minimum: 0

Maximum: 255

error_or_warn

String

The error or warning.

Minimum: 0

Maximum: 255

error_params

String

The parameters that failed the check.

Minimum: 0

Maximum: 255

Status code: 403

Table 18 Response body parameters

Parameter

Type

Description

error_code

String

The error code.

Minimum: 0

Maximum: 255

error_msg

String

The error message.

Minimum: 0

Maximum: 255

encoded_authorization_message

String

The encrypted authorization information.

Minimum: 0

Maximum: 65535

error_param

Array of strings

Error parameters.

Minimum: 0

Maximum: 65535

Array Length: 1 - 20

details

Array of details objects

The error details.

Array Length: 1 - 20

Table 19 details

Parameter

Type

Description

error_code

String

The SMS error code.

Minimum: 0

Maximum: 65535

error_msg

String

The SMS error message.

Minimum: 0

Maximum: 65535

Example Requests

This example queries the information about the source server with the ID 211d7878-d7ba-4cac-acf1-a02ccfb8xxxx.

GET https://{endpoint}/v3/sources/211d7878-d7ba-4cac-acf1-a02ccfb8xxxx

Example Responses

Status code: 200

The details about a source server were obtained.

{
  "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
  "ip" : "192.168.0.154",
  "name" : "sms-win16",
  "hostname" : "sms-win16",
  "add_date" : 1598435769000,
  "os_type" : "WINDOWS",
  "os_version" : "WINDOWS2016_64BIT",
  "oem_system" : false,
  "state" : "initialize",
  "connected" : true,
  "firmware" : "BIOS",
  "cpu_quantity" : 1,
  "memory" : 2146553856,
  "current_task" : {
    "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "name" : "MigrationTask",
    "type" : "MIGRATE_BLOCK",
    "state" : "RUNNING",
    "speed_limit" : 0,
    "start_target_server" : true,
    "vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
    "region_id" : "region_id",
    "project_name" : "project_name",
    "project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
    "target_server" : {
      "vm_id" : "",
      "name" : ""
    },
    "log_collect_status" : "INIT",
    "exist_server" : false,
    "use_public_ip" : true,
    "clone_server" : null
  },
  "disks" : [ {
    "name" : "Disk 0",
    "relation_name" : null,
    "partition_style" : "MBR",
    "size" : 42949672960,
    "used_size" : 42947575808,
    "device_use" : "BOOT",
    "os_disk" : false,
    "physical_volumes" : [ {
      "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-100000000000}\\",
      "index" : 1,
      "name" : "(Reserved)",
      "device_use" : "BOOT",
      "file_system" : "NTFS",
      "mount_point" : null,
      "size" : 524288000,
      "used_size" : 410275840
    }, {
      "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-501f00000000}\\",
      "index" : 2,
      "name" : "C:\\",
      "device_use" : "OS",
      "file_system" : "NTFS",
      "mount_point" : null,
      "size" : 42423287808,
      "used_size" : 23170301952
    } ]
  } ],
  "volume_groups" : [ ],
  "networks" : [ {
    "name" : null,
    "ip" : null,
    "netmask" : null,
    "gateway" : null,
    "mtu" : 0,
    "mac" : "dac20cd4f6318ca6458673b0046ddcc89e936df292d0806cb868ba63a817853c"
  } ],
  "checks" : [ {
    "id" : 524146,
    "params" : [ "" ],
    "name" : "OS_VERSION",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524147,
    "params" : [ "" ],
    "name" : "FIRMWARE",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524148,
    "params" : [ "" ],
    "name" : "CPU",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524149,
    "params" : [ "" ],
    "name" : "MEMORY",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524150,
    "params" : [ "" ],
    "name" : "SYSTEM_ROOT",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524151,
    "params" : [ "" ],
    "name" : "PARTITION_STYLE",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524152,
    "params" : [ "" ],
    "name" : "FILE_SYSTEM",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524153,
    "params" : [ "" ],
    "name" : "FREE_SPACE",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524154,
    "params" : [ "" ],
    "name" : "OEM_SYSTEM",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524155,
    "params" : [ "" ],
    "name" : "DRIVER_FILE",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524156,
    "params" : [ "" ],
    "name" : "SERVICE",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  }, {
    "id" : 524157,
    "params" : [ "" ],
    "name" : "ACCOUNT_RIGHTS",
    "result" : "OK",
    "error_code" : null,
    "error_or_warn" : null,
    "error_params" : ""
  } ],
  "init_target_server" : {
    "disks" : [ {
      "name" : "Disk 0",
      "size" : 42949672960,
      "used_size" : 42947575808,
      "device_use" : "OS",
      "physical_volumes" : [ {
        "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-100000000000}\\",
        "index" : 1,
        "name" : "(Reserved)",
        "device_use" : "BOOT",
        "file_system" : "NTFS",
        "mount_point" : null,
        "size" : 524288000,
        "used_size" : 410275840
      }, {
        "uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-501f00000000}\\",
        "index" : 2,
        "name" : "C:\\",
        "device_use" : "OS",
        "file_system" : "NTFS",
        "mount_point" : null,
        "size" : 42423287808,
        "used_size" : 23170301952
      } ]
    } ],
    "volume_groups" : [ ]
  },
  "replicatesize" : 0,
  "stage_action_time" : 1598435768945,
  "totalsize" : 0,
  "last_visit_time" : 1598435801422,
  "agent_version" : "6.1.8",
  "migration_cycle" : "replicating",
  "state_action_time" : 1598435783569
}

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 SDK 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 ShowServerSolution {

    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();
        ShowServerRequest request = new ShowServerRequest();
        request.withSourceId("{source_id}");
        try {
            ShowServerResponse response = client.showServer(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 = ShowServerRequest()
        request.source_id = "{source_id}"
        response = client.show_server(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.ShowServerRequest{}
	request.SourceId = "{source_id}"
	response, err := client.ShowServer(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

The details about a source server were obtained.

403

Authentication failed.

Error Codes

See Error Codes.