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

[key vault] Regenerate keys #12101

Merged
merged 53 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
93ea6e7
move generated code out of shared folder
iscai-msft Jun 12, 2020
e73478a
generate with autorest v3 (except v7.2-preview)
iscai-msft Jun 12, 2020
bd75efe
fix wiring with new generated code
iscai-msft Jun 17, 2020
6585bef
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jun 17, 2020
23200f5
only call and import AioHttpTransport if user did not supply a transport
iscai-msft Jun 18, 2020
93da956
correct user agent
iscai-msft Jun 18, 2020
74088ed
fix duplicate platform info in user agent
iscai-msft Jun 18, 2020
b224136
fix pylint
iscai-msft Jun 18, 2020
40a8430
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jun 22, 2020
c4589a0
switch references of user agent to sdk moniker in wrapped code
iscai-msft Jun 22, 2020
bf3ee1c
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jun 23, 2020
a5d7e00
Revert "Merge branch 'master' of https://github.com/Azure/azure-sdk-f…
iscai-msft Jun 23, 2020
3ac2aea
generate with unflattened code
iscai-msft Jun 24, 2020
c3a2d16
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jun 24, 2020
6308a6a
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jun 30, 2020
f5c3231
regenerate to get exposed http_logging_policy
iscai-msft Jun 30, 2020
de9431b
add allowed header names to http logging policy
iscai-msft Jun 30, 2020
8bf6550
add tests for http logging policy
iscai-msft Jun 30, 2020
d7ec446
update dependency on azure core
iscai-msft Jun 30, 2020
576ba50
remove 7.2-preview from generation
iscai-msft Jul 1, 2020
00dfbc9
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jul 20, 2020
a848b77
checkout erroneous changes to customvision
iscai-msft Jul 20, 2020
c00855b
move generated code out of shared folder
iscai-msft Jun 12, 2020
a6e88db
generate with autorest v3 (except v7.2-preview)
iscai-msft Jun 12, 2020
40a2356
fix wiring with new generated code
iscai-msft Jun 17, 2020
7211aad
only call and import AioHttpTransport if user did not supply a transport
iscai-msft Jun 18, 2020
bb1f553
correct user agent
iscai-msft Jun 18, 2020
af2108b
fix duplicate platform info in user agent
iscai-msft Jun 18, 2020
4ce0926
fix pylint
iscai-msft Jun 18, 2020
3bc569f
switch references of user agent to sdk moniker in wrapped code
iscai-msft Jun 22, 2020
7479cf7
Revert "Merge branch 'master' of https://github.com/Azure/azure-sdk-f…
iscai-msft Jun 23, 2020
70d0019
generate with unflattened code
iscai-msft Jun 24, 2020
d13f077
regenerate to get exposed http_logging_policy
iscai-msft Jun 30, 2020
0fb7376
add allowed header names to http logging policy
iscai-msft Jun 30, 2020
a295cb8
add tests for http logging policy
iscai-msft Jun 30, 2020
7585f56
update dependency on azure core
iscai-msft Jun 30, 2020
eb86479
remove 7.2-preview from generation
iscai-msft Jul 1, 2020
6bf4cc7
checkout erroneous changes to customvision
iscai-msft Jul 20, 2020
d0e2e56
Merge branch 'regenerate_keys' of https://github.com/iscai-msft/azure…
iscai-msft Jul 20, 2020
7a9386d
revert erroneous changes to master
iscai-msft Jul 20, 2020
f1c3c72
fix more erroneous changes
iscai-msft Jul 20, 2020
3478f0a
update changelog
iscai-msft Jul 20, 2020
5fd90da
fix changelog
iscai-msft Jul 20, 2020
e1f08b2
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jul 24, 2020
44af22f
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jul 27, 2020
d1a8d77
regenerate
iscai-msft Jul 29, 2020
ce6604b
update api versions
iscai-msft Jul 29, 2020
e7eec68
re-record
iscai-msft Jul 29, 2020
6520b29
test you can pass custom hook policy to client
iscai-msft Jul 29, 2020
2485750
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Jul 29, 2020
f125090
import JsonWebKey from generated v7.1
iscai-msft Jul 29, 2020
4a6f5de
add check for whether user passed in their own pipeline before import…
iscai-msft Jul 29, 2020
f69a065
add RequestIdPolicy to changelog
iscai-msft Jul 30, 2020
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
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-keys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Updated minimum `azure-core` version to 1.4.0
- `CryptographyClient` will no longer perform encrypt or wrap operations when
its key has expired or is not yet valid.
- Users can pass in CustomHookPolicy through the kwarg `custom_hook_policy` when initializing the client
- RequestIdPolicy is now always set for all requests. This policy sets the id of the request in the header.

