5
5
6
6
import requests
7
7
8
+ from fixtures .log_helper import log
9
+
8
10
if TYPE_CHECKING :
9
11
from typing import Any , Literal , Optional
10
12
@@ -30,7 +32,11 @@ def __request(self, method: str | bytes, endpoint: str, **kwargs: Any) -> reques
30
32
kwargs ["headers" ] = {}
31
33
kwargs ["headers" ]["Authorization" ] = f"Bearer { self .__neon_api_key } "
32
34
33
- return requests .request (method , f"{ self .__neon_api_base_url } { endpoint } " , ** kwargs )
35
+ resp = requests .request (method , f"{ self .__neon_api_base_url } { endpoint } " , ** kwargs )
36
+ log .debug ("%s %s returned a %d: %s" , method , endpoint , resp .status_code , resp .text )
37
+ resp .raise_for_status ()
38
+
39
+ return resp
34
40
35
41
def create_project (
36
42
self ,
@@ -66,8 +72,6 @@ def create_project(
66
72
json = data ,
67
73
)
68
74
69
- assert resp .status_code == 201
70
-
71
75
return cast ("dict[str, Any]" , resp .json ())
72
76
73
77
def get_project_details (self , project_id : str ) -> dict [str , Any ]:
@@ -79,7 +83,7 @@ def get_project_details(self, project_id: str) -> dict[str, Any]:
79
83
"Content-Type" : "application/json" ,
80
84
},
81
85
)
82
- assert resp . status_code == 200
86
+
83
87
return cast ("dict[str, Any]" , resp .json ())
84
88
85
89
def delete_project (
@@ -95,8 +99,6 @@ def delete_project(
95
99
},
96
100
)
97
101
98
- assert resp .status_code == 200
99
-
100
102
return cast ("dict[str, Any]" , resp .json ())
101
103
102
104
def start_endpoint (
@@ -112,8 +114,6 @@ def start_endpoint(
112
114
},
113
115
)
114
116
115
- assert resp .status_code == 200
116
-
117
117
return cast ("dict[str, Any]" , resp .json ())
118
118
119
119
def suspend_endpoint (
@@ -129,8 +129,6 @@ def suspend_endpoint(
129
129
},
130
130
)
131
131
132
- assert resp .status_code == 200
133
-
134
132
return cast ("dict[str, Any]" , resp .json ())
135
133
136
134
def restart_endpoint (
@@ -146,8 +144,6 @@ def restart_endpoint(
146
144
},
147
145
)
148
146
149
- assert resp .status_code == 200
150
-
151
147
return cast ("dict[str, Any]" , resp .json ())
152
148
153
149
def create_endpoint (
@@ -178,8 +174,6 @@ def create_endpoint(
178
174
json = data ,
179
175
)
180
176
181
- assert resp .status_code == 201
182
-
183
177
return cast ("dict[str, Any]" , resp .json ())
184
178
185
179
def get_connection_uri (
@@ -206,8 +200,6 @@ def get_connection_uri(
206
200
},
207
201
)
208
202
209
- assert resp .status_code == 200
210
-
211
203
return cast ("dict[str, Any]" , resp .json ())
212
204
213
205
def get_branches (self , project_id : str ) -> dict [str , Any ]:
@@ -219,8 +211,6 @@ def get_branches(self, project_id: str) -> dict[str, Any]:
219
211
},
220
212
)
221
213
222
- assert resp .status_code == 200
223
-
224
214
return cast ("dict[str, Any]" , resp .json ())
225
215
226
216
def get_endpoints (self , project_id : str ) -> dict [str , Any ]:
@@ -232,8 +222,6 @@ def get_endpoints(self, project_id: str) -> dict[str, Any]:
232
222
},
233
223
)
234
224
235
- assert resp .status_code == 200
236
-
237
225
return cast ("dict[str, Any]" , resp .json ())
238
226
239
227
def get_operations (self , project_id : str ) -> dict [str , Any ]:
@@ -246,8 +234,6 @@ def get_operations(self, project_id: str) -> dict[str, Any]:
246
234
},
247
235
)
248
236
249
- assert resp .status_code == 200
250
-
251
237
return cast ("dict[str, Any]" , resp .json ())
252
238
253
239
def wait_for_operation_to_finish (self , project_id : str ):
0 commit comments