|
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 |
|
11 | | -from azure.mgmt.core import ARMPipelineClient |
12 | 12 | from msrest import Deserializer, Serializer |
13 | 13 |
|
14 | | -if TYPE_CHECKING: |
15 | | - # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | | - from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
| 14 | +from azure.core.rest import HttpRequest, HttpResponse |
| 15 | +from azure.mgmt.core import ARMPipelineClient |
20 | 16 |
|
21 | | -from ._configuration import ChaosManagementClientConfiguration |
22 | | -from .operations import CapabilitiesOperations |
23 | | -from .operations import ExperimentsOperations |
24 | | -from .operations import Operations |
25 | | -from .operations import TargetsOperations |
26 | | -from .operations import TargetTypesOperations |
27 | | -from .operations import CapabilityTypesOperations |
28 | 17 | from . import models |
| 18 | +from ._configuration import ChaosManagementClientConfiguration |
| 19 | +from .operations import CapabilitiesOperations, CapabilityTypesOperations, ExperimentsOperations, Operations, TargetTypesOperations, TargetsOperations |
29 | 20 |
|
| 21 | +if TYPE_CHECKING: |
| 22 | + # pylint: disable=unused-import,ungrouped-imports |
| 23 | + from azure.core.credentials import TokenCredential |
30 | 24 |
|
31 | | -class ChaosManagementClient(object): |
| 25 | +class ChaosManagementClient: |
32 | 26 | """Chaos Management Client. |
33 | 27 |
|
34 | 28 | :ivar capabilities: CapabilitiesOperations operations |
35 | | - :vartype capabilities: chaos_management_client.operations.CapabilitiesOperations |
| 29 | + :vartype capabilities: azure.mgmt.chaos.operations.CapabilitiesOperations |
36 | 30 | :ivar experiments: ExperimentsOperations operations |
37 | | - :vartype experiments: chaos_management_client.operations.ExperimentsOperations |
| 31 | + :vartype experiments: azure.mgmt.chaos.operations.ExperimentsOperations |
38 | 32 | :ivar operations: Operations operations |
39 | | - :vartype operations: chaos_management_client.operations.Operations |
| 33 | + :vartype operations: azure.mgmt.chaos.operations.Operations |
40 | 34 | :ivar targets: TargetsOperations operations |
41 | | - :vartype targets: chaos_management_client.operations.TargetsOperations |
| 35 | + :vartype targets: azure.mgmt.chaos.operations.TargetsOperations |
42 | 36 | :ivar target_types: TargetTypesOperations operations |
43 | | - :vartype target_types: chaos_management_client.operations.TargetTypesOperations |
| 37 | + :vartype target_types: azure.mgmt.chaos.operations.TargetTypesOperations |
44 | 38 | :ivar capability_types: CapabilityTypesOperations operations |
45 | | - :vartype capability_types: chaos_management_client.operations.CapabilityTypesOperations |
| 39 | + :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations |
46 | 40 | :param credential: Credential needed for the client to connect to Azure. |
47 | 41 | :type credential: ~azure.core.credentials.TokenCredential |
48 | 42 | :param subscription_id: GUID that represents an Azure subscription ID. |
49 | 43 | :type subscription_id: str |
50 | | - :param str base_url: Service URL |
51 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 44 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 45 | + :type base_url: str |
| 46 | + :keyword api_version: Api Version. Default value is "2021-09-15-preview". Note that overriding |
| 47 | + this default value may result in unsupported behavior. |
| 48 | + :paramtype api_version: str |
| 49 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 50 | + Retry-After header is present. |
52 | 51 | """ |
53 | 52 |
|
54 | 53 | def __init__( |
55 | 54 | self, |
56 | | - credential, # type: "TokenCredential" |
57 | | - subscription_id, # type: str |
58 | | - base_url=None, # type: Optional[str] |
59 | | - **kwargs # type: Any |
60 | | - ): |
61 | | - # type: (...) -> None |
62 | | - if not base_url: |
63 | | - base_url = 'https://management.azure.com' |
64 | | - self._config = ChaosManagementClientConfiguration(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 = ChaosManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
65 | 61 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
66 | 62 |
|
67 | 63 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
68 | 64 | self._serialize = Serializer(client_models) |
69 | | - self._serialize.client_side_validation = False |
70 | 65 | self._deserialize = Deserializer(client_models) |
| 66 | + self._serialize.client_side_validation = False |
| 67 | + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 69 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 70 | + self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 71 | + self.target_types = TargetTypesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 72 | + self.capability_types = CapabilityTypesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 73 | + |
71 | 74 |
|
72 | | - self.capabilities = CapabilitiesOperations( |
73 | | - self._client, self._config, self._serialize, self._deserialize) |
74 | | - self.experiments = ExperimentsOperations( |
75 | | - self._client, self._config, self._serialize, self._deserialize) |
76 | | - self.operations = Operations( |
77 | | - self._client, self._config, self._serialize, self._deserialize) |
78 | | - self.targets = TargetsOperations( |
79 | | - self._client, self._config, self._serialize, self._deserialize) |
80 | | - self.target_types = TargetTypesOperations( |
81 | | - self._client, self._config, self._serialize, self._deserialize) |
82 | | - self.capability_types = CapabilityTypesOperations( |
83 | | - self._client, self._config, self._serialize, self._deserialize) |
84 | | - |
85 | | - def _send_request(self, http_request, **kwargs): |
86 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 75 | + def _send_request( |
| 76 | + self, |
| 77 | + request: HttpRequest, |
| 78 | + **kwargs: Any |
| 79 | + ) -> HttpResponse: |
87 | 80 | """Runs the network request through the client's chained policies. |
88 | 81 |
|
89 | | - :param http_request: The network request you want to make. Required. |
90 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
91 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 82 | + >>> from azure.core.rest import HttpRequest |
| 83 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 84 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 85 | + >>> response = client._send_request(request) |
| 86 | + <HttpResponse: 200 OK> |
| 87 | +
|
| 88 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 89 | +
|
| 90 | + :param request: The network request you want to make. Required. |
| 91 | + :type request: ~azure.core.rest.HttpRequest |
| 92 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
92 | 93 | :return: The response of your network call. Does not do error handling on your response. |
93 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 94 | + :rtype: ~azure.core.rest.HttpResponse |
94 | 95 | """ |
95 | | - path_format_arguments = { |
96 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), |
97 | | - } |
98 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
99 | | - stream = kwargs.pop("stream", True) |
100 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
101 | | - return pipeline_response.http_response |
| 96 | + |
| 97 | + request_copy = deepcopy(request) |
| 98 | + request_copy.url = self._client.format_url(request_copy.url) |
| 99 | + return self._client.send_request(request_copy, **kwargs) |
102 | 100 |
|
103 | 101 | def close(self): |
104 | 102 | # type: () -> None |
|
0 commit comments