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
Make returned responses more consistent #537
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update some of our documentation based on your changes. |
Codecov Report
@@ Coverage Diff @@
## develop #537 +/- ##
===========================================
- Coverage 83.03% 82.54% -0.49%
===========================================
Files 55 54 -1
Lines 2976 2859 -117
===========================================
- Hits 2471 2360 -111
+ Misses 505 499 -6
Continue to review full report at Codecov.
|
I just had the last-second realization that the I also forgot to mention in the original PR that I added an adapter option called |
I just realized an additional breaking change regarding this PR: the Unfortunately, I can't think of a good way to resolve this issue. The Requests Adapter is created from a user-specified class so we can't assume in advance what sort of data type it will return. What are your thoughts on this matter? I can revert the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we use this library for downstream ansible modules, i was mostly concerned with the expected return values; whether or not they change based on the new json adapter. based on initial tests i dont see breaking changes happening to https://github.com/TerryHowe/ansible-modules-hashivault
based on this consideration, this PR has my 👍 . it should definitely be minor or possibly major release though
print(client.auth.azure.read_config())
# prev: {'client_id': 'test', 'environment': 'AzurePublicCloud', 'resource': 'test', 'tenant_id': 'test'}
# new: {'client_id': 'test', 'environment': 'AzurePublicCloud', 'resource': 'test', 'tenant_id': 'test'}
the following outputs are identical except for request_id
(expected)
new `sys.list_auth_method` output
#list_auths NEW ''' { "token/": { "accessor": "auth_token_8e77bdb2", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "token based credentials", "local": false, "options": null, "seal_wrap": false, "type": "token", "uuid": "9aae3834-9e4e-3c3c-a891-d34b49f5dabd" }, "azure/": { "accessor": "auth_azure_2154cde7", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "", "local": false, "options": null, "seal_wrap": false, "type": "azure", "uuid": "504b59a1-7d52-fbd1-082f-c1625b165e58" }, "request_id": "62e1e72f-ebf0-0bde-1ef8-f5696135a07f", "lease_id": "", "renewable": false, "lease_duration": 0, "data": { "azure/": { "accessor": "auth_azure_2154cde7", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "", "local": false, "options": null, "seal_wrap": false, "type": "azure", "uuid": "504b59a1-7d52-fbd1-082f-c1625b165e58" }, "token/": { "accessor": "auth_token_8e77bdb2", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "token based credentials", "local": false, "options": null, "seal_wrap": false, "type": "token", "uuid": "9aae3834-9e4e-3c3c-a891-d34b49f5dabd" } }, "wrap_info": null, "warnings": null, "auth": null } '''previous `sys.list_auth_method` output
#list auths OLD ''' { "token/": { "accessor": "auth_token_8e77bdb2", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "token based credentials", "local": false, "options": null, "seal_wrap": false, "type": "token", "uuid": "9aae3834-9e4e-3c3c-a891-d34b49f5dabd" }, "azure/": { "accessor": "auth_azure_2154cde7", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "", "local": false, "options": null, "seal_wrap": false, "type": "azure", "uuid": "504b59a1-7d52-fbd1-082f-c1625b165e58" }, "request_id": "7797ff7c-0fcf-8469-083d-146f1cb0d7b9", "lease_id": "", "renewable": false, "lease_duration": 0, "data": { "azure/": { "accessor": "auth_azure_2154cde7", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "", "local": false, "options": null, "seal_wrap": false, "type": "azure", "uuid": "504b59a1-7d52-fbd1-082f-c1625b165e58" }, "token/": { "accessor": "auth_token_8e77bdb2", "config": { "default_lease_ttl": 0, "force_no_cache": false, "max_lease_ttl": 0, "token_type": "default-service" }, "description": "token based credentials", "local": false, "options": null, "seal_wrap": false, "type": "token", "uuid": "9aae3834-9e4e-3c3c-a891-d34b49f5dabd" } }, "wrap_info": null, "warnings": null, "auth": null } '''great work @llamasoft and thanks for the great contribution
Any word on if Unfortunately, removing them will be a breaking change for some users. |
I suppose I feel it makes most sense to return the entire response in all cases. In general, this module is intended to be a pretty basic wrapper for Vault API (at least as far as I'm concerned). |
I agree with @jeffwecan . we had explored the idea of making all returns just the |
This looks like an nice improvement ! |
@Lucas-C: I figure it is about time to get this PR put in place! :D Will start working on getting it trued back up with the current state of the develop branch... |
Planning on merging this in today. To close the loop on returning the entire response dicts versus only the data key: I still want to see use move to the former in all places eventually. However I'd rather tackle that in another PR / release since its most certainly a breaking change (as @llamasoft alluded to). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, this one was really confusing, because the documentation, which really copies doctstrings from the source code, still says to expect |
I would imagine so, and sorry for the added confusion! @trishankatdatadog, I went ahead and quoted your comment into a new issue (#537) and will try to get a review of docstrings, etc. done, and any incorrect return types updated, sometime over the next week or so. (Though contributions along those lines are of course also very welcomed. ☺) |
Thanks! Also wrong link for issue 🙂 |
This is another big PR so apologies in advance. This PR fixes issue #525 and arises from the discussion therein.
This PR does one thing: create a new JSONAdapter and makes it the default. The "JSON adapter" works just like the previous "Request" adapter except the return value uses the following logic:
The net result is that all client functions now have consistent logic regarding what they return.
As a result, all instances of the following client logic have been removed:
and
This will likely cause some breaking changes for some users, especially with regards to the direct
client.[read,list,write,delete]
methods as they will no longer throw a ValueError from assuming the response always contains a JSON body.