Skip to content

Commit c8bb8f0

Browse files
simorenohsofiar-msft
authored andcommitted
[Cosmos] elevate kwargs for sync client (Azure#34207)
* elevate kwargs for sync client, other small fixes * addressed most comments, missing computed properties * provisional marking for computed properties
1 parent 95c4dbb commit c8bb8f0

File tree

8 files changed

+336
-61
lines changed

8 files changed

+336
-61
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#### Bugs Fixed
1010

1111
#### Other Changes
12+
* Marked `computed_properties` keyword as provisional, un-marked `continuation_token_limit` as provisional. See [PR 34207](https://github.com/Azure/azure-sdk-for-python/pull/34207).
1213

1314
### 4.5.2b4 (2024-02-02)
1415
This version and all future versions will require Python 3.8+.

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ async def read_item(
297297
request_options = _build_options(kwargs)
298298

299299
request_options["partitionKey"] = await self._set_partition_key(partition_key)
300-
max_integrated_cache_staleness_in_ms = kwargs.pop('max_integrated_cache_staleness_in_ms', None)
301300
if max_integrated_cache_staleness_in_ms is not None:
302301
validate_cache_staleness_value(max_integrated_cache_staleness_in_ms)
303302
request_options["maxIntegratedCacheStaleness"] = max_integrated_cache_staleness_in_ms
@@ -369,6 +368,7 @@ def query_items(
369368
initial_headers: Optional[Dict[str, str]] = None,
370369
max_integrated_cache_staleness_in_ms: Optional[int] = None,
371370
priority_level: Optional[Literal["High", "Low"]] = None,
371+
continuation_token_limit: Optional[int] = None,
372372
**kwargs: Any
373373
) -> AsyncItemPaged[Dict[str, Any]]:
374374
"""Return all results matching the given `query`.
@@ -397,9 +397,9 @@ def query_items(
397397
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
398398
:keyword response_hook: A callable invoked with the response metadata.
399399
:paramtype response_hook: Callable[[Dict[str, str], AsyncItemPaged[Dict[str, Any]]], None]
400-
:keyword int continuation_token_limit: **provisional** The size limit in kb of the
401-
response continuation token in the query response. Valid values are positive integers.
402-
A value of 0 is the same as not passing a value (default no limit).
400+
:keyword int continuation_token_limit: The size limit in kb of the response continuation token in the query
401+
response. Valid values are positive integers.
402+
A value of 0 is the same as not passing a value (default no limit).
403403
:keyword int max_integrated_cache_staleness_in_ms: The max cache staleness for the integrated cache in
404404
milliseconds. For accounts configured to use the integrated cache, using Session or Eventual consistency,
405405
responses are guaranteed to be no staler than this value.
@@ -453,7 +453,6 @@ def query_items(
453453
feed_options["maxIntegratedCacheStaleness"] = max_integrated_cache_staleness_in_ms
454454
correlated_activity_id = GenerateGuidId()
455455
feed_options["correlatedActivityId"] = correlated_activity_id
456-
continuation_token_limit = kwargs.pop("continuation_token_limit", None)
457456
if continuation_token_limit is not None:
458457
feed_options["responseContinuationTokenLimitInKb"] = continuation_token_limit
459458
if hasattr(response_hook, "clear"):

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def _build_auth(credential: CredentialType) -> CredentialDict:
6666
"such as ClientSecretCredential).")
6767
return auth
6868

69+
6970
def _build_connection_policy(kwargs: Dict[str, Any]) -> ConnectionPolicy:
7071
# pylint: disable=protected-access
7172
policy = kwargs.pop('connection_policy', None) or ConnectionPolicy()

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ async def create_container(
194194
has changed, and act according to the condition specified by the `match_condition` parameter.
195195
:keyword match_condition: The match condition to use upon the etag.
196196
:paramtype match_condition: ~azure.core.MatchConditions
197-
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this container in the Azure
198-
Cosmos DB Service. For more Information on how to use computed properties visit
197+
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
198+
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
199199
`here: https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
200200
:keyword response_hook: A callable invoked with the response metadata.
201201
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
@@ -291,8 +291,8 @@ async def create_container_if_not_exists(
291291
has changed, and act according to the condition specified by the `match_condition` parameter.
292292
:keyword match_condition: The match condition to use upon the etag.
293293
:paramtype match_condition: ~azure.core.MatchConditions
294-
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this container in the Azure
295-
Cosmos DB Service. For more Information on how to use computed properties visit
294+
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
295+
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
296296
`here: https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
297297
:keyword response_hook: A callable invoked with the response metadata.
298298
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
@@ -479,14 +479,14 @@ async def replace_container(
479479
:keyword match_condition: The match condition to use upon the etag.
480480
:paramtype match_condition: ~azure.core.MatchConditions
481481
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
482-
:keyword response_hook: A callable invoked with the response metadata.
483-
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
484-
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: Raised if the container couldn't be replaced.
485-
This includes if the container with given id does not exist.
486482
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
487483
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
488484
note that analytical storage can only be enabled on Synapse Link enabled accounts.
485+
:keyword response_hook: A callable invoked with the response metadata.
486+
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
489487
:returns: A `ContainerProxy` instance representing the container after replace completed.
488+
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: Raised if the container couldn't be replaced.
489+
This includes if the container with given id does not exist.
490490
:rtype: ~azure.cosmos.aio.ContainerProxy
491491
492492
.. admonition:: Example:

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_scripts.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class ScriptsProxy:
5050
"""
5151

5252
def __init__(
53-
self,
54-
container: "ContainerProxy",
55-
client_connection: _CosmosClientConnection,
56-
container_link: str
53+
self,
54+
container: "ContainerProxy",
55+
client_connection: _CosmosClientConnection,
56+
container_link: str
5757
) -> None:
5858
self.client_connection = client_connection
5959
self.container_link = container_link

0 commit comments

Comments
 (0)