- 參考鏈接:
http://pulsar.apache.org/admin-rest-api/#restapis - 環(huán)境說明
Broker的WebServer:
HOST:http://xxx.xxx.xxx.xxx:8081
JWT認證頭信息:
Authorization: Bearer JWT_TOKEN
- 命令筆記
【tenant】
[tenant list - 查看tenant列表]
GET /admin/v2/tenants
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" http://xxx.xxx.xxx.xxx:8081/admin/v2/tenants
[tenant create - 創(chuàng)建tenant]
備注:需要設置可在該tenant下操作的Role和集群
PUT /admin/v2/tenants/{tenant}
BODY:
{
"adminRoles": [
"admin"
],
"allowedClusters": [
"pulsar-cluster"
]
}
e.g:
curl -v -H "Authorization: Bearer JWT_TOKEN" -X PUT -H "Content-Type:application/json" -d '{"adminRoles": ["admin"],"allowedClusters": ["pulsar-cluster"]}' http://xxx.xxx.xxx.xxx:8081/admin/v2/tenants/test_def
[tenant delete - 刪除tenant]
DELETE /admin/v2/tenants/{tenant}
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" -X DELETE http://xxx.xxx.xxx.xxx:8081/admin/v2/tenants/test_def
【namespace】
[namespace list - 查看指定tenant下的namespace列表]
GET /admin/v2/namespaces/{tenant}
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" http://xxx.xxx.xxx.xxx:8081/admin/v2/namespaces/test_def
[namespace create - 創(chuàng)建namespace]
PUT /admin/v2/namespaces/{tenant}/{namespace}
e.g:
curl -v -H "Authorization: Bearer JWT_TOKEN" -X PUT http://xxx.xxx.xxx.xxx:8081/admin/v2/namespaces/test_def/test_name
[namespace delete - 刪除namespace]
DELETE /admin/v2/namespaces/{tenant}/{namespace}
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" -X DELETE http://xxx.xxx.xxx.xxx:8081/admin/v2/namespaces/test_def/test_name
【topic】
[topic list - 查看Topic列表]
無分區(qū):
GET /admin/v2/persistent/public/default
分區(qū):
GET /admin/v2/persistent/public/default/partitioned
非持久化:
GET /admin/v2/non-persistent/public/default
GET /admin/v2/non-persistent/public/default/partitioned
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" http://xxx.xxx.xxx.xxx:8081/admin/v2/persistent/public/default
curl -H "Authorization: Bearer JWT_TOKEN" http://xxx.xxx.xxx.xxx:8081/admin/v2/persistent/public/default/partitioned
curl -H "Authorization: Bearer JWT_TOKEN" http://xxx.xxx.xxx.xxx:8081/admin/v2/non-persistent/public/default
[topic create - 創(chuàng)建Topic]
備注:需要根據(jù)如果請求返回307狀態(tài),需要使用跳轉(zhuǎn)的請求再執(zhí)行一次調(diào)用
分區(qū):
PUT /admin/v2/persistent/public/default/test_topic/partitions
無分區(qū):
PUT /admin/v2/persistent/public/default/test_topic
非持久化:
PUT /admin/v2/non-persistent/public/default/test_topic/partitions
PUT /admin/v2/non-persistent/public/default/test_topic
e.g:
curl -v -H "Authorization: Bearer JWT_TOKEN" -H "Content-Type:text/plain" -d "2" -X PUT http://xxx.xxx.xxx.xxx:8081/admin/v2/persistent/public/default/test_topic/partitions
curl -v -H "Authorization: Bearer JWT_TOKEN" -X PUT http://xxx.xxx.xxx.xxx:8081/admin/v2/persistent/public/default/test_topic
[topic delete - 刪除topic]
DELETE /admin/v2/persistent/public/default/test_topic?force=false
DELETE /admin/v2/persistent/public/default/test_topic/partitions?force=false
DELETE /admin/v2/non-persistent/public/default/test_topic?force=false
DELETE /admin/v2/non-persistent/public/default/test_topic/partitions?force=false
e.g:
curl -H "Authorization: Bearer JWT_TOKEN" -X DELETE http://xxx.xxx.xxx.xxx:8081/admin/v2/persistent/public/default/test_topic?force=false
[topic stats - 查看topic狀態(tài)]
GET /admin/v2/non-persistent/public/default/test_topic/stats
GET /admin/v2/persistent/public/default/test_topic/stats