|
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 AzureArcDataManagementClientConfiguration |
| 18 | +from .operations import ActiveDirectoryConnectorsOperations, DataControllersOperations, Operations, PostgresInstancesOperations, SqlManagedInstancesOperations, SqlServerInstancesOperations |
| 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 AzureArcDataManagementClientConfiguration |
22 |
| -from .operations import Operations |
23 |
| -from .operations import SqlManagedInstancesOperations |
24 |
| -from .operations import SqlServerInstancesOperations |
25 |
| -from .operations import DataControllersOperations |
26 |
| -from . import models |
27 |
| - |
28 | 23 |
|
29 |
| -class AzureArcDataManagementClient(object): |
| 24 | +class AzureArcDataManagementClient: |
30 | 25 | """The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data Services on Azure Arc Resources.
|
31 | 26 |
|
32 | 27 | :ivar operations: Operations operations
|
33 |
| - :vartype operations: azure_arc_data_management_client.operations.Operations |
| 28 | + :vartype operations: azure.mgmt.azurearcdata.operations.Operations |
34 | 29 | :ivar sql_managed_instances: SqlManagedInstancesOperations operations
|
35 |
| - :vartype sql_managed_instances: azure_arc_data_management_client.operations.SqlManagedInstancesOperations |
| 30 | + :vartype sql_managed_instances: |
| 31 | + azure.mgmt.azurearcdata.operations.SqlManagedInstancesOperations |
36 | 32 | :ivar sql_server_instances: SqlServerInstancesOperations operations
|
37 |
| - :vartype sql_server_instances: azure_arc_data_management_client.operations.SqlServerInstancesOperations |
| 33 | + :vartype sql_server_instances: azure.mgmt.azurearcdata.operations.SqlServerInstancesOperations |
38 | 34 | :ivar data_controllers: DataControllersOperations operations
|
39 |
| - :vartype data_controllers: azure_arc_data_management_client.operations.DataControllersOperations |
| 35 | + :vartype data_controllers: azure.mgmt.azurearcdata.operations.DataControllersOperations |
| 36 | + :ivar active_directory_connectors: ActiveDirectoryConnectorsOperations operations |
| 37 | + :vartype active_directory_connectors: |
| 38 | + azure.mgmt.azurearcdata.operations.ActiveDirectoryConnectorsOperations |
| 39 | + :ivar postgres_instances: PostgresInstancesOperations operations |
| 40 | + :vartype postgres_instances: azure.mgmt.azurearcdata.operations.PostgresInstancesOperations |
40 | 41 | :param credential: Credential needed for the client to connect to Azure.
|
41 | 42 | :type credential: ~azure.core.credentials.TokenCredential
|
42 | 43 | :param subscription_id: The ID of the Azure subscription.
|
43 | 44 | :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. |
| 45 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 46 | + :type base_url: str |
| 47 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 48 | + Retry-After header is present. |
46 | 49 | """
|
47 | 50 |
|
48 | 51 | def __init__(
|
49 | 52 | 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 = AzureArcDataManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 53 | + credential: "TokenCredential", |
| 54 | + subscription_id: str, |
| 55 | + base_url: str = "https://management.azure.com", |
| 56 | + **kwargs: Any |
| 57 | + ) -> None: |
| 58 | + self._config = AzureArcDataManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
59 | 59 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
|
60 | 60 |
|
61 | 61 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
|
62 | 62 | self._serialize = Serializer(client_models)
|
63 |
| - self._serialize.client_side_validation = False |
64 | 63 | self._deserialize = Deserializer(client_models)
|
| 64 | + self._serialize.client_side_validation = False |
| 65 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 66 | + self.sql_managed_instances = SqlManagedInstancesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 67 | + self.sql_server_instances = SqlServerInstancesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.data_controllers = DataControllersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 69 | + self.active_directory_connectors = ActiveDirectoryConnectorsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 70 | + self.postgres_instances = PostgresInstancesOperations(self._client, self._config, self._serialize, self._deserialize) |
65 | 71 |
|
66 |
| - self.operations = Operations( |
67 |
| - self._client, self._config, self._serialize, self._deserialize) |
68 |
| - self.sql_managed_instances = SqlManagedInstancesOperations( |
69 |
| - self._client, self._config, self._serialize, self._deserialize) |
70 |
| - self.sql_server_instances = SqlServerInstancesOperations( |
71 |
| - self._client, self._config, self._serialize, self._deserialize) |
72 |
| - self.data_controllers = DataControllersOperations( |
73 |
| - self._client, self._config, self._serialize, self._deserialize) |
74 |
| - |
75 |
| - def _send_request(self, http_request, **kwargs): |
76 |
| - # type: (HttpRequest, Any) -> HttpResponse |
| 72 | + |
| 73 | + def _send_request( |
| 74 | + self, |
| 75 | + request, # type: HttpRequest |
| 76 | + **kwargs: Any |
| 77 | + ) -> HttpResponse: |
77 | 78 | """Runs the network request through the client's chained policies.
|
78 | 79 |
|
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. |
| 80 | + >>> from azure.core.rest import HttpRequest |
| 81 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 82 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 83 | + >>> response = client._send_request(request) |
| 84 | + <HttpResponse: 200 OK> |
| 85 | +
|
| 86 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 87 | +
|
| 88 | + :param request: The network request you want to make. Required. |
| 89 | + :type request: ~azure.core.rest.HttpRequest |
| 90 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
82 | 91 | :return: The response of your network call. Does not do error handling on your response.
|
83 |
| - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 92 | + :rtype: ~azure.core.rest.HttpResponse |
84 | 93 | """
|
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 |
| 94 | + |
| 95 | + request_copy = deepcopy(request) |
| 96 | + request_copy.url = self._client.format_url(request_copy.url) |
| 97 | + return self._client.send_request(request_copy, **kwargs) |
92 | 98 |
|
93 | 99 | def close(self):
|
94 | 100 | # type: () -> None
|
|
0 commit comments