# サブスクリプション情報API

本APIドキュメントでは、MQTTクライアントのサブスクリプション情報の閲覧に関する操作について説明します。全サブスクリプション情報の取得や特定クライアントの全サブスクリプション情報の取得が含まれます。

## 全サブスクリプション情報の取得

デプロイメント内のすべてのサブスクリプション情報を取得します。ページネーションに対応しています。

### URI

GET /subscriptions

### リクエストメッセージ

クエリパラメータ:

| 名前          | 型       | 説明                             |
| ------------- | -------- | -------------------------------- |
| _page         | Integer  | ページ番号                       |
| _limit        | Integer  | 1ページあたりのデータ件数         |
| clientid      | String   | クライアント識別子               |
| qos           | Integer  | 取り得る値：`0`、`1`、`2`       |
| share         | String   | 共有サブスクリプションのグループ名 |
| _match_topic  | String   | マッチングクエリ用のトピック     |

### レスポンスメッセージ

| 名前            | 型               | 説明                           |
| --------------- | ---------------- | ------------------------------ |
| data            | オブジェクト配列 | すべてのサブスクリプション情報 |
| data[].node     | String           | ノード名                       |
| data[].clientid | String           | クライアント識別子             |
| data[].topic    | String           | サブスクライブしているトピック |
| data[].qos      | Integer          | QoSレベル                     |
| nl              | Integer          | No Local                      |
| rap             | Integer          | Retain as Published           |
| rh              | Integer          | Retain Handling               |
| meta            | オブジェクト     | ページネーション情報           |
| meta.page       | Integer          | ページ番号                   |
| meta.limit      | Integer          | 1ページあたりのデータ件数     |
| meta.count      | Integer          | 総データ件数                 |

### リクエスト例

```bash
curl -u app_id:app_secret -X GET {api}/subscriptions
```

### レスポンス例

```json
// HTTPステータスコード
200
// HTTPレスポンスボディ
{
  "meta": {
    "page": 1,
    "limit": 100,
    "hasnext": false,
    "count": 2
  },
  "data": [
    {
      "topic": "t/a",
      "qos": 0,
      "node": "emqx@10.12.50.91",
      "clientid": "client_1",
      "nl": 0,
      "rap": 0,
      "rh": 0
    },
    {
      "topic": "t/b",
      "qos": 1,
      "node": "emqx@10.12.50.91",
      "clientid": "client_2",
      "nl": 0,
      "rap": 0,
      "rh": 0
    }
  ]
}
```

## 特定クライアントの全サブスクリプション情報の取得

### URI

GET /clients/{client_id}/subscriptions

### リクエストメッセージ

なし

### レスポンスメッセージ

| 名前            | 型               | 説明                         |
| --------------- | ---------------- | ---------------------------- |
| data            | オブジェクト配列 | すべてのサブスクリプション情報 |
| data[].node     | String           | ノード名                     |
| data[].clientid | String           | クライアント識別子           |
| data[].topic    | String           | サブスクライブしているトピック |
| data[].qos      | Integer          | QoSレベル                   |
| nl              | Integer          | No Local                    |
| rap             | Integer          | Retain as Published         |
| rh              | Integer          | Retain Handling             |

### リクエスト例

```bash
curl -u app_id:app_secret -X GET {api}/clients/client_1/subscriptions
```

### レスポンス例

```json
{
  "data": [
    {
      "topic": "t/a",
      "qos": 0,
      "node": "emqx@10.12.50.36",
      "clientid": "client_1",
      "nl": 0,
      "rap": 0,
      "rh": 0
    },
    {
      "topic": "t/b",
      "qos": 1,
      "node": "emqx@10.12.50.36",
      "clientid": "client_1",
      "nl": 0,
      "rap": 0,
      "rh": 0
    }
  ]
}
```
