Querying Details About 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.
URI
GET /v3/sources/{source_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
source_id |
Yes |
String |
The ID of the source server displayed on the SMS console. Minimum length: 0 characters Maximum length: 255 characters |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
The user token. It can be obtained by calling the IAM API (value of X-Subject-Token in the response header). Minimum length: 1 character Maximum length: 16,384 characters |
Response
Status code: 200
Parameter |
Type |
Description |
---|---|---|
id |
String |
The source server ID. Minimum length: 0 characters Maximum length: 255 characters |
ip |
String |
The IP address of 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 |
hostname |
String |
The hostname 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 |
enterprise_project_id |
String |
The enterprise project ID. Minimum length: 1 character Maximum length: 255 characters |
add_date |
Long |
The time when the source is registered. Minimum value: 0 Maximum value: 9223372036854775807 |
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 |
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 |
Specifies whether the OS is an OEM OS (Windows). |
state |
String |
The source server status. The value can be: |
connected |
Boolean |
Specifies whether the Agent installed on the source server is properly connected to SMS. |
firmware |
String |
The boot mode. The value can be: |
init_target_server |
InitTargetServer object |
The recommended configuration of the target server. |
cpu_quantity |
Integer |
The number of CPU cores on the source server. Minimum value: 0 Maximum value: 65535 |
memory |
Long |
The physical memory size (MB) of the source server. Minimum value: 0 Maximum value: 9223372036854775807 |
current_task |
TaskByServerSource object |
The migration task associated with the source server. |
disks |
Array of ServerDisk objects |
The disk information of the source server. Array length: 0 to 65,535 characters |
volume_groups |
Array of VolumeGroups objects |
The volume group information of the source server. If there are no volume groups, the value is an empty array []. Array length: 0 to 65,535 characters |
btrfs_list |
Array of BtrfsFileSystem objects |
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 []. Array length: 0 to 65,535 characters |
networks |
Array of NetWork objects |
The NIC information of the source server. Array length: 0 to 65,535 characters |
checks |
Array of EnvironmentCheck objects |
The information about the migration feasibility check of the source server. Array length: 0 to 65,535 characters |
migration_cycle |
String |
The current migration stage of the source server. Minimum length: 0 characters Maximum length: 255 characters The value can be: |
state_action_time |
Long |
The time (in timestamp) when the status of the source server last changed. Minimum value: 0 Maximum value: 9223372036854775807 |
replicatesize |
Long |
The amount of data that has been migrated, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
totalsize |
Long |
The total amount of data to be migrated, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
last_visit_time |
Long |
The time (in timestamp) when the Agent connection status last changed. Minimum value: 0 Maximum value: 9223372036854775807 |
stage_action_time |
Long |
The time when the migration stage of the source server last changed. Minimum value: 0 Maximum value: 9223372036854775807 |
agent_version |
String |
The version of the Agent installed on the source server. Minimum length: 0 characters Maximum length: 255 characters |
Parameter |
Type |
Description |
---|---|---|
disks |
Array of DiskIntargetServer objects |
The information about the recommended target server disks. Array length: 0 to 65,535 characters |
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 to 65,535 characters |
Parameter |
Type |
Description |
---|---|---|
name |
String |
The disk name. Minimum length: 0 characters Maximum length: 255 characters |
size |
Long |
The disk size, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
device_use |
String |
The disk function. Minimum length: 0 characters Maximum length: 255 characters The value can be: |
used_size |
Long |
The used disk space, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
physical_volumes |
Array of PhysicalVolumes objects |
The physical volume information. Array length: 0 to 65,535 characters |
Parameter |
Type |
Description |
---|---|---|
device_use |
String |
The partition function. The value can be NORMAL, BOOT, or OS. Minimum length: 0 characters Maximum length: 255 characters |
file_system |
String |
The file system type. Minimum length: 0 characters Maximum length: 255 characters |
index |
Integer |
The serial number of the volume. Minimum value: 0 Maximum value: 2147483647 |
mount_point |
String |
The mount point. Minimum length: 0 characters Maximum length: 255 characters |
name |
String |
The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID. Minimum length: 0 characters Maximum length: 255 characters |
size |
Long |
The size. Minimum value: 0 Maximum value: 9223372036854775807 |
inode_size |
Long |
The number of inodes. Minimum value: 0 Maximum value: 9223372036854775807 |
used_size |
Long |
The used space. Minimum value: 0 Maximum value: 9223372036854775807 |
The UUID. |
String |
The GUID, which can be obtained from the source server. Minimum length: 0 characters Maximum length: 255 characters |
Parameter |
Type |
Description |
---|---|---|
id |
String |
The task ID. Minimum length: 0 characters Maximum length: 255 characters |
name |
String |
The task name. Minimum length: 0 characters Maximum length: 255 characters |
type |
String |
The task type. Minimum length: 0 characters Maximum length: 255 characters |
state |
String |
The task status. Minimum length: 0 characters Maximum length: 255 characters |
start_date |
Long |
The start time. Minimum value: 0 Maximum value: 9223372036854775807 |
speed_limit |
Integer |
The migration rate limit. Minimum value: 0 Maximum value: 10000 |
migrate_speed |
Double |
The migration rate. Minimum value: 0 Maximum value: 10000 |
start_target_server |
Boolean |
Specifies whether the target server is started. |
vm_template_id |
String |
The server template ID. Minimum length: 0 characters Maximum length: 255 characters |
region_id |
String |
region_id Minimum length: 0 characters Maximum length: 255 characters |
project_name |
String |
The project name. Minimum length: 0 characters Maximum length: 255 characters |
project_id |
String |
The project ID. Minimum length: 0 characters Maximum length: 255 characters |
target_server |
TargetServerById object |
The information about the target server. |
log_collect_status |
String |
The log collection status. Minimum length: 0 characters Maximum length: 255 characters |
exist_server |
Boolean |
Specifies whether an existing ECS is used as the target server. |
use_public_ip |
Boolean |
Indicates whether to use a public IP address for migration. |
clone_server |
CloneServer object |
The information about the cloned server. |
Parameter |
Type |
Description |
---|---|---|
vm_id |
String |
The target server ID. Minimum length: 0 characters Maximum length: 255 characters |
name |
String |
The name of the target server. Minimum length: 0 characters Maximum length: 255 characters |
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 message returned for cloning failure. Minimum length: 0 characters Maximum length: 255 characters |
clone_state |
String |
The cloning status. Minimum length: 0 characters Maximum length: 255 characters |
error_msg |
String |
The error message returned for cloning failure. Minimum length: 0 characters Maximum length: 1,024 characters |
Parameter |
Type |
Description |
---|---|---|
name |
String |
The disk name. Minimum length: 0 characters Maximum length: 255 characters |
partition_style |
String |
The disk partition type. This parameter is mandatory for source server registration. The value can be: |
device_use |
String |
The disk type. The value can be: |
size |
Long |
The disk size, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
used_size |
Long |
The used disk space, in bytes. Minimum value: 0 Maximum value: 9223372036854775807 |
physical_volumes |
Array of PhysicalVolume objects |
The physical partition information of the disk. Array length: 0 to 65,535 characters |
os_disk |
Boolean |
Specifies whether the disk is the system disk. |
relation_name |
String |
The name of the corresponding disk on the target server running Linux. Minimum length: 0 characters Maximum length: 255 characters |
inode_size |
Integer |
The number of inodes. Minimum value: 0 Maximum value: 2147483647 |
Parameter |
Type |
Description |
---|---|---|
device_use |
String |
The partition function. The value can be NORMAL, BOOT, or OS. Minimum length: 0 characters Maximum length: 255 characters |
file_system |
String |
The file system type. Minimum length: 0 characters Maximum length: 255 characters |
index |
Integer |
The serial number of the volume. Minimum value: 0 Maximum value: 2147483647 |
mount_point |
String |
The mount point. Minimum length: 0 characters Maximum length: 255 characters |
name |
String |
The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID. 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 |
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 |
The UUID. |
String |
The GUID, which can be obtained from the source server. Minimum length: 0 characters Maximum length: 255 characters |
size_per_cluster |
Integer |
The size of each cluster. Minimum value: 0 Maximum value: 2147483647 |
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 characters |
name |
String |
The name. Minimum length: 0 characters Maximum length: 255 characters |
size |
Long |
The size. Minimum value: 0 Maximum value: 9223372036854775807 |
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 value can be NORMAL, BOOT, or OS. 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 |
Parameter |
Type |
Description |
---|---|---|
name |
String |
The file system name. Minimum length: 0 characters Maximum length: 255 characters |
label |
String |
The file system tag. If no tag exists, the value is an empty string. Minimum length: 0 characters Maximum length: 255 characters |
The UUID. |
String |
The UUID of the file system. Minimum length: 0 characters Maximum length: 255 characters |
device |
String |
The device name in the Btrfs. Minimum length: 0 characters Maximum length: 255 characters |
size |
Long |
The space occupied by the file system. Minimum value: 0 Maximum value: 9223372036854775807 |
nodesize |
Long |
The size of the Btrfs node. Minimum value: 0 Maximum value: 9223372036854775807 |
sectorsize |
Integer |
The sector size. Minimum value: 0 Maximum value: 2147483647 |
data_profile |
String |
The data profile (RAD). Minimum length: 0 characters Maximum length: 255 characters |
system_profile |
String |
The file system profile (RAD). Minimum length: 0 characters Maximum length: 255 characters |
metadata_profile |
String |
The metadata profile (RAD). Minimum length: 0 characters Maximum length: 255 characters |
global_reserve1 |
String |
The Btrfs file system information. Minimum length: 0 characters Maximum length: 255 characters |
g_vol_used_size |
Long |
The used space of the Btrfs volume. Minimum value: 0 Maximum value: 9223372036854775807 |
default_subvolid |
String |
The ID of the default subvolume. Minimum length: 0 characters Maximum length: 255 characters |
default_subvol_name |
String |
The name of the default subvolume. Minimum length: 0 characters Maximum length: 255 characters |
default_subvol_mountpath |
String |
The mount path of the default subvolume or Btrfs file system. Minimum length: 0 characters Maximum length: 255 characters |
subvolume |
Array of BtrfsSubvolumn objects |
The subvolume information. Array length: 0 to 65,535 characters |
Parameter |
Type |
Description |
---|---|---|
The UUID. |
String |
The UUID of the parent volume. Minimum length: 0 characters Maximum length: 255 characters |
is_snapshot |
String |
Specifies whether the subvolume is a snapshot. Minimum length: 0 characters Maximum length: 255 characters |
subvol_id |
String |
The subvolume ID. Minimum length: 0 characters Maximum length: 255 characters |
parent_id |
String |
The parent volume ID. Minimum length: 0 characters Maximum length: 255 characters |
subvol_name |
String |
The subvolume name. Minimum length: 0 characters Maximum length: 255 characters |
subvol_mount_path |
String |
The mount path of the subvolume. Minimum length: 0 characters Maximum length: 255 characters |
Parameter |
Type |
Description |
---|---|---|
name |
String |
The NIC name. Minimum length: 0 characters Maximum length: 255 characters |
ip |
String |
The IP address bound to the NIC. Minimum length: 0 characters Maximum length: 255 characters |
netmask |
String |
The subnet mask. Minimum length: 0 characters Maximum length: 255 characters |
gateway |
String |
The gateway. Minimum length: 0 characters Maximum length: 255 characters |
mtu |
Integer |
The NIC MTU. This parameter is mandatory for Linux. Minimum value: 0 Maximum value: 2147483647 |
mac |
String |
The MAC address. Minimum length: 0 characters Maximum length: 255 characters |
id |
String |
The database ID. Minimum length: 0 characters Maximum length: 255 characters |
Parameter |
Type |
Description |
---|---|---|
id |
Long |
The check item ID. Minimum value: 0 Maximum value: 9223372036854775807 |
params |
Array of strings |
Parameter Minimum length: 0 characters Maximum length: 255 characters Array length: 0 to 65,535 characters |
name |
String |
The check item name. Minimum length: 0 characters Maximum length: 255 characters |
result |
String |
The check result. Minimum length: 0 characters Maximum length: 255 characters The value can be: |
error_code |
String |
The returned error code. Minimum length: 0 characters Maximum length: 255 characters |
error_or_warn |
String |
The error or warning. Minimum length: 0 characters Maximum length: 255 characters |
error_params |
String |
The parameters that failed the check. Minimum length: 0 characters Maximum length: 255 characters |
Example Request
This example queries the information about the source server with ID 211d7878-d7ba-4cac-acf1-a02ccfb8xxxx.
GET https://{endpoint}/v3/sources/211d7878-d7ba-4cac-acf1-a02ccfb8xxxx
Example Response
Status code: 200
OK
{ "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 }
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 |
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(); 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 |
# 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() 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 |
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{} response, err := client.ShowServer(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 |
Response returned. |
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot