|
1 | 1 | # coding=utf-8
|
2 | 2 | # --------------------------------------------------------------------------
|
3 | 3 | # Copyright (c) Microsoft Corporation. All rights reserved.
|
4 |
| -# Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for |
| 5 | +# license information. |
| 6 | +# |
5 | 7 | # Code generated by Microsoft (R) AutoRest Code Generator.
|
6 |
| -# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
7 | 10 | # --------------------------------------------------------------------------
|
8 | 11 |
|
9 |
| -from copy import deepcopy |
10 |
| -from typing import Any, TYPE_CHECKING |
| 12 | +from typing import Any, Optional, TYPE_CHECKING |
11 | 13 |
|
12 |
| -from msrest import Deserializer, Serializer |
13 |
| - |
14 |
| -from azure.core.rest import HttpRequest, HttpResponse |
15 | 14 | from azure.mgmt.core import ARMPipelineClient
|
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
16 | 17 |
|
17 |
| -from . import models |
18 | 18 | from ._configuration import AppConfigurationManagementClientConfiguration
|
19 |
| -from .operations import ConfigurationStoresOperations, KeyValuesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations |
| 19 | +from ._serialization import Deserializer, Serializer |
20 | 20 |
|
21 | 21 | if TYPE_CHECKING:
|
22 | 22 | # pylint: disable=unused-import,ungrouped-imports
|
23 | 23 | from azure.core.credentials import TokenCredential
|
24 | 24 |
|
25 |
| -class AppConfigurationManagementClient: |
| 25 | +class _SDKClient(object): |
| 26 | + def __init__(self, *args, **kwargs): |
| 27 | + """This is a fake class to support current implemetation of MultiApiClientMixin." |
| 28 | + Will be removed in final version of multiapi azure-core based client |
| 29 | + """ |
| 30 | + pass |
| 31 | + |
| 32 | +class AppConfigurationManagementClient(MultiApiClientMixin, _SDKClient): |
26 | 33 | """AppConfigurationManagementClient.
|
27 | 34 |
|
28 |
| - :ivar configuration_stores: ConfigurationStoresOperations operations |
29 |
| - :vartype configuration_stores: |
30 |
| - azure.mgmt.appconfiguration.operations.ConfigurationStoresOperations |
31 |
| - :ivar operations: Operations operations |
32 |
| - :vartype operations: azure.mgmt.appconfiguration.operations.Operations |
33 |
| - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations |
34 |
| - :vartype private_endpoint_connections: |
35 |
| - azure.mgmt.appconfiguration.operations.PrivateEndpointConnectionsOperations |
36 |
| - :ivar private_link_resources: PrivateLinkResourcesOperations operations |
37 |
| - :vartype private_link_resources: |
38 |
| - azure.mgmt.appconfiguration.operations.PrivateLinkResourcesOperations |
39 |
| - :ivar key_values: KeyValuesOperations operations |
40 |
| - :vartype key_values: azure.mgmt.appconfiguration.operations.KeyValuesOperations |
41 |
| - :param credential: Credential needed for the client to connect to Azure. |
| 35 | + This ready contains multiple API versions, to help you deal with all of the Azure clouds |
| 36 | + (Azure Stack, Azure Government, Azure China, etc.). |
| 37 | + By default, it uses the latest API version available on public Azure. |
| 38 | + For production, you should stick to a particular api-version and/or profile. |
| 39 | + The profile sets a mapping between an operation group and its API version. |
| 40 | + The api-version parameter sets the default API version if the operation |
| 41 | + group is not described in the profile. |
| 42 | +
|
| 43 | + :param credential: Credential needed for the client to connect to Azure. Required. |
42 | 44 | :type credential: ~azure.core.credentials.TokenCredential
|
43 |
| - :param subscription_id: The Microsoft Azure subscription ID. |
| 45 | + :param subscription_id: The Microsoft Azure subscription ID. Required. |
44 | 46 | :type subscription_id: str
|
45 |
| - :param base_url: Service URL. Default value is "https://management.azure.com". |
| 47 | + :param api_version: API version to use if no profile is provided, or if missing in profile. |
| 48 | + :type api_version: str |
| 49 | + :param base_url: Service URL |
46 | 50 | :type base_url: str
|
47 |
| - :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this |
48 |
| - default value may result in unsupported behavior. |
49 |
| - :paramtype api_version: str |
50 |
| - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
51 |
| - Retry-After header is present. |
| 51 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 52 | + :type profile: azure.profiles.KnownProfiles |
| 53 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
52 | 54 | """
|
53 | 55 |
|
| 56 | + DEFAULT_API_VERSION = '2022-05-01' |
| 57 | + _PROFILE_TAG = "azure.mgmt.appconfiguration.AppConfigurationManagementClient" |
| 58 | + LATEST_PROFILE = ProfileDefinition({ |
| 59 | + _PROFILE_TAG: { |
| 60 | + None: DEFAULT_API_VERSION, |
| 61 | + 'replicas': '2022-03-01-preview', |
| 62 | + }}, |
| 63 | + _PROFILE_TAG + " latest" |
| 64 | + ) |
| 65 | + |
54 | 66 | def __init__(
|
55 | 67 | self,
|
56 | 68 | credential: "TokenCredential",
|
57 | 69 | subscription_id: str,
|
| 70 | + api_version=None, # type: Optional[str] |
58 | 71 | base_url: str = "https://management.azure.com",
|
59 |
| - **kwargs: Any |
60 |
| - ) -> None: |
61 |
| - self._config = AppConfigurationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
| 72 | + profile=KnownProfiles.default, # type: KnownProfiles |
| 73 | + **kwargs # type: Any |
| 74 | + ): |
| 75 | + self._config = AppConfigurationManagementClientConfiguration(credential, subscription_id, **kwargs) |
62 | 76 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
|
| 77 | + super(AppConfigurationManagementClient, self).__init__( |
| 78 | + api_version=api_version, |
| 79 | + profile=profile |
| 80 | + ) |
63 | 81 |
|
64 |
| - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
65 |
| - self._serialize = Serializer(client_models) |
66 |
| - self._deserialize = Deserializer(client_models) |
67 |
| - self._serialize.client_side_validation = False |
68 |
| - self.configuration_stores = ConfigurationStoresOperations(self._client, self._config, self._serialize, self._deserialize) |
69 |
| - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
70 |
| - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
71 |
| - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) |
72 |
| - self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 82 | + @classmethod |
| 83 | + def _models_dict(cls, api_version): |
| 84 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
73 | 85 |
|
| 86 | + @classmethod |
| 87 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 88 | + """Module depends on the API version: |
74 | 89 |
|
75 |
| - def _send_request( |
76 |
| - self, |
77 |
| - request: HttpRequest, |
78 |
| - **kwargs: Any |
79 |
| - ) -> HttpResponse: |
80 |
| - """Runs the network request through the client's chained policies. |
81 |
| -
|
82 |
| - >>> from azure.core.rest import HttpRequest |
83 |
| - >>> request = HttpRequest("GET", "https://www.example.org/") |
84 |
| - <HttpRequest [GET], url: 'https://www.example.org/'> |
85 |
| - >>> response = client._send_request(request) |
86 |
| - <HttpResponse: 200 OK> |
87 |
| -
|
88 |
| - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
89 |
| -
|
90 |
| - :param request: The network request you want to make. Required. |
91 |
| - :type request: ~azure.core.rest.HttpRequest |
92 |
| - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
93 |
| - :return: The response of your network call. Does not do error handling on your response. |
94 |
| - :rtype: ~azure.core.rest.HttpResponse |
| 90 | + * 2022-03-01-preview: :mod:`v2022_03_01_preview.models<azure.mgmt.appconfiguration.v2022_03_01_preview.models>` |
| 91 | + * 2022-05-01: :mod:`v2022_05_01.models<azure.mgmt.appconfiguration.v2022_05_01.models>` |
95 | 92 | """
|
96 |
| - |
97 |
| - request_copy = deepcopy(request) |
98 |
| - request_copy.url = self._client.format_url(request_copy.url) |
99 |
| - return self._client.send_request(request_copy, **kwargs) |
| 93 | + if api_version == '2022-03-01-preview': |
| 94 | + from .v2022_03_01_preview import models |
| 95 | + return models |
| 96 | + elif api_version == '2022-05-01': |
| 97 | + from .v2022_05_01 import models |
| 98 | + return models |
| 99 | + raise ValueError("API version {} is not available".format(api_version)) |
| 100 | + |
| 101 | + @property |
| 102 | + def configuration_stores(self): |
| 103 | + """Instance depends on the API version: |
| 104 | +
|
| 105 | + * 2022-03-01-preview: :class:`ConfigurationStoresOperations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.ConfigurationStoresOperations>` |
| 106 | + * 2022-05-01: :class:`ConfigurationStoresOperations<azure.mgmt.appconfiguration.v2022_05_01.operations.ConfigurationStoresOperations>` |
| 107 | + """ |
| 108 | + api_version = self._get_api_version('configuration_stores') |
| 109 | + if api_version == '2022-03-01-preview': |
| 110 | + from .v2022_03_01_preview.operations import ConfigurationStoresOperations as OperationClass |
| 111 | + elif api_version == '2022-05-01': |
| 112 | + from .v2022_05_01.operations import ConfigurationStoresOperations as OperationClass |
| 113 | + else: |
| 114 | + raise ValueError("API version {} does not have operation group 'configuration_stores'".format(api_version)) |
| 115 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 116 | + |
| 117 | + @property |
| 118 | + def key_values(self): |
| 119 | + """Instance depends on the API version: |
| 120 | +
|
| 121 | + * 2022-03-01-preview: :class:`KeyValuesOperations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.KeyValuesOperations>` |
| 122 | + * 2022-05-01: :class:`KeyValuesOperations<azure.mgmt.appconfiguration.v2022_05_01.operations.KeyValuesOperations>` |
| 123 | + """ |
| 124 | + api_version = self._get_api_version('key_values') |
| 125 | + if api_version == '2022-03-01-preview': |
| 126 | + from .v2022_03_01_preview.operations import KeyValuesOperations as OperationClass |
| 127 | + elif api_version == '2022-05-01': |
| 128 | + from .v2022_05_01.operations import KeyValuesOperations as OperationClass |
| 129 | + else: |
| 130 | + raise ValueError("API version {} does not have operation group 'key_values'".format(api_version)) |
| 131 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 132 | + |
| 133 | + @property |
| 134 | + def operations(self): |
| 135 | + """Instance depends on the API version: |
| 136 | +
|
| 137 | + * 2022-03-01-preview: :class:`Operations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.Operations>` |
| 138 | + * 2022-05-01: :class:`Operations<azure.mgmt.appconfiguration.v2022_05_01.operations.Operations>` |
| 139 | + """ |
| 140 | + api_version = self._get_api_version('operations') |
| 141 | + if api_version == '2022-03-01-preview': |
| 142 | + from .v2022_03_01_preview.operations import Operations as OperationClass |
| 143 | + elif api_version == '2022-05-01': |
| 144 | + from .v2022_05_01.operations import Operations as OperationClass |
| 145 | + else: |
| 146 | + raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) |
| 147 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 148 | + |
| 149 | + @property |
| 150 | + def private_endpoint_connections(self): |
| 151 | + """Instance depends on the API version: |
| 152 | +
|
| 153 | + * 2022-03-01-preview: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.PrivateEndpointConnectionsOperations>` |
| 154 | + * 2022-05-01: :class:`PrivateEndpointConnectionsOperations<azure.mgmt.appconfiguration.v2022_05_01.operations.PrivateEndpointConnectionsOperations>` |
| 155 | + """ |
| 156 | + api_version = self._get_api_version('private_endpoint_connections') |
| 157 | + if api_version == '2022-03-01-preview': |
| 158 | + from .v2022_03_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass |
| 159 | + elif api_version == '2022-05-01': |
| 160 | + from .v2022_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass |
| 161 | + else: |
| 162 | + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) |
| 163 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 164 | + |
| 165 | + @property |
| 166 | + def private_link_resources(self): |
| 167 | + """Instance depends on the API version: |
| 168 | +
|
| 169 | + * 2022-03-01-preview: :class:`PrivateLinkResourcesOperations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.PrivateLinkResourcesOperations>` |
| 170 | + * 2022-05-01: :class:`PrivateLinkResourcesOperations<azure.mgmt.appconfiguration.v2022_05_01.operations.PrivateLinkResourcesOperations>` |
| 171 | + """ |
| 172 | + api_version = self._get_api_version('private_link_resources') |
| 173 | + if api_version == '2022-03-01-preview': |
| 174 | + from .v2022_03_01_preview.operations import PrivateLinkResourcesOperations as OperationClass |
| 175 | + elif api_version == '2022-05-01': |
| 176 | + from .v2022_05_01.operations import PrivateLinkResourcesOperations as OperationClass |
| 177 | + else: |
| 178 | + raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) |
| 179 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 180 | + |
| 181 | + @property |
| 182 | + def replicas(self): |
| 183 | + """Instance depends on the API version: |
| 184 | +
|
| 185 | + * 2022-03-01-preview: :class:`ReplicasOperations<azure.mgmt.appconfiguration.v2022_03_01_preview.operations.ReplicasOperations>` |
| 186 | + """ |
| 187 | + api_version = self._get_api_version('replicas') |
| 188 | + if api_version == '2022-03-01-preview': |
| 189 | + from .v2022_03_01_preview.operations import ReplicasOperations as OperationClass |
| 190 | + else: |
| 191 | + raise ValueError("API version {} does not have operation group 'replicas'".format(api_version)) |
| 192 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
100 | 193 |
|
101 | 194 | def close(self):
|
102 |
| - # type: () -> None |
103 | 195 | self._client.close()
|
104 |
| - |
105 | 196 | def __enter__(self):
|
106 |
| - # type: () -> AppConfigurationManagementClient |
107 | 197 | self._client.__enter__()
|
108 | 198 | return self
|
109 |
| - |
110 | 199 | def __exit__(self, *exc_details):
|
111 |
| - # type: (Any) -> None |
112 | 200 | self._client.__exit__(*exc_details)
|
0 commit comments