9
9
from copy import deepcopy
10
10
from typing import Any , Awaitable , TYPE_CHECKING
11
11
12
+ from azure .core .pipeline import policies
12
13
from azure .core .rest import AsyncHttpResponse , HttpRequest
13
14
from azure .mgmt .core import AsyncARMPipelineClient
15
+ from azure .mgmt .core .policies import AsyncARMAutoResourceProviderRegistrationPolicy
14
16
15
17
from .. import models as _models
16
18
from .._serialization import Deserializer , Serializer
@@ -57,7 +59,25 @@ def __init__(
57
59
self , credential : "AsyncTokenCredential" , base_url : str = "https://management.azure.com" , ** kwargs : Any
58
60
) -> None :
59
61
self ._config = ServiceLinkerManagementClientConfiguration (credential = credential , ** kwargs )
60
- self ._client : AsyncARMPipelineClient = AsyncARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
62
+ _policies = kwargs .pop ("policies" , None )
63
+ if _policies is None :
64
+ _policies = [
65
+ policies .RequestIdPolicy (** kwargs ),
66
+ self ._config .headers_policy ,
67
+ self ._config .user_agent_policy ,
68
+ self ._config .proxy_policy ,
69
+ policies .ContentDecodePolicy (** kwargs ),
70
+ AsyncARMAutoResourceProviderRegistrationPolicy (),
71
+ self ._config .redirect_policy ,
72
+ self ._config .retry_policy ,
73
+ self ._config .authentication_policy ,
74
+ self ._config .custom_hook_policy ,
75
+ self ._config .logging_policy ,
76
+ policies .DistributedTracingPolicy (** kwargs ),
77
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
78
+ self ._config .http_logging_policy ,
79
+ ]
80
+ self ._client : AsyncARMPipelineClient = AsyncARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
61
81
62
82
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
63
83
self ._serialize = Serializer (client_models )
@@ -71,7 +91,9 @@ def __init__(
71
91
self ._client , self ._config , self ._serialize , self ._deserialize
72
92
)
73
93
74
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> Awaitable [AsyncHttpResponse ]:
94
+ def _send_request (
95
+ self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any
96
+ ) -> Awaitable [AsyncHttpResponse ]:
75
97
"""Runs the network request through the client's chained policies.
76
98
77
99
>>> from azure.core.rest import HttpRequest
@@ -91,7 +113,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH
91
113
92
114
request_copy = deepcopy (request )
93
115
request_copy .url = self ._client .format_url (request_copy .url )
94
- return self ._client .send_request (request_copy , ** kwargs )
116
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
95
117
96
118
async def close (self ) -> None :
97
119
await self ._client .close ()
0 commit comments