Pulsar REST API使用笔记

  • 参考链接:
    http://pulsar.apache.org/admin-rest-api/#restapis
  • 环境说明
    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 - 创建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 - 创建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列表]
无分区:
GET /admin/v2/persistent/public/default
分区:
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 - 创建Topic]

备注:需要根据如果请求返回307状态,需要使用跳转的请求再执行一次调用

分区:
PUT /admin/v2/persistent/public/default/test_topic/partitions
无分区:
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状态]
GET /admin/v2/non-persistent/public/default/test_topic/stats
GET /admin/v2/persistent/public/default/test_topic/stats

你可能感兴趣的:(Pulsar REST API使用笔记)