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
@@ -4,9 +4,10 @@ from .basesdk import BaseSDK
4
4
  from jsonpath import JSONPath
5
5
  from latitudesh_python_sdk import models, utils
6
6
  from latitudesh_python_sdk._hooks import HookContext
7
- from latitudesh_python_sdk.types import BaseModel, OptionalNullable, UNSET
7
+ from latitudesh_python_sdk.types import OptionalNullable, UNSET
8
8
  from latitudesh_python_sdk.utils import get_security_from_env
9
- from typing import Any, Dict, List, Mapping, Optional, Union, cast
9
+ from latitudesh_python_sdk.utils.unmarshal_json_response import unmarshal_json_response
10
+ from typing import Any, Dict, List, Mapping, Optional, Union
10
11
 
11
12
 
12
13
  class ProjectsSDK(BaseSDK):
@@ -94,6 +95,7 @@ class ProjectsSDK(BaseSDK):
94
95
 
95
96
  http_res = self.do_request(
96
97
  hook_ctx=HookContext(
98
+ config=self.sdk_configuration,
97
99
  base_url=base_url or "",
98
100
  operation_id="get-projects",
99
101
  oauth2_scopes=[],
@@ -135,28 +137,17 @@ class ProjectsSDK(BaseSDK):
135
137
 
136
138
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
137
139
  return models.GetProjectsResponse(
138
- result=utils.unmarshal_json(http_res.text, models.Projects),
140
+ result=unmarshal_json_response(models.Projects, http_res),
139
141
  next=next_func,
140
142
  )
141
143
  if utils.match_response(http_res, "4XX", "*"):
142
144
  http_res_text = utils.stream_to_text(http_res)
143
- raise models.APIError(
144
- "API error occurred", http_res.status_code, http_res_text, http_res
145
- )
145
+ raise models.APIError("API error occurred", http_res, http_res_text)
146
146
  if utils.match_response(http_res, "5XX", "*"):
147
147
  http_res_text = utils.stream_to_text(http_res)
148
- raise models.APIError(
149
- "API error occurred", http_res.status_code, http_res_text, http_res
150
- )
148
+ raise models.APIError("API error occurred", http_res, http_res_text)
151
149
 
152
- content_type = http_res.headers.get("Content-Type")
153
- http_res_text = utils.stream_to_text(http_res)
154
- raise models.APIError(
155
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
156
- http_res.status_code,
157
- http_res_text,
158
- http_res,
159
- )
150
+ raise models.APIError("Unexpected response received", http_res)
160
151
 
161
152
  async def list_async(
162
153
  self,
@@ -242,6 +233,7 @@ class ProjectsSDK(BaseSDK):
242
233
 
243
234
  http_res = await self.do_request_async(
244
235
  hook_ctx=HookContext(
236
+ config=self.sdk_configuration,
245
237
  base_url=base_url or "",
246
238
  operation_id="get-projects",
247
239
  oauth2_scopes=[],
@@ -283,36 +275,27 @@ class ProjectsSDK(BaseSDK):
283
275
 
284
276
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
285
277
  return models.GetProjectsResponse(
286
- result=utils.unmarshal_json(http_res.text, models.Projects),
278
+ result=unmarshal_json_response(models.Projects, http_res),
287
279
  next=next_func,
288
280
  )
289
281
  if utils.match_response(http_res, "4XX", "*"):
290
282
  http_res_text = await utils.stream_to_text_async(http_res)
291
- raise models.APIError(
292
- "API error occurred", http_res.status_code, http_res_text, http_res
293
- )
283
+ raise models.APIError("API error occurred", http_res, http_res_text)
294
284
  if utils.match_response(http_res, "5XX", "*"):
295
285
  http_res_text = await utils.stream_to_text_async(http_res)
296
- raise models.APIError(
297
- "API error occurred", http_res.status_code, http_res_text, http_res
298
- )
286
+ raise models.APIError("API error occurred", http_res, http_res_text)
299
287
 
300
- content_type = http_res.headers.get("Content-Type")
301
- http_res_text = await utils.stream_to_text_async(http_res)
302
- raise models.APIError(
303
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
304
- http_res.status_code,
305
- http_res_text,
306
- http_res,
307
- )
288
+ raise models.APIError("Unexpected response received", http_res)
308
289
 
309
290
  def create(
310
291
  self,
311
292
  *,
312
- request: Union[
313
- models.CreateProjectProjectsRequestBody,
314
- models.CreateProjectProjectsRequestBodyTypedDict,
315
- ] = models.CreateProjectProjectsRequestBody(),
293
+ data: Optional[
294
+ Union[
295
+ models.CreateProjectProjectsData,
296
+ models.CreateProjectProjectsDataTypedDict,
297
+ ]
298
+ ] = None,
316
299
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
317
300
  server_url: Optional[str] = None,
318
301
  timeout_ms: Optional[int] = None,
@@ -320,7 +303,7 @@ class ProjectsSDK(BaseSDK):
320
303
  ) -> models.CreateProjectResponseBody:
321
304
  r"""Create a Project
322
305
 
323
- :param request: The request object to send.
306
+ :param data:
324
307
  :param retries: Override the default retry configuration for this method
325
308
  :param server_url: Override the default server URL for this method
326
309
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -336,9 +319,11 @@ class ProjectsSDK(BaseSDK):
336
319
  else:
337
320
  base_url = self._get_url(base_url, url_variables)
338
321
 
339
- if not isinstance(request, BaseModel):
340
- request = utils.unmarshal(request, models.CreateProjectProjectsRequestBody)
341
- request = cast(models.CreateProjectProjectsRequestBody, request)
322
+ request = models.CreateProjectProjectsRequestBody(
323
+ data=utils.get_pydantic_model(
324
+ data, Optional[models.CreateProjectProjectsData]
325
+ ),
326
+ )
342
327
 
343
328
  req = self._build_request(
344
329
  method="POST",
@@ -354,11 +339,7 @@ class ProjectsSDK(BaseSDK):
354
339
  http_headers=http_headers,
355
340
  security=self.sdk_configuration.security,
356
341
  get_serialized_body=lambda: utils.serialize_request_body(
357
- request,
358
- False,
359
- True,
360
- "json",
361
- Optional[models.CreateProjectProjectsRequestBody],
342
+ request, False, False, "json", models.CreateProjectProjectsRequestBody
362
343
  ),
363
344
  timeout_ms=timeout_ms,
364
345
  )
@@ -373,6 +354,7 @@ class ProjectsSDK(BaseSDK):
373
354
 
374
355
  http_res = self.do_request(
375
356
  hook_ctx=HookContext(
357
+ config=self.sdk_configuration,
376
358
  base_url=base_url or "",
377
359
  operation_id="create-project",
378
360
  oauth2_scopes=[],
@@ -387,39 +369,30 @@ class ProjectsSDK(BaseSDK):
387
369
 
388
370
  response_data: Any = None
389
371
  if utils.match_response(http_res, "201", "application/vnd.api+json"):
390
- return utils.unmarshal_json(http_res.text, models.CreateProjectResponseBody)
372
+ return unmarshal_json_response(models.CreateProjectResponseBody, http_res)
391
373
  if utils.match_response(
392
374
  http_res, ["400", "403", "422"], "application/vnd.api+json"
393
375
  ):
394
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
395
- raise models.ErrorObject(data=response_data)
376
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
377
+ raise models.ErrorObject(response_data, http_res)
396
378
  if utils.match_response(http_res, "4XX", "*"):
397
379
  http_res_text = utils.stream_to_text(http_res)
398
- raise models.APIError(
399
- "API error occurred", http_res.status_code, http_res_text, http_res
400
- )
380
+ raise models.APIError("API error occurred", http_res, http_res_text)
401
381
  if utils.match_response(http_res, "5XX", "*"):
402
382
  http_res_text = utils.stream_to_text(http_res)
403
- raise models.APIError(
404
- "API error occurred", http_res.status_code, http_res_text, http_res
405
- )
383
+ raise models.APIError("API error occurred", http_res, http_res_text)
406
384
 
407
- content_type = http_res.headers.get("Content-Type")
408
- http_res_text = utils.stream_to_text(http_res)
409
- raise models.APIError(
410
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
411
- http_res.status_code,
412
- http_res_text,
413
- http_res,
414
- )
385
+ raise models.APIError("Unexpected response received", http_res)
415
386
 
416
387
  async def create_async(
417
388
  self,
418
389
  *,
419
- request: Union[
420
- models.CreateProjectProjectsRequestBody,
421
- models.CreateProjectProjectsRequestBodyTypedDict,
422
- ] = models.CreateProjectProjectsRequestBody(),
390
+ data: Optional[
391
+ Union[
392
+ models.CreateProjectProjectsData,
393
+ models.CreateProjectProjectsDataTypedDict,
394
+ ]
395
+ ] = None,
423
396
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
424
397
  server_url: Optional[str] = None,
425
398
  timeout_ms: Optional[int] = None,
@@ -427,7 +400,7 @@ class ProjectsSDK(BaseSDK):
427
400
  ) -> models.CreateProjectResponseBody:
428
401
  r"""Create a Project
429
402
 
430
- :param request: The request object to send.
403
+ :param data:
431
404
  :param retries: Override the default retry configuration for this method
432
405
  :param server_url: Override the default server URL for this method
433
406
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -443,9 +416,11 @@ class ProjectsSDK(BaseSDK):
443
416
  else:
444
417
  base_url = self._get_url(base_url, url_variables)
445
418
 
446
- if not isinstance(request, BaseModel):
447
- request = utils.unmarshal(request, models.CreateProjectProjectsRequestBody)
448
- request = cast(models.CreateProjectProjectsRequestBody, request)
419
+ request = models.CreateProjectProjectsRequestBody(
420
+ data=utils.get_pydantic_model(
421
+ data, Optional[models.CreateProjectProjectsData]
422
+ ),
423
+ )
449
424
 
450
425
  req = self._build_request_async(
451
426
  method="POST",
@@ -461,11 +436,7 @@ class ProjectsSDK(BaseSDK):
461
436
  http_headers=http_headers,
462
437
  security=self.sdk_configuration.security,
463
438
  get_serialized_body=lambda: utils.serialize_request_body(
464
- request,
465
- False,
466
- True,
467
- "json",
468
- Optional[models.CreateProjectProjectsRequestBody],
439
+ request, False, False, "json", models.CreateProjectProjectsRequestBody
469
440
  ),
470
441
  timeout_ms=timeout_ms,
471
442
  )
@@ -480,6 +451,7 @@ class ProjectsSDK(BaseSDK):
480
451
 
481
452
  http_res = await self.do_request_async(
482
453
  hook_ctx=HookContext(
454
+ config=self.sdk_configuration,
483
455
  base_url=base_url or "",
484
456
  operation_id="create-project",
485
457
  oauth2_scopes=[],
@@ -494,31 +466,20 @@ class ProjectsSDK(BaseSDK):
494
466
 
495
467
  response_data: Any = None
496
468
  if utils.match_response(http_res, "201", "application/vnd.api+json"):
497
- return utils.unmarshal_json(http_res.text, models.CreateProjectResponseBody)
469
+ return unmarshal_json_response(models.CreateProjectResponseBody, http_res)
498
470
  if utils.match_response(
499
471
  http_res, ["400", "403", "422"], "application/vnd.api+json"
500
472
  ):
501
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
502
- raise models.ErrorObject(data=response_data)
473
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
474
+ raise models.ErrorObject(response_data, http_res)
503
475
  if utils.match_response(http_res, "4XX", "*"):
504
476
  http_res_text = await utils.stream_to_text_async(http_res)
505
- raise models.APIError(
506
- "API error occurred", http_res.status_code, http_res_text, http_res
507
- )
477
+ raise models.APIError("API error occurred", http_res, http_res_text)
508
478
  if utils.match_response(http_res, "5XX", "*"):
509
479
  http_res_text = await utils.stream_to_text_async(http_res)
510
- raise models.APIError(
511
- "API error occurred", http_res.status_code, http_res_text, http_res
512
- )
480
+ raise models.APIError("API error occurred", http_res, http_res_text)
513
481
 
514
- content_type = http_res.headers.get("Content-Type")
515
- http_res_text = await utils.stream_to_text_async(http_res)
516
- raise models.APIError(
517
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
518
- http_res.status_code,
519
- http_res_text,
520
- http_res,
521
- )
482
+ raise models.APIError("Unexpected response received", http_res)
522
483
 
523
484
  def update(
524
485
  self,
@@ -591,6 +552,7 @@ class ProjectsSDK(BaseSDK):
591
552
 
592
553
  http_res = self.do_request(
593
554
  hook_ctx=HookContext(
555
+ config=self.sdk_configuration,
594
556
  base_url=base_url or "",
595
557
  operation_id="update-project",
596
558
  oauth2_scopes=[],
@@ -605,31 +567,20 @@ class ProjectsSDK(BaseSDK):
605
567
 
606
568
  response_data: Any = None
607
569
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
608
- return utils.unmarshal_json(http_res.text, models.UpdateProjectResponseBody)
570
+ return unmarshal_json_response(models.UpdateProjectResponseBody, http_res)
609
571
  if utils.match_response(
610
572
  http_res, ["403", "404", "422"], "application/vnd.api+json"
611
573
  ):
612
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
613
- raise models.ErrorObject(data=response_data)
574
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
575
+ raise models.ErrorObject(response_data, http_res)
614
576
  if utils.match_response(http_res, "4XX", "*"):
615
577
  http_res_text = utils.stream_to_text(http_res)
616
- raise models.APIError(
617
- "API error occurred", http_res.status_code, http_res_text, http_res
618
- )
578
+ raise models.APIError("API error occurred", http_res, http_res_text)
619
579
  if utils.match_response(http_res, "5XX", "*"):
620
580
  http_res_text = utils.stream_to_text(http_res)
621
- raise models.APIError(
622
- "API error occurred", http_res.status_code, http_res_text, http_res
623
- )
581
+ raise models.APIError("API error occurred", http_res, http_res_text)
624
582
 
625
- content_type = http_res.headers.get("Content-Type")
626
- http_res_text = utils.stream_to_text(http_res)
627
- raise models.APIError(
628
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
629
- http_res.status_code,
630
- http_res_text,
631
- http_res,
632
- )
583
+ raise models.APIError("Unexpected response received", http_res)
633
584
 
634
585
  async def update_async(
635
586
  self,
@@ -702,6 +653,7 @@ class ProjectsSDK(BaseSDK):
702
653
 
703
654
  http_res = await self.do_request_async(
704
655
  hook_ctx=HookContext(
656
+ config=self.sdk_configuration,
705
657
  base_url=base_url or "",
706
658
  operation_id="update-project",
707
659
  oauth2_scopes=[],
@@ -716,31 +668,20 @@ class ProjectsSDK(BaseSDK):
716
668
 
717
669
  response_data: Any = None
718
670
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
719
- return utils.unmarshal_json(http_res.text, models.UpdateProjectResponseBody)
671
+ return unmarshal_json_response(models.UpdateProjectResponseBody, http_res)
720
672
  if utils.match_response(
721
673
  http_res, ["403", "404", "422"], "application/vnd.api+json"
722
674
  ):
723
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
724
- raise models.ErrorObject(data=response_data)
675
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
676
+ raise models.ErrorObject(response_data, http_res)
725
677
  if utils.match_response(http_res, "4XX", "*"):
726
678
  http_res_text = await utils.stream_to_text_async(http_res)
727
- raise models.APIError(
728
- "API error occurred", http_res.status_code, http_res_text, http_res
729
- )
679
+ raise models.APIError("API error occurred", http_res, http_res_text)
730
680
  if utils.match_response(http_res, "5XX", "*"):
731
681
  http_res_text = await utils.stream_to_text_async(http_res)
732
- raise models.APIError(
733
- "API error occurred", http_res.status_code, http_res_text, http_res
734
- )
682
+ raise models.APIError("API error occurred", http_res, http_res_text)
735
683
 
736
- content_type = http_res.headers.get("Content-Type")
737
- http_res_text = await utils.stream_to_text_async(http_res)
738
- raise models.APIError(
739
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
740
- http_res.status_code,
741
- http_res_text,
742
- http_res,
743
- )
684
+ raise models.APIError("Unexpected response received", http_res)
744
685
 
745
686
  def delete(
746
687
  self,
@@ -799,6 +740,7 @@ class ProjectsSDK(BaseSDK):
799
740
 
800
741
  http_res = self.do_request(
801
742
  hook_ctx=HookContext(
743
+ config=self.sdk_configuration,
802
744
  base_url=base_url or "",
803
745
  operation_id="delete-project",
804
746
  oauth2_scopes=[],
@@ -817,27 +759,16 @@ class ProjectsSDK(BaseSDK):
817
759
  if utils.match_response(
818
760
  http_res, ["403", "404", "422"], "application/vnd.api+json"
819
761
  ):
820
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
821
- raise models.ErrorObject(data=response_data)
762
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
763
+ raise models.ErrorObject(response_data, http_res)
822
764
  if utils.match_response(http_res, "4XX", "*"):
823
765
  http_res_text = utils.stream_to_text(http_res)
824
- raise models.APIError(
825
- "API error occurred", http_res.status_code, http_res_text, http_res
826
- )
766
+ raise models.APIError("API error occurred", http_res, http_res_text)
827
767
  if utils.match_response(http_res, "5XX", "*"):
828
768
  http_res_text = utils.stream_to_text(http_res)
829
- raise models.APIError(
830
- "API error occurred", http_res.status_code, http_res_text, http_res
831
- )
769
+ raise models.APIError("API error occurred", http_res, http_res_text)
832
770
 
833
- content_type = http_res.headers.get("Content-Type")
834
- http_res_text = utils.stream_to_text(http_res)
835
- raise models.APIError(
836
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
837
- http_res.status_code,
838
- http_res_text,
839
- http_res,
840
- )
771
+ raise models.APIError("Unexpected response received", http_res)
841
772
 
842
773
  async def delete_async(
843
774
  self,
@@ -896,6 +827,7 @@ class ProjectsSDK(BaseSDK):
896
827
 
897
828
  http_res = await self.do_request_async(
898
829
  hook_ctx=HookContext(
830
+ config=self.sdk_configuration,
899
831
  base_url=base_url or "",
900
832
  operation_id="delete-project",
901
833
  oauth2_scopes=[],
@@ -914,24 +846,13 @@ class ProjectsSDK(BaseSDK):
914
846
  if utils.match_response(
915
847
  http_res, ["403", "404", "422"], "application/vnd.api+json"
916
848
  ):
917
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
918
- raise models.ErrorObject(data=response_data)
849
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
850
+ raise models.ErrorObject(response_data, http_res)
919
851
  if utils.match_response(http_res, "4XX", "*"):
920
852
  http_res_text = await utils.stream_to_text_async(http_res)
921
- raise models.APIError(
922
- "API error occurred", http_res.status_code, http_res_text, http_res
923
- )
853
+ raise models.APIError("API error occurred", http_res, http_res_text)
924
854
  if utils.match_response(http_res, "5XX", "*"):
925
855
  http_res_text = await utils.stream_to_text_async(http_res)
926
- raise models.APIError(
927
- "API error occurred", http_res.status_code, http_res_text, http_res
928
- )
856
+ raise models.APIError("API error occurred", http_res, http_res_text)
929
857
 
930
- content_type = http_res.headers.get("Content-Type")
931
- http_res_text = await utils.stream_to_text_async(http_res)
932
- raise models.APIError(
933
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
934
- http_res.status_code,
935
- http_res_text,
936
- http_res,
937
- )
858
+ 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
 
@@ -74,6 +75,7 @@ class RegionsSDK(BaseSDK):
74
75
 
75
76
  http_res = self.do_request(
76
77
  hook_ctx=HookContext(
78
+ config=self.sdk_configuration,
77
79
  base_url=base_url or "",
78
80
  operation_id="get-regions",
79
81
  oauth2_scopes=[],
@@ -108,28 +110,16 @@ class RegionsSDK(BaseSDK):
108
110
 
109
111
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
110
112
  return models.GetRegionsResponse(
111
- result=utils.unmarshal_json(http_res.text, models.Regions),
112
- next=next_func,
113
+ result=unmarshal_json_response(models.Regions, http_res), next=next_func
113
114
  )
114
115
  if utils.match_response(http_res, "4XX", "*"):
115
116
  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
- )
117
+ raise models.APIError("API error occurred", http_res, http_res_text)
119
118
  if utils.match_response(http_res, "5XX", "*"):
120
119
  http_res_text = utils.stream_to_text(http_res)
121
- raise models.APIError(
122
- "API error occurred", http_res.status_code, http_res_text, http_res
123
- )
120
+ raise models.APIError("API error occurred", http_res, http_res_text)
124
121
 
125
- content_type = http_res.headers.get("Content-Type")
126
- http_res_text = utils.stream_to_text(http_res)
127
- raise models.APIError(
128
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
129
- http_res.status_code,
130
- http_res_text,
131
- http_res,
132
- )
122
+ raise models.APIError("Unexpected response received", http_res)
133
123
 
134
124
  async def list_async(
135
125
  self,
@@ -195,6 +185,7 @@ class RegionsSDK(BaseSDK):
195
185
 
196
186
  http_res = await self.do_request_async(
197
187
  hook_ctx=HookContext(
188
+ config=self.sdk_configuration,
198
189
  base_url=base_url or "",
199
190
  operation_id="get-regions",
200
191
  oauth2_scopes=[],
@@ -229,28 +220,16 @@ class RegionsSDK(BaseSDK):
229
220
 
230
221
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
231
222
  return models.GetRegionsResponse(
232
- result=utils.unmarshal_json(http_res.text, models.Regions),
233
- next=next_func,
223
+ result=unmarshal_json_response(models.Regions, http_res), next=next_func
234
224
  )
235
225
  if utils.match_response(http_res, "4XX", "*"):
236
226
  http_res_text = await utils.stream_to_text_async(http_res)
237
- raise models.APIError(
238
- "API error occurred", http_res.status_code, http_res_text, http_res
239
- )
227
+ raise models.APIError("API error occurred", http_res, http_res_text)
240
228
  if utils.match_response(http_res, "5XX", "*"):
241
229
  http_res_text = await utils.stream_to_text_async(http_res)
242
- raise models.APIError(
243
- "API error occurred", http_res.status_code, http_res_text, http_res
244
- )
230
+ raise models.APIError("API error occurred", http_res, http_res_text)
245
231
 
246
- content_type = http_res.headers.get("Content-Type")
247
- http_res_text = await utils.stream_to_text_async(http_res)
248
- raise models.APIError(
249
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
250
- http_res.status_code,
251
- http_res_text,
252
- http_res,
253
- )
232
+ raise models.APIError("Unexpected response received", http_res)
254
233
 
255
234
  def get(
256
235
  self,
@@ -309,6 +288,7 @@ class RegionsSDK(BaseSDK):
309
288
 
310
289
  http_res = self.do_request(
311
290
  hook_ctx=HookContext(
291
+ config=self.sdk_configuration,
312
292
  base_url=base_url or "",
313
293
  operation_id="get-region",
314
294
  oauth2_scopes=[],
@@ -323,29 +303,18 @@ class RegionsSDK(BaseSDK):
323
303
 
324
304
  response_data: Any = None
325
305
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
326
- return utils.unmarshal_json(http_res.text, models.Region)
306
+ return unmarshal_json_response(models.Region, http_res)
327
307
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
328
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
329
- raise models.ErrorObject(data=response_data)
308
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
309
+ raise models.ErrorObject(response_data, http_res)
330
310
  if utils.match_response(http_res, "4XX", "*"):
331
311
  http_res_text = utils.stream_to_text(http_res)
332
- raise models.APIError(
333
- "API error occurred", http_res.status_code, http_res_text, http_res
334
- )
312
+ raise models.APIError("API error occurred", http_res, http_res_text)
335
313
  if utils.match_response(http_res, "5XX", "*"):
336
314
  http_res_text = utils.stream_to_text(http_res)
337
- raise models.APIError(
338
- "API error occurred", http_res.status_code, http_res_text, http_res
339
- )
315
+ raise models.APIError("API error occurred", http_res, http_res_text)
340
316
 
341
- content_type = http_res.headers.get("Content-Type")
342
- http_res_text = utils.stream_to_text(http_res)
343
- raise models.APIError(
344
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
345
- http_res.status_code,
346
- http_res_text,
347
- http_res,
348
- )
317
+ raise models.APIError("Unexpected response received", http_res)
349
318
 
350
319
  async def get_async(
351
320
  self,
@@ -404,6 +373,7 @@ class RegionsSDK(BaseSDK):
404
373
 
405
374
  http_res = await self.do_request_async(
406
375
  hook_ctx=HookContext(
376
+ config=self.sdk_configuration,
407
377
  base_url=base_url or "",
408
378
  operation_id="get-region",
409
379
  oauth2_scopes=[],
@@ -418,26 +388,15 @@ class RegionsSDK(BaseSDK):
418
388
 
419
389
  response_data: Any = None
420
390
  if utils.match_response(http_res, "200", "application/vnd.api+json"):
421
- return utils.unmarshal_json(http_res.text, models.Region)
391
+ return unmarshal_json_response(models.Region, http_res)
422
392
  if utils.match_response(http_res, "404", "application/vnd.api+json"):
423
- response_data = utils.unmarshal_json(http_res.text, models.ErrorObjectData)
424
- raise models.ErrorObject(data=response_data)
393
+ response_data = unmarshal_json_response(models.ErrorObjectData, http_res)
394
+ raise models.ErrorObject(response_data, http_res)
425
395
  if utils.match_response(http_res, "4XX", "*"):
426
396
  http_res_text = await utils.stream_to_text_async(http_res)
427
- raise models.APIError(
428
- "API error occurred", http_res.status_code, http_res_text, http_res
429
- )
397
+ raise models.APIError("API error occurred", http_res, http_res_text)
430
398
  if utils.match_response(http_res, "5XX", "*"):
431
399
  http_res_text = await utils.stream_to_text_async(http_res)
432
- raise models.APIError(
433
- "API error occurred", http_res.status_code, http_res_text, http_res
434
- )
400
+ raise models.APIError("API error occurred", http_res, http_res_text)
435
401
 
436
- content_type = http_res.headers.get("Content-Type")
437
- http_res_text = await utils.stream_to_text_async(http_res)
438
- raise models.APIError(
439
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
440
- http_res.status_code,
441
- http_res_text,
442
- http_res,
443
- )
402
+ raise models.APIError("Unexpected response received", http_res)