@@ -190,6 +190,7 @@ async def create_item(
190
190
etag : Optional [str ] = None ,
191
191
match_condition : Optional [MatchConditions ] = None ,
192
192
priority : Optional [Literal ["High" , "Low" ]] = None ,
193
+ no_response : Optional [bool ] = None ,
193
194
** kwargs : Any
194
195
) -> Dict [str , Any ]:
195
196
"""Create an item in the container.
@@ -216,7 +217,10 @@ async def create_item(
216
217
request. Once the user has reached their provisioned throughput, low priority requests are throttled
217
218
before high priority requests start getting throttled. Feature must first be enabled at the account level.
218
219
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: Item with the given ID already exists.
219
- :returns: A dict representing the new item.
220
+ :keyword bool no_response: Indicates whether service should be instructed to skip
221
+ sending response payloads. When not specified explicitly here, the default value will be determined from
222
+ client-level options.
223
+ :returns: A dict representing the new item. The dict will be empty if `no_response` is specified.
220
224
:rtype: Dict[str, Any]
221
225
"""
222
226
if pre_trigger_include is not None :
@@ -233,6 +237,8 @@ async def create_item(
233
237
kwargs ['etag' ] = etag
234
238
if match_condition is not None :
235
239
kwargs ['match_condition' ] = match_condition
240
+ if no_response is not None :
241
+ kwargs ['no_response' ] = no_response
236
242
request_options = _build_options (kwargs )
237
243
request_options ["disableAutomaticIdGeneration" ] = not enable_automatic_id_generation
238
244
if indexing_directive is not None :
@@ -243,7 +249,7 @@ async def create_item(
243
249
result = await self .client_connection .CreateItem (
244
250
database_or_container_link = self .container_link , document = body , options = request_options , ** kwargs
245
251
)
246
- return result
252
+ return result or {}
247
253
248
254
@distributed_trace_async
249
255
async def read_item (
@@ -552,6 +558,7 @@ async def upsert_item(
552
558
etag : Optional [str ] = None ,
553
559
match_condition : Optional [MatchConditions ] = None ,
554
560
priority : Optional [Literal ["High" , "Low" ]] = None ,
561
+ no_response : Optional [bool ] = None ,
555
562
** kwargs : Any
556
563
) -> Dict [str , Any ]:
557
564
"""Insert or update the specified item.
@@ -574,7 +581,11 @@ async def upsert_item(
574
581
request. Once the user has reached their provisioned throughput, low priority requests are throttled
575
582
before high priority requests start getting throttled. Feature must first be enabled at the account level.
576
583
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The given item could not be upserted.
577
- :returns: A dict representing the upserted item.
584
+ :keyword bool no_response: Indicates whether service should be instructed to skip
585
+ sending response payloads. When not specified explicitly here, the default value will be determined from
586
+ client-level options.
587
+ :returns: A dict representing the item after the upsert operation went through. The dict will be empty if
588
+ `no_response` is specified.
578
589
:rtype: Dict[str, Any]
579
590
"""
580
591
if pre_trigger_include is not None :
@@ -591,6 +602,8 @@ async def upsert_item(
591
602
kwargs ['etag' ] = etag
592
603
if match_condition is not None :
593
604
kwargs ['match_condition' ] = match_condition
605
+ if no_response is not None :
606
+ kwargs ['no_response' ] = no_response
594
607
request_options = _build_options (kwargs )
595
608
request_options ["disableAutomaticIdGeneration" ] = True
596
609
if self .container_link in self .__get_client_container_caches ():
@@ -602,7 +615,7 @@ async def upsert_item(
602
615
options = request_options ,
603
616
** kwargs
604
617
)
605
- return result
618
+ return result or {}
606
619
607
620
@distributed_trace_async
608
621
async def replace_item (
@@ -617,6 +630,7 @@ async def replace_item(
617
630
etag : Optional [str ] = None ,
618
631
match_condition : Optional [MatchConditions ] = None ,
619
632
priority : Optional [Literal ["High" , "Low" ]] = None ,
633
+ no_response : Optional [bool ] = None ,
620
634
** kwargs : Any
621
635
) -> Dict [str , Any ]:
622
636
"""Replaces the specified item if it exists in the container.
@@ -641,7 +655,11 @@ async def replace_item(
641
655
before high priority requests start getting throttled. Feature must first be enabled at the account level.
642
656
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The replace failed or the item with
643
657
given id does not exist.
644
- :returns: A dict representing the item after replace went through.
658
+ :keyword bool no_response: Indicates whether service should be instructed to skip
659
+ sending response payloads. When not specified explicitly here, the default value will be determined from
660
+ client-level options.
661
+ :returns: A dict representing the item after replace went through. The dict will be empty if `no_response`
662
+ is specified.
645
663
:rtype: Dict[str, Any]
646
664
"""
647
665
item_link = self ._get_document_link (item )
@@ -659,6 +677,8 @@ async def replace_item(
659
677
kwargs ['etag' ] = etag
660
678
if match_condition is not None :
661
679
kwargs ['match_condition' ] = match_condition
680
+ if no_response is not None :
681
+ kwargs ['no_response' ] = no_response
662
682
request_options = _build_options (kwargs )
663
683
request_options ["disableAutomaticIdGeneration" ] = True
664
684
if self .container_link in self .__get_client_container_caches ():
@@ -667,7 +687,7 @@ async def replace_item(
667
687
result = await self .client_connection .ReplaceItem (
668
688
document_link = item_link , new_document = body , options = request_options , ** kwargs
669
689
)
670
- return result
690
+ return result or {}
671
691
672
692
@distributed_trace_async
673
693
async def patch_item (
@@ -683,6 +703,7 @@ async def patch_item(
683
703
etag : Optional [str ] = None ,
684
704
match_condition : Optional [MatchConditions ] = None ,
685
705
priority : Optional [Literal ["High" , "Low" ]] = None ,
706
+ no_response : Optional [bool ] = None ,
686
707
** kwargs : Any
687
708
) -> Dict [str , Any ]:
688
709
""" Patches the specified item with the provided operations if it
@@ -707,7 +728,11 @@ async def patch_item(
707
728
:keyword Literal["High", "Low"] priority: Priority based execution allows users to set a priority for each
708
729
request. Once the user has reached their provisioned throughput, low priority requests are throttled
709
730
before high priority requests start getting throttled. Feature must first be enabled at the account level.
710
- :returns: A dict representing the item after the patch operations went through.
731
+ :keyword bool no_response: Indicates whether service should be instructed to skip
732
+ sending response payloads. When not specified explicitly here, the default value will be determined from
733
+ client-level options.
734
+ :returns: A dict representing the item after the patch operation went through. The dict will be empty if
735
+ `no_response` is specified.
711
736
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The patch operations failed or the item with
712
737
given id does not exist.
713
738
:rtype: dict[str, Any]
@@ -724,6 +749,8 @@ async def patch_item(
724
749
kwargs ['etag' ] = etag
725
750
if match_condition is not None :
726
751
kwargs ['match_condition' ] = match_condition
752
+ if no_response is not None :
753
+ kwargs ['no_response' ] = no_response
727
754
request_options = _build_options (kwargs )
728
755
request_options ["disableAutomaticIdGeneration" ] = True
729
756
request_options ["partitionKey" ] = await self ._set_partition_key (partition_key )
@@ -733,8 +760,9 @@ async def patch_item(
733
760
request_options ["containerRID" ] = self .__get_client_container_caches ()[self .container_link ]["_rid" ]
734
761
735
762
item_link = self ._get_document_link (item )
736
- return await self .client_connection .PatchItem (
763
+ result = await self .client_connection .PatchItem (
737
764
document_link = item_link , operations = patch_operations , options = request_options , ** kwargs )
765
+ return result or {}
738
766
739
767
@distributed_trace_async
740
768
async def delete_item (
0 commit comments