Creating EVS Disks
Function
This API is used to create a pay-per-use or yearly/monthly EVS disk.
Calling Method
For details, see Calling APIs.
URI
POST /v2.1/{project_id}/cloudvolumes
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
The project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
The user token. It 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. |
X-Client-Token |
No |
String |
The idempotence identifier of a request. This parameter value is generated by the client and must be unique among requests. The value is a 36-digit character string in the UUID format and is valid for 8 hours. If multiple requests carry the same idempotent identifier, the requests are considered as an idempotent request and the same response body is returned. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
bssParam |
No |
BssParamForCreateVolume object |
The extended parameter of pay-per-use and yearly/monthly billing. |
volume |
Yes |
CreateVolumeOption object |
The information of the disk to be created. |
server_id |
No |
String |
The server to attach the disk. The billing mode of the created disk is the same as that of the server. Only ECSs are supported currently. BMSs are not supported. |
OS-SCH-HNT:scheduler_hints |
No |
CreateVolumeSchedulerHints object |
The disk scheduling parameter, which can be used to create the disk in a dedicated storage pool. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
chargingMode |
No |
String |
The billing mode. The default value is postPaid. Values:
Default: postPaid Enumeration values:
|
isAutoPay |
No |
String |
Whether to pay immediately. This parameter is valid only when chargingMode is set to prePaid. The default value is false. Values:
Default: false Enumeration values:
|
isAutoRenew |
No |
String |
Whether to automatically renew the subscription. This parameter is valid only when chargingMode is set to prePaid. The default value is false. Values:
Default: false Enumeration values:
|
periodNum |
No |
Integer |
The subscription term. This parameter is valid and mandatory only when chargingMode is set to prePaid. Values:
|
periodType |
No |
String |
The unit of the subscription term. This parameter is valid and mandatory only when chargingMode is set to prePaid. Values:
Enumeration values:
|
cloudServiceConsoleURL |
No |
String |
The URL used to switch to the cloud service console to view information after the subscription is complete. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
availability_zone |
Yes |
String |
The AZ where you want to create the disk. |
backup_id |
No |
String |
The backup ID. This parameter is mandatory when you create the disk from a backup. |
count |
No |
Integer |
The number of disks to be created in a batch. If this parameter is not specified, only one disk will be created. You can create a maximum of 100 disks in a batch. If the disk is created from a backup, batch creation is not possible, and this parameter must be set to 1. If the specified value is a decimal number, the number part will be used by default. |
description |
No |
String |
The disk description. You can enter up to 85 characters. |
enterprise_project_id |
No |
String |
The enterprise project ID. This ID is associated with the disk during the disk creation. |
imageRef |
No |
String |
The image ID. If this parameter is specified, the disk is created from an image. |
metadata |
No |
Map<String,String> |
The disk metadata information. The value can be as follows: __system__cmkid: The encryption CMK ID in metadata. This parameter is used together with __system__encrypted for encryption. The length of cmkid is fixed at 36 bytes.
NOTE:
For details about how to obtain the key ID, see Querying the Key List. __system__encrypted: The encryption field in metadata. The value can be 0 (does not encrypt) or 1 (encrypts). If this parameter is not specified, the encryption attribute of the disk is the same as that of the data source. If the disk is not created from a data source, the disk is not encrypted by default. [full_clone] If the disk is created from a snapshot and linked cloning needs to be used, set this parameter to 0. [hw:passthrough]
|
multiattach |
No |
Boolean |
Whether the disk is shareable. The value can be true (shareable) or false (non-shareable). |
name |
No |
String |
The disk name. If you create one disk, the name value is the disk name. You can enter up to 64 characters. If you create multiple disks (the count value greater than 1), the system automatically adds a hyphen followed by a four-digit incremental number, such as -0000, to the end of each disk name. For example, the disk names can be volume-0001 and volume-0002. |
size |
Yes |
Integer |
The disk size, in GiB. The restrictions are as follows:
|
snapshot_id |
No |
String |
The snapshot ID. If this parameter is specified, the disk is created from a snapshot. |
volume_type |
Yes |
String |
The disk type. The value can be SATA, SAS, GPSSD, SSD, ESSD, GPSSD2, or ESSD2.
If the specified disk type is not available in the AZ, the disk will fail to be created.
NOTE:
When you create a disk from a snapshot, ensure that the disk type of the new disk is consistent with that of the snapshot's source disk. For details about disk types, see Enumeration values:
|
tags |
No |
Map<String,String> |
The disk tag information. |
sys_tags |
No |
Map<String,String> |
The disk system tag information. |
iops |
No |
Integer |
The configured IOPS. This parameter is mandatory only when a general purpose SSD V2 or an extreme SSD V2 disk is created.
NOTE:
To learn the IOPS ranges of the general purpose SSD V2 and extreme SSD V2 disks, see [ [the table of EVS performance data in Disk Types and Performance.
|
throughput |
No |
Integer |
The configured throughput, in the unit of MiB/s. This parameter is mandatory only when a general purpose SSD V2 disk is created.
NOTE:
To learn the throughput range of the general purpose SSD V2 disks, see [ [the table of EVS performance data in Disk Types and Performance.
|
Response Parameters
Status code: 202
Parameter |
Type |
Description |
---|---|---|
job_id |
String |
The task ID. This parameter is returned when the disk is billed on a pay-per-use basis.
|
order_id |
String |
The order ID. This parameter is returned when the disk is billed on a yearly/monthly basis.
|
volume_ids |
Array of strings |
The IDs of the disks to be created.
|
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
The error message returned if an error occurs. For details, seeParameters in the error field. |
Parameter |
Type |
Description |
---|---|---|
code |
String |
The error code returned if an error occurs. For the error codes and their meanings, see Error Codes. |
message |
String |
The error message returned if an error occurs. |
Example Requests
-
Creating a shared, encrypted EVS disk in storage pool 1b6198f2-20a6-5dcc-aa21-58c1af5dc488 (Deploy the disk in AZ 1 of CN-Hong Kong. Set the disk name to EVS-Test, device type to SCSI, disk type to high I/O, and size to 10 GiB.)
POST https://{endpoint}/v2.1/{project_id}/cloudvolumes { "volume" : { "availability_zone" : "ap-southeast-1a", "size" : 10, "name" : "EVS-Test", "volume_type" : "SAS", "metadata" : { "hw:passthrough" : "true", "__system__encrypted" : "1", "__system__cmkid" : "94257794-d7aa-462c-9eaa-9f32c05b9966", "region" : "ap-southeast-1" }, "multiattach" : true, "enterprise_project_id" : "0" }, "OS-SCH-HNT:scheduler_hints" : { "dedicated_storage_id" : "1b6198f2-20a6-5dcc-aa21-58c1af5dc488" } }
-
Creating a shared EVS disk (Deploy the disk in AZ 1 of the CN-Hong Kong region. Set the disk name to EVS-Test2, type to general purpose SSD V2, IOPS to 5,000, throughput to 500 MiB/s, size to 100 GiB, and subscription period to three months. Add tags to the disk. Enable automatic subscription renewal. You will be billed for the disk immediately after the order is placed.)
POST https://{endpoint}/v2.1/{project_id}/cloudvolumes { "volume": { "count": 1, "availability_zone": "ap-southeast-1", "size": 100, "name": "EVS-Test2", "volume_type": "GPSSD2", "metadata": {}, "tags": { "key_string": "value_string" }, "iops": 5000, "throughput": 500, "multiattach": 1 }, "bssParam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 3, "isAutoPay": true, "isAutoRenew": true, } }
Example Responses
Status code: 202
Accepted
{ "job_id" : "70a599e0-31e7-49b7-b260-868f441e862b", "volume_ids" : [ "e1fa3e72-8c92-4871-9152-bf66fef0afe9" ] }
Status code: 400
Bad Request
{ "error" : { "message" : "XXXX", "code" : "XXX" } }
SDK Sample Code
The SDK sample code is as follows.
-
Creating a shared, encrypted EVS disk in storage pool 1b6198f2-20a6-5dcc-aa21-58c1af5dc488 (Deploy the disk in AZ 1 of CN-Hong Kong. Set the disk name to EVS-Test, device type to SCSI, disk type to high I/O, and size to 10 GiB.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.evs.v2.region.EvsRegion; import com.huaweicloud.sdk.evs.v2.*; import com.huaweicloud.sdk.evs.v2.model.*; import java.util.Map; import java.util.HashMap; public class CreateVolumeSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); EvsClient client = EvsClient.newBuilder() .withCredential(auth) .withRegion(EvsRegion.valueOf("<YOUR REGION>")) .build(); CreateVolumeRequest request = new CreateVolumeRequest(); CreateVolumeRequestBody body = new CreateVolumeRequestBody(); CreateVolumeSchedulerHints osschhntschedulerhintsbody = new CreateVolumeSchedulerHints(); osschhntschedulerhintsbody.withDedicatedStorageId("1b6198f2-20a6-5dcc-aa21-58c1af5dc488"); Map<String, String> listVolumeMetadata = new HashMap<>(); listVolumeMetadata.put("hw:passthrough", "true"); listVolumeMetadata.put("__system__encrypted", "1"); listVolumeMetadata.put("__system__cmkid", "94257794-d7aa-462c-9eaa-9f32c05b9966"); listVolumeMetadata.put("region", "ap-southeast-1"); CreateVolumeOption volumebody = new CreateVolumeOption(); volumebody.withAvailabilityZone("ap-southeast-1a") .withEnterpriseProjectId("0") .withMetadata(listVolumeMetadata) .withMultiattach(true) .withName("EVS-Test") .withSize(10) .withVolumeType(CreateVolumeOption.VolumeTypeEnum.fromValue("SAS")); body.withOsSCHHNTSchedulerHints(osschhntschedulerhintsbody); body.withVolume(volumebody); request.withBody(body); try { CreateVolumeResponse response = client.createVolume(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()); } } }
-
Creating a shared EVS disk (Deploy the disk in AZ 1 of the CN-Hong Kong region. Set the disk name to EVS-Test2, type to general purpose SSD V2, IOPS to 5,000, throughput to 500 MiB/s, size to 100 GiB, and subscription period to three months. Add tags to the disk. Enable automatic subscription renewal. You will be billed for the disk immediately after the order is placed.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.evs.v2.region.EvsRegion; import com.huaweicloud.sdk.evs.v2.*; import com.huaweicloud.sdk.evs.v2.model.*; import java.util.Map; import java.util.HashMap; public class CreateVolumeSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); EvsClient client = EvsClient.newBuilder() .withCredential(auth) .withRegion(EvsRegion.valueOf("<YOUR REGION>")) .build(); CreateVolumeRequest request = new CreateVolumeRequest(); CreateVolumeRequestBody body = new CreateVolumeRequestBody(); Map<String, String> listVolumeTags = new HashMap<>(); listVolumeTags.put("key_string", "value_string"); CreateVolumeOption volumebody = new CreateVolumeOption(); volumebody.withAvailabilityZone("ap-southeast-1") .withCount(1) .withMultiattach(1) .withName("EVS-Test2") .withSize(100) .withVolumeType(CreateVolumeOption.VolumeTypeEnum.fromValue("GPSSD2")) .withTags(listVolumeTags) .withIops(5000) .withThroughput(500); BssParamForCreateVolume bssParambody = new BssParamForCreateVolume(); bssParambody.withChargingMode(BssParamForCreateVolume.ChargingModeEnum.fromValue("prePaid")) .withIsAutoPay(BssParamForCreateVolume.IsAutoPayEnum.fromValue("true")) .withIsAutoRenew(BssParamForCreateVolume.IsAutoRenewEnum.fromValue("true")) .withPeriodNum(3) .withPeriodType(BssParamForCreateVolume.PeriodTypeEnum.fromValue("month")); body.withVolume(volumebody); body.withBssParam(bssParambody); request.withBody(body); try { CreateVolumeResponse response = client.createVolume(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()); } } }
-
Creating a shared, encrypted EVS disk in storage pool 1b6198f2-20a6-5dcc-aa21-58c1af5dc488 (Deploy the disk in AZ 1 of CN-Hong Kong. Set the disk name to EVS-Test, device type to SCSI, disk type to high I/O, and size to 10 GiB.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkevs.v2.region.evs_region import EvsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkevs.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = EvsClient.new_builder() \ .with_credentials(credentials) \ .with_region(EvsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateVolumeRequest() osschhntschedulerhintsbody = CreateVolumeSchedulerHints( dedicated_storage_id="1b6198f2-20a6-5dcc-aa21-58c1af5dc488" ) listMetadataVolume = { "hw:passthrough": "true", "__system__encrypted": "1", "__system__cmkid": "94257794-d7aa-462c-9eaa-9f32c05b9966", "region": "ap-southeast-1" } volumebody = CreateVolumeOption( availability_zone="ap-southeast-1a", enterprise_project_id="0", metadata=listMetadataVolume, multiattach=True, name="EVS-Test", size=10, volume_type="SAS" ) request.body = CreateVolumeRequestBody( os_sch_hn_tscheduler_hints=osschhntschedulerhintsbody, volume=volumebody ) response = client.create_volume(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Creating a shared EVS disk (Deploy the disk in AZ 1 of the CN-Hong Kong region. Set the disk name to EVS-Test2, type to general purpose SSD V2, IOPS to 5,000, throughput to 500 MiB/s, size to 100 GiB, and subscription period to three months. Add tags to the disk. Enable automatic subscription renewal. You will be billed for the disk immediately after the order is placed.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkevs.v2.region.evs_region import EvsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkevs.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = EvsClient.new_builder() \ .with_credentials(credentials) \ .with_region(EvsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateVolumeRequest() listTagsVolume = { "key_string": "value_string" } volumebody = CreateVolumeOption( availability_zone="ap-southeast-1", count=1, multiattach=1, name="EVS-Test2", size=100, volume_type="GPSSD2", tags=listTagsVolume, iops=5000, throughput=500 ) bssParambody = BssParamForCreateVolume( charging_mode="prePaid", is_auto_pay="true", is_auto_renew="true", period_num=3, period_type="month" ) request.body = CreateVolumeRequestBody( volume=volumebody, bss_param=bssParambody ) response = client.create_volume(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Creating a shared, encrypted EVS disk in storage pool 1b6198f2-20a6-5dcc-aa21-58c1af5dc488 (Deploy the disk in AZ 1 of CN-Hong Kong. Set the disk name to EVS-Test, device type to SCSI, disk type to high I/O, and size to 10 GiB.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" evs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := evs.NewEvsClient( evs.EvsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateVolumeRequest{} dedicatedStorageIdOSSCHHNTschedulerHints:= "1b6198f2-20a6-5dcc-aa21-58c1af5dc488" osschhntschedulerhintsbody := &model.CreateVolumeSchedulerHints{ DedicatedStorageId: &dedicatedStorageIdOSSCHHNTschedulerHints, } var listMetadataVolume = map[string]string{ "hw:passthrough": "true", "__system__encrypted": "1", "__system__cmkid": "94257794-d7aa-462c-9eaa-9f32c05b9966", "region": "ap-southeast-1", } enterpriseProjectIdVolume:= "0" multiattachVolume:= true nameVolume:= "EVS-Test" volumebody := &model.CreateVolumeOption{ AvailabilityZone: "ap-southeast-1a", EnterpriseProjectId: &enterpriseProjectIdVolume, Metadata: listMetadataVolume, Multiattach: &multiattachVolume, Name: &nameVolume, Size: int32(10), VolumeType: model.GetCreateVolumeOptionVolumeTypeEnum().SAS, } request.Body = &model.CreateVolumeRequestBody{ OSSCHHNTschedulerHints: osschhntschedulerhintsbody, Volume: volumebody, } response, err := client.CreateVolume(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Creating a shared EVS disk (Deploy the disk in AZ 1 of the CN-Hong Kong region. Set the disk name to EVS-Test2, type to general purpose SSD V2, IOPS to 5,000, throughput to 500 MiB/s, size to 100 GiB, and subscription period to three months. Add tags to the disk. Enable automatic subscription renewal. You will be billed for the disk immediately after the order is placed.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" evs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := evs.NewEvsClient( evs.EvsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateVolumeRequest{} var listTagsVolume = map[string]string{ "key_string": "value_string", } countVolume:= int32(1) multiattachVolume:= 1 nameVolume:= "EVS-Test2" iopsVolume:= int32(5000) throughputVolume:= int32(500) volumebody := &model.CreateVolumeOption{ AvailabilityZone: "ap-southeast-1", Count: &countVolume, Multiattach: &multiattachVolume, Name: &nameVolume, Size: int32(100), VolumeType: model.GetCreateVolumeOptionVolumeTypeEnum().GPSSD2, Tags: listTagsVolume, Iops: &iopsVolume, Throughput: &throughputVolume, } chargingModeBssParam:= model.GetBssParamForCreateVolumeChargingModeEnum().PRE_PAID isAutoPayBssParam:= model.GetBssParamForCreateVolumeIsAutoPayEnum().TRUE isAutoRenewBssParam:= model.GetBssParamForCreateVolumeIsAutoRenewEnum().TRUE periodNumBssParam:= int32(3) periodTypeBssParam:= model.GetBssParamForCreateVolumePeriodTypeEnum().MONTH bssParambody := &model.BssParamForCreateVolume{ ChargingMode: &chargingModeBssParam, IsAutoPay: &isAutoPayBssParam, IsAutoRenew: &isAutoRenewBssParam, PeriodNum: &periodNumBssParam, PeriodType: &periodTypeBssParam, } request.Body = &model.CreateVolumeRequestBody{ Volume: volumebody, BssParam: bssParambody, } response, err := client.CreateVolume(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 |
---|---|
202 |
Accepted |
400 |
Bad Request |
Error Codes
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