88
99from copy import deepcopy
1010from typing import Any , TYPE_CHECKING , Union
11+ from typing_extensions import Self
1112
1213from azure .core import PipelineClient
1314from azure .core .credentials import AzureKeyCredential
1415from azure .core .pipeline import policies
1516from azure .core .rest import HttpRequest , HttpResponse
1617
17- from ._configuration import FaceClientConfiguration , FaceSessionClientConfiguration
18- from ._operations import FaceClientOperationsMixin , FaceSessionClientOperationsMixin
18+ from ._configuration import (
19+ FaceAdministrationClientConfiguration ,
20+ FaceClientConfiguration ,
21+ FaceSessionClientConfiguration ,
22+ )
1923from ._serialization import Deserializer , Serializer
24+ from .operations import (
25+ FaceClientOperationsMixin ,
26+ FaceSessionClientOperationsMixin ,
27+ LargeFaceListOperations ,
28+ LargePersonGroupOperations ,
29+ )
2030
2131if TYPE_CHECKING :
22- # pylint: disable=unused-import,ungrouped-imports
2332 from azure .core .credentials import TokenCredential
2433
2534
26- class FaceClient (FaceClientOperationsMixin ): # pylint: disable=client-accepts-api-version-keyword
35+ class FaceAdministrationClient :
36+ """FaceAdministrationClient.
37+
38+ :ivar large_face_list: LargeFaceListOperations operations
39+ :vartype large_face_list: azure.ai.vision.face.operations.LargeFaceListOperations
40+ :ivar large_person_group: LargePersonGroupOperations operations
41+ :vartype large_person_group: azure.ai.vision.face.operations.LargePersonGroupOperations
42+ :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
43+ https://{resource-name}.cognitiveservices.azure.com). Required.
44+ :type endpoint: str
45+ :param credential: Credential used to authenticate requests to the service. Is either a
46+ AzureKeyCredential type or a TokenCredential type. Required.
47+ :type credential: ~azure.core.credentials.AzureKeyCredential or
48+ ~azure.core.credentials.TokenCredential
49+ :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
50+ "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
51+ :paramtype api_version: str or ~azure.ai.vision.face.models.Versions
52+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
53+ Retry-After header is present.
54+ """
55+
56+ def __init__ (self , endpoint : str , credential : Union [AzureKeyCredential , "TokenCredential" ], ** kwargs : Any ) -> None :
57+ _endpoint = "{endpoint}/face/{apiVersion}"
58+ self ._config = FaceAdministrationClientConfiguration (endpoint = endpoint , credential = credential , ** kwargs )
59+ _policies = kwargs .pop ("policies" , None )
60+ if _policies is None :
61+ _policies = [
62+ policies .RequestIdPolicy (** kwargs ),
63+ self ._config .headers_policy ,
64+ self ._config .user_agent_policy ,
65+ self ._config .proxy_policy ,
66+ policies .ContentDecodePolicy (** kwargs ),
67+ self ._config .redirect_policy ,
68+ self ._config .retry_policy ,
69+ self ._config .authentication_policy ,
70+ self ._config .custom_hook_policy ,
71+ self ._config .logging_policy ,
72+ policies .DistributedTracingPolicy (** kwargs ),
73+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
74+ self ._config .http_logging_policy ,
75+ ]
76+ self ._client : PipelineClient = PipelineClient (base_url = _endpoint , policies = _policies , ** kwargs )
77+
78+ self ._serialize = Serializer ()
79+ self ._deserialize = Deserializer ()
80+ self ._serialize .client_side_validation = False
81+ self .large_face_list = LargeFaceListOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
82+ self .large_person_group = LargePersonGroupOperations (
83+ self ._client , self ._config , self ._serialize , self ._deserialize
84+ )
85+
86+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
87+ """Runs the network request through the client's chained policies.
88+
89+ >>> from azure.core.rest import HttpRequest
90+ >>> request = HttpRequest("GET", "https://www.example.org/")
91+ <HttpRequest [GET], url: 'https://www.example.org/'>
92+ >>> response = client.send_request(request)
93+ <HttpResponse: 200 OK>
94+
95+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
96+
97+ :param request: The network request you want to make. Required.
98+ :type request: ~azure.core.rest.HttpRequest
99+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
100+ :return: The response of your network call. Does not do error handling on your response.
101+ :rtype: ~azure.core.rest.HttpResponse
102+ """
103+
104+ request_copy = deepcopy (request )
105+ path_format_arguments = {
106+ "endpoint" : self ._serialize .url ("self._config.endpoint" , self ._config .endpoint , "str" , skip_quote = True ),
107+ "apiVersion" : self ._serialize .url ("self._config.api_version" , self ._config .api_version , "str" ),
108+ }
109+
110+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
111+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
112+
113+ def close (self ) -> None :
114+ self ._client .close ()
115+
116+ def __enter__ (self ) -> Self :
117+ self ._client .__enter__ ()
118+ return self
119+
120+ def __exit__ (self , * exc_details : Any ) -> None :
121+ self ._client .__exit__ (* exc_details )
122+
123+
124+ class FaceClient (FaceClientOperationsMixin ):
27125 """FaceClient.
28126
29127 :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
@@ -33,8 +131,8 @@ class FaceClient(FaceClientOperationsMixin): # pylint: disable=client-accepts-a
33131 AzureKeyCredential type or a TokenCredential type. Required.
34132 :type credential: ~azure.core.credentials.AzureKeyCredential or
35133 ~azure.core.credentials.TokenCredential
36- :keyword api_version: API Version. Default value is "v1.1 -preview.1". Note that overriding this
37- default value may result in unsupported behavior.
134+ :keyword api_version: API Version. Known values are "v1.2 -preview.1" and None. Default value is
135+ "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
38136 :paramtype api_version: str or ~azure.ai.vision.face.models.Versions
39137 """
40138
@@ -94,15 +192,15 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
94192 def close (self ) -> None :
95193 self ._client .close ()
96194
97- def __enter__ (self ) -> "FaceClient" :
195+ def __enter__ (self ) -> Self :
98196 self ._client .__enter__ ()
99197 return self
100198
101199 def __exit__ (self , * exc_details : Any ) -> None :
102200 self ._client .__exit__ (* exc_details )
103201
104202
105- class FaceSessionClient (FaceSessionClientOperationsMixin ): # pylint: disable=client-accepts-api-version-keyword
203+ class FaceSessionClient (FaceSessionClientOperationsMixin ):
106204 """FaceSessionClient.
107205
108206 :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
@@ -112,8 +210,8 @@ class FaceSessionClient(FaceSessionClientOperationsMixin): # pylint: disable=cl
112210 AzureKeyCredential type or a TokenCredential type. Required.
113211 :type credential: ~azure.core.credentials.AzureKeyCredential or
114212 ~azure.core.credentials.TokenCredential
115- :keyword api_version: API Version. Default value is "v1.1 -preview.1". Note that overriding this
116- default value may result in unsupported behavior.
213+ :keyword api_version: API Version. Known values are "v1.2 -preview.1" and None. Default value is
214+ "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
117215 :paramtype api_version: str or ~azure.ai.vision.face.models.Versions
118216 """
119217
@@ -173,7 +271,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
173271 def close (self ) -> None :
174272 self ._client .close ()
175273
176- def __enter__ (self ) -> "FaceSessionClient" :
274+ def __enter__ (self ) -> Self :
177275 self ._client .__enter__ ()
178276 return self
179277
0 commit comments