10
10
from typing import Any
11
11
12
12
from azure .core import PipelineClient
13
+ from azure .core .pipeline import policies
13
14
from azure .core .rest import HttpRequest , HttpResponse
14
15
15
16
from . import models as _models
16
17
from ._configuration import KeyVaultClientConfiguration
18
+ from ._operations import KeyVaultClientOperationsMixin
17
19
from ._serialization import Deserializer , Serializer
18
- from .operations import KeyVaultClientOperationsMixin
19
20
20
21
21
22
class KeyVaultClient (KeyVaultClientOperationsMixin ): # pylint: disable=client-accepts-api-version-keyword
22
23
"""The key vault client performs cryptographic key operations and vault operations against the Key
23
24
Vault service.
24
25
25
- :keyword api_version: Api Version. Default value is "7.5-preview.1 ". Note that overriding this
26
- default value may result in unsupported behavior.
26
+ :keyword api_version: Api Version. Default value is "7.5". Note that overriding this default
27
+ value may result in unsupported behavior.
27
28
:paramtype api_version: str
28
29
"""
29
30
30
31
def __init__ (self , ** kwargs : Any ) -> None : # pylint: disable=missing-client-constructor-parameter-credential
31
32
_endpoint = "{vaultBaseUrl}"
32
33
self ._config = KeyVaultClientConfiguration (** kwargs )
33
- self ._client : PipelineClient = PipelineClient (base_url = _endpoint , config = self ._config , ** kwargs )
34
-
35
- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
34
+ _policies = kwargs .pop ("policies" , None )
35
+ if _policies is None :
36
+ _policies = [
37
+ policies .RequestIdPolicy (** kwargs ),
38
+ self ._config .headers_policy ,
39
+ self ._config .user_agent_policy ,
40
+ self ._config .proxy_policy ,
41
+ policies .ContentDecodePolicy (** kwargs ),
42
+ self ._config .redirect_policy ,
43
+ self ._config .retry_policy ,
44
+ self ._config .authentication_policy ,
45
+ self ._config .custom_hook_policy ,
46
+ self ._config .logging_policy ,
47
+ policies .DistributedTracingPolicy (** kwargs ),
48
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
49
+ self ._config .http_logging_policy ,
50
+ ]
51
+ self ._client : PipelineClient = PipelineClient (base_url = _endpoint , policies = _policies , ** kwargs )
52
+
53
+ client_models = {k : v for k , v in _models ._models .__dict__ .items () if isinstance (v , type )}
54
+ client_models .update ({k : v for k , v in _models .__dict__ .items () if isinstance (v , type )})
36
55
self ._serialize = Serializer (client_models )
37
56
self ._deserialize = Deserializer (client_models )
38
57
self ._serialize .client_side_validation = False
39
58
40
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
59
+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
41
60
"""Runs the network request through the client's chained policies.
42
61
43
62
>>> from azure.core.rest import HttpRequest
44
63
>>> request = HttpRequest("GET", "https://www.example.org/")
45
64
<HttpRequest [GET], url: 'https://www.example.org/'>
46
- >>> response = client._send_request (request)
65
+ >>> response = client.send_request (request)
47
66
<HttpResponse: 200 OK>
48
67
49
68
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -57,7 +76,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
57
76
58
77
request_copy = deepcopy (request )
59
78
request_copy .url = self ._client .format_url (request_copy .url )
60
- return self ._client .send_request (request_copy , ** kwargs )
79
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
61
80
62
81
def close (self ) -> None :
63
82
self ._client .close ()
0 commit comments