阅读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-阿里云