edit-icon download-icon

Fetch all PIDs of specified user

Last Updated: Jan 30, 2018

OnsPublishList interface retrieves all publishing relations owned by a specified user.

Usage

This interface shows a list of publishing relations owned by a user.

Request parameters

Name Type Required Description
OnsRegionId String Yes It specifies the region to be queried. The value is obtained through the OnsRegionList interface.
OnsPlatform String No The source of the request, which by default is POP platform.
PreventCache Long Yes It’s used for CSRF verification. Set it to the current system time.

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
Data List(PublishInfoDo) A set of query results

PublishInfoDo data structure

Member Type Description
id Long ID of the publishing information in the database
channelId Integer The ID of the region where the Topic is located, including 0-ALIYUN, 1-CLOUD, 2, 3, and 4
channelName String The name of the region where the Topic is located. ALIYUN for Alibaba Cloud, CLOUD for Tmall Cloud…
onsRegionId Long The ID of the region where the Topic is located; obtained through the OnsRegionList method.
regionName String The name of the region where the Topic is located.
Topic String The Topic name
owner String The number of the Topic owner
relation Integer Numbers of all relations. 1 for the owner, 2 for “publish”, 4 for “subscribe”, and 6 for “publish and subscribe”.
relationName String Names of all relations such as the owner, “subscribe”, “publish”, and “publish and subscribe”.
status Integer Number of the current status. 0 for In Service.
statusName String The alias of the current status, which can be In Service.
appkey Integer null
createTime Long Creation time
updateTime Long Update time
remark String An optional note
  • OnsPublishDelete: deletes a publishing relation
  • OnsPublishGet: queries a publishing relation
  • OnsPublishCreate: creates a publishing relation

    Example

This example shows the process of querying and printing a list of all PIDs of a user in the daily region.

  1. public static void main(String []args) {
  2. String regionId = "cn-hangzhou";
  3. String accessKey = "XXXXXXXXXXXXXXXXX";
  4. String secretKey = "XXXXXXXXXXXXXXXXX";
  5. String endPointName ="cn-hangzhou";
  6. String productName ="Ons";
  7. String domain ="ons.cn-hangzhou.aliyuncs.com";
  8. /**
  9. *Select Region based on the region you will access, and set the corresponding access point.
  10. */
  11. try {
  12. DefaultProfile.addEndpoint(endPointNameregionIdproductNamedomain);
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. IClientProfile profile= DefaultProfile.getProfile(regionIdaccessKeysecretKey);
  17. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  18. OnsPublishListRequest request = new OnsPublishListRequest();
  19. /**
  20. *OnsRegionId refers to the resource of the region of MQ required to be accessed by API.
  21. *This value must be selected and configured by the list obtained through the OnsRegionList method because OnsRegionId is changing, and cannot be written as a fixed value.
  22. */
  23. request.setOnsRegionId("daily");
  24. request.setPreventCache(System.currentTimeMillis());
  25. request.setAcceptFormat(FormatType.JSON);
  26. try {
  27. OnsPublishListResponse response=iAcsClient.getAcsResponse(request);
  28. List<OnsPublishListResponse.PublishInfoDo> publishInfoDoList =response.getData();
  29. for (OnsPublishListResponse.PublishInfoDo publishInfoDo:publishInfoDoList){
  30. System.out.println(publishInfoDo.getId()+" "+
  31. publishInfoDo.getChannelId()+" "+
  32. publishInfoDo.getChannelName()+" "+
  33. publishInfoDo.getOnsRegionId()+" "+
  34. publishInfoDo.getRegionName()+" "+
  35. publishInfoDo.getOwner()+" "+
  36. publishInfoDo.getProducerId()+" "+
  37. publishInfoDo.getTopic()+" "+
  38. publishInfoDo.getStatus()+" "+
  39. publishInfoDo.getStatusName()+" "+
  40. publishInfoDo.getCreateTime()+" "+
  41. publishInfoDo.getUpdateTime());
  42. }
  43. } catch (ServerException e) {
  44. e.printStackTrace();
  45. } catch (ClientException e) {
  46. e.printStackTrace();
  47. }
  48. }
Thank you! We've received your feedback.