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

查询租户订阅资源 - ListSubscriptionOrder

功能介绍

查询租户版本信息,注意:目前其中参数purchase、usage、smn互斥,同时只能有一个请求参数被命中,优先级为:smn > usage > purchase

调用方法

请参见如何调用API

授权信息

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

URI

GET /v1/{project_id}/subscriptions/orders

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

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

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

offset

Integer

参数解释:

偏移量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

limit

Integer

参数解释:

资源数据量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

page

String

参数解释:

订单资源详情信息枚举,

约束限制:

不涉及

取值范围:

  • DEFAULT:默认缺省值,获取开通的资源列表,不包含套餐包;

  • PURCHASE:在DEFAULT基础上返回租户名下ECS数量;

  • RESOURCE_LIST在DEFAULT基础上返回套餐包列表;

  • USAGE:返回资源用量信息;

  • SMN:返回已订阅的smn topic列表

默认取值:

不涉及

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。

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

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

X-Language

String

参数解释:

用户当前语言环境

约束限制:

不涉及

取值范围:

  • zh-cn

  • en-us

默认取值:

不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

csb_version

String

参数解释:

租户当前的版本信息

约束限制:

不涉及

取值范围:

BASIC(基础版),STANDARD(标准版),PROFESSIONAL(专业版),NA(无版本),大小写不敏感

默认取值:

不涉及

ecs_count

Integer

参数解释:

租户当前项目下的ecs个数

约束限制:

当请求参数purchase=true时才会返回该值,否则为0

取值范围:

不涉及

默认取值:

0

resources

Array of SubscriptionResource objects

参数解释:

资源列表

约束限制:

不涉及

取值范围:

不涉及

默认取值:

subscription_count

Integer

参数解释:

topic订阅条数,当请求参数为smn=true,返回该字段

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

subscriptions

Array of SmnSubscription objects

参数解释:

租户订阅信息,当请求参数为smn=true,会返回租户名下可订阅的smn topic列表

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表5 SubscriptionResource

参数

参数类型

描述

resource_id

String

参数解释:

资源Id

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_type_name

String

参数解释:

资源名称

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_size

Integer

参数解释:

资源规格

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

cloud_service

String

参数解释:

订单来源

约束限制:

不涉及

取值范围:

不涉及

默认取值:

SecMaster

resource_type

String

参数解释:

资源类型

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_spec_code

String

参数解释:

资源规格编码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

to_period

Boolean

参数解释:

当前资源是否能进行按需转包周期操作

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

create_time

Long

参数解释:

资源对应的创建时间戳

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

update_time

Long

参数解释:

资源对应的更新时间戳

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

expire_time

Long

参数解释:

资源到期时间戳,只有包年包月资源有该字段

约束限制:

仅包年包月支持该字段

取值范围:

不涉及

默认取值:

不涉及

resource_status

Integer

参数解释:

资源状态,目前返回正常运行的资源,其状态值为0

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

order_id

String

参数解释:

订单Id,包周期资源有该字段

约束限制:

仅包年包月支持该字段

取值范围:

不涉及

charging_mode

String

参数解释:

计费模式,目前有包周期(包年包月)PREPAID、按需POSTPAID,大小写不敏感

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

quota_reset_mode

Integer

参数解释:

重置模式,1:可重置;2:不可重置

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

quota_reset_cycle_type

Integer

参数解释:

重置周期类别:

1:按自然周期重置

2:按订购周期重置

“quota_reset_mode”为“1(可重置)”时,此字段必填;

“quota_reset_mode”为“2(不可重置)”时,此字段为空;

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

quota_reset_cycle

Integer

参数解释:

重置周期,1:小时;2:天;3:周;4:月;5:年

“quota_reset_mode”为“1(可重置)”时,此字段必填;

“quota_reset_mode”为“2(不可重置)”时,此字段为空

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

amount

String

参数解释:

资源包剩余量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

original_amount

String

参数解释:

资源包原始用量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

measure_name

String

参数解释:

资源包度量单位名称,比如GB

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

tag_list

Array of SubscriptionTagInfo objects

参数解释:

资源列表

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

usages

Array of ResourceUsage objects

参数解释:

资源使用量

约束限制:

当usage=true时返回该字段

取值范围:

不涉及

默认取值:

不涉及

表6 SubscriptionTagInfo

