latitudesh-python-sdk 1.1.0__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of latitudesh-python-sdk might be problematic. Click here for more details.

Files changed (93) hide show
  1. latitudesh_python_sdk/_hooks/types.py +7 -0
  2. latitudesh_python_sdk/_version.py +6 -4
  3. latitudesh_python_sdk/apikeys.py +73 -156
  4. latitudesh_python_sdk/basesdk.py +16 -24
  5. latitudesh_python_sdk/billing.py +13 -32
  6. latitudesh_python_sdk/events_sdk.py +11 -34
  7. latitudesh_python_sdk/firewalls_sdk.py +105 -264
  8. latitudesh_python_sdk/httpclient.py +6 -16
  9. latitudesh_python_sdk/ipaddresses_sdk.py +29 -68
  10. latitudesh_python_sdk/models/__init__.py +2586 -1126
  11. latitudesh_python_sdk/models/apierror.py +30 -14
  12. latitudesh_python_sdk/models/assign_server_virtual_networkop.py +2 -2
  13. latitudesh_python_sdk/models/{bandwidth_plan.py → bandwidth_plan_data.py} +9 -9
  14. latitudesh_python_sdk/models/bandwidth_plans.py +14 -3
  15. latitudesh_python_sdk/models/custom_tag.py +15 -0
  16. latitudesh_python_sdk/models/custom_tag_data.py +54 -0
  17. latitudesh_python_sdk/models/custom_tags.py +26 -0
  18. latitudesh_python_sdk/models/delete_ssh_keyop.py +16 -0
  19. latitudesh_python_sdk/models/delete_user_dataop.py +16 -0
  20. latitudesh_python_sdk/models/deploy_config.py +11 -6
  21. latitudesh_python_sdk/models/error_object.py +11 -6
  22. latitudesh_python_sdk/models/event_data.py +98 -0
  23. latitudesh_python_sdk/models/events.py +16 -1
  24. latitudesh_python_sdk/models/filesystem_data.py +4 -0
  25. latitudesh_python_sdk/models/firewall.py +15 -0
  26. latitudesh_python_sdk/models/firewall_assignment_data.py +50 -0
  27. latitudesh_python_sdk/models/firewall_assignments.py +29 -0
  28. latitudesh_python_sdk/models/firewall_data.py +71 -0
  29. latitudesh_python_sdk/models/firewall_server.py +4 -1
  30. latitudesh_python_sdk/models/firewalls.py +7 -7
  31. latitudesh_python_sdk/models/get_firewall_assignmentsop.py +3 -3
  32. latitudesh_python_sdk/models/get_ssh_keyop.py +30 -0
  33. latitudesh_python_sdk/models/get_ssh_keysop.py +22 -0
  34. latitudesh_python_sdk/models/get_traffic_consumptionop.py +8 -4
  35. latitudesh_python_sdk/models/get_user_dataop.py +31 -0
  36. latitudesh_python_sdk/models/get_users_dataop.py +35 -0
  37. latitudesh_python_sdk/models/latitudesherror.py +26 -0
  38. latitudesh_python_sdk/models/no_response_error.py +13 -0
  39. latitudesh_python_sdk/models/operating_system_data.py +65 -0
  40. latitudesh_python_sdk/models/operating_systems.py +15 -0
  41. latitudesh_python_sdk/models/out_of_band_connection.py +4 -4
  42. latitudesh_python_sdk/models/patch_user_dataop.py +69 -0
  43. latitudesh_python_sdk/models/post_ssh_keyop.py +58 -0
  44. latitudesh_python_sdk/models/post_user_dataop.py +45 -0
  45. latitudesh_python_sdk/models/project_include.py +3 -0
  46. latitudesh_python_sdk/models/put_ssh_keyop.py +80 -0
  47. latitudesh_python_sdk/models/region_resource_data.py +4 -4
  48. latitudesh_python_sdk/models/responsevalidationerror.py +25 -0
  49. latitudesh_python_sdk/models/role.py +11 -0
  50. latitudesh_python_sdk/models/server.py +11 -6
  51. latitudesh_python_sdk/models/server_data.py +14 -3
  52. latitudesh_python_sdk/models/server_region_resource_data.py +40 -0
  53. latitudesh_python_sdk/models/{ssh_key.py → ssh_keys.py} +13 -2
  54. latitudesh_python_sdk/models/storage_plan_data.py +47 -0
  55. latitudesh_python_sdk/models/storage_plans.py +14 -3
  56. latitudesh_python_sdk/models/update_serverop.py +58 -10
  57. latitudesh_python_sdk/models/user_data.py +11 -0
  58. latitudesh_python_sdk/models/virtual_network.py +30 -6
  59. latitudesh_python_sdk/models/virtual_network1.py +15 -0
  60. latitudesh_python_sdk/models/virtual_network_assignment.py +41 -0
  61. latitudesh_python_sdk/models/virtual_network_assignment_data.py +68 -0
  62. latitudesh_python_sdk/models/virtual_network_assignments.py +5 -5
  63. latitudesh_python_sdk/models/virtual_network_data.py +88 -0
  64. latitudesh_python_sdk/models/virtual_networks.py +3 -3
  65. latitudesh_python_sdk/operatingsystems_sdk.py +13 -32
  66. latitudesh_python_sdk/plans.py +99 -214
  67. latitudesh_python_sdk/privatenetworks.py +131 -290
  68. latitudesh_python_sdk/projects_sdk.py +79 -158
  69. latitudesh_python_sdk/regions_sdk.py +25 -66
  70. latitudesh_python_sdk/roles.py +25 -64
  71. latitudesh_python_sdk/sdk.py +110 -73
  72. latitudesh_python_sdk/sdkconfiguration.py +0 -7
  73. latitudesh_python_sdk/servers_sdk.py +305 -646
  74. latitudesh_python_sdk/sshkeys_sdk.py +1856 -0
  75. latitudesh_python_sdk/storage.py +41 -120
  76. latitudesh_python_sdk/tags.py +67 -146
  77. latitudesh_python_sdk/teams_sdk.py +41 -100
  78. latitudesh_python_sdk/teamsmembers.py +37 -96
  79. latitudesh_python_sdk/traffic_sdk.py +37 -76
  80. latitudesh_python_sdk/userdata_sdk.py +959 -149
  81. latitudesh_python_sdk/userprofile.py +37 -100
  82. latitudesh_python_sdk/utils/__init__.py +131 -46
  83. latitudesh_python_sdk/utils/forms.py +49 -28
  84. latitudesh_python_sdk/utils/serializers.py +3 -2
  85. latitudesh_python_sdk/utils/unmarshal_json_response.py +24 -0
  86. latitudesh_python_sdk/virtualmachines.py +71 -140
  87. latitudesh_python_sdk/vpnsessions.py +93 -172
  88. {latitudesh_python_sdk-1.1.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/METADATA +76 -43
  89. {latitudesh_python_sdk-1.1.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/RECORD +91 -67
  90. {latitudesh_python_sdk-1.1.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/WHEEL +1 -1
  91. latitudesh_python_sdk/models/storage_plan.py +0 -36
  92. latitudesh_python_sdk/sshkeys.py +0 -1050
  93. {latitudesh_python_sdk-1.1.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/LICENSE +0 -0
@@ -3,10 +3,12 @@
3
3
  from abc import ABC, abstractmethod
4
4
  import httpx
5
5
  from latitudesh_python_sdk.httpclient import HttpClient
6
+ from latitudesh_python_sdk.sdkconfiguration import SDKConfiguration
6
7
  from typing import Any, Callable, List, Optional, Tuple, Union
7
8
 
8
9
 
9
10
  class HookContext:
11
+ config: SDKConfiguration
10
12
  base_url: str
11
13
  operation_id: str
12
14
  oauth2_scopes: Optional[List[str]] = None
@@ -14,11 +16,13 @@ class HookContext:
14
16
 
15
17
  def __init__(
16
18
  self,
19
+ config: SDKConfiguration,
17
20
  base_url: str,
18
21
  operation_id: str,
19
22
  oauth2_scopes: Optional[List[str]],
20
23
  security_source: Optional[Union[Any, Callable[[], Any]]],
21
24
  ):
25
+ self.config = config
22
26
  self.base_url = base_url
23
27
  self.operation_id = operation_id
24
28
  self.oauth2_scopes = oauth2_scopes
@@ -28,6 +32,7 @@ class HookContext:
28
32
  class BeforeRequestContext(HookContext):
29
33
  def __init__(self, hook_ctx: HookContext):
30
34
  super().__init__(
35
+ hook_ctx.config,
31
36
  hook_ctx.base_url,
32
37
  hook_ctx.operation_id,
33
38
  hook_ctx.oauth2_scopes,
@@ -38,6 +43,7 @@ class BeforeRequestContext(HookContext):
38
43
  class AfterSuccessContext(HookContext):
39
44
  def __init__(self, hook_ctx: HookContext):
40
45
  super().__init__(
46
+ hook_ctx.config,
41
47
  hook_ctx.base_url,
42
48
  hook_ctx.operation_id,
43
49
  hook_ctx.oauth2_scopes,
@@ -48,6 +54,7 @@ class AfterSuccessContext(HookContext):
48
54
  class AfterErrorContext(HookContext):
49
55
  def __init__(self, hook_ctx: HookContext):
50
56
  super().__init__(
57
+ hook_ctx.config,
51
58
  hook_ctx.base_url,
52
59
  hook_ctx.operation_id,
53
60
  hook_ctx.oauth2_scopes,
@@ -3,10 +3,12 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "latitudesh-python-sdk"
6
- __version__: str = "1.1.0"
7
- __openapi_doc_version__: str = "v3"
8
- __gen_version__: str = "2.593.4"
9
- __user_agent__: str = "speakeasy-sdk/python 1.1.0 2.593.4 v3 latitudesh-python-sdk"
6
+ __version__: str = "2.0.1"
7
+ __openapi_doc_version__: str = "2023-06-01"
8
+ __gen_version__: str = "2.656.5"
9
+ __user_agent__: str = (
10
+ "speakeasy-sdk/python 2.0.1 2.656.5 2023-06-01 latitudesh-python-sdk"
11
+ )
10
12
 
11
13
  try:
12
14
  if __package__ is not None:
@@ -3,9 +3,10 @@
3
3
  from .basesdk import BaseSDK
4
4
  from latitudesh_python_sdk import models, utils
5
5
  from latitudesh_python_sdk._hooks import HookContext
6
- from latitudesh_python_sdk.types import BaseModel, OptionalNullable, UNSET
6
+ from latitudesh_python_sdk.types import OptionalNullable, UNSET
7
7
  from latitudesh_python_sdk.utils import get_security_from_env
8
- from typing import Any, Mapping, Optional, Union, cast
8
+ from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import Any, Mapping, Optional, Union
9
10
 
10
11
 
11
12
  class APIKeys(BaseSDK):
@@ -62,6 +63,7 @@ class APIKeys(BaseSDK):
62
63
 
63
64
  http_res = self.do_request(
64
65
  hook_ctx=HookContext(
66
+ config=self.sdk_configuration,
65
67
  base_url=base_url or "",
66
68
  operation_id="get-api-keys",
67
69
  oauth2_scopes=[],
@@ -75,26 +77,15 @@ class APIKeys(BaseSDK):
75
77
  )
76
78
 
77
79
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
78
- return utils.unmarshal_json(http_res.text, models.APIKey)
80
+ return unmarshal_json_response(models.APIKey, http_res)
79
81
  if utils.match_response(http_res, "4XX", "*"):
80
82
  http_res_text = utils.stream_to_text(http_res)
81
- raise models.APIError(
82
- "API error occurred", http_res.status_code, http_res_text, http_res
83
- )
83
+ raise models.APIError("API error occurred", http_res, http_res_text)
84
84
  if utils.match_response(http_res, "5XX", "*"):
85
85
  http_res_text = utils.stream_to_text(http_res)
86
- raise models.APIError(
87
- "API error occurred", http_res.status_code, http_res_text, http_res
88
- )
89
-
90
- content_type = http_res.headers.get("Content-Type")
91
- http_res_text = utils.stream_to_text(http_res)
92
- raise models.APIError(
93
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
94
- http_res.status_code,
95
- http_res_text,
96
- http_res,
97
- )
86
+ raise models.APIError("API error occurred", http_res, http_res_text)
87
+
88
+ raise models.APIError("Unexpected response received", http_res)
98
89
 
99
90
  async def list_async(
100
91
  self,
@@ -149,6 +140,7 @@ class APIKeys(BaseSDK):
149
140
 
150
141
  http_res = await self.do_request_async(
151
142
  hook_ctx=HookContext(
143
+ config=self.sdk_configuration,
152
144
  base_url=base_url or "",
153
145
  operation_id="get-api-keys",
154
146
  oauth2_scopes=[],
@@ -162,33 +154,20 @@ class APIKeys(BaseSDK):
162
154
  )
163
155
 
164
156
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
165
- return utils.unmarshal_json(http_res.text, models.APIKey)
157
+ return unmarshal_json_response(models.APIKey, http_res)
166
158
  if utils.match_response(http_res, "4XX", "*"):
167
159
  http_res_text = await utils.stream_to_text_async(http_res)
168
- raise models.APIError(
169
- "API error occurred", http_res.status_code, http_res_text, http_res
170
- )
160
+ raise models.APIError("API error occurred", http_res, http_res_text)
171
161
  if utils.match_response(http_res, "5XX", "*"):
172
162
  http_res_text = await utils.stream_to_text_async(http_res)
173
- raise models.APIError(
174
- "API error occurred", http_res.status_code, http_res_text, http_res
175
- )
176
-
177
- content_type = http_res.headers.get("Content-Type")
178
- http_res_text = await utils.stream_to_text_async(http_res)
179
- raise models.APIError(
180
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
181
- http_res.status_code,
182
- http_res_text,
183
- http_res,
184
- )
163
+ raise models.APIError("API error occurred", http_res, http_res_text)
164
+
165
+ raise models.APIError("Unexpected response received", http_res)
185
166
 
186
167
  def create(
187
168
  self,
188
169
  *,
189
- request: Union[
190
- models.CreateAPIKey, models.CreateAPIKeyTypedDict
191
- ] = models.CreateAPIKey(),
170
+ data: Optional[Union[models.Data, models.DataTypedDict]] = None,
192
171
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
193
172
  server_url: Optional[str] = None,
194
173
  timeout_ms: Optional[int] = None,
@@ -199,7 +178,7 @@ class APIKeys(BaseSDK):
199
178
  Create a new API Key that is tied to the current user account. The created API key is only listed ONCE upon creation. It can however be regenerated or deleted.
200
179
 
201
180
 
202
- :param request: The request object to send.
181
+ :param data:
203
182
  :param retries: Override the default retry configuration for this method
204
183
  :param server_url: Override the default server URL for this method
205
184
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -215,9 +194,9 @@ class APIKeys(BaseSDK):
215
194
  else:
216
195
  base_url = self._get_url(base_url, url_variables)
217
196
 
218
- if not isinstance(request, BaseModel):
219
- request = utils.unmarshal(request, models.CreateAPIKey)
220
- request = cast(models.CreateAPIKey, request)
197
+ request = models.CreateAPIKey(
198
+ data=utils.get_pydantic_model(data, Optional[models.Data]),
199
+ )
221
200
 
222
201
  req = self._build_request(
223
202
  method="POST",
@@ -233,7 +212,7 @@ class APIKeys(BaseSDK):
233
212
  http_headers=http_headers,
234
213
  security=self.sdk_configuration.security,
235
214
  get_serialized_body=lambda: utils.serialize_request_body(
236
- request, False, True, "json", Optional[models.CreateAPIKey]
215
+ request, False, False, "json", models.CreateAPIKey
237
216
  ),
238
217
  timeout_ms=timeout_ms,
239
218
  )
@@ -248,6 +227,7 @@ class APIKeys(BaseSDK):
248
227
 
249
228
  http_res = self.do_request(
250
229
  hook_ctx=HookContext(
230
+ config=self.sdk_configuration,
251
231
  base_url=base_url or "",
252
232
  operation_id="post-api-key",
253
233
  oauth2_scopes=[],
@@ -262,36 +242,23 @@ class APIKeys(BaseSDK):
262
242
 
263
243
  response_data: Any = None
264
244
  if utils.match_response(http_res, "201", "application/vnd.api+json"):
265
- return utils.unmarshal_json(http_res.text, models.PostAPIKeyResponseBody)
245
+ return unmarshal_json_response(models.PostAPIKeyResponseBody, http_res)
266
246
  if utils.match_response(http_res, ["400", "422"], "application/vnd.api+json"):
267
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
268
- raise models.ErrorObject(data=response_data)
247
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
248
+ raise models.ErrorObject(response_data, http_res)
269
249
  if utils.match_response(http_res, "4XX", "*"):
270
250
  http_res_text = utils.stream_to_text(http_res)
271
- raise models.APIError(
272
- "API error occurred", http_res.status_code, http_res_text, http_res
273
- )
251
+ raise models.APIError("API error occurred", http_res, http_res_text)
274
252
  if utils.match_response(http_res, "5XX", "*"):
275
253
  http_res_text = utils.stream_to_text(http_res)
276
- raise models.APIError(
277
- "API error occurred", http_res.status_code, http_res_text, http_res
278
- )
279
-
280
- content_type = http_res.headers.get("Content-Type")
281
- http_res_text = utils.stream_to_text(http_res)
282
- raise models.APIError(
283
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
284
- http_res.status_code,
285
- http_res_text,
286
- http_res,
287
- )
254
+ raise models.APIError("API error occurred", http_res, http_res_text)
255
+
256
+ raise models.APIError("Unexpected response received", http_res)
288
257
 
289
258
  async def create_async(
290
259
  self,
291
260
  *,
292
- request: Union[
293
- models.CreateAPIKey, models.CreateAPIKeyTypedDict
294
- ] = models.CreateAPIKey(),
261
+ data: Optional[Union[models.Data, models.DataTypedDict]] = None,
295
262
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
296
263
  server_url: Optional[str] = None,
297
264
  timeout_ms: Optional[int] = None,
@@ -302,7 +269,7 @@ class APIKeys(BaseSDK):
302
269
  Create a new API Key that is tied to the current user account. The created API key is only listed ONCE upon creation. It can however be regenerated or deleted.
303
270
 
304
271
 
305
- :param request: The request object to send.
272
+ :param data:
306
273
  :param retries: Override the default retry configuration for this method
307
274
  :param server_url: Override the default server URL for this method
308
275
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -318,9 +285,9 @@ class APIKeys(BaseSDK):
318
285
  else:
319
286
  base_url = self._get_url(base_url, url_variables)
320
287
 
321
- if not isinstance(request, BaseModel):
322
- request = utils.unmarshal(request, models.CreateAPIKey)
323
- request = cast(models.CreateAPIKey, request)
288
+ request = models.CreateAPIKey(
289
+ data=utils.get_pydantic_model(data, Optional[models.Data]),
290
+ )
324
291
 
325
292
  req = self._build_request_async(
326
293
  method="POST",
@@ -336,7 +303,7 @@ class APIKeys(BaseSDK):
336
303
  http_headers=http_headers,
337
304
  security=self.sdk_configuration.security,
338
305
  get_serialized_body=lambda: utils.serialize_request_body(
339
- request, False, True, "json", Optional[models.CreateAPIKey]
306
+ request, False, False, "json", models.CreateAPIKey
340
307
  ),
341
308
  timeout_ms=timeout_ms,
342
309
  )
@@ -351,6 +318,7 @@ class APIKeys(BaseSDK):
351
318
 
352
319
  http_res = await self.do_request_async(
353
320
  hook_ctx=HookContext(
321
+ config=self.sdk_configuration,
354
322
  base_url=base_url or "",
355
323
  operation_id="post-api-key",
356
324
  oauth2_scopes=[],
@@ -365,29 +333,18 @@ class APIKeys(BaseSDK):
365
333
 
366
334
  response_data: Any = None
367
335
  if utils.match_response(http_res, "201", "application/vnd.api+json"):
368
- return utils.unmarshal_json(http_res.text, models.PostAPIKeyResponseBody)
336
+ return unmarshal_json_response(models.PostAPIKeyResponseBody, http_res)
369
337
  if utils.match_response(http_res, ["400", "422"], "application/vnd.api+json"):
370
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
371
- raise models.ErrorObject(data=response_data)
338
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
339
+ raise models.ErrorObject(response_data, http_res)
372
340
  if utils.match_response(http_res, "4XX", "*"):
373
341
  http_res_text = await utils.stream_to_text_async(http_res)
374
- raise models.APIError(
375
- "API error occurred", http_res.status_code, http_res_text, http_res
376
- )
342
+ raise models.APIError("API error occurred", http_res, http_res_text)
377
343
  if utils.match_response(http_res, "5XX", "*"):
378
344
  http_res_text = await utils.stream_to_text_async(http_res)
379
- raise models.APIError(
380
- "API error occurred", http_res.status_code, http_res_text, http_res
381
- )
382
-
383
- content_type = http_res.headers.get("Content-Type")
384
- http_res_text = await utils.stream_to_text_async(http_res)
385
- raise models.APIError(
386
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
387
- http_res.status_code,
388
- http_res_text,
389
- http_res,
390
- )
345
+ raise models.APIError("API error occurred", http_res, http_res_text)
346
+
347
+ raise models.APIError("Unexpected response received", http_res)
391
348
 
392
349
  def regenerate(
393
350
  self,
@@ -459,6 +416,7 @@ class APIKeys(BaseSDK):
459
416
 
460
417
  http_res = self.do_request(
461
418
  hook_ctx=HookContext(
419
+ config=self.sdk_configuration,
462
420
  base_url=base_url or "",
463
421
  operation_id="update-api-key",
464
422
  oauth2_scopes=[],
@@ -473,29 +431,18 @@ class APIKeys(BaseSDK):
473
431
 
474
432
  response_data: Any = None
475
433
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
476
- return utils.unmarshal_json(http_res.text, models.UpdateAPIKeyResponseBody)
434
+ return unmarshal_json_response(models.UpdateAPIKeyResponseBody, http_res)
477
435
  if utils.match_response(http_res, ["400", "404"], "application/vnd.api+json"):
478
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
479
- raise models.ErrorObject(data=response_data)
436
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
437
+ raise models.ErrorObject(response_data, http_res)
480
438
  if utils.match_response(http_res, "4XX", "*"):
481
439
  http_res_text = utils.stream_to_text(http_res)
482
- raise models.APIError(
483
- "API error occurred", http_res.status_code, http_res_text, http_res
484
- )
440
+ raise models.APIError("API error occurred", http_res, http_res_text)
485
441
  if utils.match_response(http_res, "5XX", "*"):
486
442
  http_res_text = utils.stream_to_text(http_res)
487
- raise models.APIError(
488
- "API error occurred", http_res.status_code, http_res_text, http_res
489
- )
490
-
491
- content_type = http_res.headers.get("Content-Type")
492
- http_res_text = utils.stream_to_text(http_res)
493
- raise models.APIError(
494
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
495
- http_res.status_code,
496
- http_res_text,
497
- http_res,
498
- )
443
+ raise models.APIError("API error occurred", http_res, http_res_text)
444
+
445
+ raise models.APIError("Unexpected response received", http_res)
499
446
 
500
447
  async def regenerate_async(
501
448
  self,
@@ -567,6 +514,7 @@ class APIKeys(BaseSDK):
567
514
 
568
515
  http_res = await self.do_request_async(
569
516
  hook_ctx=HookContext(
517
+ config=self.sdk_configuration,
570
518
  base_url=base_url or "",
571
519
  operation_id="update-api-key",
572
520
  oauth2_scopes=[],
@@ -581,29 +529,18 @@ class APIKeys(BaseSDK):
581
529
 
582
530
  response_data: Any = None
583
531
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
584
- return utils.unmarshal_json(http_res.text, models.UpdateAPIKeyResponseBody)
532
+ return unmarshal_json_response(models.UpdateAPIKeyResponseBody, http_res)
585
533
  if utils.match_response(http_res, ["400", "404"], "application/vnd.api+json"):
586
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
587
- raise models.ErrorObject(data=response_data)
534
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
535
+ raise models.ErrorObject(response_data, http_res)
588
536
  if utils.match_response(http_res, "4XX", "*"):
589
537
  http_res_text = await utils.stream_to_text_async(http_res)
590
- raise models.APIError(
591
- "API error occurred", http_res.status_code, http_res_text, http_res
592
- )
538
+ raise models.APIError("API error occurred", http_res, http_res_text)
593
539
  if utils.match_response(http_res, "5XX", "*"):
594
540
  http_res_text = await utils.stream_to_text_async(http_res)
595
- raise models.APIError(
596
- "API error occurred", http_res.status_code, http_res_text, http_res
597
- )
598
-
599
- content_type = http_res.headers.get("Content-Type")
600
- http_res_text = await utils.stream_to_text_async(http_res)
601
- raise models.APIError(
602
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
603
- http_res.status_code,
604
- http_res_text,
605
- http_res,
606
- )
541
+ raise models.APIError("API error occurred", http_res, http_res_text)
542
+
543
+ raise models.APIError("Unexpected response received", http_res)
607
544
 
608
545
  def delete(
609
546
  self,
@@ -665,6 +602,7 @@ class APIKeys(BaseSDK):
665
602
 
666
603
  http_res = self.do_request(
667
604
  hook_ctx=HookContext(
605
+ config=self.sdk_configuration,
668
606
  base_url=base_url or "",
669
607
  operation_id="delete-api-key",
670
608
  oauth2_scopes=[],
@@ -681,27 +619,16 @@ class APIKeys(BaseSDK):
681
619
  if utils.match_response(http_res, "200", "*"):
682
620
  return
683
621
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
684
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
685
- raise models.ErrorObject(data=response_data)
622
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
623
+ raise models.ErrorObject(response_data, http_res)
686
624
  if utils.match_response(http_res, "4XX", "*"):
687
625
  http_res_text = utils.stream_to_text(http_res)
688
- raise models.APIError(
689
- "API error occurred", http_res.status_code, http_res_text, http_res
690
- )
626
+ raise models.APIError("API error occurred", http_res, http_res_text)
691
627
  if utils.match_response(http_res, "5XX", "*"):
692
628
  http_res_text = utils.stream_to_text(http_res)
693
- raise models.APIError(
694
- "API error occurred", http_res.status_code, http_res_text, http_res
695
- )
696
-
697
- content_type = http_res.headers.get("Content-Type")
698
- http_res_text = utils.stream_to_text(http_res)
699
- raise models.APIError(
700
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
701
- http_res.status_code,
702
- http_res_text,
703
- http_res,
704
- )
629
+ raise models.APIError("API error occurred", http_res, http_res_text)
630
+
631
+ raise models.APIError("Unexpected response received", http_res)
705
632
 
706
633
  async def delete_async(
707
634
  self,
@@ -763,6 +690,7 @@ class APIKeys(BaseSDK):
763
690
 
764
691
  http_res = await self.do_request_async(
765
692
  hook_ctx=HookContext(
693
+ config=self.sdk_configuration,
766
694
  base_url=base_url or "",
767
695
  operation_id="delete-api-key",
768
696
  oauth2_scopes=[],
@@ -779,24 +707,13 @@ class APIKeys(BaseSDK):
779
707
  if utils.match_response(http_res, "200", "*"):
780
708
  return
781
709
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
782
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
783
- raise models.ErrorObject(data=response_data)
710
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
711
+ raise models.ErrorObject(response_data, http_res)
784
712
  if utils.match_response(http_res, "4XX", "*"):
785
713
  http_res_text = await utils.stream_to_text_async(http_res)
786
- raise models.APIError(
787
- "API error occurred", http_res.status_code, http_res_text, http_res
788
- )
714
+ raise models.APIError("API error occurred", http_res, http_res_text)
789
715
  if utils.match_response(http_res, "5XX", "*"):
790
716
  http_res_text = await utils.stream_to_text_async(http_res)
791
- raise models.APIError(
792
- "API error occurred", http_res.status_code, http_res_text, http_res
793
- )
794
-
795
- content_type = http_res.headers.get("Content-Type")
796
- http_res_text = await utils.stream_to_text_async(http_res)
797
- raise models.APIError(
798
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
799
- http_res.status_code,
800
- http_res_text,
801
- http_res,
802
- )
717
+ raise models.APIError("API error occurred", http_res, http_res_text)
718
+
719
+ raise models.APIError("Unexpected response received", http_res)
@@ -222,12 +222,12 @@ class BaseSDK:
222
222
  client = self.sdk_configuration.client
223
223
  logger = self.sdk_configuration.debug_logger
224
224
 
225
+ hooks = self.sdk_configuration.__dict__["_hooks"]
226
+
225
227
  def do():
226
228
  http_res = None
227
229
  try:
228
- req = self.sdk_configuration.get_hooks().before_request(
229
- BeforeRequestContext(hook_ctx), request
230
- )
230
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
231
231
  logger.debug(
232
232
  "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
233
233
  req.method,
@@ -241,16 +241,14 @@ class BaseSDK:
241
241
 
242
242
  http_res = client.send(req, stream=stream)
243
243
  except Exception as e:
244
- _, e = self.sdk_configuration.get_hooks().after_error(
245
- AfterErrorContext(hook_ctx), None, e
246
- )
244
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
247
245
  if e is not None:
248
246
  logger.debug("Request Exception", exc_info=True)
249
247
  raise e
250
248
 
251
249
  if http_res is None:
252
250
  logger.debug("Raising no response SDK error")
253
- raise models.APIError("No response received")
251
+ raise models.NoResponseError("No response received")
254
252
 
255
253
  logger.debug(
256
254
  "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -261,7 +259,7 @@ class BaseSDK:
261
259
  )
262
260
 
263
261
  if utils.match_status_codes(error_status_codes, http_res.status_code):
264
- result, err = self.sdk_configuration.get_hooks().after_error(
262
+ result, err = hooks.after_error(
265
263
  AfterErrorContext(hook_ctx), http_res, None
266
264
  )
267
265
  if err is not None:
@@ -271,7 +269,7 @@ class BaseSDK:
271
269
  http_res = result
272
270
  else:
273
271
  logger.debug("Raising unexpected SDK error")
274
- raise models.APIError("Unexpected error occurred")
272
+ raise models.APIError("Unexpected error occurred", http_res)
275
273
 
276
274
  return http_res
277
275
 
@@ -281,9 +279,7 @@ class BaseSDK:
281
279
  http_res = do()
282
280
 
283
281
  if not utils.match_status_codes(error_status_codes, http_res.status_code):
284
- http_res = self.sdk_configuration.get_hooks().after_success(
285
- AfterSuccessContext(hook_ctx), http_res
286
- )
282
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
287
283
 
288
284
  return http_res
289
285
 
@@ -298,12 +294,12 @@ class BaseSDK:
298
294
  client = self.sdk_configuration.async_client
299
295
  logger = self.sdk_configuration.debug_logger
300
296
 
297
+ hooks = self.sdk_configuration.__dict__["_hooks"]
298
+
301
299
  async def do():
302
300
  http_res = None
303
301
  try:
304
- req = self.sdk_configuration.get_hooks().before_request(
305
- BeforeRequestContext(hook_ctx), request
306
- )
302
+ req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
307
303
  logger.debug(
308
304
  "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
309
305
  req.method,
@@ -317,16 +313,14 @@ class BaseSDK:
317
313
 
318
314
  http_res = await client.send(req, stream=stream)
319
315
  except Exception as e:
320
- _, e = self.sdk_configuration.get_hooks().after_error(
321
- AfterErrorContext(hook_ctx), None, e
322
- )
316
+ _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
323
317
  if e is not None:
324
318
  logger.debug("Request Exception", exc_info=True)
325
319
  raise e
326
320
 
327
321
  if http_res is None:
328
322
  logger.debug("Raising no response SDK error")
329
- raise models.APIError("No response received")
323
+ raise models.NoResponseError("No response received")
330
324
 
331
325
  logger.debug(
332
326
  "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -337,7 +331,7 @@ class BaseSDK:
337
331
  )
338
332
 
339
333
  if utils.match_status_codes(error_status_codes, http_res.status_code):
340
- result, err = self.sdk_configuration.get_hooks().after_error(
334
+ result, err = hooks.after_error(
341
335
  AfterErrorContext(hook_ctx), http_res, None
342
336
  )
343
337
  if err is not None:
@@ -347,7 +341,7 @@ class BaseSDK:
347
341
  http_res = result
348
342
  else:
349
343
  logger.debug("Raising unexpected SDK error")
350
- raise models.APIError("Unexpected error occurred")
344
+ raise models.APIError("Unexpected error occurred", http_res)
351
345
 
352
346
  return http_res
353
347
 
@@ -359,8 +353,6 @@ class BaseSDK:
359
353
  http_res = await do()
360
354
 
361
355
  if not utils.match_status_codes(error_status_codes, http_res.status_code):
362
- http_res = self.sdk_configuration.get_hooks().after_success(
363
- AfterSuccessContext(hook_ctx), http_res
364
- )
356
+ http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
365
357
 
366
358
  return http_res