修改实例规格信息
功能介绍
修改设备接入实例的规格。
调用方法
请参见如何调用API。
URI
POST /v5/iot/{project_id}/iotda-instances/{instance_id}/resize
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数说明:项目ID。获取方法请参见 获取项目ID 。 |
instance_id |
是 |
String |
参数说明:实例ID。 取值范围:长度不超过36,由小写字母[a-f]、数字、连接符(-)的组成。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
否 |
String |
参数说明:用户Token。通过调用IAM服务 获取IAM用户Token接口获取,接口返回的响应消息头中“X-Subject-Token”就是需要获取的用户Token。简要的获取方法样例请参见 Token认证。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
flavor |
是 |
Flavor object |
参数说明:设备接入实例的规格参数。 |
is_auto_pay |
否 |
Boolean |
参数说明:修改包年/包月实例的规格时可指定,表示是否自动从客户的账户中支付,此字段不影响自动续订的支付方式。 取值范围:true - 自动支付,从账户余额自动扣费; false - 默认值,只提交订单不支付。需要客户参考支付包年/包月产品订单进行支付,或者在华为云官网页面使用进行支付。 |
delay |
否 |
Boolean |
参数说明:是否延时变更设备实例的计费信息。约束:如需延时变更,需要先设置实例的变更时间窗。 取值范围:
|
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
order_id |
String |
参数说明:订单号,修改包年包月实例时返回该参数,修改按需实例时返回为空。查看订单详情请参考查询订单详情。 |
请求示例
修改标准版实例规格,修改后的规格为标准版中频单元,单元个数为2。
POST https://{endpoint}/v5/iot/{project_id}/iotda-instances/{instance_id}/resize { "flavor" : { "type" : "iotda.standard.s2", "size" : 2 } }
响应示例
状态码: 200
OK
{ "order_id" : "CS22121614500ABCD" }
SDK代码示例
SDK代码示例如下。
修改标准版实例规格,修改后的规格为标准版中频单元,单元个数为2。
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.iotdm.v5.region.IoTDMRegion; import com.huaweicloud.sdk.iotdm.v5.*; import com.huaweicloud.sdk.iotdm.v5.model.*; public class ResizeInstanceSolution { 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); IoTDMClient client = IoTDMClient.newBuilder() .withCredential(auth) .withRegion(IoTDMRegion.valueOf("<YOUR REGION>")) .build(); ResizeInstanceRequest request = new ResizeInstanceRequest(); request.withInstanceId("{instance_id}"); ResizeInstance body = new ResizeInstance(); Flavor flavorbody = new Flavor(); flavorbody.withType("iotda.standard.s2") .withSize(2); body.withFlavor(flavorbody); request.withBody(body); try { ResizeInstanceResponse response = client.resizeInstance(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()); } } } |
修改标准版实例规格,修改后的规格为标准版中频单元,单元个数为2。
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 huaweicloudsdkiotdm.v5.region.iotdm_region import IoTDMRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkiotdm.v5 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 = IoTDMClient.new_builder() \ .with_credentials(credentials) \ .with_region(IoTDMRegion.value_of("<YOUR REGION>")) \ .build() try: request = ResizeInstanceRequest() request.instance_id = "{instance_id}" flavorbody = Flavor( type="iotda.standard.s2", size=2 ) request.body = ResizeInstance( flavor=flavorbody ) response = client.resize_instance(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
修改标准版实例规格,修改后的规格为标准版中频单元,单元个数为2。
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 main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" iotdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/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 := iotdm.NewIoTDMClient( iotdm.IoTDMClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ResizeInstanceRequest{} request.InstanceId = "{instance_id}" sizeFlavor:= int32(2) flavorbody := &model.Flavor{ Type: "iotda.standard.s2", Size: &sizeFlavor, } request.Body = &model.ResizeInstance{ Flavor: flavorbody, } response, err := client.ResizeInstance(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
错误码
请参见错误码。