edit-icon download-icon

Fetch region information

Last Updated: Oct 11, 2018

OnsRegionList interface returns a list of currently available Regions of MQ.

Application scenario

Region information is required when calling all Open APIs. The Region field can be retrieved through the OnsRegionList interface.

List of request parameters

Name Type Required Description
OnsRegionId String No The region of the currently queried MQ.
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.

List of response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
Data List(RegionDo) The query result

RegionDo data structure

Member Type Description
Id Long Number in a database
RegionId String The name of RegionId
RegionName String The alias of Region
ChannelId Long The number of the channel
ChannelName String The alias of the channel
CreateTime Long Time of creation
UpdateTime Long Time of the last update

Example

  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. OnsRegionListRequest request = new OnsRegionListRequest();
  19. request.setAcceptFormat(FormatType.JSON);
  20. request.setPreventCache(System.currentTimeMillis());
  21. try {
  22. OnsRegionListResponse response = IAcsClient.getAcsResponse(request);
  23. List<OnsRegionListResponse.RegionDo> regionDoList=response.getData();
  24. for (OnsRegionListResponse.RegionDo regionDo:regionDoList){
  25. System.out.println(regionDo.getId()+" "+
  26. regionDo.getOnsRegionId()+" "+
  27. regionDo.getRegionName()+" "+
  28. regionDo.getChannelId()+" "+
  29. regionDo.getChannelName()+" "+
  30. regionDo.getCreateTime()+" "+
  31. regionDo.getUpdateTime());
  32. }
  33. } catch (ClientException e) {
  34. e.printStackTrace();
  35. }
  36. catch (Exception e) {
  37. e.printStackTrace();
  38. }
  39. }
Thank you! We've received your feedback.