|
| 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 RecoveryServicesClientConfiguration |
| 21 | +from ._utils.serialization import Deserializer, Serializer |
| 22 | +from .operations import ( |
| 23 | + DeletedVaultsOperations, |
| 24 | + Operations, |
| 25 | + PrivateLinkResourcesOperations, |
| 26 | + RecoveryServicesOperations, |
| 27 | + RegisteredIdentitiesOperations, |
| 28 | + ReplicationUsagesOperations, |
| 29 | + UsagesOperations, |
| 30 | + VaultCertificatesOperations, |
| 31 | + VaultExtendedInfoOperations, |
| 32 | + VaultsOperations, |
| 33 | + _RecoveryServicesClientOperationsMixin, |
| 34 | +) |
| 35 | + |
| 36 | +if TYPE_CHECKING: |
| 37 | + from azure.core import AzureClouds |
| 38 | + from azure.core.credentials import TokenCredential |
| 39 | + |
| 40 | + |
| 41 | +class RecoveryServicesClient(_RecoveryServicesClientOperationsMixin): # pylint: disable=too-many-instance-attributes |
| 42 | + """RecoveryServicesClient. |
| 43 | +
|
| 44 | + :ivar operations: Operations operations |
| 45 | + :vartype operations: azure.mgmt.recoveryservices.operations.Operations |
| 46 | + :ivar vaults: VaultsOperations operations |
| 47 | + :vartype vaults: azure.mgmt.recoveryservices.operations.VaultsOperations |
| 48 | + :ivar deleted_vaults: DeletedVaultsOperations operations |
| 49 | + :vartype deleted_vaults: azure.mgmt.recoveryservices.operations.DeletedVaultsOperations |
| 50 | + :ivar private_link_resources: PrivateLinkResourcesOperations operations |
| 51 | + :vartype private_link_resources: |
| 52 | + azure.mgmt.recoveryservices.operations.PrivateLinkResourcesOperations |
| 53 | + :ivar vault_certificates: VaultCertificatesOperations operations |
| 54 | + :vartype vault_certificates: azure.mgmt.recoveryservices.operations.VaultCertificatesOperations |
| 55 | + :ivar registered_identities: RegisteredIdentitiesOperations operations |
| 56 | + :vartype registered_identities: |
| 57 | + azure.mgmt.recoveryservices.operations.RegisteredIdentitiesOperations |
| 58 | + :ivar replication_usages: ReplicationUsagesOperations operations |
| 59 | + :vartype replication_usages: azure.mgmt.recoveryservices.operations.ReplicationUsagesOperations |
| 60 | + :ivar usages: UsagesOperations operations |
| 61 | + :vartype usages: azure.mgmt.recoveryservices.operations.UsagesOperations |
| 62 | + :ivar vault_extended_info: VaultExtendedInfoOperations operations |
| 63 | + :vartype vault_extended_info: |
| 64 | + azure.mgmt.recoveryservices.operations.VaultExtendedInfoOperations |
| 65 | + :ivar recovery_services: RecoveryServicesOperations operations |
| 66 | + :vartype recovery_services: azure.mgmt.recoveryservices.operations.RecoveryServicesOperations |
| 67 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 68 | + :type credential: ~azure.core.credentials.TokenCredential |
| 69 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 70 | + :type subscription_id: str |
| 71 | + :param base_url: Service host. Default value is None. |
| 72 | + :type base_url: str |
| 73 | + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is |
| 74 | + None. |
| 75 | + :paramtype cloud_setting: ~azure.core.AzureClouds |
| 76 | + :keyword api_version: The API version to use for this operation. Default value is "2025-08-01". |
| 77 | + Note that overriding this default value may result in unsupported behavior. |
| 78 | + :paramtype api_version: str |
| 79 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 80 | + Retry-After header is present. |
| 81 | + """ |
| 82 | + |
| 83 | + def __init__( |
| 84 | + self, |
| 85 | + credential: "TokenCredential", |
| 86 | + subscription_id: str, |
| 87 | + base_url: Optional[str] = None, |
| 88 | + *, |
| 89 | + cloud_setting: Optional["AzureClouds"] = None, |
| 90 | + **kwargs: Any |
| 91 | + ) -> None: |
| 92 | + _endpoint = "{endpoint}" |
| 93 | + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore |
| 94 | + _endpoints = get_arm_endpoints(_cloud) |
| 95 | + if not base_url: |
| 96 | + base_url = _endpoints["resource_manager"] |
| 97 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 98 | + self._config = RecoveryServicesClientConfiguration( |
| 99 | + credential=credential, |
| 100 | + subscription_id=subscription_id, |
| 101 | + base_url=cast(str, base_url), |
| 102 | + cloud_setting=cloud_setting, |
| 103 | + credential_scopes=credential_scopes, |
| 104 | + **kwargs |
| 105 | + ) |
| 106 | + |
| 107 | + _policies = kwargs.pop("policies", None) |
| 108 | + if _policies is None: |
| 109 | + _policies = [ |
| 110 | + policies.RequestIdPolicy(**kwargs), |
| 111 | + self._config.headers_policy, |
| 112 | + self._config.user_agent_policy, |
| 113 | + self._config.proxy_policy, |
| 114 | + policies.ContentDecodePolicy(**kwargs), |
| 115 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 116 | + self._config.redirect_policy, |
| 117 | + self._config.retry_policy, |
| 118 | + self._config.authentication_policy, |
| 119 | + self._config.custom_hook_policy, |
| 120 | + self._config.logging_policy, |
| 121 | + policies.DistributedTracingPolicy(**kwargs), |
| 122 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 123 | + self._config.http_logging_policy, |
| 124 | + ] |
| 125 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) |
| 126 | + |
| 127 | + self._serialize = Serializer() |
| 128 | + self._deserialize = Deserializer() |
| 129 | + self._serialize.client_side_validation = False |
| 130 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 131 | + self.vaults = VaultsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 132 | + self.deleted_vaults = DeletedVaultsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 133 | + self.private_link_resources = PrivateLinkResourcesOperations( |
| 134 | + self._client, self._config, self._serialize, self._deserialize |
| 135 | + ) |
| 136 | + self.vault_certificates = VaultCertificatesOperations( |
| 137 | + self._client, self._config, self._serialize, self._deserialize |
| 138 | + ) |
| 139 | + self.registered_identities = RegisteredIdentitiesOperations( |
| 140 | + self._client, self._config, self._serialize, self._deserialize |
| 141 | + ) |
| 142 | + self.replication_usages = ReplicationUsagesOperations( |
| 143 | + self._client, self._config, self._serialize, self._deserialize |
| 144 | + ) |
| 145 | + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 146 | + self.vault_extended_info = VaultExtendedInfoOperations( |
| 147 | + self._client, self._config, self._serialize, self._deserialize |
| 148 | + ) |
| 149 | + self.recovery_services = RecoveryServicesOperations( |
| 150 | + self._client, self._config, self._serialize, self._deserialize |
| 151 | + ) |
| 152 | + |
| 153 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 154 | + """Runs the network request through the client's chained policies. |
| 155 | +
|
| 156 | + >>> from azure.core.rest import HttpRequest |
| 157 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 158 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 159 | + >>> response = client.send_request(request) |
| 160 | + <HttpResponse: 200 OK> |
| 161 | +
|
| 162 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 163 | +
|
| 164 | + :param request: The network request you want to make. Required. |
| 165 | + :type request: ~azure.core.rest.HttpRequest |
| 166 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 167 | + :return: The response of your network call. Does not do error handling on your response. |
| 168 | + :rtype: ~azure.core.rest.HttpResponse |
| 169 | + """ |
| 170 | + |
| 171 | + request_copy = deepcopy(request) |
| 172 | + path_format_arguments = { |
| 173 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 174 | + } |
| 175 | + |
| 176 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 177 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 178 | + |
| 179 | + def close(self) -> None: |
| 180 | + self._client.close() |
| 181 | + |
| 182 | + def __enter__(self) -> Self: |
| 183 | + self._client.__enter__() |
| 184 | + return self |
| 185 | + |
| 186 | + def __exit__(self, *exc_details: Any) -> None: |
| 187 | + self._client.__exit__(*exc_details) |
0 commit comments