|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. |
7 | 7 | # -------------------------------------------------------------------------- |
8 | 8 |
|
9 | | -from typing import TYPE_CHECKING |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient |
12 | | -from msrest import Deserializer, Serializer |
| 14 | + |
| 15 | +from . import models |
| 16 | +from ._configuration import AVSClientConfiguration |
| 17 | +from ._serialization import Deserializer, Serializer |
| 18 | +from .operations import ( |
| 19 | + AddonsOperations, |
| 20 | + AuthorizationsOperations, |
| 21 | + CloudLinksOperations, |
| 22 | + ClustersOperations, |
| 23 | + DatastoresOperations, |
| 24 | + GlobalReachConnectionsOperations, |
| 25 | + HcxEnterpriseSitesOperations, |
| 26 | + LocationsOperations, |
| 27 | + Operations, |
| 28 | + PlacementPoliciesOperations, |
| 29 | + PrivateCloudsOperations, |
| 30 | + ScriptCmdletsOperations, |
| 31 | + ScriptExecutionsOperations, |
| 32 | + ScriptPackagesOperations, |
| 33 | + VirtualMachinesOperations, |
| 34 | + WorkloadNetworksOperations, |
| 35 | +) |
13 | 36 |
|
14 | 37 | if TYPE_CHECKING: |
15 | 38 | # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | 39 | from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | | - |
21 | | -from ._configuration import AVSClientConfiguration |
22 | | -from .operations import Operations |
23 | | -from .operations import LocationsOperations |
24 | | -from .operations import PrivateCloudsOperations |
25 | | -from .operations import ClustersOperations |
26 | | -from .operations import DatastoresOperations |
27 | | -from .operations import HcxEnterpriseSitesOperations |
28 | | -from .operations import AuthorizationsOperations |
29 | | -from .operations import GlobalReachConnectionsOperations |
30 | | -from .operations import WorkloadNetworksOperations |
31 | | -from .operations import CloudLinksOperations |
32 | | -from .operations import AddonsOperations |
33 | | -from .operations import VirtualMachinesOperations |
34 | | -from .operations import PlacementPoliciesOperations |
35 | | -from .operations import ScriptPackagesOperations |
36 | | -from .operations import ScriptCmdletsOperations |
37 | | -from .operations import ScriptExecutionsOperations |
38 | | -from . import models |
39 | 40 |
|
40 | 41 |
|
41 | | -class AVSClient(object): |
| 42 | +class AVSClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes |
42 | 43 | """Azure VMware Solution API. |
43 | 44 |
|
44 | 45 | :ivar operations: Operations operations |
@@ -73,82 +74,83 @@ class AVSClient(object): |
73 | 74 | :vartype script_cmdlets: azure.mgmt.avs.operations.ScriptCmdletsOperations |
74 | 75 | :ivar script_executions: ScriptExecutionsOperations operations |
75 | 76 | :vartype script_executions: azure.mgmt.avs.operations.ScriptExecutionsOperations |
76 | | - :param credential: Credential needed for the client to connect to Azure. |
| 77 | + :param credential: Credential needed for the client to connect to Azure. Required. |
77 | 78 | :type credential: ~azure.core.credentials.TokenCredential |
78 | | - :param subscription_id: The ID of the target subscription. |
| 79 | + :param subscription_id: The ID of the target subscription. Required. |
79 | 80 | :type subscription_id: str |
80 | | - :param str base_url: Service URL |
81 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 81 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 82 | + :type base_url: str |
| 83 | + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this |
| 84 | + default value may result in unsupported behavior. |
| 85 | + :paramtype api_version: str |
| 86 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 87 | + Retry-After header is present. |
82 | 88 | """ |
83 | 89 |
|
84 | 90 | def __init__( |
85 | 91 | self, |
86 | | - credential, # type: "TokenCredential" |
87 | | - subscription_id, # type: str |
88 | | - base_url=None, # type: Optional[str] |
89 | | - **kwargs # type: Any |
90 | | - ): |
91 | | - # type: (...) -> None |
92 | | - if not base_url: |
93 | | - base_url = 'https://management.azure.com' |
94 | | - self._config = AVSClientConfiguration(credential, subscription_id, **kwargs) |
| 92 | + credential: "TokenCredential", |
| 93 | + subscription_id: str, |
| 94 | + base_url: str = "https://management.azure.com", |
| 95 | + **kwargs: Any |
| 96 | + ) -> None: |
| 97 | + self._config = AVSClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
95 | 98 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
96 | 99 |
|
97 | 100 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
98 | 101 | self._serialize = Serializer(client_models) |
99 | | - self._serialize.client_side_validation = False |
100 | 102 | self._deserialize = Deserializer(client_models) |
101 | | - |
102 | | - self.operations = Operations( |
103 | | - self._client, self._config, self._serialize, self._deserialize) |
104 | | - self.locations = LocationsOperations( |
105 | | - self._client, self._config, self._serialize, self._deserialize) |
106 | | - self.private_clouds = PrivateCloudsOperations( |
107 | | - self._client, self._config, self._serialize, self._deserialize) |
108 | | - self.clusters = ClustersOperations( |
109 | | - self._client, self._config, self._serialize, self._deserialize) |
110 | | - self.datastores = DatastoresOperations( |
111 | | - self._client, self._config, self._serialize, self._deserialize) |
| 103 | + self._serialize.client_side_validation = False |
| 104 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 105 | + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 106 | + self.private_clouds = PrivateCloudsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 107 | + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 108 | + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) |
112 | 109 | self.hcx_enterprise_sites = HcxEnterpriseSitesOperations( |
113 | | - self._client, self._config, self._serialize, self._deserialize) |
114 | | - self.authorizations = AuthorizationsOperations( |
115 | | - self._client, self._config, self._serialize, self._deserialize) |
| 110 | + self._client, self._config, self._serialize, self._deserialize |
| 111 | + ) |
| 112 | + self.authorizations = AuthorizationsOperations(self._client, self._config, self._serialize, self._deserialize) |
116 | 113 | self.global_reach_connections = GlobalReachConnectionsOperations( |
117 | | - self._client, self._config, self._serialize, self._deserialize) |
| 114 | + self._client, self._config, self._serialize, self._deserialize |
| 115 | + ) |
118 | 116 | self.workload_networks = WorkloadNetworksOperations( |
119 | | - self._client, self._config, self._serialize, self._deserialize) |
120 | | - self.cloud_links = CloudLinksOperations( |
121 | | - self._client, self._config, self._serialize, self._deserialize) |
122 | | - self.addons = AddonsOperations( |
123 | | - self._client, self._config, self._serialize, self._deserialize) |
| 117 | + self._client, self._config, self._serialize, self._deserialize |
| 118 | + ) |
| 119 | + self.cloud_links = CloudLinksOperations(self._client, self._config, self._serialize, self._deserialize) |
| 120 | + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) |
124 | 121 | self.virtual_machines = VirtualMachinesOperations( |
125 | | - self._client, self._config, self._serialize, self._deserialize) |
| 122 | + self._client, self._config, self._serialize, self._deserialize |
| 123 | + ) |
126 | 124 | self.placement_policies = PlacementPoliciesOperations( |
127 | | - self._client, self._config, self._serialize, self._deserialize) |
128 | | - self.script_packages = ScriptPackagesOperations( |
129 | | - self._client, self._config, self._serialize, self._deserialize) |
130 | | - self.script_cmdlets = ScriptCmdletsOperations( |
131 | | - self._client, self._config, self._serialize, self._deserialize) |
| 125 | + self._client, self._config, self._serialize, self._deserialize |
| 126 | + ) |
| 127 | + self.script_packages = ScriptPackagesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 128 | + self.script_cmdlets = ScriptCmdletsOperations(self._client, self._config, self._serialize, self._deserialize) |
132 | 129 | self.script_executions = ScriptExecutionsOperations( |
133 | | - self._client, self._config, self._serialize, self._deserialize) |
| 130 | + self._client, self._config, self._serialize, self._deserialize |
| 131 | + ) |
134 | 132 |
|
135 | | - def _send_request(self, http_request, **kwargs): |
136 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 133 | + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
137 | 134 | """Runs the network request through the client's chained policies. |
138 | 135 |
|
139 | | - :param http_request: The network request you want to make. Required. |
140 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
141 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 136 | + >>> from azure.core.rest import HttpRequest |
| 137 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 138 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 139 | + >>> response = client._send_request(request) |
| 140 | + <HttpResponse: 200 OK> |
| 141 | +
|
| 142 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 143 | +
|
| 144 | + :param request: The network request you want to make. Required. |
| 145 | + :type request: ~azure.core.rest.HttpRequest |
| 146 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
142 | 147 | :return: The response of your network call. Does not do error handling on your response. |
143 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 148 | + :rtype: ~azure.core.rest.HttpResponse |
144 | 149 | """ |
145 | | - path_format_arguments = { |
146 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), |
147 | | - } |
148 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
149 | | - stream = kwargs.pop("stream", True) |
150 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
151 | | - return pipeline_response.http_response |
| 150 | + |
| 151 | + request_copy = deepcopy(request) |
| 152 | + request_copy.url = self._client.format_url(request_copy.url) |
| 153 | + return self._client.send_request(request_copy, **kwargs) |
152 | 154 |
|
153 | 155 | def close(self): |
154 | 156 | # type: () -> None |
|
0 commit comments