lambdadb 0.3.5__py3-none-any.whl → 0.3.6__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 lambdadb might be problematic. Click here for more details.

lambdadb/collections.py CHANGED
@@ -97,46 +97,37 @@ class Collections(BaseSDK):
97
97
 
98
98
  response_data: Any = None
99
99
  if utils.match_response(http_res, "200", "application/json"):
100
- return utils.unmarshal_json(http_res.text, models.ListCollectionsResponse)
100
+ return utils.unmarshal_json_response(
101
+ models.ListCollectionsResponse, http_res
102
+ )
101
103
  if utils.match_response(http_res, "401", "application/json"):
102
- response_data = utils.unmarshal_json(
103
- http_res.text, errors.UnauthenticatedErrorData
104
+ response_data = utils.unmarshal_json_response(
105
+ errors.UnauthenticatedErrorData, http_res
104
106
  )
105
- raise errors.UnauthenticatedError(data=response_data)
107
+ raise errors.UnauthenticatedError(response_data, http_res)
106
108
  if utils.match_response(http_res, "404", "application/json"):
107
- response_data = utils.unmarshal_json(
108
- http_res.text, errors.ResourceNotFoundErrorData
109
+ response_data = utils.unmarshal_json_response(
110
+ errors.ResourceNotFoundErrorData, http_res
109
111
  )
110
- raise errors.ResourceNotFoundError(data=response_data)
112
+ raise errors.ResourceNotFoundError(response_data, http_res)
111
113
  if utils.match_response(http_res, "429", "application/json"):
112
- response_data = utils.unmarshal_json(
113
- http_res.text, errors.TooManyRequestsErrorData
114
+ response_data = utils.unmarshal_json_response(
115
+ errors.TooManyRequestsErrorData, http_res
114
116
  )
115
- raise errors.TooManyRequestsError(data=response_data)
117
+ raise errors.TooManyRequestsError(response_data, http_res)
116
118
  if utils.match_response(http_res, "500", "application/json"):
117
- response_data = utils.unmarshal_json(
118
- http_res.text, errors.InternalServerErrorData
119
+ response_data = utils.unmarshal_json_response(
120
+ errors.InternalServerErrorData, http_res
119
121
  )
120
- raise errors.InternalServerError(data=response_data)
122
+ raise errors.InternalServerError(response_data, http_res)
121
123
  if utils.match_response(http_res, "4XX", "*"):
122
124
  http_res_text = utils.stream_to_text(http_res)
123
- raise errors.APIError(
124
- "API error occurred", http_res.status_code, http_res_text, http_res
125
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
126
126
  if utils.match_response(http_res, "5XX", "*"):
127
127
  http_res_text = utils.stream_to_text(http_res)
128
- raise errors.APIError(
129
- "API error occurred", http_res.status_code, http_res_text, http_res
130
- )
128
+ raise errors.APIError("API error occurred", http_res, http_res_text)
131
129
 
132
- content_type = http_res.headers.get("Content-Type")
133
- http_res_text = utils.stream_to_text(http_res)
134
- raise errors.APIError(
135
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
136
- http_res.status_code,
137
- http_res_text,
138
- http_res,
139
- )
130
+ raise errors.APIError("Unexpected response received", http_res)
140
131
 
141
132
  async def list_async(
142
133
  self,
@@ -214,46 +205,37 @@ class Collections(BaseSDK):
214
205
 
215
206
  response_data: Any = None
216
207
  if utils.match_response(http_res, "200", "application/json"):
217
- return utils.unmarshal_json(http_res.text, models.ListCollectionsResponse)
208
+ return utils.unmarshal_json_response(
209
+ models.ListCollectionsResponse, http_res
210
+ )
218
211
  if utils.match_response(http_res, "401", "application/json"):
219
- response_data = utils.unmarshal_json(
220
- http_res.text, errors.UnauthenticatedErrorData
212
+ response_data = utils.unmarshal_json_response(
213
+ errors.UnauthenticatedErrorData, http_res
221
214
  )
222
- raise errors.UnauthenticatedError(data=response_data)
215
+ raise errors.UnauthenticatedError(response_data, http_res)
223
216
  if utils.match_response(http_res, "404", "application/json"):
224
- response_data = utils.unmarshal_json(
225
- http_res.text, errors.ResourceNotFoundErrorData
217
+ response_data = utils.unmarshal_json_response(
218
+ errors.ResourceNotFoundErrorData, http_res
226
219
  )
227
- raise errors.ResourceNotFoundError(data=response_data)
220
+ raise errors.ResourceNotFoundError(response_data, http_res)
228
221
  if utils.match_response(http_res, "429", "application/json"):
229
- response_data = utils.unmarshal_json(
230
- http_res.text, errors.TooManyRequestsErrorData
222
+ response_data = utils.unmarshal_json_response(
223
+ errors.TooManyRequestsErrorData, http_res
231
224
  )
232
- raise errors.TooManyRequestsError(data=response_data)
225
+ raise errors.TooManyRequestsError(response_data, http_res)
233
226
  if utils.match_response(http_res, "500", "application/json"):
234
- response_data = utils.unmarshal_json(
235
- http_res.text, errors.InternalServerErrorData
227
+ response_data = utils.unmarshal_json_response(
228
+ errors.InternalServerErrorData, http_res
236
229
  )
237
- raise errors.InternalServerError(data=response_data)
230
+ raise errors.InternalServerError(response_data, http_res)
238
231
  if utils.match_response(http_res, "4XX", "*"):
239
232
  http_res_text = await utils.stream_to_text_async(http_res)
240
- raise errors.APIError(
241
- "API error occurred", http_res.status_code, http_res_text, http_res
242
- )
233
+ raise errors.APIError("API error occurred", http_res, http_res_text)
243
234
  if utils.match_response(http_res, "5XX", "*"):
244
235
  http_res_text = await utils.stream_to_text_async(http_res)
245
- raise errors.APIError(
246
- "API error occurred", http_res.status_code, http_res_text, http_res
247
- )
236
+ raise errors.APIError("API error occurred", http_res, http_res_text)
248
237
 
249
- content_type = http_res.headers.get("Content-Type")
250
- http_res_text = await utils.stream_to_text_async(http_res)
251
- raise errors.APIError(
252
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
253
- http_res.status_code,
254
- http_res_text,
255
- http_res,
256
- )
238
+ raise errors.APIError("Unexpected response received", http_res)
257
239
 
258
240
  def create(
259
241
  self,
@@ -365,51 +347,42 @@ class Collections(BaseSDK):
365
347
 
366
348
  response_data: Any = None
367
349
  if utils.match_response(http_res, "202", "application/json"):
368
- return utils.unmarshal_json(http_res.text, models.CreateCollectionResponse)
350
+ return utils.unmarshal_json_response(
351
+ models.CreateCollectionResponse, http_res
352
+ )
369
353
  if utils.match_response(http_res, "400", "application/json"):
370
- response_data = utils.unmarshal_json(
371
- http_res.text, errors.BadRequestErrorData
354
+ response_data = utils.unmarshal_json_response(
355
+ errors.BadRequestErrorData, http_res
372
356
  )
373
- raise errors.BadRequestError(data=response_data)
357
+ raise errors.BadRequestError(response_data, http_res)
374
358
  if utils.match_response(http_res, "401", "application/json"):
375
- response_data = utils.unmarshal_json(
376
- http_res.text, errors.UnauthenticatedErrorData
359
+ response_data = utils.unmarshal_json_response(
360
+ errors.UnauthenticatedErrorData, http_res
377
361
  )
378
- raise errors.UnauthenticatedError(data=response_data)
362
+ raise errors.UnauthenticatedError(response_data, http_res)
379
363
  if utils.match_response(http_res, "409", "application/json"):
380
- response_data = utils.unmarshal_json(
381
- http_res.text, errors.ResourceAlreadyExistsErrorData
364
+ response_data = utils.unmarshal_json_response(
365
+ errors.ResourceAlreadyExistsErrorData, http_res
382
366
  )
383
- raise errors.ResourceAlreadyExistsError(data=response_data)
367
+ raise errors.ResourceAlreadyExistsError(response_data, http_res)
384
368
  if utils.match_response(http_res, "429", "application/json"):
385
- response_data = utils.unmarshal_json(
386
- http_res.text, errors.TooManyRequestsErrorData
369
+ response_data = utils.unmarshal_json_response(
370
+ errors.TooManyRequestsErrorData, http_res
387
371
  )
388
- raise errors.TooManyRequestsError(data=response_data)
372
+ raise errors.TooManyRequestsError(response_data, http_res)
389
373
  if utils.match_response(http_res, "500", "application/json"):
390
- response_data = utils.unmarshal_json(
391
- http_res.text, errors.InternalServerErrorData
374
+ response_data = utils.unmarshal_json_response(
375
+ errors.InternalServerErrorData, http_res
392
376
  )
393
- raise errors.InternalServerError(data=response_data)
377
+ raise errors.InternalServerError(response_data, http_res)
394
378
  if utils.match_response(http_res, "4XX", "*"):
395
379
  http_res_text = utils.stream_to_text(http_res)
396
- raise errors.APIError(
397
- "API error occurred", http_res.status_code, http_res_text, http_res
398
- )
380
+ raise errors.APIError("API error occurred", http_res, http_res_text)
399
381
  if utils.match_response(http_res, "5XX", "*"):
400
382
  http_res_text = utils.stream_to_text(http_res)
401
- raise errors.APIError(
402
- "API error occurred", http_res.status_code, http_res_text, http_res
403
- )
383
+ raise errors.APIError("API error occurred", http_res, http_res_text)
404
384
 
405
- content_type = http_res.headers.get("Content-Type")
406
- http_res_text = utils.stream_to_text(http_res)
407
- raise errors.APIError(
408
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
409
- http_res.status_code,
410
- http_res_text,
411
- http_res,
412
- )
385
+ raise errors.APIError("Unexpected response received", http_res)
413
386
 
414
387
  async def create_async(
415
388
  self,
@@ -521,51 +494,42 @@ class Collections(BaseSDK):
521
494
 
522
495
  response_data: Any = None
523
496
  if utils.match_response(http_res, "202", "application/json"):
524
- return utils.unmarshal_json(http_res.text, models.CreateCollectionResponse)
497
+ return utils.unmarshal_json_response(
498
+ models.CreateCollectionResponse, http_res
499
+ )
525
500
  if utils.match_response(http_res, "400", "application/json"):
526
- response_data = utils.unmarshal_json(
527
- http_res.text, errors.BadRequestErrorData
501
+ response_data = utils.unmarshal_json_response(
502
+ errors.BadRequestErrorData, http_res
528
503
  )
529
- raise errors.BadRequestError(data=response_data)
504
+ raise errors.BadRequestError(response_data, http_res)
530
505
  if utils.match_response(http_res, "401", "application/json"):
531
- response_data = utils.unmarshal_json(
532
- http_res.text, errors.UnauthenticatedErrorData
506
+ response_data = utils.unmarshal_json_response(
507
+ errors.UnauthenticatedErrorData, http_res
533
508
  )
534
- raise errors.UnauthenticatedError(data=response_data)
509
+ raise errors.UnauthenticatedError(response_data, http_res)
535
510
  if utils.match_response(http_res, "409", "application/json"):
536
- response_data = utils.unmarshal_json(
537
- http_res.text, errors.ResourceAlreadyExistsErrorData
511
+ response_data = utils.unmarshal_json_response(
512
+ errors.ResourceAlreadyExistsErrorData, http_res
538
513
  )
539
- raise errors.ResourceAlreadyExistsError(data=response_data)
514
+ raise errors.ResourceAlreadyExistsError(response_data, http_res)
540
515
  if utils.match_response(http_res, "429", "application/json"):
541
- response_data = utils.unmarshal_json(
542
- http_res.text, errors.TooManyRequestsErrorData
516
+ response_data = utils.unmarshal_json_response(
517
+ errors.TooManyRequestsErrorData, http_res
543
518
  )
544
- raise errors.TooManyRequestsError(data=response_data)
519
+ raise errors.TooManyRequestsError(response_data, http_res)
545
520
  if utils.match_response(http_res, "500", "application/json"):
546
- response_data = utils.unmarshal_json(
547
- http_res.text, errors.InternalServerErrorData
521
+ response_data = utils.unmarshal_json_response(
522
+ errors.InternalServerErrorData, http_res
548
523
  )
549
- raise errors.InternalServerError(data=response_data)
524
+ raise errors.InternalServerError(response_data, http_res)
550
525
  if utils.match_response(http_res, "4XX", "*"):
551
526
  http_res_text = await utils.stream_to_text_async(http_res)
552
- raise errors.APIError(
553
- "API error occurred", http_res.status_code, http_res_text, http_res
554
- )
527
+ raise errors.APIError("API error occurred", http_res, http_res_text)
555
528
  if utils.match_response(http_res, "5XX", "*"):
556
529
  http_res_text = await utils.stream_to_text_async(http_res)
557
- raise errors.APIError(
558
- "API error occurred", http_res.status_code, http_res_text, http_res
559
- )
530
+ raise errors.APIError("API error occurred", http_res, http_res_text)
560
531
 
561
- content_type = http_res.headers.get("Content-Type")
562
- http_res_text = await utils.stream_to_text_async(http_res)
563
- raise errors.APIError(
564
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
565
- http_res.status_code,
566
- http_res_text,
567
- http_res,
568
- )
532
+ raise errors.APIError("Unexpected response received", http_res)
569
533
 
570
534
  def delete(
571
535
  self,
@@ -646,46 +610,35 @@ class Collections(BaseSDK):
646
610
 
647
611
  response_data: Any = None
648
612
  if utils.match_response(http_res, "202", "application/json"):
649
- return utils.unmarshal_json(http_res.text, models.MessageResponse)
613
+ return utils.unmarshal_json_response(models.MessageResponse, http_res)
650
614
  if utils.match_response(http_res, "401", "application/json"):
651
- response_data = utils.unmarshal_json(
652
- http_res.text, errors.UnauthenticatedErrorData
615
+ response_data = utils.unmarshal_json_response(
616
+ errors.UnauthenticatedErrorData, http_res
653
617
  )
654
- raise errors.UnauthenticatedError(data=response_data)
618
+ raise errors.UnauthenticatedError(response_data, http_res)
655
619
  if utils.match_response(http_res, "404", "application/json"):
656
- response_data = utils.unmarshal_json(
657
- http_res.text, errors.ResourceNotFoundErrorData
620
+ response_data = utils.unmarshal_json_response(
621
+ errors.ResourceNotFoundErrorData, http_res
658
622
  )
659
- raise errors.ResourceNotFoundError(data=response_data)
623
+ raise errors.ResourceNotFoundError(response_data, http_res)
660
624
  if utils.match_response(http_res, "429", "application/json"):
661
- response_data = utils.unmarshal_json(
662
- http_res.text, errors.TooManyRequestsErrorData
625
+ response_data = utils.unmarshal_json_response(
626
+ errors.TooManyRequestsErrorData, http_res
663
627
  )
664
- raise errors.TooManyRequestsError(data=response_data)
628
+ raise errors.TooManyRequestsError(response_data, http_res)
665
629
  if utils.match_response(http_res, "500", "application/json"):
666
- response_data = utils.unmarshal_json(
667
- http_res.text, errors.InternalServerErrorData
630
+ response_data = utils.unmarshal_json_response(
631
+ errors.InternalServerErrorData, http_res
668
632
  )
669
- raise errors.InternalServerError(data=response_data)
633
+ raise errors.InternalServerError(response_data, http_res)
670
634
  if utils.match_response(http_res, "4XX", "*"):
671
635
  http_res_text = utils.stream_to_text(http_res)
672
- raise errors.APIError(
673
- "API error occurred", http_res.status_code, http_res_text, http_res
674
- )
636
+ raise errors.APIError("API error occurred", http_res, http_res_text)
675
637
  if utils.match_response(http_res, "5XX", "*"):
676
638
  http_res_text = utils.stream_to_text(http_res)
677
- raise errors.APIError(
678
- "API error occurred", http_res.status_code, http_res_text, http_res
679
- )
639
+ raise errors.APIError("API error occurred", http_res, http_res_text)
680
640
 
681
- content_type = http_res.headers.get("Content-Type")
682
- http_res_text = utils.stream_to_text(http_res)
683
- raise errors.APIError(
684
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
685
- http_res.status_code,
686
- http_res_text,
687
- http_res,
688
- )
641
+ raise errors.APIError("Unexpected response received", http_res)
689
642
 
690
643
  async def delete_async(
691
644
  self,
@@ -766,46 +719,35 @@ class Collections(BaseSDK):
766
719
 
767
720
  response_data: Any = None
768
721
  if utils.match_response(http_res, "202", "application/json"):
769
- return utils.unmarshal_json(http_res.text, models.MessageResponse)
722
+ return utils.unmarshal_json_response(models.MessageResponse, http_res)
770
723
  if utils.match_response(http_res, "401", "application/json"):
771
- response_data = utils.unmarshal_json(
772
- http_res.text, errors.UnauthenticatedErrorData
724
+ response_data = utils.unmarshal_json_response(
725
+ errors.UnauthenticatedErrorData, http_res
773
726
  )
774
- raise errors.UnauthenticatedError(data=response_data)
727
+ raise errors.UnauthenticatedError(response_data, http_res)
775
728
  if utils.match_response(http_res, "404", "application/json"):
776
- response_data = utils.unmarshal_json(
777
- http_res.text, errors.ResourceNotFoundErrorData
729
+ response_data = utils.unmarshal_json_response(
730
+ errors.ResourceNotFoundErrorData, http_res
778
731
  )
779
- raise errors.ResourceNotFoundError(data=response_data)
732
+ raise errors.ResourceNotFoundError(response_data, http_res)
780
733
  if utils.match_response(http_res, "429", "application/json"):
781
- response_data = utils.unmarshal_json(
782
- http_res.text, errors.TooManyRequestsErrorData
734
+ response_data = utils.unmarshal_json_response(
735
+ errors.TooManyRequestsErrorData, http_res
783
736
  )
784
- raise errors.TooManyRequestsError(data=response_data)
737
+ raise errors.TooManyRequestsError(response_data, http_res)
785
738
  if utils.match_response(http_res, "500", "application/json"):
786
- response_data = utils.unmarshal_json(
787
- http_res.text, errors.InternalServerErrorData
739
+ response_data = utils.unmarshal_json_response(
740
+ errors.InternalServerErrorData, http_res
788
741
  )
789
- raise errors.InternalServerError(data=response_data)
742
+ raise errors.InternalServerError(response_data, http_res)
790
743
  if utils.match_response(http_res, "4XX", "*"):
791
744
  http_res_text = await utils.stream_to_text_async(http_res)
792
- raise errors.APIError(
793
- "API error occurred", http_res.status_code, http_res_text, http_res
794
- )
745
+ raise errors.APIError("API error occurred", http_res, http_res_text)
795
746
  if utils.match_response(http_res, "5XX", "*"):
796
747
  http_res_text = await utils.stream_to_text_async(http_res)
797
- raise errors.APIError(
798
- "API error occurred", http_res.status_code, http_res_text, http_res
799
- )
748
+ raise errors.APIError("API error occurred", http_res, http_res_text)
800
749
 
801
- content_type = http_res.headers.get("Content-Type")
802
- http_res_text = await utils.stream_to_text_async(http_res)
803
- raise errors.APIError(
804
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
805
- http_res.status_code,
806
- http_res_text,
807
- http_res,
808
- )
750
+ raise errors.APIError("Unexpected response received", http_res)
809
751
 
810
752
  def get(
811
753
  self,
@@ -886,46 +828,35 @@ class Collections(BaseSDK):
886
828
 
887
829
  response_data: Any = None
888
830
  if utils.match_response(http_res, "200", "application/json"):
889
- return utils.unmarshal_json(http_res.text, models.GetCollectionResponse)
831
+ return utils.unmarshal_json_response(models.GetCollectionResponse, http_res)
890
832
  if utils.match_response(http_res, "401", "application/json"):
891
- response_data = utils.unmarshal_json(
892
- http_res.text, errors.UnauthenticatedErrorData
833
+ response_data = utils.unmarshal_json_response(
834
+ errors.UnauthenticatedErrorData, http_res
893
835
  )
894
- raise errors.UnauthenticatedError(data=response_data)
836
+ raise errors.UnauthenticatedError(response_data, http_res)
895
837
  if utils.match_response(http_res, "404", "application/json"):
896
- response_data = utils.unmarshal_json(
897
- http_res.text, errors.ResourceNotFoundErrorData
838
+ response_data = utils.unmarshal_json_response(
839
+ errors.ResourceNotFoundErrorData, http_res
898
840
  )
899
- raise errors.ResourceNotFoundError(data=response_data)
841
+ raise errors.ResourceNotFoundError(response_data, http_res)
900
842
  if utils.match_response(http_res, "429", "application/json"):
901
- response_data = utils.unmarshal_json(
902
- http_res.text, errors.TooManyRequestsErrorData
843
+ response_data = utils.unmarshal_json_response(
844
+ errors.TooManyRequestsErrorData, http_res
903
845
  )
904
- raise errors.TooManyRequestsError(data=response_data)
846
+ raise errors.TooManyRequestsError(response_data, http_res)
905
847
  if utils.match_response(http_res, "500", "application/json"):
906
- response_data = utils.unmarshal_json(
907
- http_res.text, errors.InternalServerErrorData
848
+ response_data = utils.unmarshal_json_response(
849
+ errors.InternalServerErrorData, http_res
908
850
  )
909
- raise errors.InternalServerError(data=response_data)
851
+ raise errors.InternalServerError(response_data, http_res)
910
852
  if utils.match_response(http_res, "4XX", "*"):
911
853
  http_res_text = utils.stream_to_text(http_res)
912
- raise errors.APIError(
913
- "API error occurred", http_res.status_code, http_res_text, http_res
914
- )
854
+ raise errors.APIError("API error occurred", http_res, http_res_text)
915
855
  if utils.match_response(http_res, "5XX", "*"):
916
856
  http_res_text = utils.stream_to_text(http_res)
917
- raise errors.APIError(
918
- "API error occurred", http_res.status_code, http_res_text, http_res
919
- )
857
+ raise errors.APIError("API error occurred", http_res, http_res_text)
920
858
 
921
- content_type = http_res.headers.get("Content-Type")
922
- http_res_text = utils.stream_to_text(http_res)
923
- raise errors.APIError(
924
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
925
- http_res.status_code,
926
- http_res_text,
927
- http_res,
928
- )
859
+ raise errors.APIError("Unexpected response received", http_res)
929
860
 
930
861
  async def get_async(
931
862
  self,
@@ -1006,46 +937,35 @@ class Collections(BaseSDK):
1006
937
 
1007
938
  response_data: Any = None
1008
939
  if utils.match_response(http_res, "200", "application/json"):
1009
- return utils.unmarshal_json(http_res.text, models.GetCollectionResponse)
940
+ return utils.unmarshal_json_response(models.GetCollectionResponse, http_res)
1010
941
  if utils.match_response(http_res, "401", "application/json"):
1011
- response_data = utils.unmarshal_json(
1012
- http_res.text, errors.UnauthenticatedErrorData
942
+ response_data = utils.unmarshal_json_response(
943
+ errors.UnauthenticatedErrorData, http_res
1013
944
  )
1014
- raise errors.UnauthenticatedError(data=response_data)
945
+ raise errors.UnauthenticatedError(response_data, http_res)
1015
946
  if utils.match_response(http_res, "404", "application/json"):
1016
- response_data = utils.unmarshal_json(
1017
- http_res.text, errors.ResourceNotFoundErrorData
947
+ response_data = utils.unmarshal_json_response(
948
+ errors.ResourceNotFoundErrorData, http_res
1018
949
  )
1019
- raise errors.ResourceNotFoundError(data=response_data)
950
+ raise errors.ResourceNotFoundError(response_data, http_res)
1020
951
  if utils.match_response(http_res, "429", "application/json"):
1021
- response_data = utils.unmarshal_json(
1022
- http_res.text, errors.TooManyRequestsErrorData
952
+ response_data = utils.unmarshal_json_response(
953
+ errors.TooManyRequestsErrorData, http_res
1023
954
  )
1024
- raise errors.TooManyRequestsError(data=response_data)
955
+ raise errors.TooManyRequestsError(response_data, http_res)
1025
956
  if utils.match_response(http_res, "500", "application/json"):
1026
- response_data = utils.unmarshal_json(
1027
- http_res.text, errors.InternalServerErrorData
957
+ response_data = utils.unmarshal_json_response(
958
+ errors.InternalServerErrorData, http_res
1028
959
  )
1029
- raise errors.InternalServerError(data=response_data)
960
+ raise errors.InternalServerError(response_data, http_res)
1030
961
  if utils.match_response(http_res, "4XX", "*"):
1031
962
  http_res_text = await utils.stream_to_text_async(http_res)
1032
- raise errors.APIError(
1033
- "API error occurred", http_res.status_code, http_res_text, http_res
1034
- )
963
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1035
964
  if utils.match_response(http_res, "5XX", "*"):
1036
965
  http_res_text = await utils.stream_to_text_async(http_res)
1037
- raise errors.APIError(
1038
- "API error occurred", http_res.status_code, http_res_text, http_res
1039
- )
966
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1040
967
 
1041
- content_type = http_res.headers.get("Content-Type")
1042
- http_res_text = await utils.stream_to_text_async(http_res)
1043
- raise errors.APIError(
1044
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1045
- http_res.status_code,
1046
- http_res_text,
1047
- http_res,
1048
- )
968
+ raise errors.APIError("Unexpected response received", http_res)
1049
969
 
1050
970
  def update(
1051
971
  self,
@@ -1143,51 +1063,42 @@ class Collections(BaseSDK):
1143
1063
 
1144
1064
  response_data: Any = None
1145
1065
  if utils.match_response(http_res, "200", "application/json"):
1146
- return utils.unmarshal_json(http_res.text, models.UpdateCollectionResponse)
1066
+ return utils.unmarshal_json_response(
1067
+ models.UpdateCollectionResponse, http_res
1068
+ )
1147
1069
  if utils.match_response(http_res, "400", "application/json"):
1148
- response_data = utils.unmarshal_json(
1149
- http_res.text, errors.BadRequestErrorData
1070
+ response_data = utils.unmarshal_json_response(
1071
+ errors.BadRequestErrorData, http_res
1150
1072
  )
1151
- raise errors.BadRequestError(data=response_data)
1073
+ raise errors.BadRequestError(response_data, http_res)
1152
1074
  if utils.match_response(http_res, "401", "application/json"):
1153
- response_data = utils.unmarshal_json(
1154
- http_res.text, errors.UnauthenticatedErrorData
1075
+ response_data = utils.unmarshal_json_response(
1076
+ errors.UnauthenticatedErrorData, http_res
1155
1077
  )
1156
- raise errors.UnauthenticatedError(data=response_data)
1078
+ raise errors.UnauthenticatedError(response_data, http_res)
1157
1079
  if utils.match_response(http_res, "404", "application/json"):
1158
- response_data = utils.unmarshal_json(
1159
- http_res.text, errors.ResourceNotFoundErrorData
1080
+ response_data = utils.unmarshal_json_response(
1081
+ errors.ResourceNotFoundErrorData, http_res
1160
1082
  )
1161
- raise errors.ResourceNotFoundError(data=response_data)
1083
+ raise errors.ResourceNotFoundError(response_data, http_res)
1162
1084
  if utils.match_response(http_res, "429", "application/json"):
1163
- response_data = utils.unmarshal_json(
1164
- http_res.text, errors.TooManyRequestsErrorData
1085
+ response_data = utils.unmarshal_json_response(
1086
+ errors.TooManyRequestsErrorData, http_res
1165
1087
  )
1166
- raise errors.TooManyRequestsError(data=response_data)
1088
+ raise errors.TooManyRequestsError(response_data, http_res)
1167
1089
  if utils.match_response(http_res, "500", "application/json"):
1168
- response_data = utils.unmarshal_json(
1169
- http_res.text, errors.InternalServerErrorData
1090
+ response_data = utils.unmarshal_json_response(
1091
+ errors.InternalServerErrorData, http_res
1170
1092
  )
1171
- raise errors.InternalServerError(data=response_data)
1093
+ raise errors.InternalServerError(response_data, http_res)
1172
1094
  if utils.match_response(http_res, "4XX", "*"):
1173
1095
  http_res_text = utils.stream_to_text(http_res)
1174
- raise errors.APIError(
1175
- "API error occurred", http_res.status_code, http_res_text, http_res
1176
- )
1096
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1177
1097
  if utils.match_response(http_res, "5XX", "*"):
1178
1098
  http_res_text = utils.stream_to_text(http_res)
1179
- raise errors.APIError(
1180
- "API error occurred", http_res.status_code, http_res_text, http_res
1181
- )
1099
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1182
1100
 
1183
- content_type = http_res.headers.get("Content-Type")
1184
- http_res_text = utils.stream_to_text(http_res)
1185
- raise errors.APIError(
1186
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1187
- http_res.status_code,
1188
- http_res_text,
1189
- http_res,
1190
- )
1101
+ raise errors.APIError("Unexpected response received", http_res)
1191
1102
 
1192
1103
  async def update_async(
1193
1104
  self,
@@ -1285,51 +1196,42 @@ class Collections(BaseSDK):
1285
1196
 
1286
1197
  response_data: Any = None
1287
1198
  if utils.match_response(http_res, "200", "application/json"):
1288
- return utils.unmarshal_json(http_res.text, models.UpdateCollectionResponse)
1199
+ return utils.unmarshal_json_response(
1200
+ models.UpdateCollectionResponse, http_res
1201
+ )
1289
1202
  if utils.match_response(http_res, "400", "application/json"):
1290
- response_data = utils.unmarshal_json(
1291
- http_res.text, errors.BadRequestErrorData
1203
+ response_data = utils.unmarshal_json_response(
1204
+ errors.BadRequestErrorData, http_res
1292
1205
  )
1293
- raise errors.BadRequestError(data=response_data)
1206
+ raise errors.BadRequestError(response_data, http_res)
1294
1207
  if utils.match_response(http_res, "401", "application/json"):
1295
- response_data = utils.unmarshal_json(
1296
- http_res.text, errors.UnauthenticatedErrorData
1208
+ response_data = utils.unmarshal_json_response(
1209
+ errors.UnauthenticatedErrorData, http_res
1297
1210
  )
1298
- raise errors.UnauthenticatedError(data=response_data)
1211
+ raise errors.UnauthenticatedError(response_data, http_res)
1299
1212
  if utils.match_response(http_res, "404", "application/json"):
1300
- response_data = utils.unmarshal_json(
1301
- http_res.text, errors.ResourceNotFoundErrorData
1213
+ response_data = utils.unmarshal_json_response(
1214
+ errors.ResourceNotFoundErrorData, http_res
1302
1215
  )
1303
- raise errors.ResourceNotFoundError(data=response_data)
1216
+ raise errors.ResourceNotFoundError(response_data, http_res)
1304
1217
  if utils.match_response(http_res, "429", "application/json"):
1305
- response_data = utils.unmarshal_json(
1306
- http_res.text, errors.TooManyRequestsErrorData
1218
+ response_data = utils.unmarshal_json_response(
1219
+ errors.TooManyRequestsErrorData, http_res
1307
1220
  )
1308
- raise errors.TooManyRequestsError(data=response_data)
1221
+ raise errors.TooManyRequestsError(response_data, http_res)
1309
1222
  if utils.match_response(http_res, "500", "application/json"):
1310
- response_data = utils.unmarshal_json(
1311
- http_res.text, errors.InternalServerErrorData
1223
+ response_data = utils.unmarshal_json_response(
1224
+ errors.InternalServerErrorData, http_res
1312
1225
  )
1313
- raise errors.InternalServerError(data=response_data)
1226
+ raise errors.InternalServerError(response_data, http_res)
1314
1227
  if utils.match_response(http_res, "4XX", "*"):
1315
1228
  http_res_text = await utils.stream_to_text_async(http_res)
1316
- raise errors.APIError(
1317
- "API error occurred", http_res.status_code, http_res_text, http_res
1318
- )
1229
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1319
1230
  if utils.match_response(http_res, "5XX", "*"):
1320
1231
  http_res_text = await utils.stream_to_text_async(http_res)
1321
- raise errors.APIError(
1322
- "API error occurred", http_res.status_code, http_res_text, http_res
1323
- )
1232
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1324
1233
 
1325
- content_type = http_res.headers.get("Content-Type")
1326
- http_res_text = await utils.stream_to_text_async(http_res)
1327
- raise errors.APIError(
1328
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1329
- http_res.status_code,
1330
- http_res_text,
1331
- http_res,
1332
- )
1234
+ raise errors.APIError("Unexpected response received", http_res)
1333
1235
 
1334
1236
  def query(
1335
1237
  self,
@@ -1337,10 +1239,10 @@ class Collections(BaseSDK):
1337
1239
  project_name: str,
1338
1240
  collection_name: str,
1339
1241
  size: int,
1340
- query: Optional[Union[models.Query, models.QueryTypedDict]] = None,
1242
+ query: Optional[Dict[str, Any]] = None,
1341
1243
  consistent_read: Optional[bool] = False,
1342
1244
  include_vectors: Optional[bool] = False,
1343
- sort: Optional[Union[List[models.Sort], List[models.SortTypedDict]]] = None,
1245
+ sort: Optional[List[Dict[str, Any]]] = None,
1344
1246
  fields: Optional[List[str]] = None,
1345
1247
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
1346
1248
  server_url: Optional[str] = None,
@@ -1377,10 +1279,10 @@ class Collections(BaseSDK):
1377
1279
  collection_name=collection_name,
1378
1280
  request_body=models.QueryCollectionRequestBody(
1379
1281
  size=size,
1380
- query=utils.get_pydantic_model(query, Optional[models.Query]),
1282
+ query=query,
1381
1283
  consistent_read=consistent_read,
1382
1284
  include_vectors=include_vectors,
1383
- sort=utils.get_pydantic_model(sort, Optional[List[models.Sort]]),
1285
+ sort=sort,
1384
1286
  fields=fields,
1385
1287
  ),
1386
1288
  )
@@ -1437,51 +1339,42 @@ class Collections(BaseSDK):
1437
1339
 
1438
1340
  response_data: Any = None
1439
1341
  if utils.match_response(http_res, "200", "application/json"):
1440
- return utils.unmarshal_json(http_res.text, models.QueryCollectionResponse)
1342
+ return utils.unmarshal_json_response(
1343
+ models.QueryCollectionResponse, http_res
1344
+ )
1441
1345
  if utils.match_response(http_res, "400", "application/json"):
1442
- response_data = utils.unmarshal_json(
1443
- http_res.text, errors.BadRequestErrorData
1346
+ response_data = utils.unmarshal_json_response(
1347
+ errors.BadRequestErrorData, http_res
1444
1348
  )
1445
- raise errors.BadRequestError(data=response_data)
1349
+ raise errors.BadRequestError(response_data, http_res)
1446
1350
  if utils.match_response(http_res, "401", "application/json"):
1447
- response_data = utils.unmarshal_json(
1448
- http_res.text, errors.UnauthenticatedErrorData
1351
+ response_data = utils.unmarshal_json_response(
1352
+ errors.UnauthenticatedErrorData, http_res
1449
1353
  )
1450
- raise errors.UnauthenticatedError(data=response_data)
1354
+ raise errors.UnauthenticatedError(response_data, http_res)
1451
1355
  if utils.match_response(http_res, "404", "application/json"):
1452
- response_data = utils.unmarshal_json(
1453
- http_res.text, errors.ResourceNotFoundErrorData
1356
+ response_data = utils.unmarshal_json_response(
1357
+ errors.ResourceNotFoundErrorData, http_res
1454
1358
  )
1455
- raise errors.ResourceNotFoundError(data=response_data)
1359
+ raise errors.ResourceNotFoundError(response_data, http_res)
1456
1360
  if utils.match_response(http_res, "429", "application/json"):
1457
- response_data = utils.unmarshal_json(
1458
- http_res.text, errors.TooManyRequestsErrorData
1361
+ response_data = utils.unmarshal_json_response(
1362
+ errors.TooManyRequestsErrorData, http_res
1459
1363
  )
1460
- raise errors.TooManyRequestsError(data=response_data)
1364
+ raise errors.TooManyRequestsError(response_data, http_res)
1461
1365
  if utils.match_response(http_res, "500", "application/json"):
1462
- response_data = utils.unmarshal_json(
1463
- http_res.text, errors.InternalServerErrorData
1366
+ response_data = utils.unmarshal_json_response(
1367
+ errors.InternalServerErrorData, http_res
1464
1368
  )
1465
- raise errors.InternalServerError(data=response_data)
1369
+ raise errors.InternalServerError(response_data, http_res)
1466
1370
  if utils.match_response(http_res, "4XX", "*"):
1467
1371
  http_res_text = utils.stream_to_text(http_res)
1468
- raise errors.APIError(
1469
- "API error occurred", http_res.status_code, http_res_text, http_res
1470
- )
1372
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1471
1373
  if utils.match_response(http_res, "5XX", "*"):
1472
1374
  http_res_text = utils.stream_to_text(http_res)
1473
- raise errors.APIError(
1474
- "API error occurred", http_res.status_code, http_res_text, http_res
1475
- )
1375
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1476
1376
 
1477
- content_type = http_res.headers.get("Content-Type")
1478
- http_res_text = utils.stream_to_text(http_res)
1479
- raise errors.APIError(
1480
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1481
- http_res.status_code,
1482
- http_res_text,
1483
- http_res,
1484
- )
1377
+ raise errors.APIError("Unexpected response received", http_res)
1485
1378
 
1486
1379
  async def query_async(
1487
1380
  self,
@@ -1489,10 +1382,10 @@ class Collections(BaseSDK):
1489
1382
  project_name: str,
1490
1383
  collection_name: str,
1491
1384
  size: int,
1492
- query: Optional[Union[models.Query, models.QueryTypedDict]] = None,
1385
+ query: Optional[Dict[str, Any]] = None,
1493
1386
  consistent_read: Optional[bool] = False,
1494
1387
  include_vectors: Optional[bool] = False,
1495
- sort: Optional[Union[List[models.Sort], List[models.SortTypedDict]]] = None,
1388
+ sort: Optional[List[Dict[str, Any]]] = None,
1496
1389
  fields: Optional[List[str]] = None,
1497
1390
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
1498
1391
  server_url: Optional[str] = None,
@@ -1529,10 +1422,10 @@ class Collections(BaseSDK):
1529
1422
  collection_name=collection_name,
1530
1423
  request_body=models.QueryCollectionRequestBody(
1531
1424
  size=size,
1532
- query=utils.get_pydantic_model(query, Optional[models.Query]),
1425
+ query=query,
1533
1426
  consistent_read=consistent_read,
1534
1427
  include_vectors=include_vectors,
1535
- sort=utils.get_pydantic_model(sort, Optional[List[models.Sort]]),
1428
+ sort=sort,
1536
1429
  fields=fields,
1537
1430
  ),
1538
1431
  )
@@ -1589,48 +1482,39 @@ class Collections(BaseSDK):
1589
1482
 
1590
1483
  response_data: Any = None
1591
1484
  if utils.match_response(http_res, "200", "application/json"):
1592
- return utils.unmarshal_json(http_res.text, models.QueryCollectionResponse)
1485
+ return utils.unmarshal_json_response(
1486
+ models.QueryCollectionResponse, http_res
1487
+ )
1593
1488
  if utils.match_response(http_res, "400", "application/json"):
1594
- response_data = utils.unmarshal_json(
1595
- http_res.text, errors.BadRequestErrorData
1489
+ response_data = utils.unmarshal_json_response(
1490
+ errors.BadRequestErrorData, http_res
1596
1491
  )
1597
- raise errors.BadRequestError(data=response_data)
1492
+ raise errors.BadRequestError(response_data, http_res)
1598
1493
  if utils.match_response(http_res, "401", "application/json"):
1599
- response_data = utils.unmarshal_json(
1600
- http_res.text, errors.UnauthenticatedErrorData
1494
+ response_data = utils.unmarshal_json_response(
1495
+ errors.UnauthenticatedErrorData, http_res
1601
1496
  )
1602
- raise errors.UnauthenticatedError(data=response_data)
1497
+ raise errors.UnauthenticatedError(response_data, http_res)
1603
1498
  if utils.match_response(http_res, "404", "application/json"):
1604
- response_data = utils.unmarshal_json(
1605
- http_res.text, errors.ResourceNotFoundErrorData
1499
+ response_data = utils.unmarshal_json_response(
1500
+ errors.ResourceNotFoundErrorData, http_res
1606
1501
  )
1607
- raise errors.ResourceNotFoundError(data=response_data)
1502
+ raise errors.ResourceNotFoundError(response_data, http_res)
1608
1503
  if utils.match_response(http_res, "429", "application/json"):
1609
- response_data = utils.unmarshal_json(
1610
- http_res.text, errors.TooManyRequestsErrorData
1504
+ response_data = utils.unmarshal_json_response(
1505
+ errors.TooManyRequestsErrorData, http_res
1611
1506
  )
1612
- raise errors.TooManyRequestsError(data=response_data)
1507
+ raise errors.TooManyRequestsError(response_data, http_res)
1613
1508
  if utils.match_response(http_res, "500", "application/json"):
1614
- response_data = utils.unmarshal_json(
1615
- http_res.text, errors.InternalServerErrorData
1509
+ response_data = utils.unmarshal_json_response(
1510
+ errors.InternalServerErrorData, http_res
1616
1511
  )
1617
- raise errors.InternalServerError(data=response_data)
1512
+ raise errors.InternalServerError(response_data, http_res)
1618
1513
  if utils.match_response(http_res, "4XX", "*"):
1619
1514
  http_res_text = await utils.stream_to_text_async(http_res)
1620
- raise errors.APIError(
1621
- "API error occurred", http_res.status_code, http_res_text, http_res
1622
- )
1515
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1623
1516
  if utils.match_response(http_res, "5XX", "*"):
1624
1517
  http_res_text = await utils.stream_to_text_async(http_res)
1625
- raise errors.APIError(
1626
- "API error occurred", http_res.status_code, http_res_text, http_res
1627
- )
1518
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1628
1519
 
1629
- content_type = http_res.headers.get("Content-Type")
1630
- http_res_text = await utils.stream_to_text_async(http_res)
1631
- raise errors.APIError(
1632
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1633
- http_res.status_code,
1634
- http_res_text,
1635
- http_res,
1636
- )
1520
+ raise errors.APIError("Unexpected response received", http_res)