# 查询指定Topic的订阅者列表 - ListSubscriptionsByTopic
#### 功能介绍
分页获取特定Topic的订阅列表，订阅列表按照订阅创建时间进行升序排列。分页查询可以指定offset以及limit。如果指定Topic不存在订阅者，返回空列表。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-smn/smn_api_30000.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-smn/smn_api_80000.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                                | 访问级别 | 资源类型（\*为必须） | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | 别名             | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | smn:topic:listSubscriptionsByTopic | List | topic \*    | - g:EnterpriseProjectId   - g:ResourceTag/\<tag-key\>    | smn:topic:list | -      |
     
  
 
#### URI
GET /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                          |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID。获取项目ID请参考 [获取项目ID](https://support.huaweicloud.com/api-smn/smn_api_66000.html)。        |
| topic_urn  | 是    | String | Topic的唯一的资源标识，可通过[查询主题列表](https://support.huaweicloud.com/api-smn/smn_api_51004.html)获取该标识。 |
   
表2Query参数 
| 参数           | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| offset       | 否    | Integer | 偏移量。 偏移量为一个大于0小于资源总个数的整数，表示查询该偏移量后面的所有的资源，默认值为0。 **默认取值：** 0             |
| limit        | 否    | Integer | 查询的数量限制。 取值范围：1\~100，取值一般为10，20，50。功能说明：每页返回的资源个数。默认值为100。 **默认取值：** 100 |
| fuzzy_remark | 否    | String  | 检索的订阅备注字段，模糊匹配。最大长度限制为128字节。                                                                                                                                                                                                                                                                        |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                 |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。 通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数                 | 参数类型                                                                                                                             | 描述               |
|:---|:---|:---|
| request_id         | String                                                                                                                           | 请求的唯一标识ID。       |
| subscription_count | Integer                                                                                                                          | 订阅者个数。           |
| subscriptions      | Array of [ListSubscriptionsItem] objects | Subscription结构体。 |
   
 表5ListSubscriptionsItem 
| 参数               | 参数类型                                                                                                                                     | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|
| topic_urn        | String                                                                                                                                   | Topic的唯一的资源标识。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| protocol         | String                                                                                                                                   | 不同协议对应不同的endpoint（接受消息的接入点）。目前支持的协议包括： "default": 默认协议。 "email"：邮件传输协议，endpoint为邮箱地址。 "sms"：短信传输协议，endpoint为手机号码。 "functionstage"：FunctionGraph（函数）传输协议，endpoint为一个函数。 "http"、"https"：HTTP/HTTPS传输协议，endpoint为URL。 |
| subscription_urn | String                                                                                                                                   | 订阅者的唯一资源标识。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| owner            | String                                                                                                                                   | Topic创建者的项目ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| endpoint         | String                                                                                                                                   | 接受消息的接入点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| remark           | String                                                                                                                                   | 备注。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| status           | Integer                                                                                                                                  | 订阅者状态：0表示订阅还未确认，1表示已经确认，3表示已经取消确认。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| filter_polices   | Array of [SubscriptionsFilterPolicy] objects | 过滤策略。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| extension        | [SubscriptionExtensionResponse] object   | 订阅终端扩展字段                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
   
 表6SubscriptionsFilterPolicy 
| 参数            | 参数类型             | 描述                                                                                                                                                          |
|:---|:---|:---|
| name          | String           | 过滤策略名称。 包含小写英文字母(\[a-z\])、数字(\[0-9\])、下划线(_)，下划线不得开始、结尾或连续出现，长度限制{1,32}，不能是smn_开头。 |
| string_equals | Array of strings | 字符串精确匹配数组。数组长度\[1, 10\]，数组内容不能重复，值不能为null或者空字符串" "，长度限制\[1,32\]，中英文、数字、下划线                                                                                  |
   
 表7SubscriptionExtensionResponse 
| 参数                        | 参数类型    | 描述                      |
|:---|:---|:---|
| verification_code_enabled | Boolean | 是否启用验证码发送确认短信，默认为false。 |
   
**状态码：400**
表8响应Body参数 
| 参数         | 参数类型   | 描述          |
|:---|:---|:---|
| request_id | String | 请求的唯一标识ID。  |
| code       | String | 服务异常错误信息编码。 |
| message    | String | 服务异常错误信息描述。 |
   
**状态码：403**
表9响应Body参数 
| 参数         | 参数类型   | 描述          |
|:---|:---|:---|
| request_id | String | 请求的唯一标识ID。  |
| code       | String | 服务异常错误信息编码。 |
| message    | String | 服务异常错误信息描述。 |
   
**状态码：404**
表10响应Body参数 
| 参数         | 参数类型   | 描述          |
|:---|:---|:---|
| request_id | String | 请求的唯一标识ID。  |
| code       | String | 服务异常错误信息编码。 |
| message    | String | 服务异常错误信息描述。 |
   
**状态码：500**
表11响应Body参数 
| 参数         | 参数类型   | 描述          |
|:---|:---|:---|
| request_id | String | 请求的唯一标识ID。  |
| code       | String | 服务异常错误信息编码。 |
| message    | String | 服务异常错误信息描述。 |
   
#### 请求示例
查询名称为test_topic_v2的主题的订阅者列表
```
GET https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1/subscriptions?offset=0&limit=100
null
```
#### 响应示例
**状态码：200**
```
{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "subscription_count" : 2,
  "subscriptions" : [ {
    "topic_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1",
    "protocol" : "sms",
    "subscription_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:2e778e84408e44058e6cbc6d3c377837",
    "owner" : "762bdb3251034f268af0e395c53ea09b",
    "endpoint" : "xxxxxxxxxxx",
    "remark" : "",
    "status" : 0,
    "filter_polices" : [ {
      "name" : "alarm",
      "string_equals" : [ "os", "process" ]
    }, {
      "name" : "service",
      "string_equals" : [ "api", "db" ]
    } ]
  }, {
    "topic_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1",
    "protocol" : "email",
    "subscription_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:a2d52a9f5c3b47f48c3fafb177a58796",
    "owner" : "762bdb3251034f268af0e395c53ea09b",
    "endpoint" : "xx@example.com",
    "remark" : "",
    "status" : 0,
    "filter_polices" : [ {
      "name" : "alarm",
      "string_equals" : [ "os", "process" ]
    }, {
      "name" : "service",
      "string_equals" : [ "api", "db" ]
    } ]
  } ]
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK                    |
| 400 | Bad Request           |
| 403 | Unauthorized          |
| 404 | Not Found             |
| 500 | Internal Server Error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-smn/ErrorCode.html)。
