文档首页/ 安全云脑 SecMaster/ API参考/ 安全云脑 API V1/ 计量计费管理/ 更新订阅资源 - UpdateSubscriptionOrder
更新时间:2026-06-26 GMT+08:00
分享

更新订阅资源 - UpdateSubscriptionOrder

功能介绍

更新订阅资源

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项

URI

PUT /v1/{project_id}/subscriptions/orders

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产,可以通过调用API获取,也可以从控制台获取。

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。

通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

X-Language

String

参数解释:

用户当前语言环境

约束限制:

不涉及

取值范围:

  • zh-cn

  • en-us

默认取值:

不涉及

表3 请求Body参数

参数

是否必选

参数类型

描述

scene

String

参数解释:

操作场景,包周期场景:PREPAID 或者 按需场景:POSTPAID

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

operate_type

String

参数解释:

按需或者包周期场景下,要进行的操作类型

比如增减配额,规格升降配,按需转包周期

约束限制:

注:目前不支持规格降级,比如不支持从专业版降级为标准版或基础版

取值范围:

规格升级:UPGRADE,配额增加:ADDITION,配额减少:DECREASE,按需转包周期:POSTPAID_2_PREPAID

默认取值:

不涉及

promotion_info

String

参数解释:

促销折扣信息

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

tag_list

Array of SubscriptionTag objects

参数解释:

计费标签

约束限制:

标签个数不应超过20个

取值范围:

不涉及

默认取值:

不涉及

product_list

Array of UpdateProduct objects

参数解释:

要进行变更的商品列表

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表4 SubscriptionTag

参数

是否必选

参数类型

描述

key

String

参数解释:

标签键。

约束限制:

字符集:A-Z,a-z , 0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)

取值范围:

最小标签长度为1,最大长度128个字符。

默认取值:

不涉及

value

String

参数解释:

标签值。

约束限制:

字符集:A-Z,a-z , 0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)

取值范围:

最小标签长度为0,最大长度255个字符。

默认取值:

表5 UpdateProduct

参数

是否必选

参数类型

描述

resource_type

String

参数解释:

变更后的资源类型

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_spec_code

String

参数解释:

变更后的商品规格编码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_size

Integer

参数解释:

变更后的资源配额

约束限制:

如果operate_type为addition时,resource_size必须要大于原来的resource_id,decrease时要小于原来的resource_size,并且大于等于当前project下的ecs数量

取值范围:

不涉及

默认取值:

不涉及

resource_id

String

参数解释:

要进行变更的资源ID

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

响应参数

状态码:200

表6 响应Body参数

参数

参数类型

描述

order_id

String

参数解释:

创建的订单ID

约束限制:

只有scene为PREPAID时返回有此数据

取值范围:

不涉及

默认取值:

不涉及

order_status

Integer

参数解释:

订单创建状态

约束限制:

不涉及

取值范围:

1:创建成功,5,创建失败

默认取值:

不涉及

状态码:400

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

error_msg

String

参数解释:

错误描述

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

状态码:403

表8 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

error_msg

String

参数解释:

错误描述

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

状态码:404

表9 响应Body参数

参数

参数类型

描述

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
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := secmaster.SecMasterClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := secmaster.NewSecMasterClient(hcClient)
    
        request := &model.UpdateSubscriptionOrderRequest{}
    	resourceTypeProductList:= "xxx.resource.type.secmaster.typical"
    	resourceSizeProductList:= int32(3)
    	var listProductListbody = []model.UpdateProduct{
            {
                ResourceType: &resourceTypeProductList,
                ResourceSpecCode: "secmaster.professional",
                ResourceSize: &resourceSizeProductList,
                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
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := secmaster.SecMasterClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := secmaster.NewSecMasterClient(hcClient)
    
        request := &model.UpdateSubscriptionOrderRequest{}
    	resourceTypeProductList:= "xxx.resource.type.secmaster.typical"
    	resourceSizeProductList:= int32(3)
    	var listProductListbody = []model.UpdateProduct{
            {
                ResourceType: &resourceTypeProductList,
                ResourceSpecCode: "secmaster.professional",
                ResourceSize: &resourceSizeProductList,
                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
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := secmaster.SecMasterClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := secmaster.NewSecMasterClient(hcClient)
    
        request := &model.UpdateSubscriptionOrderRequest{}
    	resourceTypeProductList:= "xxx.resource.type.secmaster.typical"
    	resourceSizeProductList:= int32(2)
    	var listProductListbody = []model.UpdateProduct{
            {
                ResourceType: &resourceTypeProductList,
                ResourceSpecCode: "secmaster.professional",
                ResourceSize: &resourceSizeProductList,
                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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    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, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := secmaster.SecMasterClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := secmaster.NewSecMasterClient(hcClient)
    
        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

资源不存在

错误码

请参见错误码

相关文档