参数

参数类型

描述

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个字符。

默认取值:

create_time

Long

参数解释:

标签创建时间戳

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

update_time

Long

参数解释:

标签更新时间戳

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

表7 ResourceUsage

参数

参数类型

描述

unit

String

参数解释:

使用量单位

约束限制:

不涉及

取值范围:

OPS 次,MB 流量体积MB,GB 流量体积GB

默认取值:

不涉及

resource_type_name

String

参数解释:

资源类型名称

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

source_resource_spec_code

String

参数解释:

源资源规格编码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

resource_spec_code

String

参数解释:

资源规格编码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

source_type

String

参数解释:

源资源类型编码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

used_percent

Double

参数解释:

用量百分比

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

quota

Double

参数解释:

配额总量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

used

Double

参数解释:

已用量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

free

Double

参数解释:

剩余量

约束限制:

不涉及

取值范围:

不涉及

默认取值:

0

表8 SmnSubscription

参数

参数类型

描述

owner

String

参数解释:

租户project_id

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

endpoint

String

参数解释:

订阅终端

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

protocol

String

参数解释:

终端协议,比如HTTPS协议,SMS协议,EMAIL协议,HTTP协议

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

subscription_urn

String

参数解释:

smn订阅的urn

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

topic_urn

String

参数解释:

订阅topic对应的urn

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

status

Integer

参数解释:

订阅状态

约束限制:

不涉及

取值范围:

0:未确认

1:已确认

2:不需要确认

3:已取消确认

4:已经删除。

默认取值:

不涉及

状态码:403

表9 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

error_msg

String

参数解释:

错误描述

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

请求示例

  • 返回租户资源列表

    GET https://{endpoint}/v1/{projectId}/subscriptions/orders
  • 返回携带ECS数量的租户资源列表

    GET https://{endpoint}/v1/{projectId}/subscriptions/orders?purchase=true
  • 返回租户资源用量列表

    GET https://{endpoint}/v1/{projectId}/subscriptions/orders?usage=true

响应示例

状态码:200

用户历史订阅信息

{
  "csb_version" : "PROFESSIONAL",
  "ecs_count" : 12,
  "resources" : [ {
    "resource_id" : "c9528aa2-d593-11f0-a34e-fa163e798915",
    "resource_type" : "xxx.resource.type.secmaster.typical",
    "resource_spec_code" : "csb.professional",
    "resource_type_name" : "SecMaster Professional",
    "resource_size" : 2,
    "resource_status" : 0,
    "cloud_service" : "SecMaster,",
    "charging_mode" : "POSTPAID",
    "to_period" : false,
    "create_time" : 1765349400000,
    "update_time" : 1765349400000,
    "tag_list" : [ {
      "key" : "dept",
      "value" : "dev",
      "create_time" : 1765349400000,
      "update_time" : 1765349400000
    } ],
    "usages" : [ {
      "resource_type_name" : "SecMaster Professional-Security Orchestration",
      "source_resource_spec_code" : "csb.professional",
      "resource_spec_code" : "soar.action",
      "source_type" : "xxx.resource.type.csb.professional",
      "unit" : "OPS",
      "quota" : 100,
      "used_percent" : 0.2,
      "used" : 20,
      "free" : 80
    } ]
  } ],
  "subscription_count" : 1,
  "subscriptions" : [ {
    "owner" : "7bae9770eb3a47d3ba4759a88e4b748d",
    "endpoint" : "maizhelun@xxx.com",
    "protocol" : "email",
    "subscription_urn" : "urn:smn:demo-region:7bae9770eb3a47d3ba4759a88e4b748d:test-topic-abc:d4b4f367adf9420abc03736391069934",
    "topic_urn" : "urn:smn:demo-region:7bae9770eb3a47d3ba4759a88e4b748d:test-topic-abc",
    "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
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.*;


public class ListSubscriptionOrderSolution {

    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();
        ListSubscriptionOrderRequest request = new ListSubscriptionOrderRequest();
        try {
            ListSubscriptionOrderResponse response = client.listSubscriptionOrder(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
# 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 = ListSubscriptionOrderRequest()
        response = client.list_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
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.ListSubscriptionOrderRequest{}
	response, err := client.ListSubscriptionOrder(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

用户历史订阅信息

403

权限不足

错误码

请参见错误码

相关文档