閱讀95 返回首頁    go 魔獸


查看授權__資源授權接口_Open API_消息隊列 MQ-阿裏雲

本文介紹 OnsEmpowerList 接口,調用該接口查詢目標 Topic 對特定賬號的授權信息。

1. 使用場景

Topic 的所有者查詢自己 owner 的 Topic 是否對特定賬號授權,授權的類型可以通過該接口查詢。

2. 請求參數列表

名稱 類型 是否必須 描述
OnsRegionId String 當前查詢 MQ 所在區域,可以通過 OnsRegionList 方法獲取
OnsPlatform String 該請求來源,默認是從 POP 平台
PreventCache Long 用於 CSRF 校驗,設置為係統當前時間即可
EmpowerUser Long 查詢的目標用戶 User ID,支持子賬號 ID
Topic String 查詢的目標 Topic,該 Topic 必須是當前用戶所有

3. 返回參數列表

名稱 類型 描述
RequestId String 為公共參數,每個請求獨一無二
HelpUrl String 幫助鏈接
Data List(AuthOwnerInfoDo) 查詢到的權限數據列表

AuthOwnerInfoDo 結構體內容

名稱 類型 描述
Topic String Topic 名稱
Owner Long 所有者 UserId
Relation Integer 權限類型,參考授權的參數說明

4. 相關 API

  • OnsEmpowerCreate:創建授權信息
  • OnsEmpowerDelete:刪除授權信息

5. 使用示例

調用示例

  1. public static void main(String []args) {
  2. public static void main(String []args) {
  3. String regionId = "cn-hangzhou";
  4. String accessKey = "XXXXXXXXXXXXXXXXX";
  5. String secretKey = "XXXXXXXXXXXXXXXXX";
  6. String endPointName ="cn-hangzhou";
  7. String productName ="Ons";
  8. String domain ="ons.cn-hangzhou.aliyuncs.com";
  9. /**
  10. *根據自己需要訪問的區域選擇Region,並設置對應的接入點
  11. */
  12. try {
  13. DefaultProfile.addEndpoint(endPointName,regionId,productName,domain);
  14. } catch (ClientException e) {
  15. e.printStackTrace();
  16. }
  17. IClientProfile profile= DefaultProfile.getProfile(regionId,accessKey,secretKey);
  18. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  19. OnsEmpowerListRequest request = new OnsEmpowerListRequest();
  20. request.setOnsRegionId("cn-qingdao-publictest");
  21. request.setPreventCache(System.currentTimeMillis());
  22. request.setAcceptFormat(FormatType.JSON);
  23. request.setEmpowerUser("1675352326808602");
  24. request.setTopic("topic_for_public_msg_test");
  25. try {
  26. OnsEmpowerListResponse response=iAcsClient.getAcsResponse(request);
  27. System.out.println(response.getRequestId());
  28. } catch (ServerException e) {
  29. e.printStackTrace();
  30. } catch (ClientException e) {
  31. e.printStackTrace();
  32. }
  33. }

最後更新:2016-11-23 18:56:43

  上一篇:go 創建授權__資源授權接口_Open API_消息隊列 MQ-阿裏雲
  下一篇:go 刪除授權__資源授權接口_Open API_消息隊列 MQ-阿裏雲