7
7
# --------------------------------------------------------------------------
8
8
9
9
from copy import deepcopy
10
- from typing import Any , TYPE_CHECKING
10
+ from typing import Any , Optional , TYPE_CHECKING , cast
11
+ from typing_extensions import Self
11
12
12
13
from azure .core .pipeline import policies
13
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
14
16
from azure .mgmt .core import ARMPipelineClient
15
17
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
16
19
17
20
from . import models as _models
18
21
from ._configuration import MaintenanceManagementClientConfiguration
19
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
20
23
from .operations import (
21
24
ApplyUpdateForResourceGroupOperations ,
22
25
ApplyUpdatesOperations ,
33
36
)
34
37
35
38
if TYPE_CHECKING :
36
- # pylint: disable=unused-import,ungrouped-imports
37
39
from azure .core .credentials import TokenCredential
38
40
39
41
40
- class MaintenanceManagementClient : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
42
+ class MaintenanceManagementClient : # pylint: disable=too-many-instance-attributes
41
43
"""Azure Maintenance Management Client.
42
44
43
- :ivar scheduled_event: ScheduledEventOperations operations
44
- :vartype scheduled_event: azure.mgmt.maintenance.operations.ScheduledEventOperations
45
- :ivar public_maintenance_configurations: PublicMaintenanceConfigurationsOperations operations
46
- :vartype public_maintenance_configurations:
47
- azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations
45
+ :ivar operations: Operations operations
46
+ :vartype operations: azure.mgmt.maintenance.operations.Operations
48
47
:ivar apply_updates: ApplyUpdatesOperations operations
49
48
:vartype apply_updates: azure.mgmt.maintenance.operations.ApplyUpdatesOperations
50
- :ivar configuration_assignments: ConfigurationAssignmentsOperations operations
51
- :vartype configuration_assignments:
52
- azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations
53
- :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations
54
- :vartype maintenance_configurations:
55
- azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations
56
- :ivar maintenance_configurations_for_resource_group:
57
- MaintenanceConfigurationsForResourceGroupOperations operations
58
- :vartype maintenance_configurations_for_resource_group:
59
- azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations
60
- :ivar apply_update_for_resource_group: ApplyUpdateForResourceGroupOperations operations
61
- :vartype apply_update_for_resource_group:
62
- azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations
63
49
:ivar configuration_assignments_within_subscription:
64
50
ConfigurationAssignmentsWithinSubscriptionOperations operations
65
51
:vartype configuration_assignments_within_subscription:
@@ -68,35 +54,53 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version
68
54
ConfigurationAssignmentsForSubscriptionsOperations operations
69
55
:vartype configuration_assignments_for_subscriptions:
70
56
azure.mgmt.maintenance.operations.ConfigurationAssignmentsForSubscriptionsOperations
57
+ :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations
58
+ :vartype maintenance_configurations:
59
+ azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations
60
+ :ivar public_maintenance_configurations: PublicMaintenanceConfigurationsOperations operations
61
+ :vartype public_maintenance_configurations:
62
+ azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations
63
+ :ivar configuration_assignments: ConfigurationAssignmentsOperations operations
64
+ :vartype configuration_assignments:
65
+ azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations
66
+ :ivar apply_update_for_resource_group: ApplyUpdateForResourceGroupOperations operations
67
+ :vartype apply_update_for_resource_group:
68
+ azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations
71
69
:ivar configuration_assignments_for_resource_group:
72
70
ConfigurationAssignmentsForResourceGroupOperations operations
73
71
:vartype configuration_assignments_for_resource_group:
74
72
azure.mgmt.maintenance.operations.ConfigurationAssignmentsForResourceGroupOperations
75
- :ivar operations: Operations operations
76
- :vartype operations: azure.mgmt.maintenance.operations.Operations
73
+ :ivar maintenance_configurations_for_resource_group:
74
+ MaintenanceConfigurationsForResourceGroupOperations operations
75
+ :vartype maintenance_configurations_for_resource_group:
76
+ azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations
77
77
:ivar updates: UpdatesOperations operations
78
78
:vartype updates: azure.mgmt.maintenance.operations.UpdatesOperations
79
+ :ivar scheduled_event: ScheduledEventOperations operations
80
+ :vartype scheduled_event: azure.mgmt.maintenance.operations.ScheduledEventOperations
79
81
:param credential: Credential needed for the client to connect to Azure. Required.
80
82
:type credential: ~azure.core.credentials.TokenCredential
81
83
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
82
84
:type subscription_id: str
83
- :param base_url: Service URL. Default value is "https://management.azure.com" .
85
+ :param base_url: Service URL. Default value is None .
84
86
:type base_url: str
85
87
:keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding
86
88
this default value may result in unsupported behavior.
87
89
:paramtype api_version: str
88
90
"""
89
91
90
92
def __init__ (
91
- self ,
92
- credential : "TokenCredential" ,
93
- subscription_id : str ,
94
- base_url : str = "https://management.azure.com" ,
95
- ** kwargs : Any
93
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
96
94
) -> None :
95
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
96
+ _endpoints = get_arm_endpoints (_cloud )
97
+ if not base_url :
98
+ base_url = _endpoints ["resource_manager" ]
99
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
97
100
self ._config = MaintenanceManagementClientConfiguration (
98
- credential = credential , subscription_id = subscription_id , ** kwargs
101
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
99
102
)
103
+
100
104
_policies = kwargs .pop ("policies" , None )
101
105
if _policies is None :
102
106
_policies = [
@@ -115,40 +119,40 @@ def __init__(
115
119
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
116
120
self ._config .http_logging_policy ,
117
121
]
118
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
122
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
119
123
120
124
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
121
125
self ._serialize = Serializer (client_models )
122
126
self ._deserialize = Deserializer (client_models )
123
127
self ._serialize .client_side_validation = False
124
- self .scheduled_event = ScheduledEventOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
125
- self .public_maintenance_configurations = PublicMaintenanceConfigurationsOperations (
128
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
129
+ self .apply_updates = ApplyUpdatesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
130
+ self .configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations (
126
131
self ._client , self ._config , self ._serialize , self ._deserialize
127
132
)
128
- self .apply_updates = ApplyUpdatesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
129
- self .configuration_assignments = ConfigurationAssignmentsOperations (
133
+ self .configuration_assignments_for_subscriptions = ConfigurationAssignmentsForSubscriptionsOperations (
130
134
self ._client , self ._config , self ._serialize , self ._deserialize
131
135
)
132
136
self .maintenance_configurations = MaintenanceConfigurationsOperations (
133
137
self ._client , self ._config , self ._serialize , self ._deserialize
134
138
)
135
- self .maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations (
139
+ self .public_maintenance_configurations = PublicMaintenanceConfigurationsOperations (
136
140
self ._client , self ._config , self ._serialize , self ._deserialize
137
141
)
138
- self .apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations (
142
+ self .configuration_assignments = ConfigurationAssignmentsOperations (
139
143
self ._client , self ._config , self ._serialize , self ._deserialize
140
144
)
141
- self .configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations (
145
+ self .apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations (
142
146
self ._client , self ._config , self ._serialize , self ._deserialize
143
147
)
144
- self .configuration_assignments_for_subscriptions = ConfigurationAssignmentsForSubscriptionsOperations (
148
+ self .configuration_assignments_for_resource_group = ConfigurationAssignmentsForResourceGroupOperations (
145
149
self ._client , self ._config , self ._serialize , self ._deserialize
146
150
)
147
- self .configuration_assignments_for_resource_group = ConfigurationAssignmentsForResourceGroupOperations (
151
+ self .maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations (
148
152
self ._client , self ._config , self ._serialize , self ._deserialize
149
153
)
150
- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
151
154
self .updates = UpdatesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
155
+ self .scheduled_event = ScheduledEventOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
152
156
153
157
def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
154
158
"""Runs the network request through the client's chained policies.
@@ -175,7 +179,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
175
179
def close (self ) -> None :
176
180
self ._client .close ()
177
181
178
- def __enter__ (self ) -> "MaintenanceManagementClient" :
182
+ def __enter__ (self ) -> Self :
179
183
self ._client .__enter__ ()
180
184
return self
181
185
0 commit comments