Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Generate request url without domain
:param region_id: String
:return: String
"""
sign_params = self.get_query_params()
if 'RegionId' not in list(sign_params.keys()):
sign_params['RegionId'] = region_id
url = oss_signer.get_url(
sign_params,
self.get_uri_pattern(),
self.get_path_params())
return url
class CommonRequest(AcsRequest):
def __init__(self, domain=None, version=None, action_name=None, uri_pattern=None, product=None, location_endpoint_type='openAPI'):
super(CommonRequest, self).__init__(product)
self.request = None
self.endpoint = domain
self._version = version
self._action_name = action_name
self._uri_pattern = uri_pattern
self._product = product
self._location_endpoint_type = location_endpoint_type,
self._signer = sha_hmac1
self.add_header('x-sdk-invoke-type', 'common')
self._path_params = None
self._method = "GET"
def get_path_params(self):
def get_style(self):
pass
@abc.abstractmethod
def get_url(self, region_id, ak, secret):
pass
@abc.abstractmethod
def get_signed_header(self, region_id, ak, secret):
pass
def set_endpoint(self, endpoint):
self.endpoint = endpoint
class RpcRequest(AcsRequest):
"""
Class to compose an RPC style request with.
"""
def __init__(
self,
product,
version,
action_name,
location_service_code=None,
location_endpoint_type='openAPI',
format=None,
protocol=None,
signer=sha_hmac1):
AcsRequest.__init__(
self,
secret,
self.get_accept_format(),
self.get_method(),
self.get_body_params(),
self._signer)
return url
def get_signed_header(self, region_id=None, ak=None, secret=None):
headers = {}
for headerKey, headerValue in list(self.get_headers().items()):
if headerKey.startswith("x-acs-") or headerKey.startswith("x-sdk-"):
headers[headerKey] = headerValue
return headers
class RoaRequest(AcsRequest):
"""
Class to compose an ROA style request with.
"""
def __init__(
self,
product,
version,
action_name,
location_service_code=None,
location_endpoint_type='openAPI',
method=None,
headers=None,
uri_pattern=None,
path_params=None,
protocol=None):
"""
Compose request url without domain
:param region_id: String
:return: String
"""
sign_params = self.get_query_params()
# if region_id not in sign_params.keys():
# sign_params['RegionId'] = region_id
url = roa_signer.get_url(
self.get_uri_pattern(),
sign_params,
self.get_path_params())
return url
class OssRequest(AcsRequest):
def __init__(
self,
product,
version,
action_name,
location_service_code,
bucket=None,
method=None,
headers=None,
uri_pattern=None,
path_params=None,
protocol=None):
"""
:param product: String, mandatory
:param version: String, mandatory