Skip to content

Commit 116dc62

Browse files
committed
fix(core): total_count legacy
1 parent 6fe996f commit 116dc62

File tree

1 file changed

+6
-2
lines changed
  • scaleway-core/scaleway_core

1 file changed

+6
-2
lines changed

scaleway-core/scaleway_core/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _request(
118118
body: Optional[Body] = None,
119119
) -> requests.Response:
120120
additional_headers: Dict[str, str] = {}
121-
122121
method = method.upper()
123122
if method == "POST" or method == "PUT" or method == "PATCH":
124123
additional_headers["Content-Type"] = "application/json; charset=utf-8"
@@ -146,7 +145,6 @@ def _request(
146145
**additional_headers,
147146
**headers,
148147
}
149-
150148
url = f"{self.client.api_url}{path}"
151149

152150
logger = APILogger(self._log, self.client._increment_request_count())
@@ -168,6 +166,12 @@ def _request(
168166
verify=not self.client.api_allow_insecure,
169167
)
170168

169+
if response.headers.get("x-total-count"):
170+
b = response.json()
171+
b["total_count"] = response.headers.get("x-total-count")
172+
b = json.dumps(b)
173+
response._content = bytes(b, "utf-8")
174+
171175
logger.log_response(
172176
response=response,
173177
)

0 commit comments

Comments
 (0)