|
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 GuestConfigurationClientConfiguration |
| 17 | +from ._serialization import Deserializer, Serializer |
| 18 | +from .operations import ( |
| 19 | + GuestConfigurationAssignmentReportsOperations, |
| 20 | + GuestConfigurationAssignmentReportsVMSSOperations, |
| 21 | + GuestConfigurationAssignmentsOperations, |
| 22 | + GuestConfigurationAssignmentsVMSSOperations, |
| 23 | + GuestConfigurationHCRPAssignmentReportsOperations, |
| 24 | + GuestConfigurationHCRPAssignmentsOperations, |
| 25 | + Operations, |
| 26 | +) |
13 | 27 |
|
14 | 28 | if TYPE_CHECKING: |
15 | 29 | # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | 30 | 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 | 31 |
|
29 | 32 |
|
30 | | -class GuestConfigurationClient(object): |
| 33 | +class GuestConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes |
31 | 34 | """Guest Configuration Client. |
32 | 35 |
|
33 | 36 | :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 |
| 37 | + :vartype guest_configuration_assignments: |
| 38 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsOperations |
| 39 | + :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations |
| 40 | + operations |
| 41 | + :vartype guest_configuration_assignment_reports: |
| 42 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsOperations |
| 43 | + :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations |
| 44 | + operations |
| 45 | + :vartype guest_configuration_hcrp_assignments: |
| 46 | + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentsOperations |
| 47 | + :ivar guest_configuration_hcrp_assignment_reports: |
| 48 | + GuestConfigurationHCRPAssignmentReportsOperations operations |
| 49 | + :vartype guest_configuration_hcrp_assignment_reports: |
| 50 | + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentReportsOperations |
| 51 | + :ivar guest_configuration_assignments_vmss: GuestConfigurationAssignmentsVMSSOperations |
| 52 | + operations |
| 53 | + :vartype guest_configuration_assignments_vmss: |
| 54 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsVMSSOperations |
| 55 | + :ivar guest_configuration_assignment_reports_vmss: |
| 56 | + GuestConfigurationAssignmentReportsVMSSOperations operations |
| 57 | + :vartype guest_configuration_assignment_reports_vmss: |
| 58 | + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsVMSSOperations |
41 | 59 | :ivar operations: Operations operations |
42 | 60 | :vartype operations: azure.mgmt.guestconfig.operations.Operations |
43 | | - :param credential: Credential needed for the client to connect to Azure. |
| 61 | + :param credential: Credential needed for the client to connect to Azure. Required. |
44 | 62 | :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. |
| 63 | + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. |
| 64 | + The subscription ID forms part of the URI for every service call. Required. |
46 | 65 | :type subscription_id: str |
47 | | - :param str base_url: Service URL |
| 66 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 67 | + :type base_url: str |
| 68 | + :keyword api_version: Api Version. Default value is "2022-01-25". Note that overriding this |
| 69 | + default value may result in unsupported behavior. |
| 70 | + :paramtype api_version: str |
48 | 71 | """ |
49 | 72 |
|
50 | 73 | def __init__( |
51 | 74 | 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) |
| 75 | + credential: "TokenCredential", |
| 76 | + subscription_id: str, |
| 77 | + base_url: str = "https://management.azure.com", |
| 78 | + **kwargs: Any |
| 79 | + ) -> None: |
| 80 | + self._config = GuestConfigurationClientConfiguration( |
| 81 | + credential=credential, subscription_id=subscription_id, **kwargs |
| 82 | + ) |
61 | 83 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
62 | 84 |
|
63 | 85 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
64 | 86 | self._serialize = Serializer(client_models) |
65 | | - self._serialize.client_side_validation = False |
66 | 87 | self._deserialize = Deserializer(client_models) |
67 | | - |
| 88 | + self._serialize.client_side_validation = False |
68 | 89 | self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( |
69 | | - self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self._client, self._config, self._serialize, self._deserialize |
| 91 | + ) |
70 | 92 | self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( |
71 | | - self._client, self._config, self._serialize, self._deserialize) |
| 93 | + self._client, self._config, self._serialize, self._deserialize |
| 94 | + ) |
72 | 95 | self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( |
73 | | - self._client, self._config, self._serialize, self._deserialize) |
| 96 | + self._client, self._config, self._serialize, self._deserialize |
| 97 | + ) |
74 | 98 | 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 |
| 99 | + self._client, self._config, self._serialize, self._deserialize |
| 100 | + ) |
| 101 | + self.guest_configuration_assignments_vmss = GuestConfigurationAssignmentsVMSSOperations( |
| 102 | + self._client, self._config, self._serialize, self._deserialize |
| 103 | + ) |
| 104 | + self.guest_configuration_assignment_reports_vmss = GuestConfigurationAssignmentReportsVMSSOperations( |
| 105 | + self._client, self._config, self._serialize, self._deserialize |
| 106 | + ) |
| 107 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 108 | + |
| 109 | + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
81 | 110 | """Runs the network request through the client's chained policies. |
82 | 111 |
|
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. |
| 112 | + >>> from azure.core.rest import HttpRequest |
| 113 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 114 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 115 | + >>> response = client._send_request(request) |
| 116 | + <HttpResponse: 200 OK> |
| 117 | +
|
| 118 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 119 | +
|
| 120 | + :param request: The network request you want to make. Required. |
| 121 | + :type request: ~azure.core.rest.HttpRequest |
| 122 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
86 | 123 | :return: The response of your network call. Does not do error handling on your response. |
87 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 124 | + :rtype: ~azure.core.rest.HttpResponse |
88 | 125 | """ |
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 |
| 126 | + |
| 127 | + request_copy = deepcopy(request) |
| 128 | + request_copy.url = self._client.format_url(request_copy.url) |
| 129 | + return self._client.send_request(request_copy, **kwargs) |
96 | 130 |
|
97 | 131 | def close(self): |
98 | 132 | # type: () -> None |
|
0 commit comments