client.py 850 B

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