syllable-sdk 0.35.32__py3-none-any.whl → 0.35.33__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.
Files changed (51) hide show
  1. syllable_sdk/__init__.py +0 -1
  2. syllable_sdk/_version.py +3 -3
  3. syllable_sdk/agents.py +83 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +131 -329
  6. syllable_sdk/campaigns.py +73 -183
  7. syllable_sdk/channels.py +29 -73
  8. syllable_sdk/conversations.py +19 -37
  9. syllable_sdk/custom_messages.py +73 -183
  10. syllable_sdk/dashboards.py +67 -195
  11. syllable_sdk/data_sources.py +85 -183
  12. syllable_sdk/errors/__init__.py +55 -0
  13. syllable_sdk/errors/apierror.py +38 -0
  14. syllable_sdk/errors/httpvalidationerror.py +26 -0
  15. syllable_sdk/errors/no_response_error.py +13 -0
  16. syllable_sdk/errors/responsevalidationerror.py +25 -0
  17. syllable_sdk/errors/syllablesdkerror.py +26 -0
  18. syllable_sdk/events.py +15 -37
  19. syllable_sdk/folders.py +121 -293
  20. syllable_sdk/full_summary.py +19 -37
  21. syllable_sdk/incidents.py +83 -215
  22. syllable_sdk/insights_sdk.py +17 -39
  23. syllable_sdk/insights_tools.py +97 -251
  24. syllable_sdk/language_groups.py +85 -215
  25. syllable_sdk/latency.py +19 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +53 -111
  28. syllable_sdk/organizations.py +51 -139
  29. syllable_sdk/permissions.py +11 -33
  30. syllable_sdk/prompts.py +95 -249
  31. syllable_sdk/roles.py +75 -181
  32. syllable_sdk/services.py +73 -183
  33. syllable_sdk/session_debug.py +43 -109
  34. syllable_sdk/session_labels.py +47 -109
  35. syllable_sdk/sessions.py +59 -141
  36. syllable_sdk/takeouts.py +35 -99
  37. syllable_sdk/targets.py +75 -185
  38. syllable_sdk/test.py +15 -37
  39. syllable_sdk/tools.py +75 -181
  40. syllable_sdk/transcript.py +17 -39
  41. syllable_sdk/twilio.py +43 -109
  42. syllable_sdk/users.py +97 -247
  43. syllable_sdk/utils/__init__.py +3 -0
  44. syllable_sdk/utils/serializers.py +21 -3
  45. syllable_sdk/v1.py +97 -247
  46. syllable_sdk/workflows.py +115 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
  49. syllable_sdk/models/apierror.py +0 -22
  50. syllable_sdk/models/httpvalidationerror.py +0 -21
  51. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -81,31 +81,22 @@ class FullSummary(BaseSDK):
81
81
 
82
82
  response_data: Any = None
83
83
  if utils.match_response(http_res, "200", "application/json"):
84
- return utils.unmarshal_json(http_res.text, models.SessionSummaryResponse)
84
+ return utils.unmarshal_json_response(
85
+ models.SessionSummaryResponse, http_res
86
+ )
85
87
  if utils.match_response(http_res, "422", "application/json"):
