Skip to content

Commit

Permalink
Add context manager API to Key Vault clients (#9906)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored Feb 21, 2020
1 parent 7dc041d commit 0ceb22f
Show file tree
Hide file tree
Showing 51 changed files with 750 additions and 1,073 deletions.
4 changes: 3 additions & 1 deletion sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Release History

## 4.0.2 (Unreleased)

- `CertificateClient` instances have a `close` method which closes opened
sockets. Used as a context manager, a `CertificateClient` closes opened sockets
on exit. ([#9906](https://github.com/Azure/azure-sdk-for-python/pull/9906))

## 4.0.1 (2020-02-11)
- `azure.keyvault.certificates` defines `__version__`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def begin_create_certificate(self, certificate_name, policy, **kwargs):
tags = kwargs.pop("tags", None)

if enabled is not None:
attributes = self._client.models.CertificateAttributes(enabled=enabled)
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None

Expand Down Expand Up @@ -359,7 +359,7 @@ def import_certificate(self, certificate_name, certificate_bytes, **kwargs):
policy = kwargs.pop("policy", None)

if enabled is not None:
attributes = self._client.models.CertificateAttributes(enabled=enabled)
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None
base64_encoded_certificate = base64.b64encode(certificate_bytes).decode("utf-8")
Expand Down Expand Up @@ -442,7 +442,7 @@ def update_certificate_properties(self, certificate_name, version=None, **kwargs
enabled = kwargs.pop("enabled", None)

if enabled is not None:
attributes = self._client.models.CertificateAttributes(enabled=enabled)
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None

Expand Down Expand Up @@ -760,7 +760,7 @@ def merge_certificate(self, certificate_name, x509_certificates, **kwargs):
enabled = kwargs.pop("enabled", None)

if enabled is not None:
attributes = self._client.models.CertificateAttributes(enabled=enabled)
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None
bundle = self._client.merge_certificate(
Expand Down Expand Up @@ -832,12 +832,12 @@ def create_issuer(self, issuer_name, provider, **kwargs):
admin_contacts = kwargs.pop("admin_contacts", None)

if account_id or password:
issuer_credentials = self._client.models.IssuerCredentials(account_id=account_id, password=password)
issuer_credentials = self._models.IssuerCredentials(account_id=account_id, password=password)
else:
issuer_credentials = None
if admin_contacts:
admin_details = [
self._client.models.AdministratorDetails(
self._models.AdministratorDetails(
first_name=contact.first_name,
last_name=contact.last_name,
email_address=contact.email,
Expand All @@ -848,13 +848,13 @@ def create_issuer(self, issuer_name, provider, **kwargs):
else:
admin_details = None
if organization_id or admin_details:
organization_details = self._client.models.OrganizationDetails(
organization_details = self._models.OrganizationDetails(
id=organization_id, admin_details=admin_details
)
else:
organization_details = None
if enabled is not None:
issuer_attributes = self._client.models.IssuerAttributes(enabled=enabled)
issuer_attributes = self._models.IssuerAttributes(enabled=enabled)
else:
issuer_attributes = None
issuer_bundle = self._client.set_certificate_issuer(
Expand Down Expand Up @@ -895,12 +895,12 @@ def update_issuer(self, issuer_name, **kwargs):
admin_contacts = kwargs.pop("admin_contacts", None)

if account_id or password:
issuer_credentials = self._client.models.IssuerCredentials(account_id=account_id, password=password)
issuer_credentials = self._models.IssuerCredentials(account_id=account_id, password=password)
else:
issuer_credentials = None
if admin_contacts:
admin_details = [
self._client.models.AdministratorDetails(
self._models.AdministratorDetails(
first_name=contact.first_name,
last_name=contact.last_name,
email_address=contact.email,
Expand All @@ -911,13 +911,13 @@ def update_issuer(self, issuer_name, **kwargs):
else:
admin_details = None
if organization_id or admin_details:
organization_details = self._client.models.OrganizationDetails(
organization_details = self._models.OrganizationDetails(
id=organization_id, admin_details=admin_details
)
else:
organization_details = None
if enabled is not None:
issuer_attributes = self._client.models.IssuerAttributes(enabled=enabled)
issuer_attributes = self._models.IssuerAttributes(enabled=enabled)
else:
issuer_attributes = None
issuer_bundle = self._client.update_certificate_issuer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from .key_vault_client import KeyVaultClient

__all__ = ["KeyVaultClient"]

This file was deleted.

Loading

0 comments on commit 0ceb22f

Please sign in to comment.