Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support https #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions footmark/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class ACSAuthConnection(object):
def __init__(self, acs_access_key_id=None, acs_secret_access_key=None, security_token=None,
region=None, provider='acs', user_agent=None, ecs_role_name=None):
region=None, provider='acs', user_agent=None, ecs_role_name=None, alicloud_protocol=None):
"""
:keyword str acs_access_key_id: Your ACS Access Key ID (provided by
Alicloud). If none is specified, the value in your
Expand All @@ -48,7 +48,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None, security_
acs_access_key_id,
acs_secret_access_key,
security_token,
ecs_role_name)
ecs_role_name,
alicloud_protocol)

def acs_access_key_id(self):
return self.provider.access_key
Expand All @@ -75,12 +76,16 @@ def ecs_role_name(self):

ecs_role_name = property(ecs_role_name)

def alicloud_protocol(self):
return self.provider.alicloud_protocol

alicloud_protocol = property(alicloud_protocol)

class ACSQueryConnection(ACSAuthConnection):
ResponseError = FootmarkServerError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None, region=None,
product=None, security_token=None, ecs_role_name=None, provider='acs',
product=None, security_token=None, ecs_role_name=None, alicloud_protocol=None, provider='acs',
user_agent='Alicloud-Footmark-v'+footmark.__version__):

super(ACSQueryConnection, self).__init__(
Expand All @@ -90,7 +95,9 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None, region=No
ecs_role_name=ecs_role_name,
region=region,
provider=provider,
user_agent=user_agent)
user_agent=user_agent,
alicloud_protocol=alicloud_protocol
)

self.product = product
self.user_agent = user_agent
Expand Down Expand Up @@ -304,12 +311,12 @@ def make_request_new(self, params):

if not params.get('Action', params.get('action')):
raise Exception("'Action' is required for this request.")

while timeout > 0:
request = self.import_request(params.get('Action', params.get('action')))
request.set_accept_format('json')
request.set_read_timeout(30)
request.set_connect_timeout(30)
request.set_protocol_type(self.alicloud_protocol)
try:
for k, v in list(params.items()):
if hasattr(request, k):
Expand Down Expand Up @@ -339,9 +346,9 @@ def convert_tags(self, tags):

def underscore_to_studlycaps(self, text):
"""
Convert a under_score string to studly_caps, like: aaa_bbb -> AaaBbb
:param text:
:return:
Convert a under_score string to studly_caps, like: aaa_bbb -> AaaBbb
:param text:
:return:
"""
res = ""
for key in [_f for _f in str(text).lower().split('_') if _f]:
Expand All @@ -352,8 +359,8 @@ def get_current_function_name(self, is_studly_caps=False):
"""
Get the current function name and the return can be StudlyCaps.
E.G: The current name is "aaa_bbb_ccc", if is_studly_caps, return AaaBbbCcc, else return aaa_bbb_ccc
:param is_studly_caps:
:return:
:param is_studly_caps:
:return:
"""
res = inspect.stack()[1][3]
if is_studly_caps:
Expand Down
5 changes: 3 additions & 2 deletions footmark/dns/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DNSConnection(ACSQueryConnection):
ResponseError = DNSResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to DNS.
"""
Expand All @@ -36,7 +36,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
security_token=security_token,
region=self.region, product=self.STSSDK,
user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def add_domain(self, **kwargs):
domain_name = self.get_object_new(self.build_request_params(self.format_request_kwargs(**kwargs)), ResultSet).domain_name
Expand Down
5 changes: 3 additions & 2 deletions footmark/ecs/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ECSConnection(ACSQueryConnection):
ResponseError = ECSResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to ECS.
"""
Expand All @@ -51,7 +51,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
acs_secret_access_key=acs_secret_access_key,
region=self.region, product=self.ECSSDK,
security_token=security_token, user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def build_filter_params(self, params, filters):
if not isinstance(filters, dict):
Expand Down
5 changes: 3 additions & 2 deletions footmark/ess/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ESSConnection(ACSQueryConnection):
ResponseError = ECSResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to ECS.
"""
Expand All @@ -43,7 +43,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
acs_secret_access_key=acs_secret_access_key,
region=self.region, product=self.ESSSDK,
security_token=security_token, user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def build_filter_params(self, params, filters):
if not isinstance(filters, dict):
Expand Down
5 changes: 3 additions & 2 deletions footmark/market/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MARKETConnection(ACSQueryConnection):
ResponseError = MARKETResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to MARKET.
"""
Expand All @@ -32,7 +32,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
security_token=security_token,
region=self.region, product=self.MARKETSDK,
user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def describe_products(self, **kwargs):
return self.get_list_new(self.build_request_params(self.format_request_kwargs(**kwargs)), ['ProductItems', Product])
Expand Down
5 changes: 3 additions & 2 deletions footmark/oos/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OOSConnection(ACSQueryConnection):
ResponseError = OOSResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to OOS.
"""
Expand All @@ -31,7 +31,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
security_token=security_token,
region=self.region, product=self.RAMSDK,
user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def get_template(self, **kwargs):
return self.get_object_new(self.build_request_params(self.format_request_kwargs(**kwargs)), Template)
Expand Down
11 changes: 10 additions & 1 deletion footmark/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@


class Provider(object):
def __init__(self, name, access_key=None, secret_key=None, security_token=None, ecs_role_name=None):
def __init__(self, name, access_key=None, secret_key=None, security_token=None, ecs_role_name=None, alicloud_protocol=None):
self.access_key = access_key
self.secret_key = secret_key
self.security_token = security_token
self.ecs_role_name = ecs_role_name
self.alicloud_protocol = alicloud_protocol

def get_access_key(self):
# if self._credentials_need_refresh():
Expand Down Expand Up @@ -48,6 +49,14 @@ def set_ecs_role_name(self, value):

ecs_role_name = property(get_ecs_role_name, set_ecs_role_name)

def get_alicloud_protocol(self):
return self._alicloud_protocol

def set_alicloud_protocol(self, value):
self._alicloud_protocol = value

alicloud_protocol = property(get_alicloud_protocol, set_alicloud_protocol)


# Static utility method for getting default Provider.
def get_default():
Expand Down
5 changes: 3 additions & 2 deletions footmark/ram/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RAMConnection(ACSQueryConnection):
ResponseError = RAMResponseError

def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None):
region=None, sdk_version=None, security_token=None, ecs_role_name=None, user_agent=None, alicloud_protocol=None):
"""
Init method to create a new connection to STS.
"""
Expand All @@ -32,7 +32,8 @@ def __init__(self, acs_access_key_id=None, acs_secret_access_key=None,
security_token=security_token,
region=self.region, product=self.RAMSDK,
user_agent=user_agent,
ecs_role_name=ecs_role_name)
ecs_role_name=ecs_role_name,
alicloud_protocol=alicloud_protocol)

def list_users(self, **kwargs):
results = []
Expand Down
Loading