Skip to content

Commit

Permalink
Reduce client.verify complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
van-ess0 committed Oct 26, 2023
1 parent 2eac90a commit 60ad2bf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions aiven/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ def verify(
)
time.sleep(0.2)

return self._process_response(response=response, op=op, path=path, result_key=result_key)

@staticmethod
def build_path(*parts: str) -> str:
return "/" + "/".join(quote(part, safe="") for part in parts)

def _process_response(
self,
response: Response,
op: Callable[..., Response],
path: str,
result_key: str | None = None,
) -> Mapping | str:
# Check API is actually returning data or not
if response.status_code == HTTPStatus.NO_CONTENT or response.headers.get("Content-Length", "0") == "0":
return {}
Expand All @@ -199,10 +212,6 @@ def verify(
return result[result_key]
return result

@staticmethod
def build_path(*parts: str) -> str:
return "/" + "/".join(quote(part, safe="") for part in parts)


class AivenClient(AivenClientBase):
"""Aiven Client with high-level operations"""
Expand Down

0 comments on commit 60ad2bf

Please sign in to comment.