Updating an EVS Disk
Function
This API is used to update the name and description of an EVS disk.
Calling Method
For details, see Calling APIs.
URI
PUT /v2/{project_id}/cloudvolumes/{volume_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition The project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
volume_id |
Yes |
String |
Definition The disk ID. You can obtain it on the disk list page of the EVS console. Constraints N/A Range N/A Default Value N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition The user token. You can obtain it by calling the IAM API. The value of X-Subject-Token in the response header is the user token. Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
volume |
Yes |
UpdateVolumeOption object |
Definition The information of the disk to be modified. Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
description |
No |
String |
Definition The new disk description. Constraints name and description cannot both be null. It can contain a maximum of 85 characters. Range N/A Default Value N/A |
name |
No |
String |
Definition The new disk name. Constraints name and description cannot both be null. It can contain a maximum of 64 characters. Range N/A Default Value N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
attachments |
Array of Attachment objects |
Definition Whether the disk is attached. Range N/A |
availability_zone |
String |
Definition The AZ to which the disk belongs. Range N/A |
bootable |
String |
Definition Whether the disk is bootable. Range N/A |
created_at |
String |
Definition The time when the disk was created. Range N/A |
id |
String |
Definition The disk ID. Range N/A |
links |
Array of Link objects |
Definition The disk URI. Range N/A |
metadata |
VolumeMetadata object |
Definition The disk metadata. Range N/A |
multiattach |
Boolean |
Definition Whether the disk is shareable. Range N/A |
name |
String |
Definition The disk name. Range N/A |
os-vol-host-attr:host |
String |
Definition The reserved field. Range N/A |
os-vol-tenant-attr:tenant_id |
String |
Definition The ID of the project to which the disk belongs. Range N/A |
shareable |
String |
Definition Whether the disk is shareable. Range N/A |
size |
Integer |
Definition The disk capacity. Range N/A |
snapshot_id |
String |
Definition The snapshot ID. Range N/A |
source_volid |
String |
Definition The reserved field. Range N/A |
status |
String |
Definition The disk status. Range N/A |
volume_image_metadata |
Object |
Definition The metadata of the disk image. For details about the volume_image_metadata field, see Querying Image Details (Native OpenStack API). Range N/A |
volume_type |
String |
Definition The disk type. Range N/A |
description |
String |
Definition The disk description. Range N/A |
os-volume-replication:extended_status |
String |
Definition The reserved field. Range N/A |
Parameter |
Type |
Description |
---|---|---|
attached_at |
String |
Definition The time when the disk was attached. Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX Range N/A |
attachment_id |
String |
Definition The attachment ID. Range N/A |
device |
String |
Definition The device name. Range N/A |
host_name |
String |
Definition The name of the physical host housing the cloud server to which the disk is attached. Range N/A |
id |
String |
Definition The ID of the attached disk. Range N/A |
server_id |
String |
Definition The ID of the server to which the disk is attached. Range N/A |
volume_id |
String |
Definition The disk ID. Range N/A |
Parameter |
Type |
Description |
---|---|---|
href |
String |
Definition The corresponding shortcut link. Range N/A |
rel |
String |
Definition The shortcut link marker name. Range N/A |
Parameter |
Type |
Description |
---|---|---|
__system__cmkid |
String |
Definition 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. For details about how to obtain the key ID, see Querying the Key List. Range N/A |
__system__encrypted |
String |
Definition The encryption field in metadata. The value can be 0 (no encryption) or 1 (encryption). 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. Range 0 (no encryption) or 1 (encryption) |
hw:passthrough |
String |
Definition The disk device type. Range
|
orderID |
String |
Definition The parameter that describes the disk billing mode in metadata. If this parameter has a value, the disk is billed on a yearly/monthly basis. If this parameter is not specified, the disk is billed on a pay-per-use basis. Range N/A |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
Definition The error code returned if an error occurs. For the error codes and their meanings, see Error Codes. Range N/A |
Parameter |
Type |
Description |
---|---|---|
code |
String |
Definition The error code returned if an error occurs. Range For the error codes and their meanings, see Error Codes. |
message |
String |
Definition The error message returned if an error occurs. Range N/A |
Example Requests
Updating the EVS disk name and description
PUT https://{endpoint}/v2/{project_id}/cloudvolumes/{volume_id} { "volume" : { "name" : "test_volume", "description" : "test" } }
Example Responses
Status code: 200
OK
{ "id" : "36ba39af-3579-4e6e-adfc-b764349c0f77", "links" : [ { "href" : "https://volume.region.xxx.xxx-tsi.de/v2/3cfb09080bd944d0b4cdd72ef26857bd/volumes/36ba39af-3579-4e6e-adfc-b764349c0f77", "rel" : "self" }, { "href" : "https://volume.region.xxx.xxx-tsi.de/3cfb09080bd944d0b4cdd72ef26857bd/volumes/36ba39af-3579-4e6e-adfc-b764349c0f77", "rel" : "bookmark" } ], "name" : "newVolume", "status" : "in-use", "attachments" : [ { "server_id" : "c3d3250c-7ce5-42cc-b620-dd2b63d19ca5", "attachment_id" : "011a2bdb-a033-4479-845b-50bd8ed7f4d4", "attached_at" : "2017-05-23T11:27:38.604815", "volume_id" : "36ba39af-3579-4e6e-adfc-b764349c0f77", "device" : "/dev/sdf", "id" : "36ba39af-3579-4e6e-adfc-b764349c0f77" } ], "description" : "new volume", "multiattach" : false, "shareable" : false, "size" : 10, "metadata" : { "hw:passthrough" : "false" }, "bootable" : "false", "availability_zone" : "az-dc-1", "created_at" : "2017-05-23T09:49:44.481299", "volume_type" : "SATA" }
Status code: 400
Bad Request
{ "error" : { "message" : "XXXX", "code" : "XXX" } }
SDK Sample Code
The SDK sample code is as follows.
Java
Updating the EVS disk name and description
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 |
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.*; public class UpdateVolumeSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); EvsClient client = EvsClient.newBuilder() .withCredential(auth) .withRegion(EvsRegion.valueOf("<YOUR REGION>")) .build(); UpdateVolumeRequest request = new UpdateVolumeRequest(); request.withVolumeId("{volume_id}"); UpdateVolumeRequestBody body = new UpdateVolumeRequestBody(); UpdateVolumeOption volumebody = new UpdateVolumeOption(); volumebody.withDescription("test") .withName("test_volume"); body.withVolume(volumebody); request.withBody(body); try { UpdateVolumeResponse response = client.updateVolume(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
Updating the EVS disk name and description
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 |
# coding: utf-8 import os 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.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = EvsClient.new_builder() \ .with_credentials(credentials) \ .with_region(EvsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateVolumeRequest() request.volume_id = "{volume_id}" volumebody = UpdateVolumeOption( description="test", name="test_volume" ) request.body = UpdateVolumeRequestBody( volume=volumebody ) response = client.update_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) |
Go
Updating the EVS disk name and description
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 |
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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := evs.NewEvsClient( evs.EvsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateVolumeRequest{} request.VolumeId = "{volume_id}" descriptionVolume:= "test" nameVolume:= "test_volume" volumebody := &model.UpdateVolumeOption{ Description: &descriptionVolume, Name: &nameVolume, } request.Body = &model.UpdateVolumeRequestBody{ Volume: volumebody, } response, err := client.UpdateVolume(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
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 |
OK |
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