|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. |
7 | 7 | # -------------------------------------------------------------------------- |
8 | 8 |
|
| 9 | +from copy import deepcopy |
9 | 10 | from typing import TYPE_CHECKING |
10 | 11 |
|
11 | 12 | from azure.mgmt.core import ARMPipelineClient |
12 | 13 | from msrest import Deserializer, Serializer |
13 | 14 |
|
| 15 | +from . import models |
| 16 | +from ._configuration import MicrosoftResourceHealthConfiguration |
| 17 | +from .operations import AvailabilityStatusesOperations, ChildAvailabilityStatusesOperations, ChildResourcesOperations, Operations |
| 18 | + |
14 | 19 | if TYPE_CHECKING: |
15 | 20 | # pylint: disable=unused-import,ungrouped-imports |
16 | 21 | from typing import Any, Optional |
17 | 22 |
|
18 | 23 | from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | | - |
21 | | -from ._configuration import MicrosoftResourceHealthConfiguration |
22 | | -from .operations import AvailabilityStatusesOperations |
23 | | -from .operations import ChildAvailabilityStatusesOperations |
24 | | -from .operations import ChildResourcesOperations |
25 | | -from .operations import Operations |
26 | | -from . import models |
27 | | - |
| 24 | + from azure.core.rest import HttpRequest, HttpResponse |
28 | 25 |
|
29 | 26 | class MicrosoftResourceHealth(object): |
30 | 27 | """The Resource Health Client. |
31 | 28 |
|
32 | 29 | :ivar availability_statuses: AvailabilityStatusesOperations operations |
33 | | - :vartype availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.operations.AvailabilityStatusesOperations |
| 30 | + :vartype availability_statuses: |
| 31 | + azure.mgmt.resourcehealth.v2015_01_01.operations.AvailabilityStatusesOperations |
34 | 32 | :ivar child_availability_statuses: ChildAvailabilityStatusesOperations operations |
35 | | - :vartype child_availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.operations.ChildAvailabilityStatusesOperations |
| 33 | + :vartype child_availability_statuses: |
| 34 | + azure.mgmt.resourcehealth.v2015_01_01.operations.ChildAvailabilityStatusesOperations |
36 | 35 | :ivar child_resources: ChildResourcesOperations operations |
37 | | - :vartype child_resources: azure.mgmt.resourcehealth.v2015_01_01.operations.ChildResourcesOperations |
| 36 | + :vartype child_resources: |
| 37 | + azure.mgmt.resourcehealth.v2015_01_01.operations.ChildResourcesOperations |
38 | 38 | :ivar operations: Operations operations |
39 | 39 | :vartype operations: azure.mgmt.resourcehealth.v2015_01_01.operations.Operations |
40 | 40 | :param credential: Credential needed for the client to connect to Azure. |
41 | 41 | :type credential: ~azure.core.credentials.TokenCredential |
42 | | - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
| 42 | + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure |
| 43 | + subscription. The subscription ID forms part of the URI for every service call. |
43 | 44 | :type subscription_id: str |
44 | | - :param str base_url: Service URL |
| 45 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 46 | + :type base_url: str |
45 | 47 | """ |
46 | 48 |
|
47 | 49 | def __init__( |
48 | 50 | self, |
49 | 51 | credential, # type: "TokenCredential" |
50 | 52 | subscription_id, # type: str |
51 | | - base_url=None, # type: Optional[str] |
| 53 | + base_url="https://management.azure.com", # type: str |
52 | 54 | **kwargs # type: Any |
53 | 55 | ): |
54 | 56 | # type: (...) -> None |
55 | | - if not base_url: |
56 | | - base_url = 'https://management.azure.com' |
57 | | - self._config = MicrosoftResourceHealthConfiguration(credential, subscription_id, **kwargs) |
| 57 | + self._config = MicrosoftResourceHealthConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
58 | 58 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
59 | 59 |
|
60 | 60 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
61 | 61 | self._serialize = Serializer(client_models) |
62 | | - self._serialize.client_side_validation = False |
63 | 62 | self._deserialize = Deserializer(client_models) |
| 63 | + self._serialize.client_side_validation = False |
| 64 | + self.availability_statuses = AvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 65 | + self.child_availability_statuses = ChildAvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 66 | + self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 67 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + |
64 | 69 |
|
65 | | - self.availability_statuses = AvailabilityStatusesOperations( |
66 | | - self._client, self._config, self._serialize, self._deserialize) |
67 | | - self.child_availability_statuses = ChildAvailabilityStatusesOperations( |
68 | | - self._client, self._config, self._serialize, self._deserialize) |
69 | | - self.child_resources = ChildResourcesOperations( |
70 | | - self._client, self._config, self._serialize, self._deserialize) |
71 | | - self.operations = Operations( |
72 | | - self._client, self._config, self._serialize, self._deserialize) |
73 | | - |
74 | | - def _send_request(self, http_request, **kwargs): |
75 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 70 | + def _send_request( |
| 71 | + self, |
| 72 | + request, # type: HttpRequest |
| 73 | + **kwargs # type: Any |
| 74 | + ): |
| 75 | + # type: (...) -> HttpResponse |
76 | 76 | """Runs the network request through the client's chained policies. |
77 | 77 |
|
78 | | - :param http_request: The network request you want to make. Required. |
79 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
80 | | - :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. |
81 | 89 | :return: The response of your network call. Does not do error handling on your response. |
82 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 90 | + :rtype: ~azure.core.rest.HttpResponse |
83 | 91 | """ |
84 | | - path_format_arguments = { |
85 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
86 | | - } |
87 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
88 | | - stream = kwargs.pop("stream", True) |
89 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
90 | | - 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) |
91 | 96 |
|
92 | 97 | def close(self): |
93 | 98 | # type: () -> None |
|
0 commit comments