client.py 889 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. class Client(object):
  3. @staticmethod
  4. def get_endpoint_rules(product, region_id, endpoint_type, network, suffix=None):
  5. product = product or ""
  6. network = network or ""
  7. if endpoint_type == "regional":
  8. if region_id is None or region_id == "":
  9. raise RuntimeError(
  10. "RegionId is empty, please set a valid RegionId")
  11. result = "<product><network>.<region_id>.aliyuncs.com".replace(
  12. "<region_id>", region_id)
  13. else:
  14. result = "<product><network>.aliyuncs.com"
  15. result = result.replace("<product>", product.lower())
  16. if network == "" or network == "public":
  17. result = result.replace("<network>", "")
  18. else:
  19. result = result.replace("<network>", "-" + network)
  20. return result