in oss2/models.py [0:0]
def __init__(self, redirect_type=None, pass_query_string= None, replace_key_with=None, replace_key_prefix_with=None,
proto=None, host_name=None, http_redirect_code=None, mirror_url=None, mirror_url_slave=None,
mirror_url_probe=None, mirror_pass_query_string=None, mirror_follow_redirect=None,
mirror_check_md5=None, mirror_headers=None):
if redirect_type not in [REDIRECT_TYPE_MIRROR, REDIRECT_TYPE_EXTERNAL, REDIRECT_TYPE_INTERNAL, REDIRECT_TYPE_ALICDN]:
raise ClientError('redirect_type must be Internal, External, Mirror or AliCDN.')
if redirect_type == REDIRECT_TYPE_INTERNAL:
if any((host_name, proto, http_redirect_code)):
raise ClientError('host_name, proto, http_redirect_code must be empty when redirect_type is Internal.')
if redirect_type in [REDIRECT_TYPE_EXTERNAL, REDIRECT_TYPE_ALICDN]:
if http_redirect_code is not None:
if http_redirect_code < 300 or http_redirect_code > 399:
raise ClientError("http_redirect_code must be a valid HTTP 3xx status code.")
if redirect_type in [REDIRECT_TYPE_EXTERNAL, REDIRECT_TYPE_ALICDN, REDIRECT_TYPE_INTERNAL]:
if all((replace_key_with, replace_key_prefix_with)):
raise ClientError("replace_key_with or replace_key_prefix_with only choose one.")
elif redirect_type == REDIRECT_TYPE_MIRROR:
if any((proto, host_name, replace_key_with, replace_key_prefix_with, http_redirect_code)):
raise ClientError('host_name, replace_key_with, replace_key_prefix_with, http_redirect_code and proto must be empty when redirect_type is Mirror.')
if mirror_url is None:
raise ClientError('mirror_url should not be None when redirect_type is Mirror.')
if (not mirror_url.startswith('http://') and not mirror_url.startswith('https://')) or not mirror_url.endswith('/'):
raise ClientError(r'mirror_url is invalid, should startwith "http://" or "https://", and endwith "/"')
if mirror_url_slave is not None:
if mirror_url_probe is None:
raise ClientError('mirror_url_probe should not be none when mirror_url_slave is indicated')
if (not mirror_url_slave.startswith('http://') and not mirror_url_slave.startswith('https://')) or not mirror_url_slave.endswith('/'):
raise ClientError(r'mirror_url_salve is invalid, should startwith "http://" or "https://", and endwith "/"')
self.redirect_type = redirect_type
self.pass_query_string = pass_query_string
self.replace_key_with = replace_key_with
self.replace_key_prefix_with = replace_key_prefix_with
self.proto = proto
self.host_name = host_name
self.http_redirect_code = http_redirect_code
self.mirror_url = mirror_url
self.mirror_url_slave = mirror_url_slave
self.mirror_url_probe = mirror_url_probe
self.mirror_pass_query_string = mirror_pass_query_string
self.mirror_check_md5 = mirror_check_md5
self.mirror_follow_redirect = mirror_follow_redirect
self.mirror_headers = mirror_headers