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