@@ -156,7 +156,6 @@ async def read(
156
156
:returns: Dict representing the retrieved container.
157
157
:rtype: Dict[str, Any]
158
158
"""
159
- response_hook = kwargs .pop ('response_hook' , None )
160
159
if session_token is not None :
161
160
kwargs ['session_token' ] = session_token
162
161
if priority_level is not None :
@@ -173,8 +172,6 @@ async def read(
173
172
self ._properties = await self .client_connection .ReadContainer (
174
173
collection_link , options = request_options , ** kwargs
175
174
)
176
- if response_hook :
177
- response_hook (self .client_connection .last_response_headers , self ._properties )
178
175
return self ._properties
179
176
180
177
@distributed_trace_async
@@ -220,7 +217,6 @@ async def create_item(
220
217
:returns: A dict representing the new item.
221
218
:rtype: Dict[str, Any]
222
219
"""
223
- response_hook = kwargs .pop ('response_hook' , None )
224
220
if pre_trigger_include is not None :
225
221
kwargs ['pre_trigger_include' ] = pre_trigger_include
226
222
if post_trigger_include is not None :
@@ -243,8 +239,6 @@ async def create_item(
243
239
result = await self .client_connection .CreateItem (
244
240
database_or_container_link = self .container_link , document = body , options = request_options , ** kwargs
245
241
)
246
- if response_hook :
247
- response_hook (self .client_connection .last_response_headers , result )
248
242
return result
249
243
250
244
@distributed_trace_async
@@ -291,7 +285,6 @@ async def read_item(
291
285
:caption: Get an item from the database and update one of its properties:
292
286
:name: update_item
293
287
"""
294
- response_hook = kwargs .pop ('response_hook' , None )
295
288
doc_link = self ._get_document_link (item )
296
289
if post_trigger_include is not None :
297
290
kwargs ['post_trigger_include' ] = post_trigger_include
@@ -309,10 +302,7 @@ async def read_item(
309
302
validate_cache_staleness_value (max_integrated_cache_staleness_in_ms )
310
303
request_options ["maxIntegratedCacheStaleness" ] = max_integrated_cache_staleness_in_ms
311
304
312
- result = await self .client_connection .ReadItem (document_link = doc_link , options = request_options , ** kwargs )
313
- if response_hook :
314
- response_hook (self .client_connection .last_response_headers , result )
315
- return result
305
+ return await self .client_connection .ReadItem (document_link = doc_link , options = request_options , ** kwargs )
316
306
317
307
@distributed_trace
318
308
def read_all_items (
@@ -571,7 +561,6 @@ async def upsert_item(
571
561
:returns: A dict representing the upserted item.
572
562
:rtype: Dict[str, Any]
573
563
"""
574
- response_hook = kwargs .pop ('response_hook' , None )
575
564
if pre_trigger_include is not None :
576
565
kwargs ['pre_trigger_include' ] = pre_trigger_include
577
566
if post_trigger_include is not None :
@@ -595,8 +584,6 @@ async def upsert_item(
595
584
options = request_options ,
596
585
** kwargs
597
586
)
598
- if response_hook :
599
- response_hook (self .client_connection .last_response_headers , result )
600
587
return result
601
588
602
589
@distributed_trace_async
@@ -639,7 +626,6 @@ async def replace_item(
639
626
:returns: A dict representing the item after replace went through.
640
627
:rtype: Dict[str, Any]
641
628
"""
642
- response_hook = kwargs .pop ('response_hook' , None )
643
629
item_link = self ._get_document_link (item )
644
630
if pre_trigger_include is not None :
645
631
kwargs ['pre_trigger_include' ] = pre_trigger_include
@@ -661,8 +647,6 @@ async def replace_item(
661
647
result = await self .client_connection .ReplaceItem (
662
648
document_link = item_link , new_document = body , options = request_options , ** kwargs
663
649
)
664
- if response_hook :
665
- response_hook (self .client_connection .last_response_headers , result )
666
650
return result
667
651
668
652
@distributed_trace_async
@@ -708,7 +692,6 @@ async def patch_item(
708
692
given id does not exist.
709
693
:rtype: dict[str, Any]
710
694
"""
711
- response_hook = kwargs .pop ('response_hook' , None )
712
695
if pre_trigger_include is not None :
713
696
kwargs ['pre_trigger_include' ] = pre_trigger_include
714
697
if post_trigger_include is not None :
@@ -728,11 +711,8 @@ async def patch_item(
728
711
request_options ["filterPredicate" ] = filter_predicate
729
712
730
713
item_link = self ._get_document_link (item )
731
- result = await self .client_connection .PatchItem (
714
+ return await self .client_connection .PatchItem (
732
715
document_link = item_link , operations = patch_operations , options = request_options , ** kwargs )
733
- if response_hook :
734
- response_hook (self .client_connection .last_response_headers , result )
735
- return result
736
716
737
717
@distributed_trace_async
738
718
async def delete_item (
@@ -770,7 +750,6 @@ async def delete_item(
770
750
:raises ~azure.cosmos.exceptions.CosmosResourceNotFoundError: The item does not exist in the container.
771
751
:rtype: None
772
752
"""
773
- response_hook = kwargs .pop ('response_hook' , None )
774
753
if pre_trigger_include is not None :
775
754
kwargs ['pre_trigger_include' ] = pre_trigger_include
776
755
if post_trigger_include is not None :
@@ -788,8 +767,6 @@ async def delete_item(
788
767
789
768
document_link = self ._get_document_link (item )
790
769
await self .client_connection .DeleteItem (document_link = document_link , options = request_options , ** kwargs )
791
- if response_hook :
792
- response_hook (self .client_connection .last_response_headers , None )
793
770
794
771
@distributed_trace_async
795
772
async def get_throughput (self , ** kwargs : Any ) -> ThroughputProperties :
@@ -842,7 +819,6 @@ async def replace_throughput(
842
819
:returns: ThroughputProperties for the container, updated with new throughput.
843
820
:rtype: ~azure.cosmos.offer.ThroughputProperties
844
821
"""
845
- response_hook = kwargs .pop ('response_hook' , None )
846
822
properties = await self ._get_properties ()
847
823
link = properties ["_self" ]
848
824
query_spec = {
@@ -860,8 +836,6 @@ async def replace_throughput(
860
836
_replace_throughput (throughput = throughput , new_throughput_properties = new_offer )
861
837
data = await self .client_connection .ReplaceOffer (offer_link = throughput_properties [0 ]["_self" ],
862
838
offer = throughput_properties [0 ], ** kwargs )
863
- if response_hook :
864
- response_hook (self .client_connection .last_response_headers , data )
865
839
866
840
return ThroughputProperties (offer_throughput = data ["content" ]["offerThroughput" ], properties = data )
867
841
@@ -955,13 +929,10 @@ async def get_conflict(
955
929
:rtype: Dict[str, Any]
956
930
"""
957
931
request_options = _build_options (kwargs )
958
- response_hook = kwargs .pop ('response_hook' , None )
959
932
request_options ["partitionKey" ] = await self ._set_partition_key (partition_key )
960
933
result = await self .client_connection .ReadConflict (
961
934
conflict_link = self ._get_conflict_link (conflict ), options = request_options , ** kwargs
962
935
)
963
- if response_hook :
964
- response_hook (self .client_connection .last_response_headers , result )
965
936
return result
966
937
967
938
@distributed_trace_async
@@ -986,13 +957,11 @@ async def delete_conflict(
986
957
:rtype: None
987
958
"""
988
959
request_options = _build_options (kwargs )
989
- response_hook = kwargs .pop ('response_hook' , None )
990
960
request_options ["partitionKey" ] = await self ._set_partition_key (partition_key )
961
+
991
962
await self .client_connection .DeleteConflict (
992
963
conflict_link = self ._get_conflict_link (conflict ), options = request_options , ** kwargs
993
964
)
994
- if response_hook :
995
- response_hook (self .client_connection .last_response_headers , None )
996
965
997
966
@distributed_trace_async
998
967
async def delete_all_items_by_partition_key (
@@ -1023,7 +992,6 @@ async def delete_all_items_by_partition_key(
1023
992
:keyword Callable response_hook: A callable invoked with the response metadata.
1024
993
:rtype: None
1025
994
"""
1026
- response_hook = kwargs .pop ('response_hook' , None )
1027
995
if pre_trigger_include is not None :
1028
996
kwargs ['pre_trigger_include' ] = pre_trigger_include
1029
997
if post_trigger_include is not None :
@@ -1040,8 +1008,6 @@ async def delete_all_items_by_partition_key(
1040
1008
1041
1009
await self .client_connection .DeleteAllItemsByPartitionKey (collection_link = self .container_link ,
1042
1010
options = request_options , ** kwargs )
1043
- if response_hook :
1044
- response_hook (self .client_connection .last_response_headers , None )
1045
1011
1046
1012
@distributed_trace_async
1047
1013
async def execute_item_batch (
@@ -1074,7 +1040,6 @@ async def execute_item_batch(
1074
1040
:raises ~azure.cosmos.exceptions.CosmosBatchOperationError: A transactional batch operation failed in the batch.
1075
1041
:rtype: List[Dict[str, Any]]
1076
1042
"""
1077
- response_hook = kwargs .pop ('response_hook' , None )
1078
1043
if pre_trigger_include is not None :
1079
1044
kwargs ['pre_trigger_include' ] = pre_trigger_include
1080
1045
if post_trigger_include is not None :
@@ -1089,8 +1054,5 @@ async def execute_item_batch(
1089
1054
request_options ["partitionKey" ] = await self ._set_partition_key (partition_key )
1090
1055
request_options ["disableAutomaticIdGeneration" ] = True
1091
1056
1092
- result = await self .client_connection .Batch (
1057
+ return await self .client_connection .Batch (
1093
1058
collection_link = self .container_link , batch_operations = batch_operations , options = request_options , ** kwargs )
1094
- if response_hook :
1095
- response_hook (self .client_connection .last_response_headers , result )
1096
- return result
0 commit comments