|
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 |
|
21 | | -from ._configuration import MaintenanceManagementClientConfiguration |
22 | | -from .operations import PublicMaintenanceConfigurationsOperations |
23 | | -from .operations import ApplyUpdatesOperations |
24 | | -from .operations import ConfigurationAssignmentsOperations |
25 | | -from .operations import MaintenanceConfigurationsOperations |
26 | | -from .operations import MaintenanceConfigurationsForResourceGroupOperations |
27 | | -from .operations import ApplyUpdateForResourceGroupOperations |
28 | | -from .operations import ConfigurationAssignmentsWithinSubscriptionOperations |
29 | | -from .operations import Operations |
30 | | -from .operations import UpdatesOperations |
31 | 17 | from . import models |
| 18 | +from ._configuration import MaintenanceManagementClientConfiguration |
| 19 | +from .operations import ApplyUpdateForResourceGroupOperations, ApplyUpdatesOperations, ConfigurationAssignmentsOperations, ConfigurationAssignmentsWithinSubscriptionOperations, MaintenanceConfigurationsForResourceGroupOperations, MaintenanceConfigurationsOperations, Operations, PublicMaintenanceConfigurationsOperations, UpdatesOperations |
32 | 20 |
|
| 21 | +if TYPE_CHECKING: |
| 22 | + # pylint: disable=unused-import,ungrouped-imports |
| 23 | + from azure.core.credentials import TokenCredential |
33 | 24 |
|
34 | | -class MaintenanceManagementClient(object): |
| 25 | +class MaintenanceManagementClient: # pylint: disable=too-many-instance-attributes |
35 | 26 | """Azure Maintenance Management Client. |
36 | 27 |
|
37 | 28 | :ivar public_maintenance_configurations: PublicMaintenanceConfigurationsOperations operations |
38 | | - :vartype public_maintenance_configurations: azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations |
| 29 | + :vartype public_maintenance_configurations: |
| 30 | + azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations |
39 | 31 | :ivar apply_updates: ApplyUpdatesOperations operations |
40 | 32 | :vartype apply_updates: azure.mgmt.maintenance.operations.ApplyUpdatesOperations |
41 | 33 | :ivar configuration_assignments: ConfigurationAssignmentsOperations operations |
42 | | - :vartype configuration_assignments: azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations |
| 34 | + :vartype configuration_assignments: |
| 35 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations |
43 | 36 | :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations |
44 | | - :vartype maintenance_configurations: azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations |
45 | | - :ivar maintenance_configurations_for_resource_group: MaintenanceConfigurationsForResourceGroupOperations operations |
46 | | - :vartype maintenance_configurations_for_resource_group: azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations |
| 37 | + :vartype maintenance_configurations: |
| 38 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations |
| 39 | + :ivar maintenance_configurations_for_resource_group: |
| 40 | + MaintenanceConfigurationsForResourceGroupOperations operations |
| 41 | + :vartype maintenance_configurations_for_resource_group: |
| 42 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations |
47 | 43 | :ivar apply_update_for_resource_group: ApplyUpdateForResourceGroupOperations operations |
48 | | - :vartype apply_update_for_resource_group: azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations |
49 | | - :ivar configuration_assignments_within_subscription: ConfigurationAssignmentsWithinSubscriptionOperations operations |
50 | | - :vartype configuration_assignments_within_subscription: azure.mgmt.maintenance.operations.ConfigurationAssignmentsWithinSubscriptionOperations |
| 44 | + :vartype apply_update_for_resource_group: |
| 45 | + azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations |
| 46 | + :ivar configuration_assignments_within_subscription: |
| 47 | + ConfigurationAssignmentsWithinSubscriptionOperations operations |
| 48 | + :vartype configuration_assignments_within_subscription: |
| 49 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsWithinSubscriptionOperations |
51 | 50 | :ivar operations: Operations operations |
52 | 51 | :vartype operations: azure.mgmt.maintenance.operations.Operations |
53 | 52 | :ivar updates: UpdatesOperations operations |
54 | 53 | :vartype updates: azure.mgmt.maintenance.operations.UpdatesOperations |
55 | 54 | :param credential: Credential needed for the client to connect to Azure. |
56 | 55 | :type credential: ~azure.core.credentials.TokenCredential |
57 | | - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
| 56 | + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure |
| 57 | + subscription. The subscription ID forms part of the URI for every service call. |
58 | 58 | :type subscription_id: str |
59 | | - :param str base_url: Service URL |
| 59 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 60 | + :type base_url: str |
| 61 | + :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding |
| 62 | + this default value may result in unsupported behavior. |
| 63 | + :paramtype api_version: str |
60 | 64 | """ |
61 | 65 |
|
62 | 66 | def __init__( |
63 | 67 | self, |
64 | | - credential, # type: "TokenCredential" |
65 | | - subscription_id, # type: str |
66 | | - base_url=None, # type: Optional[str] |
67 | | - **kwargs # type: Any |
68 | | - ): |
69 | | - # type: (...) -> None |
70 | | - if not base_url: |
71 | | - base_url = 'https://management.azure.com' |
72 | | - self._config = MaintenanceManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 68 | + credential: "TokenCredential", |
| 69 | + subscription_id: str, |
| 70 | + base_url: str = "https://management.azure.com", |
| 71 | + **kwargs: Any |
| 72 | + ) -> None: |
| 73 | + self._config = MaintenanceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
73 | 74 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
74 | 75 |
|
75 | 76 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
76 | 77 | self._serialize = Serializer(client_models) |
77 | | - self._serialize.client_side_validation = False |
78 | 78 | self._deserialize = Deserializer(client_models) |
79 | | - |
| 79 | + self._serialize.client_side_validation = False |
80 | 80 | self.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations( |
81 | | - self._client, self._config, self._serialize, self._deserialize) |
| 81 | + self._client, self._config, self._serialize, self._deserialize |
| 82 | + ) |
82 | 83 | self.apply_updates = ApplyUpdatesOperations( |
83 | | - self._client, self._config, self._serialize, self._deserialize) |
| 84 | + self._client, self._config, self._serialize, self._deserialize |
| 85 | + ) |
84 | 86 | self.configuration_assignments = ConfigurationAssignmentsOperations( |
85 | | - self._client, self._config, self._serialize, self._deserialize) |
| 87 | + self._client, self._config, self._serialize, self._deserialize |
| 88 | + ) |
86 | 89 | self.maintenance_configurations = MaintenanceConfigurationsOperations( |
87 | | - self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self._client, self._config, self._serialize, self._deserialize |
| 91 | + ) |
88 | 92 | self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations( |
89 | | - self._client, self._config, self._serialize, self._deserialize) |
| 93 | + self._client, self._config, self._serialize, self._deserialize |
| 94 | + ) |
90 | 95 | self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations( |
91 | | - self._client, self._config, self._serialize, self._deserialize) |
| 96 | + self._client, self._config, self._serialize, self._deserialize |
| 97 | + ) |
92 | 98 | self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( |
93 | | - self._client, self._config, self._serialize, self._deserialize) |
| 99 | + self._client, self._config, self._serialize, self._deserialize |
| 100 | + ) |
94 | 101 | self.operations = Operations( |
95 | | - self._client, self._config, self._serialize, self._deserialize) |
| 102 | + self._client, self._config, self._serialize, self._deserialize |
| 103 | + ) |
96 | 104 | self.updates = UpdatesOperations( |
97 | | - self._client, self._config, self._serialize, self._deserialize) |
| 105 | + self._client, self._config, self._serialize, self._deserialize |
| 106 | + ) |
| 107 | + |
98 | 108 |
|
99 | | - def _send_request(self, http_request, **kwargs): |
100 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 109 | + def _send_request( |
| 110 | + self, |
| 111 | + request: HttpRequest, |
| 112 | + **kwargs: Any |
| 113 | + ) -> HttpResponse: |
101 | 114 | """Runs the network request through the client's chained policies. |
102 | 115 |
|
103 | | - :param http_request: The network request you want to make. Required. |
104 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
105 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 116 | + >>> from azure.core.rest import HttpRequest |
| 117 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 118 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 119 | + >>> response = client._send_request(request) |
| 120 | + <HttpResponse: 200 OK> |
| 121 | +
|
| 122 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 123 | +
|
| 124 | + :param request: The network request you want to make. Required. |
| 125 | + :type request: ~azure.core.rest.HttpRequest |
| 126 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
106 | 127 | :return: The response of your network call. Does not do error handling on your response. |
107 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 128 | + :rtype: ~azure.core.rest.HttpResponse |
108 | 129 | """ |
109 | | - path_format_arguments = { |
110 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
111 | | - } |
112 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
113 | | - stream = kwargs.pop("stream", True) |
114 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
115 | | - return pipeline_response.http_response |
| 130 | + |
| 131 | + request_copy = deepcopy(request) |
| 132 | + request_copy.url = self._client.format_url(request_copy.url) |
| 133 | + return self._client.send_request(request_copy, **kwargs) |
116 | 134 |
|
117 | 135 | def close(self): |
118 | 136 | # type: () -> None |
|
0 commit comments