|
12 | 12 | from msrest.service_client import SDKClient
|
13 | 13 | from msrest import Serializer, Deserializer
|
14 | 14 | from msrestazure import AzureConfiguration
|
| 15 | + |
| 16 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 17 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
15 | 18 | from .version import VERSION
|
16 |
| -from .operations.vaults_operations import VaultsOperations |
17 |
| -from .operations.operations import Operations |
18 |
| -from . import models |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class KeyVaultManagementClientConfiguration(AzureConfiguration):
|
@@ -52,39 +52,93 @@ def __init__(
|
52 | 52 | self.subscription_id = subscription_id
|
53 | 53 |
|
54 | 54 |
|
55 |
| -class KeyVaultManagementClient(SDKClient): |
| 55 | +class KeyVaultManagementClient(MultiApiClientMixin, SDKClient): |
56 | 56 | """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault.
|
57 | 57 |
|
58 | 58 | :ivar config: Configuration for client.
|
59 | 59 | :vartype config: KeyVaultManagementClientConfiguration
|
60 | 60 |
|
61 |
| - :ivar vaults: Vaults operations |
62 |
| - :vartype vaults: azure.mgmt.keyvault.operations.VaultsOperations |
63 |
| - :ivar operations: Operations operations |
64 |
| - :vartype operations: azure.mgmt.keyvault.operations.Operations |
65 |
| -
|
66 | 61 | :param credentials: Credentials needed for the client to connect to Azure.
|
67 | 62 | :type credentials: :mod:`A msrestazure Credentials
|
68 | 63 | object<msrestazure.azure_active_directory>`
|
69 | 64 | :param subscription_id: Subscription credentials which uniquely identify
|
70 | 65 | Microsoft Azure subscription. The subscription ID forms part of the URI
|
71 | 66 | for every service call.
|
72 | 67 | :type subscription_id: str
|
| 68 | + :param str api_version: API version to use if no profile is provided, or if |
| 69 | + missing in profile. |
73 | 70 | :param str base_url: Service URL
|
| 71 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 72 | + :type profile: azure.profiles.KnownProfiles |
74 | 73 | """
|
75 | 74 |
|
76 |
| - def __init__( |
77 |
| - self, credentials, subscription_id, base_url=None): |
| 75 | + DEFAULT_API_VERSION = '2018-02-14' |
| 76 | + _PROFILE_TAG = "azure.mgmt.keyvault.KeyVaultManagementClient" |
| 77 | + LATEST_PROFILE = ProfileDefinition({ |
| 78 | + _PROFILE_TAG: { |
| 79 | + None: DEFAULT_API_VERSION |
| 80 | + }}, |
| 81 | + _PROFILE_TAG + " latest" |
| 82 | + ) |
78 | 83 |
|
| 84 | + def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default): |
79 | 85 | self.config = KeyVaultManagementClientConfiguration(credentials, subscription_id, base_url)
|
80 |
| - super(KeyVaultManagementClient, self).__init__(self.config.credentials, self.config) |
81 |
| - |
82 |
| - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
83 |
| - self.api_version = '2018-02-14' |
84 |
| - self._serialize = Serializer(client_models) |
85 |
| - self._deserialize = Deserializer(client_models) |
86 |
| - |
87 |
| - self.vaults = VaultsOperations( |
88 |
| - self._client, self.config, self._serialize, self._deserialize) |
89 |
| - self.operations = Operations( |
90 |
| - self._client, self.config, self._serialize, self._deserialize) |
| 86 | + super(KeyVaultManagementClient, self).__init__( |
| 87 | + credentials, |
| 88 | + self.config, |
| 89 | + api_version=api_version, |
| 90 | + profile=profile |
| 91 | + ) |
| 92 | + |
| 93 | +############ Generated from here ############ |
| 94 | + |
| 95 | + @classmethod |
| 96 | + def _models_dict(cls, api_version): |
| 97 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 98 | + |
| 99 | + @classmethod |
| 100 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 101 | + """Module depends on the API version: |
| 102 | +
|
| 103 | + * 2016-10-01: :mod:`v2016_10_01.models<azure.mgmt.keyvault.v2016_10_01.models>` |
| 104 | + * 2018-02-14: :mod:`v2018_02_14.models<azure.mgmt.keyvault.v2018_02_14.models>` |
| 105 | + """ |
| 106 | + if api_version == '2016-10-01': |
| 107 | + from .v2016_10_01 import models |
| 108 | + return models |
| 109 | + elif api_version == '2018-02-14': |
| 110 | + from .v2018_02_14 import models |
| 111 | + return models |
| 112 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 113 | + |
| 114 | + @property |
| 115 | + def operations(self): |
| 116 | + """Instance depends on the API version: |
| 117 | +
|
| 118 | + * 2016-10-01: :class:`Operations<azure.mgmt.keyvault.v2016_10_01.operations.Operations>` |
| 119 | + * 2018-02-14: :class:`Operations<azure.mgmt.keyvault.v2018_02_14.operations.Operations>` |
| 120 | + """ |
| 121 | + api_version = self._get_api_version('operations') |
| 122 | + if api_version == '2016-10-01': |
| 123 | + from .v2016_10_01.operations import Operations as OperationClass |
| 124 | + elif api_version == '2018-02-14': |
| 125 | + from .v2018_02_14.operations import Operations as OperationClass |
| 126 | + else: |
| 127 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 128 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 129 | + |
| 130 | + @property |
| 131 | + def vaults(self): |
| 132 | + """Instance depends on the API version: |
| 133 | +
|
| 134 | + * 2016-10-01: :class:`VaultsOperations<azure.mgmt.keyvault.v2016_10_01.operations.VaultsOperations>` |
| 135 | + * 2018-02-14: :class:`VaultsOperations<azure.mgmt.keyvault.v2018_02_14.operations.VaultsOperations>` |
| 136 | + """ |
| 137 | + api_version = self._get_api_version('vaults') |
| 138 | + if api_version == '2016-10-01': |
| 139 | + from .v2016_10_01.operations import VaultsOperations as OperationClass |
| 140 | + elif api_version == '2018-02-14': |
| 141 | + from .v2018_02_14.operations import VaultsOperations as OperationClass |
| 142 | + else: |
| 143 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 144 | + return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
0 commit comments