Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,8 @@ async def get_throughput(
async def replace_throughput(
self,
throughput: Union[int, ThroughputProperties],
*,
response_hook: Optional[Callable[[Mapping[str, Any], CosmosDict], None]] = None,
**kwargs: Any
) -> ThroughputProperties:
"""Replace the container's throughput.
Expand All @@ -1456,7 +1458,7 @@ async def replace_throughput(
:param throughput: The throughput to be set.
:type throughput: Union[int, ~azure.cosmos.ThroughputProperties]
:keyword response_hook: A callable invoked with the response metadata.
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
:paramtype response_hook: [Callable[[Mapping[str, Any], CosmosDict], None]]
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No throughput properties exist for the container
or the throughput properties could not be updated.
:returns: ThroughputProperties for the container, updated with new throughput.
Expand All @@ -1477,6 +1479,9 @@ async def replace_throughput(
_replace_throughput(throughput=throughput, new_throughput_properties=new_offer)
data = await self.client_connection.ReplaceOffer(offer_link=throughput_properties[0]["_self"],
offer=throughput_properties[0], **kwargs)

if response_hook:
response_hook(self.client_connection.last_response_headers, data)

return ThroughputProperties(offer_throughput=data["content"]["offerThroughput"], properties=data)

Expand Down
7 changes: 7 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,8 @@ def get_throughput(
def replace_throughput(
self,
throughput: Union[int, ThroughputProperties],
*,
response_hook: Optional[Callable[[Mapping[str, Any], CosmosDict], None]] = None,
**kwargs: Any
) -> ThroughputProperties:
"""Replace the container's throughput.
Expand All @@ -1636,6 +1638,8 @@ def replace_throughput(

:param throughput: The throughput to be set.
:type throughput: Union[int, ~azure.cosmos.ThroughputProperties]
:keyword response_hook: A callable invoked with the response metadata.
:paramtype response_hook: Callable[[Mapping[str, Any], CosmosDict], None]
:returns: ThroughputProperties for the container, updated with new throughput.
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No throughput properties exist for the container
or the throughput properties could not be updated.
Expand All @@ -1654,6 +1658,9 @@ def replace_throughput(
_replace_throughput(throughput=throughput, new_throughput_properties=new_throughput_properties)
data = self.client_connection.ReplaceOffer(
offer_link=throughput_properties[0]["_self"], offer=throughput_properties[0], **kwargs)

if response_hook:
response_hook(self.client_connection.last_response_headers, data)

return ThroughputProperties(offer_throughput=data["content"]["offerThroughput"], properties=data)

Expand Down
Loading