Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
got rid of error mapping, README uses HttpResponseError instead
  • Loading branch information
iscai-msft committed Sep 5, 2019
commit 5ff9a328f9762bdfa941d108f287b867d631f637
15 changes: 12 additions & 3 deletions sdk/keyvault/azure-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Azure Key Vault Certificates client library for Python
Azure Key Vault is a cloud service that provides a secure management of certificates, which are built on top of keys and secrets and adds an automated renewal feature. The certificate client library allows you securely store and manage the life-cycle of your certificate, be notified about certificate life-cycle events, and supports automatic renewal with selected issuers. This library offers operations to create, retrieve, update, delete, purge, backup, restore, and list the certificates and its versions, and offers CRUD operations for the certificate issuers, contacts, and management policies of the certificates..
Azure Key Vault helps solve the following problems:
- Cryptographic key management (this library) - create, store, and control
access to the keys used to encrypt your data
- Secrets management
([`azure-keyvault-secrets`](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/keyvault/azure-keyvault-secrets)) -
securely store and control access to tokens, passwords, certificates, API keys,
and other secrets
- Certificate management
([`azure-keyvault-certificates`](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/keyvault/azure-keyvault-certificates)) -
create, manage, and deploy public and private SSL/TLS certificates

[Source code][certificates_client_src] | [Package (PyPI)][pypi_package_certificates] | [API reference documentation][reference_docs] | [Product documentation][keyvault_docs] | [Samples][certificates_samples]
## Getting started
Expand Down Expand Up @@ -149,10 +158,10 @@ Key Vault clients raise exceptions defined in azure-core. For more detailed info

For example, if you try to retrieve a certificate after it is deleted a `404` error is returned, indicating resource not found. In the following snippet, the error is handled gracefully by catching the exception and displaying additional information about the error.
```python
from azure.core.exceptions import ResourceNotFoundError
from azure.core.exceptions import HttpResponseError
try:
certificate_client.get_certificate(name="deleted_certificate", version="deleted_certificate_version")
except ResourceNotFoundError as e:
except HttpResponseError as e:
print(e.message)

Output: "certificate not found:deleted_certificate"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import print_function
import functools

from azure.core.exceptions import ResourceNotFoundError
from devtools_testutils import ResourceGroupPreparer
from certificates_preparer import VaultClientPreparer
from certificates_test_case import KeyVaultTestCase
Expand Down Expand Up @@ -47,7 +46,7 @@ def test_example_certificate_crud_operations(self, vault_client, **kwargs):
issuer_name='Self',
subject_name='CN=*.microsoft.com',
validity_in_months=24,
san_dns_names=['onedrive.microsoft.com', 'xbox.microsoft.com']
san_dns_names=['sdk.azure-int.net']
)

cert_name = "cert-name"
Expand Down Expand Up @@ -170,7 +169,6 @@ def test_example_certificate_list_operations(self, vault_client, **kwargs):
@VaultClientPreparer()
def test_example_certificate_backup_restore(self, vault_client, **kwargs):
from azure.keyvault.certificates import CertificatePolicy, KeyProperties, SecretContentType
import time
certificate_client = vault_client.certificates

# specify the certificate policy
Expand All @@ -182,7 +180,7 @@ def test_example_certificate_backup_restore(self, vault_client, **kwargs):
issuer_name='Self',
subject_name='CN=*.microsoft.com',
validity_in_months=24,
san_dns_names=['onedrive.microsoft.com', 'xbox.microsoft.com']
san_dns_names=['sdk.azure-int.net']
)

cert_name = "cert-name"
Expand Down Expand Up @@ -216,6 +214,7 @@ def test_example_certificate_backup_restore(self, vault_client, **kwargs):
@VaultClientPreparer(enable_soft_delete=True)
def test_example_certificate_recover(self, vault_client, **kwargs):
from azure.keyvault.certificates import CertificatePolicy, KeyProperties, SecretContentType
from azure.core.exceptions import HttpResponseError
certificate_client = vault_client.certificates

# specify the certificate policy
Expand All @@ -227,7 +226,7 @@ def test_example_certificate_recover(self, vault_client, **kwargs):
issuer_name='Self',
subject_name='CN=*.microsoft.com',
validity_in_months=24,
san_dns_names=['onedrive.microsoft.com', 'xbox.microsoft.com']
san_dns_names=['sdk.azure-int.net']
)

cert_name = "cert-name"
Expand All @@ -236,7 +235,7 @@ def test_example_certificate_recover(self, vault_client, **kwargs):
certificate_client.delete_certificate(name=cert_name)
self._poll_until_no_exception(
functools.partial(certificate_client.get_deleted_certificate, cert_name),
ResourceNotFoundError
HttpResponseError
)
# [START get_deleted_certificate]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from azure.core.exceptions import ResourceNotFoundError
from devtools_testutils import ResourceGroupPreparer
from certificates_async_preparer import AsyncVaultClientPreparer
from certificates_async_test_case import AsyncKeyVaultTestCase
Expand Down Expand Up @@ -32,7 +31,6 @@ class TestExamplesKeyVault(AsyncKeyVaultTestCase):
@AsyncVaultClientPreparer(enable_soft_delete=True)
@AsyncKeyVaultTestCase.await_prepared_test
async def test_example_certificate_crud_operations(self, vault_client, **kwargs):
import asyncio
certificate_client = vault_client.certificates
# [START create_certificate]
from azure.keyvault.certificates import CertificatePolicy, KeyProperties, SecretContentType
Expand Down Expand Up @@ -217,6 +215,7 @@ async def test_example_certificate_backup_restore(self, vault_client, **kwargs):
@AsyncKeyVaultTestCase.await_prepared_test
async def test_example_certificate_recover(self, vault_client, **kwargs):
from azure.keyvault.certificates import CertificatePolicy, KeyProperties, SecretContentType
from azure.core.exceptions import HttpResponseError
certificate_client = vault_client.certificates

# specify the certificate policy
Expand All @@ -237,7 +236,7 @@ async def test_example_certificate_recover(self, vault_client, **kwargs):

await certificate_client.delete_certificate(name=cert_name)
await self._poll_until_no_exception(
certificate_client.get_deleted_certificate, cert_name, expected_exception=ResourceNotFoundError
certificate_client.get_deleted_certificate, cert_name, expected_exception=HttpResponseError
)

# [START get_deleted_certificate]
Expand Down