|
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, Optional, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient
|
12 | 14 | from msrest import Deserializer, Serializer
|
13 | 15 |
|
| 16 | +from . import models |
| 17 | +from ._configuration import ResourceMoverServiceAPIConfiguration |
| 18 | +from .operations import MoveCollectionsOperations, MoveResourcesOperations, OperationsDiscoveryOperations, UnresolvedDependenciesOperations |
| 19 | + |
14 | 20 | if TYPE_CHECKING:
|
15 | 21 | # pylint: disable=unused-import,ungrouped-imports
|
16 |
| - from typing import Any, Optional |
17 |
| - |
18 | 22 | from azure.core.credentials import TokenCredential
|
19 |
| - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 |
| - |
21 |
| -from ._configuration import ResourceMoverServiceAPIConfiguration |
22 |
| -from .operations import MoveCollectionsOperations |
23 |
| -from .operations import MoveResourcesOperations |
24 |
| -from .operations import UnresolvedDependenciesOperations |
25 |
| -from .operations import OperationsDiscoveryOperations |
26 |
| -from . import models |
27 |
| - |
28 | 23 |
|
29 |
| -class ResourceMoverServiceAPI(object): |
| 24 | +class ResourceMoverServiceAPI: |
30 | 25 | """A first party Azure service orchestrating the move of Azure resources from one Azure region to another or between zones within a region.
|
31 | 26 |
|
32 | 27 | :ivar move_collections: MoveCollectionsOperations operations
|
33 |
| - :vartype move_collections: resource_mover_service_api.operations.MoveCollectionsOperations |
| 28 | + :vartype move_collections: azure.mgmt.resourcemover.operations.MoveCollectionsOperations |
34 | 29 | :ivar move_resources: MoveResourcesOperations operations
|
35 |
| - :vartype move_resources: resource_mover_service_api.operations.MoveResourcesOperations |
| 30 | + :vartype move_resources: azure.mgmt.resourcemover.operations.MoveResourcesOperations |
36 | 31 | :ivar unresolved_dependencies: UnresolvedDependenciesOperations operations
|
37 |
| - :vartype unresolved_dependencies: resource_mover_service_api.operations.UnresolvedDependenciesOperations |
| 32 | + :vartype unresolved_dependencies: |
| 33 | + azure.mgmt.resourcemover.operations.UnresolvedDependenciesOperations |
38 | 34 | :ivar operations_discovery: OperationsDiscoveryOperations operations
|
39 |
| - :vartype operations_discovery: resource_mover_service_api.operations.OperationsDiscoveryOperations |
| 35 | + :vartype operations_discovery: |
| 36 | + azure.mgmt.resourcemover.operations.OperationsDiscoveryOperations |
40 | 37 | :param credential: Credential needed for the client to connect to Azure.
|
41 | 38 | :type credential: ~azure.core.credentials.TokenCredential
|
42 | 39 | :param subscription_id: The Subscription ID.
|
43 | 40 | :type subscription_id: str
|
44 |
| - :param str base_url: Service URL |
45 |
| - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 41 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 42 | + :type base_url: str |
| 43 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 44 | + Retry-After header is present. |
46 | 45 | """
|
47 | 46 |
|
48 | 47 | def __init__(
|
49 | 48 | self,
|
50 |
| - credential, # type: "TokenCredential" |
51 |
| - subscription_id, # type: str |
52 |
| - base_url=None, # type: Optional[str] |
53 |
| - **kwargs # type: Any |
54 |
| - ): |
55 |
| - # type: (...) -> None |
56 |
| - if not base_url: |
57 |
| - base_url = 'https://management.azure.com' |
58 |
| - self._config = ResourceMoverServiceAPIConfiguration(credential, subscription_id, **kwargs) |
| 49 | + credential: "TokenCredential", |
| 50 | + subscription_id: str, |
| 51 | + base_url: str = "https://management.azure.com", |
| 52 | + **kwargs: Any |
| 53 | + ) -> None: |
| 54 | + self._config = ResourceMoverServiceAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
59 | 55 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
|
60 | 56 |
|
61 | 57 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
|
62 | 58 | self._serialize = Serializer(client_models)
|
63 |
| - self._serialize.client_side_validation = False |
64 | 59 | self._deserialize = Deserializer(client_models)
|
| 60 | + self._serialize.client_side_validation = False |
| 61 | + self.move_collections = MoveCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 62 | + self.move_resources = MoveResourcesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 63 | + self.unresolved_dependencies = UnresolvedDependenciesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 64 | + self.operations_discovery = OperationsDiscoveryOperations(self._client, self._config, self._serialize, self._deserialize) |
65 | 65 |
|
66 |
| - self.move_collections = MoveCollectionsOperations( |
67 |
| - self._client, self._config, self._serialize, self._deserialize) |
68 |
| - self.move_resources = MoveResourcesOperations( |
69 |
| - self._client, self._config, self._serialize, self._deserialize) |
70 |
| - self.unresolved_dependencies = UnresolvedDependenciesOperations( |
71 |
| - self._client, self._config, self._serialize, self._deserialize) |
72 |
| - self.operations_discovery = OperationsDiscoveryOperations( |
73 |
| - self._client, self._config, self._serialize, self._deserialize) |
74 |
| - |
75 |
| - def _send_request(self, http_request, **kwargs): |
76 |
| - # type: (HttpRequest, Any) -> HttpResponse |
| 66 | + |
| 67 | + def _send_request( |
| 68 | + self, |
| 69 | + request, # type: HttpRequest |
| 70 | + **kwargs: Any |
| 71 | + ) -> HttpResponse: |
77 | 72 | """Runs the network request through the client's chained policies.
|
78 | 73 |
|
79 |
| - :param http_request: The network request you want to make. Required. |
80 |
| - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
81 |
| - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 74 | + >>> from azure.core.rest import HttpRequest |
| 75 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 76 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 77 | + >>> response = client._send_request(request) |
| 78 | + <HttpResponse: 200 OK> |
| 79 | +
|
| 80 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 81 | +
|
| 82 | + :param request: The network request you want to make. Required. |
| 83 | + :type request: ~azure.core.rest.HttpRequest |
| 84 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
82 | 85 | :return: The response of your network call. Does not do error handling on your response.
|
83 |
| - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 86 | + :rtype: ~azure.core.rest.HttpResponse |
84 | 87 | """
|
85 |
| - path_format_arguments = { |
86 |
| - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
87 |
| - } |
88 |
| - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
89 |
| - stream = kwargs.pop("stream", True) |
90 |
| - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
91 |
| - return pipeline_response.http_response |
| 88 | + |
| 89 | + request_copy = deepcopy(request) |
| 90 | + request_copy.url = self._client.format_url(request_copy.url) |
| 91 | + return self._client.send_request(request_copy, **kwargs) |
92 | 92 |
|
93 | 93 | def close(self):
|
94 | 94 | # type: () -> None
|
|
0 commit comments