|
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 AutomanageClientConfiguration |
| 18 | +from .operations import BestPracticesOperations, BestPracticesVersionsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfilesOperations, ConfigurationProfilesVersionsOperations, Operations, ReportsOperations, ServicePrincipalsOperations |
| 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 | 23 |
|
20 | | -from ._configuration import AutomanageClientConfiguration |
21 | | -from .operations import AccountsOperations |
22 | | -from .operations import ConfigurationProfileAssignmentsOperations |
23 | | -from .operations import ConfigurationProfilePreferencesOperations |
24 | | -from .operations import Operations |
25 | | -from . import models |
26 | | - |
27 | | - |
28 | | -class AutomanageClient(object): |
| 24 | +class AutomanageClient: |
29 | 25 | """Automanage Client. |
30 | 26 |
|
31 | | - :ivar accounts: AccountsOperations operations |
32 | | - :vartype accounts: automanage_client.operations.AccountsOperations |
| 27 | + :ivar best_practices: BestPracticesOperations operations |
| 28 | + :vartype best_practices: automanage_client.operations.BestPracticesOperations |
| 29 | + :ivar best_practices_versions: BestPracticesVersionsOperations operations |
| 30 | + :vartype best_practices_versions: automanage_client.operations.BestPracticesVersionsOperations |
| 31 | + :ivar configuration_profiles: ConfigurationProfilesOperations operations |
| 32 | + :vartype configuration_profiles: automanage_client.operations.ConfigurationProfilesOperations |
| 33 | + :ivar configuration_profiles_versions: ConfigurationProfilesVersionsOperations operations |
| 34 | + :vartype configuration_profiles_versions: |
| 35 | + automanage_client.operations.ConfigurationProfilesVersionsOperations |
33 | 36 | :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations |
34 | | - :vartype configuration_profile_assignments: automanage_client.operations.ConfigurationProfileAssignmentsOperations |
35 | | - :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations |
36 | | - :vartype configuration_profile_preferences: automanage_client.operations.ConfigurationProfilePreferencesOperations |
| 37 | + :vartype configuration_profile_assignments: |
| 38 | + automanage_client.operations.ConfigurationProfileAssignmentsOperations |
37 | 39 | :ivar operations: Operations operations |
38 | 40 | :vartype operations: automanage_client.operations.Operations |
| 41 | + :ivar reports: ReportsOperations operations |
| 42 | + :vartype reports: automanage_client.operations.ReportsOperations |
| 43 | + :ivar service_principals: ServicePrincipalsOperations operations |
| 44 | + :vartype service_principals: automanage_client.operations.ServicePrincipalsOperations |
39 | 45 | :param credential: Credential needed for the client to connect to Azure. |
40 | 46 | :type credential: ~azure.core.credentials.TokenCredential |
41 | 47 | :param subscription_id: The ID of the target subscription. |
42 | 48 | :type subscription_id: str |
43 | | - :param str base_url: Service URL |
44 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 49 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 50 | + :type base_url: str |
45 | 51 | """ |
46 | 52 |
|
47 | 53 | def __init__( |
48 | 54 | self, |
49 | | - credential, # type: "TokenCredential" |
50 | | - subscription_id, # type: str |
51 | | - base_url=None, # type: Optional[str] |
52 | | - **kwargs # type: Any |
53 | | - ): |
54 | | - # type: (...) -> None |
55 | | - if not base_url: |
56 | | - base_url = 'https://management.azure.com' |
57 | | - self._config = AutomanageClientConfiguration(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 = AutomanageClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
58 | 61 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
59 | 62 |
|
60 | 63 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
61 | 64 | self._serialize = Serializer(client_models) |
62 | 65 | self._deserialize = Deserializer(client_models) |
| 66 | + self._serialize.client_side_validation = False |
| 67 | + self.best_practices = BestPracticesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.best_practices_versions = BestPracticesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 69 | + self.configuration_profiles = ConfigurationProfilesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 70 | + self.configuration_profiles_versions = ConfigurationProfilesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 71 | + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 72 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 73 | + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 74 | + self.service_principals = ServicePrincipalsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 75 | + |
| 76 | + |
| 77 | + def _send_request( |
| 78 | + self, |
| 79 | + request, # type: HttpRequest |
| 80 | + **kwargs: Any |
| 81 | + ) -> HttpResponse: |
| 82 | + """Runs the network request through the client's chained policies. |
| 83 | +
|
| 84 | + >>> from azure.core.rest import HttpRequest |
| 85 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 86 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 87 | + >>> response = client._send_request(request) |
| 88 | + <HttpResponse: 200 OK> |
| 89 | +
|
| 90 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 91 | +
|
| 92 | + :param request: The network request you want to make. Required. |
| 93 | + :type request: ~azure.core.rest.HttpRequest |
| 94 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 95 | + :return: The response of your network call. Does not do error handling on your response. |
| 96 | + :rtype: ~azure.core.rest.HttpResponse |
| 97 | + """ |
63 | 98 |
|
64 | | - self.accounts = AccountsOperations( |
65 | | - self._client, self._config, self._serialize, self._deserialize) |
66 | | - self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( |
67 | | - self._client, self._config, self._serialize, self._deserialize) |
68 | | - self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( |
69 | | - self._client, self._config, self._serialize, self._deserialize) |
70 | | - self.operations = Operations( |
71 | | - self._client, self._config, self._serialize, self._deserialize) |
| 99 | + request_copy = deepcopy(request) |
| 100 | + request_copy.url = self._client.format_url(request_copy.url) |
| 101 | + return self._client.send_request(request_copy, **kwargs) |
72 | 102 |
|
73 | 103 | def close(self): |
74 | 104 | # type: () -> None |
|
0 commit comments