77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import Any , TYPE_CHECKING
10+ from typing import Any
11+ from typing_extensions import Self
1112
1213from azure .core import PipelineClient
14+ from azure .core .pipeline import policies
1315from azure .core .rest import HttpRequest , HttpResponse
1416
15- from ._configuration import AzureCommunicationEmailServiceConfiguration
16- from ._serialization import Deserializer , Serializer
17- from .operations import EmailOperations
17+ from ._configuration import EmailClientConfiguration
18+ from ._operations import _EmailClientOperationsMixin
19+ from ._utils . serialization import Deserializer , Serializer
1820
19- if TYPE_CHECKING :
20- # pylint: disable=unused-import,ungrouped-imports
21- from typing import Dict
2221
23-
24- class AzureCommunicationEmailService : # pylint: disable=client-accepts-api-version-keyword
22+ class EmailClient (_EmailClientOperationsMixin ):
2523 """Azure Communication Email Service.
2624
27- :ivar email: EmailOperations operations
28- :vartype email: azure.communication.email.operations.EmailOperations
2925 :param endpoint: The communication resource, for example
3026 https://my-resource.communication.azure.com. Required.
3127 :type endpoint: str
32- :keyword api_version: Api Version. Default value is "2024-07 -01-preview ". Note that overriding
33- this default value may result in unsupported behavior.
28+ :keyword api_version: Api Version. Default value is "2025-09 -01". Note that overriding this
29+ default value may result in unsupported behavior.
3430 :paramtype api_version: str
3531 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
3632 Retry-After header is present.
@@ -40,15 +36,32 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
4036 self , endpoint : str , ** kwargs : Any
4137 ) -> None :
4238 _endpoint = "{endpoint}"
43- self ._config = AzureCommunicationEmailServiceConfiguration (endpoint = endpoint , ** kwargs )
44- self ._client = PipelineClient (base_url = _endpoint , config = self ._config , ** kwargs )
39+ self ._config = EmailClientConfiguration (endpoint = endpoint , ** kwargs )
40+
41+ _policies = kwargs .pop ("policies" , None )
42+ if _policies is None :
43+ _policies = [
44+ policies .RequestIdPolicy (** kwargs ),
45+ self ._config .headers_policy ,
46+ self ._config .user_agent_policy ,
47+ self ._config .proxy_policy ,
48+ policies .ContentDecodePolicy (** kwargs ),
49+ self ._config .redirect_policy ,
50+ self ._config .retry_policy ,
51+ self ._config .authentication_policy ,
52+ self ._config .custom_hook_policy ,
53+ self ._config .logging_policy ,
54+ policies .DistributedTracingPolicy (** kwargs ),
55+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
56+ self ._config .http_logging_policy ,
57+ ]
58+ self ._client : PipelineClient = PipelineClient (base_url = _endpoint , policies = _policies , ** kwargs )
4559
4660 self ._serialize = Serializer ()
4761 self ._deserialize = Deserializer ()
4862 self ._serialize .client_side_validation = False
49- self .email = EmailOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
5063
51- def send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
64+ def send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
5265 """Runs the network request through the client's chained policies.
5366
5467 >>> from azure.core.rest import HttpRequest
@@ -72,17 +85,14 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
7285 }
7386
7487 request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
75- return self ._client .send_request (request_copy , ** kwargs )
88+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
7689
77- def close (self ):
78- # type: () -> None
90+ def close (self ) -> None :
7991 self ._client .close ()
8092
81- def __enter__ (self ):
82- # type: () -> AzureCommunicationEmailService
93+ def __enter__ (self ) -> Self :
8394 self ._client .__enter__ ()
8495 return self
8596
86- def __exit__ (self , * exc_details ):
87- # type: (Any) -> None
97+ def __exit__ (self , * exc_details : Any ) -> None :
8898 self ._client .__exit__ (* exc_details )
0 commit comments