|
| 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.mgmt.core import AsyncARMPipelineClient |
| 13 | +from msrest import Serializer, Deserializer |
| 14 | + |
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
| 17 | +from ._configuration_async import KeyVaultManagementClientConfiguration |
| 18 | + |
| 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 KeyVaultManagementClient(MultiApiClientMixin, _SDKClient): |
| 27 | + """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. |
| 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 | +
|
| 37 | + :param credential: Credential needed for the client to connect to Azure. |
| 38 | + :type credential: ~azure.core.credentials_async.AsyncTokenCredential |
| 39 | + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
| 40 | + :type subscription_id: str |
| 41 | + :param str api_version: API version to use if no profile is provided, or if |
| 42 | + missing in profile. |
| 43 | + :param str base_url: Service URL |
| 44 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 45 | + :type profile: azure.profiles.KnownProfiles |
| 46 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 47 | + """ |
| 48 | + |
| 49 | + DEFAULT_API_VERSION = '2019-09-01' |
| 50 | + _PROFILE_TAG = "azure.mgmt.keyvault.KeyVaultManagementClient" |
| 51 | + LATEST_PROFILE = ProfileDefinition({ |
| 52 | + _PROFILE_TAG: { |
| 53 | + None: DEFAULT_API_VERSION, |
| 54 | + }}, |
| 55 | + _PROFILE_TAG + " latest" |
| 56 | + ) |
| 57 | + |
| 58 | + def __init__( |
| 59 | + self, |
| 60 | + credential, # type: "AsyncTokenCredential" |
| 61 | + subscription_id, # type: str |
| 62 | + api_version=None, |
| 63 | + base_url=None, |
| 64 | + profile=KnownProfiles.default, |
| 65 | + **kwargs # type: Any |
| 66 | + ) -> None: |
| 67 | + if not base_url: |
| 68 | + base_url = 'https://management.azure.com' |
| 69 | + self._config = KeyVaultManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 70 | + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 71 | + super(KeyVaultManagementClient, self).__init__( |
| 72 | + credential, |
| 73 | + self._config, |
| 74 | + api_version=api_version, |
| 75 | + profile=profile |
| 76 | + ) |
| 77 | + |
| 78 | + @classmethod |
| 79 | + def _models_dict(cls, api_version): |
| 80 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 81 | + |
| 82 | + @classmethod |
| 83 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 84 | + """Module depends on the API version: |
| 85 | +
|
| 86 | + * 2016-10-01: :mod:`v2016_10_01.models<azure.mgmt.keyvault.v2016_10_01.models>` |
| 87 | + * 2018-02-14: :mod:`v2018_02_14.models<azure.mgmt.keyvault.v2018_02_14.models>` |
| 88 | + * 2019-09-01: :mod:`v2019_09_01.models<azure.mgmt.keyvault.v2019_09_01.models>` |
| 89 | + """ |
| 90 | + if api_version == '2016-10-01': |
| 91 | + from ..v2016_10_01 import models |
| 92 | + return models |
| 93 | + elif api_version == '2018-02-14': |
| 94 | + from ..v2018_02_14 import models |
| 95 | + return models |
| 96 | + elif api_version == '2019-09-01': |
| 97 | + from ..v2019_09_01 import models |
| 98 | + return models |
| 99 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 100 | + |
| 101 | + @property |
| 102 | + def operations(self): |
| 103 | + """Instance depends on the API version: |
| 104 | +
|
| 105 | + * 2016-10-01: :class:`Operations<azure.mgmt.keyvault.v2016_10_01.aio.operations_async.Operations>` |
| 106 | + * 2018-02-14: :class:`Operations<azure.mgmt.keyvault.v2018_02_14.aio.operations_async.Operations>` |
| 107 | + * 2019-09-01: :class:`Operations<azure.mgmt.keyvault.v2019_09_01.aio.operations_async.Operations>` |
| 108 | + """ |
| 109 | + api_version = self._get_api_version('operations') |
| 110 | + if api_version == '2016-10-01': |
| 111 | + from ..v2016_10_01.aio.operations_async import Operations as OperationClass |
| 112 | + elif api_version == '2018-02-14': |
| 113 | + from ..v2018_02_14.aio.operations_async import Operations as OperationClass |
| 114 | + elif api_version == '2019-09-01': |
| 115 | + from ..v2019_09_01.aio.operations_async import Operations as OperationClass |
| 116 | + else: |
| 117 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 118 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 119 | + |
| 120 | + @property |
| 121 | + def private_endpoint_connections(self): |
| 122 | + """Instance depends on the API version: |
| 123 | +
|
| 124 | + * 2018-02-14: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.keyvault.v2018_02_14.aio.operations_async.PrivateEndpointConnectionsOperations>` |
| 125 | + * 2019-09-01: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.keyvault.v2019_09_01.aio.operations_async.PrivateEndpointConnectionsOperations>` |
| 126 | + """ |
| 127 | + api_version = self._get_api_version('private_endpoint_connections') |
| 128 | + if api_version == '2018-02-14': |
| 129 | + from ..v2018_02_14.aio.operations_async import PrivateEndpointConnectionsOperations as OperationClass |
| 130 | + elif api_version == '2019-09-01': |
| 131 | + from ..v2019_09_01.aio.operations_async import PrivateEndpointConnectionsOperations as OperationClass |
| 132 | + else: |
| 133 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 134 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 135 | + |
| 136 | + @property |
| 137 | + def private_link_resources(self): |
| 138 | + """Instance depends on the API version: |
| 139 | +
|
| 140 | + * 2018-02-14: :class:`PrivateLinkResourcesOperations<azure.mgmt.keyvault.v2018_02_14.aio.operations_async.PrivateLinkResourcesOperations>` |
| 141 | + * 2019-09-01: :class:`PrivateLinkResourcesOperations<azure.mgmt.keyvault.v2019_09_01.aio.operations_async.PrivateLinkResourcesOperations>` |
| 142 | + """ |
| 143 | + api_version = self._get_api_version('private_link_resources') |
| 144 | + if api_version == '2018-02-14': |
| 145 | + from ..v2018_02_14.aio.operations_async import PrivateLinkResourcesOperations as OperationClass |
| 146 | + elif api_version == '2019-09-01': |
| 147 | + from ..v2019_09_01.aio.operations_async import PrivateLinkResourcesOperations as OperationClass |
| 148 | + else: |
| 149 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 150 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 151 | + |
| 152 | + @property |
| 153 | + def vaults(self): |
| 154 | + """Instance depends on the API version: |
| 155 | +
|
| 156 | + * 2016-10-01: :class:`VaultsOperations<azure.mgmt.keyvault.v2016_10_01.aio.operations_async.VaultsOperations>` |
| 157 | + * 2018-02-14: :class:`VaultsOperations<azure.mgmt.keyvault.v2018_02_14.aio.operations_async.VaultsOperations>` |
| 158 | + * 2019-09-01: :class:`VaultsOperations<azure.mgmt.keyvault.v2019_09_01.aio.operations_async.VaultsOperations>` |
| 159 | + """ |
| 160 | + api_version = self._get_api_version('vaults') |
| 161 | + if api_version == '2016-10-01': |
| 162 | + from ..v2016_10_01.aio.operations_async import VaultsOperations as OperationClass |
| 163 | + elif api_version == '2018-02-14': |
| 164 | + from ..v2018_02_14.aio.operations_async import VaultsOperations as OperationClass |
| 165 | + elif api_version == '2019-09-01': |
| 166 | + from ..v2019_09_01.aio.operations_async import VaultsOperations as OperationClass |
| 167 | + else: |
| 168 | + raise NotImplementedError("APIVersion {} is not available".format(api_version)) |
| 169 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 170 | + |
| 171 | + async def close(self): |
| 172 | + await self._client.close() |
| 173 | + async def __aenter__(self): |
| 174 | + await self._client.__aenter__() |
| 175 | + return self |
| 176 | + async def __aexit__(self, *exc_details): |
| 177 | + await self._client.__aexit__(*exc_details) |
0 commit comments