syllable-sdk 0.35.30__py3-none-any.whl → 0.35.32__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 (47) hide show
  1. syllable_sdk/_version.py +3 -3
  2. syllable_sdk/agents.py +210 -82
  3. syllable_sdk/basesdk.py +4 -4
  4. syllable_sdk/batches.py +328 -130
  5. syllable_sdk/campaigns.py +182 -72
  6. syllable_sdk/channels.py +72 -28
  7. syllable_sdk/conversations.py +36 -18
  8. syllable_sdk/custom_messages.py +182 -72
  9. syllable_sdk/dashboards.py +194 -66
  10. syllable_sdk/data_sources.py +182 -84
  11. syllable_sdk/events.py +36 -14
  12. syllable_sdk/folders.py +292 -120
  13. syllable_sdk/full_summary.py +36 -18
  14. syllable_sdk/incidents.py +214 -82
  15. syllable_sdk/insights_sdk.py +38 -16
  16. syllable_sdk/insights_tools.py +250 -96
  17. syllable_sdk/language_groups.py +214 -84
  18. syllable_sdk/latency.py +36 -18
  19. syllable_sdk/models/__init__.py +0 -9
  20. syllable_sdk/models/apierror.py +14 -30
  21. syllable_sdk/models/httpvalidationerror.py +6 -11
  22. syllable_sdk/numbers.py +110 -52
  23. syllable_sdk/organizations.py +138 -50
  24. syllable_sdk/permissions.py +32 -10
  25. syllable_sdk/prompts.py +248 -94
  26. syllable_sdk/roles.py +180 -74
  27. syllable_sdk/services.py +182 -72
  28. syllable_sdk/session_debug.py +108 -42
  29. syllable_sdk/session_labels.py +108 -46
  30. syllable_sdk/sessions.py +140 -58
  31. syllable_sdk/takeouts.py +98 -34
  32. syllable_sdk/targets.py +184 -74
  33. syllable_sdk/test.py +36 -14
  34. syllable_sdk/tools.py +180 -74
  35. syllable_sdk/transcript.py +38 -16
  36. syllable_sdk/twilio.py +108 -42
  37. syllable_sdk/users.py +246 -96
  38. syllable_sdk/utils/__init__.py +0 -3
  39. syllable_sdk/utils/serializers.py +4 -20
  40. syllable_sdk/v1.py +246 -96
  41. syllable_sdk/workflows.py +290 -114
  42. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/METADATA +24 -44
  43. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/RECORD +44 -47
  44. syllable_sdk/models/no_response_error.py +0 -13
  45. syllable_sdk/models/responsevalidationerror.py +0 -25
  46. syllable_sdk/models/syllablesdkerror.py +0 -26
  47. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/WHEEL +0 -0
@@ -1,38 +1,22 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
- import httpx
3
+ from dataclasses import dataclass
4
4
  from typing import Optional
5
+ import httpx
5
6
 
6
- from syllable_sdk.models import SyllableSDKError
7
-
8
- MAX_MESSAGE_LEN = 10_000
9
-
10
-
11
- class APIError(SyllableSDKError):
12
- """The fallback error class if no more specific error class is matched."""
13
-
14
- def __init__(
15
- self, message: str, raw_response: httpx.Response, body: Optional[str] = None
16
- ):
17
- body_display = body or raw_response.text or '""'
18
-
19
- if message:
20
- message += ": "
21
- message += f"Status {raw_response.status_code}"
22
7
 
23
- headers = raw_response.headers
24
- content_type = headers.get("content-type", '""')
25
- if content_type != "application/json":
26
- if " " in content_type:
27
- content_type = f'"{content_type}"'
28
- message += f" Content-Type {content_type}"
8
+ @dataclass
9
+ class APIError(Exception):
10
+ """Represents an error returned by the API."""
29
11
 
30
- if len(body_display) > MAX_MESSAGE_LEN:
31
- truncated = body_display[:MAX_MESSAGE_LEN]
32
- remaining = len(body_display) - MAX_MESSAGE_LEN
33
- body_display = f"{truncated}...and {remaining} more chars"
12
+ message: str
13
+ status_code: int = -1
14
+ body: str = ""
15
+ raw_response: Optional[httpx.Response] = None
34
16
 
