From a9a9da5d0aec1e9dba58d44dd2a15b6c2fa37dbf Mon Sep 17 00:00:00 2001 From: Martin Kudlej Date: Thu, 11 Aug 2022 09:57:51 +0200 Subject: [PATCH] fixes for crd client --- threescale_api/client.py | 2 +- threescale_api/defaults.py | 4 +++- threescale_api/resources.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/threescale_api/client.py b/threescale_api/client.py index 4978797..a44e597 100644 --- a/threescale_api/client.py +++ b/threescale_api/client.py @@ -292,7 +292,7 @@ def request(self, method='GET', url=None, path='', params: dict = None, """ if 'resource' in kwargs: - del(kwargs['resource']) + del kwargs['resource'] full_url = url if url else urljoin(self.url, path) full_url = full_url + ".json" headers = headers or {} diff --git a/threescale_api/defaults.py b/threescale_api/defaults.py index 4bc1364..374d67d 100644 --- a/threescale_api/defaults.py +++ b/threescale_api/defaults.py @@ -351,8 +351,10 @@ def _lazy_load(self, **kwargs) -> 'DefaultResource': fetched = self.fetch(**kwargs) if isinstance(fetched, dict): self._entity = fetched - else: + elif fetched is not None: self._entity = fetched._entity + else: + return None return self def read(self, **kwargs) -> 'DefaultResource': diff --git a/threescale_api/resources.py b/threescale_api/resources.py index 45f94f3..312d924 100644 --- a/threescale_api/resources.py +++ b/threescale_api/resources.py @@ -44,7 +44,7 @@ def url(self) -> str: class Limits(DefaultClient): - def __init__(self, *args, entity_name='limit', entity_collection='limits', metric, + def __init__(self, *args, entity_name='limit', entity_collection='limits', metric=None, **kwargs): super().__init__(*args, entity_name=entity_name, entity_collection=entity_collection, **kwargs)