|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) Python Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, Optional, TYPE_CHECKING, cast |
| 11 | +from typing_extensions import Self |
| 12 | + |
| 13 | +from azure.core.pipeline import policies |
| 14 | +from azure.core.rest import HttpRequest, HttpResponse |
| 15 | +from azure.core.settings import settings |
| 16 | +from azure.mgmt.core import ARMPipelineClient |
| 17 | +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy |
| 18 | +from azure.mgmt.core.tools import get_arm_endpoints |
| 19 | + |
| 20 | +from ._configuration import MaintenanceClientConfiguration |
| 21 | +from ._utils.serialization import Deserializer, Serializer |
| 22 | +from .operations import ( |
| 23 | + ApplyUpdateForResourceGroupOperationGroupOperations, |
| 24 | + ApplyUpdateOperationGroupOperations, |
| 25 | + ApplyUpdateOperationGroupOpsOperations, |
| 26 | + ApplyUpdateOpsOperations, |
| 27 | + ApplyUpdatesOperationGroupOperations, |
| 28 | + ApplyUpdatesOperations, |
| 29 | + ConfigurationAssignmentForResourceGroupOperationGroupOperations, |
| 30 | + ConfigurationAssignmentOperationGroupOperations, |
| 31 | + ConfigurationAssignmentOperationGroupOpsOperations, |
| 32 | + ConfigurationAssignmentOpsOperations, |
| 33 | + ConfigurationAssignmentsForResourceGroupOperations, |
| 34 | + ConfigurationAssignmentsForResourceGroupOpsOperations, |
| 35 | + ConfigurationAssignmentsForSubscriptionOpsOperations, |
| 36 | + ConfigurationAssignmentsForSubscriptionsOperations, |
| 37 | + ConfigurationAssignmentsOperations, |
| 38 | + MaintenanceConfigurationOperationGroupOperations, |
| 39 | + MaintenanceConfigurationOperationGroupOpsOperations, |
| 40 | + MaintenanceConfigurationOpsOperations, |
| 41 | + MaintenanceConfigurationsOperations, |
| 42 | + Operations, |
| 43 | + ScheduledEventOperationGroupOperations, |
| 44 | + UpdatesOperationGroupOperations, |
| 45 | +) |
| 46 | + |
| 47 | +if TYPE_CHECKING: |
| 48 | + from azure.core.credentials import TokenCredential |
| 49 | + |
| 50 | + |
| 51 | +class MaintenanceClient: # pylint: disable=too-many-instance-attributes |
| 52 | + """Azure Maintenance Management Client. |
| 53 | +
|
| 54 | + :ivar operations: Operations operations |
| 55 | + :vartype operations: azure.mgmt.maintenance.operations.Operations |
| 56 | + :ivar maintenance_configuration_ops: MaintenanceConfigurationOpsOperations operations |
| 57 | + :vartype maintenance_configuration_ops: |
| 58 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationOpsOperations |
| 59 | + :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations |
| 60 | + :vartype maintenance_configurations: |
| 61 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations |
| 62 | + :ivar maintenance_configuration_operation_group_ops: |
| 63 | + MaintenanceConfigurationOperationGroupOpsOperations operations |
| 64 | + :vartype maintenance_configuration_operation_group_ops: |
| 65 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationOperationGroupOpsOperations |
| 66 | + :ivar maintenance_configuration_operation_group: |
| 67 | + MaintenanceConfigurationOperationGroupOperations operations |
| 68 | + :vartype maintenance_configuration_operation_group: |
| 69 | + azure.mgmt.maintenance.operations.MaintenanceConfigurationOperationGroupOperations |
| 70 | + :ivar apply_update_ops: ApplyUpdateOpsOperations operations |
| 71 | + :vartype apply_update_ops: azure.mgmt.maintenance.operations.ApplyUpdateOpsOperations |
| 72 | + :ivar apply_updates: ApplyUpdatesOperations operations |
| 73 | + :vartype apply_updates: azure.mgmt.maintenance.operations.ApplyUpdatesOperations |
| 74 | + :ivar apply_update_operation_group_ops: ApplyUpdateOperationGroupOpsOperations operations |
| 75 | + :vartype apply_update_operation_group_ops: |
| 76 | + azure.mgmt.maintenance.operations.ApplyUpdateOperationGroupOpsOperations |
| 77 | + :ivar apply_update_operation_group: ApplyUpdateOperationGroupOperations operations |
| 78 | + :vartype apply_update_operation_group: |
| 79 | + azure.mgmt.maintenance.operations.ApplyUpdateOperationGroupOperations |
| 80 | + :ivar configuration_assignment_ops: ConfigurationAssignmentOpsOperations operations |
| 81 | + :vartype configuration_assignment_ops: |
| 82 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentOpsOperations |
| 83 | + :ivar configuration_assignments: ConfigurationAssignmentsOperations operations |
| 84 | + :vartype configuration_assignments: |
| 85 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations |
| 86 | + :ivar configuration_assignment_operation_group_ops: |
| 87 | + ConfigurationAssignmentOperationGroupOpsOperations operations |
| 88 | + :vartype configuration_assignment_operation_group_ops: |
| 89 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentOperationGroupOpsOperations |
| 90 | + :ivar configuration_assignment_operation_group: ConfigurationAssignmentOperationGroupOperations |
| 91 | + operations |
| 92 | + :vartype configuration_assignment_operation_group: |
| 93 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentOperationGroupOperations |
| 94 | + :ivar configuration_assignments_for_subscription_ops: |
| 95 | + ConfigurationAssignmentsForSubscriptionOpsOperations operations |
| 96 | + :vartype configuration_assignments_for_subscription_ops: |
| 97 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForSubscriptionOpsOperations |
| 98 | + :ivar configuration_assignments_for_subscriptions: |
| 99 | + ConfigurationAssignmentsForSubscriptionsOperations operations |
| 100 | + :vartype configuration_assignments_for_subscriptions: |
| 101 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForSubscriptionsOperations |
| 102 | + :ivar configuration_assignments_for_resource_group_ops: |
| 103 | + ConfigurationAssignmentsForResourceGroupOpsOperations operations |
| 104 | + :vartype configuration_assignments_for_resource_group_ops: |
| 105 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForResourceGroupOpsOperations |
| 106 | + :ivar configuration_assignments_for_resource_group: |
| 107 | + ConfigurationAssignmentsForResourceGroupOperations operations |
| 108 | + :vartype configuration_assignments_for_resource_group: |
| 109 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForResourceGroupOperations |
| 110 | + :ivar scheduled_event_operation_group: ScheduledEventOperationGroupOperations operations |
| 111 | + :vartype scheduled_event_operation_group: |
| 112 | + azure.mgmt.maintenance.operations.ScheduledEventOperationGroupOperations |
| 113 | + :ivar apply_updates_operation_group: ApplyUpdatesOperationGroupOperations operations |
| 114 | + :vartype apply_updates_operation_group: |
| 115 | + azure.mgmt.maintenance.operations.ApplyUpdatesOperationGroupOperations |
| 116 | + :ivar apply_update_for_resource_group_operation_group: |
| 117 | + ApplyUpdateForResourceGroupOperationGroupOperations operations |
| 118 | + :vartype apply_update_for_resource_group_operation_group: |
| 119 | + azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperationGroupOperations |
| 120 | + :ivar configuration_assignment_for_resource_group_operation_group: |
| 121 | + ConfigurationAssignmentForResourceGroupOperationGroupOperations operations |
| 122 | + :vartype configuration_assignment_for_resource_group_operation_group: |
| 123 | + azure.mgmt.maintenance.operations.ConfigurationAssignmentForResourceGroupOperationGroupOperations |
| 124 | + :ivar updates_operation_group: UpdatesOperationGroupOperations operations |
| 125 | + :vartype updates_operation_group: |
| 126 | + azure.mgmt.maintenance.operations.UpdatesOperationGroupOperations |
| 127 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 128 | + :type credential: ~azure.core.credentials.TokenCredential |
| 129 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 130 | + :type subscription_id: str |
| 131 | + :param base_url: Service host. Default value is None. |
| 132 | + :type base_url: str |
| 133 | + :keyword api_version: The API version to use for this operation. Default value is |
| 134 | + "2023-10-01-preview". Note that overriding this default value may result in unsupported |
| 135 | + behavior. |
| 136 | + :paramtype api_version: str |
| 137 | + """ |
| 138 | + |
| 139 | + def __init__( |
| 140 | + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any |
| 141 | + ) -> None: |
| 142 | + _endpoint = "{endpoint}" |
| 143 | + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore |
| 144 | + _endpoints = get_arm_endpoints(_cloud) |
| 145 | + if not base_url: |
| 146 | + base_url = _endpoints["resource_manager"] |
| 147 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 148 | + self._config = MaintenanceClientConfiguration( |
| 149 | + credential=credential, |
| 150 | + subscription_id=subscription_id, |
| 151 | + base_url=cast(str, base_url), |
| 152 | + credential_scopes=credential_scopes, |
| 153 | + **kwargs |
| 154 | + ) |
| 155 | + |
| 156 | + _policies = kwargs.pop("policies", None) |
| 157 | + if _policies is None: |
| 158 | + _policies = [ |
| 159 | + policies.RequestIdPolicy(**kwargs), |
| 160 | + self._config.headers_policy, |
| 161 | + self._config.user_agent_policy, |
| 162 | + self._config.proxy_policy, |
| 163 | + policies.ContentDecodePolicy(**kwargs), |
| 164 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 165 | + self._config.redirect_policy, |
| 166 | + self._config.retry_policy, |
| 167 | + self._config.authentication_policy, |
| 168 | + self._config.custom_hook_policy, |
| 169 | + self._config.logging_policy, |
| 170 | + policies.DistributedTracingPolicy(**kwargs), |
| 171 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 172 | + self._config.http_logging_policy, |
| 173 | + ] |
| 174 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) |
| 175 | + |
| 176 | + self._serialize = Serializer() |
| 177 | + self._deserialize = Deserializer() |
| 178 | + self._serialize.client_side_validation = False |
| 179 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 180 | + self.maintenance_configuration_ops = MaintenanceConfigurationOpsOperations( |
| 181 | + self._client, self._config, self._serialize, self._deserialize |
| 182 | + ) |
| 183 | + self.maintenance_configurations = MaintenanceConfigurationsOperations( |
| 184 | + self._client, self._config, self._serialize, self._deserialize |
| 185 | + ) |
| 186 | + self.maintenance_configuration_operation_group_ops = MaintenanceConfigurationOperationGroupOpsOperations( |
| 187 | + self._client, self._config, self._serialize, self._deserialize |
| 188 | + ) |
| 189 | + self.maintenance_configuration_operation_group = MaintenanceConfigurationOperationGroupOperations( |
| 190 | + self._client, self._config, self._serialize, self._deserialize |
| 191 | + ) |
| 192 | + self.apply_update_ops = ApplyUpdateOpsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 193 | + self.apply_updates = ApplyUpdatesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 194 | + self.apply_update_operation_group_ops = ApplyUpdateOperationGroupOpsOperations( |
| 195 | + self._client, self._config, self._serialize, self._deserialize |
| 196 | + ) |
| 197 | + self.apply_update_operation_group = ApplyUpdateOperationGroupOperations( |
| 198 | + self._client, self._config, self._serialize, self._deserialize |
| 199 | + ) |
| 200 | + self.configuration_assignment_ops = ConfigurationAssignmentOpsOperations( |
| 201 | + self._client, self._config, self._serialize, self._deserialize |
| 202 | + ) |
| 203 | + self.configuration_assignments = ConfigurationAssignmentsOperations( |
| 204 | + self._client, self._config, self._serialize, self._deserialize |
| 205 | + ) |
| 206 | + self.configuration_assignment_operation_group_ops = ConfigurationAssignmentOperationGroupOpsOperations( |
| 207 | + self._client, self._config, self._serialize, self._deserialize |
| 208 | + ) |
| 209 | + self.configuration_assignment_operation_group = ConfigurationAssignmentOperationGroupOperations( |
| 210 | + self._client, self._config, self._serialize, self._deserialize |
| 211 | + ) |
| 212 | + self.configuration_assignments_for_subscription_ops = ConfigurationAssignmentsForSubscriptionOpsOperations( |
| 213 | + self._client, self._config, self._serialize, self._deserialize |
| 214 | + ) |
| 215 | + self.configuration_assignments_for_subscriptions = ConfigurationAssignmentsForSubscriptionsOperations( |
| 216 | + self._client, self._config, self._serialize, self._deserialize |
| 217 | + ) |
| 218 | + self.configuration_assignments_for_resource_group_ops = ConfigurationAssignmentsForResourceGroupOpsOperations( |
| 219 | + self._client, self._config, self._serialize, self._deserialize |
| 220 | + ) |
| 221 | + self.configuration_assignments_for_resource_group = ConfigurationAssignmentsForResourceGroupOperations( |
| 222 | + self._client, self._config, self._serialize, self._deserialize |
| 223 | + ) |
| 224 | + self.scheduled_event_operation_group = ScheduledEventOperationGroupOperations( |
| 225 | + self._client, self._config, self._serialize, self._deserialize |
| 226 | + ) |
| 227 | + self.apply_updates_operation_group = ApplyUpdatesOperationGroupOperations( |
| 228 | + self._client, self._config, self._serialize, self._deserialize |
| 229 | + ) |
| 230 | + self.apply_update_for_resource_group_operation_group = ApplyUpdateForResourceGroupOperationGroupOperations( |
| 231 | + self._client, self._config, self._serialize, self._deserialize |
| 232 | + ) |
| 233 | + self.configuration_assignment_for_resource_group_operation_group = ( |
| 234 | + ConfigurationAssignmentForResourceGroupOperationGroupOperations( |
| 235 | + self._client, self._config, self._serialize, self._deserialize |
| 236 | + ) |
| 237 | + ) |
| 238 | + self.updates_operation_group = UpdatesOperationGroupOperations( |
| 239 | + self._client, self._config, self._serialize, self._deserialize |
| 240 | + ) |
| 241 | + |
| 242 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 243 | + """Runs the network request through the client's chained policies. |
| 244 | +
|
| 245 | + >>> from azure.core.rest import HttpRequest |
| 246 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 247 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 248 | + >>> response = client.send_request(request) |
| 249 | + <HttpResponse: 200 OK> |
| 250 | +
|
| 251 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 252 | +
|
| 253 | + :param request: The network request you want to make. Required. |
| 254 | + :type request: ~azure.core.rest.HttpRequest |
| 255 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 256 | + :return: The response of your network call. Does not do error handling on your response. |
| 257 | + :rtype: ~azure.core.rest.HttpResponse |
| 258 | + """ |
| 259 | + |
| 260 | + request_copy = deepcopy(request) |
| 261 | + path_format_arguments = { |
| 262 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 263 | + } |
| 264 | + |
| 265 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 266 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 267 | + |
| 268 | + def close(self) -> None: |
| 269 | + self._client.close() |
| 270 | + |
| 271 | + def __enter__(self) -> Self: |
| 272 | + self._client.__enter__() |
| 273 | + return self |
| 274 | + |
| 275 | + def __exit__(self, *exc_details: Any) -> None: |
| 276 | + self._client.__exit__(*exc_details) |
0 commit comments