查询租户订阅资源 - ListSubscriptionOrder
功能介绍
查询租户版本信息,注意:目前其中参数purchase、usage、smn互斥,同时只能有一个请求参数被命中,优先级为:smn > usage > purchase
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
GET /v1/{project_id}/subscriptions/orders
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
租户projectId |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
offset |
否 |
Integer |
smn订阅偏移量 |
|
limit |
否 |
Integer |
smn订阅返回数量 |
|
page |
否 |
String |
订单资源详情信息枚举,DEFAULT:默认缺省值,获取开通的资源列表,不包含套餐包;PURCHASE:在DEFAULT基础上返回租户名下ECS数量;RESOURCE_LIST在DEFAULT基础上返回套餐包列表;USAGE:返回资源用量信息;SMN:返回已订阅的smn topic列表 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
|
X-Language |
是 |
String |
用户当前语言环境 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
csb_version |
String |
租户当前的版本信息 BASIC(基础版),STANDARD(标准版),PROFESSIONAL(专业版),NA(无版本),大小写不敏感 |
|
ecs_count |
Integer |
ecs个数,当请求参数purchase=true时才会返回该值,否则为0 |
|
resources |
Array of SubscriptionResource objects |
资源列表 |
|
subscription_count |
Integer |
topic订阅条数,当请求参数为smn=true,返回该字段 |
|
subscriptions |
Array of SmnSubscription objects |
租户订阅信息,当请求参数为smn=true,会返回租户名下可订阅的smn topic列表 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
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 |
|
order_id |
String |
订单Id,包周期资源有该字段 |
|
charging_mode |
String |
计费模式,目前有包周期(包年包月)PREPAID、按需POSTPAID,大小写不敏感 |
|
tag_list |
Array of SubscriptionTagInfo objects |
资源列表 |
|
usages |
Array of ResourceUsage objects |
资源使用量,当usage=true时返回该字段 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
key |
String |
键。 最大长度36个字符。 字符集:A-Z,a-z , 0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF) |
|
value |
String |
值。 最大长度43个字符,可以为空字符串。 字符集:A-Z,a-z , 0-9,‘.’,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF) |
|
create_time |
Long |
创建时间戳 |
|
update_time |
Long |
更新时间戳 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
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 |
用量百分比 |
|
quota |
Double |
配额总量 |
|
used |
Double |
已用量 |
|
free |
Double |
剩余量 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
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
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
参数解释: 错误码 取值范围: 不涉及 |
|
error_msg |
String |
参数解释: 错误描述 取值范围: 不涉及 |
请求示例
响应示例
状态码: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,
"order_id" : "CS2510212051NLDL4",
"cloud_service" : "SecMaster,",
"charging_mode" : "PREPAID",
"to_period" : false,
"create_time" : 1765349400000,
"update_time" : 1765349400000,
"expire_time" : 1796885400000,
"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 |
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.ListSubscriptionOrderRequest{} response, err := client.ListSubscriptionOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
用户历史订阅信息响应 |
|
403 |
权限不足 |
错误码
请参见错误码。