|
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 GuestConfigurationClientConfiguration |
| 18 | +from .operations import GuestConfigurationAssignmentReportsOperations, GuestConfigurationAssignmentsOperations, GuestConfigurationHCRPAssignmentReportsOperations, GuestConfigurationHCRPAssignmentsOperations, Operations |
| 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 GuestConfigurationClientConfiguration |
22 | | -from .operations import GuestConfigurationAssignmentsOperations |
23 | | -from .operations import GuestConfigurationAssignmentReportsOperations |
24 | | -from .operations import GuestConfigurationHCRPAssignmentsOperations |
25 | | -from .operations import GuestConfigurationHCRPAssignmentReportsOperations |
26 | | -from .operations import Operations |
27 | | -from . import models |
28 | | - |
29 | 23 |
|
30 | | -class GuestConfigurationClient(object): |
| 24 | +class GuestConfigurationClient: |
31 | 25 | """Guest Configuration Client. |
32 | 26 |
|
33 | 27 | :ivar guest_configuration_assignments: GuestConfigurationAssignmentsOperations operations |
34 | | - :vartype guest_configuration_assignments: azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsOperations |
35 | | - :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations operations |
36 | | - :vartype guest_configuration_assignment_reports: azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsOperations |
37 | | - :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations operations |
38 | | - :vartype guest_configuration_hcrp_assignments: azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentsOperations |
39 | | - :ivar guest_configuration_hcrp_assignment_reports: GuestConfigurationHCRPAssignmentReportsOperations operations |
40 | | - :vartype guest_configuration_hcrp_assignment_reports: azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentReportsOperations |
| 28 | + :vartype guest_configuration_assignments: |
| 29 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsOperations |
| 30 | + :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations |
| 31 | + operations |
| 32 | + :vartype guest_configuration_assignment_reports: |
| 33 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsOperations |
| 34 | + :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations |
| 35 | + operations |
| 36 | + :vartype guest_configuration_hcrp_assignments: |
| 37 | + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentsOperations |
| 38 | + :ivar guest_configuration_hcrp_assignment_reports: |
| 39 | + GuestConfigurationHCRPAssignmentReportsOperations operations |
| 40 | + :vartype guest_configuration_hcrp_assignment_reports: |
| 41 | + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentReportsOperations |
41 | 42 | :ivar operations: Operations operations |
42 | 43 | :vartype operations: azure.mgmt.guestconfig.operations.Operations |
43 | 44 | :param credential: Credential needed for the client to connect to Azure. |
44 | 45 | :type credential: ~azure.core.credentials.TokenCredential |
45 | | - :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
| 46 | + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. |
| 47 | + The subscription ID forms part of the URI for every service call. |
46 | 48 | :type subscription_id: str |
47 | | - :param str base_url: Service URL |
| 49 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 50 | + :type base_url: str |
48 | 51 | """ |
49 | 52 |
|
50 | 53 | def __init__( |
51 | 54 | self, |
52 | | - credential, # type: "TokenCredential" |
53 | | - subscription_id, # type: str |
54 | | - base_url=None, # type: Optional[str] |
55 | | - **kwargs # type: Any |
56 | | - ): |
57 | | - # type: (...) -> None |
58 | | - if not base_url: |
59 | | - base_url = 'https://management.azure.com' |
60 | | - self._config = GuestConfigurationClientConfiguration(credential, subscription_id, **kwargs) |
| 55 | + credential: "TokenCredential", |
| 56 | + subscription_id: str, |
| 57 | + base_url: str = "https://management.azure.com", |
| 58 | + **kwargs: Any |
| 59 | + ) -> None: |
| 60 | + self._config = GuestConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
61 | 61 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
62 | 62 |
|
63 | 63 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
64 | 64 | self._serialize = Serializer(client_models) |
65 | | - self._serialize.client_side_validation = False |
66 | 65 | self._deserialize = Deserializer(client_models) |
| 66 | + self._serialize.client_side_validation = False |
| 67 | + self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 69 | + self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 70 | + self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 71 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
67 | 72 |
|
68 | | - self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( |
69 | | - self._client, self._config, self._serialize, self._deserialize) |
70 | | - self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( |
71 | | - self._client, self._config, self._serialize, self._deserialize) |
72 | | - self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( |
73 | | - self._client, self._config, self._serialize, self._deserialize) |
74 | | - self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations( |
75 | | - self._client, self._config, self._serialize, self._deserialize) |
76 | | - self.operations = Operations( |
77 | | - self._client, self._config, self._serialize, self._deserialize) |
78 | | - |
79 | | - def _send_request(self, http_request, **kwargs): |
80 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 73 | + |
| 74 | + def _send_request( |
| 75 | + self, |
| 76 | + request, # type: HttpRequest |
| 77 | + **kwargs: Any |
| 78 | + ) -> HttpResponse: |
81 | 79 | """Runs the network request through the client's chained policies. |
82 | 80 |
|
83 | | - :param http_request: The network request you want to make. Required. |
84 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
85 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 81 | + >>> from azure.core.rest import HttpRequest |
| 82 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 83 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 84 | + >>> response = client._send_request(request) |
| 85 | + <HttpResponse: 200 OK> |
| 86 | +
|
| 87 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 88 | +
|
| 89 | + :param request: The network request you want to make. Required. |
| 90 | + :type request: ~azure.core.rest.HttpRequest |
| 91 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
86 | 92 | :return: The response of your network call. Does not do error handling on your response. |
87 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 93 | + :rtype: ~azure.core.rest.HttpResponse |
88 | 94 | """ |
89 | | - path_format_arguments = { |
90 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
91 | | - } |
92 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
93 | | - stream = kwargs.pop("stream", True) |
94 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
95 | | - return pipeline_response.http_response |
| 95 | + |
| 96 | + request_copy = deepcopy(request) |
| 97 | + request_copy.url = self._client.format_url(request_copy.url) |
| 98 | + return self._client.send_request(request_copy, **kwargs) |
96 | 99 |
|
97 | 100 | def close(self): |
98 | 101 | # type: () -> None |
|
0 commit comments