77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import Any , TYPE_CHECKING
10+ from typing import Any , Optional , TYPE_CHECKING , cast
11+ from typing_extensions import Self
1112
13+ from azure .core .pipeline import policies
1214from azure .core .rest import HttpRequest , HttpResponse
15+ from azure .core .settings import settings
1316from azure .mgmt .core import ARMPipelineClient
17+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18+ from azure .mgmt .core .tools import get_arm_endpoints
1419
1520from . import models as _models
1621from ._configuration import ChaosManagementClientConfiguration
17- from ._serialization import Deserializer , Serializer
22+ from ._utils . serialization import Deserializer , Serializer
1823from .operations import (
1924 CapabilitiesOperations ,
2025 CapabilityTypesOperations ,
2631)
2732
2833if TYPE_CHECKING :
29- # pylint: disable=unused-import,ungrouped-imports
3034 from azure .core .credentials import TokenCredential
3135
3236
33- class ChaosManagementClient : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
37+ class ChaosManagementClient : # pylint: disable=too-many-instance-attributes
3438 """Chaos Management Client.
3539
36- :ivar capabilities: CapabilitiesOperations operations
37- :vartype capabilities: azure.mgmt.chaos.operations.CapabilitiesOperations
38- :ivar capability_types: CapabilityTypesOperations operations
39- :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations
40+ :ivar operations: Operations operations
41+ :vartype operations: azure.mgmt.chaos.operations.Operations
4042 :ivar experiments: ExperimentsOperations operations
4143 :vartype experiments: azure.mgmt.chaos.operations.ExperimentsOperations
4244 :ivar operation_statuses: OperationStatusesOperations operations
4345 :vartype operation_statuses: azure.mgmt.chaos.operations.OperationStatusesOperations
44- :ivar operations: Operations operations
45- :vartype operations: azure.mgmt.chaos.operations.Operations
4646 :ivar target_types: TargetTypesOperations operations
4747 :vartype target_types: azure.mgmt.chaos.operations.TargetTypesOperations
48+ :ivar capability_types: CapabilityTypesOperations operations
49+ :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations
4850 :ivar targets: TargetsOperations operations
4951 :vartype targets: azure.mgmt.chaos.operations.TargetsOperations
52+ :ivar capabilities: CapabilitiesOperations operations
53+ :vartype capabilities: azure.mgmt.chaos.operations.CapabilitiesOperations
5054 :param credential: Credential needed for the client to connect to Azure. Required.
5155 :type credential: ~azure.core.credentials.TokenCredential
52- :param subscription_id: GUID that represents an Azure subscription ID . Required.
56+ :param subscription_id: The ID of the target subscription. The value must be an UUID . Required.
5357 :type subscription_id: str
54- :param base_url: Service URL. Default value is "https://management.azure.com" .
58+ :param base_url: Service URL. Default value is None .
5559 :type base_url: str
56- :keyword api_version: Api Version. Default value is "2024 -01-01". Note that overriding this
60+ :keyword api_version: Api Version. Default value is "2025 -01-01". Note that overriding this
5761 default value may result in unsupported behavior.
5862 :paramtype api_version: str
5963 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
6064 Retry-After header is present.
6165 """
6266
6367 def __init__ (
64- self ,
65- credential : "TokenCredential" ,
66- subscription_id : str ,
67- base_url : str = "https://management.azure.com" ,
68- ** kwargs : Any
68+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
6969 ) -> None :
70+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
71+ _endpoints = get_arm_endpoints (_cloud )
72+ if not base_url :
73+ base_url = _endpoints ["resource_manager" ]
74+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
7075 self ._config = ChaosManagementClientConfiguration (
71- credential = credential , subscription_id = subscription_id , ** kwargs
76+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
7277 )
73- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
78+
79+ _policies = kwargs .pop ("policies" , None )
80+ if _policies is None :
81+ _policies = [
82+ policies .RequestIdPolicy (** kwargs ),
83+ self ._config .headers_policy ,
84+ self ._config .user_agent_policy ,
85+ self ._config .proxy_policy ,
86+ policies .ContentDecodePolicy (** kwargs ),
87+ ARMAutoResourceProviderRegistrationPolicy (),
88+ self ._config .redirect_policy ,
89+ self ._config .retry_policy ,
90+ self ._config .authentication_policy ,
91+ self ._config .custom_hook_policy ,
92+ self ._config .logging_policy ,
93+ policies .DistributedTracingPolicy (** kwargs ),
94+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
95+ self ._config .http_logging_policy ,
96+ ]
97+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
7498
7599 client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
76100 self ._serialize = Serializer (client_models )
77101 self ._deserialize = Deserializer (client_models )
78102 self ._serialize .client_side_validation = False
79- self .capabilities = CapabilitiesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
80- self .capability_types = CapabilityTypesOperations (
81- self ._client , self ._config , self ._serialize , self ._deserialize
82- )
103+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
83104 self .experiments = ExperimentsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
84105 self .operation_statuses = OperationStatusesOperations (
85106 self ._client , self ._config , self ._serialize , self ._deserialize
86107 )
87- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
88108 self .target_types = TargetTypesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
109+ self .capability_types = CapabilityTypesOperations (
110+ self ._client , self ._config , self ._serialize , self ._deserialize
111+ )
89112 self .targets = TargetsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
113+ self .capabilities = CapabilitiesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
90114
91- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
115+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
92116 """Runs the network request through the client's chained policies.
93117
94118 >>> from azure.core.rest import HttpRequest
@@ -108,12 +132,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
108132
109133 request_copy = deepcopy (request )
110134 request_copy .url = self ._client .format_url (request_copy .url )
111- return self ._client .send_request (request_copy , ** kwargs )
135+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
112136
113137 def close (self ) -> None :
114138 self ._client .close ()
115139
116- def __enter__ (self ) -> "ChaosManagementClient" :
140+ def __enter__ (self ) -> Self :
117141 self ._client .__enter__ ()
118142 return self
119143
0 commit comments