File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
scaleway-core/scaleway_core Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,6 @@ def _request(
118
118
body : Optional [Body ] = None ,
119
119
) -> requests .Response :
120
120
additional_headers : Dict [str , str ] = {}
121
-
122
121
method = method .upper ()
123
122
if method == "POST" or method == "PUT" or method == "PATCH" :
124
123
additional_headers ["Content-Type" ] = "application/json; charset=utf-8"
@@ -141,12 +140,12 @@ def _request(
141
140
142
141
headers = {
143
142
"accept" : "application/json" ,
144
- "x-auth-token" : self .client .secret_key or "" ,
145
143
"user-agent" : self .client .user_agent ,
146
144
** additional_headers ,
147
145
** headers ,
148
146
}
149
-
147
+ if self .client .secret_key is not None :
148
+ headers ["x-auth-token" ] = self .client .secret_key
150
149
url = f"{ self .client .api_url } { path } "
151
150
152
151
logger = APILogger (self ._log , self .client ._increment_request_count ())
@@ -168,6 +167,12 @@ def _request(
168
167
verify = not self .client .api_allow_insecure ,
169
168
)
170
169
170
+ if response .headers .get ("x-total-count" ):
171
+ b = response .json ()
172
+ b ["total_count" ] = response .headers .get ("x-total-count" )
173
+ b = json .dumps (b )
174
+ response ._content = bytes (b , "utf-8" )
175
+
171
176
logger .log_response (
172
177
response = response ,
173
178
)
Original file line number Diff line number Diff line change
1
+ import logging
2
+ import sys
3
+ import unittest
4
+ from scaleway_core .client import Client
5
+ from scaleway .instance .v1 import InstanceV1API
6
+
7
+ logger = logging .getLogger ()
8
+ logger .level = logging .DEBUG
9
+ stream_handler = logging .StreamHandler (sys .stdout )
10
+ logger .addHandler (stream_handler )
11
+
12
+
13
+ class TestTotalCountLegacy (unittest .TestCase ):
14
+
15
+ def setUp (self ) -> None :
16
+ self .client = Client ()
17
+ self .instance_api = InstanceV1API (self .client , bypass_validation = True )
18
+
19
+ def test_list_servers_type (self ):
20
+ list_server_type = self .instance_api .list_servers_types (zone = "fr-par-1" )
21
+ self .assertIsNotNone (list_server_type .total_count )
22
+
23
+
You can’t perform that action at this time.
0 commit comments