## 6\. Consumers *地址*:/consumers *说明*:Consumer 是某类服务的消费者,需与用户认证体系配合才能使用。 ### 6.1 请求方法 | 序号 | NAME | 请求URI | 请求body | 说明 | | --- | --- | --- | --- | --- | | 1 | POST | /consumers | {...} | 新增consumers | | 2 | GET | /consumers | | 查询consumers列表 | | 3 | GET | /consumers/{username or id} | | 获取consumers信息 | | 4 | GET | /plugins/{plugin id}/consumer | | 同上 | | 5 | PATCH | /consumers/{username or id} | {...} | 更新consumers信息 | | 6 | PATCH | /plugins/{plugin id}/consumer | {...} | 同上 | | 7 | PUT | /consumers/{username or id} | {...} | 新增/更新consumers | | 8 | PUT | /plugins/{plugin id}/consumer | {...} | 同上 | | 9 | DELETE | /consumers/{username or id} | | 删除consumers | ### 6.2 body 请求参数 | 序号 | 参数名 | 可选 | 默认值 | 说明 | 示例 | | --- | --- | --- | --- | --- | --- | | 1 | username | 半选 | | 用户名,必须唯一,username和custom\_id两者必须填写一项 | zhangshan | | 2 | custom\_id | 半选 | | 唯一标识,必须保证唯一,username和custom\_id两者必须填写一项 | | | 3 | tags | 可选 | | | | ### 6.3 数据样例 body 请求参数 ``` { "id": "ec1a1f6f-2aa4-4e58-93ff-b56368f19b27", "created_at": 1422386534, "username": "my-username", "custom_id": "my-custom-id", "tags": ["user-level", "low-priority"] } ``` consumers列表 ``` { "data": [{ "id": "a4407883-c166-43fd-80ca-3ca035b0cdb7", "created_at": 1422386534, "username": "my-username", "custom_id": "my-custom-id", "tags": ["user-level", "low-priority"] }, { "id": "01c23299-839c-49a5-a6d5-8864c09184af", "created_at": 1422386534, "username": "my-username", "custom_id": "my-custom-id", "tags": ["admin", "high-priority", "critical"] }], "next": "http://localhost:8001/consumers?offset=6378122c-a0a1-438d-a5c6-efabae9fb969" } ```