|
| 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 AVSClientConfiguration |
| 21 | +from ._utils.serialization import Deserializer, Serializer |
| 22 | +from .operations import ( |
| 23 | + AddonsOperations, |
| 24 | + AuthorizationsOperations, |
| 25 | + CloudLinksOperations, |
| 26 | + ClustersOperations, |
| 27 | + DatastoresOperations, |
| 28 | + GlobalReachConnectionsOperations, |
| 29 | + HcxEnterpriseSitesOperations, |
| 30 | + HostsOperations, |
| 31 | + IscsiPathsOperations, |
| 32 | + LocationsOperations, |
| 33 | + Operations, |
| 34 | + PlacementPoliciesOperations, |
| 35 | + PrivateCloudsOperations, |
| 36 | + ProvisionedNetworksOperations, |
| 37 | + PureStoragePoliciesOperations, |
| 38 | + ScriptCmdletsOperations, |
| 39 | + ScriptExecutionsOperations, |
| 40 | + ScriptPackagesOperations, |
| 41 | + SkusOperations, |
| 42 | + VirtualMachinesOperations, |
| 43 | + WorkloadNetworkDhcpConfigurationsOperations, |
| 44 | + WorkloadNetworkDnsServicesOperations, |
| 45 | + WorkloadNetworkDnsZonesOperations, |
| 46 | + WorkloadNetworkGatewaysOperations, |
| 47 | + WorkloadNetworkPortMirroringProfilesOperations, |
| 48 | + WorkloadNetworkPublicIpsOperations, |
| 49 | + WorkloadNetworkSegmentsOperations, |
| 50 | + WorkloadNetworkVirtualMachinesOperations, |
| 51 | + WorkloadNetworkVmGroupsOperations, |
| 52 | + WorkloadNetworksOperations, |
| 53 | +) |
| 54 | + |
| 55 | +if TYPE_CHECKING: |
| 56 | + from azure.core.credentials import TokenCredential |
| 57 | + |
| 58 | + |
| 59 | +class AVSClient: # pylint: disable=too-many-instance-attributes |
| 60 | + """Azure VMware Solution API. |
| 61 | +
|
| 62 | + :ivar operations: Operations operations |
| 63 | + :vartype operations: azure.mgmt.avs.operations.Operations |
| 64 | + :ivar addons: AddonsOperations operations |
| 65 | + :vartype addons: azure.mgmt.avs.operations.AddonsOperations |
| 66 | + :ivar authorizations: AuthorizationsOperations operations |
| 67 | + :vartype authorizations: azure.mgmt.avs.operations.AuthorizationsOperations |
| 68 | + :ivar cloud_links: CloudLinksOperations operations |
| 69 | + :vartype cloud_links: azure.mgmt.avs.operations.CloudLinksOperations |
| 70 | + :ivar clusters: ClustersOperations operations |
| 71 | + :vartype clusters: azure.mgmt.avs.operations.ClustersOperations |
| 72 | + :ivar datastores: DatastoresOperations operations |
| 73 | + :vartype datastores: azure.mgmt.avs.operations.DatastoresOperations |
| 74 | + :ivar global_reach_connections: GlobalReachConnectionsOperations operations |
| 75 | + :vartype global_reach_connections: azure.mgmt.avs.operations.GlobalReachConnectionsOperations |
| 76 | + :ivar hcx_enterprise_sites: HcxEnterpriseSitesOperations operations |
| 77 | + :vartype hcx_enterprise_sites: azure.mgmt.avs.operations.HcxEnterpriseSitesOperations |
| 78 | + :ivar hosts: HostsOperations operations |
| 79 | + :vartype hosts: azure.mgmt.avs.operations.HostsOperations |
| 80 | + :ivar iscsi_paths: IscsiPathsOperations operations |
| 81 | + :vartype iscsi_paths: azure.mgmt.avs.operations.IscsiPathsOperations |
| 82 | + :ivar locations: LocationsOperations operations |
| 83 | + :vartype locations: azure.mgmt.avs.operations.LocationsOperations |
| 84 | + :ivar placement_policies: PlacementPoliciesOperations operations |
| 85 | + :vartype placement_policies: azure.mgmt.avs.operations.PlacementPoliciesOperations |
| 86 | + :ivar private_clouds: PrivateCloudsOperations operations |
| 87 | + :vartype private_clouds: azure.mgmt.avs.operations.PrivateCloudsOperations |
| 88 | + :ivar provisioned_networks: ProvisionedNetworksOperations operations |
| 89 | + :vartype provisioned_networks: azure.mgmt.avs.operations.ProvisionedNetworksOperations |
| 90 | + :ivar pure_storage_policies: PureStoragePoliciesOperations operations |
| 91 | + :vartype pure_storage_policies: azure.mgmt.avs.operations.PureStoragePoliciesOperations |
| 92 | + :ivar script_cmdlets: ScriptCmdletsOperations operations |
| 93 | + :vartype script_cmdlets: azure.mgmt.avs.operations.ScriptCmdletsOperations |
| 94 | + :ivar script_executions: ScriptExecutionsOperations operations |
| 95 | + :vartype script_executions: azure.mgmt.avs.operations.ScriptExecutionsOperations |
| 96 | + :ivar script_packages: ScriptPackagesOperations operations |
| 97 | + :vartype script_packages: azure.mgmt.avs.operations.ScriptPackagesOperations |
| 98 | + :ivar skus: SkusOperations operations |
| 99 | + :vartype skus: azure.mgmt.avs.operations.SkusOperations |
| 100 | + :ivar virtual_machines: VirtualMachinesOperations operations |
| 101 | + :vartype virtual_machines: azure.mgmt.avs.operations.VirtualMachinesOperations |
| 102 | + :ivar workload_network_dhcp_configurations: WorkloadNetworkDhcpConfigurationsOperations |
| 103 | + operations |
| 104 | + :vartype workload_network_dhcp_configurations: |
| 105 | + azure.mgmt.avs.operations.WorkloadNetworkDhcpConfigurationsOperations |
| 106 | + :ivar workload_network_dns_services: WorkloadNetworkDnsServicesOperations operations |
| 107 | + :vartype workload_network_dns_services: |
| 108 | + azure.mgmt.avs.operations.WorkloadNetworkDnsServicesOperations |
| 109 | + :ivar workload_network_dns_zones: WorkloadNetworkDnsZonesOperations operations |
| 110 | + :vartype workload_network_dns_zones: |
| 111 | + azure.mgmt.avs.operations.WorkloadNetworkDnsZonesOperations |
| 112 | + :ivar workload_network_gateways: WorkloadNetworkGatewaysOperations operations |
| 113 | + :vartype workload_network_gateways: azure.mgmt.avs.operations.WorkloadNetworkGatewaysOperations |
| 114 | + :ivar workload_network_port_mirroring_profiles: WorkloadNetworkPortMirroringProfilesOperations |
| 115 | + operations |
| 116 | + :vartype workload_network_port_mirroring_profiles: |
| 117 | + azure.mgmt.avs.operations.WorkloadNetworkPortMirroringProfilesOperations |
| 118 | + :ivar workload_network_public_ips: WorkloadNetworkPublicIpsOperations operations |
| 119 | + :vartype workload_network_public_ips: |
| 120 | + azure.mgmt.avs.operations.WorkloadNetworkPublicIpsOperations |
| 121 | + :ivar workload_network_segments: WorkloadNetworkSegmentsOperations operations |
| 122 | + :vartype workload_network_segments: azure.mgmt.avs.operations.WorkloadNetworkSegmentsOperations |
| 123 | + :ivar workload_network_virtual_machines: WorkloadNetworkVirtualMachinesOperations operations |
| 124 | + :vartype workload_network_virtual_machines: |
| 125 | + azure.mgmt.avs.operations.WorkloadNetworkVirtualMachinesOperations |
| 126 | + :ivar workload_network_vm_groups: WorkloadNetworkVmGroupsOperations operations |
| 127 | + :vartype workload_network_vm_groups: |
| 128 | + azure.mgmt.avs.operations.WorkloadNetworkVmGroupsOperations |
| 129 | + :ivar workload_networks: WorkloadNetworksOperations operations |
| 130 | + :vartype workload_networks: azure.mgmt.avs.operations.WorkloadNetworksOperations |
| 131 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 132 | + :type credential: ~azure.core.credentials.TokenCredential |
| 133 | + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. |
| 134 | + :type subscription_id: str |
| 135 | + :param base_url: Service host. Default value is None. |
| 136 | + :type base_url: str |
| 137 | + :keyword api_version: The API version to use for this operation. Default value is "2024-09-01". |
| 138 | + Note that overriding this default value may result in unsupported behavior. |
| 139 | + :paramtype api_version: str |
| 140 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 141 | + Retry-After header is present. |
| 142 | + """ |
| 143 | + |
| 144 | + def __init__( |
| 145 | + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any |
| 146 | + ) -> None: |
| 147 | + _endpoint = "{endpoint}" |
| 148 | + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore |
| 149 | + _endpoints = get_arm_endpoints(_cloud) |
| 150 | + if not base_url: |
| 151 | + base_url = _endpoints["resource_manager"] |
| 152 | + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) |
| 153 | + self._config = AVSClientConfiguration( |
| 154 | + credential=credential, |
| 155 | + subscription_id=subscription_id, |
| 156 | + base_url=cast(str, base_url), |
| 157 | + credential_scopes=credential_scopes, |
| 158 | + **kwargs |
| 159 | + ) |
| 160 | + |
| 161 | + _policies = kwargs.pop("policies", None) |
| 162 | + if _policies is None: |
| 163 | + _policies = [ |
| 164 | + policies.RequestIdPolicy(**kwargs), |
| 165 | + self._config.headers_policy, |
| 166 | + self._config.user_agent_policy, |
| 167 | + self._config.proxy_policy, |
| 168 | + policies.ContentDecodePolicy(**kwargs), |
| 169 | + ARMAutoResourceProviderRegistrationPolicy(), |
| 170 | + self._config.redirect_policy, |
| 171 | + self._config.retry_policy, |
| 172 | + self._config.authentication_policy, |
| 173 | + self._config.custom_hook_policy, |
| 174 | + self._config.logging_policy, |
| 175 | + policies.DistributedTracingPolicy(**kwargs), |
| 176 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 177 | + self._config.http_logging_policy, |
| 178 | + ] |
| 179 | + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) |
| 180 | + |
| 181 | + self._serialize = Serializer() |
| 182 | + self._deserialize = Deserializer() |
| 183 | + self._serialize.client_side_validation = False |
| 184 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 185 | + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 186 | + self.authorizations = AuthorizationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 187 | + self.cloud_links = CloudLinksOperations(self._client, self._config, self._serialize, self._deserialize) |
| 188 | + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 189 | + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) |
| 190 | + self.global_reach_connections = GlobalReachConnectionsOperations( |
| 191 | + self._client, self._config, self._serialize, self._deserialize |
| 192 | + ) |
| 193 | + self.hcx_enterprise_sites = HcxEnterpriseSitesOperations( |
| 194 | + self._client, self._config, self._serialize, self._deserialize |
| 195 | + ) |
| 196 | + self.hosts = HostsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 197 | + self.iscsi_paths = IscsiPathsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 198 | + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 199 | + self.placement_policies = PlacementPoliciesOperations( |
| 200 | + self._client, self._config, self._serialize, self._deserialize |
| 201 | + ) |
| 202 | + self.private_clouds = PrivateCloudsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 203 | + self.provisioned_networks = ProvisionedNetworksOperations( |
| 204 | + self._client, self._config, self._serialize, self._deserialize |
| 205 | + ) |
| 206 | + self.pure_storage_policies = PureStoragePoliciesOperations( |
| 207 | + self._client, self._config, self._serialize, self._deserialize |
| 208 | + ) |
| 209 | + self.script_cmdlets = ScriptCmdletsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 210 | + self.script_executions = ScriptExecutionsOperations( |
| 211 | + self._client, self._config, self._serialize, self._deserialize |
| 212 | + ) |
| 213 | + self.script_packages = ScriptPackagesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 214 | + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) |
| 215 | + self.virtual_machines = VirtualMachinesOperations( |
| 216 | + self._client, self._config, self._serialize, self._deserialize |
| 217 | + ) |
| 218 | + self.workload_network_dhcp_configurations = WorkloadNetworkDhcpConfigurationsOperations( |
| 219 | + self._client, self._config, self._serialize, self._deserialize |
| 220 | + ) |
| 221 | + self.workload_network_dns_services = WorkloadNetworkDnsServicesOperations( |
| 222 | + self._client, self._config, self._serialize, self._deserialize |
| 223 | + ) |
| 224 | + self.workload_network_dns_zones = WorkloadNetworkDnsZonesOperations( |
| 225 | + self._client, self._config, self._serialize, self._deserialize |
| 226 | + ) |
| 227 | + self.workload_network_gateways = WorkloadNetworkGatewaysOperations( |
| 228 | + self._client, self._config, self._serialize, self._deserialize |
| 229 | + ) |
| 230 | + self.workload_network_port_mirroring_profiles = WorkloadNetworkPortMirroringProfilesOperations( |
| 231 | + self._client, self._config, self._serialize, self._deserialize |
| 232 | + ) |
| 233 | + self.workload_network_public_ips = WorkloadNetworkPublicIpsOperations( |
| 234 | + self._client, self._config, self._serialize, self._deserialize |
| 235 | + ) |
| 236 | + self.workload_network_segments = WorkloadNetworkSegmentsOperations( |
| 237 | + self._client, self._config, self._serialize, self._deserialize |
| 238 | + ) |
| 239 | + self.workload_network_virtual_machines = WorkloadNetworkVirtualMachinesOperations( |
| 240 | + self._client, self._config, self._serialize, self._deserialize |
| 241 | + ) |
| 242 | + self.workload_network_vm_groups = WorkloadNetworkVmGroupsOperations( |
| 243 | + self._client, self._config, self._serialize, self._deserialize |
| 244 | + ) |
| 245 | + self.workload_networks = WorkloadNetworksOperations( |
| 246 | + self._client, self._config, self._serialize, self._deserialize |
| 247 | + ) |
| 248 | + |
| 249 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 250 | + """Runs the network request through the client's chained policies. |
| 251 | +
|
| 252 | + >>> from azure.core.rest import HttpRequest |
| 253 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 254 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 255 | + >>> response = client.send_request(request) |
| 256 | + <HttpResponse: 200 OK> |
| 257 | +
|
| 258 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 259 | +
|
| 260 | + :param request: The network request you want to make. Required. |
| 261 | + :type request: ~azure.core.rest.HttpRequest |
| 262 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 263 | + :return: The response of your network call. Does not do error handling on your response. |
| 264 | + :rtype: ~azure.core.rest.HttpResponse |
| 265 | + """ |
| 266 | + |
| 267 | + request_copy = deepcopy(request) |
| 268 | + path_format_arguments = { |
| 269 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 270 | + } |
| 271 | + |
| 272 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 273 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 274 | + |
| 275 | + def close(self) -> None: |
| 276 | + self._client.close() |
| 277 | + |
| 278 | + def __enter__(self) -> Self: |
| 279 | + self._client.__enter__() |
| 280 | + return self |
| 281 | + |
| 282 | + def __exit__(self, *exc_details: Any) -> None: |
| 283 | + self._client.__exit__(*exc_details) |
0 commit comments