@@ -153,7 +153,6 @@ def read( # pylint:disable=docstring-missing-param
153
153
:rtype: dict[str, Any]
154
154
"""
155
155
request_options = build_options (kwargs )
156
- response_hook = kwargs .pop ('response_hook' , None )
157
156
if populate_query_metrics :
158
157
warnings .warn (
159
158
"the populate_query_metrics flag does not apply to this method and will be removed in the future" ,
@@ -167,8 +166,6 @@ def read( # pylint:disable=docstring-missing-param
167
166
self ._properties = self .client_connection .ReadContainer (
168
167
collection_link , options = request_options , ** kwargs
169
168
)
170
- if response_hook :
171
- response_hook (self .client_connection .last_response_headers , self ._properties )
172
169
return self ._properties
173
170
174
171
@distributed_trace
@@ -211,7 +208,6 @@ def read_item( # pylint:disable=docstring-missing-param
211
208
"""
212
209
doc_link = self ._get_document_link (item )
213
210
request_options = build_options (kwargs )
214
- response_hook = kwargs .pop ('response_hook' , None )
215
211
216
212
if partition_key is not None :
217
213
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
@@ -229,10 +225,7 @@ def read_item( # pylint:disable=docstring-missing-param
229
225
validate_cache_staleness_value (max_integrated_cache_staleness_in_ms )
230
226
request_options ["maxIntegratedCacheStaleness" ] = max_integrated_cache_staleness_in_ms
231
227
232
- result = self .client_connection .ReadItem (document_link = doc_link , options = request_options , ** kwargs )
233
- if response_hook :
234
- response_hook (self .client_connection .last_response_headers , result )
235
- return result
228
+ return self .client_connection .ReadItem (document_link = doc_link , options = request_options , ** kwargs )
236
229
237
230
@distributed_trace
238
231
def read_all_items ( # pylint:disable=docstring-missing-param
@@ -275,8 +268,7 @@ def read_all_items( # pylint:disable=docstring-missing-param
275
268
response_hook .clear ()
276
269
277
270
items = self .client_connection .ReadItems (
278
- collection_link = self .container_link , feed_options = feed_options , response_hook = response_hook , ** kwargs
279
- )
271
+ collection_link = self .container_link , feed_options = feed_options , response_hook = response_hook , ** kwargs )
280
272
if response_hook :
281
273
response_hook (self .client_connection .last_response_headers , items )
282
274
return items
@@ -494,7 +486,6 @@ def replace_item( # pylint:disable=docstring-missing-param
494
486
"""
495
487
item_link = self ._get_document_link (item )
496
488
request_options = build_options (kwargs )
497
- response_hook = kwargs .pop ('response_hook' , None )
498
489
request_options ["disableAutomaticIdGeneration" ] = True
499
490
if populate_query_metrics is not None :
500
491
warnings .warn (
@@ -507,12 +498,9 @@ def replace_item( # pylint:disable=docstring-missing-param
507
498
if post_trigger_include is not None :
508
499
request_options ["postTriggerInclude" ] = post_trigger_include
509
500
510
- result = self .client_connection .ReplaceItem (
501
+ return self .client_connection .ReplaceItem (
511
502
document_link = item_link , new_document = body , options = request_options , ** kwargs
512
503
)
513
- if response_hook :
514
- response_hook (self .client_connection .last_response_headers , result )
515
- return result
516
504
517
505
@distributed_trace
518
506
def upsert_item ( # pylint:disable=docstring-missing-param
@@ -546,7 +534,6 @@ def upsert_item( # pylint:disable=docstring-missing-param
546
534
:rtype: Dict[str, Any]
547
535
"""
548
536
request_options = build_options (kwargs )
549
- response_hook = kwargs .pop ('response_hook' , None )
550
537
request_options ["disableAutomaticIdGeneration" ] = True
551
538
if populate_query_metrics is not None :
552
539
warnings .warn (
@@ -559,15 +546,12 @@ def upsert_item( # pylint:disable=docstring-missing-param
559
546
if post_trigger_include is not None :
560
547
request_options ["postTriggerInclude" ] = post_trigger_include
561
548
562
- result = self .client_connection .UpsertItem (
549
+ return self .client_connection .UpsertItem (
563
550
database_or_container_link = self .container_link ,
564
551
document = body ,
565
552
options = request_options ,
566
553
** kwargs
567
554
)
568
- if response_hook :
569
- response_hook (self .client_connection .last_response_headers , result )
570
- return result
571
555
572
556
@distributed_trace
573
557
def create_item ( # pylint:disable=docstring-missing-param
@@ -606,7 +590,6 @@ def create_item( # pylint:disable=docstring-missing-param
606
590
:rtype: Dict[str, Any]
607
591
"""
608
592
request_options = build_options (kwargs )
609
- response_hook = kwargs .pop ('response_hook' , None )
610
593
611
594
request_options ["disableAutomaticIdGeneration" ] = not kwargs .pop ('enable_automatic_id_generation' , False )
612
595
if populate_query_metrics :
@@ -622,12 +605,8 @@ def create_item( # pylint:disable=docstring-missing-param
622
605
if indexing_directive is not None :
623
606
request_options ["indexingDirective" ] = indexing_directive
624
607
625
- result = self .client_connection .CreateItem (
626
- database_or_container_link = self .container_link , document = body , options = request_options , ** kwargs
627
- )
628
- if response_hook :
629
- response_hook (self .client_connection .last_response_headers , result )
630
- return result
608
+ return self .client_connection .CreateItem (
609
+ database_or_container_link = self .container_link , document = body , options = request_options , ** kwargs )
631
610
632
611
@distributed_trace
633
612
def patch_item (
@@ -662,19 +641,15 @@ def patch_item(
662
641
:rtype: dict[str, Any]
663
642
"""
664
643
request_options = build_options (kwargs )
665
- response_hook = kwargs .pop ('response_hook' , None )
666
644
request_options ["disableAutomaticIdGeneration" ] = True
667
645
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
668
646
filter_predicate = kwargs .pop ("filter_predicate" , None )
669
647
if filter_predicate is not None :
670
648
request_options ["filterPredicate" ] = filter_predicate
671
649
672
650
item_link = self ._get_document_link (item )
673
- result = self .client_connection .PatchItem (
651
+ return self .client_connection .PatchItem (
674
652
document_link = item_link , operations = patch_operations , options = request_options , ** kwargs )
675
- if response_hook :
676
- response_hook (self .client_connection .last_response_headers , result )
677
- return result
678
653
679
654
@distributed_trace
680
655
def execute_item_batch (
@@ -703,14 +678,10 @@ def execute_item_batch(
703
678
"""
704
679
request_options = build_options (kwargs )
705
680
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
706
- response_hook = kwargs .pop ('response_hook' , None )
707
681
request_options ["disableAutomaticIdGeneration" ] = True
708
682
709
- result = self .client_connection .Batch (
683
+ return self .client_connection .Batch (
710
684
collection_link = self .container_link , batch_operations = batch_operations , options = request_options , ** kwargs )
711
- if response_hook :
712
- response_hook (self .client_connection .last_response_headers , result )
713
- return result
714
685
715
686
@distributed_trace
716
687
def delete_item ( # pylint:disable=docstring-missing-param
@@ -743,7 +714,6 @@ def delete_item( # pylint:disable=docstring-missing-param
743
714
:rtype: None
744
715
"""
745
716
request_options = build_options (kwargs )
746
- response_hook = kwargs .pop ('response_hook' , None )
747
717
if partition_key is not None :
748
718
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
749
719
if populate_query_metrics is not None :
@@ -759,8 +729,6 @@ def delete_item( # pylint:disable=docstring-missing-param
759
729
760
730
document_link = self ._get_document_link (item )
761
731
self .client_connection .DeleteItem (document_link = document_link , options = request_options , ** kwargs )
762
- if response_hook :
763
- response_hook (self .client_connection .last_response_headers , None )
764
732
765
733
@distributed_trace
766
734
def read_offer (self , ** kwargs : Any ) -> Offer :
@@ -827,7 +795,6 @@ def replace_throughput(
827
795
or the throughput properties could not be updated.
828
796
:rtype: ~azure.cosmos.ThroughputProperties
829
797
"""
830
- response_hook = kwargs .pop ('response_hook' , None )
831
798
properties = self ._get_properties ()
832
799
link = properties ["_self" ]
833
800
query_spec = {
@@ -844,8 +811,6 @@ def replace_throughput(
844
811
data = self .client_connection .ReplaceOffer (
845
812
offer_link = throughput_properties [0 ]["_self" ], offer = throughput_properties [0 ], ** kwargs )
846
813
847
- if response_hook :
848
- response_hook (self .client_connection .last_response_headers , data )
849
814
return ThroughputProperties (offer_throughput = data ["content" ]["offerThroughput" ], properties = data )
850
815
851
816
@distributed_trace
@@ -936,16 +901,12 @@ def get_conflict(
936
901
:rtype: Dict[str, Any]
937
902
"""
938
903
request_options = build_options (kwargs )
939
- response_hook = kwargs .pop ('response_hook' , None )
940
904
if partition_key is not None :
941
905
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
942
906
943
- result = self .client_connection .ReadConflict (
907
+ return self .client_connection .ReadConflict (
944
908
conflict_link = self ._get_conflict_link (conflict ), options = request_options , ** kwargs
945
909
)
946
- if response_hook :
947
- response_hook (self .client_connection .last_response_headers , result )
948
- return result
949
910
950
911
@distributed_trace
951
912
def delete_conflict (
@@ -968,15 +929,12 @@ def delete_conflict(
968
929
:rtype: None
969
930
"""
970
931
request_options = build_options (kwargs )
971
- response_hook = kwargs .pop ('response_hook' , None )
972
932
if partition_key is not None :
973
933
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
974
934
975
935
self .client_connection .DeleteConflict (
976
936
conflict_link = self ._get_conflict_link (conflict ), options = request_options , ** kwargs
977
937
)
978
- if response_hook :
979
- response_hook (self .client_connection .last_response_headers , None )
980
938
981
939
@distributed_trace
982
940
def delete_all_items_by_partition_key (
@@ -1002,11 +960,8 @@ def delete_all_items_by_partition_key(
1002
960
:rtype: None
1003
961
"""
1004
962
request_options = build_options (kwargs )
1005
- response_hook = kwargs .pop ('response_hook' , None )
1006
963
# regardless if partition key is valid we set it as invalid partition keys are set to a default empty value
1007
964
request_options ["partitionKey" ] = self ._set_partition_key (partition_key )
1008
965
1009
- self .client_connection .DeleteAllItemsByPartitionKey (collection_link = self .container_link ,
1010
- options = request_options , ** kwargs )
1011
- if response_hook :
1012
- response_hook (self .client_connection .last_response_headers , None )
966
+ self .client_connection .DeleteAllItemsByPartitionKey (
967
+ collection_link = self .container_link , options = request_options , ** kwargs )
0 commit comments