35
- message += f". Body: {body_display}"
36
- message = message.strip()
17
+ def __str__(self):
18
+ body = ""
19
+ if len(self.body) > 0:
20
+ body = f"\n{self.body}"
37
21
 
38
- super().__init__(message, raw_response, body)
22
+ return f"{self.message}: Status {self.status_code}{body}"
@@ -2,8 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .validationerror import ValidationError
5
- import httpx
6
- from syllable_sdk.models import SyllableSDKError
5
+ from syllable_sdk import utils
7
6
  from syllable_sdk.types import BaseModel
8
7
  from typing import List, Optional
9
8
 
@@ -12,15 +11,11 @@ class HTTPValidationErrorData(BaseModel):
12
11
  detail: Optional[List[ValidationError]] = None
13
12
 
14
13
 
15
- class HTTPValidationError(SyllableSDKError):
14
+ class HTTPValidationError(Exception):
16
15
  data: HTTPValidationErrorData
17
16
 
18
- def __init__(
19
- self,
20
- data: HTTPValidationErrorData,
21
- raw_response: httpx.Response,
22
- body: Optional[str] = None,
23
- ):
24
- message = body or raw_response.text
25
- super().__init__(message, raw_response, body)
17
+ def __init__(self, data: HTTPValidationErrorData):
26
18
  self.data = data
19
+
20
+ def __str__(self) -> str:
21
+ return utils.marshal_json(self.data, HTTPValidationErrorData)
syllable_sdk/numbers.py CHANGED
@@ -99,22 +99,31 @@ class Numbers(BaseSDK):
99
99
 
100
100
  response_data: Any = None
101
101
  if utils.match_response(http_res, "200", "application/json"):
102
- return utils.unmarshal_json_response(
103
- models.TwilioNumberAddResponse, http_res
104
- )
102
+ return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
105
103
  if utils.match_response(http_res, "422", "application/json"):
