|
| 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 RecoveryServicesDataReplicationMgmtClientConfiguration |
| 21 | +from ._utils.serialization import Deserializer, Serializer |
| 22 | +from .operations import ( |
| 23 | + CheckNameAvailabilityOperations, |
| 24 | + DeploymentPreflightOperations, |
| 25 | + EmailConfigurationOperations, |
| 26 | + EventOperations, |
| 27 | + FabricAgentOperations, |
| 28 | + FabricOperations, |
| 29 | + JobOperations, |
| 30 | + LocationBasedOperationResultsOperations, |
| 31 | + OperationResultsOperations, |
| 32 | + Operations, |
| 33 | + PolicyOperations, |
| 34 | + PrivateEndpointConnectionProxiesOperations, |
| 35 | + PrivateEndpointConnectionsOperations, |
| 36 | + PrivateLinkResourcesOperations, |
| 37 | + ProtectedItemOperations, |
| 38 | + RecoveryPointOperations, |
| 39 | + ReplicationExtensionOperations, |
| 40 | + VaultOperations, |
| 41 | +) |
| 42 | + |
| 43 | +if TYPE_CHECKING: |
| 44 | + from azure.core.credentials import TokenCredential |
| 45 | + |
| 46 | + |
| 47 | +class RecoveryServicesDataReplicationMgmtClient: # pylint: disable=too-many-instance-attributes,name-too-long |
| 48 | + """A first party Azure service enabling the data replication. |
| 49 | +
|
| 50 | + :ivar operations: Operations operations |
| 51 | + :vartype operations: azure.mgmt.recoveryservicesdatareplication.operations.Operations |
| 52 | + :ivar email_configuration: EmailConfigurationOperations operations |
| 53 | + :vartype email_configuration: |
| 54 | + azure.mgmt.recoveryservicesdatareplication.operations.EmailConfigurationOperations |
| 55 | + :ivar vault: VaultOperations operations |
| 56 | + :vartype vault: azure.mgmt.recoveryservicesdatareplication.operations.VaultOperations |
| 57 | + :ivar event: EventOperations operations |
| 58 | + :vartype event: azure.mgmt.recoveryservicesdatareplication.operations.EventOperations |
| 59 | + :ivar fabric: FabricOperations operations |
| 60 | + :vartype fabric: azure.mgmt.recoveryservicesdatareplication.operations.FabricOperations |
| 61 | + :ivar fabric_agent: FabricAgentOperations operations |
| 62 | + :vartype fabric_agent: |
| 63 | + azure.mgmt.recoveryservicesdatareplication.operations.FabricAgentOperations |
| 64 | + :ivar job: JobOperations operations |
| 65 | + :vartype job: azure.mgmt.recoveryservicesdatareplication.operations.JobOperations |
| 66 | + :ivar policy: PolicyOperations operations |
| 67 | + :vartype policy: azure.mgmt.recoveryservicesdatareplication.operations.PolicyOperations |
| 68 | + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations |
| 69 | + :vartype private_endpoint_connections: |
| 70 | + azure.mgmt.recoveryservicesdatareplication.operations.PrivateEndpointConnectionsOperations |
| 71 | + :ivar private_endpoint_connection_proxies: PrivateEndpointConnectionProxiesOperations |
| 72 | + operations |
| 73 | + :vartype private_endpoint_connection_proxies: |
| 74 | + azure.mgmt.recoveryservicesdatareplication.operations.PrivateEndpointConnectionProxiesOperations |
| 75 | + :ivar private_link_resources: PrivateLinkResourcesOperations operations |
| 76 | + :vartype private_link_resources: |
| 77 | + azure.mgmt.recoveryservicesdatareplication.operations.PrivateLinkResourcesOperations |
| 78 | + :ivar protected_item: ProtectedItemOperations operations |
| 79 | + :vartype protected_item: |
| 80 | + azure.mgmt.recoveryservicesdatareplication.operations.ProtectedItemOperations |
| 81 | + :ivar recovery_point: RecoveryPointOperations operations |
| 82 | + :vartype recovery_point: |
| 83 | + azure.mgmt.recoveryservicesdatareplication.operations.RecoveryPointOperations |
| 84 | + :ivar replication_extension: ReplicationExtensionOperations operations |
| 85 | + :vartype replication_extension: |
| 86 | + azure.mgmt.recoveryservicesdatareplication.operations.ReplicationExtensionOperations |
| 87 | + :ivar check_name_availability: CheckNameAvailabilityOperations operations |
| 88 | + :vartype check_name_availability: |
| 89 | + azure.mgmt.recoveryservicesdatareplication.operations.CheckNameAvailabilityOperations |
| 90 | + :ivar deployment_preflight: DeploymentPreflightOperations operations |
| 91 | + :vartype deployment_preflight: |
| 92 | + azure.mgmt.recoveryservicesdatareplication.operations.DeploymentPreflightOperations |
| 93 | + :ivar operation_results: OperationResultsOperations operations |
| 94 | + :vartype operation_results: |
| 95 | + azure.mgmt.recoveryservicesdatareplication.operations.OperationResultsOperations |
| 96 | + :ivar location_based_operation_results: LocationBasedOperationResultsOperations operations |
| 97 | + :vartype location_based_operation_results: |
| 98 | + azure.mgmt.recoveryservicesdatareplication.operations.LocationBasedOperationResultsOperations |
| 99 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 100 | + :type credential: ~azure.core.credentials.TokenCredential |
| 101 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 102 | + :type subscription_id: str |
| 103 | + :param base_url: Service host. Default value is None. |
| 104 | + :type base_url: str |
| 105 | + :keyword api_version: The API version to use for this operation. Default value is "2024-09-01". |
| 106 | + Note that overriding this default value may result in unsupported behavior. |
| 107 | + :paramtype api_version: str |
| 108 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 109 | + Retry-After header is present. |
| 110 | + """ |
| 111 | + |
| 112 | + def __init__( |
| 113 | + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any |
| 114 | + ) -> None: |
| 115 | + _endpoint = "{endpoint}" |
| 116 | + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore |
| 117 | + _endpoints = get_arm_endpoints(_cloud) |
| 118 | + if not base_url: |
| 119 | + base_url = _endpoints["resource_manager"] |
| 120 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 121 | + self._config = RecoveryServicesDataReplicationMgmtClientConfiguration( |
| 122 | + credential=credential, |
| 123 | + subscription_id=subscription_id, |
| 124 | + base_url=cast(str, base_url), |
| 125 | + credential_scopes=credential_scopes, |
| 126 | + **kwargs |
| 127 | + ) |
| 128 | + |
| 129 | + _policies = kwargs.pop("policies", None) |
| 130 | + if _policies is None: |
| 131 | + _policies = [ |
| 132 | + policies.RequestIdPolicy(**kwargs), |
| 133 | + self._config.headers_policy, |
| 134 | + self._config.user_agent_policy, |
| 135 | + self._config.proxy_policy, |
| 136 | + policies.ContentDecodePolicy(**kwargs), |
| 137 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 138 | + self._config.redirect_policy, |
| 139 | + self._config.retry_policy, |
| 140 | + self._config.authentication_policy, |
| 141 | + self._config.custom_hook_policy, |
| 142 | + self._config.logging_policy, |
| 143 | + policies.DistributedTracingPolicy(**kwargs), |
| 144 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 145 | + self._config.http_logging_policy, |
| 146 | + ] |
| 147 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) |
| 148 | + |
| 149 | + self._serialize = Serializer() |
| 150 | + self._deserialize = Deserializer() |
| 151 | + self._serialize.client_side_validation = False |
| 152 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 153 | + self.email_configuration = EmailConfigurationOperations( |
| 154 | + self._client, self._config, self._serialize, self._deserialize |
| 155 | + ) |
| 156 | + self.vault = VaultOperations(self._client, self._config, self._serialize, self._deserialize) |
| 157 | + self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) |
| 158 | + self.fabric = FabricOperations(self._client, self._config, self._serialize, self._deserialize) |
| 159 | + self.fabric_agent = FabricAgentOperations(self._client, self._config, self._serialize, self._deserialize) |
| 160 | + self.job = JobOperations(self._client, self._config, self._serialize, self._deserialize) |
| 161 | + self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) |
| 162 | + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( |
| 163 | + self._client, self._config, self._serialize, self._deserialize |
| 164 | + ) |
| 165 | + self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations( |
| 166 | + self._client, self._config, self._serialize, self._deserialize |
| 167 | + ) |
| 168 | + self.private_link_resources = PrivateLinkResourcesOperations( |
| 169 | + self._client, self._config, self._serialize, self._deserialize |
| 170 | + ) |
| 171 | + self.protected_item = ProtectedItemOperations(self._client, self._config, self._serialize, self._deserialize) |
| 172 | + self.recovery_point = RecoveryPointOperations(self._client, self._config, self._serialize, self._deserialize) |
| 173 | + self.replication_extension = ReplicationExtensionOperations( |
| 174 | + self._client, self._config, self._serialize, self._deserialize |
| 175 | + ) |
| 176 | + self.check_name_availability = CheckNameAvailabilityOperations( |
| 177 | + self._client, self._config, self._serialize, self._deserialize |
| 178 | + ) |
| 179 | + self.deployment_preflight = DeploymentPreflightOperations( |
| 180 | + self._client, self._config, self._serialize, self._deserialize |
| 181 | + ) |
| 182 | + self.operation_results = OperationResultsOperations( |
| 183 | + self._client, self._config, self._serialize, self._deserialize |
| 184 | + ) |
| 185 | + self.location_based_operation_results = LocationBasedOperationResultsOperations( |
| 186 | + self._client, self._config, self._serialize, self._deserialize |
| 187 | + ) |
| 188 | + |
| 189 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 190 | + """Runs the network request through the client's chained policies. |
| 191 | +
|
| 192 | + >>> from azure.core.rest import HttpRequest |
| 193 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 194 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 195 | + >>> response = client.send_request(request) |
| 196 | + <HttpResponse: 200 OK> |
| 197 | +
|
| 198 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 199 | +
|
| 200 | + :param request: The network request you want to make. Required. |
| 201 | + :type request: ~azure.core.rest.HttpRequest |
| 202 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 203 | + :return: The response of your network call. Does not do error handling on your response. |
| 204 | + :rtype: ~azure.core.rest.HttpResponse |
| 205 | + """ |
| 206 | + |
| 207 | + request_copy = deepcopy(request) |
| 208 | + path_format_arguments = { |
| 209 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 210 | + } |
| 211 | + |
| 212 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 213 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 214 | + |
| 215 | + def close(self) -> None: |
| 216 | + self._client.close() |
| 217 | + |
| 218 | + def __enter__(self) -> Self: |
| 219 | + self._client.__enter__() |
| 220 | + return self |
| 221 | + |
| 222 | + def __exit__(self, *exc_details: Any) -> None: |
| 223 | + self._client.__exit__(*exc_details) |
0 commit comments