-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cosmos] item operation response includes response headers #35791
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API change check APIView has identified API level changes in this PR and created following API reviews. |
annatisch
reviewed
Jun 11, 2024
/azp run python - cosmos - tests |
Adding a reference to underlying Azure SDK feature issue: #32571 |
simorenoh
requested review from
kushagraThapar,
xinlian12,
bambriz and
Pilchie
as code owners
June 19, 2024 16:42
simorenoh
changed the title
[Cosmos] item response includes response headers
[Cosmos] item operation response includes response headers
Jul 20, 2024
/azp run python - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
xinlian12
reviewed
Aug 1, 2024
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
annatisch
reviewed
Aug 1, 2024
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
annatisch
reviewed
Oct 15, 2024
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Outdated
Show resolved
Hide resolved
/azp run python - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
annatisch
approved these changes
Oct 16, 2024
This was referenced Oct 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We do not have a good way for users to access response headers. Currently, we use a last_response_headers dictionary (map) that gets cached in the client instance, and recommend users look at headers like such:
Not only is this design not intuitive, it is not thread safe, so using it directly has no real guarantees of validity depending on what the user is trying to do. Separately, we also allow users to pass in a function/method/callable response_hook, and have recently made that functionality thread safe, but having to require users to send in a function/method/callable in order to access these headers is also less than ideal from a UX perspective. Since in Cosmos headers can be highly relevant to user cases, this PR attempts to improve the user experience.
This PR adds the ability to fetch response headers for a given operation directly from its response through a newly introduced method. The new return type can do this, while still maintaining its ability to work as previously, with
CosmosDict
behaving like a dict andCosmosList
behaving like a list.This means an operation response like this:
Would now be able to have direct knowledge into the response headers associated with it by doing this, and would be able to use that information directly:
For query operations, since each request is made to one partition at once, aggregating the results of an entire query result for cross-partition scenarios is going to be a separate issue. For now, much like in the Java SDK we will collect headers on a per-page basis for pagination scenarios - and in this case the headers will be updated in the pageable object as the user goes through each of them:
and then the next page:
Items in this PR: