|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for |
| 5 | +# license information. |
| 6 | +# |
| 7 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
| 10 | +# -------------------------------------------------------------------------- |
| 11 | + |
| 12 | +from azure.core import PipelineClient |
| 13 | +from msrest import Serializer, Deserializer |
| 14 | + |
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
| 17 | +from ._configuration import KeyVaultClientConfiguration |
| 18 | +from ._operations_mixin import KeyVaultClientOperationsMixin |
| 19 | +class _SDKClient(object): |
| 20 | + def __init__(self, *args, **kwargs): |
| 21 | + """This is a fake class to support current implemetation of MultiApiClientMixin." |
| 22 | + Will be removed in final version of multiapi azure-core based client |
| 23 | + """ |
| 24 | + pass |
| 25 | + |
| 26 | +class KeyVaultClient(KeyVaultClientOperationsMixin, MultiApiClientMixin, _SDKClient): |
| 27 | + """The key vault client performs cryptographic key operations and vault operations against the Key Vault service. |
| 28 | +
|
| 29 | + This ready contains multiple API versions, to help you deal with all of the Azure clouds |
| 30 | + (Azure Stack, Azure Government, Azure China, etc.). |
| 31 | + By default, it uses the latest API version available on public Azure. |
| 32 | + For production, you should stick to a particular api-version and/or profile. |
| 33 | + The profile sets a mapping between an operation group and its API version. |
| 34 | + The api-version parameter sets the default API version if the operation |
| 35 | + group is not described in the profile. |
| 36 | + :param str api_version: API version to use if no profile is provided, or if |
| 37 | + missing in profile. |
| 38 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 39 | + :type profile: azure.profiles.KnownProfiles |
| 40 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 41 | + """ |
| 42 | + |
| 43 | + DEFAULT_API_VERSION = '7.1' |
| 44 | + _PROFILE_TAG = "azure.keyvault.KeyVaultClient" |
| 45 | + LATEST_PROFILE = ProfileDefinition({ |
| 46 | + _PROFILE_TAG: { |
| 47 | + None: DEFAULT_API_VERSION, |
| 48 | + 'backup_certificate': '7.0', |
| 49 | + 'backup_secret': '7.0', |
| 50 | + 'backup_storage_account': '7.0', |
| 51 | + 'create_certificate': '7.0', |
| 52 | + 'delete_certificate': '7.0', |
| 53 | + 'delete_certificate_contacts': '7.0', |
| 54 | + 'delete_certificate_issuer': '7.0', |
| 55 | + 'delete_certificate_operation': '7.0', |
| 56 | + 'delete_sas_definition': '7.0', |
| 57 | + 'delete_secret': '7.0', |
| 58 | + 'delete_storage_account': '7.0', |
| 59 | + 'get_certificate': '7.0', |
| 60 | + 'get_certificate_contacts': '7.0', |
| 61 | + 'get_certificate_issuer': '7.0', |
| 62 | + 'get_certificate_issuers': '7.0', |
| 63 | + 'get_certificate_operation': '7.0', |
| 64 | + 'get_certificate_policy': '7.0', |
| 65 | + 'get_certificate_versions': '7.0', |
| 66 | + 'get_certificates': '7.0', |
| 67 | + 'get_deleted_certificate': '7.0', |
| 68 | + 'get_deleted_certificates': '7.0', |
| 69 | + 'get_deleted_sas_definition': '7.0', |
| 70 | + 'get_deleted_sas_definitions': '7.0', |
| 71 | + 'get_deleted_secret': '7.0', |
| 72 | + 'get_deleted_secrets': '7.0', |
| 73 | + 'get_deleted_storage_account': '7.0', |
| 74 | + 'get_deleted_storage_accounts': '7.0', |
| 75 | + 'get_sas_definition': '7.0', |
| 76 | + 'get_sas_definitions': '7.0', |
| 77 | + 'get_secret': '7.0', |
| 78 | + 'get_secret_versions': '7.0', |
| 79 | + 'get_secrets': '7.0', |
| 80 | + 'get_storage_account': '7.0', |
| 81 | + 'get_storage_accounts': '7.0', |
| 82 | + 'import_certificate': '7.0', |
| 83 | + 'merge_certificate': '7.0', |
| 84 | + 'purge_deleted_certificate': '7.0', |
| 85 | + 'purge_deleted_secret': '7.0', |
| 86 | + 'purge_deleted_storage_account': '7.0', |
| 87 | + 'recover_deleted_certificate': '7.0', |
| 88 | + 'recover_deleted_sas_definition': '7.0', |
| 89 | + 'recover_deleted_secret': '7.0', |
| 90 | + 'recover_deleted_storage_account': '7.0', |
| 91 | + 'regenerate_storage_account_key': '7.0', |
| 92 | + 'restore_certificate': '7.0', |
| 93 | + 'restore_secret': '7.0', |
| 94 | + 'restore_storage_account': '7.0', |
| 95 | + 'set_certificate_contacts': '7.0', |
| 96 | + 'set_certificate_issuer': '7.0', |
| 97 | + 'set_sas_definition': '7.0', |
| 98 | + 'set_secret': '7.0', |
| 99 | + 'set_storage_account': '7.0', |
| 100 | + 'update_certificate': '7.0', |
| 101 | + 'update_certificate_issuer': '7.0', |
| 102 | + 'update_certificate_operation': '7.0', |
| 103 | + 'update_certificate_policy': '7.0', |
| 104 | + 'update_sas_definition': '7.0', |
| 105 | + 'update_secret': '7.0', |
| 106 | + 'update_storage_account': '7.0', |
| 107 | + }}, |
| 108 | + _PROFILE_TAG + " latest" |
| 109 | + ) |
| 110 | + |
| 111 | + def __init__( |
| 112 | + self, |
| 113 | + api_version=None, |
| 114 | + profile=KnownProfiles.default, |
| 115 | + **kwargs # type: Any |
| 116 | + ): |
| 117 | + if api_version == '2016-10-01' or api_version == '7.0' or api_version == '7.1': |
| 118 | + base_url = '{vaultBaseUrl}' |
| 119 | + else: |
| 120 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 121 | + self._config = KeyVaultClientConfiguration(**kwargs) |
| 122 | + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 123 | + super(KeyVaultClient, self).__init__( |
| 124 | + api_version=api_version, |
| 125 | + profile=profile |
| 126 | + ) |
| 127 | + |
| 128 | + @classmethod |
| 129 | + def _models_dict(cls, api_version): |
| 130 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 131 | + |
| 132 | + @classmethod |
| 133 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 134 | + """Module depends on the API version: |
| 135 | +
|
| 136 | + * 2016-10-01: :mod:`v2016_10_01.models<azure.keyvault.v2016_10_01.models>` |
| 137 | + * 7.0: :mod:`v7_0.models<azure.keyvault.v7_0.models>` |
| 138 | + * 7.1: :mod:`v7_1.models<azure.keyvault.v7_1.models>` |
| 139 | + """ |
| 140 | + if api_version == '2016-10-01': |
| 141 | + from .v2016_10_01 import models |
| 142 | + return models |
| 143 | + elif api_version == '7.0': |
| 144 | + from .v7_0 import models |
| 145 | + return models |
| 146 | + elif api_version == '7.1': |
| 147 | + from .v7_1 import models |
| 148 | + return models |
| 149 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 150 | + |
| 151 | + def close(self): |
| 152 | + self._client.close() |
| 153 | + def __enter__(self): |
| 154 | + self._client.__enter__() |
| 155 | + return self |
| 156 | + def __exit__(self, *exc_details): |
| 157 | + self._client.__exit__(*exc_details) |
0 commit comments