Skip to content

Commit 9c7becd

Browse files
authored
[Cosmos] add post_trigger_include to async read_item method and docs updates (Azure#24561)
* Update _container.py * docs * more docs * fix pipeline tests * refactoring of cosmos_client to be private for imports * fix private class renaming * update Dict to dict * Update _container.py
1 parent 0f72ec0 commit 9c7becd

File tree

9 files changed

+74
-76
lines changed

9 files changed

+74
-76
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# SOFTWARE.
2121

2222
from ._container import ContainerProxy
23-
from .cosmos_client import CosmosClient
23+
from ._cosmos_client import CosmosClient
2424
from ._database import DatabaseProxy
2525
from ._user import UserProxy
2626
from ._scripts import ScriptsProxy

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def read(
122122
range statistics in response headers.
123123
:keyword bool populate_quota_info: Enable returning collection storage quota information in response headers.
124124
:keyword str session_token: Token for use with Session consistency.
125-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
125+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
126126
:keyword response_hook: A callable invoked with the response metadata.
127127
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
128128
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: Raised if the container couldn't be retrieved.
@@ -160,23 +160,17 @@ async def create_item(
160160
To update or replace an existing item, use the
161161
:func:`ContainerProxy.upsert_item` method.
162162
163-
:param Dict[str, str] body: A dict-like object representing the item to create.
164-
:keyword pre_trigger_include: trigger id to be used as pre operation trigger.
165-
:paramtype pre_trigger_include: str
166-
:keyword post_trigger_include: trigger id to be used as post operation trigger.
167-
:paramtype post_trigger_include: str
163+
:param dict[str, str] body: A dict-like object representing the item to create.
164+
:keyword str pre_trigger_include: trigger id to be used as pre operation trigger.
165+
:keyword str post_trigger_include: trigger id to be used as post operation trigger.
168166
:keyword indexing_directive: Enumerates the possible values to indicate whether the document should
169167
be omitted from indexing. Possible values include: 0 for Default, 1 for Exclude, or 2 for Include.
170-
:paramtype indexing_directive: int or ~azure.cosmos.documents.IndexingDirective
171-
:keyword enable_automatic_id_generation: Enable automatic id generation if no id present.
172-
:paramtype enable_automatic_id_generation: bool
173-
:keyword session_token: Token for use with Session consistency.
174-
:paramtype session_token: str
175-
:keyword initial_headers: Initial headers to be sent as part of the request.
176-
:paramtype initial_headers: dict[str,str]
168+
:paramtype indexing_directive: Union[int, ~azure.cosmos.documents.IndexingDirective]
169+
:keyword bool enable_automatic_id_generation: Enable automatic id generation if no id present.
170+
:keyword str session_token: Token for use with Session consistency.
171+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
177172
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
178173
has changed, and act according to the condition specified by the `match_condition` parameter.
179-
:paramtype etag: str
180174
:keyword match_condition: The match condition to use upon the etag.
181175
:paramtype match_condition: ~azure.core.MatchConditions
182176
:keyword response_hook: A callable invoked with the response metadata.
@@ -219,8 +213,9 @@ async def read_item(
219213
:type item: Union[str, Dict[str, Any]]
220214
:param partition_key: Partition key for the item to retrieve.
221215
:type partition_key: Union[str, int, float, bool]
216+
:keyword str post_trigger_include: trigger id to be used as post operation trigger.
222217
:keyword str session_token: Token for use with Session consistency.
223-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
218+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
224219
:keyword response_hook: A callable invoked with the response metadata.
225220
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
226221
**Provisional** keyword argument max_integrated_cache_staleness_in_ms
@@ -245,6 +240,9 @@ async def read_item(
245240
request_options = _build_options(kwargs)
246241
response_hook = kwargs.pop('response_hook', None)
247242
request_options["partitionKey"] = self._set_partition_key(partition_key)
243+
post_trigger_include = kwargs.pop('post_trigger_include', None)
244+
if post_trigger_include is not None:
245+
request_options["postTriggerInclude"] = post_trigger_include
248246
max_integrated_cache_staleness_in_ms = kwargs.pop('max_integrated_cache_staleness_in_ms', None)
249247
if max_integrated_cache_staleness_in_ms is not None:
250248
validate_cache_staleness_value(max_integrated_cache_staleness_in_ms)
@@ -264,7 +262,7 @@ def read_all_items(
264262
265263
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
266264
:keyword str session_token: Token for use with Session consistency.
267-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
265+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
268266
:keyword response_hook: A callable invoked with the response metadata.
269267
:paramtype response_hook: Callable[[Dict[str, str], AsyncItemPaged[Dict[str, Any]]], None]
270268
**Provisional** keyword argument max_integrated_cache_staleness_in_ms
@@ -320,7 +318,7 @@ def query_items(
320318
indexing was opted out on the requested paths.
321319
:keyword bool populate_query_metrics: Enable returning query metrics in response headers.
322320
:keyword str session_token: Token for use with Session consistency.
323-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
321+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
324322
:keyword response_hook: A callable invoked with the response metadata.
325323
:paramtype response_hook: Callable[[Dict[str, str], AsyncItemPaged[Dict[str, Any]]], None]
326324
**Provisional** keyword argument max_integrated_cache_staleness_in_ms
@@ -447,8 +445,7 @@ async def upsert_item(
447445
:keyword str pre_trigger_include: trigger id to be used as pre operation trigger.
448446
:keyword str post_trigger_include: trigger id to be used as post operation trigger.
449447
:keyword str session_token: Token for use with Session consistency.
450-
:paramtype session_token: str
451-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
448+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
452449
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
453450
has changed, and act according to the condition specified by the `match_condition` parameter.
454451
:keyword match_condition: The match condition to use upon the etag.
@@ -496,7 +493,7 @@ async def replace_item(
496493
:keyword str pre_trigger_include: trigger id to be used as pre operation trigger.
497494
:keyword str post_trigger_include: trigger id to be used as post operation trigger.
498495
:keyword str session_token: Token for use with Session consistency.
499-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
496+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
500497
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
501498
has changed, and act according to the condition specified by the `match_condition` parameter.
502499
:keyword match_condition: The match condition to use upon the etag.
@@ -544,7 +541,7 @@ async def delete_item(
544541
:keyword str pre_trigger_include: trigger id to be used as pre operation trigger.
545542
:keyword str post_trigger_include: trigger id to be used as post operation trigger.
546543
:keyword str session_token: Token for use with Session consistency.
547-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
544+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
548545
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
549546
has changed, and act according to the condition specified by the `match_condition` parameter.
550547
:keyword match_condition: The match condition to use upon the etag.
@@ -581,7 +578,7 @@ async def get_throughput(self, **kwargs: Any) -> ThroughputProperties:
581578
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No throughput properties exist for the container
582579
or the throughput properties could not be retrieved.
583580
:returns: ThroughputProperties for the container.
584-
:rtype: ~azure.cosmos.ThroughputProperties
581+
:rtype: ~azure.cosmos.offer.ThroughputProperties
585582
"""
586583
response_hook = kwargs.pop('response_hook', None)
587584
properties = await self._get_properties()
@@ -615,7 +612,7 @@ async def replace_throughput(self, throughput: int, **kwargs: Any) -> Throughput
615612
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: No throughput properties exist for the container
616613
or the throughput properties could not be updated.
617614
:returns: ThroughputProperties for the container, updated with new throughput.
618-
:rtype: ~azure.cosmos.ThroughputProperties
615+
:rtype: ~azure.cosmos.offer.ThroughputProperties
619616
"""
620617
response_hook = kwargs.pop('response_hook', None)
621618
properties = await self._get_properties()

sdk/cosmos/azure-cosmos/azure/cosmos/aio/cosmos_client.py renamed to sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,10 @@ async def create_database( # pylint: disable=redefined-builtin
195195
"""
196196
Create a new database with the given ID (name).
197197
198-
:param id: ID (name) of the database to create.
199-
:type id: str
198+
:param str id: ID (name) of the database to create.
200199
:keyword int offer_throughput: The provisioned throughput for this offer.
201200
:keyword str session_token: Token for use with Session consistency.
202-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
201+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
203202
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
204203
has changed, and act according to the condition specified by the `match_condition` parameter.
205204
:keyword match_condition: The match condition to use upon the etag.
@@ -250,7 +249,7 @@ async def create_database_if_not_exists( # pylint: disable=redefined-builtin
250249
:param str id: ID (name) of the database to read or create.
251250
:keyword int offer_throughput: The provisioned throughput for this offer.
252251
:keyword str session_token: Token for use with Session consistency.
253-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
252+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
254253
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
255254
has changed, and act according to the condition specified by the `match_condition` parameter.
256255
:keyword match_condition: The match condition to use upon the etag.
@@ -299,7 +298,7 @@ def list_databases(
299298
300299
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
301300
:keyword str session_token: Token for use with Session consistency.
302-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
301+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
303302
:keyword response_hook: A callable invoked with the response metadata.
304303
:paramtype response_hook: Callable[[Dict[str, str]], None]
305304
:returns: An AsyncItemPaged of database properties (dicts).
@@ -329,7 +328,7 @@ def query_databases(
329328
:paramtype parameters: List[Dict[str, Any]]
330329
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
331330
:keyword str session_token: Token for use with Session consistency.
332-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
331+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
333332
:keyword response_hook: A callable invoked with the response metadata.
334333
:paramtype response_hook: Callable[[Dict[str, str]], None]
335334
:returns: An AsyncItemPaged of database properties (dicts).
@@ -363,7 +362,7 @@ async def delete_database(
363362
instance of the database to delete.
364363
:type database: Union[str, ~azure.cosmos.DatabaseProxy, Dict[str, Any]]
365364
:keyword str session_token: Token for use with Session consistency.
366-
:keyword Dict[str, str] initial_headers: Initial headers to be sent as part of the request.
365+
:keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request.
367366
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
368367
has changed, and act according to the condition specified by the `match_condition` parameter.
369368
:keyword match_condition: The match condition to use upon the etag.

0 commit comments

Comments
 (0)