Skip to content

Commit d372454

Browse files
author
Martin Kudlej
committed
rebase with master
change import of `Retry` to `from urllib3.util import Retry` because of newer verion of requests and its dependecies
1 parent db09d7a commit d372454

File tree

5 files changed

+65
-65
lines changed

5 files changed

+65
-65
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ share/python-wheels/
3232
.installed.cfg
3333
*.egg
3434
MANIFEST
35+
Pipfile.lock
3536

3637
# PyInstaller
3738
# Usually these files are written by a python script from a template

threescale_api/auth.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def __call__(self, request):
1919
credentials = self.credentials
2020

2121
if self.location == "authorization":
22-
credentials = credentials.values()
23-
auth = requests.auth.HTTPBasicAuth(*credentials)
22+
auth = requests.auth.HTTPBasicAuth(credentials["username"], credentials["password"])
2423
return auth(request)
2524

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

3938
def __init__(self, app, location=None):
40-
BaseClientAuth.__init__(self, app, location)
39+
super(UserKeyAuth, self).__init__(app, location)
4140
self.credentials = {
4241
self.app.service.proxy.list()["auth_user_key"]: self.app["user_key"]
4342
}
@@ -46,19 +45,19 @@ def __call__(self, request):
4645
if self.location == "authorization":
4746
auth = requests.auth.HTTPBasicAuth(next(iter(self.credentials.values())), "")
4847
return auth(request)
49-
return BaseClientAuth.__call__(self, request)
48+
return super().__call__(request)
5049

5150

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

5554
def __init__(self, app, location=None):
56-
BaseClientAuth.__init__(self, app, location)
55+
super(AppIdKeyAuth, self).__init__(app, location)
5756
proxy = self.app.service.proxy.list()
5857
self.credentials = {
5958
proxy["auth_app_id"]: self.app["application_id"],
6059
proxy["auth_app_key"]: self.app.keys.list()["keys"][0]["key"]["value"]
6160
}
6261

6362
def __call__(self, request):
64-
return BaseClientAuth.__call__(self, request)
63+
return super().__call__(request)

threescale_api/defaults.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def __make_instance(self, extracted: dict, klass):
261261

262262
class DefaultResource(collections.abc.MutableMapping):
263263
def __init__(self, client: DefaultClient = None, entity_id: int = None, entity_name: str = None,
264-
entity: dict = None, **kwargs):
264+
entity: dict = None):
265265
"""Create instance of the resource
266266
Args:
267267
client: Client instance of the resource
@@ -281,7 +281,7 @@ def threescale_client(self) -> 'ThreeScaleClient':
281281
@property
282282
def parent(self) -> 'DefaultResource':
283283
return self.client.parent
284-
284+
285285
@parent.setter
286286
def parent(self, parent):
287287
self.client.parent = parent
@@ -416,7 +416,7 @@ def get_default(self, **kwargs) -> Optional['DefaultResource']:
416416

417417
class DefaultPlanResource(DefaultResource):
418418
def __init__(self, entity_name='system_name', **kwargs):
419-
DefaultResource.__init__(self, entity_name=entity_name, **kwargs)
419+
super().__init__(entity_name=entity_name, **kwargs)
420420

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

463463
class DefaultUserResource(DefaultStateResource):
464464
def __init__(self, entity_name='username', **kwargs):
465-
DefaultStateResource.__init__(self, entity_name=entity_name, **kwargs)
465+
super().__init__(entity_name=entity_name, **kwargs)
466466

467467
def suspend(self, **kwargs) -> 'DefaultUserResource':
468468
"""Suspends the user

threescale_api/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class ThreeScaleApiError(Exception):
22
def __init__(self, message, *args):
33
self.message = message
4-
Exception.__init__(self, message, *args)
4+
super(ThreeScaleApiError, self).__init__(message, *args)
55

66

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

0 commit comments

Comments
 (0)