Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
ff20cf9
change default read timeout
tvaron3 Feb 6, 2025
40e43c4
fix tests
tvaron3 Feb 6, 2025
faf6c27
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Feb 6, 2025
aefe30b
Add read timeout tests for database account calls
tvaron3 Feb 6, 2025
9a234f8
fix timeout retry policy
tvaron3 Feb 6, 2025
8859c9f
Fixed the timeout logic
kushagraThapar Feb 6, 2025
8b166fc
Merge pull request #2 from tvaron3/tvaron3/readTimeout
kushagraThapar Feb 6, 2025
ac78da9
Fixed the timeout retry policy
kushagraThapar Feb 6, 2025
e8bc02e
Merge pull request #3 from tvaron3/readtimeout
kushagraThapar Feb 6, 2025
09aac90
Mock tests for timeout and failover retry policy
tvaron3 Feb 6, 2025
48a20fa
Merge branch 'tvaron3/readtimeout' of https://github.com/tvaron3/azur…
FabianMeiswinkel Feb 6, 2025
f22e7d2
Create test_dummy.py
FabianMeiswinkel Feb 7, 2025
dd8a466
Update test_dummy.py
FabianMeiswinkel Feb 7, 2025
8ac11c5
Update test_dummy.py
FabianMeiswinkel Feb 7, 2025
b53e2e9
Update test_dummy.py
FabianMeiswinkel Feb 7, 2025
973ec44
Iterating on fault injection tooling
FabianMeiswinkel Feb 7, 2025
f25af53
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
FabianMeiswinkel Feb 7, 2025
5d72848
Refactoring to have FaultInjectionTransport in its own file
FabianMeiswinkel Feb 7, 2025
8c9aa4b
Update test_dummy.py
FabianMeiswinkel Feb 10, 2025
7260e9d
Reafctoring FaultInjectionTransport
FabianMeiswinkel Feb 18, 2025
bf3e60b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
FabianMeiswinkel Feb 19, 2025
0705aeb
Iterating on tests
FabianMeiswinkel Feb 19, 2025
baf7aea
Prettifying tests
FabianMeiswinkel Feb 20, 2025
e90b722
small refactoring
FabianMeiswinkel Feb 21, 2025
cb58896
Adding MM topology on Emulator
FabianMeiswinkel Feb 21, 2025
46ec31c
Adding cross region retry tests
FabianMeiswinkel Feb 22, 2025
f03f51f
Add Excluded Locations Feature
allenkim0129 Mar 31, 2025
cf42098
initial ppcb changes
tvaron3 Mar 31, 2025
9d46122
add missing changes
tvaron3 Apr 1, 2025
af6c72b
Merge with main
tvaron3 Apr 1, 2025
4efa9ad
fix mypy errors
tvaron3 Apr 1, 2025
d86d381
Refactored gem for ppcb and hooked up retryconfigurations with failur…
tvaron3 Apr 2, 2025
d6406f0
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 2, 2025
3d8ed69
merge with main
tvaron3 Apr 2, 2025
9e51011
fix use multiple write locations bug
tvaron3 Apr 2, 2025
1896338
merge excluded locations
tvaron3 Apr 2, 2025
8d27651
clean up and revert vs env variable changes
tvaron3 Apr 2, 2025
90fe5c2
remove async await
tvaron3 Apr 2, 2025
206be78
refactor and fix tests
tvaron3 Apr 2, 2025
622589f
Fix refactoring
tvaron3 Apr 2, 2025
4dd17ea
Fix tests
tvaron3 Apr 3, 2025
e631b74
fix tests
tvaron3 Apr 3, 2025
2d5f0d7
add more tests
tvaron3 Apr 3, 2025
f04a506
add more tests
tvaron3 Apr 3, 2025
bcee9cf
Add tests
tvaron3 Apr 3, 2025
80f4ddd
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 3, 2025
779f9d1
fix tests
tvaron3 Apr 3, 2025
b4db22e
fix tests
tvaron3 Apr 3, 2025
9a94d02
fix tests
tvaron3 Apr 3, 2025
9471b7a
Merge branch 'users/fabianm/tests' of https://github.com/FabianMeiswi…
tvaron3 Apr 3, 2025
eab1b63
fix test
tvaron3 Apr 3, 2025
93c2d7d
fix test
tvaron3 Apr 3, 2025
345f390
fix tests
tvaron3 Apr 3, 2025
fe74aa0
fix async in test
tvaron3 Apr 3, 2025
5bb9f1f
Added multi-region tests
kushagraThapar Apr 3, 2025
996217a
Fix _AddParitionKey to pass options to sub methods
allenkim0129 Apr 3, 2025
41fc917
Added initial live tests
allenkim0129 Apr 3, 2025
07b8f39
Updated live-platform-matrix for multi-region tests
allenkim0129 Apr 3, 2025
1b09739
initial sync version of fault injection
tvaron3 Apr 3, 2025
0f0a991
Merge branch 'users/fabianm/tests' of https://github.com/tvaron3/azur…
tvaron3 Apr 3, 2025
2fb3dc9
add all sync tests
tvaron3 Apr 3, 2025
7b81482
add new error and fix logs
tvaron3 Apr 3, 2025
f355e30
fix test
tvaron3 Apr 3, 2025
3056787
Merge branch 'users/fabianm/tests' of https://github.com/FabianMeiswi…
tvaron3 Apr 3, 2025
8495c51
Add cosmosQuery mark to TestQuery
allenkim0129 Apr 4, 2025
b29980c
Correct spelling
allenkim0129 Apr 4, 2025
5e79172
Fixed live platform matrix syntax
allenkim0129 Apr 4, 2025
fd40cd7
Changed Multi-regions
allenkim0129 Apr 4, 2025
85e1206
first ppcb test
tvaron3 Apr 4, 2025
96124fe
merge with main
tvaron3 Apr 4, 2025
34e3d82
fix test
tvaron3 Apr 7, 2025
ce14666
refactor due to pk range wrapper needing io call and pylint
tvaron3 Apr 7, 2025
7b939e8
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 7, 2025
b33cfb6
Merge branch 'user/allekim/feature/addExcludedLocations' of https://g…
tvaron3 Apr 7, 2025
29305f4
Added client level ExcludedLocation for async
allenkim0129 Apr 7, 2025
c77b4e7
Update Live test settings
allenkim0129 Apr 7, 2025
d82fa74
Added Async tests
allenkim0129 Apr 7, 2025
5610889
Add more live tests for all other Python versions
allenkim0129 Apr 7, 2025
f4cb8b3
Fix Async test failure
allenkim0129 Apr 8, 2025
e98ab57
add test for failure_rate threshold
tvaron3 Apr 8, 2025
9b0236d
Merge branch 'main' into user/allekim/feature/addExcludedLocations
allenkim0129 Apr 8, 2025
4f08168
Fix live test failures
allenkim0129 Apr 8, 2025
36407c6
fix pylint and cspell
tvaron3 Apr 8, 2025
4e2fd6b
Fix live test failures
allenkim0129 Apr 8, 2025
1baf872
fix pylint
tvaron3 Apr 8, 2025
e0dab29
Fix live test failures
allenkim0129 Apr 8, 2025
798c12f
Add test_delete_all_items_by_partition_key
allenkim0129 Apr 8, 2025
2c5b8fc
Remove test_delete_all_items_by_partition_key
allenkim0129 Apr 8, 2025
739e090
fix and add tests
tvaron3 Apr 9, 2025
d5c380a
add collection rid to batch
tvaron3 Apr 9, 2025
e7f7265
add partition key range id to partition key range to cache
tvaron3 Apr 9, 2025
38f8033
address failures
tvaron3 Apr 9, 2025
828a99b
update tests
tvaron3 Apr 9, 2025
2b9b58f
Added missing doc for excluded_locations in async client
allenkim0129 Apr 10, 2025
1c98b48
Remove duplicate functions
allenkim0129 Apr 10, 2025
b5accfa
add more operations
tvaron3 Apr 10, 2025
8324a71
Fix live tests with multi write locations
allenkim0129 Apr 11, 2025
b65f07d
Fixed bug with endpoint routing with multi write region partition key…
allenkim0129 Apr 11, 2025
4a144d9
Adding emulator tests for delete_all_items_by_partition_key API
allenkim0129 Apr 11, 2025
9c68f75
minimized duplicate codes
allenkim0129 Apr 14, 2025
225bc26
Added Async emulator tests
allenkim0129 Apr 14, 2025
a6e556e
Merge branch 'main' into user/allekim/feature/addExcludedLocations
allenkim0129 Apr 14, 2025
5f2c5a0
Nit: Changed test names
allenkim0129 Apr 14, 2025
c3e39e5
Addressed comments about documents
allenkim0129 Apr 15, 2025
fc8e58a
Merge branch 'user/allekim/feature/addExcludedLocations' of https://g…
tvaron3 Apr 16, 2025
39a464c
live tests
tvaron3 Apr 17, 2025
d70343c
fix tests
tvaron3 Apr 17, 2025
137a130
add container rid
tvaron3 Apr 17, 2025
08e9e45
fix mm tests
tvaron3 Apr 18, 2025
72a9f48
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 18, 2025
fdba914
test improvements
tvaron3 Apr 18, 2025
8ee6b3e
recovering optimizations, lower request timeout, disable in region re…
tvaron3 Apr 19, 2025
8a45b4c
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 19, 2025
b80b20c
recovering optimizations, lower request timeout, disable in region re…
tvaron3 Apr 20, 2025
e3ab320
fix transitions from a success
tvaron3 Apr 21, 2025
9307157
Implement exponential backoff
tvaron3 Apr 21, 2025
0a0df4f
fix pylint
tvaron3 Apr 21, 2025
b7effee
add sync tests
tvaron3 Apr 21, 2025
5a235c5
refactor tests
tvaron3 Apr 21, 2025
0f85716
sync changes
tvaron3 Apr 21, 2025
397d087
sync changes and cleanup
tvaron3 Apr 22, 2025
9ee3e87
container cache changes
tvaron3 Apr 22, 2025
870296d
revert change
tvaron3 Apr 23, 2025
12df430
add extra mapping to container cache
tvaron3 Apr 23, 2025
b493b36
fix emulator tests
tvaron3 Apr 23, 2025
998aaa7
add sync single master tests
tvaron3 Apr 23, 2025
64b02bd
fix tests
tvaron3 Apr 23, 2025
fd76117
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 23, 2025
d78838e
fix tests
tvaron3 Apr 23, 2025
2ffddf1
fix tests
tvaron3 Apr 23, 2025
8cb5159
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 23, 2025
f5acc27
fix tests
tvaron3 Apr 23, 2025
477c299
fix tests
tvaron3 Apr 23, 2025
b7521fd
fix tests
tvaron3 Apr 23, 2025
9e0ed7e
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 23, 2025
d1e553e
test changes
tvaron3 Apr 24, 2025
454a3ce
fix some tests
tvaron3 Apr 24, 2025
629e07b
fix tests
tvaron3 Apr 25, 2025
ffbf716
Merge with main
tvaron3 Apr 25, 2025
dd5034d
Rename test files
tvaron3 Apr 25, 2025
5d942d2
fix tests and setup ppcb pipeline
tvaron3 Apr 25, 2025
ef52e43
fix tests
tvaron3 Apr 25, 2025
218cf2a
fix ci tests
tvaron3 Apr 27, 2025
7952bba
move all ppcb tests to live tests
tvaron3 Apr 27, 2025
1b41c73
add logger for ppcb test
tvaron3 Apr 27, 2025
28a4cc4
fix ci tests
tvaron3 Apr 27, 2025
1047e47
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 27, 2025
0096d84
fix tests
tvaron3 Apr 27, 2025
fc3d2ba
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 27, 2025
153903e
fixed resource token bug and tests
tvaron3 Apr 28, 2025
c3166bb
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 28, 2025
ff22510
fix tests and split up them up across to live tests pipelines
tvaron3 Apr 29, 2025
d9c24c4
fix tests and cspell
tvaron3 Apr 29, 2025
6e1c8d5
add sync deleta all item partiton key tests
tvaron3 Apr 29, 2025
b83b1c9
fix tests
tvaron3 Apr 29, 2025
09934aa
fix ci tests
tvaron3 Apr 29, 2025
3d71dc5
fix tests
tvaron3 Apr 29, 2025
d09a445
fix ci
tvaron3 Apr 29, 2025
1eb29e9
fix ci
tvaron3 Apr 29, 2025
e9cc6f1
refactor tests, removed print statements, and added async emulator de…
tvaron3 Apr 29, 2025
adf1cad
fix tests
tvaron3 Apr 29, 2025
c4e28f8
fix ci tests
tvaron3 Apr 29, 2025
eb2b74a
Merge branch 'tvaron3/ppcb' of https://github.com/tvaron3/azure-sdk-f…
tvaron3 Apr 29, 2025
8cb02e1
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 Apr 30, 2025
416bb91
fix live tests
tvaron3 May 1, 2025
399df8a
fix tests
tvaron3 May 1, 2025
aefc42d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 1, 2025
bdf5025
remove unnecessary line
tvaron3 May 3, 2025
fd755c0
fix tests
tvaron3 May 5, 2025
c6ddb12
fix tests
tvaron3 May 5, 2025
ba7ac08
fix tests
tvaron3 May 5, 2025
afd8b61
fix tests
tvaron3 May 5, 2025
a9e449e
fix tests
tvaron3 May 5, 2025
bf6a7c2
fix tests
tvaron3 May 5, 2025
c46cdc7
fix tests
tvaron3 May 6, 2025
75d3781
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 7, 2025
61b15e9
remove unused logger
tvaron3 May 8, 2025
d0feac2
add regression testing for cross partition queries
tvaron3 May 12, 2025
9c34f41
react to comments
tvaron3 May 12, 2025
4d5a1f9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 12, 2025
08075bd
react to comments
tvaron3 May 13, 2025
adce28f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 27, 2025
da362fc
react to async client changes from merge
tvaron3 May 27, 2025
ef41d9d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 27, 2025
c29c52a
react to comments
tvaron3 May 27, 2025
2feca2a
fix tests
tvaron3 May 27, 2025
c0441bf
react to comments and fix tests
tvaron3 May 28, 2025
5f8b7e8
react to comments and fix tests
tvaron3 May 28, 2025
9c37222
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
tvaron3 May 28, 2025
3010aa5
fix tests
tvaron3 May 28, 2025
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
2 changes: 2 additions & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#### Features Added
* Added ability to set a user agent suffix at the client level. See [PR 40904](https://github.com/Azure/azure-sdk-for-python/pull/40904)
* Added ability to use request level `excluded_locations` on metadata calls, such as getting container properties. See [PR 40905](https://github.com/Azure/azure-sdk-for-python/pull/40905)
* Per partition circuit breaker support. It can be enabled through the environment variable `AZURE_COSMOS_ENABLE_CIRCUIT_BREAKER`. See [PR 40302](https://github.com/Azure/azure-sdk-for-python/pull/40302).

#### Bugs Fixed
* Fixed how resource tokens are parsed for metadata calls in the lifecycle of a document operation. See [PR 40302](https://github.com/Azure/azure-sdk-for-python/pull/40302).
* Fixed issue where Query Change Feed did not return items if the container uses legacy Hash V1 Partition Keys. This also fixes issues with not being able to change feed query for Specific Partition Key Values for HPK. See [PR 41270](https://github.com/Azure/azure-sdk-for-python/pull/41270/)

#### Other Changes
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ def _format_batch_operations(
return final_operations


def _set_properties_cache(properties: Dict[str, Any]) -> Dict[str, Any]:
def _build_properties_cache(properties: Dict[str, Any], container_link: str) -> Dict[str, Any]:
return {
"_self": properties.get("_self", None), "_rid": properties.get("_rid", None),
"partitionKey": properties.get("partitionKey", None)
"partitionKey": properties.get("partitionKey", None), "container_link": container_link
}
10 changes: 10 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class _Constants:
HS_MAX_ITEMS_CONFIG_DEFAULT: int = 1000
MAX_ITEM_BUFFER_VS_CONFIG: str = "AZURE_COSMOS_MAX_ITEM_BUFFER_VECTOR_SEARCH"
MAX_ITEM_BUFFER_VS_CONFIG_DEFAULT: int = 50000
CIRCUIT_BREAKER_ENABLED_CONFIG: str = "AZURE_COSMOS_ENABLE_CIRCUIT_BREAKER"
CIRCUIT_BREAKER_ENABLED_CONFIG_DEFAULT: str = "False"
# Only applicable when circuit breaker is enabled -------------------------
CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_READ: str = "AZURE_COSMOS_CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_READ"
CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_READ_DEFAULT: int = 10
CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_WRITE: str = "AZURE_COSMOS_CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_WRITE"
CONSECUTIVE_ERROR_COUNT_TOLERATED_FOR_WRITE_DEFAULT: int = 5
FAILURE_PERCENTAGE_TOLERATED = "AZURE_COSMOS_FAILURE_PERCENTAGE_TOLERATED"
FAILURE_PERCENTAGE_TOLERATED_DEFAULT: int = 90
# -------------------------------------------------------------------------

# Error code translations
ERROR_TRANSLATIONS: Dict[int, str] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ def ShouldRetry(self, exception: Optional[Any]) -> bool:
def __find_container_link_with_rid(self, container_properties_caches: Optional[Dict[str, Any]], rid: str) -> \
Optional[str]:
if container_properties_caches:
for key, inner_dict in container_properties_caches.items():
is_match = next((k for k, v in inner_dict.items() if v == rid), None)
if is_match:
return key
if rid in container_properties_caches:
return container_properties_caches[rid]["container_link"]
# If we cannot get the container link at all it might mean the cache was somehow deleted, this isn't
# a container request so this retry is not needed. Return None.
return None
Expand Down
90 changes: 60 additions & 30 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
HttpResponse # pylint: disable=no-legacy-azure-core-http-response-import

from . import _base as base
from . import _global_endpoint_manager as global_endpoint_manager
from ._global_partition_endpoint_manager_circuit_breaker import _GlobalPartitionEndpointManagerForCircuitBreaker
from . import _query_iterable as query_iterable
from . import _runtime_constants as runtime_constants
from . import _session
Expand All @@ -57,7 +57,7 @@
from . import documents
from . import http_constants, exceptions
from ._auth_policy import CosmosBearerTokenCredentialPolicy
from ._base import _set_properties_cache
from ._base import _build_properties_cache
from ._change_feed.change_feed_iterable import ChangeFeedIterable
from ._change_feed.change_feed_state import ChangeFeedState
from ._constants import _Constants as Constants
Expand Down Expand Up @@ -168,7 +168,7 @@ def __init__( # pylint: disable=too-many-statements
self.last_response_headers: CaseInsensitiveDict = CaseInsensitiveDict()

self.UseMultipleWriteLocations = False
self._global_endpoint_manager = global_endpoint_manager._GlobalEndpointManager(self)
self._global_endpoint_manager = _GlobalPartitionEndpointManagerForCircuitBreaker(self)

retry_policy = None
if isinstance(self.connection_policy.ConnectionRetryConfiguration, HTTPPolicy):
Expand Down Expand Up @@ -262,6 +262,7 @@ def _set_container_properties_cache(self, container_link: str, properties: Optio
:type properties: Optional[Dict[str, Any]]"""
if properties:
self.__container_properties_cache[container_link] = properties
self.__container_properties_cache[properties["_rid"]] = properties
else:
self.__container_properties_cache[container_link] = {}

Expand Down Expand Up @@ -1295,8 +1296,13 @@ def CreateItem(

if base.IsItemContainerLink(database_or_container_link):
options = self._AddPartitionKey(database_or_container_link, document, options)
return self.Create(document, path, http_constants.ResourceType.Document, collection_id, None,
options, **kwargs)
return self.Create(document,
path,
http_constants.ResourceType.Document,
collection_id,
None,
options,
**kwargs)

def UpsertItem(
self,
Expand Down Expand Up @@ -1332,8 +1338,13 @@ def UpsertItem(
collection_id, document, path = self._GetContainerIdWithPathForItem(
database_or_container_link, document, options
)
return self.Upsert(document, path, http_constants.ResourceType.Document, collection_id, None,
options, **kwargs)
return self.Upsert(document,
path,
http_constants.ResourceType.Document,
collection_id,
None,
options,
**kwargs)

PartitionResolverErrorMessage = (
"Couldn't find any partition resolvers for the database link provided. "
Expand Down Expand Up @@ -2020,8 +2031,13 @@ def ReplaceItem(
collection_link = base.GetItemContainerLink(document_link)
options = self._AddPartitionKey(collection_link, new_document, options)

return self.Replace(new_document, path, http_constants.ResourceType.Document, document_id, None,
options, **kwargs)
return self.Replace(new_document,
path,
http_constants.ResourceType.Document,
document_id,
None,
options,
**kwargs)

def PatchItem(
self,
Expand Down Expand Up @@ -2052,7 +2068,9 @@ def PatchItem(
headers = base.GetHeaders(self, self.default_headers, "patch", path, document_id, resource_type,
documents._OperationType.Patch, options)
# Patch will use WriteEndpoint since it uses PUT operation
request_params = RequestObject(resource_type, documents._OperationType.Patch)
request_params = RequestObject(resource_type,
documents._OperationType.Patch,
headers)
request_params.set_excluded_location_from_options(options)
request_data = {}
if options.get("filterPredicate"):
Expand Down Expand Up @@ -2142,7 +2160,9 @@ def _Batch(
headers = base.GetHeaders(self, initial_headers, "post", path, collection_id,
http_constants.ResourceType.Document,
documents._OperationType.Batch, options)
request_params = RequestObject(http_constants.ResourceType.Document, documents._OperationType.Batch)
request_params = RequestObject(http_constants.ResourceType.Document,
documents._OperationType.Batch,
headers)
request_params.set_excluded_location_from_options(options)
return cast(
Tuple[List[Dict[str, Any]], CaseInsensitiveDict],
Expand Down Expand Up @@ -2203,7 +2223,9 @@ def DeleteAllItemsByPartitionKey(
collection_id = base.GetResourceIdOrFullNameFromLink(collection_link)
headers = base.GetHeaders(self, self.default_headers, "post", path, collection_id,
http_constants.ResourceType.PartitionKey, documents._OperationType.Delete, options)
request_params = RequestObject(http_constants.ResourceType.PartitionKey, documents._OperationType.Delete)
request_params = RequestObject(http_constants.ResourceType.PartitionKey,
documents._OperationType.Delete,
headers)
request_params.set_excluded_location_from_options(options)
_, last_response_headers = self.__Post(
path=path,
Expand Down Expand Up @@ -2377,7 +2399,7 @@ def ExecuteStoredProcedure(

# ExecuteStoredProcedure will use WriteEndpoint since it uses POST operation
request_params = RequestObject(http_constants.ResourceType.StoredProcedure,
documents._OperationType.ExecuteJavaScript)
documents._OperationType.ExecuteJavaScript, headers)
result, self.last_response_headers = self.__Post(path, request_params, params, headers, **kwargs)
return result

Expand Down Expand Up @@ -2573,7 +2595,9 @@ def GetDatabaseAccount(

headers = base.GetHeaders(self, self.default_headers, "get", "", "", "",
documents._OperationType.Read,{}, client_id=self.client_id)
request_params = RequestObject(http_constants.ResourceType.DatabaseAccount, documents._OperationType.Read,
request_params = RequestObject(http_constants.ResourceType.DatabaseAccount,
documents._OperationType.Read,
headers,
url_connection)
result, last_response_headers = self.__Get("", request_params, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -2623,7 +2647,9 @@ def _GetDatabaseAccountCheck(

headers = base.GetHeaders(self, self.default_headers, "get", "", "", "",
documents._OperationType.Read,{}, client_id=self.client_id)
request_params = RequestObject(http_constants.ResourceType.DatabaseAccount, documents._OperationType.Read,
request_params = RequestObject(http_constants.ResourceType.DatabaseAccount,
documents._OperationType.Read,
headers,
url_connection)
self.__Get("", request_params, headers, **kwargs)

Expand Down Expand Up @@ -2663,7 +2689,7 @@ def Create(
options)
# Create will use WriteEndpoint since it uses POST operation

request_params = RequestObject(typ, documents._OperationType.Create)
request_params = RequestObject(typ, documents._OperationType.Create, headers)
request_params.set_excluded_location_from_options(options)
result, last_response_headers = self.__Post(path, request_params, body, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -2710,7 +2736,7 @@ def Upsert(
headers[http_constants.HttpHeaders.IsUpsert] = True

# Upsert will use WriteEndpoint since it uses POST operation
request_params = RequestObject(typ, documents._OperationType.Upsert)
request_params = RequestObject(typ, documents._OperationType.Upsert, headers)
request_params.set_excluded_location_from_options(options)
result, last_response_headers = self.__Post(path, request_params, body, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -2754,7 +2780,7 @@ def Replace(
headers = base.GetHeaders(self, initial_headers, "put", path, id, typ, documents._OperationType.Replace,
options)
# Replace will use WriteEndpoint since it uses PUT operation
request_params = RequestObject(typ, documents._OperationType.Replace)
request_params = RequestObject(typ, documents._OperationType.Replace, headers)
request_params.set_excluded_location_from_options(options)
result, last_response_headers = self.__Put(path, request_params, resource, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -2796,7 +2822,7 @@ def Read(
initial_headers = initial_headers or self.default_headers
headers = base.GetHeaders(self, initial_headers, "get", path, id, typ, documents._OperationType.Read, options)
# Read will use ReadEndpoint since it uses GET operation
request_params = RequestObject(typ, documents._OperationType.Read)
request_params = RequestObject(typ, documents._OperationType.Read, headers)
request_params.set_excluded_location_from_options(options)
result, last_response_headers = self.__Get(path, request_params, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -2836,7 +2862,7 @@ def DeleteResource(
headers = base.GetHeaders(self, initial_headers, "delete", path, id, typ, documents._OperationType.Delete,
options)
# Delete will use WriteEndpoint since it uses DELETE operation
request_params = RequestObject(typ, documents._OperationType.Delete)
request_params = RequestObject(typ, documents._OperationType.Delete, headers)
request_params.set_excluded_location_from_options(options)
result, last_response_headers = self.__Delete(path, request_params, headers, **kwargs)
self.last_response_headers = last_response_headers
Expand Down Expand Up @@ -3069,24 +3095,27 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]:
initial_headers = self.default_headers.copy()
# Copy to make sure that default_headers won't be changed.
if query is None:
op_typ = documents._OperationType.QueryPlan if is_query_plan else documents._OperationType.ReadFeed
# Query operations will use ReadEndpoint even though it uses GET(for feed requests)
request_params = RequestObject(
resource_type,
documents._OperationType.QueryPlan if is_query_plan else documents._OperationType.ReadFeed
)
request_params.set_excluded_location_from_options(options)
headers = base.GetHeaders(
self,
initial_headers,
"get",
path,
resource_id,
resource_type,
request_params.operation_type,
op_typ,
options,
partition_key_range_id
)

request_params = RequestObject(
resource_type,
op_typ,
headers
)
request_params.set_excluded_location_from_options(options)

change_feed_state: Optional[ChangeFeedState] = options.get("changeFeedState")
if change_feed_state is not None:
feed_options = {}
Expand Down Expand Up @@ -3115,8 +3144,6 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]:
raise SystemError("Unexpected query compatibility mode.")

# Query operations will use ReadEndpoint even though it uses POST(for regular query operations)
request_params = RequestObject(resource_type, documents._OperationType.SqlQuery)
request_params.set_excluded_location_from_options(options)
req_headers = base.GetHeaders(
self,
initial_headers,
Expand All @@ -3129,6 +3156,9 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]:
partition_key_range_id
)

request_params = RequestObject(resource_type, documents._OperationType.SqlQuery, req_headers)
request_params.set_excluded_location_from_options(options)

# check if query has prefix partition key
isPrefixPartitionQuery = kwargs.pop("isPrefixPartitionQuery", None)
if isPrefixPartitionQuery and "partitionKeyDefinition" in kwargs:
Expand Down Expand Up @@ -3364,7 +3394,7 @@ def _refresh_container_properties_cache(self, container_link: str):
# If container properties cache is stale, refresh it by reading the container.
container = self.ReadContainer(container_link, options=None)
# Only cache Container Properties that will not change in the lifetime of the container
self._set_container_properties_cache(container_link, _set_properties_cache(container))
self._set_container_properties_cache(container_link, _build_properties_cache(container, container_link))

def _UpdateSessionIfRequired(
self,
Expand Down Expand Up @@ -3407,5 +3437,5 @@ def _get_partition_key_definition(
else:
container = self.ReadContainer(collection_link, options)
partition_key_definition = container.get("partitionKey")
self.__container_properties_cache[collection_link] = _set_properties_cache(container)
self._set_container_properties_cache(collection_link, _build_properties_cache(container, collection_link))
return partition_key_definition
Loading