消費者對象表示服務的消費者或使用者。您既可以依賴于Kong作為主數(shù)據(jù)存儲,也可以使用數(shù)據(jù)庫映射消費者列表,以保持Kong和現(xiàn)有主數(shù)據(jù)存儲之間的一致性。
CONSUMER API 詳解:
1、創(chuàng)建Consumer
請求地址:/consumers/
請求方法:POST
請求表單參數(shù):
| 屬性 | 描述 |
|---|---|
| username(半可選) | 用戶的唯一用戶名。username或custom_id二選一。 |
| custom_id(半可選) | 消費者存儲唯一ID - 用于現(xiàn)有數(shù)據(jù)庫中的用戶進行映射。username或custom_id二選一。 |
2、檢索Consumer
請求地址:/consumers/{username or id}
請求方法:GET
PATH參數(shù):
| 屬性 | 描述 |
|---|---|
| username or id(必選) | 要檢索的消費者的唯一標識符或用戶名。 |
3、Consumer列表
請求地址:/consumers/
請求方法:GET
請求參數(shù):
| 屬性 | 描述 |
|---|---|
| id(可選) | 基于消費者id字段的過濾器。 |
| custom_id(可選) | 基于消費者custom_id字段的過濾器。 |
| username(可選) | 基于消費者username字段的過濾器。 |
| offset(可選) | 用于分頁的游標。偏移量是定義列表中的位置的對象標識符。 |
| size(可選,默認是100) | 每個頁面返回的對象數(shù)量的限制。 |
4、更新Consumer
請求地址:/consumers/{username or id}
請求方法:PATCH
PATH參數(shù):
| 屬性 | 描述 |
|---|---|
| username or id(必選) | 更新的唯一標識符或用戶名。 |
請求主體:同1、添加Consumer
5、更新或創(chuàng)建Consumer
請求地址:/consumers/
請求方法:PUT
請求主體:同1、添加Consumer
6、刪除Consumer
請求地址:/consumers/{username or id}
請求方法:DELETE
PATH參數(shù):
| 屬性 | 描述 |
|---|---|
| username or id(必選) | 更新的唯一標識符或用戶名。 |