88
99from copy import deepcopy
1010from typing import Any , TYPE_CHECKING
11+ from typing_extensions import Self
1112
13+ from azure .core .pipeline import policies
1214from azure .core .rest import HttpRequest , HttpResponse
1315from azure .mgmt .core import ARMPipelineClient
16+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
1417
1518from . import models as _models
1619from ._configuration import AstroMgmtClientConfiguration
@@ -35,7 +38,7 @@ class AstroMgmtClient: # pylint: disable=client-accepts-api-version-keyword
3538 :type subscription_id: str
3639 :param base_url: Service URL. Default value is "https://management.azure.com".
3740 :type base_url: str
38- :keyword api_version: Api Version. Default value is "2023 -08-01 ". Note that overriding this
41+ :keyword api_version: Api Version. Default value is "2024 -08-27 ". Note that overriding this
3942 default value may result in unsupported behavior.
4043 :paramtype api_version: str
4144 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -50,7 +53,25 @@ def __init__(
5053 ** kwargs : Any
5154 ) -> None :
5255 self ._config = AstroMgmtClientConfiguration (credential = credential , subscription_id = subscription_id , ** kwargs )
53- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
56+ _policies = kwargs .pop ("policies" , None )
57+ if _policies is None :
58+ _policies = [
59+ policies .RequestIdPolicy (** kwargs ),
60+ self ._config .headers_policy ,
61+ self ._config .user_agent_policy ,
62+ self ._config .proxy_policy ,
63+ policies .ContentDecodePolicy (** kwargs ),
64+ ARMAutoResourceProviderRegistrationPolicy (),
65+ self ._config .redirect_policy ,
66+ self ._config .retry_policy ,
67+ self ._config .authentication_policy ,
68+ self ._config .custom_hook_policy ,
69+ self ._config .logging_policy ,
70+ policies .DistributedTracingPolicy (** kwargs ),
71+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
72+ self ._config .http_logging_policy ,
73+ ]
74+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
5475
5576 client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
5677 self ._serialize = Serializer (client_models )
@@ -59,7 +80,7 @@ def __init__(
5980 self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
6081 self .organizations = OrganizationsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
6182
62- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
83+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
6384 """Runs the network request through the client's chained policies.
6485
6586 >>> from azure.core.rest import HttpRequest
@@ -79,12 +100,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
79100
80101 request_copy = deepcopy (request )
81102 request_copy .url = self ._client .format_url (request_copy .url )
82- return self ._client .send_request (request_copy , ** kwargs )
103+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
83104
84105 def close (self ) -> None :
85106 self ._client .close ()
86107
87- def __enter__ (self ) -> "AstroMgmtClient" :
108+ def __enter__ (self ) -> Self :
88109 self ._client .__enter__ ()
89110 return self
90111
0 commit comments