|
| 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) AutoRest 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 . import models as _models |
| 21 | +from ._configuration import MySQLManagementClientConfiguration |
| 22 | +from ._utils.serialization import Deserializer, Serializer |
| 23 | +from .operations import ( |
| 24 | + BackupsOperations, |
| 25 | + CheckNameAvailabilityOperations, |
| 26 | + CheckNameAvailabilityWithoutLocationOperations, |
| 27 | + CheckVirtualNetworkSubnetUsageOperations, |
| 28 | + ConfigurationsOperations, |
| 29 | + DatabasesOperations, |
| 30 | + FirewallRulesOperations, |
| 31 | + GetPrivateDnsZoneSuffixOperations, |
| 32 | + LocationBasedCapabilitiesOperations, |
| 33 | + Operations, |
| 34 | + ReplicasOperations, |
| 35 | + ServersOperations, |
| 36 | +) |
| 37 | + |
| 38 | +if TYPE_CHECKING: |
| 39 | + from azure.core import AzureClouds |
| 40 | + from azure.core.credentials import TokenCredential |
| 41 | + |
| 42 | + |
| 43 | +class MySQLManagementClient: # pylint: disable=too-many-instance-attributes |
| 44 | + """The Microsoft Azure management API provides create, read, update, and delete functionality for |
| 45 | + Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files and |
| 46 | + configurations with new business model. |
| 47 | +
|
| 48 | + :ivar servers: ServersOperations operations |
| 49 | + :vartype servers: azure.mgmt.rdbms.mysql_flexibleservers.operations.ServersOperations |
| 50 | + :ivar replicas: ReplicasOperations operations |
| 51 | + :vartype replicas: azure.mgmt.rdbms.mysql_flexibleservers.operations.ReplicasOperations |
| 52 | + :ivar backups: BackupsOperations operations |
| 53 | + :vartype backups: azure.mgmt.rdbms.mysql_flexibleservers.operations.BackupsOperations |
| 54 | + :ivar firewall_rules: FirewallRulesOperations operations |
| 55 | + :vartype firewall_rules: |
| 56 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.FirewallRulesOperations |
| 57 | + :ivar databases: DatabasesOperations operations |
| 58 | + :vartype databases: azure.mgmt.rdbms.mysql_flexibleservers.operations.DatabasesOperations |
| 59 | + :ivar configurations: ConfigurationsOperations operations |
| 60 | + :vartype configurations: |
| 61 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.ConfigurationsOperations |
| 62 | + :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations |
| 63 | + :vartype location_based_capabilities: |
| 64 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.LocationBasedCapabilitiesOperations |
| 65 | + :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations |
| 66 | + :vartype check_virtual_network_subnet_usage: |
| 67 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations |
| 68 | + :ivar check_name_availability: CheckNameAvailabilityOperations operations |
| 69 | + :vartype check_name_availability: |
| 70 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.CheckNameAvailabilityOperations |
| 71 | + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations |
| 72 | + operations |
| 73 | + :vartype check_name_availability_without_location: |
| 74 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations |
| 75 | + :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations |
| 76 | + :vartype get_private_dns_zone_suffix: |
| 77 | + azure.mgmt.rdbms.mysql_flexibleservers.operations.GetPrivateDnsZoneSuffixOperations |
| 78 | + :ivar operations: Operations operations |
| 79 | + :vartype operations: azure.mgmt.rdbms.mysql_flexibleservers.operations.Operations |
| 80 | + :param credential: Credential needed for the client to connect to Azure. Required. |
| 81 | + :type credential: ~azure.core.credentials.TokenCredential |
| 82 | + :param subscription_id: The ID of the target subscription. Required. |
| 83 | + :type subscription_id: str |
| 84 | + :param base_url: Service URL. Default value is None. |
| 85 | + :type base_url: str |
| 86 | + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is |
| 87 | + None. |
| 88 | + :paramtype cloud_setting: ~azure.core.AzureClouds |
| 89 | + :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this |
| 90 | + default value may result in unsupported behavior. |
| 91 | + :paramtype api_version: str |
| 92 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 93 | + Retry-After header is present. |
| 94 | + """ |
| 95 | + |
| 96 | + def __init__( |
| 97 | + self, |
| 98 | + credential: "TokenCredential", |
| 99 | + subscription_id: str, |
| 100 | + base_url: Optional[str] = None, |
| 101 | + *, |
| 102 | + cloud_setting: Optional["AzureClouds"] = None, |
| 103 | + **kwargs: Any |
| 104 | + ) -> None: |
| 105 | + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore |
| 106 | + _endpoints = get_arm_endpoints(_cloud) |
| 107 | + if not base_url: |
| 108 | + base_url = _endpoints["resource_manager"] |
| 109 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 110 | + self._config = MySQLManagementClientConfiguration( |
| 111 | + credential=credential, |
| 112 | + subscription_id=subscription_id, |
| 113 | + cloud_setting=cloud_setting, |
| 114 | + credential_scopes=credential_scopes, |
| 115 | + **kwargs |
| 116 | + ) |
| 117 | + |
| 118 | + _policies = kwargs.pop("policies", None) |
| 119 | + if _policies is None: |
| 120 | + _policies = [ |
| 121 | + policies.RequestIdPolicy(**kwargs), |
| 122 | + self._config.headers_policy, |
| 123 | + self._config.user_agent_policy, |
| 124 | + self._config.proxy_policy, |
| 125 | + policies.ContentDecodePolicy(**kwargs), |
| 126 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 127 | + self._config.redirect_policy, |
| 128 | + self._config.retry_policy, |
| 129 | + self._config.authentication_policy, |
| 130 | + self._config.custom_hook_policy, |
| 131 | + self._config.logging_policy, |
| 132 | + policies.DistributedTracingPolicy(**kwargs), |
| 133 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 134 | + self._config.http_logging_policy, |
| 135 | + ] |
| 136 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) |
| 137 | + |
| 138 | + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} |
| 139 | + self._serialize = Serializer(client_models) |
| 140 | + self._deserialize = Deserializer(client_models) |
| 141 | + self._serialize.client_side_validation = False |
| 142 | + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 143 | + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) |
| 144 | + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 145 | + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 146 | + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 147 | + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 148 | + self.location_based_capabilities = LocationBasedCapabilitiesOperations( |
| 149 | + self._client, self._config, self._serialize, self._deserialize |
| 150 | + ) |
| 151 | + self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( |
| 152 | + self._client, self._config, self._serialize, self._deserialize |
| 153 | + ) |
| 154 | + self.check_name_availability = CheckNameAvailabilityOperations( |
| 155 | + self._client, self._config, self._serialize, self._deserialize |
| 156 | + ) |
| 157 | + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( |
| 158 | + self._client, self._config, self._serialize, self._deserialize |
| 159 | + ) |
| 160 | + self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( |
| 161 | + self._client, self._config, self._serialize, self._deserialize |
| 162 | + ) |
| 163 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 164 | + |
| 165 | + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 166 | + """Runs the network request through the client's chained policies. |
| 167 | +
|
| 168 | + >>> from azure.core.rest import HttpRequest |
| 169 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 170 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 171 | + >>> response = client._send_request(request) |
| 172 | + <HttpResponse: 200 OK> |
| 173 | +
|
| 174 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 175 | +
|
| 176 | + :param request: The network request you want to make. Required. |
| 177 | + :type request: ~azure.core.rest.HttpRequest |
| 178 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 179 | + :return: The response of your network call. Does not do error handling on your response. |
| 180 | + :rtype: ~azure.core.rest.HttpResponse |
| 181 | + """ |
| 182 | + |
| 183 | + request_copy = deepcopy(request) |
| 184 | + request_copy.url = self._client.format_url(request_copy.url) |
| 185 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 186 | + |
| 187 | + def close(self) -> None: |
| 188 | + self._client.close() |
| 189 | + |
| 190 | + def __enter__(self) -> Self: |
| 191 | + self._client.__enter__() |
| 192 | + return self |
| 193 | + |
| 194 | + def __exit__(self, *exc_details: Any) -> None: |
| 195 | + self._client.__exit__(*exc_details) |
0 commit comments