86
- response_data = utils.unmarshal_json(
87
- http_res.text, models.HTTPValidationErrorData
88
+ response_data = utils.unmarshal_json_response(
89
+ errors.HTTPValidationErrorData, http_res
88
90
  )
89
- raise models.HTTPValidationError(data=response_data)
91
+ raise errors.HTTPValidationError(response_data, http_res)
90
92
  if utils.match_response(http_res, "4XX", "*"):
91
93
  http_res_text = utils.stream_to_text(http_res)
92
- raise models.APIError(
93
- "API error occurred", http_res.status_code, http_res_text, http_res
94
- )
94
+ raise errors.APIError("API error occurred", http_res, http_res_text)
95
95
  if utils.match_response(http_res, "5XX", "*"):
96
96
  http_res_text = utils.stream_to_text(http_res)
97
- raise models.APIError(
98
- "API error occurred", http_res.status_code, http_res_text, http_res
99
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
100
98
 
101
- content_type = http_res.headers.get("Content-Type")
102
- http_res_text = utils.stream_to_text(http_res)
103
- raise models.APIError(
104
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
105
- http_res.status_code,
106
- http_res_text,
107
- http_res,
108
- )
99
+ raise errors.APIError("Unexpected response received", http_res)
109
100
 
110
101
  async def get_by_id_async(
111
102
  self,
@@ -179,28 +170,19 @@ class FullSummary(BaseSDK):
179
170
 
180
171
  response_data: Any = None
181
172
  if utils.match_response(http_res, "200", "application/json"):
182
- return utils.unmarshal_json(http_res.text, models.SessionSummaryResponse)
173
+ return utils.unmarshal_json_response(
174
+ models.SessionSummaryResponse, http_res
175
+ )
183
176
  if utils.match_response(http_res, "422", "application/json"):
184
- response_data = utils.unmarshal_json(
185
- http_res.text, models.HTTPValidationErrorData
177
+ response_data = utils.unmarshal_json_response(
178
+ errors.HTTPValidationErrorData, http_res
186
179
  )
187
- raise models.HTTPValidationError(data=response_data)
180
+ raise errors.HTTPValidationError(response_data, http_res)
188
181
  if utils.match_response(http_res, "4XX", "*"):
189
182
  http_res_text = await utils.stream_to_text_async(http_res)
190
- raise models.APIError(
191
- "API error occurred", http_res.status_code, http_res_text, http_res
192
- )
183
+ raise errors.APIError("API error occurred", http_res, http_res_text)
193
184
  if utils.match_response(http_res, "5XX", "*"):
194
185
  http_res_text = await utils.stream_to_text_async(http_res)
195
- raise models.APIError(
196
- "API error occurred", http_res.status_code, http_res_text, http_res
197
- )
186
+ raise errors.APIError("API error occurred", http_res, http_res_text)
198
187
 
199
- content_type = http_res.headers.get("Content-Type")
200
- http_res_text = await utils.stream_to_text_async(http_res)
201
- raise models.APIError(
202
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
203
- http_res.status_code,
204
- http_res_text,
205
- http_res,
206
- )
188
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/incidents.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -109,33 +109,22 @@ class Incidents(BaseSDK):
109
109
 
110
110
  response_data: Any = None
111
111
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(
113
- http_res.text, models.ListResponseIncidentResponse
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseIncidentResponse, http_res
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
116
+ response_data = utils.unmarshal_json_response(
117
+ errors.HTTPValidationErrorData, http_res
118
118
  )
119
- raise models.HTTPValidationError(data=response_data)
119
+ raise errors.HTTPValidationError(response_data, http_res)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError(
123
- "API error occurred", http_res.status_code, http_res_text, http_res
124
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
123
  if utils.match_response(http_res, "5XX", "*"):
126
124
  http_res_text = utils.stream_to_text(http_res)
127
- raise models.APIError(
128
- "API error occurred", http_res.status_code, http_res_text, http_res
129
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
126
 
131
- content_type = http_res.headers.get("Content-Type")
132
- http_res_text = utils.stream_to_text(http_res)
133
- raise models.APIError(
134
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
135
- http_res.status_code,
136
- http_res_text,
137
- http_res,
138
- )
127
+ raise errors.APIError("Unexpected response received", http_res)
139
128
 
140
129
  async def list_async(
141
130
  self,
@@ -235,33 +224,22 @@ class Incidents(BaseSDK):
235
224
 
236
225
  response_data: Any = None
237
226
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseIncidentResponse
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseIncidentResponse, http_res
240
229
  )
241
230
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
231
+ response_data = utils.unmarshal_json_response(
232
+ errors.HTTPValidationErrorData, http_res
244
233
  )
245
- raise models.HTTPValidationError(data=response_data)
234
+ raise errors.HTTPValidationError(response_data, http_res)
246
235
  if utils.match_response(http_res, "4XX", "*"):
247
236
  http_res_text = await utils.stream_to_text_async(http_res)
248
- raise models.APIError(
249
- "API error occurred", http_res.status_code, http_res_text, http_res
250
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
238
  if utils.match_response(http_res, "5XX", "*"):
252
239
  http_res_text = await utils.stream_to_text_async(http_res)
253
- raise models.APIError(
254
- "API error occurred", http_res.status_code, http_res_text, http_res
255
- )
240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
241
 
257
- content_type = http_res.headers.get("Content-Type")
258
- http_res_text = await utils.stream_to_text_async(http_res)
259
- raise models.APIError(
260
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
261
- http_res.status_code,
262
- http_res_text,
263
- http_res,
264
- )
242
+ raise errors.APIError("Unexpected response received", http_res)
265
243
 
266
244
  def create(
267
245
  self,
@@ -342,31 +320,20 @@ class Incidents(BaseSDK):
342
320
 
343
321
  response_data: Any = None
344
322
  if utils.match_response(http_res, "200", "application/json"):
345
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
323
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
346
324
  if utils.match_response(http_res, "422", "application/json"):
347
- response_data = utils.unmarshal_json(
348
- http_res.text, models.HTTPValidationErrorData
325
+ response_data = utils.unmarshal_json_response(
326
+ errors.HTTPValidationErrorData, http_res
349
327
  )
350
- raise models.HTTPValidationError(data=response_data)
328
+ raise errors.HTTPValidationError(response_data, http_res)
351
329
  if utils.match_response(http_res, "4XX", "*"):
352
330
  http_res_text = utils.stream_to_text(http_res)
353
- raise models.APIError(
354
- "API error occurred", http_res.status_code, http_res_text, http_res
355
- )
331
+ raise errors.APIError("API error occurred", http_res, http_res_text)
356
332
  if utils.match_response(http_res, "5XX", "*"):
357
333
  http_res_text = utils.stream_to_text(http_res)
358
- raise models.APIError(
359
- "API error occurred", http_res.status_code, http_res_text, http_res
360
- )
334
+ raise errors.APIError("API error occurred", http_res, http_res_text)
361
335
 
362
- content_type = http_res.headers.get("Content-Type")
363
- http_res_text = utils.stream_to_text(http_res)
364
- raise models.APIError(
365
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
366
- http_res.status_code,
367
- http_res_text,
368
- http_res,
369
- )
336
+ raise errors.APIError("Unexpected response received", http_res)
370
337
 
371
338
  async def create_async(
372
339
  self,
@@ -447,31 +414,20 @@ class Incidents(BaseSDK):
447
414
 
448
415
  response_data: Any = None
449
416
  if utils.match_response(http_res, "200", "application/json"):
450
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
417
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
451
418
  if utils.match_response(http_res, "422", "application/json"):
452
- response_data = utils.unmarshal_json(
453
- http_res.text, models.HTTPValidationErrorData
419
+ response_data = utils.unmarshal_json_response(
420
+ errors.HTTPValidationErrorData, http_res
454
421
  )
455
- raise models.HTTPValidationError(data=response_data)
422
+ raise errors.HTTPValidationError(response_data, http_res)
456
423
  if utils.match_response(http_res, "4XX", "*"):
457
424
  http_res_text = await utils.stream_to_text_async(http_res)
458
- raise models.APIError(
459
- "API error occurred", http_res.status_code, http_res_text, http_res
460
- )
425
+ raise errors.APIError("API error occurred", http_res, http_res_text)
461
426
  if utils.match_response(http_res, "5XX", "*"):
462
427
  http_res_text = await utils.stream_to_text_async(http_res)
463
- raise models.APIError(
464
- "API error occurred", http_res.status_code, http_res_text, http_res
465
- )
428
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
429
 
467
- content_type = http_res.headers.get("Content-Type")
468
- http_res_text = await utils.stream_to_text_async(http_res)
469
- raise models.APIError(
470
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
471
- http_res.status_code,
472
- http_res_text,
473
- http_res,
474
- )
430
+ raise errors.APIError("Unexpected response received", http_res)
475
431
 
476
432
  def update(
477
433
  self,
@@ -552,31 +508,20 @@ class Incidents(BaseSDK):
552
508
 
553
509
  response_data: Any = None
554
510
  if utils.match_response(http_res, "200", "application/json"):
555
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
511
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
556
512
  if utils.match_response(http_res, "422", "application/json"):
557
- response_data = utils.unmarshal_json(
558
- http_res.text, models.HTTPValidationErrorData
513
+ response_data = utils.unmarshal_json_response(
514
+ errors.HTTPValidationErrorData, http_res
559
515
  )
560
- raise models.HTTPValidationError(data=response_data)
516
+ raise errors.HTTPValidationError(response_data, http_res)
561
517
  if utils.match_response(http_res, "4XX", "*"):
562
518
  http_res_text = utils.stream_to_text(http_res)
563
- raise models.APIError(
564
- "API error occurred", http_res.status_code, http_res_text, http_res
565
- )
519
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
520
  if utils.match_response(http_res, "5XX", "*"):
567
521
  http_res_text = utils.stream_to_text(http_res)
568
- raise models.APIError(
569
- "API error occurred", http_res.status_code, http_res_text, http_res
570
- )
522
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
523
 
572
- content_type = http_res.headers.get("Content-Type")
573
- http_res_text = utils.stream_to_text(http_res)
574
- raise models.APIError(
575
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
576
- http_res.status_code,
577
- http_res_text,
578
- http_res,
579
- )
524
+ raise errors.APIError("Unexpected response received", http_res)
580
525
 
581
526
  async def update_async(
582
527
  self,
@@ -657,31 +602,20 @@ class Incidents(BaseSDK):
657
602
 
658
603
  response_data: Any = None
659
604
  if utils.match_response(http_res, "200", "application/json"):
660
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
605
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
661
606
  if utils.match_response(http_res, "422", "application/json"):
662
- response_data = utils.unmarshal_json(
663
- http_res.text, models.HTTPValidationErrorData
607
+ response_data = utils.unmarshal_json_response(
608
+ errors.HTTPValidationErrorData, http_res
664
609
  )
665
- raise models.HTTPValidationError(data=response_data)
610
+ raise errors.HTTPValidationError(response_data, http_res)
666
611
  if utils.match_response(http_res, "4XX", "*"):
667
612
  http_res_text = await utils.stream_to_text_async(http_res)
668
- raise models.APIError(
669
- "API error occurred", http_res.status_code, http_res_text, http_res
670
- )
613
+ raise errors.APIError("API error occurred", http_res, http_res_text)
671
614
  if utils.match_response(http_res, "5XX", "*"):
672
615
  http_res_text = await utils.stream_to_text_async(http_res)
673
- raise models.APIError(
674
- "API error occurred", http_res.status_code, http_res_text, http_res
675
- )
616
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
617
 
677
- content_type = http_res.headers.get("Content-Type")
678
- http_res_text = await utils.stream_to_text_async(http_res)
679
- raise models.APIError(
680
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
681
- http_res.status_code,
682
- http_res_text,
683
- http_res,
684
- )
618
+ raise errors.APIError("Unexpected response received", http_res)
685
619
 
686
620
  def incident_get_organizations(
687
621
  self,
@@ -749,28 +683,17 @@ class Incidents(BaseSDK):
749
683
  )
750
684
 
751
685
  if utils.match_response(http_res, "200", "application/json"):
752
- return utils.unmarshal_json(
753
- http_res.text, List[models.IncidentOrganizationResponse]
686
+ return utils.unmarshal_json_response(
687
+ List[models.IncidentOrganizationResponse], http_res
754
688
  )
755
689
  if utils.match_response(http_res, "4XX", "*"):
756
690
  http_res_text = utils.stream_to_text(http_res)
757
- raise models.APIError(
758
- "API error occurred", http_res.status_code, http_res_text, http_res
759
- )
691
+ raise errors.APIError("API error occurred", http_res, http_res_text)
760
692
  if utils.match_response(http_res, "5XX", "*"):
761
693
  http_res_text = utils.stream_to_text(http_res)
762
- raise models.APIError(
763
- "API error occurred", http_res.status_code, http_res_text, http_res
764
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
765
695
 
766
- content_type = http_res.headers.get("Content-Type")
767
- http_res_text = utils.stream_to_text(http_res)
768
- raise models.APIError(
769
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
770
- http_res.status_code,
771
- http_res_text,
772
- http_res,
773
- )
696
+ raise errors.APIError("Unexpected response received", http_res)
774
697
 
775
698
  async def incident_get_organizations_async(
776
699
  self,
@@ -838,28 +761,17 @@ class Incidents(BaseSDK):
838
761
  )
839
762
 
840
763
  if utils.match_response(http_res, "200", "application/json"):
841
- return utils.unmarshal_json(
842
- http_res.text, List[models.IncidentOrganizationResponse]
764
+ return utils.unmarshal_json_response(
765
+ List[models.IncidentOrganizationResponse], http_res
843
766
  )
844
767
  if utils.match_response(http_res, "4XX", "*"):
845
768
  http_res_text = await utils.stream_to_text_async(http_res)
846
- raise models.APIError(
847
- "API error occurred", http_res.status_code, http_res_text, http_res
848
- )
769
+ raise errors.APIError("API error occurred", http_res, http_res_text)
849
770
  if utils.match_response(http_res, "5XX", "*"):
850
771
  http_res_text = await utils.stream_to_text_async(http_res)
851
- raise models.APIError(
852
- "API error occurred", http_res.status_code, http_res_text, http_res
853
- )
772
+ raise errors.APIError("API error occurred", http_res, http_res_text)
854
773
 
855
- content_type = http_res.headers.get("Content-Type")
856
- http_res_text = await utils.stream_to_text_async(http_res)
857
- raise models.APIError(
858
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
859
- http_res.status_code,
860
- http_res_text,
861
- http_res,
862
- )
774
+ raise errors.APIError("Unexpected response received", http_res)
863
775
 
864
776
  def get_by_id(
865
777
  self,
@@ -935,31 +847,20 @@ class Incidents(BaseSDK):
935
847
 
936
848
  response_data: Any = None
937
849
  if utils.match_response(http_res, "200", "application/json"):
938
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
850
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
939
851
  if utils.match_response(http_res, "422", "application/json"):
940
- response_data = utils.unmarshal_json(
941
- http_res.text, models.HTTPValidationErrorData
852
+ response_data = utils.unmarshal_json_response(
853
+ errors.HTTPValidationErrorData, http_res
942
854
  )
943
- raise models.HTTPValidationError(data=response_data)
855
+ raise errors.HTTPValidationError(response_data, http_res)
944
856
  if utils.match_response(http_res, "4XX", "*"):
945
857
  http_res_text = utils.stream_to_text(http_res)
946
- raise models.APIError(
947
- "API error occurred", http_res.status_code, http_res_text, http_res
948
- )
858
+ raise errors.APIError("API error occurred", http_res, http_res_text)
949
859
  if utils.match_response(http_res, "5XX", "*"):
950
860
  http_res_text = utils.stream_to_text(http_res)
951
- raise models.APIError(
952
- "API error occurred", http_res.status_code, http_res_text, http_res
953
- )
861
+ raise errors.APIError("API error occurred", http_res, http_res_text)
954
862
 
955
- content_type = http_res.headers.get("Content-Type")
956
- http_res_text = utils.stream_to_text(http_res)
957
- raise models.APIError(
958
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
959
- http_res.status_code,
960
- http_res_text,
961
- http_res,
962
- )
863
+ raise errors.APIError("Unexpected response received", http_res)
963
864
 
964
865
  async def get_by_id_async(
965
866
  self,
@@ -1035,31 +936,20 @@ class Incidents(BaseSDK):
1035
936
 
1036
937
  response_data: Any = None
1037
938
  if utils.match_response(http_res, "200", "application/json"):
1038
- return utils.unmarshal_json(http_res.text, models.IncidentResponse)
939
+ return utils.unmarshal_json_response(models.IncidentResponse, http_res)
1039
940
  if utils.match_response(http_res, "422", "application/json"):
1040
- response_data = utils.unmarshal_json(
1041
- http_res.text, models.HTTPValidationErrorData
941
+ response_data = utils.unmarshal_json_response(
942
+ errors.HTTPValidationErrorData, http_res
1042
943
  )
1043
- raise models.HTTPValidationError(data=response_data)
944
+ raise errors.HTTPValidationError(response_data, http_res)
1044
945
  if utils.match_response(http_res, "4XX", "*"):
1045
946
  http_res_text = await utils.stream_to_text_async(http_res)
1046
- raise models.APIError(
1047
- "API error occurred", http_res.status_code, http_res_text, http_res
1048
- )
947
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1049
948
  if utils.match_response(http_res, "5XX", "*"):
1050
949
  http_res_text = await utils.stream_to_text_async(http_res)
1051
- raise models.APIError(
1052
- "API error occurred", http_res.status_code, http_res_text, http_res
1053
- )
950
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1054
951
 
1055
- content_type = http_res.headers.get("Content-Type")
1056
- http_res_text = await utils.stream_to_text_async(http_res)
1057
- raise models.APIError(
1058
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1059
- http_res.status_code,
1060
- http_res_text,
1061
- http_res,
1062
- )
952
+ raise errors.APIError("Unexpected response received", http_res)
1063
953
 
1064
954
  def delete(
1065
955
  self,
@@ -1138,31 +1028,20 @@ class Incidents(BaseSDK):
1138
1028
 
1139
1029
  response_data: Any = None
1140
1030
  if utils.match_response(http_res, "200", "application/json"):
1141
- return utils.unmarshal_json(http_res.text, Any)
1031
+ return utils.unmarshal_json_response(Any, http_res)
1142
1032
  if utils.match_response(http_res, "422", "application/json"):
1143
- response_data = utils.unmarshal_json(
1144
- http_res.text, models.HTTPValidationErrorData
1033
+ response_data = utils.unmarshal_json_response(
1034
+ errors.HTTPValidationErrorData, http_res
1145
1035
  )
1146
- raise models.HTTPValidationError(data=response_data)
1036
+ raise errors.HTTPValidationError(response_data, http_res)
1147
1037
  if utils.match_response(http_res, "4XX", "*"):
1148
1038
  http_res_text = utils.stream_to_text(http_res)
1149
- raise models.APIError(
1150
- "API error occurred", http_res.status_code, http_res_text, http_res
1151
- )
1039
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1152
1040
  if utils.match_response(http_res, "5XX", "*"):
1153
1041
  http_res_text = utils.stream_to_text(http_res)
1154
- raise models.APIError(
1155
- "API error occurred", http_res.status_code, http_res_text, http_res
1156
- )
1042
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1157
1043
 
1158
- content_type = http_res.headers.get("Content-Type")
1159
- http_res_text = utils.stream_to_text(http_res)
1160
- raise models.APIError(
1161
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1162
- http_res.status_code,
1163
- http_res_text,
1164
- http_res,
1165
- )
1044
+ raise errors.APIError("Unexpected response received", http_res)
1166
1045
 
1167
1046
  async def delete_async(
1168
1047
  self,
@@ -1241,28 +1120,17 @@ class Incidents(BaseSDK):
1241
1120
 
1242
1121
  response_data: Any = None
1243
1122
  if utils.match_response(http_res, "200", "application/json"):
1244
- return utils.unmarshal_json(http_res.text, Any)
1123
+ return utils.unmarshal_json_response(Any, http_res)
1245
1124
  if utils.match_response(http_res, "422", "application/json"):
1246
- response_data = utils.unmarshal_json(
1247
- http_res.text, models.HTTPValidationErrorData
1125
+ response_data = utils.unmarshal_json_response(
1126
+ errors.HTTPValidationErrorData, http_res
1248
1127
  )
1249
- raise models.HTTPValidationError(data=response_data)
1128
+ raise errors.HTTPValidationError(response_data, http_res)
1250
1129
  if utils.match_response(http_res, "4XX", "*"):
1251
1130
  http_res_text = await utils.stream_to_text_async(http_res)
1252
- raise models.APIError(
1253
- "API error occurred", http_res.status_code, http_res_text, http_res
1254
- )
1131
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1255
1132
  if utils.match_response(http_res, "5XX", "*"):
1256
1133
  http_res_text = await utils.stream_to_text_async(http_res)
1257
- raise models.APIError(
1258
- "API error occurred", http_res.status_code, http_res_text, http_res
1259
- )
1134
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1260
1135
 
1261
- content_type = http_res.headers.get("Content-Type")
1262
- http_res_text = await utils.stream_to_text_async(http_res)
1263
- raise models.APIError(
1264
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1265
- http_res.status_code,
1266
- http_res_text,
1267
- http_res,
1268
- )
1136
+ raise errors.APIError("Unexpected response received", http_res)
@@ -2,7 +2,7 @@
2
2
 
3
3
  from .basesdk import BaseSDK
4
4
  from .sdkconfiguration import SDKConfiguration
5
- from syllable_sdk import models, utils
5
+ from syllable_sdk import errors, models, utils
6
6
  from syllable_sdk._hooks import HookContext
7
7
  from syllable_sdk.folders import Folders
8
8
  from syllable_sdk.insights_tools import InsightsTools
@@ -130,33 +130,22 @@ class InsightsSDK(BaseSDK):
130
130
 
131
131
  response_data: Any = None
132
132
  if utils.match_response(http_res, "200", "application/json"):
133
- return utils.unmarshal_json(
134
- http_res.text, models.ListResponseInsightsOutput
133
+ return utils.unmarshal_json_response(
134
+ models.ListResponseInsightsOutput, http_res
135
135
  )
136
136
  if utils.match_response(http_res, "422", "application/json"):
137
- response_data = utils.unmarshal_json(
138
- http_res.text, models.HTTPValidationErrorData
137
+ response_data = utils.unmarshal_json_response(
138
+ errors.HTTPValidationErrorData, http_res
139
139
  )
140
- raise models.HTTPValidationError(data=response_data)
140
+ raise errors.HTTPValidationError(response_data, http_res)
141
141
  if utils.match_response(http_res, "4XX", "*"):
142
142
  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
- )
143
+ raise errors.APIError("API error occurred", http_res, http_res_text)
146
144
  if utils.match_response(http_res, "5XX", "*"):
147
145
  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
- )
146
+ raise errors.APIError("API error occurred", http_res, http_res_text)
151
147
 
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
- )
148
+ raise errors.APIError("Unexpected response received", http_res)
160
149
 
161
150
  async def list_async(
162
151
  self,
@@ -256,30 +245,19 @@ class InsightsSDK(BaseSDK):
256
245
 
257
246
  response_data: Any = None
258
247
  if utils.match_response(http_res, "200", "application/json"):
259
- return utils.unmarshal_json(
260
- http_res.text, models.ListResponseInsightsOutput
248
+ return utils.unmarshal_json_response(
249
+ models.ListResponseInsightsOutput, http_res
261
250
  )
262
251
  if utils.match_response(http_res, "422", "application/json"):
263
- response_data = utils.unmarshal_json(
264
- http_res.text, models.HTTPValidationErrorData
252
+ response_data = utils.unmarshal_json_response(
253
+ errors.HTTPValidationErrorData, http_res
265
254
  )
266
- raise models.HTTPValidationError(data=response_data)
255
+ raise errors.HTTPValidationError(response_data, http_res)
267
256
  if utils.match_response(http_res, "4XX", "*"):
268
257
  http_res_text = await utils.stream_to_text_async(http_res)
269
- raise models.APIError(
270
- "API error occurred", http_res.status_code, http_res_text, http_res
271
- )
258
+ raise errors.APIError("API error occurred", http_res, http_res_text)
272
259
  if utils.match_response(http_res, "5XX", "*"):
273
260
  http_res_text = await utils.stream_to_text_async(http_res)
274
- raise models.APIError(
275
- "API error occurred", http_res.status_code, http_res_text, http_res
276
- )
261
+ raise errors.APIError("API error occurred", http_res, http_res_text)
277
262
 
278
- content_type = http_res.headers.get("Content-Type")
279
- http_res_text = await utils.stream_to_text_async(http_res)
280
- raise models.APIError(
281
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
282
- http_res.status_code,
283
- http_res_text,
284
- http_res,
285
- )
263
+ raise errors.APIError("Unexpected response received", http_res)