更新订阅资源 - UpdateSubscriptionOrder
功能介绍
更新订阅资源
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
PUT /v1/{project_id}/subscriptions/orders
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
租户projectId |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
|
X-Language |
是 |
String |
用户当前语言环境 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
scene |
是 |
String |
操作场景,包周期场景:PREPAID 或者 按需场景:POSTPAID |
|
operate_type |
是 |
String |
按需或者包周期场景下,要进行的操作类型 比如增减配额,规格升降配,按需转包周期 规格升级:UPGRADE,配额增加:ADDITION,配额减少:DECREASE,按需转包周期:POSTPAID_2_PREPAID 注:目前不支持规格降级,比如不支持从专业版降级为标准版或基础版 |
|
promotion_info |
否 |
String |
促销折扣信息 |
|
tag_list |
否 |
Array of SubscriptionTag objects |
计费标签 |
|
product_list |
否 |
Array of UpdateProduct objects |
要进行变更的商品列表 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
order_id |
String |
创建或变更订单ID,只有scene为PREPAID时返回有此数据 |
|
order_status |
Integer |
订单更新状态,1:变更订单成功,5,订单变更失败 |
状态码:400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
参数解释: 错误码 取值范围: 不涉及 |
|
error_msg |
String |
参数解释: 错误描述 取值范围: 不涉及 |
状态码:403
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
参数解释: 错误码 取值范围: 不涉及 |
|
error_msg |
String |
参数解释: 错误描述 取值范围: 不涉及 |
状态码:404
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
参数解释: 错误码 取值范围: 不涉及 |
|
error_msg |
String |
参数解释: 错误描述 取值范围: 不涉及 |
请求示例
-
{ "scene" : "PREPAID", "operate_type" : "UPGRADE", "product_list" : [ { "resource_type" : "xxx.resource.type.secmaster.typical", "resource_spec_code" : "secmaster.professional", "resource_size" : 3, "resource_id" : "e6d9047a-3478-4867-8c0d-7c4cfed1685b" } ], "tag_list" : [ { "key" : "testKey3", "value" : "testVal3" } ] } -
{ "scene" : "POSTPAID", "operate_type" : "ADDITION", "product_list" : [ { "resource_type" : "xxx.resource.type.secmaster.typical", "resource_spec_code" : "secmaster.professional", "resource_size" : 3, "resource_id" : "e6d9047a-3478-4867-8c0d-7c4cfed1685b" } ], "tag_list" : [ { "key" : "testKey3", "value" : "testVal3" } ] } -
{ "scene" : "POSTPAID", "operate_type" : "DECREASE", "product_list" : [ { "resource_type" : "xxx.resource.type.secmaster.typical", "resource_spec_code" : "secmaster.professional", "resource_size" : 2, "resource_id" : "e6d9047a-3478-4867-8c0d-7c4cfed1685b" } ], "tag_list" : [ { "key" : "testKey3", "value" : "testVal3" } ] } -
{ "scene" : "POSTPAID", "operate_type" : "POSTPAID_2_PREPAID", "product_list" : [ { "resource_spec_code" : "secmaster.professional", "resource_id" : "e6d9047a-3478-4867-8c0d-7c4cfed1685b" } ] }
响应示例
状态码:200
接口请求成功
{
"order_id" : "CS2510212051NLDL4",
"order_status" : 1
}
SDK代码示例
SDK代码示例如下。
-
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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSubscriptionOrderSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); UpdateSubscriptionOrderRequest request = new UpdateSubscriptionOrderRequest(); UpdateOrderInfoReq body = new UpdateOrderInfoReq(); List<UpdateProduct> listbodyProductList = new ArrayList<>(); listbodyProductList.add( new UpdateProduct() .withResourceType("xxx.resource.type.secmaster.typical") .withResourceSpecCode("secmaster.professional") .withResourceSize(3) .withResourceId("e6d9047a-3478-4867-8c0d-7c4cfed1685b") ); List<SubscriptionTag> listbodyTagList = new ArrayList<>(); listbodyTagList.add( new SubscriptionTag() .withKey("testKey3") .withValue("testVal3") ); body.withProductList(listbodyProductList); body.withTagList(listbodyTagList); body.withOperateType(UpdateOrderInfoReq.OperateTypeEnum.fromValue("UPGRADE")); body.withScene(UpdateOrderInfoReq.SceneEnum.fromValue("PREPAID")); request.withBody(body); try { UpdateSubscriptionOrderResponse response = client.updateSubscriptionOrder(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 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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSubscriptionOrderSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); UpdateSubscriptionOrderRequest request = new UpdateSubscriptionOrderRequest(); UpdateOrderInfoReq body = new UpdateOrderInfoReq(); List<UpdateProduct> listbodyProductList = new ArrayList<>(); listbodyProductList.add( new UpdateProduct() .withResourceType("xxx.resource.type.secmaster.typical") .withResourceSpecCode("secmaster.professional") .withResourceSize(3) .withResourceId("e6d9047a-3478-4867-8c0d-7c4cfed1685b") ); List<SubscriptionTag> listbodyTagList = new ArrayList<>(); listbodyTagList.add( new SubscriptionTag() .withKey("testKey3") .withValue("testVal3") ); body.withProductList(listbodyProductList); body.withTagList(listbodyTagList); body.withOperateType(UpdateOrderInfoReq.OperateTypeEnum.fromValue("ADDITION")); body.withScene(UpdateOrderInfoReq.SceneEnum.fromValue("POSTPAID")); request.withBody(body); try { UpdateSubscriptionOrderResponse response = client.updateSubscriptionOrder(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 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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSubscriptionOrderSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); UpdateSubscriptionOrderRequest request = new UpdateSubscriptionOrderRequest(); UpdateOrderInfoReq body = new UpdateOrderInfoReq(); List<UpdateProduct> listbodyProductList = new ArrayList<>(); listbodyProductList.add( new UpdateProduct() .withResourceType("xxx.resource.type.secmaster.typical") .withResourceSpecCode("secmaster.professional") .withResourceSize(2) .withResourceId("e6d9047a-3478-4867-8c0d-7c4cfed1685b") ); List<SubscriptionTag> listbodyTagList = new ArrayList<>(); listbodyTagList.add( new SubscriptionTag() .withKey("testKey3") .withValue("testVal3") ); body.withProductList(listbodyProductList); body.withTagList(listbodyTagList); body.withOperateType(UpdateOrderInfoReq.OperateTypeEnum.fromValue("DECREASE")); body.withScene(UpdateOrderInfoReq.SceneEnum.fromValue("POSTPAID")); request.withBody(body); try { UpdateSubscriptionOrderResponse response = client.updateSubscriptionOrder(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 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
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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateSubscriptionOrderSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); UpdateSubscriptionOrderRequest request = new UpdateSubscriptionOrderRequest(); UpdateOrderInfoReq body = new UpdateOrderInfoReq(); List<UpdateProduct> listbodyProductList = new ArrayList<>(); listbodyProductList.add( new UpdateProduct() .withResourceSpecCode("secmaster.professional") .withResourceId("e6d9047a-3478-4867-8c0d-7c4cfed1685b") ); body.withProductList(listbodyProductList); body.withOperateType(UpdateOrderInfoReq.OperateTypeEnum.fromValue("POSTPAID_2_PREPAID")); body.withScene(UpdateOrderInfoReq.SceneEnum.fromValue("POSTPAID")); request.withBody(body); try { UpdateSubscriptionOrderResponse response = client.updateSubscriptionOrder(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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSubscriptionOrderRequest() listProductListbody = [ UpdateProduct( resource_type="xxx.resource.type.secmaster.typical", resource_spec_code="secmaster.professional", resource_size=3, resource_id="e6d9047a-3478-4867-8c0d-7c4cfed1685b" ) ] listTagListbody = [ SubscriptionTag( key="testKey3", value="testVal3" ) ] request.body = UpdateOrderInfoReq( product_list=listProductListbody, tag_list=listTagListbody, operate_type="UPGRADE", scene="PREPAID" ) response = client.update_subscription_order(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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSubscriptionOrderRequest() listProductListbody = [ UpdateProduct( resource_type="xxx.resource.type.secmaster.typical", resource_spec_code="secmaster.professional", resource_size=3, resource_id="e6d9047a-3478-4867-8c0d-7c4cfed1685b" ) ] listTagListbody = [ SubscriptionTag( key="testKey3", value="testVal3" ) ] request.body = UpdateOrderInfoReq( product_list=listProductListbody, tag_list=listTagListbody, operate_type="ADDITION", scene="POSTPAID" ) response = client.update_subscription_order(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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSubscriptionOrderRequest() listProductListbody = [ UpdateProduct( resource_type="xxx.resource.type.secmaster.typical", resource_spec_code="secmaster.professional", resource_size=2, resource_id="e6d9047a-3478-4867-8c0d-7c4cfed1685b" ) ] listTagListbody = [ SubscriptionTag( key="testKey3", value="testVal3" ) ] request.body = UpdateOrderInfoReq( product_list=listProductListbody, tag_list=listTagListbody, operate_type="DECREASE", scene="POSTPAID" ) response = client.update_subscription_order(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 37 38 39 40 41 42
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateSubscriptionOrderRequest() listProductListbody = [ UpdateProduct( resource_spec_code="secmaster.professional", resource_id="e6d9047a-3478-4867-8c0d-7c4cfed1685b" ) ] request.body = UpdateOrderInfoReq( product_list=listProductListbody, operate_type="POSTPAID_2_PREPAID", scene="POSTPAID" ) response = client.update_subscription_order(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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSubscriptionOrderRequest{} var listProductListbody = []model.UpdateProduct{ { ResourceType: "xxx.resource.type.secmaster.typical", ResourceSpecCode: "secmaster.professional", ResourceSize: int32(3), ResourceId: "e6d9047a-3478-4867-8c0d-7c4cfed1685b", }, } keyTagList:= "testKey3" valueTagList:= "testVal3" var listTagListbody = []model.SubscriptionTag{ { Key: &keyTagList, Value: &valueTagList, }, } request.Body = &model.UpdateOrderInfoReq{ ProductList: &listProductListbody, TagList: &listTagListbody, OperateType: model.GetUpdateOrderInfoReqOperateTypeEnum().UPGRADE, Scene: model.GetUpdateOrderInfoReqSceneEnum().PREPAID, } response, err := client.UpdateSubscriptionOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSubscriptionOrderRequest{} var listProductListbody = []model.UpdateProduct{ { ResourceType: "xxx.resource.type.secmaster.typical", ResourceSpecCode: "secmaster.professional", ResourceSize: int32(3), ResourceId: "e6d9047a-3478-4867-8c0d-7c4cfed1685b", }, } keyTagList:= "testKey3" valueTagList:= "testVal3" var listTagListbody = []model.SubscriptionTag{ { Key: &keyTagList, Value: &valueTagList, }, } request.Body = &model.UpdateOrderInfoReq{ ProductList: &listProductListbody, TagList: &listTagListbody, OperateType: model.GetUpdateOrderInfoReqOperateTypeEnum().ADDITION, Scene: model.GetUpdateOrderInfoReqSceneEnum().POSTPAID, } response, err := client.UpdateSubscriptionOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSubscriptionOrderRequest{} var listProductListbody = []model.UpdateProduct{ { ResourceType: "xxx.resource.type.secmaster.typical", ResourceSpecCode: "secmaster.professional", ResourceSize: int32(2), ResourceId: "e6d9047a-3478-4867-8c0d-7c4cfed1685b", }, } keyTagList:= "testKey3" valueTagList:= "testVal3" var listTagListbody = []model.SubscriptionTag{ { Key: &keyTagList, Value: &valueTagList, }, } request.Body = &model.UpdateOrderInfoReq{ ProductList: &listProductListbody, TagList: &listTagListbody, OperateType: model.GetUpdateOrderInfoReqOperateTypeEnum().DECREASE, Scene: model.GetUpdateOrderInfoReqSceneEnum().POSTPAID, } response, err := client.UpdateSubscriptionOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateSubscriptionOrderRequest{} var listProductListbody = []model.UpdateProduct{ { ResourceSpecCode: "secmaster.professional", ResourceId: "e6d9047a-3478-4867-8c0d-7c4cfed1685b", }, } request.Body = &model.UpdateOrderInfoReq{ ProductList: &listProductListbody, OperateType: model.GetUpdateOrderInfoReqOperateTypeEnum().POSTPAID_2_PREPAID, Scene: model.GetUpdateOrderInfoReqSceneEnum().POSTPAID, } response, err := client.UpdateSubscriptionOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
接口请求成功 |
|
400 |
请求参数异常 |
|
403 |
权限不足 |
|
404 |
资源不存在 |
错误码
请参见错误码。