|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. |
7 | 7 | # -------------------------------------------------------------------------- |
8 | 8 |
|
9 | | -from typing import TYPE_CHECKING |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, Optional, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient |
12 | 14 | from msrest import Deserializer, Serializer |
13 | 15 |
|
| 16 | +from . import models |
| 17 | +from ._configuration import AppConfigurationManagementClientConfiguration |
| 18 | +from .operations import ConfigurationStoresOperations, KeyValuesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations |
| 19 | + |
14 | 20 | if TYPE_CHECKING: |
15 | 21 | # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | 22 | from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | | - |
21 | | -from ._configuration import AppConfigurationManagementClientConfiguration |
22 | | -from .operations import ConfigurationStoresOperations |
23 | | -from .operations import Operations |
24 | | -from .operations import PrivateEndpointConnectionsOperations |
25 | | -from .operations import PrivateLinkResourcesOperations |
26 | | -from .operations import KeyValuesOperations |
27 | | -from . import models |
28 | | - |
29 | 23 |
|
30 | | -class AppConfigurationManagementClient(object): |
| 24 | +class AppConfigurationManagementClient: |
31 | 25 | """AppConfigurationManagementClient. |
32 | 26 |
|
33 | 27 | :ivar configuration_stores: ConfigurationStoresOperations operations |
34 | | - :vartype configuration_stores: app_configuration_management_client.operations.ConfigurationStoresOperations |
| 28 | + :vartype configuration_stores: |
| 29 | + app_configuration_management_client.operations.ConfigurationStoresOperations |
35 | 30 | :ivar operations: Operations operations |
36 | 31 | :vartype operations: app_configuration_management_client.operations.Operations |
37 | 32 | :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations |
38 | | - :vartype private_endpoint_connections: app_configuration_management_client.operations.PrivateEndpointConnectionsOperations |
| 33 | + :vartype private_endpoint_connections: |
| 34 | + app_configuration_management_client.operations.PrivateEndpointConnectionsOperations |
39 | 35 | :ivar private_link_resources: PrivateLinkResourcesOperations operations |
40 | | - :vartype private_link_resources: app_configuration_management_client.operations.PrivateLinkResourcesOperations |
| 36 | + :vartype private_link_resources: |
| 37 | + app_configuration_management_client.operations.PrivateLinkResourcesOperations |
41 | 38 | :ivar key_values: KeyValuesOperations operations |
42 | 39 | :vartype key_values: app_configuration_management_client.operations.KeyValuesOperations |
43 | 40 | :param credential: Credential needed for the client to connect to Azure. |
44 | 41 | :type credential: ~azure.core.credentials.TokenCredential |
45 | 42 | :param subscription_id: The Microsoft Azure subscription ID. |
46 | 43 | :type subscription_id: str |
47 | | - :param str base_url: Service URL |
48 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 44 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 45 | + :type base_url: str |
| 46 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 47 | + Retry-After header is present. |
49 | 48 | """ |
50 | 49 |
|
51 | 50 | def __init__( |
52 | 51 | self, |
53 | | - credential, # type: "TokenCredential" |
54 | | - subscription_id, # type: str |
55 | | - base_url=None, # type: Optional[str] |
56 | | - **kwargs # type: Any |
57 | | - ): |
58 | | - # type: (...) -> None |
59 | | - if not base_url: |
60 | | - base_url = 'https://management.azure.com' |
61 | | - self._config = AppConfigurationManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 52 | + credential: "TokenCredential", |
| 53 | + subscription_id: str, |
| 54 | + base_url: str = "https://management.azure.com", |
| 55 | + **kwargs: Any |
| 56 | + ) -> None: |
| 57 | + self._config = AppConfigurationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
62 | 58 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
63 | 59 |
|
64 | 60 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
65 | 61 | self._serialize = Serializer(client_models) |
66 | | - self._serialize.client_side_validation = False |
67 | 62 | self._deserialize = Deserializer(client_models) |
| 63 | + self._serialize.client_side_validation = False |
| 64 | + self.configuration_stores = ConfigurationStoresOperations(self._client, self._config, self._serialize, self._deserialize) |
| 65 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 66 | + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 67 | + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.key_values = KeyValuesOperations(self._client, self._config, self._serialize, self._deserialize) |
68 | 69 |
|
69 | | - self.configuration_stores = ConfigurationStoresOperations( |
70 | | - self._client, self._config, self._serialize, self._deserialize) |
71 | | - self.operations = Operations( |
72 | | - self._client, self._config, self._serialize, self._deserialize) |
73 | | - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( |
74 | | - self._client, self._config, self._serialize, self._deserialize) |
75 | | - self.private_link_resources = PrivateLinkResourcesOperations( |
76 | | - self._client, self._config, self._serialize, self._deserialize) |
77 | | - self.key_values = KeyValuesOperations( |
78 | | - self._client, self._config, self._serialize, self._deserialize) |
79 | | - |
80 | | - def _send_request(self, http_request, **kwargs): |
81 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 70 | + |
| 71 | + def _send_request( |
| 72 | + self, |
| 73 | + request, # type: HttpRequest |
| 74 | + **kwargs: Any |
| 75 | + ) -> HttpResponse: |
82 | 76 | """Runs the network request through the client's chained policies. |
83 | 77 |
|
84 | | - :param http_request: The network request you want to make. Required. |
85 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
86 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 78 | + >>> from azure.core.rest import HttpRequest |
| 79 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 80 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 81 | + >>> response = client._send_request(request) |
| 82 | + <HttpResponse: 200 OK> |
| 83 | +
|
| 84 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 85 | +
|
| 86 | + :param request: The network request you want to make. Required. |
| 87 | + :type request: ~azure.core.rest.HttpRequest |
| 88 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
87 | 89 | :return: The response of your network call. Does not do error handling on your response. |
88 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 90 | + :rtype: ~azure.core.rest.HttpResponse |
89 | 91 | """ |
90 | | - path_format_arguments = { |
91 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
92 | | - } |
93 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
94 | | - stream = kwargs.pop("stream", True) |
95 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
96 | | - return pipeline_response.http_response |
| 92 | + |
| 93 | + request_copy = deepcopy(request) |
| 94 | + request_copy.url = self._client.format_url(request_copy.url) |
| 95 | + return self._client.send_request(request_copy, **kwargs) |
97 | 96 |
|
98 | 97 | def close(self): |
99 | 98 | # type: () -> None |
|
0 commit comments