106
- response_data = utils.unmarshal_json_response(
107
- models.HTTPValidationErrorData, http_res
104
+ response_data = utils.unmarshal_json(
105
+ http_res.text, models.HTTPValidationErrorData
108
106
  )
109
- raise models.HTTPValidationError(response_data, http_res)
107
+ raise models.HTTPValidationError(data=response_data)
110
108
  if utils.match_response(http_res, "4XX", "*"):
111
109
  http_res_text = utils.stream_to_text(http_res)
112
- raise models.APIError("API error occurred", http_res, http_res_text)
110
+ raise models.APIError(
111
+ "API error occurred", http_res.status_code, http_res_text, http_res
112
+ )
113
113
  if utils.match_response(http_res, "5XX", "*"):
114
114
  http_res_text = utils.stream_to_text(http_res)
115
- raise models.APIError("API error occurred", http_res, http_res_text)
115
+ raise models.APIError(
116
+ "API error occurred", http_res.status_code, http_res_text, http_res
117
+ )
116
118
 
117
- raise models.APIError("Unexpected response received", http_res)
119
+ content_type = http_res.headers.get("Content-Type")
120
+ http_res_text = utils.stream_to_text(http_res)
121
+ raise models.APIError(
122
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
123
+ http_res.status_code,
124
+ http_res_text,
125
+ http_res,
126
+ )
118
127
 
119
128
  async def add_async(
120
129
  self,
@@ -204,22 +213,31 @@ class Numbers(BaseSDK):
204
213
 
205
214
  response_data: Any = None
206
215
  if utils.match_response(http_res, "200", "application/json"):
207
- return utils.unmarshal_json_response(
208
- models.TwilioNumberAddResponse, http_res
209
- )
216
+ return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
210
217
  if utils.match_response(http_res, "422", "application/json"):
211
- response_data = utils.unmarshal_json_response(
212
- models.HTTPValidationErrorData, http_res
218
+ response_data = utils.unmarshal_json(
219
+ http_res.text, models.HTTPValidationErrorData
213
220
  )
214
- raise models.HTTPValidationError(response_data, http_res)
221
+ raise models.HTTPValidationError(data=response_data)
215
222
  if utils.match_response(http_res, "4XX", "*"):
216
223
  http_res_text = await utils.stream_to_text_async(http_res)
217
- raise models.APIError("API error occurred", http_res, http_res_text)
224
+ raise models.APIError(
225
+ "API error occurred", http_res.status_code, http_res_text, http_res
226
+ )
218
227
  if utils.match_response(http_res, "5XX", "*"):
219
228
  http_res_text = await utils.stream_to_text_async(http_res)
220
- raise models.APIError("API error occurred", http_res, http_res_text)
229
+ raise models.APIError(
230
+ "API error occurred", http_res.status_code, http_res_text, http_res
231
+ )
221
232
 
222
- raise models.APIError("Unexpected response received", http_res)
233
+ content_type = http_res.headers.get("Content-Type")
234
+ http_res_text = await utils.stream_to_text_async(http_res)
235
+ raise models.APIError(
236
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
237
+ http_res.status_code,
238
+ http_res_text,
239
+ http_res,
240
+ )
223
241
 
224
242
  def update(
225
243
  self,
@@ -309,22 +327,33 @@ class Numbers(BaseSDK):
309
327
 
310
328
  response_data: Any = None
311
329
  if utils.match_response(http_res, "200", "application/json"):
312
- return utils.unmarshal_json_response(
313
- models.TwilioNumberUpdateResponse, http_res
330
+ return utils.unmarshal_json(
331
+ http_res.text, models.TwilioNumberUpdateResponse
314
332
  )
315
333
  if utils.match_response(http_res, "422", "application/json"):
316
- response_data = utils.unmarshal_json_response(
317
- models.HTTPValidationErrorData, http_res
334
+ response_data = utils.unmarshal_json(
335
+ http_res.text, models.HTTPValidationErrorData
318
336
  )
319
- raise models.HTTPValidationError(response_data, http_res)
337
+ raise models.HTTPValidationError(data=response_data)
320
338
  if utils.match_response(http_res, "4XX", "*"):
321
339
  http_res_text = utils.stream_to_text(http_res)
322
- raise models.APIError("API error occurred", http_res, http_res_text)
340
+ raise models.APIError(
341
+ "API error occurred", http_res.status_code, http_res_text, http_res
342
+ )
323
343
  if utils.match_response(http_res, "5XX", "*"):
324
344
  http_res_text = utils.stream_to_text(http_res)
325
- raise models.APIError("API error occurred", http_res, http_res_text)
345
+ raise models.APIError(
346
+ "API error occurred", http_res.status_code, http_res_text, http_res
347
+ )
326
348
 
327
- raise models.APIError("Unexpected response received", http_res)
349
+ content_type = http_res.headers.get("Content-Type")
350
+ http_res_text = utils.stream_to_text(http_res)
351
+ raise models.APIError(
352
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
353
+ http_res.status_code,
354
+ http_res_text,
355
+ http_res,
356
+ )
328
357
 
329
358
  async def update_async(
330
359
  self,
@@ -414,22 +443,33 @@ class Numbers(BaseSDK):
414
443
 
415
444
  response_data: Any = None
416
445
  if utils.match_response(http_res, "200", "application/json"):
417
- return utils.unmarshal_json_response(
418
- models.TwilioNumberUpdateResponse, http_res
446
+ return utils.unmarshal_json(
447
+ http_res.text, models.TwilioNumberUpdateResponse
419
448
  )
420
449
  if utils.match_response(http_res, "422", "application/json"):
421
- response_data = utils.unmarshal_json_response(
422
- models.HTTPValidationErrorData, http_res
450
+ response_data = utils.unmarshal_json(
451
+ http_res.text, models.HTTPValidationErrorData
423
452
  )
424
- raise models.HTTPValidationError(response_data, http_res)
453
+ raise models.HTTPValidationError(data=response_data)
425
454
  if utils.match_response(http_res, "4XX", "*"):
426
455
  http_res_text = await utils.stream_to_text_async(http_res)
427
- raise models.APIError("API error occurred", http_res, http_res_text)
456
+ raise models.APIError(
457
+ "API error occurred", http_res.status_code, http_res_text, http_res
458
+ )
428
459
  if utils.match_response(http_res, "5XX", "*"):
429
460
  http_res_text = await utils.stream_to_text_async(http_res)
430
- raise models.APIError("API error occurred", http_res, http_res_text)
461
+ raise models.APIError(
462
+ "API error occurred", http_res.status_code, http_res_text, http_res
463
+ )
431
464
 
432
- raise models.APIError("Unexpected response received", http_res)
465
+ content_type = http_res.headers.get("Content-Type")
466
+ http_res_text = await utils.stream_to_text_async(http_res)
467
+ raise models.APIError(
468
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
469
+ http_res.status_code,
470
+ http_res_text,
471
+ http_res,
472
+ )
433
473
 
434
474
  def list(
435
475
  self,
@@ -505,22 +545,31 @@ class Numbers(BaseSDK):
505
545
 
506
546
  response_data: Any = None
507
547
  if utils.match_response(http_res, "200", "application/json"):
508
- return utils.unmarshal_json_response(
509
- models.TwilioListNumbersResponse, http_res
510
- )
548
+ return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
511
549
  if utils.match_response(http_res, "422", "application/json"):
512
- response_data = utils.unmarshal_json_response(
513
- models.HTTPValidationErrorData, http_res
550
+ response_data = utils.unmarshal_json(
551
+ http_res.text, models.HTTPValidationErrorData
514
552
  )
515
- raise models.HTTPValidationError(response_data, http_res)
553
+ raise models.HTTPValidationError(data=response_data)
516
554
  if utils.match_response(http_res, "4XX", "*"):
517
555
  http_res_text = utils.stream_to_text(http_res)
518
- raise models.APIError("API error occurred", http_res, http_res_text)
556
+ raise models.APIError(
557
+ "API error occurred", http_res.status_code, http_res_text, http_res
558
+ )
519
559
  if utils.match_response(http_res, "5XX", "*"):
520
560
  http_res_text = utils.stream_to_text(http_res)
521
- raise models.APIError("API error occurred", http_res, http_res_text)
561
+ raise models.APIError(
562
+ "API error occurred", http_res.status_code, http_res_text, http_res
563
+ )
522
564
 
523
- raise models.APIError("Unexpected response received", http_res)
565
+ content_type = http_res.headers.get("Content-Type")
566
+ http_res_text = utils.stream_to_text(http_res)
567
+ raise models.APIError(
568
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
569
+ http_res.status_code,
570
+ http_res_text,
571
+ http_res,
572
+ )
524
573
 
525
574
  async def list_async(
526
575
  self,
@@ -596,19 +645,28 @@ class Numbers(BaseSDK):
596
645
 
597
646
  response_data: Any = None
598
647
  if utils.match_response(http_res, "200", "application/json"):
599
- return utils.unmarshal_json_response(
600
- models.TwilioListNumbersResponse, http_res
601
- )
648
+ return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
602
649
  if utils.match_response(http_res, "422", "application/json"):
603
- response_data = utils.unmarshal_json_response(
604
- models.HTTPValidationErrorData, http_res
650
+ response_data = utils.unmarshal_json(
651
+ http_res.text, models.HTTPValidationErrorData
605
652
  )
606
- raise models.HTTPValidationError(response_data, http_res)
653
+ raise models.HTTPValidationError(data=response_data)
607
654
  if utils.match_response(http_res, "4XX", "*"):
608
655
  http_res_text = await utils.stream_to_text_async(http_res)
609
- raise models.APIError("API error occurred", http_res, http_res_text)
656
+ raise models.APIError(
657
+ "API error occurred", http_res.status_code, http_res_text, http_res
658
+ )
610
659
  if utils.match_response(http_res, "5XX", "*"):
611
660
  http_res_text = await utils.stream_to_text_async(http_res)
612
- raise models.APIError("API error occurred", http_res, http_res_text)
661
+ raise models.APIError(
662
+ "API error occurred", http_res.status_code, http_res_text, http_res
663
+ )
613
664
 
614
- raise models.APIError("Unexpected response received", http_res)
665
+ content_type = http_res.headers.get("Content-Type")
666
+ http_res_text = await utils.stream_to_text_async(http_res)
667
+ raise models.APIError(
668
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
669
+ http_res.status_code,
670
+ http_res_text,
671
+ http_res,
672
+ )
@@ -77,15 +77,26 @@ class Organizations(BaseSDK):
77
77
  )
78
78
 
79
79
  if utils.match_response(http_res, "200", "application/json"):
80
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
80
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
81
81
  if utils.match_response(http_res, "4XX", "*"):
82
82
  http_res_text = utils.stream_to_text(http_res)
83
- raise models.APIError("API error occurred", http_res, http_res_text)
83
+ raise models.APIError(
84
+ "API error occurred", http_res.status_code, http_res_text, http_res
85
+ )
84
86
  if utils.match_response(http_res, "5XX", "*"):
85
87
  http_res_text = utils.stream_to_text(http_res)
86
- raise models.APIError("API error occurred", http_res, http_res_text)
88
+ raise models.APIError(
89
+ "API error occurred", http_res.status_code, http_res_text, http_res
90
+ )
87
91
 
88
- raise models.APIError("Unexpected response received", http_res)
92
+ content_type = http_res.headers.get("Content-Type")
93
+ http_res_text = utils.stream_to_text(http_res)
94
+ raise models.APIError(
95
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
96
+ http_res.status_code,
97
+ http_res_text,
98
+ http_res,
99
+ )
89
100
 
90
101
  async def organizations_get_async(
91
102
  self,
@@ -153,15 +164,26 @@ class Organizations(BaseSDK):
153
164
  )
154
165
 
155
166
  if utils.match_response(http_res, "200", "application/json"):
156
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
167
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
157
168
  if utils.match_response(http_res, "4XX", "*"):
158
169
  http_res_text = await utils.stream_to_text_async(http_res)
159
- raise models.APIError("API error occurred", http_res, http_res_text)
170
+ raise models.APIError(
171
+ "API error occurred", http_res.status_code, http_res_text, http_res
172
+ )
160
173
  if utils.match_response(http_res, "5XX", "*"):
161
174
  http_res_text = await utils.stream_to_text_async(http_res)
162
- raise models.APIError("API error occurred", http_res, http_res_text)
175
+ raise models.APIError(
176
+ "API error occurred", http_res.status_code, http_res_text, http_res
177
+ )
163
178
 
164
- raise models.APIError("Unexpected response received", http_res)
179
+ content_type = http_res.headers.get("Content-Type")
180
+ http_res_text = await utils.stream_to_text_async(http_res)
181
+ raise models.APIError(
182
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
183
+ http_res.status_code,
184
+ http_res_text,
185
+ http_res,
186
+ )
165
187
 
166
188
  def update(
167
189
  self,
@@ -242,20 +264,31 @@ class Organizations(BaseSDK):
242
264
 
243
265
  response_data: Any = None
244
266
  if utils.match_response(http_res, "200", "application/json"):
245
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
267
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
246
268
  if utils.match_response(http_res, "422", "application/json"):
247
- response_data = utils.unmarshal_json_response(
248
- models.HTTPValidationErrorData, http_res
269
+ response_data = utils.unmarshal_json(
270
+ http_res.text, models.HTTPValidationErrorData
249
271
  )
250
- raise models.HTTPValidationError(response_data, http_res)
272
+ raise models.HTTPValidationError(data=response_data)
251
273
  if utils.match_response(http_res, "4XX", "*"):
252
274
  http_res_text = utils.stream_to_text(http_res)
253
- raise models.APIError("API error occurred", http_res, http_res_text)
275
+ raise models.APIError(
276
+ "API error occurred", http_res.status_code, http_res_text, http_res
277
+ )
254
278
  if utils.match_response(http_res, "5XX", "*"):
255
279
  http_res_text = utils.stream_to_text(http_res)
256
- raise models.APIError("API error occurred", http_res, http_res_text)
280
+ raise models.APIError(
281
+ "API error occurred", http_res.status_code, http_res_text, http_res
282
+ )
257
283
 
258
- raise models.APIError("Unexpected response received", http_res)
284
+ content_type = http_res.headers.get("Content-Type")
285
+ http_res_text = utils.stream_to_text(http_res)
286
+ raise models.APIError(
287
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
288
+ http_res.status_code,
289
+ http_res_text,
290
+ http_res,
291
+ )
259
292
 
260
293
  async def update_async(
261
294
  self,
@@ -336,20 +369,31 @@ class Organizations(BaseSDK):
336
369
 
337
370
  response_data: Any = None
338
371
  if utils.match_response(http_res, "200", "application/json"):
339
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
372
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
340
373
  if utils.match_response(http_res, "422", "application/json"):
341
- response_data = utils.unmarshal_json_response(
342
- models.HTTPValidationErrorData, http_res
374
+ response_data = utils.unmarshal_json(
375
+ http_res.text, models.HTTPValidationErrorData
343
376
  )
344
- raise models.HTTPValidationError(response_data, http_res)
377
+ raise models.HTTPValidationError(data=response_data)
345
378
  if utils.match_response(http_res, "4XX", "*"):
346
379
  http_res_text = await utils.stream_to_text_async(http_res)
347
- raise models.APIError("API error occurred", http_res, http_res_text)
380
+ raise models.APIError(
381
+ "API error occurred", http_res.status_code, http_res_text, http_res
382
+ )
348
383
  if utils.match_response(http_res, "5XX", "*"):
349
384
  http_res_text = await utils.stream_to_text_async(http_res)
350
- raise models.APIError("API error occurred", http_res, http_res_text)
385
+ raise models.APIError(
386
+ "API error occurred", http_res.status_code, http_res_text, http_res
387
+ )
351
388
 
352
- raise models.APIError("Unexpected response received", http_res)
389
+ content_type = http_res.headers.get("Content-Type")
390
+ http_res_text = await utils.stream_to_text_async(http_res)
391
+ raise models.APIError(
392
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
393
+ http_res.status_code,
394
+ http_res_text,
395
+ http_res,
396
+ )
353
397
 
354
398
  def create(
355
399
  self,
@@ -430,20 +474,31 @@ class Organizations(BaseSDK):
430
474
 
431
475
  response_data: Any = None
432
476
  if utils.match_response(http_res, "200", "application/json"):
433
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
477
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
434
478
  if utils.match_response(http_res, "422", "application/json"):
435
- response_data = utils.unmarshal_json_response(
436
- models.HTTPValidationErrorData, http_res
479
+ response_data = utils.unmarshal_json(
480
+ http_res.text, models.HTTPValidationErrorData
437
481
  )
438
- raise models.HTTPValidationError(response_data, http_res)
482
+ raise models.HTTPValidationError(data=response_data)
439
483
  if utils.match_response(http_res, "4XX", "*"):
440
484
  http_res_text = utils.stream_to_text(http_res)
441
- raise models.APIError("API error occurred", http_res, http_res_text)
485
+ raise models.APIError(
486
+ "API error occurred", http_res.status_code, http_res_text, http_res
487
+ )
442
488
  if utils.match_response(http_res, "5XX", "*"):
443
489
  http_res_text = utils.stream_to_text(http_res)
444
- raise models.APIError("API error occurred", http_res, http_res_text)
490
+ raise models.APIError(
491
+ "API error occurred", http_res.status_code, http_res_text, http_res
492
+ )
445
493
 
446
- raise models.APIError("Unexpected response received", http_res)
494
+ content_type = http_res.headers.get("Content-Type")
495
+ http_res_text = utils.stream_to_text(http_res)
496
+ raise models.APIError(
497
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
498
+ http_res.status_code,
499
+ http_res_text,
500
+ http_res,
501
+ )
447
502
 
448
503
  async def create_async(
449
504
  self,
@@ -524,20 +579,31 @@ class Organizations(BaseSDK):
524
579
 
525
580
  response_data: Any = None
526
581
  if utils.match_response(http_res, "200", "application/json"):
527
- return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
582
+ return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
528
583
  if utils.match_response(http_res, "422", "application/json"):
529
- response_data = utils.unmarshal_json_response(
530
- models.HTTPValidationErrorData, http_res
584
+ response_data = utils.unmarshal_json(
585
+ http_res.text, models.HTTPValidationErrorData
531
586
  )
532
- raise models.HTTPValidationError(response_data, http_res)
587
+ raise models.HTTPValidationError(data=response_data)
533
588
  if utils.match_response(http_res, "4XX", "*"):
534
589
  http_res_text = await utils.stream_to_text_async(http_res)
535
- raise models.APIError("API error occurred", http_res, http_res_text)
590
+ raise models.APIError(
591
+ "API error occurred", http_res.status_code, http_res_text, http_res
592
+ )
536
593
  if utils.match_response(http_res, "5XX", "*"):
537
594
  http_res_text = await utils.stream_to_text_async(http_res)
538
- raise models.APIError("API error occurred", http_res, http_res_text)
595
+ raise models.APIError(
596
+ "API error occurred", http_res.status_code, http_res_text, http_res
597
+ )
539
598
 
540
- raise models.APIError("Unexpected response received", http_res)
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
607
 
542
608
  def delete(
543
609
  self,
@@ -620,20 +686,31 @@ class Organizations(BaseSDK):
620
686
 
621
687
  response_data: Any = None
622
688
  if utils.match_response(http_res, "200", "application/json"):
623
- return utils.unmarshal_json_response(Any, http_res)
689
+ return utils.unmarshal_json(http_res.text, Any)
624
690
  if utils.match_response(http_res, "422", "application/json"):
625
- response_data = utils.unmarshal_json_response(
626
- models.HTTPValidationErrorData, http_res
691
+ response_data = utils.unmarshal_json(
692
+ http_res.text, models.HTTPValidationErrorData
627
693
  )
628
- raise models.HTTPValidationError(response_data, http_res)
694
+ raise models.HTTPValidationError(data=response_data)
629
695
  if utils.match_response(http_res, "4XX", "*"):
630
696
  http_res_text = utils.stream_to_text(http_res)
631
- raise models.APIError("API error occurred", http_res, http_res_text)
697
+ raise models.APIError(
698
+ "API error occurred", http_res.status_code, http_res_text, http_res
699
+ )
632
700
  if utils.match_response(http_res, "5XX", "*"):
633
701
  http_res_text = utils.stream_to_text(http_res)
634
- raise models.APIError("API error occurred", http_res, http_res_text)
702
+ raise models.APIError(
703
+ "API error occurred", http_res.status_code, http_res_text, http_res
704
+ )
635
705
 
636
- raise models.APIError("Unexpected response received", http_res)
706
+ content_type = http_res.headers.get("Content-Type")
707
+ http_res_text = utils.stream_to_text(http_res)
708
+ raise models.APIError(
709
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
710
+ http_res.status_code,
711
+ http_res_text,
712
+ http_res,
713
+ )
637
714
 
638
715
  async def delete_async(
639
716
  self,
@@ -716,17 +793,28 @@ class Organizations(BaseSDK):
716
793
 
717
794
  response_data: Any = None
718
795
  if utils.match_response(http_res, "200", "application/json"):
719
- return utils.unmarshal_json_response(Any, http_res)
796
+ return utils.unmarshal_json(http_res.text, Any)
720
797
  if utils.match_response(http_res, "422", "application/json"):
721
- response_data = utils.unmarshal_json_response(
722
- models.HTTPValidationErrorData, http_res
798
+ response_data = utils.unmarshal_json(
799
+ http_res.text, models.HTTPValidationErrorData
723
800
  )
724
- raise models.HTTPValidationError(response_data, http_res)
801
+ raise models.HTTPValidationError(data=response_data)
725
802
  if utils.match_response(http_res, "4XX", "*"):
726
803
  http_res_text = await utils.stream_to_text_async(http_res)
727
- raise models.APIError("API error occurred", http_res, http_res_text)
804
+ raise models.APIError(
805
+ "API error occurred", http_res.status_code, http_res_text, http_res
806
+ )
728
807
  if utils.match_response(http_res, "5XX", "*"):
729
808
  http_res_text = await utils.stream_to_text_async(http_res)
730
- raise models.APIError("API error occurred", http_res, http_res_text)
809
+ raise models.APIError(
810
+ "API error occurred", http_res.status_code, http_res_text, http_res
811
+ )
731
812
 
732
- raise models.APIError("Unexpected response received", http_res)
813
+ content_type = http_res.headers.get("Content-Type")
814
+ http_res_text = await utils.stream_to_text_async(http_res)
815
+ raise models.APIError(
816
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
817
+ http_res.status_code,
818
+ http_res_text,
819
+ http_res,
820
+ )