Skip to content
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

Add context manager API to Key Vault clients #9906

Merged
merged 10 commits into from
Feb 21, 2020

Conversation

chlowell
Copy link
Member

With this change Key Vault clients expose context manager APIs wrapping their autorest-generated clients (closes #7228). Implementing this would have required changes to the KeyVaultClient class wrapping those clients. Because that class is unnecessarily complex and the reason azure-keyvault-* depends on azure-common, I took this opportunity to replace it with simpler code (closes #8370).

Sorry for the large diff. Most of it is duplicating shared code across libraries. You can filter out the "copy shared code" commit to hide all that.

@chlowell chlowell added KeyVault Client This issue points to a problem in the data-plane of the library. labels Feb 19, 2020
@chlowell chlowell requested a review from schaabs as a code owner February 19, 2020 18:07
@chlowell chlowell self-assigned this Feb 19, 2020
client = CertificateClient(vault_url="https://localhost", credential=object(), transport=transport)

async with client:
assert transport.__aenter__.call_count == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is transport.aenter.call_count checked twice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paranoid thoroughness 😸
__aenter__ should only be called once. Possibly client.__aenter__ calls it twice, or client.__aexit__ calls it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. KeyVault
Projects
None yet
3 participants