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