code: def cs_encode(s):
      
      if PY2 and isinstance(s, text_type):
          s = s.encode("utf-8")
      return quote(s, safe="*")
docs: Encode URI component like CloudStack would do before signing.
  
      java.net.URLEncoder.encode(s).replace('+', '%20')