latitudesh-python-sdk 2.0.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 (43) hide show
  1. latitudesh_python_sdk/_version.py +3 -3
  2. latitudesh_python_sdk/apikeys.py +51 -138
  3. latitudesh_python_sdk/basesdk.py +4 -4
  4. latitudesh_python_sdk/billing.py +11 -32
  5. latitudesh_python_sdk/events_sdk.py +9 -34
  6. latitudesh_python_sdk/firewalls_sdk.py +89 -264
  7. latitudesh_python_sdk/ipaddresses_sdk.py +25 -68
  8. latitudesh_python_sdk/models/__init__.py +27 -4
  9. latitudesh_python_sdk/models/apierror.py +30 -14
  10. latitudesh_python_sdk/models/deploy_config.py +11 -6
  11. latitudesh_python_sdk/models/error_object.py +11 -6
  12. latitudesh_python_sdk/models/latitudesherror.py +26 -0
  13. latitudesh_python_sdk/models/no_response_error.py +13 -0
  14. latitudesh_python_sdk/models/region_resource_data.py +4 -4
  15. latitudesh_python_sdk/models/responsevalidationerror.py +25 -0
  16. latitudesh_python_sdk/models/server.py +11 -6
  17. latitudesh_python_sdk/models/server_data.py +6 -3
  18. latitudesh_python_sdk/models/server_region_resource_data.py +40 -0
  19. latitudesh_python_sdk/models/update_serverop.py +1 -3
  20. latitudesh_python_sdk/models/virtual_network.py +11 -6
  21. latitudesh_python_sdk/operatingsystems_sdk.py +11 -32
  22. latitudesh_python_sdk/plans.py +57 -188
  23. latitudesh_python_sdk/privatenetworks.py +87 -262
  24. latitudesh_python_sdk/projects_sdk.py +43 -130
  25. latitudesh_python_sdk/regions_sdk.py +21 -66
  26. latitudesh_python_sdk/roles.py +21 -64
  27. latitudesh_python_sdk/servers_sdk.py +207 -604
  28. latitudesh_python_sdk/sshkeys_sdk.py +85 -304
  29. latitudesh_python_sdk/storage.py +33 -120
  30. latitudesh_python_sdk/tags.py +39 -126
  31. latitudesh_python_sdk/teams_sdk.py +35 -100
  32. latitudesh_python_sdk/teamsmembers.py +31 -96
  33. latitudesh_python_sdk/traffic_sdk.py +25 -68
  34. latitudesh_python_sdk/userdata_sdk.py +79 -298
  35. latitudesh_python_sdk/userprofile.py +31 -100
  36. latitudesh_python_sdk/utils/serializers.py +3 -2
  37. latitudesh_python_sdk/utils/unmarshal_json_response.py +24 -0
  38. latitudesh_python_sdk/virtualmachines.py +35 -122
  39. latitudesh_python_sdk/vpnsessions.py +55 -146
  40. {latitudesh_python_sdk-2.0.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/METADATA +47 -24
  41. {latitudesh_python_sdk-2.0.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/RECORD +43 -38
  42. {latitudesh_python_sdk-2.0.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/LICENSE +0 -0
  43. {latitudesh_python_sdk-2.0.0.dist-info → latitudesh_python_sdk-2.0.1.dist-info}/WHEEL +0 -0
@@ -6,6 +6,7 @@ from latitudesh_python_sdk import models, utils
6
6
  from latitudesh_python_sdk._hooks import HookContext
7
7
  from latitudesh_python_sdk.types import OptionalNullable, UNSET
8
8
  from latitudesh_python_sdk.utils import get_security_from_env
9
+ from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
10
  from typing import Any, Dict, List, Mapping, Optional, Union
10
11
 
11
12
 
@@ -108,30 +109,19 @@ class OperatingSystemsSDK(BaseSDK):
108
109
 
109
110
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
110
111
  return models.GetPlansOperatingSystemResponse(
111
- result=utils.unmarshal_json(
112
- http_res.text, models.GetPlansOperatingSystemResponseBody
112
+ result=unmarshal_json_response(
113
+ models.GetPlansOperatingSystemResponseBody, http_res
113
114
  ),
114
115
  next=next_func,
115
116
  )
116
117
  if utils.match_response(http_res, "4XX", "*"):
117
118
  http_res_text = utils.stream_to_text(http_res)
118
- raise models.APIError(
119
- "API error occurred", http_res.status_code, http_res_text, http_res
120
- )
119
+ raise models.APIError("API error occurred", http_res, http_res_text)
121
120
  if utils.match_response(http_res, "5XX", "*"):
122
121
  http_res_text = utils.stream_to_text(http_res)
123
- raise models.APIError(
124
- "API error occurred", http_res.status_code, http_res_text, http_res
125
- )
122
+ raise models.APIError("API error occurred", http_res, http_res_text)
126
123
 
127
- content_type = http_res.headers.get("Content-Type")
128
- http_res_text = utils.stream_to_text(http_res)
129
- raise models.APIError(
130
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
131
- http_res.status_code,
132
- http_res_text,
133
- http_res,
134
- )
124
+ raise models.APIError("Unexpected response received", http_res)
135
125
 
136
126
  async def list_async(
137
127
  self,
@@ -231,27 +221,16 @@ class OperatingSystemsSDK(BaseSDK):
231
221
 
232
222
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
233
223
  return models.GetPlansOperatingSystemResponse(
234
- result=utils.unmarshal_json(
235
- http_res.text, models.GetPlansOperatingSystemResponseBody
224
+ result=unmarshal_json_response(
225
+ models.GetPlansOperatingSystemResponseBody, http_res
236
226
  ),
237
227
  next=next_func,
238
228
  )
239
229
  if utils.match_response(http_res, "4XX", "*"):
240
230
  http_res_text = await utils.stream_to_text_async(http_res)
241
- raise models.APIError(
242
- "API error occurred", http_res.status_code, http_res_text, http_res
243
- )
231
+ raise models.APIError("API error occurred", http_res, http_res_text)
244
232
  if utils.match_response(http_res, "5XX", "*"):
245
233
  http_res_text = await utils.stream_to_text_async(http_res)
246
- raise models.APIError(
247
- "API error occurred", http_res.status_code, http_res_text, http_res
248
- )
234
+ raise models.APIError("API error occurred", http_res, http_res_text)
249
235
 
250
- content_type = http_res.headers.get("Content-Type")
251
- http_res_text = await utils.stream_to_text_async(http_res)
252
- raise models.APIError(
253
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
254
- http_res.status_code,
255
- http_res_text,
256
- http_res,
257
- )
236
+ raise models.APIError("Unexpected response received", http_res)
@@ -6,6 +6,7 @@ from latitudesh_python_sdk import models, utils
6
6
  from latitudesh_python_sdk._hooks import HookContext
7
7
  from latitudesh_python_sdk.types import OptionalNullable, UNSET
8
8
  from latitudesh_python_sdk.utils import get_security_from_env
9
+ from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
10
  from typing import Any, Dict, List, Mapping, Optional, Union
10
11
 
11
12
 
@@ -105,26 +106,15 @@ class Plans(BaseSDK):
105
106
  )
106
107
 
107
108
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
108
- return utils.unmarshal_json(http_res.text, models.GetPlansResponseBody)
109
+ return unmarshal_json_response(models.GetPlansResponseBody, http_res)
109
110
  if utils.match_response(http_res, "4XX", "*"):
110
111
  http_res_text = utils.stream_to_text(http_res)
111
- raise models.APIError(
112
- "API error occurred", http_res.status_code, http_res_text, http_res
113
- )
112
+ raise models.APIError("API error occurred", http_res, http_res_text)
114
113
  if utils.match_response(http_res, "5XX", "*"):
115
114
  http_res_text = utils.stream_to_text(http_res)
116
- raise models.APIError(
117
- "API error occurred", http_res.status_code, http_res_text, http_res
118
- )
115
+ raise models.APIError("API error occurred", http_res, http_res_text)
119
116
 
120
- content_type = http_res.headers.get("Content-Type")
121
- http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError(
123
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
124
- http_res.status_code,
125
- http_res_text,
126
- http_res,
127
- )
117
+ raise models.APIError("Unexpected response received", http_res)
128
118
 
129
119
  async def list_async(
130
120
  self,
@@ -221,26 +211,15 @@ class Plans(BaseSDK):
221
211
  )
222
212
 
223
213
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
224
- return utils.unmarshal_json(http_res.text, models.GetPlansResponseBody)
214
+ return unmarshal_json_response(models.GetPlansResponseBody, http_res)
225
215
  if utils.match_response(http_res, "4XX", "*"):
226
216
  http_res_text = await utils.stream_to_text_async(http_res)
227
- raise models.APIError(
228
- "API error occurred", http_res.status_code, http_res_text, http_res
229
- )
217
+ raise models.APIError("API error occurred", http_res, http_res_text)
230
218
  if utils.match_response(http_res, "5XX", "*"):
231
219
  http_res_text = await utils.stream_to_text_async(http_res)
232
- raise models.APIError(
233
- "API error occurred", http_res.status_code, http_res_text, http_res
234
- )
220
+ raise models.APIError("API error occurred", http_res, http_res_text)
235
221
 
236
- content_type = http_res.headers.get("Content-Type")
237
- http_res_text = await utils.stream_to_text_async(http_res)
238
- raise models.APIError(
239
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
240
- http_res.status_code,
241
- http_res_text,
242
- http_res,
243
- )
222
+ raise models.APIError("Unexpected response received", http_res)
244
223
 
245
224
  def get(
246
225
  self,
@@ -314,29 +293,18 @@ class Plans(BaseSDK):
314
293
 
315
294
  response_data: Any = None
316
295
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
317
- return utils.unmarshal_json(http_res.text, models.Plan)
296
+ return unmarshal_json_response(models.Plan, http_res)
318
297
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
319
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
320
- raise models.ErrorObject(data=response_data)
298
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
299
+ raise models.ErrorObject(response_data, http_res)
321
300
  if utils.match_response(http_res, "4XX", "*"):
322
301
  http_res_text = utils.stream_to_text(http_res)
323
- raise models.APIError(
324
- "API error occurred", http_res.status_code, http_res_text, http_res
325
- )
302
+ raise models.APIError("API error occurred", http_res, http_res_text)
326
303
  if utils.match_response(http_res, "5XX", "*"):
327
304
  http_res_text = utils.stream_to_text(http_res)
328
- raise models.APIError(
329
- "API error occurred", http_res.status_code, http_res_text, http_res
330
- )
305
+ raise models.APIError("API error occurred", http_res, http_res_text)
331
306
 
332
- content_type = http_res.headers.get("Content-Type")
333
- http_res_text = utils.stream_to_text(http_res)
334
- raise models.APIError(
335
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
336
- http_res.status_code,
337
- http_res_text,
338
- http_res,
339
- )
307
+ raise models.APIError("Unexpected response received", http_res)
340
308
 
341
309
  async def get_async(
342
310
  self,
@@ -410,29 +378,18 @@ class Plans(BaseSDK):
410
378
 
411
379
  response_data: Any = None
412
380
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
413
- return utils.unmarshal_json(http_res.text, models.Plan)
381
+ return unmarshal_json_response(models.Plan, http_res)
414
382
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
415
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
416
- raise models.ErrorObject(data=response_data)
383
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
384
+ raise models.ErrorObject(response_data, http_res)
417
385
  if utils.match_response(http_res, "4XX", "*"):
418
386
  http_res_text = await utils.stream_to_text_async(http_res)
419
- raise models.APIError(
420
- "API error occurred", http_res.status_code, http_res_text, http_res
421
- )
387
+ raise models.APIError("API error occurred", http_res, http_res_text)
422
388
  if utils.match_response(http_res, "5XX", "*"):
423
389
  http_res_text = await utils.stream_to_text_async(http_res)
424
- raise models.APIError(
425
- "API error occurred", http_res.status_code, http_res_text, http_res
426
- )
390
+ raise models.APIError("API error occurred", http_res, http_res_text)
427
391
 
428
- content_type = http_res.headers.get("Content-Type")
429
- http_res_text = await utils.stream_to_text_async(http_res)
430
- raise models.APIError(
431
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
432
- http_res.status_code,
433
- http_res_text,
434
- http_res,
435
- )
392
+ raise models.APIError("Unexpected response received", http_res)
436
393
 
437
394
  def list_bandwidth(
438
395
  self,
@@ -539,28 +496,17 @@ class Plans(BaseSDK):
539
496
 
540
497
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
541
498
  return models.GetBandwidthPlansResponse(
542
- result=utils.unmarshal_json(http_res.text, models.BandwidthPlans),
499
+ result=unmarshal_json_response(models.BandwidthPlans, http_res),
543
500
  next=next_func,
544
501
  )
545
502
  if utils.match_response(http_res, "4XX", "*"):
546
503
  http_res_text = utils.stream_to_text(http_res)
547
- raise models.APIError(
548
- "API error occurred", http_res.status_code, http_res_text, http_res
549
- )
504
+ raise models.APIError("API error occurred", http_res, http_res_text)
550
505
  if utils.match_response(http_res, "5XX", "*"):
551
506
  http_res_text = utils.stream_to_text(http_res)
552
- raise models.APIError(
553
- "API error occurred", http_res.status_code, http_res_text, http_res
554
- )
507
+ raise models.APIError("API error occurred", http_res, http_res_text)
555
508
 
556
- content_type = http_res.headers.get("Content-Type")
557
- http_res_text = utils.stream_to_text(http_res)
558
- raise models.APIError(
559
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
560
- http_res.status_code,
561
- http_res_text,
562
- http_res,
563
- )
509
+ raise models.APIError("Unexpected response received", http_res)
564
510
 
565
511
  async def list_bandwidth_async(
566
512
  self,
@@ -667,28 +613,17 @@ class Plans(BaseSDK):
667
613
 
668
614
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
669
615
  return models.GetBandwidthPlansResponse(
670
- result=utils.unmarshal_json(http_res.text, models.BandwidthPlans),
616
+ result=unmarshal_json_response(models.BandwidthPlans, http_res),
671
617
  next=next_func,
672
618
  )
673
619
  if utils.match_response(http_res, "4XX", "*"):
674
620
  http_res_text = await utils.stream_to_text_async(http_res)
675
- raise models.APIError(
676
- "API error occurred", http_res.status_code, http_res_text, http_res
677
- )
621
+ raise models.APIError("API error occurred", http_res, http_res_text)
678
622
  if utils.match_response(http_res, "5XX", "*"):
679
623
  http_res_text = await utils.stream_to_text_async(http_res)
680
- raise models.APIError(
681
- "API error occurred", http_res.status_code, http_res_text, http_res
682
- )
624
+ raise models.APIError("API error occurred", http_res, http_res_text)
683
625
 
684
- content_type = http_res.headers.get("Content-Type")
685
- http_res_text = await utils.stream_to_text_async(http_res)
686
- raise models.APIError(
687
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
688
- http_res.status_code,
689
- http_res_text,
690
- http_res,
691
- )
626
+ raise models.APIError("Unexpected response received", http_res)
692
627
 
693
628
  def update_bandwidth(
694
629
  self,
@@ -779,29 +714,18 @@ class Plans(BaseSDK):
779
714
 
780
715
  response_data: Any = None
781
716
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
782
- return utils.unmarshal_json(http_res.text, models.BandwidthPackages)
717
+ return unmarshal_json_response(models.BandwidthPackages, http_res)
783
718
  if utils.match_response(http_res, "403", "application/vnd.api+json"):
784
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
785
- raise models.ErrorObject(data=response_data)
719
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
720
+ raise models.ErrorObject(response_data, http_res)
786
721
  if utils.match_response(http_res, "4XX", "*"):
787
722
  http_res_text = utils.stream_to_text(http_res)
788
- raise models.APIError(
789
- "API error occurred", http_res.status_code, http_res_text, http_res
790
- )
723
+ raise models.APIError("API error occurred", http_res, http_res_text)
791
724
  if utils.match_response(http_res, "5XX", "*"):
792
725
  http_res_text = utils.stream_to_text(http_res)
793
- raise models.APIError(
794
- "API error occurred", http_res.status_code, http_res_text, http_res
795
- )
726
+ raise models.APIError("API error occurred", http_res, http_res_text)
796
727
 
797
- content_type = http_res.headers.get("Content-Type")
798
- http_res_text = utils.stream_to_text(http_res)
799
- raise models.APIError(
800
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
801
- http_res.status_code,
802
- http_res_text,
803
- http_res,
804
- )
728
+ raise models.APIError("Unexpected response received", http_res)
805
729
 
806
730
  async def update_bandwidth_async(
807
731
  self,
@@ -892,29 +816,18 @@ class Plans(BaseSDK):
892
816
 
893
817
  response_data: Any = None
894
818
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
895
- return utils.unmarshal_json(http_res.text, models.BandwidthPackages)
819
+ return unmarshal_json_response(models.BandwidthPackages, http_res)
896
820
  if utils.match_response(http_res, "403", "application/vnd.api+json"):
897
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
898
- raise models.ErrorObject(data=response_data)
821
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
822
+ raise models.ErrorObject(response_data, http_res)
899
823
  if utils.match_response(http_res, "4XX", "*"):
900
824
  http_res_text = await utils.stream_to_text_async(http_res)
901
- raise models.APIError(
902
- "API error occurred", http_res.status_code, http_res_text, http_res
903
- )
825
+ raise models.APIError("API error occurred", http_res, http_res_text)
904
826
  if utils.match_response(http_res, "5XX", "*"):
905
827
  http_res_text = await utils.stream_to_text_async(http_res)
906
- raise models.APIError(
907
- "API error occurred", http_res.status_code, http_res_text, http_res
908
- )
828
+ raise models.APIError("API error occurred", http_res, http_res_text)
909
829
 
910
- content_type = http_res.headers.get("Content-Type")
911
- http_res_text = await utils.stream_to_text_async(http_res)
912
- raise models.APIError(
913
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
914
- http_res.status_code,
915
- http_res_text,
916
- http_res,
917
- )
830
+ raise models.APIError("Unexpected response received", http_res)
918
831
 
919
832
  def list_storage(
920
833
  self,
@@ -980,26 +893,15 @@ class Plans(BaseSDK):
980
893
  )
981
894
 
982
895
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
983
- return utils.unmarshal_json(http_res.text, models.StoragePlans)
896
+ return unmarshal_json_response(models.StoragePlans, http_res)
984
897
  if utils.match_response(http_res, "4XX", "*"):
985
898
  http_res_text = utils.stream_to_text(http_res)
986
- raise models.APIError(
987
- "API error occurred", http_res.status_code, http_res_text, http_res
988
- )
899
+ raise models.APIError("API error occurred", http_res, http_res_text)
989
900
  if utils.match_response(http_res, "5XX", "*"):
990
901
  http_res_text = utils.stream_to_text(http_res)
991
- raise models.APIError(
992
- "API error occurred", http_res.status_code, http_res_text, http_res
993
- )
902
+ raise models.APIError("API error occurred", http_res, http_res_text)
994
903
 
995
- content_type = http_res.headers.get("Content-Type")
996
- http_res_text = utils.stream_to_text(http_res)
997
- raise models.APIError(
998
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
999
- http_res.status_code,
1000
- http_res_text,
1001
- http_res,
1002
- )
904
+ raise models.APIError("Unexpected response received", http_res)
1003
905
 
1004
906
  async def list_storage_async(
1005
907
  self,
@@ -1065,26 +967,15 @@ class Plans(BaseSDK):
1065
967
  )
1066
968
 
1067
969
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
1068
- return utils.unmarshal_json(http_res.text, models.StoragePlans)
970
+ return unmarshal_json_response(models.StoragePlans, http_res)
1069
971
  if utils.match_response(http_res, "4XX", "*"):
1070
972
  http_res_text = await utils.stream_to_text_async(http_res)
1071
- raise models.APIError(
1072
- "API error occurred", http_res.status_code, http_res_text, http_res
1073
- )
973
+ raise models.APIError("API error occurred", http_res, http_res_text)
1074
974
  if utils.match_response(http_res, "5XX", "*"):
1075
975
  http_res_text = await utils.stream_to_text_async(http_res)
1076
- raise models.APIError(
1077
- "API error occurred", http_res.status_code, http_res_text, http_res
1078
- )
976
+ raise models.APIError("API error occurred", http_res, http_res_text)
1079
977
 
1080
- content_type = http_res.headers.get("Content-Type")
1081
- http_res_text = await utils.stream_to_text_async(http_res)
1082
- raise models.APIError(
1083
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1084
- http_res.status_code,
1085
- http_res_text,
1086
- http_res,
1087
- )
978
+ raise models.APIError("Unexpected response received", http_res)
1088
979
 
1089
980
  def list_vm_plans(
1090
981
  self,
@@ -1150,26 +1041,15 @@ class Plans(BaseSDK):
1150
1041
  )
1151
1042
 
1152
1043
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
1153
- return utils.unmarshal_json(http_res.text, models.VirtualMachinePlans)
1044
+ return unmarshal_json_response(models.VirtualMachinePlans, http_res)
1154
1045
  if utils.match_response(http_res, "4XX", "*"):
1155
1046
  http_res_text = utils.stream_to_text(http_res)
1156
- raise models.APIError(
1157
- "API error occurred", http_res.status_code, http_res_text, http_res
1158
- )
1047
+ raise models.APIError("API error occurred", http_res, http_res_text)
1159
1048
  if utils.match_response(http_res, "5XX", "*"):
1160
1049
  http_res_text = utils.stream_to_text(http_res)
1161
- raise models.APIError(
1162
- "API error occurred", http_res.status_code, http_res_text, http_res
1163
- )
1050
+ raise models.APIError("API error occurred", http_res, http_res_text)
1164
1051
 
1165
- content_type = http_res.headers.get("Content-Type")
1166
- http_res_text = utils.stream_to_text(http_res)
1167
- raise models.APIError(
1168
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1169
- http_res.status_code,
1170
- http_res_text,
1171
- http_res,
1172
- )
1052
+ raise models.APIError("Unexpected response received", http_res)
1173
1053
 
1174
1054
  async def list_vm_plans_async(
1175
1055
  self,
@@ -1235,23 +1115,12 @@ class Plans(BaseSDK):
1235
1115
  )
1236
1116
 
1237
1117
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
1238
- return utils.unmarshal_json(http_res.text, models.VirtualMachinePlans)
1118
+ return unmarshal_json_response(models.VirtualMachinePlans, http_res)
1239
1119
  if utils.match_response(http_res, "4XX", "*"):
1240
1120
  http_res_text = await utils.stream_to_text_async(http_res)
1241
- raise models.APIError(
1242
- "API error occurred", http_res.status_code, http_res_text, http_res
1243
- )
1121
+ raise models.APIError("API error occurred", http_res, http_res_text)
1244
1122
  if utils.match_response(http_res, "5XX", "*"):
1245
1123
  http_res_text = await utils.stream_to_text_async(http_res)
1246
- raise models.APIError(
1247
- "API error occurred", http_res.status_code, http_res_text, http_res
1248
- )
1124
+ raise models.APIError("API error occurred", http_res, http_res_text)
1249
1125
 
1250
- content_type = http_res.headers.get("Content-Type")
1251
- http_res_text = await utils.stream_to_text_async(http_res)
1252
- raise models.APIError(
1253
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1254
- http_res.status_code,
1255
- http_res_text,
1256
- http_res,
1257
- )
1126
+ raise models.APIError("Unexpected response received", http_res)