Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
61ba8d1
initial commit
simorenoh Aug 13, 2021
15dcceb
Client Constructor (#20310)
annatisch Aug 20, 2021
bda95c3
read database
simorenoh Aug 27, 2021
c9648ab
Update simon_testfile.py
simorenoh Aug 27, 2021
80540dc
with coroutine
simorenoh Aug 30, 2021
1285438
Update simon_testfile.py
simorenoh Aug 30, 2021
992b0cd
small changes
simorenoh Aug 31, 2021
47cb688
async with returns no exceptions
simorenoh Aug 31, 2021
f3fa79f
Merge pull request #1 from Azure/simonmoreno/async
simorenoh Aug 31, 2021
0c49739
async read container
simorenoh Sep 1, 2021
47f4af5
async item read
simorenoh Sep 2, 2021
c97c946
cleaning up
simorenoh Sep 3, 2021
fcd95db
create item/ database methods
simorenoh Sep 13, 2021
36c5b90
item delete working
simorenoh Sep 13, 2021
44db2a2
docs replace functionality
simorenoh Sep 16, 2021
ec5b6ed
upsert functionality
simorenoh Sep 17, 2021
d63d052
Merge pull request #2 from simorenoh/item-read
simorenoh Oct 8, 2021
5d74c8f
missing query methods
simorenoh Oct 11, 2021
89fc2f7
CRUD for udf, sproc, triggers
simorenoh Oct 12, 2021
fdaa880
Merge branch 'Azure:main' into async-client
simorenoh Oct 12, 2021
3f9baf2
Merge branch 'Azure:main' into async-client
simorenoh Oct 12, 2021
d6650bc
Merge branch 'Azure:main' into query-functionality
simorenoh Oct 12, 2021
043dfe0
initial query logic + container methods
simorenoh Oct 13, 2021
befdb41
Merge branch 'async-client' into query-functionality
simorenoh Oct 13, 2021
8cffbe2
Merge pull request #3 from simorenoh/query-functionality
simorenoh Oct 13, 2021
72de7c8
missing some execution logic and tests
simorenoh Oct 21, 2021
5b805b8
oops
simorenoh Oct 21, 2021
8d8d0c4
fully working queries
simorenoh Oct 22, 2021
b597ca8
small fix to query_items()
simorenoh Oct 22, 2021
18319df
Update _cosmos_client_connection_async.py
simorenoh Oct 22, 2021
162c44d
Update _cosmos_client_connection.py
simorenoh Oct 22, 2021
ebbac51
documentation update
simorenoh Oct 22, 2021
43f78e6
Merge branch 'Azure:main' into main
simorenoh Oct 22, 2021
470aa5b
updated MIT dates and get_user_client() description
simorenoh Oct 22, 2021
74da690
Update CHANGELOG.md
simorenoh Oct 22, 2021
7104d63
Merge branch 'Azure:main' into main
simorenoh Oct 25, 2021
20718c7
Delete simon_testfile.py
simorenoh Oct 25, 2021
d825eaa
Merge pull request #4 from simorenoh/async-client
simorenoh Oct 25, 2021
e3c27a5
leftover retry utility
simorenoh Oct 25, 2021
3b778ad
Update README.md
simorenoh Oct 25, 2021
c6e352e
docs and removed six package
simorenoh Oct 28, 2021
8971a25
Merge remote-tracking branch 'upstream/main'
simorenoh Oct 28, 2021
52736ac
changes based on comments
simorenoh Nov 4, 2021
ad98039
small change in type hints
simorenoh Nov 4, 2021
f76c595
updated readme
simorenoh Nov 9, 2021
3f02a65
fixes based on conversations
simorenoh Nov 10, 2021
e719869
added missing type comments
simorenoh Nov 11, 2021
d03ee05
Merge branch 'Azure:main' into main
simorenoh Nov 11, 2021
02c52ee
update changelog for ci pipeline
simorenoh Nov 23, 2021
2cb4551
added typehints, moved params into keywords, added decorators, made _…
simorenoh Nov 29, 2021
cf20d35
changes based on sync with central sdk
simorenoh Dec 2, 2021
f456817
remove is_system_key from scripts (only used in execute_sproc)
simorenoh Dec 3, 2021
ea9bd16
Revert "remove is_system_key from scripts (only used in execute_sproc)"
simorenoh Dec 3, 2021
709d2eb
async script proxy using composition
simorenoh Dec 3, 2021
3277dd8
pylint
simorenoh Dec 3, 2021
a57cb4d
capitalized constants
simorenoh Dec 6, 2021
014578b
Apply suggestions from code review
simorenoh Dec 6, 2021
0d79695
closing python code snippet
simorenoh Dec 6, 2021
fdabea1
last doc updates
simorenoh Dec 7, 2021
016d0dd
Update sdk/cosmos/azure-cosmos/CHANGELOG.md
tjprescott Dec 7, 2021
8228aa9
version update
simorenoh Dec 7, 2021
7ae1cd0
Merge branch 'Azure:main' into main
simorenoh Dec 13, 2021
7e8e953
cosmos updates for release
simorenoh Dec 13, 2021
52fed84
depracate offer naming, make throughput methods, and create throughpu…
simorenoh Dec 27, 2021
e0aa254
Delete offer.py
simorenoh Dec 27, 2021
99997e9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
simorenoh Jan 12, 2022
294efa1
Merge branch 'main' into deprecate-read-offer
simorenoh Apr 6, 2022
68b5e1f
Update CHANGELOG.md
simorenoh Apr 12, 2022
eca7d13
Merge branch 'main' into deprecate-read-offer
simorenoh Apr 12, 2022
8b41e54
Update container.py
simorenoh Apr 12, 2022
3cdea59
fixed tabs
simorenoh Apr 18, 2022
0bce109
Merge branch 'main' into deprecate-read-offer
simorenoh Apr 26, 2022
a7dad7c
Merge branch 'main' into deprecate-read-offer
simorenoh Apr 27, 2022
e28b839
support for isinstance(variable, Offer) while using ThroughputPropert…
simorenoh May 2, 2022
6087d04
added test
simorenoh May 4, 2022
0048bb3
Update container.py
simorenoh May 4, 2022
9c575a1
updated naming to get
simorenoh May 11, 2022
6fd1ea3
changed naming in samples/ tests
simorenoh May 11, 2022
9c88b19
Update CHANGELOG.md
simorenoh May 12, 2022
73a3389
Merge branch 'Azure-main' into deprecate-read-offer
simorenoh May 12, 2022
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
3 changes: 2 additions & 1 deletion sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 4.3.0b5 (Unreleased)

#### Other Changes
- Deprecated offer-named methods in favor of their new throughput-named counterparts (`read_offer` -> `get_throughput`).
- Marked the GetAuthorizationMethod for deprecation since it will no longer be public in a future release.
- Added samples showing how to configure retry options for both the sync and async clients.
- Deprecated the `connection_retry_policy` and `retry_options` options in the sync client.
Expand Down Expand Up @@ -31,7 +32,7 @@
- Added new **provisional** `max_integrated_cache_staleness_in_ms` parameter to read item and query items APIs in order
to make use of the **preview** CosmosDB integrated cache functionality.
Please see [Azure Cosmos DB integrated cache](https://docs.microsoft.com/azure/cosmos-db/integrated-cache) for more details.
- Added support for split-proof queries for the async client
- Added support for split-proof queries for the async client.

### Bugs fixed
- Default consistency level for the sync and async clients is no longer `Session` and will instead be set to the
Expand Down
179 changes: 92 additions & 87 deletions sdk/cosmos/azure-cosmos/azure/cosmos/aio/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .._base import build_options as _build_options, validate_cache_staleness_value
from ..exceptions import CosmosResourceNotFoundError
from ..http_constants import StatusCodes
from ..offer import Offer
from ..offer import ThroughputProperties
from .scripts import ScriptsProxy
from ..partition_key import NonePartitionKeyValue

Expand Down Expand Up @@ -114,10 +114,10 @@ def _set_partition_key(self, partition_key) -> Union[str, Awaitable]:

@distributed_trace_async
async def read(
self,
populate_partition_key_range_statistics=None, # type: Optional[bool]
populate_quota_info=None, # type: Optional[bool]
**kwargs # type: Any
self,
populate_partition_key_range_statistics=None, # type: Optional[bool]
populate_quota_info=None, # type: Optional[bool]
**kwargs # type: Any
) -> Dict[str, Any]:
"""Read the container properties.

Expand Down Expand Up @@ -151,9 +151,9 @@ async def read(

@distributed_trace_async
async def create_item(
self,
body, # type: Dict[str, Any]
**kwargs # type: Any
self,
body, # type: Dict[str, Any]
**kwargs # type: Any
) -> Dict[str, Any]:
"""Create an item in the container.

Expand Down Expand Up @@ -198,10 +198,10 @@ async def create_item(

@distributed_trace_async
async def read_item(
self,
item, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
self,
item, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
) -> Dict[str, Any]:
"""Get the item identified by `item`.

Expand Down Expand Up @@ -245,9 +245,9 @@ async def read_item(

@distributed_trace
def read_all_items(
self,
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
self,
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
) -> AsyncItemPaged[Dict[str, Any]]:
"""List all the items in the container.

Expand Down Expand Up @@ -284,14 +284,14 @@ def read_all_items(

@distributed_trace
def query_items(
self,
query, # type: str
parameters=None, # type: Optional[List[Dict[str, Any]]]
partition_key=None, # type: Optional[Any]
max_item_count=None, # type: Optional[int]
enable_scan_in_query=None, # type: Optional[bool]
populate_query_metrics=None, # type: Optional[bool]
**kwargs # type: Any
self,
query, # type: str
parameters=None, # type: Optional[List[Dict[str, Any]]]
partition_key=None, # type: Optional[Any]
max_item_count=None, # type: Optional[int]
enable_scan_in_query=None, # type: Optional[bool]
populate_query_metrics=None, # type: Optional[bool]
**kwargs # type: Any
) -> AsyncItemPaged[Dict[str, Any]]:
"""Return all results matching the given `query`.

Expand Down Expand Up @@ -373,12 +373,12 @@ def query_items(

@distributed_trace
def query_items_change_feed(
self,
partition_key_range_id=None, # type: Optional[str]
is_start_from_beginning=False, # type: bool
continuation=None, # type: Optional[str]
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
self,
partition_key_range_id=None, # type: Optional[str]
is_start_from_beginning=False, # type: bool
continuation=None, # type: Optional[str]
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
) -> AsyncItemPaged[Dict[str, Any]]:
"""Get a sorted list of items that were changed, in the order in which they were modified.

Expand Down Expand Up @@ -419,11 +419,11 @@ def query_items_change_feed(

@distributed_trace_async
async def upsert_item(
self,
body, # type: Dict[str, Any]
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
self,
body, # type: Dict[str, Any]
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
) -> Dict[str, Any]:
"""Insert or update the specified item.

Expand Down Expand Up @@ -463,12 +463,12 @@ async def upsert_item(

@distributed_trace_async
async def replace_item(
self,
item, # type: Union[str, Dict[str, Any]]
body, # type: Dict[str, Any]
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
self,
item, # type: Union[str, Dict[str, Any]]
body, # type: Dict[str, Any]
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
) -> Dict[str, Any]:
"""Replaces the specified item if it exists in the container.

Expand Down Expand Up @@ -507,12 +507,12 @@ async def replace_item(

@distributed_trace_async
async def delete_item(
self,
item, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
self,
item, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
pre_trigger_include=None, # type: Optional[str]
post_trigger_include=None, # type: Optional[str]
**kwargs # type: Any
) -> None:
"""Delete the specified item from the container.

Expand Down Expand Up @@ -546,17 +546,17 @@ async def delete_item(
response_hook(self.client_connection.last_response_headers, result)

@distributed_trace_async
async def read_offer(self, **kwargs):
# type: (Any) -> Offer
"""Read the Offer object for this container.
async def get_throughput(self, **kwargs):
# type: (Any) -> ThroughputProperties
"""Get the ThroughputProperties object for this container.

If no Offer already exists for the container, an exception is raised.
If no ThroughputProperties already exist for the container, an exception is raised.

:keyword Callable response_hook: A callable invoked with the response metadata.
:returns: Offer for the container.
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No offer exists for the container or
the offer could not be retrieved.
:rtype: ~azure.cosmos.Offer
:returns: ThroughputProperties for the container.
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No throughput properties exists for the container or
the throughput properties could not be retrieved.
:rtype: ~azure.cosmos.ThroughputProperties
"""
response_hook = kwargs.pop('response_hook', None)
properties = await self._get_properties()
Expand All @@ -565,30 +565,33 @@ async def read_offer(self, **kwargs):
"query": "SELECT * FROM root r WHERE r.resource=@link",
"parameters": [{"name": "@link", "value": link}],
}
offers = [offer async for offer in self.client_connection.QueryOffers(query_spec, **kwargs)]
if len(offers) == 0:
throughput_properties = [throughput async for throughput in
self.client_connection.QueryOffers(query_spec, **kwargs)]
if len(throughput_properties) == 0:
raise CosmosResourceNotFoundError(
status_code=StatusCodes.NOT_FOUND,
message="Could not find Offer for database " + self.database_link)
message="Could not find ThroughputProperties for container " + self.container_link)

if response_hook:
response_hook(self.client_connection.last_response_headers, offers)
response_hook(self.client_connection.last_response_headers, throughput_properties)

return Offer(offer_throughput=offers[0]["content"]["offerThroughput"], properties=offers[0])
return ThroughputProperties(
offer_throughput=throughput_properties[0]["content"]["offerThroughput"],
properties=throughput_properties[0])

@distributed_trace_async
async def replace_throughput(self, throughput, **kwargs):
# type: (int, Any) -> Offer
# type: (int, Any) -> ThroughputProperties
"""Replace the container's throughput.

If no Offer already exists for the container, an exception is raised.
If no ThroughputProperties already exist for the container, an exception is raised.

:param throughput: The throughput to be set (an integer).
:keyword Callable response_hook: A callable invoked with the response metadata.
:returns: Offer for the container, updated with new throughput.
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No offer exists for the container
or the offer could not be updated.
:rtype: ~azure.cosmos.Offer
: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.
:rtype: ~azure.cosmos.ThroughputProperties
"""
response_hook = kwargs.pop('response_hook', None)
properties = await self._get_properties()
Expand All @@ -597,19 +600,21 @@ async def replace_throughput(self, throughput, **kwargs):
"query": "SELECT * FROM root r WHERE r.resource=@link",
"parameters": [{"name": "@link", "value": link}],
}
offers = [offer async for offer in self.client_connection.QueryOffers(query_spec, **kwargs)]
if len(offers) == 0:
throughput_properties = [throughput async for throughput in
self.client_connection.QueryOffers(query_spec, **kwargs)]
if len(throughput_properties) == 0:
raise CosmosResourceNotFoundError(
status_code=StatusCodes.NOT_FOUND,
message="Could not find Offer for database " + self.database_link)
message="Could not find ThroughputProperties for container " + self.container_link)

new_offer = offers[0].copy()
new_offer["content"]["offerThroughput"] = throughput
data = await self.client_connection.ReplaceOffer(offer_link=offers[0]["_self"], offer=offers[0], **kwargs)
new_throughput_properties = throughput_properties[0].copy()
new_throughput_properties["content"]["offerThroughput"] = throughput
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 Offer(offer_throughput=data["content"]["offerThroughput"], properties=data)
return ThroughputProperties(offer_throughput=data["content"]["offerThroughput"], properties=data)

@distributed_trace
def list_conflicts(self, max_item_count=None, **kwargs):
Expand All @@ -635,12 +640,12 @@ def list_conflicts(self, max_item_count=None, **kwargs):

@distributed_trace
def query_conflicts(
self,
query, # type: str
parameters=None, # type: Optional[List[Dict[str, Any]]]
partition_key=None, # type: Optional[Any]
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
self,
query, # type: str
parameters=None, # type: Optional[List[Dict[str, Any]]]
partition_key=None, # type: Optional[Any]
max_item_count=None, # type: Optional[int]
**kwargs # type: Any
) -> AsyncItemPaged[Dict[str, Any]]:
"""Return all conflicts matching a given `query`.

Expand Down Expand Up @@ -673,11 +678,11 @@ def query_conflicts(
return result

@distributed_trace_async
async def read_conflict(
self,
conflict, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
async def get_conflict(
self,
conflict, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
) -> Dict[str, Any]:
"""Get the conflict identified by `conflict`.

Expand All @@ -700,10 +705,10 @@ async def read_conflict(

@distributed_trace_async
async def delete_conflict(
self,
conflict, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
self,
conflict, # type: Union[str, Dict[str, Any]]
partition_key, # type: Any
**kwargs # type: Any
) -> None:
"""Delete a specified conflict from the container.

Expand Down
Loading