Skip to content

Commit

Permalink
rebase with master
Browse files Browse the repository at this point in the history
change import of `Retry` to `from urllib3.util import Retry` because of
newer verion of requests and its dependecies
  • Loading branch information
mkudlej committed Feb 11, 2022
1 parent db09d7a commit d372454
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
Pipfile.lock

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
11 changes: 5 additions & 6 deletions threescale_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def __call__(self, request):
credentials = self.credentials

if self.location == "authorization":
credentials = credentials.values()
auth = requests.auth.HTTPBasicAuth(*credentials)
auth = requests.auth.HTTPBasicAuth(credentials["username"], credentials["password"])
return auth(request)

if self.location == "headers":
Expand All @@ -37,7 +36,7 @@ class UserKeyAuth(BaseClientAuth):
"""Provides user_key authentication for api client calls"""

def __init__(self, app, location=None):
BaseClientAuth.__init__(self, app, location)
super(UserKeyAuth, self).__init__(app, location)
self.credentials = {
self.app.service.proxy.list()["auth_user_key"]: self.app["user_key"]
}
Expand All @@ -46,19 +45,19 @@ def __call__(self, request):
if self.location == "authorization":
auth = requests.auth.HTTPBasicAuth(next(iter(self.credentials.values())), "")
return auth(request)
return BaseClientAuth.__call__(self, request)
return super().__call__(request)


class AppIdKeyAuth(BaseClientAuth):
"""Provides app_id/app_key pair based authentication for api client calls"""

def __init__(self, app, location=None):
BaseClientAuth.__init__(self, app, location)
super(AppIdKeyAuth, self).__init__(app, location)
proxy = self.app.service.proxy.list()
self.credentials = {
proxy["auth_app_id"]: self.app["application_id"],
proxy["auth_app_key"]: self.app.keys.list()["keys"][0]["key"]["value"]
}

def __call__(self, request):
return BaseClientAuth.__call__(self, request)
return super().__call__(request)
8 changes: 4 additions & 4 deletions threescale_api/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def __make_instance(self, extracted: dict, klass):

class DefaultResource(collections.abc.MutableMapping):
def __init__(self, client: DefaultClient = None, entity_id: int = None, entity_name: str = None,
entity: dict = None, **kwargs):
entity: dict = None):
"""Create instance of the resource
Args:
client: Client instance of the resource
Expand All @@ -281,7 +281,7 @@ def threescale_client(self) -> 'ThreeScaleClient':
@property
def parent(self) -> 'DefaultResource':
return self.client.parent

@parent.setter
def parent(self, parent):
self.client.parent = parent
Expand Down Expand Up @@ -416,7 +416,7 @@ def get_default(self, **kwargs) -> Optional['DefaultResource']:

class DefaultPlanResource(DefaultResource):
def __init__(self, entity_name='system_name', **kwargs):
DefaultResource.__init__(self, entity_name=entity_name, **kwargs)
super().__init__(entity_name=entity_name, **kwargs)

def set_default(self, **kwargs) -> 'DefaultStateResource':
"""Set the plan default
Expand Down Expand Up @@ -462,7 +462,7 @@ def set_state(self, state: str, **kwargs) -> 'DefaultStateResource':

class DefaultUserResource(DefaultStateResource):
def __init__(self, entity_name='username', **kwargs):
DefaultStateResource.__init__(self, entity_name=entity_name, **kwargs)
super().__init__(entity_name=entity_name, **kwargs)

def suspend(self, **kwargs) -> 'DefaultUserResource':
"""Suspends the user
Expand Down
4 changes: 2 additions & 2 deletions threescale_api/errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ThreeScaleApiError(Exception):
def __init__(self, message, *args):
self.message = message
Exception.__init__(self, message, *args)
super(ThreeScaleApiError, self).__init__(message, *args)


class ApiClientError(ThreeScaleApiError):
Expand All @@ -13,4 +13,4 @@ def __init__(self, code, reason, body, message: str = None):
msg = f"Response({self.code} {reason}): {body}"
if message:
msg += f"; {message}"
ThreeScaleApiError.__init__(self, msg)
super(ApiClientError, self).__init__(msg)
Loading

0 comments on commit d372454

Please sign in to comment.