## 4.2.0b1 (2020-03-10)
- Support for Key Vault API version 7.1-preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# -------------------------------------
from ._enums import KeyCurveName, KeyOperation, KeyType
from ._shared.multi_api import ApiVersion
from ._shared.client_base import ApiVersion
from ._models import DeletedKey, JsonWebKey, KeyProperties, KeyVaultKey
from ._client import KeyClient

Expand Down
41 changes: 32 additions & 9 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ def create_key(self, name, key_type, **kwargs):
else:
attributes = None

bundle = self._client.create_key(
vault_base_url=self.vault_url,
key_name=name,
parameters = self._models.KeyCreateParameters(
kty=key_type,
key_size=kwargs.pop("size", None),
key_attributes=attributes,
key_ops=kwargs.pop("key_operations", None),
tags=kwargs.pop("tags", None),
curve=kwargs.pop("curve", None)
)

bundle = self._client.create_key(
vault_base_url=self.vault_url,
key_name=name,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -439,12 +445,18 @@ def update_key_properties(self, name, version=None, **kwargs):
attributes = self._models.KeyAttributes(enabled=enabled, not_before=not_before, expires=expires_on)
else:
attributes = None

parameters = self._models.KeyUpdateParameters(
key_ops=kwargs.pop("key_operations", None),
key_attributes=attributes,
tags=kwargs.pop("tags", None)
)

bundle = self._client.update_key(
self.vault_url,
name,
key_version=version or "",
key_ops=kwargs.pop("key_operations", None),
key_attributes=attributes,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -500,7 +512,12 @@ def restore_key_backup(self, backup, **kwargs):
:caption: Restore a key backup
:dedent: 8
"""
bundle = self._client.restore_key(self.vault_url, backup, error_map=_error_map, **kwargs)
bundle = self._client.restore_key(
self.vault_url,
parameters=self._models.KeyRestoreParameters(key_bundle_backup=backup),
error_map=_error_map,
**kwargs
)
return KeyVaultKey._from_key_bundle(bundle)

@distributed_trace
Expand Down Expand Up @@ -530,12 +547,18 @@ def import_key(self, name, key, **kwargs):
attributes = self._models.KeyAttributes(enabled=enabled, not_before=not_before, expires=expires_on)
else:
attributes = None
bundle = self._client.import_key(
self.vault_url,
name,

parameters = self._models.KeyImportParameters(
key=key._to_generated_model(),
key_attributes=attributes,
hsm=kwargs.pop("hardware_protected", None),
tags=kwargs.pop("tags", None)
)

bundle = self._client.import_key(
self.vault_url,
name,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._key_vault_client import KeyVaultClient
__all__ = ['KeyVaultClient']

from .version import VERSION

__version__ = VERSION

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,42 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .version import VERSION
from ._version import VERSION


class KeyVaultClientConfiguration(Configuration):
"""Configuration for KeyVaultClient
"""Configuration for KeyVaultClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
"""

def __init__(self, credentials, **kwargs):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")

def __init__(
self,
**kwargs # type: Any
):
# type: (...) -> None
super(KeyVaultClientConfiguration, self).__init__(**kwargs)
self._configure(**kwargs)

self.user_agent_policy.add_user_agent('azsdk-python-azure-keyvault/{}'.format(VERSION))
self.generate_client_request_id = True

self.credentials = credentials
kwargs.setdefault('sdk_moniker', 'azure-keyvault/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(self, **kwargs):
def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from azure.core import PipelineClient
from msrest import Serializer, Deserializer

from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from ._configuration import KeyVaultClientConfiguration
from ._operations_mixin import KeyVaultClientOperationsMixin
class _SDKClient(object):
def __init__(self, *args, **kwargs):
"""This is a fake class to support current implemetation of MultiApiClientMixin."
Will be removed in final version of multiapi azure-core based client
"""
pass

class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKClient):
"""The key vault client performs cryptographic key operations and vault operations against the Key Vault service.

This ready contains multiple API versions, to help you deal with all of the Azure clouds
(Azure Stack, Azure Government, Azure China, etc.).
By default, it uses the latest API version available on public Azure.
For production, you should stick to a particular api-version and/or profile.
The profile sets a mapping between an operation group and its API version.
The api-version parameter sets the default API version if the operation
group is not described in the profile.
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

DEFAULT_API_VERSION = '7.1'
_PROFILE_TAG = "azure.keyvault.KeyVaultClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
None: DEFAULT_API_VERSION,
'backup_certificate': '7.0',
Copy link
Member

Choose a reason for hiding this comment

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

Should this be 7.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. The tagging done here is saying that backup_certificate is only available in version 7.0. The reason for this is, in 7.0 we have the keys, secrets, and certificate mixin operations all generated, but for 7.1 (thanks to @heaths work), we only generate the keys for the key client.

'backup_secret': '7.0',
'backup_storage_account': '7.0',
'create_certificate': '7.0',
'delete_certificate': '7.0',
'delete_certificate_contacts': '7.0',
'delete_certificate_issuer': '7.0',
'delete_certificate_operation': '7.0',
'delete_sas_definition': '7.0',
'delete_secret': '7.0',
'delete_storage_account': '7.0',
'get_certificate': '7.0',
'get_certificate_contacts': '7.0',
'get_certificate_issuer': '7.0',
'get_certificate_issuers': '7.0',
'get_certificate_operation': '7.0',
'get_certificate_policy': '7.0',
'get_certificate_versions': '7.0',
'get_certificates': '7.0',
'get_deleted_certificate': '7.0',
'get_deleted_certificates': '7.0',
'get_deleted_sas_definition': '7.0',
'get_deleted_sas_definitions': '7.0',
'get_deleted_secret': '7.0',
'get_deleted_secrets': '7.0',
'get_deleted_storage_account': '7.0',
'get_deleted_storage_accounts': '7.0',
'get_sas_definition': '7.0',
'get_sas_definitions': '7.0',
'get_secret': '7.0',
'get_secret_versions': '7.0',
'get_secrets': '7.0',
'get_storage_account': '7.0',
'get_storage_accounts': '7.0',
'import_certificate': '7.0',
'merge_certificate': '7.0',
'purge_deleted_certificate': '7.0',
'purge_deleted_secret': '7.0',
'purge_deleted_storage_account': '7.0',
'recover_deleted_certificate': '7.0',
'recover_deleted_sas_definition': '7.0',
'recover_deleted_secret': '7.0',
'recover_deleted_storage_account': '7.0',
'regenerate_storage_account_key': '7.0',
'restore_certificate': '7.0',
'restore_secret': '7.0',
'restore_storage_account': '7.0',
'set_certificate_contacts': '7.0',
'set_certificate_issuer': '7.0',
'set_sas_definition': '7.0',
'set_secret': '7.0',
'set_storage_account': '7.0',
'update_certificate': '7.0',
'update_certificate_issuer': '7.0',
'update_certificate_operation': '7.0',
'update_certificate_policy': '7.0',
'update_sas_definition': '7.0',
'update_secret': '7.0',
'update_storage_account': '7.0',
}},
_PROFILE_TAG + " latest"
)

def __init__(
self,
api_version=None,
profile=KnownProfiles.default,
**kwargs # type: Any
):
if api_version == '2016-10-01' or api_version == '7.0' or api_version == '7.1':
base_url = '{vaultBaseUrl}'
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
self._config = KeyVaultClientConfiguration(**kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
super(KeyVaultClient, self).__init__(
api_version=api_version,
profile=profile
)

@classmethod
def _models_dict(cls, api_version):
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}

@classmethod
def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:

* 2016-10-01: :mod:`v2016_10_01.models<azure.keyvault.v2016_10_01.models>`
* 7.0: :mod:`v7_0.models<azure.keyvault.v7_0.models>`
* 7.1: :mod:`v7_1.models<azure.keyvault.v7_1.models>`
"""
if api_version == '2016-10-01':
from .v2016_10_01 import models
return models
elif api_version == '7.0':
from .v7_0 import models
return models
elif api_version == '7.1':
from .v7_1 import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))

def close(self):
self._client.close()
def __enter__(self):
self._client.__enter__()
return self
def __exit__(self, *exc_details):
self._client.__exit__(*exc_details)
Loading