Skip to content

Commit 3c200e5

Browse files
andrewmathew1Andrew Mathew
andauthored
Removed **provisional** from computed_properties (Azure#39543)
* removed **provisional** from computed_properties * updated changelog * added computed_properties keyword argument to function def * annotated computed_properties tests * added replace computed_properties feature with tests * added replace computed_properties feature with tests * changed test class annotation to cosmosQuery, removed extra annotations --------- Co-authored-by: Andrew Mathew <[email protected]>
1 parent 87d4a32 commit 3c200e5

File tree

9 files changed

+526
-357
lines changed

9 files changed

+526
-357
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
### 4.9.1b5 (Unreleased)
44

55
#### Features Added
6+
* Added ability to replace `computed_properties` through `replace_container` method. See [PR 39543](https://github.com/Azure/azure-sdk-for-python/pull/39543)
67

78
#### Breaking Changes
89

910
#### Bugs Fixed
1011

1112
#### Other Changes
13+
* Un-marked `computed_properties` keyword as **provisional**. See [PR 39543](https://github.com/Azure/azure-sdk-for-python/pull/39543)
1214

1315
### 4.9.1b4 (2025-02-06)
1416

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ async def create_container(
173173
initial_headers: Optional[Dict[str, str]] = None,
174174
etag: Optional[str] = None,
175175
match_condition: Optional[MatchConditions] = None,
176+
computed_properties: Optional[List[Dict[str, str]]] = None,
176177
analytical_storage_ttl: Optional[int] = None,
177178
vector_embedding_policy: Optional[Dict[str, Any]] = None,
178179
change_feed_policy: Optional[Dict[str, Any]] = None,
@@ -199,7 +200,7 @@ async def create_container(
199200
has changed, and act according to the condition specified by the `match_condition` parameter.
200201
:keyword match_condition: The match condition to use upon the etag.
201202
:paramtype match_condition: ~azure.core.MatchConditions
202-
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
203+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
203204
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
204205
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
205206
:keyword response_hook: A callable invoked with the response metadata.
@@ -255,7 +256,6 @@ async def create_container(
255256
definition["conflictResolutionPolicy"] = conflict_resolution_policy
256257
if analytical_storage_ttl is not None:
257258
definition["analyticalStorageTtl"] = analytical_storage_ttl
258-
computed_properties = kwargs.pop('computed_properties', None)
259259
if computed_properties is not None:
260260
definition["computedProperties"] = computed_properties
261261
if vector_embedding_policy is not None:
@@ -296,6 +296,7 @@ async def create_container_if_not_exists(
296296
initial_headers: Optional[Dict[str, str]] = None,
297297
etag: Optional[str] = None,
298298
match_condition: Optional[MatchConditions] = None,
299+
computed_properties: Optional[List[Dict[str, str]]] = None,
299300
analytical_storage_ttl: Optional[int] = None,
300301
vector_embedding_policy: Optional[Dict[str, Any]] = None,
301302
change_feed_policy: Optional[Dict[str, Any]] = None,
@@ -324,7 +325,7 @@ async def create_container_if_not_exists(
324325
has changed, and act according to the condition specified by the `match_condition` parameter.
325326
:keyword match_condition: The match condition to use upon the etag.
326327
:paramtype match_condition: ~azure.core.MatchConditions
327-
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
328+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
328329
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
329330
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
330331
:keyword response_hook: A callable invoked with the response metadata.
@@ -344,7 +345,6 @@ async def create_container_if_not_exists(
344345
:returns: A `ContainerProxy` instance representing the new container.
345346
:rtype: ~azure.cosmos.aio.ContainerProxy
346347
"""
347-
computed_properties = kwargs.pop("computed_properties", None)
348348
try:
349349
container_proxy = self.get_container_client(id)
350350
await container_proxy.read(
@@ -504,6 +504,7 @@ async def replace_container(
504504
etag: Optional[str] = None,
505505
match_condition: Optional[MatchConditions] = None,
506506
analytical_storage_ttl: Optional[int] = None,
507+
computed_properties: Optional[List[Dict[str, str]]] = None,
507508
full_text_policy: Optional[Dict[str, Any]] = None,
508509
**kwargs: Any
509510
) -> ContainerProxy:
@@ -530,6 +531,9 @@ async def replace_container(
530531
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
531532
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
532533
note that analytical storage can only be enabled on Synapse Link enabled accounts.
534+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
535+
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
536+
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
533537
:keyword response_hook: A callable invoked with the response metadata.
534538
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
535539
:keyword Dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
@@ -571,6 +575,7 @@ async def replace_container(
571575
"defaultTtl": default_ttl,
572576
"conflictResolutionPolicy": conflict_resolution_policy,
573577
"analyticalStorageTtl": analytical_storage_ttl,
578+
"computedProperties": computed_properties,
574579
"fullTextPolicy": full_text_policy
575580
}.items()
576581
if value is not None

sdk/cosmos/azure-cosmos/azure/cosmos/database.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def create_container( # pylint:disable=docstring-missing-param
174174
etag: Optional[str] = None,
175175
match_condition: Optional[MatchConditions] = None,
176176
analytical_storage_ttl: Optional[int] = None,
177+
computed_properties: Optional[List[Dict[str, str]]] = None,
177178
vector_embedding_policy: Optional[Dict[str, Any]] = None,
178179
change_feed_policy: Optional[Dict[str, Any]] = None,
179180
full_text_policy: Optional[Dict[str, Any]] = None,
@@ -200,7 +201,7 @@ def create_container( # pylint:disable=docstring-missing-param
200201
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
201202
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
202203
note that analytical storage can only be enabled on Synapse Link enabled accounts.
203-
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
204+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
204205
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
205206
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
206207
:keyword Dict[str, Any] vector_embedding_policy: **provisional** The vector embedding policy for the container.
@@ -249,7 +250,6 @@ def create_container( # pylint:disable=docstring-missing-param
249250
definition["conflictResolutionPolicy"] = conflict_resolution_policy
250251
if analytical_storage_ttl is not None:
251252
definition["analyticalStorageTtl"] = analytical_storage_ttl
252-
computed_properties = kwargs.pop('computed_properties', None)
253253
if computed_properties is not None:
254254
definition["computedProperties"] = computed_properties
255255
if vector_embedding_policy is not None:
@@ -298,6 +298,7 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
298298
etag: Optional[str] = None,
299299
match_condition: Optional[MatchConditions] = None,
300300
analytical_storage_ttl: Optional[int] = None,
301+
computed_properties: Optional[List[Dict[str, str]]] = None,
301302
vector_embedding_policy: Optional[Dict[str, Any]] = None,
302303
change_feed_policy: Optional[Dict[str, Any]] = None,
303304
full_text_policy: Optional[Dict[str, Any]] = None,
@@ -326,7 +327,7 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
326327
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
327328
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
328329
note that analytical storage can only be enabled on Synapse Link enabled accounts.
329-
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
330+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
330331
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
331332
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
332333
:keyword Dict[str, Any] vector_embedding_policy: The vector embedding policy for the container. Each vector
@@ -341,7 +342,6 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
341342
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The container read or creation failed.
342343
:rtype: ~azure.cosmos.ContainerProxy
343344
"""
344-
computed_properties = kwargs.pop("computed_properties", None)
345345
try:
346346
container_proxy = self.get_container_client(id)
347347
container_proxy.read(
@@ -559,6 +559,7 @@ def replace_container( # pylint:disable=docstring-missing-param
559559
etag: Optional[str] = None,
560560
match_condition: Optional[MatchConditions] = None,
561561
analytical_storage_ttl: Optional[int] = None,
562+
computed_properties: Optional[List[Dict[str, str]]] = None,
562563
full_text_policy: Optional[Dict[str, Any]] = None,
563564
**kwargs: Any
564565
) -> ContainerProxy:
@@ -583,6 +584,9 @@ def replace_container( # pylint:disable=docstring-missing-param
583584
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
584585
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
585586
note that analytical storage can only be enabled on Synapse Link enabled accounts.
587+
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
588+
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
589+
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
586590
:keyword Callable response_hook: A callable invoked with the response metadata.
587591
:keyword Dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
588592
Used to denote the default language to be used for all full text indexes, or to individually
@@ -628,6 +632,7 @@ def replace_container( # pylint:disable=docstring-missing-param
628632
"defaultTtl": default_ttl,
629633
"conflictResolutionPolicy": conflict_resolution_policy,
630634
"analyticalStorageTtl": analytical_storage_ttl,
635+
"computedProperties": computed_properties,
631636
"fullTextPolicy": full_text_policy,
632637
}.items()
633638
if value is not None

0 commit comments

Comments
 (0)