|
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 |
10 | 11 |
|
11 | 12 | from azure.core import PipelineClient
|
12 |
| -from msrest import Deserializer, Serializer |
13 |
| - |
14 |
| -if TYPE_CHECKING: |
15 |
| - # pylint: disable=unused-import,ungrouped-imports |
16 |
| - from typing import Any, Optional |
17 |
| - |
18 |
| - from azure.core.credentials import TokenCredential |
19 |
| - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
| 13 | +from azure.core.rest import HttpRequest, HttpResponse |
20 | 14 |
|
| 15 | +from . import models |
21 | 16 | from ._configuration import AzureAppConfigurationConfiguration
|
| 17 | +from ._serialization import Deserializer, Serializer |
22 | 18 | from .operations import AzureAppConfigurationOperationsMixin
|
23 |
| -from . import models |
24 | 19 |
|
25 | 20 |
|
26 |
| -class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): |
| 21 | +class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): # pylint: disable=client-accepts-api-version-keyword |
27 | 22 | """AzureAppConfiguration.
|
28 | 23 |
|
29 |
| - :param credential: Credential needed for the client to connect to Azure. |
30 |
| - :type credential: ~azure.core.credentials.TokenCredential |
31 |
| - :param endpoint: The endpoint of the App Configuration instance to send requests to. |
| 24 | + :param endpoint: The endpoint of the App Configuration instance to send requests to. Required. |
32 | 25 | :type endpoint: str
|
33 |
| - :param sync_token: Used to guarantee real-time consistency between requests. |
| 26 | + :param sync_token: Used to guarantee real-time consistency between requests. Default value is |
| 27 | + None. |
34 | 28 | :type sync_token: str
|
| 29 | + :keyword api_version: Api Version. Default value is "1.0". Note that overriding this default |
| 30 | + value may result in unsupported behavior. |
| 31 | + :paramtype api_version: str |
35 | 32 | """
|
36 | 33 |
|
37 |
| - def __init__( |
38 |
| - self, |
39 |
| - credential, # type: "TokenCredential" |
40 |
| - endpoint, # type: str |
41 |
| - sync_token=None, # type: Optional[str] |
42 |
| - **kwargs # type: Any |
43 |
| - ): |
44 |
| - # type: (...) -> None |
45 |
| - base_url = '{endpoint}' |
46 |
| - self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs) |
47 |
| - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 34 | + def __init__( # pylint: disable=missing-client-constructor-parameter-credential |
| 35 | + self, endpoint: str, sync_token: Optional[str] = None, **kwargs: Any |
| 36 | + ) -> None: |
| 37 | + _endpoint = "{endpoint}" |
| 38 | + self._config = AzureAppConfigurationConfiguration(endpoint=endpoint, sync_token=sync_token, **kwargs) |
| 39 | + self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) |
48 | 40 |
|
49 | 41 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
|
50 | 42 | self._serialize = Serializer(client_models)
|
51 |
| - self._serialize.client_side_validation = False |
52 | 43 | self._deserialize = Deserializer(client_models)
|
| 44 | + self._serialize.client_side_validation = False |
53 | 45 |
|
54 |
| - |
55 |
| - def _send_request(self, http_request, **kwargs): |
56 |
| - # type: (HttpRequest, Any) -> HttpResponse |
| 46 | + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
57 | 47 | """Runs the network request through the client's chained policies.
|
58 | 48 |
|
59 |
| - :param http_request: The network request you want to make. Required. |
60 |
| - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
61 |
| - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 49 | + >>> from azure.core.rest import HttpRequest |
| 50 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 51 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 52 | + >>> response = client._send_request(request) |
| 53 | + <HttpResponse: 200 OK> |
| 54 | +
|
| 55 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 56 | +
|
| 57 | + :param request: The network request you want to make. Required. |
| 58 | + :type request: ~azure.core.rest.HttpRequest |
| 59 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
62 | 60 | :return: The response of your network call. Does not do error handling on your response.
|
63 |
| - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 61 | + :rtype: ~azure.core.rest.HttpResponse |
64 | 62 | """
|
| 63 | + |
| 64 | + request_copy = deepcopy(request) |
65 | 65 | path_format_arguments = {
|
66 |
| - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), |
| 66 | + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), |
67 | 67 | }
|
68 |
| - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
69 |
| - stream = kwargs.pop("stream", True) |
70 |
| - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
71 |
| - return pipeline_response.http_response |
| 68 | + |
| 69 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 70 | + return self._client.send_request(request_copy, **kwargs) |
72 | 71 |
|
73 | 72 | def close(self):
|
74 | 73 | # type: () -> None
|
|
0 commit comments