diff --git a/sdk/face/azure-ai-vision-face/MANIFEST.in b/sdk/face/azure-ai-vision-face/MANIFEST.in index a8d93584ffcc..b9e2541c2b53 100644 --- a/sdk/face/azure-ai-vision-face/MANIFEST.in +++ b/sdk/face/azure-ai-vision-face/MANIFEST.in @@ -5,4 +5,4 @@ recursive-include tests *.py recursive-include samples *.py *.md include azure/__init__.py include azure/ai/__init__.py -include azure/ai/vision/__init__.py \ No newline at end of file +include azure/ai/vision/__init__.py diff --git a/sdk/face/azure-ai-vision-face/_meta.json b/sdk/face/azure-ai-vision-face/_meta.json index ebf0ddcdb2f0..561dd7622ea0 100644 --- a/sdk/face/azure-ai-vision-face/_meta.json +++ b/sdk/face/azure-ai-vision-face/_meta.json @@ -1,7 +1,6 @@ { - "commit": "37acfe2967e5e1be1169146ac461eb1875c9476e", + "commit": "0660a73ea14775552af66f95d92e1a0446a04b54", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/ai/Face", - "@azure-tools/typespec-python": "0.23.8", - "@autorest/python": "6.13.15" + "@azure-tools/typespec-python": "0.44.1" } \ No newline at end of file diff --git a/sdk/face/azure-ai-vision-face/apiview-properties.json b/sdk/face/azure-ai-vision-face/apiview-properties.json new file mode 100644 index 000000000000..2f47fe3c3ded --- /dev/null +++ b/sdk/face/azure-ai-vision-face/apiview-properties.json @@ -0,0 +1,157 @@ +{ + "CrossLanguagePackageId": "Face", + "CrossLanguageDefinitionId": { + "azure.ai.vision.face.models.AccessoryItem": "Face.AccessoryItem", + "azure.ai.vision.face.models.AddFaceResult": "Face.AddFaceResult", + "azure.ai.vision.face.models.BlurProperties": "Face.BlurProperties", + "azure.ai.vision.face.models.CreateLivenessSessionContent": "Face.CreateLivenessSessionContent", + "azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent": "Face.CreateLivenessWithVerifySessionContent", + "azure.ai.vision.face.models.CreatePersonResult": "Face.CreatePersonResult", + "azure.ai.vision.face.models.ExposureProperties": "Face.ExposureProperties", + "azure.ai.vision.face.models.FaceAttributes": "Face.FaceAttributes", + "azure.ai.vision.face.models.FaceDetectionResult": "Face.FaceDetectionResult", + "azure.ai.vision.face.models.FaceError": "Face.FaceError", + "azure.ai.vision.face.models.FaceErrorResponse": "Face.FaceErrorResponse", + "azure.ai.vision.face.models.FaceFindSimilarResult": "Face.FindSimilarResult", + "azure.ai.vision.face.models.FaceGroupingResult": "Face.GroupingResult", + "azure.ai.vision.face.models.FaceIdentificationCandidate": "Face.IdentificationCandidate", + "azure.ai.vision.face.models.FaceIdentificationResult": "Face.IdentificationResult", + "azure.ai.vision.face.models.FaceLandmarks": "Face.FaceLandmarks", + "azure.ai.vision.face.models.FaceRectangle": "Face.FaceRectangle", + "azure.ai.vision.face.models.FaceTrainingResult": "Face.TrainingResult", + "azure.ai.vision.face.models.FaceVerificationResult": "Face.VerificationResult", + "azure.ai.vision.face.models.FacialHair": "Face.FacialHair", + "azure.ai.vision.face.models.HairColor": "Face.HairColor", + "azure.ai.vision.face.models.HairProperties": "Face.HairProperties", + "azure.ai.vision.face.models.HeadPose": "Face.HeadPose", + "azure.ai.vision.face.models.LandmarkCoordinate": "Face.LandmarkCoordinate", + "azure.ai.vision.face.models.LargeFaceList": "Face.LargeFaceList", + "azure.ai.vision.face.models.LargeFaceListFace": "Face.LargeFaceListFace", + "azure.ai.vision.face.models.LargePersonGroup": "Face.LargePersonGroup", + "azure.ai.vision.face.models.LargePersonGroupPerson": "Face.LargePersonGroupPerson", + "azure.ai.vision.face.models.LargePersonGroupPersonFace": "Face.LargePersonGroupPersonFace", + "azure.ai.vision.face.models.LivenessColorDecisionTarget": "Face.LivenessColorDecisionTarget", + "azure.ai.vision.face.models.LivenessDecisionTargets": "Face.LivenessDecisionTargets", + "azure.ai.vision.face.models.LivenessError": "Face.LivenessError", + "azure.ai.vision.face.models.LivenessResult": "Face.LivenessResult", + "azure.ai.vision.face.models.LivenessSession": "Face.LivenessSession", + "azure.ai.vision.face.models.LivenessSessionAttempt": "Face.LivenessSessionAttempt", + "azure.ai.vision.face.models.LivenessSessionResults": "Face.LivenessSessionResults", + "azure.ai.vision.face.models.LivenessWithVerifyOutputs": "Face.LivenessWithVerifyOutputs", + "azure.ai.vision.face.models.LivenessWithVerifyReference": "Face.LivenessWithVerifyReference", + "azure.ai.vision.face.models.LivenessWithVerifyResult": "Face.LivenessWithVerifyResult", + "azure.ai.vision.face.models.LivenessWithVerifySession": "Face.LivenessWithVerifySession", + "azure.ai.vision.face.models.LivenessWithVerifySessionAttempt": "Face.LivenessWithVerifySessionAttempt", + "azure.ai.vision.face.models.LivenessWithVerifySessionResults": "Face.LivenessWithVerifySessionResults", + "azure.ai.vision.face.models.MaskProperties": "Face.MaskProperties", + "azure.ai.vision.face.models.NoiseProperties": "Face.NoiseProperties", + "azure.ai.vision.face.models.OcclusionProperties": "Face.OcclusionProperties", + "azure.ai.vision.face.models.Versions": "Face.Versions", + "azure.ai.vision.face.models.FaceRecognitionModel": "Face.RecognitionModel", + "azure.ai.vision.face.models.GlassesType": "Face.GlassesType", + "azure.ai.vision.face.models.HairColorType": "Face.HairColorType", + "azure.ai.vision.face.models.AccessoryType": "Face.AccessoryType", + "azure.ai.vision.face.models.BlurLevel": "Face.BlurLevel", + "azure.ai.vision.face.models.ExposureLevel": "Face.ExposureLevel", + "azure.ai.vision.face.models.NoiseLevel": "Face.NoiseLevel", + "azure.ai.vision.face.models.MaskType": "Face.MaskType", + "azure.ai.vision.face.models.QualityForRecognition": "Face.QualityForRecognition", + "azure.ai.vision.face.models.FaceDetectionModel": "Face.DetectionModel", + "azure.ai.vision.face.models.FaceAttributeType": "Face.FaceAttributeType", + "azure.ai.vision.face.models.FindSimilarMatchMode": "Face.FindSimilarMatchMode", + "azure.ai.vision.face.models.OperationState": "Azure.Core.Foundations.OperationState", + "azure.ai.vision.face.models.LivenessModel": "Face.LivenessModel", + "azure.ai.vision.face.models.FaceLivenessDecision": "Face.LivenessDecision", + "azure.ai.vision.face.models.LivenessOperationMode": "Face.LivenessOperationMode", + "azure.ai.vision.face.models.FaceImageType": "Face.ImageType", + "azure.ai.vision.face.models.FaceOperationStatus": "Face.OperationStatus", + "azure.ai.vision.face.FaceClient.find_similar": "ClientCustomizations.FaceClient.findSimilar", + "azure.ai.vision.face.aio.FaceClient.find_similar": "ClientCustomizations.FaceClient.findSimilar", + "azure.ai.vision.face.FaceClient.verify_face_to_face": "ClientCustomizations.FaceClient.verifyFaceToFace", + "azure.ai.vision.face.aio.FaceClient.verify_face_to_face": "ClientCustomizations.FaceClient.verifyFaceToFace", + "azure.ai.vision.face.FaceClient.group": "ClientCustomizations.FaceClient.group", + "azure.ai.vision.face.aio.FaceClient.group": "ClientCustomizations.FaceClient.group", + "azure.ai.vision.face.FaceClient.find_similar_from_large_face_list": "ClientCustomizations.FaceClient.findSimilarFromLargeFaceList", + "azure.ai.vision.face.aio.FaceClient.find_similar_from_large_face_list": "ClientCustomizations.FaceClient.findSimilarFromLargeFaceList", + "azure.ai.vision.face.FaceClient.identify_from_large_person_group": "ClientCustomizations.FaceClient.identifyFromLargePersonGroup", + "azure.ai.vision.face.aio.FaceClient.identify_from_large_person_group": "ClientCustomizations.FaceClient.identifyFromLargePersonGroup", + "azure.ai.vision.face.FaceClient.verify_from_large_person_group": "ClientCustomizations.FaceClient.verifyFromLargePersonGroup", + "azure.ai.vision.face.aio.FaceClient.verify_from_large_person_group": "ClientCustomizations.FaceClient.verifyFromLargePersonGroup", + "azure.ai.vision.face.FaceSessionClient.create_liveness_session": "ClientCustomizations.FaceSessionClient.createLivenessSession", + "azure.ai.vision.face.aio.FaceSessionClient.create_liveness_session": "ClientCustomizations.FaceSessionClient.createLivenessSession", + "azure.ai.vision.face.FaceSessionClient.delete_liveness_session": "ClientCustomizations.FaceSessionClient.deleteLivenessSession", + "azure.ai.vision.face.aio.FaceSessionClient.delete_liveness_session": "ClientCustomizations.FaceSessionClient.deleteLivenessSession", + "azure.ai.vision.face.FaceSessionClient.get_liveness_session_result": "ClientCustomizations.FaceSessionClient.getLivenessSessionResult", + "azure.ai.vision.face.aio.FaceSessionClient.get_liveness_session_result": "ClientCustomizations.FaceSessionClient.getLivenessSessionResult", + "azure.ai.vision.face.FaceSessionClient.create_liveness_with_verify_session": "ClientCustomizations.FaceSessionClient.createLivenessWithVerifySession", + "azure.ai.vision.face.aio.FaceSessionClient.create_liveness_with_verify_session": "ClientCustomizations.FaceSessionClient.createLivenessWithVerifySession", + "azure.ai.vision.face.FaceSessionClient.delete_liveness_with_verify_session": "ClientCustomizations.FaceSessionClient.deleteLivenessWithVerifySession", + "azure.ai.vision.face.aio.FaceSessionClient.delete_liveness_with_verify_session": "ClientCustomizations.FaceSessionClient.deleteLivenessWithVerifySession", + "azure.ai.vision.face.FaceSessionClient.get_liveness_with_verify_session_result": "ClientCustomizations.FaceSessionClient.getLivenessWithVerifySessionResult", + "azure.ai.vision.face.aio.FaceSessionClient.get_liveness_with_verify_session_result": "ClientCustomizations.FaceSessionClient.getLivenessWithVerifySessionResult", + "azure.ai.vision.face.FaceSessionClient.detect_from_session_image": "ClientCustomizations.FaceSessionClient.detectFromSessionImage", + "azure.ai.vision.face.aio.FaceSessionClient.detect_from_session_image": "ClientCustomizations.FaceSessionClient.detectFromSessionImage", + "azure.ai.vision.face.FaceSessionClient.get_session_image": "ClientCustomizations.FaceSessionClient.getSessionImage", + "azure.ai.vision.face.aio.FaceSessionClient.get_session_image": "ClientCustomizations.FaceSessionClient.getSessionImage", + "azure.ai.vision.face.operations.LargeFaceListOperations.create": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.create", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.create": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.create", + "azure.ai.vision.face.operations.LargeFaceListOperations.delete": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.delete", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.delete": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.delete", + "azure.ai.vision.face.operations.LargeFaceListOperations.get": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.get", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.get": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.get", + "azure.ai.vision.face.operations.LargeFaceListOperations.update": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.update", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.update": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.update", + "azure.ai.vision.face.operations.LargeFaceListOperations.get_large_face_lists": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getLargeFaceLists", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.get_large_face_lists": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getLargeFaceLists", + "azure.ai.vision.face.operations.LargeFaceListOperations.get_training_status": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getTrainingStatus", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.get_training_status": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getTrainingStatus", + "azure.ai.vision.face.operations.LargeFaceListOperations.begin_train": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.train", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.begin_train": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.train", + "azure.ai.vision.face.operations.LargeFaceListOperations.add_face_from_url": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.addFaceFromUrl", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.add_face_from_url": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.addFaceFromUrl", + "azure.ai.vision.face.operations.LargeFaceListOperations.add_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.addFace", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.add_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.addFace", + "azure.ai.vision.face.operations.LargeFaceListOperations.delete_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.deleteFace", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.delete_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.deleteFace", + "azure.ai.vision.face.operations.LargeFaceListOperations.get_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getFace", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.get_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getFace", + "azure.ai.vision.face.operations.LargeFaceListOperations.update_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.updateFace", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.update_face": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.updateFace", + "azure.ai.vision.face.operations.LargeFaceListOperations.get_faces": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getFaces", + "azure.ai.vision.face.aio.operations.LargeFaceListOperations.get_faces": "ClientCustomizations.FaceAdministrationClient.LargeFaceList.getFaces", + "azure.ai.vision.face.operations.LargePersonGroupOperations.create": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.create", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.create": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.create", + "azure.ai.vision.face.operations.LargePersonGroupOperations.delete": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.delete", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.delete": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.delete", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.get", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.get", + "azure.ai.vision.face.operations.LargePersonGroupOperations.update": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.update", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.update": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.update", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get_large_person_groups": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getLargePersonGroups", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get_large_person_groups": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getLargePersonGroups", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get_training_status": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getTrainingStatus", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get_training_status": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getTrainingStatus", + "azure.ai.vision.face.operations.LargePersonGroupOperations.begin_train": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.train", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.begin_train": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.train", + "azure.ai.vision.face.operations.LargePersonGroupOperations.create_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.createPerson", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.create_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.createPerson", + "azure.ai.vision.face.operations.LargePersonGroupOperations.delete_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.deletePerson", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.delete_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.deletePerson", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getPerson", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getPerson", + "azure.ai.vision.face.operations.LargePersonGroupOperations.update_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.updatePerson", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.update_person": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.updatePerson", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get_persons": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getPersons", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get_persons": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getPersons", + "azure.ai.vision.face.operations.LargePersonGroupOperations.add_face_from_url": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.addFaceFromUrl", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.add_face_from_url": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.addFaceFromUrl", + "azure.ai.vision.face.operations.LargePersonGroupOperations.add_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.addFace", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.add_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.addFace", + "azure.ai.vision.face.operations.LargePersonGroupOperations.delete_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.deleteFace", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.delete_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.deleteFace", + "azure.ai.vision.face.operations.LargePersonGroupOperations.get_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getFace", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.get_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.getFace", + "azure.ai.vision.face.operations.LargePersonGroupOperations.update_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.updateFace", + "azure.ai.vision.face.aio.operations.LargePersonGroupOperations.update_face": "ClientCustomizations.FaceAdministrationClient.LargePersonGroup.updateFace" + } +} \ No newline at end of file diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/__init__.py index fb2a4f6ec76e..21405e77f7fa 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/__init__.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/__init__.py @@ -5,22 +5,32 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import FaceAdministrationClient -from ._patch import FaceClient -from ._patch import FaceSessionClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import FaceClient # type: ignore +from ._client import FaceSessionClient # type: ignore +from ._client import FaceAdministrationClient # type: ignore from ._version import VERSION __version__ = VERSION - +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "FaceAdministrationClient", "FaceClient", "FaceSessionClient", + "FaceAdministrationClient", ] - +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_client.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_client.py index b2f532920bb5..4f337abed7a0 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_client.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_client.py @@ -20,7 +20,7 @@ FaceClientConfiguration, FaceSessionClientConfiguration, ) -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( FaceClientOperationsMixin, FaceSessionClientOperationsMixin, @@ -32,30 +32,25 @@ from azure.core.credentials import TokenCredential -class FaceAdministrationClient: - """FaceAdministrationClient. +class FaceClient(FaceClientOperationsMixin): + """FaceClient. - :ivar large_face_list: LargeFaceListOperations operations - :vartype large_face_list: azure.ai.vision.face.operations.LargeFaceListOperations - :ivar large_person_group: LargePersonGroupOperations operations - :vartype large_person_group: azure.ai.vision.face.operations.LargePersonGroupOperations :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -78,10 +73,6 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCr self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.large_face_list = LargeFaceListOperations(self._client, self._config, self._serialize, self._deserialize) - self.large_person_group = LargePersonGroupOperations( - self._client, self._config, self._serialize, self._deserialize - ) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. @@ -121,24 +112,25 @@ def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) -class FaceClient(FaceClientOperationsMixin): - """FaceClient. +class FaceSessionClient(FaceSessionClientOperationsMixin): + """FaceSessionClient. :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceSessionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -200,24 +192,31 @@ def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) -class FaceSessionClient(FaceSessionClientOperationsMixin): - """FaceSessionClient. +class FaceAdministrationClient: + """FaceAdministrationClient. + :ivar large_face_list: LargeFaceListOperations operations + :vartype large_face_list: azure.ai.vision.face.operations.LargeFaceListOperations + :ivar large_person_group: LargePersonGroupOperations operations + :vartype large_person_group: azure.ai.vision.face.operations.LargePersonGroupOperations :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceSessionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -240,6 +239,10 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCr self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False + self.large_face_list = LargeFaceListOperations(self._client, self._config, self._serialize, self._deserialize) + self.large_person_group = LargePersonGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_configuration.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_configuration.py index 4fe969da162c..e78af8f196a5 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_configuration.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_configuration.py @@ -17,8 +17,8 @@ from azure.core.credentials import TokenCredential -class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceAdministrationClient. +class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -26,17 +26,17 @@ class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instanc :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -72,8 +72,8 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = self._infer_policy(**kwargs) -class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceClient. +class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceSessionClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -81,17 +81,17 @@ class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -127,8 +127,8 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = self._infer_policy(**kwargs) -class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceSessionClient. +class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceAdministrationClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -136,17 +136,17 @@ class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attri :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_patch.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_patch.py index 98b897fa68e2..8bcb627aa475 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_patch.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_patch.py @@ -1,315 +1,15 @@ -# pylint: disable=too-many-lines -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, IO, List, Optional, Union, overload +from typing import List -from azure.core.tracing.decorator import distributed_trace - -from . import models as _models -from ._client import FaceClient as FaceClientGenerated -from ._client import FaceSessionClient as FaceSessionClientGenerated -from .operations._operations import JSON, _Unset - - -class FaceClient(FaceClientGenerated): - """FaceClient. - - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: - https://{resource-name}.cognitiveservices.azure.com). Required. - :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Default value is "v1.2-preview.1". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - """ - - @overload - def detect_from_url( - self, - *, - url: str, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @overload - def detect_from_url( - self, - body: JSON, - *, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @overload - def detect_from_url( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @distributed_trace - def detect_from_url( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - url: str = _Unset, - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url for more - details. - - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - return super()._detect_from_url( - body, - url=url, - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - **kwargs, - ) - - @distributed_trace - def detect( - self, - image_content: bytes, - *, - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to https://learn.microsoft.com/rest/api/face/face-detection-operations/detect for - more details. - - :param image_content: The input image binary. Required. - :type image_content: bytes - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - return super()._detect( - image_content, - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - **kwargs, - ) - - def __enter__(self) -> "FaceClient": - super().__enter__() - return self - - -class FaceSessionClient(FaceSessionClientGenerated): - """FaceSessionClient. - - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: - https://{resource-name}.cognitiveservices.azure.com). Required. - :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials.TokenCredential - :keyword api_version: API Version. Default value is "v1.2-preview.1". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - """ - - @overload - def create_liveness_with_verify_session( - self, - body: _models.CreateLivenessWithVerifySessionContent, - *, - verify_image: Union[bytes, None], - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: ... - - @overload - def create_liveness_with_verify_session( - self, - body: JSON, - *, - verify_image: Union[bytes, None], - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: ... - - @distributed_trace - def create_liveness_with_verify_session( - self, - body: Union[_models.CreateLivenessWithVerifySessionContent, JSON], - *, - verify_image: Union[bytes, None], - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Client device submits VerifyImage during the - /detectLivenessWithVerify/singleModal call. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session - for more details. - - :param body: Body parameter. Is one of the following types: - CreateLivenessWithVerifySessionContent, JSON, IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON or - IO[bytes] - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - if verify_image is not None: - if not isinstance(body, _models.CreateLivenessWithVerifySessionContent): - # Convert body to CreateLivenessWithVerifySessionContent if necessary - body = _models.CreateLivenessWithVerifySessionContent(**body) - request_body = ( - _models._models.CreateLivenessWithVerifySessionMultipartContent( # pylint: disable=protected-access - parameters=body, - verify_image=("verify-image", verify_image), - ) - ) - return super()._create_liveness_with_verify_session_with_verify_image(request_body, **kwargs) - - return super()._create_liveness_with_verify_session(body, **kwargs) - - def __enter__(self) -> "FaceSessionClient": - super().__enter__() - return self - - -__all__: List[str] = [ - "FaceClient", - "FaceSessionClient", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_model_base.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/model_base.py similarity index 92% rename from sdk/face/azure-ai-vision-face/azure/ai/vision/face/_model_base.py rename to sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/model_base.py index 9d401b0cf012..49d5c7259389 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_model_base.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/model_base.py @@ -2,10 +2,11 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines +# pylint: disable=protected-access, broad-except import copy import calendar @@ -21,6 +22,7 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET +from collections.abc import MutableMapping from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError @@ -28,11 +30,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] @@ -347,7 +344,7 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object +class _MyMutableMapping(MutableMapping[str, typing.Any]): def __init__(self, data: typing.Dict[str, typing.Any]) -> None: self._data = data @@ -373,50 +370,97 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ return self._data.items() def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ try: return self[key] except KeyError: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from D. + """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ self._data.update(*args, **kwargs) @typing.overload def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) @@ -574,7 +618,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' @@ -585,8 +629,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di annotations = { k: v for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() } for attr, rf in attr_to_rest_field.items(): rf._module = cls.__module__ @@ -597,12 +641,12 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - return super().__new__(cls) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: - if hasattr(base, "__mapping__"): # pylint: disable=no-member - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: @@ -613,7 +657,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField @classmethod def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + if not hasattr(cls, "__mapping__"): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) if discriminator is None: @@ -754,7 +798,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except AttributeError: model_name = annotation if module is not None: - annotation = _get_model(module, model_name) + annotation = _get_model(module, model_name) # type: ignore try: if module and _is_model(annotation): @@ -894,6 +938,35 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + class _RestField: def __init__( self, diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_serialization.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/serialization.py similarity index 93% rename from sdk/face/azure-ai-vision-face/azure/ai/vision/face/_serialization.py rename to sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/serialization.py index 7b3074215a30..eb86ea23c965 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_serialization.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/serialization.py @@ -1,27 +1,10 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -47,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -60,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -184,73 +165,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -478,8 +393,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -506,7 +421,6 @@ def _flatten_subtype(cls, key, objects): def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. :param dict response: The initial data :param dict objects: The class objects @@ -518,7 +432,7 @@ def _classify(cls, response, objects): if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -563,7 +477,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -598,7 +512,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -626,7 +540,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -736,8 +650,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +695,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +719,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +749,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +769,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1192,7 +1106,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1132,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1165,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1429,7 +1343,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1441,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1452,7 +1366,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1488,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1416,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1683,17 +1597,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore @@ -1713,7 +1631,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1795,7 +1713,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1841,7 +1759,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1932,7 +1850,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1945,7 +1863,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1960,7 +1878,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1978,7 +1896,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1991,7 +1909,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2009,7 +1927,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2025,7 +1943,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2040,14 +1958,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2063,7 +1981,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2101,7 +2019,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_vendor.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/utils.py similarity index 75% rename from sdk/face/azure-ai-vision-face/azure/ai/vision/face/_vendor.py rename to sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/utils.py index 76a375ebbef9..89abe90d9245 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_vendor.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/_utils/utils.py @@ -7,31 +7,23 @@ from abc import ABC import json -from typing import Any, Dict, IO, List, Mapping, Optional, TYPE_CHECKING, Tuple, Union +from typing import Any, Dict, Generic, IO, List, Mapping, Optional, TYPE_CHECKING, Tuple, TypeVar, Union -from ._configuration import FaceClientConfiguration, FaceSessionClientConfiguration -from ._model_base import Model, SdkJSONEncoder +from .._utils.model_base import Model, SdkJSONEncoder if TYPE_CHECKING: - from azure.core import PipelineClient + from .serialization import Deserializer, Serializer - from ._serialization import Deserializer, Serializer - -class FaceClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: FaceClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class FaceSessionClientMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "PipelineClient" - _config: FaceSessionClientConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/__init__.py index 5bd65820f8fe..3b7ecd3ebffd 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/__init__.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/__init__.py @@ -5,19 +5,29 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import FaceAdministrationClient -from ._patch import FaceClient -from ._patch import FaceSessionClient +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._client import FaceClient # type: ignore +from ._client import FaceSessionClient # type: ignore +from ._client import FaceAdministrationClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "FaceAdministrationClient", "FaceClient", "FaceSessionClient", + "FaceAdministrationClient", ] - +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_client.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_client.py index 5ea825943687..0ec5a557a872 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_client.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_client.py @@ -15,7 +15,7 @@ from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import ( FaceAdministrationClientConfiguration, FaceClientConfiguration, @@ -32,32 +32,27 @@ from azure.core.credentials_async import AsyncTokenCredential -class FaceAdministrationClient: - """FaceAdministrationClient. +class FaceClient(FaceClientOperationsMixin): + """FaceClient. - :ivar large_face_list: LargeFaceListOperations operations - :vartype large_face_list: azure.ai.vision.face.aio.operations.LargeFaceListOperations - :ivar large_person_group: LargePersonGroupOperations operations - :vartype large_person_group: azure.ai.vision.face.aio.operations.LargePersonGroupOperations :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -80,10 +75,6 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.large_face_list = LargeFaceListOperations(self._client, self._config, self._serialize, self._deserialize) - self.large_person_group = LargePersonGroupOperations( - self._client, self._config, self._serialize, self._deserialize - ) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any @@ -125,18 +116,18 @@ async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) -class FaceClient(FaceClientOperationsMixin): - """FaceClient. +class FaceSessionClient(FaceSessionClientOperationsMixin): + """FaceSessionClient. :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ @@ -144,7 +135,8 @@ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceSessionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -208,26 +200,33 @@ async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) -class FaceSessionClient(FaceSessionClientOperationsMixin): - """FaceSessionClient. +class FaceAdministrationClient: + """FaceAdministrationClient. + :ivar large_face_list: LargeFaceListOperations operations + :vartype large_face_list: azure.ai.vision.face.aio.operations.LargeFaceListOperations + :ivar large_person_group: LargePersonGroupOperations operations + :vartype large_person_group: azure.ai.vision.face.aio.operations.LargePersonGroupOperations :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: _endpoint = "{endpoint}/face/{apiVersion}" - self._config = FaceSessionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = FaceAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -250,6 +249,10 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False + self.large_face_list = LargeFaceListOperations(self._client, self._config, self._serialize, self._deserialize) + self.large_person_group = LargePersonGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_configuration.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_configuration.py index fafe5ab8feff..8c20810eda9a 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_configuration.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_configuration.py @@ -17,8 +17,8 @@ from azure.core.credentials_async import AsyncTokenCredential -class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceAdministrationClient. +class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -26,19 +26,19 @@ class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instanc :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -74,8 +74,8 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = self._infer_policy(**kwargs) -class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceClient. +class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceSessionClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -83,19 +83,19 @@ class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -131,8 +131,8 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = self._infer_policy(**kwargs) -class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for FaceSessionClient. +class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for FaceAdministrationClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -140,19 +140,19 @@ class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attri :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com). Required. :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. + :param credential: Credential used to authenticate requests to the service. Is either a key + credential type or a token credential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is - "v1.2-preview.1". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: API Version. Known values are "v1.2" and None. Default value is "v1.2". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str or ~azure.ai.vision.face.models.Versions """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "v1.2-preview.1") + api_version: str = kwargs.pop("api_version", "v1.2") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_patch.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_patch.py index 430ddc352d01..8bcb627aa475 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_patch.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_patch.py @@ -1,315 +1,15 @@ -# pylint: disable=too-many-lines -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, IO, List, Optional, Union, overload +from typing import List -from azure.core.tracing.decorator_async import distributed_trace_async - -from .. import models as _models -from ._client import FaceClient as FaceClientGenerated -from ._client import FaceSessionClient as FaceSessionClientGenerated -from .operations._operations import JSON, _Unset - - -class FaceClient(FaceClientGenerated): - """FaceClient. - - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: - https://{resource-name}.cognitiveservices.azure.com). Required. - :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Default value is "v1.2-preview.1". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - """ - - @overload - async def detect_from_url( - self, - *, - url: str, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @overload - async def detect_from_url( - self, - body: JSON, - *, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @overload - async def detect_from_url( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @distributed_trace_async - async def detect_from_url( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - url: str = _Unset, - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url for more - details. - - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - return await super()._detect_from_url( - body, - url=url, - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - **kwargs, - ) - - @distributed_trace_async - async def detect( - self, - image_content: bytes, - *, - detection_model: Union[str, _models.FaceDetectionModel], - recognition_model: Union[str, _models.FaceRecognitionModel], - return_face_id: bool, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to https://learn.microsoft.com/rest/api/face/face-detection-operations/detect for - more details. - - :param image_content: The input image binary. Required. - :type image_content: bytes - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - return await super()._detect( - image_content, - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - **kwargs, - ) - - async def __aenter__(self) -> "FaceClient": - await super().__aenter__() - return self - - -class FaceSessionClient(FaceSessionClientGenerated): - """FaceSessionClient. - - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: - https://{resource-name}.cognitiveservices.azure.com). Required. - :type endpoint: str - :param credential: Credential used to authenticate requests to the service. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: API Version. Default value is "v1.2-preview.1". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str or ~azure.ai.vision.face.models.Versions - """ - - @overload - async def create_liveness_with_verify_session( - self, - body: _models.CreateLivenessSessionContent, - *, - verify_image: Union[bytes, None], - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: ... - - @overload - async def create_liveness_with_verify_session( - self, - body: JSON, - *, - verify_image: Union[bytes, None], - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: ... - - @distributed_trace_async - async def create_liveness_with_verify_session( - self, - body: Union[_models.CreateLivenessWithVerifySessionContent, JSON], - *, - verify_image: Union[bytes, None], - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Client device submits VerifyImage during the - /detectLivenessWithVerify/singleModal call. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session - for more details. - - :param body: Body parameter. Is one of the following types: - CreateLivenessWithVerifySessionContent, JSON, IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON or - IO[bytes] - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - if verify_image is not None: - if not isinstance(body, _models.CreateLivenessWithVerifySessionContent): - # Convert body to CreateLivenessWithVerifySessionContent if necessary - body = _models.CreateLivenessWithVerifySessionContent(**body) - request_body = ( - _models._models.CreateLivenessWithVerifySessionMultipartContent( # pylint: disable=protected-access - parameters=body, - verify_image=("verify-image", verify_image), - ) - ) - return await super()._create_liveness_with_verify_session_with_verify_image(request_body, **kwargs) - - return await super()._create_liveness_with_verify_session(body, **kwargs) - - async def __aenter__(self) -> "FaceSessionClient": - await super().__aenter__() - return self - - -__all__: List[str] = [ - "FaceClient", - "FaceSessionClient", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_vendor.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_vendor.py deleted file mode 100644 index 6193ed0a757b..000000000000 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_vendor.py +++ /dev/null @@ -1,34 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import FaceClientConfiguration, FaceSessionClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class FaceClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: FaceClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" - - -class FaceSessionClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: FaceSessionClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/__init__.py index d69ac05180a1..311b6f67a8ce 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/__init__.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/__init__.py @@ -5,21 +5,27 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import LargeFaceListOperations -from ._operations import LargePersonGroupOperations -from ._operations import FaceClientOperationsMixin -from ._operations import FaceSessionClientOperationsMixin +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import FaceClientOperationsMixin # type: ignore +from ._operations import FaceSessionClientOperationsMixin # type: ignore +from ._operations import LargeFaceListOperations # type: ignore +from ._operations import LargePersonGroupOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "LargeFaceListOperations", - "LargePersonGroupOperations", "FaceClientOperationsMixin", "FaceSessionClientOperationsMixin", + "LargeFaceListOperations", + "LargePersonGroupOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_operations.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_operations.py index 44f9683129a0..ebf211363769 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_operations.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,10 +29,11 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict -from ... import _model_base, models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ... import models as _models +from ..._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ..._utils.utils import ClientMixinABC, prepare_multipart_form_data from ..._validation import api_version_validation -from ..._vendor import prepare_multipart_form_data from ...operations._operations import ( build_face_detect_from_url_request, build_face_detect_request, @@ -41,16 +43,11 @@ build_face_identify_from_large_person_group_request, build_face_session_create_liveness_session_request, build_face_session_create_liveness_with_verify_session_request, - build_face_session_create_liveness_with_verify_session_with_verify_image_request, build_face_session_delete_liveness_session_request, build_face_session_delete_liveness_with_verify_session_request, build_face_session_detect_from_session_image_request, - build_face_session_get_liveness_session_audit_entries_request, build_face_session_get_liveness_session_result_request, - build_face_session_get_liveness_sessions_request, - build_face_session_get_liveness_with_verify_session_audit_entries_request, build_face_session_get_liveness_with_verify_session_result_request, - build_face_session_get_liveness_with_verify_sessions_request, build_face_session_get_session_image_request, build_face_verify_face_to_face_request, build_face_verify_from_large_person_group_request, @@ -85,163 +82,126 @@ build_large_person_group_update_person_request, build_large_person_group_update_request, ) -from .._vendor import FaceClientMixinABC, FaceSessionClientMixinABC +from .._configuration import ( + FaceAdministrationClientConfiguration, + FaceClientConfiguration, + FaceSessionClientConfiguration, +) -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] _Unset: Any = object() T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LargeFaceListOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.vision.face.aio.FaceAdministrationClient`'s - :attr:`large_face_list` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") +class FaceClientOperationsMixin(ClientMixinABC[AsyncPipelineClient, FaceClientConfiguration]): @overload - async def create( - self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - + async def _detect_from_url( + self, + *, + url: str, + content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any + ) -> List[_models.FaceDetectionResult]: ... @overload - async def create( + async def _detect_from_url( self, - large_face_list_id: str, + body: JSON, *, - name: str, content_type: str = "application/json", - user_data: Optional[str] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> List[_models.FaceDetectionResult]: ... @overload - async def create( - self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _detect_from_url( + self, + body: IO[bytes], + *, + content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any + ) -> List[_models.FaceDetectionResult]: ... @distributed_trace_async - async def create( + async def _detect_from_url( self, - large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - name: str = _Unset, - user_data: Optional[str] = None, + url: str = _Unset, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url + `_ for + more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -255,13 +215,13 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -270,8 +230,14 @@ async def create( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_create_request( - large_face_list_id=large_face_list_id, + _request = build_face_detect_from_url_request( + detection_model=detection_model, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, + return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, content_type=content_type, content=_content, headers=_headers, @@ -283,91 +249,89 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def delete(self, large_face_list_id: str, **kwargs: Any) -> None: - """Delete a face from a Large Face List by specified largeFaceListId and persistedFaceId. + async def _detect( + self, + image_content: bytes, + *, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list for more + Please refer to `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_large_face_list_delete_request( - large_face_list_id=large_face_list_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any - ) -> _models.LargeFaceList: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str + :param image_content: The input image binary. Required. + :type image_content: bytes + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. + false. This is only applicable when returnFaceId = true. Default value is None. :paramtype return_recognition_model: bool - :return: LargeFaceList. The LargeFaceList is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargeFaceList + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -378,14 +342,24 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargeFaceList] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) - _request = build_large_face_list_get_request( - large_face_list_id=large_face_list_id, + _content = image_content + + _request = build_face_detect_request( + detection_model=detection_model, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -396,7 +370,7 @@ async def get( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -409,13 +383,13 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargeFaceList, response.json()) + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -423,103 +397,127 @@ async def get( return deserialized # type: ignore @overload - async def update( - self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + async def find_similar( + self, + *, + face_id: str, + face_ids: List[str], + content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the + faceIds will expire 24 hours after the detection call. The number of faceIds is limited to + 1000. Required. + :paramtype face_ids: list[str] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, - large_face_list_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + async def find_similar( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + async def find_similar( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def find_similar( self, - large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - name: Optional[str] = None, - user_data: Optional[str] = None, + face_id: str = _Unset, + face_ids: List[str] = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the + faceIds will expire 24 hours after the detection call. The number of faceIds is limited to + 1000. Required. + :paramtype face_ids: list[str] + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -534,20 +532,28 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_face_list_update_request( - large_face_list_id=large_face_list_id, + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + body = { + "faceId": face_id, + "faceIds": face_ids, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + "mode": mode, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_find_similar_request( content_type=content_type, content=_content, headers=_headers, @@ -559,77 +565,8 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get_large_face_lists( - self, - *, - start: Optional[str] = None, - top: Optional[int] = None, - return_recognition_model: Optional[bool] = None, - **kwargs: Any - ) -> List[_models.LargeFaceList]: - """List Large Face Lists' information of largeFaceListId, name, userData and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-lists for more - details. - - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: list of LargeFaceList - :rtype: list[~azure.ai.vision.face.models.LargeFaceList] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LargeFaceList]] = kwargs.pop("cls", None) - - _request = build_large_face_list_get_large_face_lists_request( - start=start, - top=top, - return_recognition_model=return_recognition_model, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -642,30 +579,103 @@ async def get_large_face_lists( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LargeFaceList], response.json()) + deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def verify_face_to_face( + self, *, face_id1: str, face_id2: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :keyword face_id1: The faceId of one face, come from "Detect". Required. + :paramtype face_id1: str + :keyword face_id2: The faceId of another face, come from "Detect". Required. + :paramtype face_id2: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify_face_to_face( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify_face_to_face( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models.FaceTrainingResult: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-training-status + async def verify_face_to_face( + self, body: Union[JSON, IO[bytes]] = _Unset, *, face_id1: str = _Unset, face_id2: str = _Unset, **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceTrainingResult + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_id1: The faceId of one face, come from "Detect". Required. + :paramtype face_id1: str + :keyword face_id2: The faceId of another face, come from "Detect". Required. + :paramtype face_id2: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -676,13 +686,29 @@ async def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _ } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) - _request = build_large_face_list_get_training_status_request( - large_face_list_id=large_face_list_id, + if body is _Unset: + if face_id1 is _Unset: + raise TypeError("missing required argument: face_id1") + if face_id2 is _Unset: + raise TypeError("missing required argument: face_id2") + body = {"faceId1": face_id1, "faceId2": face_id2} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_verify_face_to_face_request( + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -693,7 +719,7 @@ async def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _ _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -706,290 +732,97 @@ async def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _ except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceTrainingResult, response.json()) + deserialized = _deserialize(_models.FaceVerificationResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _train_initial(self, large_face_list_id: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @overload + async def group( + self, *, face_ids: List[str], content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. + Required. + :paramtype face_ids: list[str] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - _request = build_large_face_list_train_request( - large_face_list_id=large_face_list_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @overload + async def group( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_train(self, large_face_list_id: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Submit a Large Face List training task. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/train-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: An instance of AsyncLROPoller that returns None - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._train_initial( - large_face_list_id=large_face_list_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - async def add_face_from_url( - self, - large_face_list_id: str, - body: JSON, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url - for more details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def add_face_from_url( - self, - large_face_list_id: str, - *, - url: str, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url - for more details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @overload - async def add_face_from_url( - self, - large_face_list_id: str, - body: IO[bytes], - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + async def group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url - for more details. + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Required. :type body: IO[bytes] - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def add_face_from_url( - self, - large_face_list_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - url: str = _Unset, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + async def group( + self, body: Union[JSON, IO[bytes]] = _Unset, *, face_ids: List[str] = _Unset, **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url - for more details. + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. + Required. + :paramtype face_ids: list[str] + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1004,12 +837,12 @@ async def add_face_from_url( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + cls: ClsType[_models.FaceGroupingResult] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + body = {"faceIds": face_ids} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -1018,11 +851,7 @@ async def add_face_from_url( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_add_face_from_url_request( - large_face_list_id=large_face_list_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, + _request = build_face_group_request( content_type=content_type, content=_content, headers=_headers, @@ -1035,7 +864,7 @@ async def add_face_from_url( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1048,54 +877,141 @@ async def add_face_from_url( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + deserialized = _deserialize(_models.FaceGroupingResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def add_face( + @overload + async def find_similar_from_large_face_list( self, + *, + face_id: str, large_face_list_id: str, - image_content: bytes, + content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ + for more details. + + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, + created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which + are persisted and will never expire. Required. + :paramtype large_face_list_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def find_similar_from_large_face_list( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ + for more details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def find_similar_from_large_face_list( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ + for more details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def find_similar_from_large_face_list( + self, + body: Union[JSON, IO[bytes]] = _Unset, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + face_id: str = _Unset, + large_face_list_id: str = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face for - more details. + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ + for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param image_content: The image to be analyzed. Required. - :type image_content: bytes - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, + created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which + are persisted and will never expire. Required. + :paramtype large_face_list_id: str + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1109,16 +1025,29 @@ async def add_face( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) - _content = image_content + if body is _Unset: + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if large_face_list_id is _Unset: + raise TypeError("missing required argument: large_face_list_id") + body = { + "faceId": face_id, + "largeFaceListId": large_face_list_id, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + "mode": mode, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_add_face_request( - large_face_list_id=large_face_list_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, + _request = build_face_find_similar_from_large_face_list_request( content_type=content_type, content=_content, headers=_headers, @@ -1131,7 +1060,7 @@ async def add_face( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1144,89 +1073,143 @@ async def add_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list-face for - more details. + @overload + async def identify_from_large_person_group( + self, + *, + face_ids: List[str], + large_person_group_id: str, + content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + confidence_threshold: Optional[float] = None, + **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: None - :rtype: None + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are + identified independently. The valid number of faceIds is between [1, 10]. Required. + :paramtype face_ids: list[str] + :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by + "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be + provided at the same time. Required. + :paramtype large_person_group_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 + and 100. Default value is 10. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword confidence_threshold: Customized identification confidence threshold, in the range of + [0, 1]. Advanced user can tweak this value to override default internal threshold for better + precision on their scenario data. Note there is no guarantee of this threshold value working on + other data and after algorithm updates. Default value is None. + :paramtype confidence_threshold: float + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_large_face_list_delete_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @overload + async def identify_from_large_person_group( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. - response = pipeline_response.http_response + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) + @overload + async def identify_from_large_person_group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. - if cls: - return cls(pipeline_response, None, {}) # type: ignore + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def get_face( - self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any - ) -> _models.LargeFaceListFace: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-face for - more details. + async def identify_from_large_person_group( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + face_ids: List[str] = _Unset, + large_person_group_id: str = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + confidence_threshold: Optional[float] = None, + **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: LargeFaceListFace. The LargeFaceListFace is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargeFaceListFace + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are + identified independently. The valid number of faceIds is between [1, 10]. Required. + :paramtype face_ids: list[str] + :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by + "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be + provided at the same time. Required. + :paramtype large_person_group_id: str + :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 + and 100. Default value is 10. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword confidence_threshold: Customized identification confidence threshold, in the range of + [0, 1]. Advanced user can tweak this value to override default internal threshold for better + precision on their scenario data. Note there is no guarantee of this threshold value working on + other data and after algorithm updates. Default value is None. + :paramtype confidence_threshold: float + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1237,14 +1220,34 @@ async def get_face( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargeFaceListFace] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.FaceIdentificationResult]] = kwargs.pop("cls", None) - _request = build_large_face_list_get_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, + if body is _Unset: + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + if large_person_group_id is _Unset: + raise TypeError("missing required argument: large_person_group_id") + body = { + "confidenceThreshold": confidence_threshold, + "faceIds": face_ids, + "largePersonGroupId": large_person_group_id, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_identify_from_large_person_group_request( + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -1255,7 +1258,7 @@ async def get_face( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1268,13 +1271,13 @@ async def get_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargeFaceListFace, response.json()) + deserialized = _deserialize(List[_models.FaceIdentificationResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1282,119 +1285,107 @@ async def get_face( return deserialized # type: ignore @overload - async def update_face( + async def verify_from_large_person_group( self, - large_face_list_id: str, - persisted_face_id: str, - body: JSON, *, + face_id: str, + large_person_group_id: str, + person_id: str, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. - :type body: JSON + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. + + :keyword face_id: The faceId of the face, come from "Detect". Required. + :paramtype face_id: str + :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading + a specified person. largePersonGroupId is created in "Create Large Person Group". Required. + :paramtype large_person_group_id: str + :keyword person_id: Specify a certain person in Large Person Group. Required. + :paramtype person_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update_face( - self, - large_face_list_id: str, - persisted_face_id: str, - *, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + async def verify_from_large_person_group( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. + + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update_face( - self, - large_face_list_id: str, - persisted_face_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + async def verify_from_large_person_group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update_face( + async def verify_from_large_person_group( self, - large_face_list_id: str, - persisted_face_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - user_data: Optional[str] = None, + face_id: str = _Unset, + large_person_group_id: str = _Unset, + person_id: str = _Unset, **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None + :keyword face_id: The faceId of the face, come from "Detect". Required. + :paramtype face_id: str + :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading + a specified person. largePersonGroupId is created in "Create Large Person Group". Required. + :paramtype large_person_group_id: str + :keyword person_id: Specify a certain person in Large Person Group. Required. + :paramtype person_id: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1409,10 +1400,16 @@ async def update_face( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) if body is _Unset: - body = {"userData": user_data} + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if large_person_group_id is _Unset: + raise TypeError("missing required argument: large_person_group_id") + if person_id is _Unset: + raise TypeError("missing required argument: person_id") + body = {"faceId": face_id, "largePersonGroupId": large_person_group_id, "personId": person_id} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -1421,9 +1418,7 @@ async def update_face( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_update_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, + _request = build_face_verify_from_large_person_group_request( content_type=content_type, content=_content, headers=_headers, @@ -1435,91 +1430,27 @@ async def update_face( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get_faces( - self, large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LargeFaceListFace]: - """List faces' persistedFaceId and userData in a specified Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-faces for - more details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LargeFaceListFace - :rtype: list[~azure.ai.vision.face.models.LargeFaceListFace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LargeFaceListFace]] = kwargs.pop("cls", None) - - _request = build_large_face_list_get_faces_request( - large_face_list_id=large_face_list_id, - start=start, - top=top, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LargeFaceListFace], response.json()) + deserialized = _deserialize(_models.FaceVerificationResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1527,147 +1458,91 @@ async def get_faces( return deserialized # type: ignore -class LargePersonGroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.vision.face.aio.FaceAdministrationClient`'s - :attr:`large_person_group` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") +class FaceSessionClientOperationsMixin(ClientMixinABC[AsyncPipelineClient, FaceSessionClientConfiguration]): @overload - async def create( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. + async def create_liveness_session( + self, body: _models.CreateLivenessSessionContent, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON + :param body: Body parameter. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create( - self, - large_person_group_id: str, - *, - name: str, - content_type: str = "application/json", - user_data: Optional[str] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. + async def create_liveness_session( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str + :param body: Body parameter. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. + async def create_liveness_session( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. + :param body: Body parameter. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create( - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - user_data: Optional[str] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["content_type", "accept"]}, + ) + async def create_liveness_session( + self, body: Union[_models.CreateLivenessSessionContent, JSON, IO[bytes]], **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None + :param body: Body parameter. Is one of the following types: CreateLivenessSessionContent, JSON, + IO[bytes] Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent or JSON or IO[bytes] + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1682,13 +1557,8 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None if isinstance(body, (IOBase, bytes)): @@ -1696,8 +1566,7 @@ async def create( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_person_group_create_request( - large_person_group_id=large_person_group_id, + _request = build_face_session_create_liveness_session_request( content_type=content_type, content=_content, headers=_headers, @@ -1709,29 +1578,48 @@ async def create( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LivenessSession, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def delete(self, large_person_group_id: str, **kwargs: Any) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group for - more details. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + async def delete_liveness_session(self, session_id: str, **kwargs: Any) -> None: + """Delete all session related information for matching the specified session id. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-session + `_ + for more details. + + :param session_id: The unique ID to reference this session. Required. + :type session_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1749,8 +1637,8 @@ async def delete(self, large_person_group_id: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_large_person_group_delete_request( - large_person_group_id=large_person_group_id, + _request = build_face_session_delete_liveness_session_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -1761,35 +1649,35 @@ async def delete(self, large_person_group_id: str, **kwargs: Any) -> None: _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get( - self, large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any - ) -> _models.LargePersonGroup: + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + async def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models.LivenessSession: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-result + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: LargePersonGroup. The LargePersonGroup is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroup + :param session_id: The unique ID to reference this session. Required. + :type session_id: str + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1803,11 +1691,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargePersonGroup] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) - _request = build_large_person_group_get_request( - large_person_group_id=large_person_group_id, - return_recognition_model=return_recognition_model, + _request = build_face_session_get_liveness_session_result_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -1818,7 +1705,7 @@ async def get( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1831,13 +1718,13 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargePersonGroup, response.json()) + deserialized = _deserialize(_models.LivenessSession, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1845,99 +1732,62 @@ async def get( return deserialized # type: ignore @overload - async def update( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def create_liveness_with_verify_session( + self, body: _models.CreateLivenessWithVerifySessionContent, **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. - @overload - async def update( - self, - large_person_group_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + :param body: Request content of liveness with verify session creation. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. + async def create_liveness_with_verify_session(self, body: JSON, **kwargs: Any) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. + + :param body: Request content of liveness with verify session creation. Required. + :type body: JSON + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["content_type", "accept"]}, + ) + async def create_liveness_with_verify_session( + self, body: Union[_models.CreateLivenessWithVerifySessionContent, JSON], **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. + + :param body: Request content of liveness with verify session creation. Is either a + CreateLivenessWithVerifySessionContent type or a JSON type. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1948,26 +1798,28 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) - if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _body = body.as_dict() if isinstance(body, _Model) else body + _file_fields: List[str] = ["verifyImage"] + _data_fields: List[str] = [ + "livenessOperationMode", + "deviceCorrelationIdSetInClient", + "enableSessionImage", + "livenessModelVersion", + "returnVerifyImageHash", + "verifyConfidenceThreshold", + "deviceCorrelationId", + "authTokenTimeToLiveInSeconds", + ] + _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_large_person_group_update_request( - large_person_group_id=large_person_group_id, - content_type=content_type, - content=_content, + _request = build_face_session_create_liveness_with_verify_session_request( + files=_files, + data=_data, headers=_headers, params=_params, ) @@ -1977,47 +1829,50 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def get_large_person_groups( - self, - *, - start: Optional[str] = None, - top: Optional[int] = None, - return_recognition_model: Optional[bool] = None, - **kwargs: Any - ) -> List[_models.LargePersonGroup]: - """List all existing Large Person Groups' largePersonGroupId, name, userData and recognitionModel. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + async def delete_liveness_with_verify_session(self, session_id: str, **kwargs: Any) -> None: + """Delete all session related information for matching the specified session id. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-groups for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-with-verify-session + `_ + for more details. - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: list of LargePersonGroup - :rtype: list[~azure.ai.vision.face.models.LargePersonGroup] + :param session_id: The unique ID to reference this session. Required. + :type session_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2031,12 +1886,10 @@ async def get_large_person_groups( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LargePersonGroup]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_large_person_group_get_large_person_groups_request( - start=start, - top=top, - return_recognition_model=return_recognition_model, + _request = build_face_session_delete_liveness_with_verify_session_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -2046,46 +1899,39 @@ async def get_large_person_groups( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.LargePersonGroup], response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get_training_status(self, large_person_group_id: str, **kwargs: Any) -> _models.FaceTrainingResult: - """To check Large Person Group training status completed or still ongoing. Large Person Group - training is an asynchronous operation triggered by "Train Large Person Group" API. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-training-status + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + async def get_liveness_with_verify_session_result( + self, session_id: str, **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-result + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceTrainingResult + :param session_id: The unique ID to reference this session. Required. + :type session_id: str + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2099,10 +1945,10 @@ async def get_training_status(self, large_person_group_id: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) - _request = build_large_person_group_get_training_status_request( - large_person_group_id=large_person_group_id, + _request = build_face_session_get_liveness_with_verify_session_result_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -2113,7 +1959,7 @@ async def get_training_status(self, large_person_group_id: str, **kwargs: Any) - _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2126,667 +1972,13 @@ async def get_training_status(self, large_person_group_id: str, **kwargs: Any) - except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceTrainingResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _train_initial(self, large_person_group_id: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_large_person_group_train_request( - large_person_group_id=large_person_group_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_train(self, large_person_group_id: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Submit a Large Person Group training task. Training is a crucial step that only a trained Large - Person Group can be used by "Identify From Large Person Group". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/train-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :return: An instance of AsyncLROPoller that returns None - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._train_initial( - large_person_group_id=large_person_group_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - async def create_person( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_person( - self, - large_person_group_id: str, - *, - name: str, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_person( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_person( - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - user_data: Optional[str] = None, - **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreatePersonResult] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_create_person_request( - large_person_group_id=large_person_group_id, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreatePersonResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_person(self, large_person_group_id: str, person_id: str, **kwargs: Any) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_large_person_group_delete_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get_person( - self, large_person_group_id: str, person_id: str, **kwargs: Any - ) -> _models.LargePersonGroupPerson: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :return: LargePersonGroupPerson. The LargePersonGroupPerson is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroupPerson - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.LargePersonGroupPerson] = kwargs.pop("cls", None) - - _request = build_large_person_group_get_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.LargePersonGroupPerson, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update_person( - self, - large_person_group_id: str, - person_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_person( - self, - large_person_group_id: str, - person_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_person( - self, - large_person_group_id: str, - person_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_person( - self, - large_person_group_id: str, - person_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_update_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get_persons( - self, large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LargePersonGroupPerson]: - """List all persons' information in the specified Large Person Group, including personId, name, - userData and persistedFaceIds of registered person faces. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-persons - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LargePersonGroupPerson - :rtype: list[~azure.ai.vision.face.models.LargePersonGroupPerson] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LargePersonGroupPerson]] = kwargs.pop("cls", None) - - _request = build_large_person_group_get_persons_request( - large_person_group_id=large_person_group_id, - start=start, - top=top, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.LargePersonGroupPerson], response.json()) + deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2794,177 +1986,273 @@ async def get_persons( return deserialized # type: ignore @overload - async def add_face_from_url( + async def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, - body: JSON, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + session_image_id: str, content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Required. - :type body: JSON - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str + :keyword session_image_id: Id of session image. Required. + :paramtype session_image_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def add_face_from_url( + async def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, + body: JSON, *, - url: str, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def add_face_from_url( + async def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, body: IO[bytes], *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str :param body: Required. :type body: IO[bytes] - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def add_face_from_url( + @api_version_validation( + method_added_on="v1.2-preview.1", + params_added_on={ + "v1.2-preview.1": [ + "content_type", + "detection_model", + "recognition_model", + "return_face_id", + "return_face_attributes", + "return_face_landmarks", + "return_recognition_model", + "face_id_time_to_live", + "accept", + ] + }, + ) + async def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - url: str = _Unset, - target_face: Optional[List[int]] = None, + session_image_id: str = _Unset, detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] + :keyword session_image_id: Id of session image. Required. + :paramtype session_image_id: str :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2978,13 +2266,13 @@ async def add_face_from_url( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + if session_image_id is _Unset: + raise TypeError("missing required argument: session_image_id") + body = {"sessionImageId": session_image_id} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -2993,12 +2281,14 @@ async def add_face_from_url( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_person_group_add_face_from_url_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - target_face=target_face, + _request = build_face_session_detect_from_session_image_request( detection_model=detection_model, - user_data=user_data, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, + return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, content_type=content_type, content=_content, headers=_headers, @@ -3011,7 +2301,7 @@ async def add_face_from_url( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3024,13 +2314,13 @@ async def add_face_from_url( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3038,42 +2328,20 @@ async def add_face_from_url( return deserialized # type: ignore @distributed_trace_async - async def add_face( - self, - large_person_group_id: str, - person_id: str, - image_content: bytes, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face - for more details. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_image_id", "accept"]}, + ) + async def get_session_image(self, session_image_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + """Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-session-image + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param image_content: The image to be analyzed. Required. - :type image_content: bytes - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :param session_image_id: The request ID of the image to be retrieved. Required. + :type session_image_id: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3084,22 +2352,13 @@ async def add_face( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - - _content = image_content + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_large_person_group_add_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, - content_type=content_type, - content=_content, + _request = build_face_session_get_session_image_request( + session_image_id=session_image_id, headers=_headers, params=_params, ) @@ -3109,8 +2368,8 @@ async def add_face( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3123,36 +2382,167 @@ async def add_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class LargeFaceListOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.vision.face.aio.FaceAdministrationClient`'s + :attr:`large_face_list` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FaceAdministrationClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create( + self, + large_face_list_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + **kwargs: Any + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + async def create( + self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. - return deserialized # type: ignore + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def delete_face( - self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any + async def create( + self, + large_face_list_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + **kwargs: Any ) -> None: - """Delete a face from a person in a Large Person Group by specified largePersonGroupId, personId - and persistedFaceId. + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -3165,15 +2555,28 @@ async def delete_face( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_large_person_group_delete_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_face_list_create_request( + large_face_list_id=large_face_list_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -3192,29 +2595,26 @@ async def delete_face( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get_face( - self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any - ) -> _models.LargePersonGroupPersonFace: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person-face - for more details. + async def delete(self, large_face_list_id: str, **kwargs: Any) -> None: + """Delete a face from a Large Face List by specified largeFaceListId and persistedFaceId. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: LargePersonGroupPersonFace. The LargePersonGroupPersonFace is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroupPersonFace + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3228,12 +2628,10 @@ async def get_face( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargePersonGroupPersonFace] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_large_person_group_get_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, + _request = build_large_face_list_delete_request( + large_face_list_id=large_face_list_id, headers=_headers, params=_params, ) @@ -3243,7 +2641,7 @@ async def get_face( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3251,147 +2649,30 @@ async def get_face( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.LargePersonGroupPersonFace, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - *, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get( + self, large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any + ) -> _models.LargeFaceList: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list + `_ for more + details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: LargeFaceList. The LargeFaceList is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargeFaceList :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3402,28 +2683,14 @@ async def update_face( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargeFaceList] = kwargs.pop("cls", None) - _request = build_large_person_group_update_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, - content_type=content_type, - content=_content, + _request = build_large_face_list_get_request( + large_face_list_id=large_face_list_id, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -3433,7 +2700,7 @@ async def update_face( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3441,121 +2708,127 @@ async def update_face( response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LargeFaceList, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore -class FaceClientOperationsMixin(FaceClientMixinABC): + return deserialized # type: ignore @overload - async def _detect_from_url( + async def update( self, - body: JSON, + large_face_list_id: str, *, content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, + name: Optional[str] = None, + user_data: Optional[str] = None, **kwargs: Any - ) -> List[_models.FaceDetectionResult]: ... + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _detect_from_url( - self, - *, - url: str, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: ... + async def update( + self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _detect_from_url( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: ... + async def update( + self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def _detect_from_url( + async def update( self, + large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - url: str = _Unset, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, + name: Optional[str] = None, + user_data: Optional[str] = None, **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url for more - details. + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3569,29 +2842,21 @@ async def _detect_from_url( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + body = {"name": name, "userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_face_detect_from_url_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_face_list_update_request( + large_face_list_id=large_face_list_id, content_type=content_type, content=_content, headers=_headers, @@ -3603,88 +2868,48 @@ async def _detect_from_url( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def _detect( + async def get_large_face_lists( self, - image_content: bytes, *, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, + start: Optional[str] = None, + top: Optional[int] = None, return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + ) -> List[_models.LargeFaceList]: + """List Large Face Lists' information of largeFaceListId, name, userData and recognitionModel. - Please refer to https://learn.microsoft.com/rest/api/face/face-detection-operations/detect for + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-lists + `_ for more details. - :param image_content: The input image binary. Required. - :type image_content: bytes - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. + false. Default value is None. :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :return: list of LargeFaceList + :rtype: list[~azure.ai.vision.face.models.LargeFaceList] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3695,24 +2920,15 @@ async def _detect( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) - - _content = image_content + cls: ClsType[List[_models.LargeFaceList]] = kwargs.pop("cls", None) - _request = build_face_detect_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, + _request = build_large_face_list_get_large_face_lists_request( + start=start, + top=top, return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - content_type=content_type, - content=_content, headers=_headers, params=_params, ) @@ -3723,7 +2939,7 @@ async def _detect( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3736,175 +2952,48 @@ async def _detect( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + deserialized = _deserialize(List[_models.LargeFaceList], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def find_similar( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. - - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def find_similar( - self, - *, - face_id: str, - face_ids: List[str], - content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, - **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. - - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the - faceIds will expire 24 hours after the detection call. The number of faceIds is limited to - 1000. Required. - :paramtype face_ids: list[str] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def find_similar( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. - - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def find_similar( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - face_id: str = _Unset, - face_ids: List[str] = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, - **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. + async def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models.FaceTrainingResult: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-training-status + `_ + for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the - faceIds will expire 24 hours after the detection call. The number of faceIds is limited to - 1000. Required. - :paramtype face_ids: list[str] - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceTrainingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) - - if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - body = { - "faceId": face_id, - "faceIds": face_ids, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - "mode": mode, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_face_find_similar_request( - content_type=content_type, - content=_content, + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) + + _request = build_large_face_list_get_training_status_request( + large_face_list_id=large_face_list_id, headers=_headers, params=_params, ) @@ -3915,7 +3004,7 @@ async def find_similar( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3928,99 +3017,295 @@ async def find_similar( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) + deserialized = _deserialize(_models.FaceTrainingResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def verify_face_to_face( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. + async def _train_initial(self, large_face_list_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_large_face_list_train_request( + large_face_list_id=large_face_list_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_train(self, large_face_list_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Submit a Large Face List training task. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for + `https://learn.microsoft.com/rest/api/face/face-list-operations/train-large-face-list + `_ for more details. - :param body: Required. - :type body: JSON + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._train_initial( + large_face_list_id=large_face_list_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def add_face_from_url( + self, + large_face_list_id: str, + *, + url: str, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def verify_face_to_face( - self, *, face_id1: str, face_id2: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. + async def add_face_from_url( + self, + large_face_list_id: str, + body: JSON, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. - :keyword face_id1: The faceId of one face, come from "Detect". Required. - :paramtype face_id1: str - :keyword face_id2: The faceId of another face, come from "Detect". Required. - :paramtype face_id2: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def verify_face_to_face( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. + async def add_face_from_url( + self, + large_face_list_id: str, + body: IO[bytes], + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Required. :type body: IO[bytes] + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def verify_face_to_face( - self, body: Union[JSON, IO[bytes]] = _Unset, *, face_id1: str = _Unset, face_id2: str = _Unset, **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. + async def add_face_from_url( + self, + large_face_list_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + url: str = _Unset, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword face_id1: The faceId of one face, come from "Detect". Required. - :paramtype face_id1: str - :keyword face_id2: The faceId of another face, come from "Detect". Required. - :paramtype face_id2: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4035,14 +3320,12 @@ async def verify_face_to_face( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) if body is _Unset: - if face_id1 is _Unset: - raise TypeError("missing required argument: face_id1") - if face_id2 is _Unset: - raise TypeError("missing required argument: face_id2") - body = {"faceId1": face_id1, "faceId2": face_id2} + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -4051,7 +3334,11 @@ async def verify_face_to_face( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_verify_face_to_face_request( + _request = build_large_face_list_add_face_from_url_request( + large_face_list_id=large_face_list_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, content_type=content_type, content=_content, headers=_headers, @@ -4064,7 +3351,7 @@ async def verify_face_to_face( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4077,93 +3364,130 @@ async def verify_face_to_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceVerificationResult, response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def group( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + @distributed_trace_async + async def add_face( + self, + large_face_list_id: str, + image_content: bytes, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face + `_ for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param image_content: The image to be analyzed. Required. + :type image_content: bytes + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def group( - self, *, face_ids: List[str], content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. - Required. - :paramtype face_ids: list[str] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + _content = image_content - @overload - async def group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + _request = build_large_face_list_add_face_request( + large_face_list_id=large_face_list_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + response = pipeline_response.http_response - @distributed_trace_async - async def group( - self, body: Union[JSON, IO[bytes]] = _Unset, *, face_ids: List[str] = _Unset, **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AddFaceResult, response.json()) - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. - Required. - :paramtype face_ids: list[str] - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list-face + `_ + for more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4174,27 +3498,72 @@ async def group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceGroupingResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - if body is _Unset: - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - body = {"faceIds": face_ids} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_large_face_list_delete_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_face( + self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any + ) -> _models.LargeFaceListFace: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-face + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: LargeFaceListFace. The LargeFaceListFace is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargeFaceListFace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_face_group_request( - content_type=content_type, - content=_content, + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LargeFaceListFace] = kwargs.pop("cls", None) + + _request = build_large_face_list_get_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, headers=_headers, params=_params, ) @@ -4205,7 +3574,7 @@ async def group( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4218,13 +3587,13 @@ async def group( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceGroupingResult, response.json()) + deserialized = _deserialize(_models.LargeFaceListFace, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4232,123 +3601,123 @@ async def group( return deserialized # type: ignore @overload - async def find_similar_from_large_face_list( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + async def update_face( + self, + large_face_list_id: str, + persisted_face_id: str, + *, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. - :param body: Required. - :type body: JSON + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def find_similar_from_large_face_list( + async def update_face( self, - *, - face_id: str, large_face_list_id: str, + persisted_face_id: str, + body: JSON, + *, content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, - created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which - are persisted and will never expire. Required. - :paramtype large_face_list_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def find_similar_from_large_face_list( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + async def update_face( + self, + large_face_list_id: str, + persisted_face_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def find_similar_from_large_face_list( + async def update_face( self, + large_face_list_id: str, + persisted_face_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - face_id: str = _Unset, - large_face_list_id: str = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + user_data: Optional[str] = None, **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, - created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which - are persisted and will never expire. Required. - :paramtype large_face_list_id: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4363,19 +3732,10 @@ async def find_similar_from_large_face_list( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if large_face_list_id is _Unset: - raise TypeError("missing required argument: large_face_list_id") - body = { - "faceId": face_id, - "largeFaceListId": large_face_list_id, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - "mode": mode, - } + body = {"userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -4384,7 +3744,9 @@ async def find_similar_from_large_face_list( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_find_similar_from_large_face_list_request( + _request = build_large_face_list_update_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, content_type=content_type, content=_content, headers=_headers, @@ -4396,8 +3758,73 @@ async def find_similar_from_large_face_list( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_faces( + self, large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> List[_models.LargeFaceListFace]: + """List faces' persistedFaceId and userData in a specified Large Face List. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-faces + `_ + for more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :return: list of LargeFaceListFace + :rtype: list[~azure.ai.vision.face.models.LargeFaceListFace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LargeFaceListFace]] = kwargs.pop("cls", None) + + _request = build_large_face_list_get_faces_request( + large_face_list_id=large_face_list_id, + start=start, + top=top, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4410,139 +3837,165 @@ async def find_similar_from_large_face_list( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) + deserialized = _deserialize(List[_models.LargeFaceListFace], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class LargePersonGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.vision.face.aio.FaceAdministrationClient`'s + :attr:`large_person_group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FaceAdministrationClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload - async def identify_from_large_person_group( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + async def create( + self, + large_person_group_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + **kwargs: Any + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. - :param body: Required. - :type body: JSON + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def identify_from_large_person_group( - self, - *, - face_ids: List[str], - large_person_group_id: str, - content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - confidence_threshold: Optional[float] = None, - **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + async def create( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. - :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are - identified independently. The valid number of faceIds is between [1, 10]. Required. - :paramtype face_ids: list[str] - :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by - "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be - provided at the same time. Required. - :paramtype large_person_group_id: str + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 - and 100. Default value is 10. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword confidence_threshold: Customized identification confidence threshold, in the range of - [0, 1]. Advanced user can tweak this value to override default internal threshold for better - precision on their scenario data. Note there is no guarantee of this threshold value working on - other data and after algorithm updates. Default value is None. - :paramtype confidence_threshold: float - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def identify_from_large_person_group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + async def create( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def identify_from_large_person_group( + async def create( self, + large_person_group_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - face_ids: List[str] = _Unset, - large_person_group_id: str = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - confidence_threshold: Optional[float] = None, + name: str = _Unset, + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are - identified independently. The valid number of faceIds is between [1, 10]. Required. - :paramtype face_ids: list[str] - :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by - "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be - provided at the same time. Required. - :paramtype large_person_group_id: str - :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 - and 100. Default value is 10. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword confidence_threshold: Customized identification confidence threshold, in the range of - [0, 1]. Advanced user can tweak this value to override default internal threshold for better - precision on their scenario data. Note there is no guarantee of this threshold value working on - other data and after algorithm updates. Default value is None. - :paramtype confidence_threshold: float - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4557,19 +4010,12 @@ async def identify_from_large_person_group( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceIdentificationResult]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - if large_person_group_id is _Unset: - raise TypeError("missing required argument: large_person_group_id") - body = { - "confidenceThreshold": confidence_threshold, - "faceIds": face_ids, - "largePersonGroupId": large_person_group_id, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - } + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -4578,7 +4024,8 @@ async def identify_from_large_person_group( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_identify_from_large_person_group_request( + _request = build_large_person_group_create_request( + large_person_group_id=large_person_group_id, content_type=content_type, content=_content, headers=_headers, @@ -4590,131 +4037,89 @@ async def identify_from_large_person_group( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.FaceIdentificationResult], response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def verify_from_large_person_group( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + return cls(pipeline_response, None, {}) # type: ignore - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + @distributed_trace_async + async def delete(self, large_person_group_id: str, **kwargs: Any) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group + `_ for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def verify_from_large_person_group( - self, - *, - face_id: str, - large_person_group_id: str, - person_id: str, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group - for more details. + cls: ClsType[None] = kwargs.pop("cls", None) - :keyword face_id: The faceId of the face, come from "Detect". Required. - :paramtype face_id: str - :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading - a specified person. largePersonGroupId is created in "Create Large Person Group". Required. - :paramtype large_person_group_id: str - :keyword person_id: Specify a certain person in Large Person Group. Required. - :paramtype person_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + _request = build_large_person_group_delete_request( + large_person_group_id=large_person_group_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - @overload - async def verify_from_large_person_group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group - for more details. + response = pipeline_response.http_response - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) - @distributed_trace_async - async def verify_from_large_person_group( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - face_id: str = _Unset, - large_person_group_id: str = _Unset, - person_id: str = _Unset, - **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + if cls: + return cls(pipeline_response, None, {}) # type: ignore - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + @distributed_trace_async + async def get( + self, large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any + ) -> _models.LargePersonGroup: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_id: The faceId of the face, come from "Detect". Required. - :paramtype face_id: str - :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading - a specified person. largePersonGroupId is created in "Create Large Person Group". Required. - :paramtype large_person_group_id: str - :keyword person_id: Specify a certain person in Large Person Group. Required. - :paramtype person_id: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: LargePersonGroup. The LargePersonGroup is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4725,31 +4130,14 @@ async def verify_from_large_person_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) - - if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if large_person_group_id is _Unset: - raise TypeError("missing required argument: large_person_group_id") - if person_id is _Unset: - raise TypeError("missing required argument: person_id") - body = {"faceId": face_id, "largePersonGroupId": large_person_group_id, "personId": person_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargePersonGroup] = kwargs.pop("cls", None) - _request = build_face_verify_from_large_person_group_request( - content_type=content_type, - content=_content, + _request = build_large_person_group_get_request( + large_person_group_id=large_person_group_id, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -4760,7 +4148,7 @@ async def verify_from_large_person_group( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4773,101 +4161,117 @@ async def verify_from_large_person_group( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceVerificationResult, response.json()) + deserialized = _deserialize(_models.LargePersonGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class FaceSessionClientOperationsMixin(FaceSessionClientMixinABC): - @overload - async def create_liveness_session( - self, body: _models.CreateLivenessSessionContent, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + async def update( + self, + large_person_group_id: str, + *, + content_type: str = "application/json", + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_liveness_session( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + async def update( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_liveness_session( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + async def update( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_liveness_session( - self, body: Union[_models.CreateLivenessSessionContent, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + async def update( + self, + large_person_group_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Is one of the following types: CreateLivenessSessionContent, JSON, - IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent or JSON or IO[bytes] - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4882,8 +4286,11 @@ async def create_liveness_session( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreateLivenessSessionResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) + if body is _Unset: + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None if isinstance(body, (IOBase, bytes)): @@ -4891,7 +4298,8 @@ async def create_liveness_session( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_session_create_liveness_session_request( + _request = build_large_person_group_update_request( + large_person_group_id=large_person_group_id, content_type=content_type, content=_content, headers=_headers, @@ -4903,45 +4311,48 @@ async def create_liveness_session( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreateLivenessSessionResult, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def delete_liveness_session(self, session_id: str, **kwargs: Any) -> None: - """Delete all session related information for matching the specified session id. + async def get_large_person_groups( + self, + *, + start: Optional[str] = None, + top: Optional[int] = None, + return_recognition_model: Optional[bool] = None, + **kwargs: Any + ) -> List[_models.LargePersonGroup]: + """List all existing Large Person Groups' largePersonGroupId, name, userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-session + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-groups + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: None - :rtype: None + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: list of LargePersonGroup + :rtype: list[~azure.ai.vision.face.models.LargePersonGroup] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4955,10 +4366,12 @@ async def delete_liveness_session(self, session_id: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[List[_models.LargePersonGroup]] = kwargs.pop("cls", None) - _request = build_face_session_delete_liveness_session_request( - session_id=session_id, + _request = build_large_person_group_get_large_person_groups_request( + start=start, + top=top, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -4968,31 +4381,47 @@ async def delete_liveness_session(self, session_id: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.LargePersonGroup], response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_training_status(self, large_person_group_id: str, **kwargs: Any) -> _models.FaceTrainingResult: + """To check Large Person Group training status completed or still ongoing. Large Person Group + training is an asynchronous operation triggered by "Train Large Person Group" API. - @distributed_trace_async - async def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models.LivenessSession: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-result + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-training-status + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: LivenessSession. The LivenessSession is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LivenessSession + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceTrainingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5006,10 +4435,10 @@ async def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) + cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_session_result_request( - session_id=session_id, + _request = build_large_person_group_get_training_status_request( + large_person_group_id=large_person_group_id, headers=_headers, params=_params, ) @@ -5020,7 +4449,7 @@ async def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _ _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5033,39 +4462,20 @@ async def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _ except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LivenessSession, response.json()) + deserialized = _deserialize(_models.FaceTrainingResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_liveness_sessions( - self, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionItem]: - """Lists sessions for /detectLiveness/SingleModal. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-sessions for - more details. - - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionItem - :rtype: list[~azure.ai.vision.face.models.LivenessSessionItem] - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _train_initial(self, large_person_group_id: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5077,11 +4487,10 @@ async def get_liveness_sessions( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionItem]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_sessions_request( - start=start, - top=top, + _request = build_large_person_group_train_request( + large_person_group_id=large_person_group_id, headers=_headers, params=_params, ) @@ -5091,51 +4500,203 @@ async def get_liveness_sessions( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.LivenessSessionItem], response.json()) + response_headers = {} + response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def get_liveness_session_audit_entries( - self, session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionAuditEntry]: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-audit-entries + async def begin_train(self, large_person_group_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Submit a Large Person Group training task. Training is a crucial step that only a trained Large + Person Group can be used by "Identify From Large Person Group". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/train-large-person-group + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionAuditEntry - :rtype: list[~azure.ai.vision.face.models.LivenessSessionAuditEntry] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._train_initial( + large_person_group_id=large_person_group_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def create_person( + self, + large_person_group_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_person( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_person( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_person( + self, + large_person_group_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5146,15 +4707,28 @@ async def get_liveness_session_audit_entries( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionAuditEntry]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CreatePersonResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_session_audit_entries_request( - session_id=session_id, - start=start, - top=top, + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_create_person_request( + large_person_group_id=large_person_group_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -5165,7 +4739,7 @@ async def get_liveness_session_audit_entries( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5178,54 +4752,32 @@ async def get_liveness_session_audit_entries( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionAuditEntry], response.json()) + deserialized = _deserialize(_models.CreatePersonResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def _create_liveness_with_verify_session( - self, - body: _models.CreateLivenessWithVerifySessionContent, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - async def _create_liveness_with_verify_session( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - async def _create_liveness_with_verify_session( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @distributed_trace_async - async def _create_liveness_with_verify_session( - self, body: Union[_models.CreateLivenessWithVerifySessionContent, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Client device submits VerifyImage during the - /detectLivenessWithVerify/singleModal call. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session + async def delete_person(self, large_person_group_id: str, person_id: str, **kwargs: Any) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person + `_ for more details. - :param body: Body parameter. Is one of the following types: - CreateLivenessWithVerifySessionContent, JSON, IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON or - IO[bytes] - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5236,22 +4788,14 @@ async def _create_liveness_with_verify_session( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreateLivenessWithVerifySessionResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_create_liveness_with_verify_session_request( - content_type=content_type, - content=_content, + _request = build_large_person_group_delete_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, headers=_headers, params=_params, ) @@ -5261,59 +4805,36 @@ async def _create_liveness_with_verify_session( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreateLivenessWithVerifySessionResult, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: _models.CreateLivenessWithVerifySessionMultipartContent, **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - async def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: JSON, **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: Union[_models.CreateLivenessWithVerifySessionMultipartContent, JSON], **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Provide the verify image during session creation. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + async def get_person( + self, large_person_group_id: str, person_id: str, **kwargs: Any + ) -> _models.LargePersonGroupPerson: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person + `_ for more details. - :param body: Request content of liveness with verify session creation. Is either a - CreateLivenessWithVerifySessionMultipartContent type or a JSON type. Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionMultipartContent or - JSON - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :return: LargePersonGroupPerson. The LargePersonGroupPerson is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroupPerson :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5327,16 +4848,11 @@ async def _create_liveness_with_verify_session_with_verify_image( # pylint: dis _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.CreateLivenessWithVerifySessionResult] = kwargs.pop("cls", None) - - _body = body.as_dict() if isinstance(body, _model_base.Model) else body - _file_fields: List[str] = ["VerifyImage"] - _data_fields: List[str] = ["Parameters"] - _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) + cls: ClsType[_models.LargePersonGroupPerson] = kwargs.pop("cls", None) - _request = build_face_session_create_liveness_with_verify_session_with_verify_image_request( - files=_files, - data=_data, + _request = build_large_person_group_get_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, headers=_headers, params=_params, ) @@ -5347,7 +4863,7 @@ async def _create_liveness_with_verify_session_with_verify_image( # pylint: dis _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5360,29 +4876,137 @@ async def _create_liveness_with_verify_session_with_verify_image( # pylint: dis except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.CreateLivenessWithVerifySessionResult, response.json()) + deserialized = _deserialize(_models.LargePersonGroupPerson, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_liveness_with_verify_session(self, session_id: str, **kwargs: Any) -> None: - """Delete all session related information for matching the specified session id. + @overload + async def update_person( + self, + large_person_group_id: str, + person_id: str, + *, + content_type: str = "application/json", + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-with-verify-session + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_person( + self, + large_person_group_id: str, + person_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_person( + self, + large_person_group_id: str, + person_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_person( + self, + large_person_group_id: str, + person_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -5395,13 +5019,27 @@ async def delete_liveness_with_verify_session(self, session_id: str, **kwargs: A } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_delete_liveness_with_verify_session_request( - session_id=session_id, + if body is _Unset: + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_update_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -5412,7 +5050,7 @@ async def delete_liveness_with_verify_session(self, session_id: str, **kwargs: A _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5420,25 +5058,34 @@ async def delete_liveness_with_verify_session(self, session_id: str, **kwargs: A if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get_liveness_with_verify_session_result( - self, session_id: str, **kwargs: Any - ) -> _models.LivenessWithVerifySession: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-result + async def get_persons( + self, large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> List[_models.LargePersonGroupPerson]: + """List all persons' information in the specified Large Person Group, including personId, name, + userData and persistedFaceIds of registered person faces. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-persons + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :return: list of LargePersonGroupPerson + :rtype: list[~azure.ai.vision.face.models.LargePersonGroupPerson] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5452,10 +5099,12 @@ async def get_liveness_with_verify_session_result( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) + cls: ClsType[List[_models.LargePersonGroupPerson]] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_session_result_request( - session_id=session_id, + _request = build_large_person_group_get_persons_request( + large_person_group_id=large_person_group_id, + start=start, + top=top, headers=_headers, params=_params, ) @@ -5466,7 +5115,7 @@ async def get_liveness_with_verify_session_result( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5479,37 +5128,195 @@ async def get_liveness_with_verify_session_result( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) + deserialized = _deserialize(List[_models.LargePersonGroupPerson], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + *, + url: str, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: JSON, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: JSON + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: IO[bytes], + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: IO[bytes] + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def get_liveness_with_verify_sessions( - self, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionItem]: - """Lists sessions for /detectLivenessWithVerify/SingleModal. + async def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + url: str = _Unset, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-sessions + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ for more details. - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionItem - :rtype: list[~azure.ai.vision.face.models.LivenessSessionItem] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5520,14 +5327,32 @@ async def get_liveness_with_verify_sessions( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionItem]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_sessions_request( - start=start, - top=top, + if body is _Unset: + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_add_face_from_url_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -5538,7 +5363,7 @@ async def get_liveness_with_verify_sessions( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5551,13 +5376,13 @@ async def get_liveness_with_verify_sessions( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionItem], response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5565,23 +5390,43 @@ async def get_liveness_with_verify_sessions( return deserialized # type: ignore @distributed_trace_async - async def get_liveness_with_verify_session_audit_entries( # pylint: disable=name-too-long - self, session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionAuditEntry]: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-audit-entries + async def add_face( + self, + large_person_group_id: str, + person_id: str, + image_content: bytes, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionAuditEntry - :rtype: list[~azure.ai.vision.face.models.LivenessSessionAuditEntry] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param image_content: The image to be analyzed. Required. + :type image_content: bytes + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5592,15 +5437,22 @@ async def get_liveness_with_verify_session_audit_entries( # pylint: disable=nam } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionAuditEntry]] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_session_audit_entries_request( - session_id=session_id, - start=start, - top=top, + _content = image_content + + _request = build_large_person_group_add_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -5611,7 +5463,7 @@ async def get_liveness_with_verify_session_audit_entries( # pylint: disable=nam _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5624,283 +5476,100 @@ async def get_liveness_with_verify_session_audit_entries( # pylint: disable=nam except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionAuditEntry], response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def detect_from_session_image( - self, - body: JSON, - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + @distributed_trace_async + async def delete_face( + self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any + ) -> None: + """Delete a face from a person in a Large Person Group by specified largePersonGroupId, personId + and persistedFaceId. Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person-face + `_ for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def detect_from_session_image( - self, - *, - session_image_id: str, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id - for more details. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - :keyword session_image_id: Id of session image. Required. - :paramtype session_image_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + cls: ClsType[None] = kwargs.pop("cls", None) - @overload - async def detect_from_session_image( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + _request = build_large_person_group_delete_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id - for more details. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response = pipeline_response.http_response - @distributed_trace_async - @api_version_validation( - method_added_on="v1.2-preview.1", - params_added_on={ - "v1.2-preview.1": [ - "content_type", - "detection_model", - "recognition_model", - "return_face_id", - "return_face_attributes", - "return_face_landmarks", - "return_recognition_model", - "face_id_time_to_live", - "accept", - ] - }, - ) - async def detect_from_session_image( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - session_image_id: str = _Unset, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_face( + self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any + ) -> _models.LargePersonGroupPersonFace: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person-face + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword session_image_id: Id of session image. Required. - :paramtype session_image_id: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: LargePersonGroupPersonFace. The LargePersonGroupPersonFace is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroupPersonFace :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5911,34 +5580,15 @@ async def detect_from_session_image( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) - - if body is _Unset: - if session_image_id is _Unset: - raise TypeError("missing required argument: session_image_id") - body = {"sessionImageId": session_image_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargePersonGroupPersonFace] = kwargs.pop("cls", None) - _request = build_face_session_detect_from_session_image_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - content_type=content_type, - content=_content, + _request = build_large_person_group_get_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, headers=_headers, params=_params, ) @@ -5949,7 +5599,7 @@ async def detect_from_session_image( _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5962,33 +5612,145 @@ async def detect_from_session_image( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + deserialized = _deserialize(_models.LargePersonGroupPersonFace, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + *, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - @api_version_validation( - method_added_on="v1.2-preview.1", - params_added_on={"v1.2-preview.1": ["session_image_id", "accept"]}, - ) - async def get_session_image(self, session_image_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + user_data: Optional[str] = None, + **kwargs: Any + ) -> None: """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-session-image for - more details. + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. - :param session_image_id: The request ID of the image to be retrieved. Required. - :type session_image_id: str - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5999,13 +5761,28 @@ async def get_session_image(self, session_image_id: str, **kwargs: Any) -> Async } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_get_session_image_request( - session_image_id=session_image_id, + if body is _Unset: + body = {"userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_update_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -6015,29 +5792,17 @@ async def get_session_image(self, session_image_id: str, **kwargs: Any) -> Async } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_patch.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_patch.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/__init__.py index 420ac616cabd..e20550d78c35 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/__init__.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/__init__.py @@ -5,94 +5,93 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models import AccessoryItem -from ._models import AddFaceResult -from ._models import AuditLivenessResponseInfo -from ._models import AuditRequestInfo -from ._models import BlurProperties -from ._models import CreateLivenessSessionContent -from ._models import CreateLivenessSessionResult -from ._models import CreateLivenessWithVerifySessionContent -from ._models import CreateLivenessWithVerifySessionMultipartContent -from ._models import CreateLivenessWithVerifySessionResult -from ._models import CreatePersonResult -from ._models import ExposureProperties -from ._models import FaceAttributes -from ._models import FaceDetectionResult -from ._models import FaceError -from ._models import FaceErrorResponse -from ._models import FaceFindSimilarResult -from ._models import FaceGroupingResult -from ._models import FaceIdentificationCandidate -from ._models import FaceIdentificationResult -from ._models import FaceLandmarks -from ._models import FaceRectangle -from ._models import FaceTrainingResult -from ._models import FaceVerificationResult -from ._models import FacialHair -from ._models import HairColor -from ._models import HairProperties -from ._models import HeadPose -from ._models import LandmarkCoordinate -from ._models import LargeFaceList -from ._models import LargeFaceListFace -from ._models import LargePersonGroup -from ._models import LargePersonGroupPerson -from ._models import LargePersonGroupPersonFace -from ._models import LivenessOutputsTarget -from ._models import LivenessResponseBody -from ._models import LivenessSession -from ._models import LivenessSessionAuditEntry -from ._models import LivenessSessionItem -from ._models import LivenessWithVerifyImage -from ._models import LivenessWithVerifyOutputs -from ._models import LivenessWithVerifySession -from ._models import MaskProperties -from ._models import NoiseProperties -from ._models import OcclusionProperties +from typing import TYPE_CHECKING -from ._enums import AccessoryType -from ._enums import BlurLevel -from ._enums import ExposureLevel -from ._enums import FaceAttributeType -from ._enums import FaceDetectionModel -from ._enums import FaceImageType -from ._enums import FaceLivenessDecision -from ._enums import FaceOperationStatus -from ._enums import FaceRecognitionModel -from ._enums import FaceSessionStatus -from ._enums import FindSimilarMatchMode -from ._enums import GlassesType -from ._enums import HairColorType -from ._enums import LivenessModel -from ._enums import LivenessOperationMode -from ._enums import MaskType -from ._enums import NoiseLevel -from ._enums import QualityForRecognition -from ._enums import Versions +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import FaceAttributeTypeDetection01 -from ._patch import FaceAttributeTypeDetection03 -from ._patch import FaceAttributeTypeRecognition03 -from ._patch import FaceAttributeTypeRecognition04 + +from ._models import ( # type: ignore + AccessoryItem, + AddFaceResult, + BlurProperties, + CreateLivenessSessionContent, + CreateLivenessWithVerifySessionContent, + CreatePersonResult, + ExposureProperties, + FaceAttributes, + FaceDetectionResult, + FaceError, + FaceErrorResponse, + FaceFindSimilarResult, + FaceGroupingResult, + FaceIdentificationCandidate, + FaceIdentificationResult, + FaceLandmarks, + FaceRectangle, + FaceTrainingResult, + FaceVerificationResult, + FacialHair, + HairColor, + HairProperties, + HeadPose, + LandmarkCoordinate, + LargeFaceList, + LargeFaceListFace, + LargePersonGroup, + LargePersonGroupPerson, + LargePersonGroupPersonFace, + LivenessColorDecisionTarget, + LivenessDecisionTargets, + LivenessError, + LivenessResult, + LivenessSession, + LivenessSessionAttempt, + LivenessSessionResults, + LivenessWithVerifyOutputs, + LivenessWithVerifyReference, + LivenessWithVerifyResult, + LivenessWithVerifySession, + LivenessWithVerifySessionAttempt, + LivenessWithVerifySessionResults, + MaskProperties, + NoiseProperties, + OcclusionProperties, +) + +from ._enums import ( # type: ignore + AccessoryType, + BlurLevel, + ExposureLevel, + FaceAttributeType, + FaceDetectionModel, + FaceImageType, + FaceLivenessDecision, + FaceOperationStatus, + FaceRecognitionModel, + FindSimilarMatchMode, + GlassesType, + HairColorType, + LivenessModel, + LivenessOperationMode, + MaskType, + NoiseLevel, + OperationState, + QualityForRecognition, + Versions, +) +from ._patch import __all__ as _patch_all +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "FaceAttributeTypeDetection01", - "FaceAttributeTypeDetection03", - "FaceAttributeTypeRecognition03", - "FaceAttributeTypeRecognition04", "AccessoryItem", "AddFaceResult", - "AuditLivenessResponseInfo", - "AuditRequestInfo", "BlurProperties", "CreateLivenessSessionContent", - "CreateLivenessSessionResult", "CreateLivenessWithVerifySessionContent", - "CreateLivenessWithVerifySessionMultipartContent", - "CreateLivenessWithVerifySessionResult", "CreatePersonResult", "ExposureProperties", "FaceAttributes", @@ -117,14 +116,19 @@ "LargePersonGroup", "LargePersonGroupPerson", "LargePersonGroupPersonFace", - "LivenessOutputsTarget", - "LivenessResponseBody", + "LivenessColorDecisionTarget", + "LivenessDecisionTargets", + "LivenessError", + "LivenessResult", "LivenessSession", - "LivenessSessionAuditEntry", - "LivenessSessionItem", - "LivenessWithVerifyImage", + "LivenessSessionAttempt", + "LivenessSessionResults", "LivenessWithVerifyOutputs", + "LivenessWithVerifyReference", + "LivenessWithVerifyResult", "LivenessWithVerifySession", + "LivenessWithVerifySessionAttempt", + "LivenessWithVerifySessionResults", "MaskProperties", "NoiseProperties", "OcclusionProperties", @@ -137,7 +141,6 @@ "FaceLivenessDecision", "FaceOperationStatus", "FaceRecognitionModel", - "FaceSessionStatus", "FindSimilarMatchMode", "GlassesType", "HairColorType", @@ -145,8 +148,9 @@ "LivenessOperationMode", "MaskType", "NoiseLevel", + "OperationState", "QualityForRecognition", "Versions", ] - +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_enums.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_enums.py index 81c3a86b106d..3ccc2e2ed1c6 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_enums.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_enums.py @@ -148,17 +148,6 @@ class FaceRecognitionModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): better recognition accuracy.""" -class FaceSessionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of the session.""" - - NOT_STARTED = "NotStarted" - """Session has not started.""" - STARTED = "Started" - """Session has started.""" - RESULT_AVAILABLE = "ResultAvailable" - """Session has available result.""" - - class FindSimilarMatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Similar face searching mode.""" @@ -205,8 +194,7 @@ class HairColorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class LivenessModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The model version used for liveness classification.""" - V2022_10_15_PREVIEW04 = "2022-10-15-preview.04" - V2023_12_20_PREVIEW06 = "2023-12-20-preview.06" + V2024_11_15 = "2024-11-15" class LivenessOperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -251,6 +239,21 @@ class NoiseLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """High noise level.""" +class OperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum describing allowed operation states.""" + + NOT_STARTED = "NotStarted" + """The operation has not started.""" + RUNNING = "Running" + """The operation is in progress.""" + SUCCEEDED = "Succeeded" + """The operation has completed successfully.""" + FAILED = "Failed" + """The operation has failed.""" + CANCELED = "Canceled" + """The operation has been canceled by the user.""" + + class QualityForRecognition(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates quality of image for recognition.""" @@ -269,3 +272,5 @@ class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """v1.1-preview.1""" V1_2_PREVIEW1 = "v1.2-preview.1" """v1.2-preview.1""" + V1_2 = "v1.2" + """v1.2""" diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_models.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_models.py index df4774e39456..5440b7b84851 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_models.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_models.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,22 +6,21 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation import datetime from typing import Any, List, Mapping, Optional, TYPE_CHECKING, Union, overload -from .. import _model_base -from .._model_base import rest_field -from .._vendor import FileType +from .._utils.model_base import Model as _Model, rest_field +from .._utils.utils import FileType if TYPE_CHECKING: from .. import models as _models -class AccessoryItem(_model_base.Model): +class AccessoryItem(_Model): """Accessory item and corresponding confidence level. - :ivar type: Type of the accessory. Required. Known values are: "headwear", "glasses", and "mask". :vartype type: str or ~azure.ai.vision.face.models.AccessoryType @@ -29,9 +28,9 @@ class AccessoryItem(_model_base.Model): :vartype confidence: float """ - type: Union[str, "_models.AccessoryType"] = rest_field() + type: Union[str, "_models.AccessoryType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Type of the accessory. Required. Known values are: \"headwear\", \"glasses\", and \"mask\".""" - confidence: float = rest_field() + confidence: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Confidence level of the accessory type. Range between [0,1]. Required.""" @overload @@ -40,30 +39,31 @@ def __init__( *, type: Union[str, "_models.AccessoryType"], confidence: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AddFaceResult(_model_base.Model): +class AddFaceResult(_Model): """Response body for adding face. - :ivar persisted_face_id: Persisted Face ID of the added face, which is persisted and will not expire. Different from faceId which is created in "Detect" and will expire in 24 hours after the detection call. Required. :vartype persisted_face_id: str """ - persisted_face_id: str = rest_field(name="persistedFaceId") + persisted_face_id: str = rest_field( + name="persistedFaceId", visibility=["read", "create", "update", "delete", "query"] + ) """Persisted Face ID of the added face, which is persisted and will not expire. Different from faceId which is created in \"Detect\" and will expire in 24 hours after the detection call. Required.""" @@ -73,114 +73,22 @@ def __init__( self, *, persisted_face_id: str, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class AuditLivenessResponseInfo(_model_base.Model): - """Audit entry for a response in the session. - - - :ivar body: The response body. The schema of this field will depend on the request.url and - request.method used by the client. Required. - :vartype body: ~azure.ai.vision.face.models.LivenessResponseBody - :ivar status_code: The HTTP status code returned to the client. Required. - :vartype status_code: int - :ivar latency_in_milliseconds: The server measured latency for this request in milliseconds. - Required. - :vartype latency_in_milliseconds: int - """ - - body: "_models.LivenessResponseBody" = rest_field() - """The response body. The schema of this field will depend on the request.url and request.method - used by the client. Required.""" - status_code: int = rest_field(name="statusCode") - """The HTTP status code returned to the client. Required.""" - latency_in_milliseconds: int = rest_field(name="latencyInMilliseconds") - """The server measured latency for this request in milliseconds. Required.""" - - @overload - def __init__( - self, - *, - body: "_models.LivenessResponseBody", - status_code: int, - latency_in_milliseconds: int, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class AuditRequestInfo(_model_base.Model): - """Audit entry for a request in the session. - - - :ivar url: The relative URL and query of the liveness request. Required. - :vartype url: str - :ivar method: The HTTP method of the request (i.e., GET, POST, DELETE). Required. - :vartype method: str - :ivar content_length: The length of the request body in bytes. - :vartype content_length: int - :ivar content_type: The content type of the request. Required. - :vartype content_type: str - :ivar user_agent: The user agent used to submit the request. - :vartype user_agent: str - """ - - url: str = rest_field() - """The relative URL and query of the liveness request. Required.""" - method: str = rest_field() - """The HTTP method of the request (i.e., GET, POST, DELETE). Required.""" - content_length: Optional[int] = rest_field(name="contentLength") - """The length of the request body in bytes.""" - content_type: str = rest_field(name="contentType") - """The content type of the request. Required.""" - user_agent: Optional[str] = rest_field(name="userAgent") - """The user agent used to submit the request.""" - - @overload - def __init__( - self, - *, - url: str, - method: str, - content_type: str, - content_length: Optional[int] = None, - user_agent: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class BlurProperties(_model_base.Model): +class BlurProperties(_Model): """Properties describing any presence of blur within the image. - :ivar blur_level: An enum value indicating level of blurriness. Required. Known values are: "low", "medium", and "high". :vartype blur_level: str or ~azure.ai.vision.face.models.BlurLevel @@ -188,10 +96,12 @@ class BlurProperties(_model_base.Model): :vartype value: float """ - blur_level: Union[str, "_models.BlurLevel"] = rest_field(name="blurLevel") + blur_level: Union[str, "_models.BlurLevel"] = rest_field( + name="blurLevel", visibility=["read", "create", "update", "delete", "query"] + ) """An enum value indicating level of blurriness. Required. Known values are: \"low\", \"medium\", and \"high\".""" - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number indicating level of blurriness ranging from 0 to 1. Required.""" @overload @@ -200,42 +110,35 @@ def __init__( *, blur_level: Union[str, "_models.BlurLevel"], value: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CreateLivenessSessionContent(_model_base.Model): +class CreateLivenessSessionContent(_Model): """Request model for creating liveness session. - All required parameters must be populated in order to send to server. - :ivar liveness_operation_mode: Type of liveness mode the client should follow. Required. Known values are: "Passive" and "PassiveActive". :vartype liveness_operation_mode: str or ~azure.ai.vision.face.models.LivenessOperationMode - :ivar send_results_to_client: Whether or not to allow a '200 - Success' response body to be - sent to the client, which may be undesirable for security reasons. Default is false, clients - will receive a '204 - NoContent' empty body response. Regardless of selection, calling Session - GetResult will always contain a response body enabling business logic to be implemented. - :vartype send_results_to_client: bool :ivar device_correlation_id_set_in_client: Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body. :vartype device_correlation_id_set_in_client: bool :ivar enable_session_image: Whether or not store the session image. :vartype enable_session_image: bool - :ivar liveness_single_modal_model: The model version used for liveness classification. This is - an optional parameter, and if this is not specified, then the latest supported model version - will be chosen. Known values are: "2022-10-15-preview.04" and "2023-12-20-preview.06". - :vartype liveness_single_modal_model: str or ~azure.ai.vision.face.models.LivenessModel + :ivar liveness_model_version: The model version used for liveness classification. This is an + optional parameter, and if this is not specified, then the latest supported model version will + be chosen. "2024-11-15" + :vartype liveness_model_version: str or ~azure.ai.vision.face.models.LivenessModel :ivar device_correlation_id: Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. @@ -245,30 +148,34 @@ class CreateLivenessSessionContent(_model_base.Model): :vartype auth_token_time_to_live_in_seconds: int """ - liveness_operation_mode: Union[str, "_models.LivenessOperationMode"] = rest_field(name="livenessOperationMode") + liveness_operation_mode: Union[str, "_models.LivenessOperationMode"] = rest_field( + name="livenessOperationMode", visibility=["read", "create", "update", "delete", "query"] + ) """Type of liveness mode the client should follow. Required. Known values are: \"Passive\" and \"PassiveActive\".""" - send_results_to_client: Optional[bool] = rest_field(name="sendResultsToClient") - """Whether or not to allow a '200 - Success' response body to be sent to the client, which may be - undesirable for security reasons. Default is false, clients will receive a '204 - NoContent' - empty body response. Regardless of selection, calling Session GetResult will always contain a - response body enabling business logic to be implemented.""" - device_correlation_id_set_in_client: Optional[bool] = rest_field(name="deviceCorrelationIdSetInClient") + device_correlation_id_set_in_client: Optional[bool] = rest_field( + name="deviceCorrelationIdSetInClient", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body.""" - enable_session_image: Optional[bool] = rest_field(name="enableSessionImage") + enable_session_image: Optional[bool] = rest_field( + name="enableSessionImage", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not store the session image.""" - liveness_single_modal_model: Optional[Union[str, "_models.LivenessModel"]] = rest_field( - name="livenessSingleModalModel" + liveness_model_version: Optional[Union[str, "_models.LivenessModel"]] = rest_field( + name="livenessModelVersion", visibility=["read", "create", "update", "delete", "query"] ) """The model version used for liveness classification. This is an optional parameter, and if this - is not specified, then the latest supported model version will be chosen. Known values are: - \"2022-10-15-preview.04\" and \"2023-12-20-preview.06\".""" - device_correlation_id: Optional[str] = rest_field(name="deviceCorrelationId") + is not specified, then the latest supported model version will be chosen. \"2024-11-15\"""" + device_correlation_id: Optional[str] = rest_field( + name="deviceCorrelationId", visibility=["read", "create", "update", "delete", "query"] + ) """Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null.""" - auth_token_time_to_live_in_seconds: Optional[int] = rest_field(name="authTokenTimeToLiveInSeconds") + auth_token_time_to_live_in_seconds: Optional[int] = rest_field( + name="authTokenTimeToLiveInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) """Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.""" @overload @@ -276,89 +183,50 @@ def __init__( self, *, liveness_operation_mode: Union[str, "_models.LivenessOperationMode"], - send_results_to_client: Optional[bool] = None, device_correlation_id_set_in_client: Optional[bool] = None, enable_session_image: Optional[bool] = None, - liveness_single_modal_model: Optional[Union[str, "_models.LivenessModel"]] = None, + liveness_model_version: Optional[Union[str, "_models.LivenessModel"]] = None, device_correlation_id: Optional[str] = None, auth_token_time_to_live_in_seconds: Optional[int] = None, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class CreateLivenessSessionResult(_model_base.Model): - """Response of liveness session creation. - - - :ivar session_id: The unique session ID of the created session. It will expire 48 hours after - it was created or may be deleted sooner using the corresponding Session DELETE operation. - Required. - :vartype session_id: str - :ivar auth_token: Bearer token to provide authentication for the Vision SDK running on a client - application. This Bearer token has limited permissions to perform only the required action and - expires after the TTL time. It is also auditable. Required. - :vartype auth_token: str - """ - - session_id: str = rest_field(name="sessionId") - """The unique session ID of the created session. It will expire 48 hours after it was created or - may be deleted sooner using the corresponding Session DELETE operation. Required.""" - auth_token: str = rest_field(name="authToken") - """Bearer token to provide authentication for the Vision SDK running on a client application. This - Bearer token has limited permissions to perform only the required action and expires after the - TTL time. It is also auditable. Required.""" - - @overload - def __init__( - self, - *, - session_id: str, - auth_token: str, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CreateLivenessWithVerifySessionContent(_model_base.Model): - """Request for creating liveness with verify session. - - All required parameters must be populated in order to send to server. +class CreateLivenessWithVerifySessionContent(_Model): + """Request of liveness with verify session creation. :ivar liveness_operation_mode: Type of liveness mode the client should follow. Required. Known values are: "Passive" and "PassiveActive". :vartype liveness_operation_mode: str or ~azure.ai.vision.face.models.LivenessOperationMode - :ivar send_results_to_client: Whether or not to allow a '200 - Success' response body to be - sent to the client, which may be undesirable for security reasons. Default is false, clients - will receive a '204 - NoContent' empty body response. Regardless of selection, calling Session - GetResult will always contain a response body enabling business logic to be implemented. - :vartype send_results_to_client: bool :ivar device_correlation_id_set_in_client: Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body. :vartype device_correlation_id_set_in_client: bool :ivar enable_session_image: Whether or not store the session image. :vartype enable_session_image: bool - :ivar liveness_single_modal_model: The model version used for liveness classification. This is - an optional parameter, and if this is not specified, then the latest supported model version - will be chosen. Known values are: "2022-10-15-preview.04" and "2023-12-20-preview.06". - :vartype liveness_single_modal_model: str or ~azure.ai.vision.face.models.LivenessModel + :ivar liveness_model_version: The model version used for liveness classification. This is an + optional parameter, and if this is not specified, then the latest supported model version will + be chosen. "2024-11-15" + :vartype liveness_model_version: str or ~azure.ai.vision.face.models.LivenessModel + :ivar return_verify_image_hash: Whether or not return the verify image hash. + :vartype return_verify_image_hash: bool + :ivar verify_confidence_threshold: Threshold for confidence of the face verification. Please + refer to the documentation for more details. + `https://learn.microsoft.com/legal/cognitive-services/face/characteristics-and-limitations?context=%2Fazure%2Fai-services%2Fcomputer-vision%2Fcontext%2Fcontext#recognition-confidence-score + `_. + :vartype verify_confidence_threshold: float + :ivar verify_image: The image stream for verify. Content-Disposition header field for this part + must have filename. Required. + :vartype verify_image: ~azure.ai.vision.face._utils.utils.FileType :ivar device_correlation_id: Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null. @@ -366,160 +234,88 @@ class CreateLivenessWithVerifySessionContent(_model_base.Model): :ivar auth_token_time_to_live_in_seconds: Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600. :vartype auth_token_time_to_live_in_seconds: int - :ivar return_verify_image_hash: Whether or not return the verify image hash. - :vartype return_verify_image_hash: bool - :ivar verify_confidence_threshold: Threshold for confidence of the face verification. - :vartype verify_confidence_threshold: float """ - liveness_operation_mode: Union[str, "_models.LivenessOperationMode"] = rest_field(name="livenessOperationMode") + liveness_operation_mode: Union[str, "_models.LivenessOperationMode"] = rest_field( + name="livenessOperationMode", visibility=["read", "create", "update", "delete", "query"] + ) """Type of liveness mode the client should follow. Required. Known values are: \"Passive\" and \"PassiveActive\".""" - send_results_to_client: Optional[bool] = rest_field(name="sendResultsToClient") - """Whether or not to allow a '200 - Success' response body to be sent to the client, which may be - undesirable for security reasons. Default is false, clients will receive a '204 - NoContent' - empty body response. Regardless of selection, calling Session GetResult will always contain a - response body enabling business logic to be implemented.""" - device_correlation_id_set_in_client: Optional[bool] = rest_field(name="deviceCorrelationIdSetInClient") + device_correlation_id_set_in_client: Optional[bool] = rest_field( + name="deviceCorrelationIdSetInClient", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body.""" - enable_session_image: Optional[bool] = rest_field(name="enableSessionImage") + enable_session_image: Optional[bool] = rest_field( + name="enableSessionImage", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not store the session image.""" - liveness_single_modal_model: Optional[Union[str, "_models.LivenessModel"]] = rest_field( - name="livenessSingleModalModel" + liveness_model_version: Optional[Union[str, "_models.LivenessModel"]] = rest_field( + name="livenessModelVersion", visibility=["read", "create", "update", "delete", "query"] ) """The model version used for liveness classification. This is an optional parameter, and if this - is not specified, then the latest supported model version will be chosen. Known values are: - \"2022-10-15-preview.04\" and \"2023-12-20-preview.06\".""" - device_correlation_id: Optional[str] = rest_field(name="deviceCorrelationId") + is not specified, then the latest supported model version will be chosen. \"2024-11-15\"""" + return_verify_image_hash: Optional[bool] = rest_field( + name="returnVerifyImageHash", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not return the verify image hash.""" + verify_confidence_threshold: Optional[float] = rest_field( + name="verifyConfidenceThreshold", visibility=["read", "create", "update", "delete", "query"] + ) + """Threshold for confidence of the face verification. Please refer to the documentation for more + details. + `https://learn.microsoft.com/legal/cognitive-services/face/characteristics-and-limitations?context=%2Fazure%2Fai-services%2Fcomputer-vision%2Fcontext%2Fcontext#recognition-confidence-score + `_.""" + verify_image: FileType = rest_field( + name="verifyImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) + """The image stream for verify. Content-Disposition header field for this part must have filename. + Required.""" + device_correlation_id: Optional[str] = rest_field( + name="deviceCorrelationId", visibility=["read", "create", "update", "delete", "query"] + ) """Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null.""" - auth_token_time_to_live_in_seconds: Optional[int] = rest_field(name="authTokenTimeToLiveInSeconds") + auth_token_time_to_live_in_seconds: Optional[int] = rest_field( + name="authTokenTimeToLiveInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) """Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.""" - return_verify_image_hash: Optional[bool] = rest_field(name="returnVerifyImageHash") - """Whether or not return the verify image hash.""" - verify_confidence_threshold: Optional[float] = rest_field(name="verifyConfidenceThreshold") - """Threshold for confidence of the face verification.""" @overload def __init__( self, *, liveness_operation_mode: Union[str, "_models.LivenessOperationMode"], - send_results_to_client: Optional[bool] = None, + verify_image: FileType, device_correlation_id_set_in_client: Optional[bool] = None, enable_session_image: Optional[bool] = None, - liveness_single_modal_model: Optional[Union[str, "_models.LivenessModel"]] = None, - device_correlation_id: Optional[str] = None, - auth_token_time_to_live_in_seconds: Optional[int] = None, + liveness_model_version: Optional[Union[str, "_models.LivenessModel"]] = None, return_verify_image_hash: Optional[bool] = None, verify_confidence_threshold: Optional[float] = None, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class CreateLivenessWithVerifySessionMultipartContent(_model_base.Model): # pylint: disable=name-too-long - """Request of liveness with verify session creation. - - All required parameters must be populated in order to send to server. - - :ivar parameters: The parameters for creating session. Required. - :vartype parameters: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent - :ivar verify_image: The image stream for verify. Content-Disposition header field for this part - must have filename. Required. - :vartype verify_image: ~azure.ai.vision.face._vendor.FileType - """ - - parameters: "_models.CreateLivenessWithVerifySessionContent" = rest_field(name="Parameters") - """The parameters for creating session. Required.""" - verify_image: FileType = rest_field(name="VerifyImage", is_multipart_file_input=True) - """The image stream for verify. Content-Disposition header field for this part must have filename. - Required.""" - - @overload - def __init__( - self, - *, - parameters: "_models.CreateLivenessWithVerifySessionContent", - verify_image: FileType, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class CreateLivenessWithVerifySessionResult(_model_base.Model): - """Response of liveness session with verify creation with verify image provided. - - - :ivar session_id: The unique session ID of the created session. It will expire 48 hours after - it was created or may be deleted sooner using the corresponding Session DELETE operation. - Required. - :vartype session_id: str - :ivar auth_token: Bearer token to provide authentication for the Vision SDK running on a client - application. This Bearer token has limited permissions to perform only the required action and - expires after the TTL time. It is also auditable. Required. - :vartype auth_token: str - :ivar verify_image: The detail of face for verification. - :vartype verify_image: ~azure.ai.vision.face.models.LivenessWithVerifyImage - """ - - session_id: str = rest_field(name="sessionId") - """The unique session ID of the created session. It will expire 48 hours after it was created or - may be deleted sooner using the corresponding Session DELETE operation. Required.""" - auth_token: str = rest_field(name="authToken") - """Bearer token to provide authentication for the Vision SDK running on a client application. This - Bearer token has limited permissions to perform only the required action and expires after the - TTL time. It is also auditable. Required.""" - verify_image: Optional["_models.LivenessWithVerifyImage"] = rest_field(name="verifyImage") - """The detail of face for verification.""" - - @overload - def __init__( - self, - *, - session_id: str, - auth_token: str, - verify_image: Optional["_models.LivenessWithVerifyImage"] = None, - ): ... + device_correlation_id: Optional[str] = None, + auth_token_time_to_live_in_seconds: Optional[int] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CreatePersonResult(_model_base.Model): +class CreatePersonResult(_Model): """Response of create person. - :ivar person_id: Person ID of the person. Required. :vartype person_id: str """ - person_id: str = rest_field(name="personId") + person_id: str = rest_field(name="personId", visibility=["read", "create", "update", "delete", "query"]) """Person ID of the person. Required.""" @overload @@ -527,23 +323,22 @@ def __init__( self, *, person_id: str, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ExposureProperties(_model_base.Model): +class ExposureProperties(_Model): """Properties describing exposure level of the image. - :ivar exposure_level: An enum value indicating level of exposure. Required. Known values are: "underExposure", "goodExposure", and "overExposure". :vartype exposure_level: str or ~azure.ai.vision.face.models.ExposureLevel @@ -552,10 +347,12 @@ class ExposureProperties(_model_base.Model): :vartype value: float """ - exposure_level: Union[str, "_models.ExposureLevel"] = rest_field(name="exposureLevel") + exposure_level: Union[str, "_models.ExposureLevel"] = rest_field( + name="exposureLevel", visibility=["read", "create", "update", "delete", "query"] + ) """An enum value indicating level of exposure. Required. Known values are: \"underExposure\", \"goodExposure\", and \"overExposure\".""" - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. Required.""" @@ -565,20 +362,20 @@ def __init__( *, exposure_level: Union[str, "_models.ExposureLevel"], value: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceAttributes(_model_base.Model): # pylint: disable=too-many-instance-attributes +class FaceAttributes(_Model): """Face attributes for the detected face. :ivar age: Age in years. @@ -612,33 +409,45 @@ class FaceAttributes(_model_base.Model): # pylint: disable=too-many-instance-at :vartype quality_for_recognition: str or ~azure.ai.vision.face.models.QualityForRecognition """ - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Age in years.""" - smile: Optional[float] = rest_field() + smile: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Smile intensity, a number between [0,1].""" - facial_hair: Optional["_models.FacialHair"] = rest_field(name="facialHair") + facial_hair: Optional["_models.FacialHair"] = rest_field( + name="facialHair", visibility=["read", "create", "update", "delete", "query"] + ) """Properties describing facial hair attributes.""" - glasses: Optional[Union[str, "_models.GlassesType"]] = rest_field() + glasses: Optional[Union[str, "_models.GlassesType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Glasses type if any of the face. Known values are: \"noGlasses\", \"readingGlasses\", \"sunglasses\", and \"swimmingGoggles\".""" - head_pose: Optional["_models.HeadPose"] = rest_field(name="headPose") + head_pose: Optional["_models.HeadPose"] = rest_field( + name="headPose", visibility=["read", "create", "update", "delete", "query"] + ) """3-D roll/yaw/pitch angles for face direction.""" - hair: Optional["_models.HairProperties"] = rest_field() + hair: Optional["_models.HairProperties"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Properties describing hair attributes.""" - occlusion: Optional["_models.OcclusionProperties"] = rest_field() + occlusion: Optional["_models.OcclusionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Properties describing occlusions on a given face.""" - accessories: Optional[List["_models.AccessoryItem"]] = rest_field() + accessories: Optional[List["_models.AccessoryItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Properties describing any accessories on a given face.""" - blur: Optional["_models.BlurProperties"] = rest_field() + blur: Optional["_models.BlurProperties"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Properties describing any presence of blur within the image.""" - exposure: Optional["_models.ExposureProperties"] = rest_field() + exposure: Optional["_models.ExposureProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Properties describing exposure level of the image.""" - noise: Optional["_models.NoiseProperties"] = rest_field() + noise: Optional["_models.NoiseProperties"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Properties describing noise level of the image.""" - mask: Optional["_models.MaskProperties"] = rest_field() + mask: Optional["_models.MaskProperties"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Properties describing the presence of a mask on a given face.""" quality_for_recognition: Optional[Union[str, "_models.QualityForRecognition"]] = rest_field( - name="qualityForRecognition" + name="qualityForRecognition", visibility=["read", "create", "update", "delete", "query"] ) """Properties describing the overall image quality regarding whether the image being used in the detection is of sufficient quality to attempt face recognition on. Known values are: \"low\", @@ -661,23 +470,22 @@ def __init__( noise: Optional["_models.NoiseProperties"] = None, mask: Optional["_models.MaskProperties"] = None, quality_for_recognition: Optional[Union[str, "_models.QualityForRecognition"]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceDetectionResult(_model_base.Model): +class FaceDetectionResult(_Model): """Response for detect API. - :ivar face_id: Unique faceId of the detected face, created by detection API and it will expire 24 hours after the detection call. To return this, it requires 'returnFaceId' parameter to be true. @@ -695,19 +503,27 @@ class FaceDetectionResult(_model_base.Model): :vartype face_attributes: ~azure.ai.vision.face.models.FaceAttributes """ - face_id: Optional[str] = rest_field(name="faceId") + face_id: Optional[str] = rest_field(name="faceId", visibility=["read", "create", "update", "delete", "query"]) """Unique faceId of the detected face, created by detection API and it will expire 24 hours after the detection call. To return this, it requires 'returnFaceId' parameter to be true.""" - recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field(name="recognitionModel") + recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field( + name="recognitionModel", visibility=["read", "create", "update", "delete", "query"] + ) """The 'recognitionModel' associated with this faceId. This is only returned when 'returnRecognitionModel' is explicitly set as true. Known values are: \"recognition_01\", \"recognition_02\", \"recognition_03\", and \"recognition_04\".""" - face_rectangle: "_models.FaceRectangle" = rest_field(name="faceRectangle") + face_rectangle: "_models.FaceRectangle" = rest_field( + name="faceRectangle", visibility=["read", "create", "update", "delete", "query"] + ) """A rectangle area for the face location on image. Required.""" - face_landmarks: Optional["_models.FaceLandmarks"] = rest_field(name="faceLandmarks") + face_landmarks: Optional["_models.FaceLandmarks"] = rest_field( + name="faceLandmarks", visibility=["read", "create", "update", "delete", "query"] + ) """An array of 27-point face landmarks pointing to the important positions of face components. To return this, it requires 'returnFaceLandmarks' parameter to be true.""" - face_attributes: Optional["_models.FaceAttributes"] = rest_field(name="faceAttributes") + face_attributes: Optional["_models.FaceAttributes"] = rest_field( + name="faceAttributes", visibility=["read", "create", "update", "delete", "query"] + ) """Face attributes for detected face.""" @overload @@ -719,23 +535,23 @@ def __init__( recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = None, face_landmarks: Optional["_models.FaceLandmarks"] = None, face_attributes: Optional["_models.FaceAttributes"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceError(_model_base.Model): +class FaceError(_Model): """The error object. For comprehensive details on error codes and messages returned by the Face - Service, please refer to the following link: https://aka.ms/face-error-codes-and-messages. - + Service, please refer to the following link: `https://aka.ms/face-error-codes-and-messages + `_. :ivar code: One of a server-defined set of error codes. Required. :vartype code: str @@ -743,9 +559,9 @@ class FaceError(_model_base.Model): :vartype message: str """ - code: str = rest_field() + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """One of a server-defined set of error codes. Required.""" - message: str = rest_field() + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A human-readable representation of the error. Required.""" @overload @@ -754,28 +570,27 @@ def __init__( *, code: str, message: str, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceErrorResponse(_model_base.Model): +class FaceErrorResponse(_Model): """A response containing error details. - :ivar error: The error object. Required. :vartype error: ~azure.ai.vision.face.models.FaceError """ - error: "_models.FaceError" = rest_field() + error: "_models.FaceError" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object. Required.""" @overload @@ -783,23 +598,22 @@ def __init__( self, *, error: "_models.FaceError", - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceFindSimilarResult(_model_base.Model): +class FaceFindSimilarResult(_Model): """Response body for find similar face operation. - :ivar confidence: Confidence value of the candidate. The higher confidence, the more similar. Range between [0,1]. Required. :vartype confidence: float @@ -811,13 +625,15 @@ class FaceFindSimilarResult(_model_base.Model): :vartype persisted_face_id: str """ - confidence: float = rest_field() + confidence: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Confidence value of the candidate. The higher confidence, the more similar. Range between [0,1]. Required.""" - face_id: Optional[str] = rest_field(name="faceId") + face_id: Optional[str] = rest_field(name="faceId", visibility=["read", "create", "update", "delete", "query"]) """faceId of candidate face when find by faceIds. faceId is created by \"Detect\" and will expire 24 hours after the detection call.""" - persisted_face_id: Optional[str] = rest_field(name="persistedFaceId") + persisted_face_id: Optional[str] = rest_field( + name="persistedFaceId", visibility=["read", "create", "update", "delete", "query"] + ) """persistedFaceId of candidate face when find by faceListId or largeFaceListId. persistedFaceId in face list/large face list is persisted and will not expire.""" @@ -828,23 +644,22 @@ def __init__( confidence: float, face_id: Optional[str] = None, persisted_face_id: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceGroupingResult(_model_base.Model): +class FaceGroupingResult(_Model): """Response body for group face operation. - :ivar groups: A partition of the original faces based on face similarity. Groups are ranked by number of faces. Required. :vartype groups: list[list[str]] @@ -853,10 +668,10 @@ class FaceGroupingResult(_model_base.Model): :vartype messy_group: list[str] """ - groups: List[List[str]] = rest_field() + groups: List[List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A partition of the original faces based on face similarity. Groups are ranked by number of faces. Required.""" - messy_group: List[str] = rest_field(name="messyGroup") + messy_group: List[str] = rest_field(name="messyGroup", visibility=["read", "create", "update", "delete", "query"]) """Face ids array of faces that cannot find any similar faces from original faces. Required.""" @overload @@ -865,23 +680,22 @@ def __init__( *, groups: List[List[str]], messy_group: List[str], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceIdentificationCandidate(_model_base.Model): +class FaceIdentificationCandidate(_Model): """Candidate for identify call. - :ivar person_id: personId of candidate person. Required. :vartype person_id: str :ivar confidence: Confidence value of the candidate. The higher confidence, the more similar. @@ -889,9 +703,9 @@ class FaceIdentificationCandidate(_model_base.Model): :vartype confidence: float """ - person_id: str = rest_field(name="personId") + person_id: str = rest_field(name="personId", visibility=["read", "create", "update", "delete", "query"]) """personId of candidate person. Required.""" - confidence: float = rest_field() + confidence: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Confidence value of the candidate. The higher confidence, the more similar. Range between [0,1]. Required.""" @@ -901,23 +715,22 @@ def __init__( *, person_id: str, confidence: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceIdentificationResult(_model_base.Model): +class FaceIdentificationResult(_Model): """Identify result. - :ivar face_id: faceId of the query face. Required. :vartype face_id: str :ivar candidates: Identified person candidates for that face (ranked by confidence). Array size @@ -926,9 +739,11 @@ class FaceIdentificationResult(_model_base.Model): :vartype candidates: list[~azure.ai.vision.face.models.FaceIdentificationCandidate] """ - face_id: str = rest_field(name="faceId") + face_id: str = rest_field(name="faceId", visibility=["read", "create", "update", "delete", "query"]) """faceId of the query face. Required.""" - candidates: List["_models.FaceIdentificationCandidate"] = rest_field() + candidates: List["_models.FaceIdentificationCandidate"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Identified person candidates for that face (ranked by confidence). Array size should be no larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty array. Required.""" @@ -939,23 +754,22 @@ def __init__( *, face_id: str, candidates: List["_models.FaceIdentificationCandidate"], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceLandmarks(_model_base.Model): # pylint: disable=too-many-instance-attributes +class FaceLandmarks(_Model): """A collection of 27-point face landmarks pointing to the important positions of face components. - :ivar pupil_left: The coordinates of the left eye pupil. Required. :vartype pupil_left: ~azure.ai.vision.face.models.LandmarkCoordinate :ivar pupil_right: The coordinates of the right eye pupil. Required. @@ -1012,59 +826,113 @@ class FaceLandmarks(_model_base.Model): # pylint: disable=too-many-instance-att :vartype under_lip_bottom: ~azure.ai.vision.face.models.LandmarkCoordinate """ - pupil_left: "_models.LandmarkCoordinate" = rest_field(name="pupilLeft") + pupil_left: "_models.LandmarkCoordinate" = rest_field( + name="pupilLeft", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eye pupil. Required.""" - pupil_right: "_models.LandmarkCoordinate" = rest_field(name="pupilRight") + pupil_right: "_models.LandmarkCoordinate" = rest_field( + name="pupilRight", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eye pupil. Required.""" - nose_tip: "_models.LandmarkCoordinate" = rest_field(name="noseTip") + nose_tip: "_models.LandmarkCoordinate" = rest_field( + name="noseTip", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose tip. Required.""" - mouth_left: "_models.LandmarkCoordinate" = rest_field(name="mouthLeft") + mouth_left: "_models.LandmarkCoordinate" = rest_field( + name="mouthLeft", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the mouth left. Required.""" - mouth_right: "_models.LandmarkCoordinate" = rest_field(name="mouthRight") + mouth_right: "_models.LandmarkCoordinate" = rest_field( + name="mouthRight", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the mouth right. Required.""" - eyebrow_left_outer: "_models.LandmarkCoordinate" = rest_field(name="eyebrowLeftOuter") + eyebrow_left_outer: "_models.LandmarkCoordinate" = rest_field( + name="eyebrowLeftOuter", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eyebrow outer. Required.""" - eyebrow_left_inner: "_models.LandmarkCoordinate" = rest_field(name="eyebrowLeftInner") + eyebrow_left_inner: "_models.LandmarkCoordinate" = rest_field( + name="eyebrowLeftInner", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eyebrow inner. Required.""" - eye_left_outer: "_models.LandmarkCoordinate" = rest_field(name="eyeLeftOuter") + eye_left_outer: "_models.LandmarkCoordinate" = rest_field( + name="eyeLeftOuter", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eye outer. Required.""" - eye_left_top: "_models.LandmarkCoordinate" = rest_field(name="eyeLeftTop") + eye_left_top: "_models.LandmarkCoordinate" = rest_field( + name="eyeLeftTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eye top. Required.""" - eye_left_bottom: "_models.LandmarkCoordinate" = rest_field(name="eyeLeftBottom") + eye_left_bottom: "_models.LandmarkCoordinate" = rest_field( + name="eyeLeftBottom", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eye bottom. Required.""" - eye_left_inner: "_models.LandmarkCoordinate" = rest_field(name="eyeLeftInner") + eye_left_inner: "_models.LandmarkCoordinate" = rest_field( + name="eyeLeftInner", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the left eye inner. Required.""" - eyebrow_right_inner: "_models.LandmarkCoordinate" = rest_field(name="eyebrowRightInner") + eyebrow_right_inner: "_models.LandmarkCoordinate" = rest_field( + name="eyebrowRightInner", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eyebrow inner. Required.""" - eyebrow_right_outer: "_models.LandmarkCoordinate" = rest_field(name="eyebrowRightOuter") + eyebrow_right_outer: "_models.LandmarkCoordinate" = rest_field( + name="eyebrowRightOuter", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eyebrow outer. Required.""" - eye_right_inner: "_models.LandmarkCoordinate" = rest_field(name="eyeRightInner") + eye_right_inner: "_models.LandmarkCoordinate" = rest_field( + name="eyeRightInner", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eye inner. Required.""" - eye_right_top: "_models.LandmarkCoordinate" = rest_field(name="eyeRightTop") + eye_right_top: "_models.LandmarkCoordinate" = rest_field( + name="eyeRightTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eye top. Required.""" - eye_right_bottom: "_models.LandmarkCoordinate" = rest_field(name="eyeRightBottom") + eye_right_bottom: "_models.LandmarkCoordinate" = rest_field( + name="eyeRightBottom", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eye bottom. Required.""" - eye_right_outer: "_models.LandmarkCoordinate" = rest_field(name="eyeRightOuter") + eye_right_outer: "_models.LandmarkCoordinate" = rest_field( + name="eyeRightOuter", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the right eye outer. Required.""" - nose_root_left: "_models.LandmarkCoordinate" = rest_field(name="noseRootLeft") + nose_root_left: "_models.LandmarkCoordinate" = rest_field( + name="noseRootLeft", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose root left. Required.""" - nose_root_right: "_models.LandmarkCoordinate" = rest_field(name="noseRootRight") + nose_root_right: "_models.LandmarkCoordinate" = rest_field( + name="noseRootRight", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose root right. Required.""" - nose_left_alar_top: "_models.LandmarkCoordinate" = rest_field(name="noseLeftAlarTop") + nose_left_alar_top: "_models.LandmarkCoordinate" = rest_field( + name="noseLeftAlarTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose left alar top. Required.""" - nose_right_alar_top: "_models.LandmarkCoordinate" = rest_field(name="noseRightAlarTop") + nose_right_alar_top: "_models.LandmarkCoordinate" = rest_field( + name="noseRightAlarTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose right alar top. Required.""" - nose_left_alar_out_tip: "_models.LandmarkCoordinate" = rest_field(name="noseLeftAlarOutTip") + nose_left_alar_out_tip: "_models.LandmarkCoordinate" = rest_field( + name="noseLeftAlarOutTip", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose left alar out tip. Required.""" - nose_right_alar_out_tip: "_models.LandmarkCoordinate" = rest_field(name="noseRightAlarOutTip") + nose_right_alar_out_tip: "_models.LandmarkCoordinate" = rest_field( + name="noseRightAlarOutTip", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the nose right alar out tip. Required.""" - upper_lip_top: "_models.LandmarkCoordinate" = rest_field(name="upperLipTop") + upper_lip_top: "_models.LandmarkCoordinate" = rest_field( + name="upperLipTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the upper lip top. Required.""" - upper_lip_bottom: "_models.LandmarkCoordinate" = rest_field(name="upperLipBottom") + upper_lip_bottom: "_models.LandmarkCoordinate" = rest_field( + name="upperLipBottom", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the upper lip bottom. Required.""" - under_lip_top: "_models.LandmarkCoordinate" = rest_field(name="underLipTop") + under_lip_top: "_models.LandmarkCoordinate" = rest_field( + name="underLipTop", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the under lip top. Required.""" - under_lip_bottom: "_models.LandmarkCoordinate" = rest_field(name="underLipBottom") + under_lip_bottom: "_models.LandmarkCoordinate" = rest_field( + name="underLipBottom", visibility=["read", "create", "update", "delete", "query"] + ) """The coordinates of the under lip bottom. Required.""" @overload @@ -1098,23 +966,22 @@ def __init__( # pylint: disable=too-many-locals upper_lip_bottom: "_models.LandmarkCoordinate", under_lip_top: "_models.LandmarkCoordinate", under_lip_bottom: "_models.LandmarkCoordinate", - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceRectangle(_model_base.Model): +class FaceRectangle(_Model): """A rectangle within which a face can be found. - :ivar top: The distance from the top edge if the image to the top edge of the rectangle, in pixels. Required. :vartype top: int @@ -1127,15 +994,15 @@ class FaceRectangle(_model_base.Model): :vartype height: int """ - top: int = rest_field() + top: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The distance from the top edge if the image to the top edge of the rectangle, in pixels. Required.""" - left: int = rest_field() + left: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The distance from the left edge if the image to the left edge of the rectangle, in pixels. Required.""" - width: int = rest_field() + width: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The width of the rectangle, in pixels. Required.""" - height: int = rest_field() + height: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The height of the rectangle, in pixels. Required.""" @overload @@ -1146,23 +1013,22 @@ def __init__( left: int, width: int, height: int, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceTrainingResult(_model_base.Model): +class FaceTrainingResult(_Model): """Training result of a container. - :ivar status: Training status of the container. Required. Known values are: "notStarted", "running", "succeeded", and "failed". :vartype status: str or ~azure.ai.vision.face.models.FaceOperationStatus @@ -1181,22 +1047,30 @@ class FaceTrainingResult(_model_base.Model): :vartype message: str """ - status: Union[str, "_models.FaceOperationStatus"] = rest_field() + status: Union[str, "_models.FaceOperationStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Training status of the container. Required. Known values are: \"notStarted\", \"running\", \"succeeded\", and \"failed\".""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") + created_date_time: datetime.datetime = rest_field( + name="createdDateTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """A combined UTC date and time string that describes the created time of the person group, large person group or large face list. Required.""" - last_action_date_time: datetime.datetime = rest_field(name="lastActionDateTime", format="rfc3339") + last_action_date_time: datetime.datetime = rest_field( + name="lastActionDateTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """A combined UTC date and time string that describes the last modify time of the person group, large person group or large face list, could be null value when the group is not successfully trained. Required.""" last_successful_training_date_time: datetime.datetime = rest_field( - name="lastSuccessfulTrainingDateTime", format="rfc3339" + name="lastSuccessfulTrainingDateTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc3339", ) """A combined UTC date and time string that describes the last successful training time of the person group, large person group or large face list. Required.""" - message: Optional[str] = rest_field() + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Show failure message when training failed (omitted when training succeed).""" @overload @@ -1208,23 +1082,22 @@ def __init__( last_action_date_time: datetime.datetime, last_successful_training_date_time: datetime.datetime, message: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FaceVerificationResult(_model_base.Model): +class FaceVerificationResult(_Model): """Verify result. - :ivar is_identical: True if the two faces belong to the same person or the face belongs to the person, otherwise false. Required. :vartype is_identical: bool @@ -1235,10 +1108,10 @@ class FaceVerificationResult(_model_base.Model): :vartype confidence: float """ - is_identical: bool = rest_field(name="isIdentical") + is_identical: bool = rest_field(name="isIdentical", visibility=["read", "create", "update", "delete", "query"]) """True if the two faces belong to the same person or the face belongs to the person, otherwise false. Required.""" - confidence: float = rest_field() + confidence: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number indicates the similarity confidence of whether two faces belong to the same person, or whether the face belongs to the person. By default, isIdentical is set to True if similarity confidence is greater than or equal to 0.5. This is useful for advanced users to override @@ -1250,23 +1123,22 @@ def __init__( *, is_identical: bool, confidence: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FacialHair(_model_base.Model): +class FacialHair(_Model): """Properties describing facial hair attributes. - :ivar moustache: A number ranging from 0 to 1 indicating a level of confidence associated with a property. Required. :vartype moustache: float @@ -1278,13 +1150,13 @@ class FacialHair(_model_base.Model): :vartype sideburns: float """ - moustache: float = rest_field() + moustache: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number ranging from 0 to 1 indicating a level of confidence associated with a property. Required.""" - beard: float = rest_field() + beard: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number ranging from 0 to 1 indicating a level of confidence associated with a property. Required.""" - sideburns: float = rest_field() + sideburns: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number ranging from 0 to 1 indicating a level of confidence associated with a property. Required.""" @@ -1295,23 +1167,22 @@ def __init__( moustache: float, beard: float, sideburns: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class HairColor(_model_base.Model): +class HairColor(_Model): """An array of candidate colors and confidence level in the presence of each. - :ivar color: Name of the hair color. Required. Known values are: "unknown", "white", "gray", "blond", "brown", "red", "black", and "other". :vartype color: str or ~azure.ai.vision.face.models.HairColorType @@ -1319,10 +1190,10 @@ class HairColor(_model_base.Model): :vartype confidence: float """ - color: Union[str, "_models.HairColorType"] = rest_field() + color: Union[str, "_models.HairColorType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Name of the hair color. Required. Known values are: \"unknown\", \"white\", \"gray\", \"blond\", \"brown\", \"red\", \"black\", and \"other\".""" - confidence: float = rest_field() + confidence: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Confidence level of the color. Range between [0,1]. Required.""" @overload @@ -1331,23 +1202,22 @@ def __init__( *, color: Union[str, "_models.HairColorType"], confidence: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class HairProperties(_model_base.Model): +class HairProperties(_Model): """Properties describing hair attributes. - :ivar bald: A number describing confidence level of whether the person is bald. Required. :vartype bald: float :ivar invisible: A boolean value describing whether the hair is visible in the image. Required. @@ -1357,11 +1227,13 @@ class HairProperties(_model_base.Model): :vartype hair_color: list[~azure.ai.vision.face.models.HairColor] """ - bald: float = rest_field() + bald: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number describing confidence level of whether the person is bald. Required.""" - invisible: bool = rest_field() + invisible: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A boolean value describing whether the hair is visible in the image. Required.""" - hair_color: List["_models.HairColor"] = rest_field(name="hairColor") + hair_color: List["_models.HairColor"] = rest_field( + name="hairColor", visibility=["read", "create", "update", "delete", "query"] + ) """An array of candidate colors and confidence level in the presence of each. Required.""" @overload @@ -1371,23 +1243,22 @@ def __init__( bald: float, invisible: bool, hair_color: List["_models.HairColor"], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class HeadPose(_model_base.Model): +class HeadPose(_Model): """3-D roll/yaw/pitch angles for face direction. - :ivar pitch: Value of angles. Required. :vartype pitch: float :ivar roll: Value of angles. Required. @@ -1396,11 +1267,11 @@ class HeadPose(_model_base.Model): :vartype yaw: float """ - pitch: float = rest_field() + pitch: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Value of angles. Required.""" - roll: float = rest_field() + roll: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Value of angles. Required.""" - yaw: float = rest_field() + yaw: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Value of angles. Required.""" @overload @@ -1410,32 +1281,31 @@ def __init__( pitch: float, roll: float, yaw: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LandmarkCoordinate(_model_base.Model): +class LandmarkCoordinate(_Model): """Landmark coordinates within an image. - :ivar x: The horizontal component, in pixels. Required. :vartype x: float :ivar y: The vertical component, in pixels. Required. :vartype y: float """ - x: float = rest_field() + x: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The horizontal component, in pixels. Required.""" - y: float = rest_field() + y: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The vertical component, in pixels. Required.""" @overload @@ -1444,25 +1314,22 @@ def __init__( *, x: float, y: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LargeFaceList(_model_base.Model): +class LargeFaceList(_Model): """Large face list is a list of faces, up to 1,000,000 faces. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: User defined name, maximum length is 128. Required. :vartype name: str :ivar user_data: Optional user defined data. Length should not exceed 16K. @@ -1476,11 +1343,13 @@ class LargeFaceList(_model_base.Model): :vartype large_face_list_id: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User defined name, maximum length is 128. Required.""" - user_data: Optional[str] = rest_field(name="userData") + user_data: Optional[str] = rest_field(name="userData", visibility=["read", "create", "update", "delete", "query"]) """Optional user defined data. Length should not exceed 16K.""" - recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field(name="recognitionModel") + recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field( + name="recognitionModel", visibility=["read", "create", "update", "delete", "query"] + ) """Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds. Known values are: \"recognition_01\", \"recognition_02\", \"recognition_03\", and \"recognition_04\".""" @@ -1494,25 +1363,22 @@ def __init__( name: str, user_data: Optional[str] = None, recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LargeFaceListFace(_model_base.Model): +class LargeFaceListFace(_Model): """Face resource for large face list. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar persisted_face_id: Face ID of the face. Required. :vartype persisted_face_id: str :ivar user_data: User-provided data attached to the face. The length limit is 1K. @@ -1521,7 +1387,7 @@ class LargeFaceListFace(_model_base.Model): persisted_face_id: str = rest_field(name="persistedFaceId", visibility=["read"]) """Face ID of the face. Required.""" - user_data: Optional[str] = rest_field(name="userData") + user_data: Optional[str] = rest_field(name="userData", visibility=["read", "create", "update", "delete", "query"]) """User-provided data attached to the face. The length limit is 1K.""" @overload @@ -1529,26 +1395,23 @@ def __init__( self, *, user_data: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LargePersonGroup(_model_base.Model): +class LargePersonGroup(_Model): """The container of the uploaded person data, including face recognition feature, and up to 1,000,000 people. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: User defined name, maximum length is 128. Required. :vartype name: str :ivar user_data: Optional user defined data. Length should not exceed 16K. @@ -1561,11 +1424,13 @@ class LargePersonGroup(_model_base.Model): :vartype large_person_group_id: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User defined name, maximum length is 128. Required.""" - user_data: Optional[str] = rest_field(name="userData") + user_data: Optional[str] = rest_field(name="userData", visibility=["read", "create", "update", "delete", "query"]) """Optional user defined data. Length should not exceed 16K.""" - recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field(name="recognitionModel") + recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = rest_field( + name="recognitionModel", visibility=["read", "create", "update", "delete", "query"] + ) """Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds. Known values are: \"recognition_01\", \"recognition_02\", \"recognition_03\", and \"recognition_04\".""" @@ -1579,26 +1444,23 @@ def __init__( name: str, user_data: Optional[str] = None, recognition_model: Optional[Union[str, "_models.FaceRecognitionModel"]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LargePersonGroupPerson(_model_base.Model): +class LargePersonGroupPerson(_Model): """The person in a specified large person group. To add face to this person, please call "Add Large Person Group Person Face". - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar person_id: ID of the person. Required. :vartype person_id: str :ivar name: User defined name, maximum length is 128. Required. @@ -1611,11 +1473,13 @@ class LargePersonGroupPerson(_model_base.Model): person_id: str = rest_field(name="personId", visibility=["read"]) """ID of the person. Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User defined name, maximum length is 128. Required.""" - user_data: Optional[str] = rest_field(name="userData") + user_data: Optional[str] = rest_field(name="userData", visibility=["read", "create", "update", "delete", "query"]) """Optional user defined data. Length should not exceed 16K.""" - persisted_face_ids: Optional[List[str]] = rest_field(name="persistedFaceIds") + persisted_face_ids: Optional[List[str]] = rest_field( + name="persistedFaceIds", visibility=["read", "create", "update", "delete", "query"] + ) """Face ids of registered faces in the person.""" @overload @@ -1625,25 +1489,22 @@ def __init__( name: str, user_data: Optional[str] = None, persisted_face_ids: Optional[List[str]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LargePersonGroupPersonFace(_model_base.Model): +class LargePersonGroupPersonFace(_Model): """Face resource for large person group person. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar persisted_face_id: Face ID of the face. Required. :vartype persisted_face_id: str :ivar user_data: User-provided data attached to the face. The length limit is 1K. @@ -1652,7 +1513,7 @@ class LargePersonGroupPersonFace(_model_base.Model): persisted_face_id: str = rest_field(name="persistedFaceId", visibility=["read"]) """Face ID of the face. Required.""" - user_data: Optional[str] = rest_field(name="userData") + user_data: Optional[str] = rest_field(name="userData", visibility=["read", "create", "update", "delete", "query"]) """User-provided data attached to the face. The length limit is 1K.""" @overload @@ -1660,212 +1521,125 @@ def __init__( self, *, user_data: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessOutputsTarget(_model_base.Model): - """The liveness classification for target face. - +class LivenessColorDecisionTarget(_Model): + """The target from color image used for liveness classification. :ivar face_rectangle: The face region where the liveness classification was made on. Required. :vartype face_rectangle: ~azure.ai.vision.face.models.FaceRectangle - :ivar file_name: The file name which contains the face rectangle where the liveness - classification was made on. Required. - :vartype file_name: str - :ivar time_offset_within_file: The time offset within the file of the frame which contains the - face rectangle where the liveness classification was made on. Required. - :vartype time_offset_within_file: int - :ivar image_type: The image type which contains the face rectangle where the liveness - classification was made on. Required. Known values are: "Color", "Infrared", and "Depth". - :vartype image_type: str or ~azure.ai.vision.face.models.FaceImageType """ - face_rectangle: "_models.FaceRectangle" = rest_field(name="faceRectangle") + face_rectangle: "_models.FaceRectangle" = rest_field( + name="faceRectangle", visibility=["read", "create", "update", "delete", "query"] + ) """The face region where the liveness classification was made on. Required.""" - file_name: str = rest_field(name="fileName") - """The file name which contains the face rectangle where the liveness classification was made on. - Required.""" - time_offset_within_file: int = rest_field(name="timeOffsetWithinFile") - """The time offset within the file of the frame which contains the face rectangle where the - liveness classification was made on. Required.""" - image_type: Union[str, "_models.FaceImageType"] = rest_field(name="imageType") - """The image type which contains the face rectangle where the liveness classification was made on. - Required. Known values are: \"Color\", \"Infrared\", and \"Depth\".""" @overload def __init__( self, *, face_rectangle: "_models.FaceRectangle", - file_name: str, - time_offset_within_file: int, - image_type: Union[str, "_models.FaceImageType"], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessResponseBody(_model_base.Model): - """The response body of detect liveness API call. +class LivenessDecisionTargets(_Model): + """The targets used for liveness classification. - :ivar liveness_decision: The liveness classification for the target face. Known values are: - "uncertain", "realface", and "spoofface". - :vartype liveness_decision: str or ~azure.ai.vision.face.models.FaceLivenessDecision - :ivar target: Specific targets used for liveness classification. - :vartype target: ~azure.ai.vision.face.models.LivenessOutputsTarget - :ivar model_version_used: The model version used for liveness classification. Known values are: - "2022-10-15-preview.04" and "2023-12-20-preview.06". - :vartype model_version_used: str or ~azure.ai.vision.face.models.LivenessModel - :ivar verify_result: The face verification output. Only available when the request is liveness - with verify. - :vartype verify_result: ~azure.ai.vision.face.models.LivenessWithVerifyOutputs + :ivar color: The target from color image used for liveness classification. Required. + :vartype color: ~azure.ai.vision.face.models.LivenessColorDecisionTarget """ - liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = rest_field(name="livenessDecision") - """The liveness classification for the target face. Known values are: \"uncertain\", \"realface\", - and \"spoofface\".""" - target: Optional["_models.LivenessOutputsTarget"] = rest_field() - """Specific targets used for liveness classification.""" - model_version_used: Optional[Union[str, "_models.LivenessModel"]] = rest_field(name="modelVersionUsed") - """The model version used for liveness classification. Known values are: \"2022-10-15-preview.04\" - and \"2023-12-20-preview.06\".""" - verify_result: Optional["_models.LivenessWithVerifyOutputs"] = rest_field(name="verifyResult") - """The face verification output. Only available when the request is liveness with verify.""" + color: "_models.LivenessColorDecisionTarget" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The target from color image used for liveness classification. Required.""" @overload def __init__( self, *, - liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = None, - target: Optional["_models.LivenessOutputsTarget"] = None, - model_version_used: Optional[Union[str, "_models.LivenessModel"]] = None, - verify_result: Optional["_models.LivenessWithVerifyOutputs"] = None, - ): ... + color: "_models.LivenessColorDecisionTarget", + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessSession(_model_base.Model): - """Session result of detect liveness. - - Readonly variables are only populated by the server, and will be ignored when sending a request. - +class LivenessError(_Model): + """The error of the liveness classification. - :ivar id: The unique ID to reference this session. Required. - :vartype id: str - :ivar created_date_time: DateTime when this session was created. Required. - :vartype created_date_time: ~datetime.datetime - :ivar session_start_date_time: DateTime when this session was started by the client. - :vartype session_start_date_time: ~datetime.datetime - :ivar session_expired: Whether or not the session is expired. Required. - :vartype session_expired: bool - :ivar device_correlation_id: Unique Guid per each end-user device. This is to provide rate - limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this - 'deviceCorrelationId' must be null. - :vartype device_correlation_id: str - :ivar auth_token_time_to_live_in_seconds: Seconds the session should last for. Range is 60 to - 86400 seconds. Default value is 600. - :vartype auth_token_time_to_live_in_seconds: int - :ivar status: The current status of the session. Required. Known values are: "NotStarted", - "Started", and "ResultAvailable". - :vartype status: str or ~azure.ai.vision.face.models.FaceSessionStatus - :ivar result: The latest session audit result only populated if status == 'ResultAvailable'. - :vartype result: ~azure.ai.vision.face.models.LivenessSessionAuditEntry + :ivar code: The error code. Required. + :vartype code: str + :ivar message: The error message. Required. + :vartype message: str + :ivar targets: Targets used for liveness classification. Required. + :vartype targets: ~azure.ai.vision.face.models.LivenessDecisionTargets """ - id: str = rest_field(visibility=["read"]) - """The unique ID to reference this session. Required.""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") - """DateTime when this session was created. Required.""" - session_start_date_time: Optional[datetime.datetime] = rest_field(name="sessionStartDateTime", format="rfc3339") - """DateTime when this session was started by the client.""" - session_expired: bool = rest_field(name="sessionExpired") - """Whether or not the session is expired. Required.""" - device_correlation_id: Optional[str] = rest_field(name="deviceCorrelationId") - """Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If - 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be - null.""" - auth_token_time_to_live_in_seconds: Optional[int] = rest_field(name="authTokenTimeToLiveInSeconds") - """Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.""" - status: Union[str, "_models.FaceSessionStatus"] = rest_field() - """The current status of the session. Required. Known values are: \"NotStarted\", \"Started\", and - \"ResultAvailable\".""" - result: Optional["_models.LivenessSessionAuditEntry"] = rest_field() - """The latest session audit result only populated if status == 'ResultAvailable'.""" + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error code. Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error message. Required.""" + targets: "_models.LivenessDecisionTargets" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Targets used for liveness classification. Required.""" @overload def __init__( self, *, - created_date_time: datetime.datetime, - session_expired: bool, - status: Union[str, "_models.FaceSessionStatus"], - session_start_date_time: Optional[datetime.datetime] = None, - device_correlation_id: Optional[str] = None, - auth_token_time_to_live_in_seconds: Optional[int] = None, - result: Optional["_models.LivenessSessionAuditEntry"] = None, - ): ... + code: str, + message: str, + targets: "_models.LivenessDecisionTargets", + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessSessionAuditEntry(_model_base.Model): - """Audit entry for a request in session. +class LivenessResult(_Model): + """The results of the liveness classification. - - :ivar id: The unique id to refer to this audit request. Use this id with the 'start' query - parameter to continue on to the next page of audit results. Required. - :vartype id: int - :ivar session_id: The unique sessionId of the created session. It will expire 48 hours after it - was created or may be deleted sooner using the corresponding session DELETE operation. - Required. - :vartype session_id: str - :ivar request_id: The unique requestId that is returned by the service to the client in the - 'apim-request-id' header. Required. - :vartype request_id: str - :ivar client_request_id: The unique clientRequestId that is sent by the client in the - 'client-request-id' header. Required. - :vartype client_request_id: str - :ivar received_date_time: The UTC DateTime that the request was received. Required. - :vartype received_date_time: ~datetime.datetime - :ivar request: The request of this entry. Required. - :vartype request: ~azure.ai.vision.face.models.AuditRequestInfo - :ivar response: The response of this entry. Required. - :vartype response: ~azure.ai.vision.face.models.AuditLivenessResponseInfo + :ivar liveness_decision: The liveness classification for the target face. Known values are: + "uncertain", "realface", and "spoofface". + :vartype liveness_decision: str or ~azure.ai.vision.face.models.FaceLivenessDecision + :ivar targets: Targets used for liveness classification. Required. + :vartype targets: ~azure.ai.vision.face.models.LivenessDecisionTargets :ivar digest: The server calculated digest for this request. If the client reported digest differs from the server calculated digest, then the message integrity between the client and service has been compromised and the result should not be trusted. For more information, see @@ -1873,129 +1647,225 @@ class LivenessSessionAuditEntry(_model_base.Model): :vartype digest: str :ivar session_image_id: The image ID of the session request. :vartype session_image_id: str - :ivar verify_image_hash: The sha256 hash of the verify-image in the request. - :vartype verify_image_hash: str """ - id: int = rest_field() - """The unique id to refer to this audit request. Use this id with the 'start' query parameter to - continue on to the next page of audit results. Required.""" - session_id: str = rest_field(name="sessionId") - """The unique sessionId of the created session. It will expire 48 hours after it was created or - may be deleted sooner using the corresponding session DELETE operation. Required.""" - request_id: str = rest_field(name="requestId") - """The unique requestId that is returned by the service to the client in the 'apim-request-id' - header. Required.""" - client_request_id: str = rest_field(name="clientRequestId") - """The unique clientRequestId that is sent by the client in the 'client-request-id' header. - Required.""" - received_date_time: datetime.datetime = rest_field(name="receivedDateTime", format="rfc3339") - """The UTC DateTime that the request was received. Required.""" - request: "_models.AuditRequestInfo" = rest_field() - """The request of this entry. Required.""" - response: "_models.AuditLivenessResponseInfo" = rest_field() - """The response of this entry. Required.""" - digest: str = rest_field() + liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = rest_field( + name="livenessDecision", visibility=["read", "create", "update", "delete", "query"] + ) + """The liveness classification for the target face. Known values are: \"uncertain\", \"realface\", + and \"spoofface\".""" + targets: "_models.LivenessDecisionTargets" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Targets used for liveness classification. Required.""" + digest: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The server calculated digest for this request. If the client reported digest differs from the server calculated digest, then the message integrity between the client and service has been compromised and the result should not be trusted. For more information, see how to guides on how to leverage this value to secure your end-to-end solution. Required.""" - session_image_id: Optional[str] = rest_field(name="sessionImageId") + session_image_id: Optional[str] = rest_field( + name="sessionImageId", visibility=["read", "create", "update", "delete", "query"] + ) """The image ID of the session request.""" - verify_image_hash: Optional[str] = rest_field(name="verifyImageHash") - """The sha256 hash of the verify-image in the request.""" @overload def __init__( self, *, - id: int, # pylint: disable=redefined-builtin - session_id: str, - request_id: str, - client_request_id: str, - received_date_time: datetime.datetime, - request: "_models.AuditRequestInfo", - response: "_models.AuditLivenessResponseInfo", + targets: "_models.LivenessDecisionTargets", digest: str, + liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = None, session_image_id: Optional[str] = None, - verify_image_hash: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessSessionItem(_model_base.Model): - """Session data returned for enumeration. +class LivenessSession(_Model): + """Session result of detect liveness. - Readonly variables are only populated by the server, and will be ignored when sending a request. + :ivar session_id: The unique ID to reference this session. Required. + :vartype session_id: str + :ivar auth_token: Bearer token to provide authentication for the Vision SDK running on a client + application. This Bearer token has limited permissions to perform only the required action and + expires after the TTL time. It is also auditable. Required. + :vartype auth_token: str + :ivar status: The current status of the session. Required. Known values are: "NotStarted", + "Running", "Succeeded", "Failed", and "Canceled". + :vartype status: str or ~azure.ai.vision.face.models.OperationState + :ivar model_version: The model version used for liveness classification. This is an optional + parameter, and if this is not specified, then the latest supported model version will be + chosen. "2024-11-15" + :vartype model_version: str or ~azure.ai.vision.face.models.LivenessModel + :ivar results: The results of the liveness session. Required. + :vartype results: ~azure.ai.vision.face.models.LivenessSessionResults + """ + session_id: str = rest_field(name="sessionId", visibility=["read"]) + """The unique ID to reference this session. Required.""" + auth_token: str = rest_field(name="authToken", visibility=["read", "create", "update", "delete", "query"]) + """Bearer token to provide authentication for the Vision SDK running on a client application. This + Bearer token has limited permissions to perform only the required action and expires after the + TTL time. It is also auditable. Required.""" + status: Union[str, "_models.OperationState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The current status of the session. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + model_version: Optional[Union[str, "_models.LivenessModel"]] = rest_field( + name="modelVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The model version used for liveness classification. This is an optional parameter, and if this + is not specified, then the latest supported model version will be chosen. \"2024-11-15\"""" + results: "_models.LivenessSessionResults" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The results of the liveness session. Required.""" - :ivar id: The unique ID to reference this session. Required. - :vartype id: str - :ivar created_date_time: DateTime when this session was created. Required. - :vartype created_date_time: ~datetime.datetime - :ivar session_start_date_time: DateTime when this session was started by the client. - :vartype session_start_date_time: ~datetime.datetime - :ivar session_expired: Whether or not the session is expired. Required. - :vartype session_expired: bool - :ivar device_correlation_id: Unique Guid per each end-user device. This is to provide rate - limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this - 'deviceCorrelationId' must be null. - :vartype device_correlation_id: str - :ivar auth_token_time_to_live_in_seconds: Seconds the session should last for. Range is 60 to - 86400 seconds. Default value is 600. - :vartype auth_token_time_to_live_in_seconds: int + @overload + def __init__( + self, + *, + auth_token: str, + status: Union[str, "_models.OperationState"], + results: "_models.LivenessSessionResults", + model_version: Optional[Union[str, "_models.LivenessModel"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LivenessSessionAttempt(_Model): + """The liveness session attempt. + + :ivar attempt_id: The attempt ID, start from 1. Required. + :vartype attempt_id: int + :ivar attempt_status: The status of the attempt. Required. Known values are: "NotStarted", + "Running", "Succeeded", "Failed", and "Canceled". + :vartype attempt_status: str or ~azure.ai.vision.face.models.OperationState + :ivar result: The result of the liveness call, will be null if there is error. + :vartype result: ~azure.ai.vision.face.models.LivenessResult + :ivar error: The error of the liveness call, will be null if there is result. + :vartype error: ~azure.ai.vision.face.models.LivenessError """ - id: str = rest_field(visibility=["read"]) - """The unique ID to reference this session. Required.""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") - """DateTime when this session was created. Required.""" - session_start_date_time: Optional[datetime.datetime] = rest_field(name="sessionStartDateTime", format="rfc3339") - """DateTime when this session was started by the client.""" - session_expired: bool = rest_field(name="sessionExpired") - """Whether or not the session is expired. Required.""" - device_correlation_id: Optional[str] = rest_field(name="deviceCorrelationId") - """Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If - 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be - null.""" - auth_token_time_to_live_in_seconds: Optional[int] = rest_field(name="authTokenTimeToLiveInSeconds") - """Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.""" + attempt_id: int = rest_field(name="attemptId", visibility=["read", "create", "update", "delete", "query"]) + """The attempt ID, start from 1. Required.""" + attempt_status: Union[str, "_models.OperationState"] = rest_field( + name="attemptStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the attempt. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + result: Optional["_models.LivenessResult"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The result of the liveness call, will be null if there is error.""" + error: Optional["_models.LivenessError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error of the liveness call, will be null if there is result.""" @overload def __init__( self, *, - created_date_time: datetime.datetime, - session_expired: bool, - session_start_date_time: Optional[datetime.datetime] = None, - device_correlation_id: Optional[str] = None, - auth_token_time_to_live_in_seconds: Optional[int] = None, - ): ... + attempt_id: int, + attempt_status: Union[str, "_models.OperationState"], + result: Optional["_models.LivenessResult"] = None, + error: Optional["_models.LivenessError"] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessWithVerifyImage(_model_base.Model): - """The detail of face for verification. +class LivenessSessionResults(_Model): + """The results of the liveness session. + + :ivar attempts: The attempts data of underlying liveness call with the session. Required. + :vartype attempts: list[~azure.ai.vision.face.models.LivenessSessionAttempt] + """ + + attempts: List["_models.LivenessSessionAttempt"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attempts data of underlying liveness call with the session. Required.""" + + @overload + def __init__( + self, + *, + attempts: List["_models.LivenessSessionAttempt"], + ) -> None: ... + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LivenessWithVerifyOutputs(_Model): + """The face verification output. + + :ivar match_confidence: The target face liveness face and comparison image face verification + confidence. Required. + :vartype match_confidence: float + :ivar is_identical: Whether the target liveness face and comparison image face match. Required. + :vartype is_identical: bool + """ + + match_confidence: float = rest_field( + name="matchConfidence", visibility=["read", "create", "update", "delete", "query"] + ) + """The target face liveness face and comparison image face verification confidence. Required.""" + is_identical: bool = rest_field(name="isIdentical", visibility=["read", "create", "update", "delete", "query"]) + """Whether the target liveness face and comparison image face match. Required.""" + + @overload + def __init__( + self, + *, + match_confidence: float, + is_identical: bool, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + +class LivenessWithVerifyReference(_Model): + """The detail of face for verification. + + :ivar reference_type: The image type which contains the face rectangle where the liveness + classification was made on. Required. Known values are: "Color", "Infrared", and "Depth". + :vartype reference_type: str or ~azure.ai.vision.face.models.FaceImageType :ivar face_rectangle: The face region where the comparison image's classification was made. Required. :vartype face_rectangle: ~azure.ai.vision.face.models.FaceRectangle @@ -2004,9 +1874,18 @@ class LivenessWithVerifyImage(_model_base.Model): :vartype quality_for_recognition: str or ~azure.ai.vision.face.models.QualityForRecognition """ - face_rectangle: "_models.FaceRectangle" = rest_field(name="faceRectangle") + reference_type: Union[str, "_models.FaceImageType"] = rest_field( + name="referenceType", visibility=["read", "create", "update", "delete", "query"] + ) + """The image type which contains the face rectangle where the liveness classification was made on. + Required. Known values are: \"Color\", \"Infrared\", and \"Depth\".""" + face_rectangle: "_models.FaceRectangle" = rest_field( + name="faceRectangle", visibility=["read", "create", "update", "delete", "query"] + ) """The face region where the comparison image's classification was made. Required.""" - quality_for_recognition: Union[str, "_models.QualityForRecognition"] = rest_field(name="qualityForRecognition") + quality_for_recognition: Union[str, "_models.QualityForRecognition"] = rest_field( + name="qualityForRecognition", visibility=["read", "create", "update", "delete", "query"] + ) """Quality of face image for recognition. Required. Known values are: \"low\", \"medium\", and \"high\".""" @@ -2014,136 +1893,243 @@ class LivenessWithVerifyImage(_model_base.Model): def __init__( self, *, + reference_type: Union[str, "_models.FaceImageType"], face_rectangle: "_models.FaceRectangle", quality_for_recognition: Union[str, "_models.QualityForRecognition"], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessWithVerifyOutputs(_model_base.Model): - """The face verification output. - +class LivenessWithVerifyResult(_Model): + """The results of the liveness with verify call. - :ivar verify_image: The detail of face for verification. Required. - :vartype verify_image: ~azure.ai.vision.face.models.LivenessWithVerifyImage - :ivar match_confidence: The target face liveness face and comparison image face verification - confidence. Required. - :vartype match_confidence: float - :ivar is_identical: Whether the target liveness face and comparison image face match. Required. - :vartype is_identical: bool + :ivar liveness_decision: The liveness classification for the target face. Known values are: + "uncertain", "realface", and "spoofface". + :vartype liveness_decision: str or ~azure.ai.vision.face.models.FaceLivenessDecision + :ivar targets: Targets used for liveness classification. Required. + :vartype targets: ~azure.ai.vision.face.models.LivenessDecisionTargets + :ivar digest: The server calculated digest for this request. If the client reported digest + differs from the server calculated digest, then the message integrity between the client and + service has been compromised and the result should not be trusted. For more information, see + how to guides on how to leverage this value to secure your end-to-end solution. Required. + :vartype digest: str + :ivar session_image_id: The image ID of the session request. + :vartype session_image_id: str + :ivar verify_result: The face verification output. Only available when the request is liveness + with verify. + :vartype verify_result: ~azure.ai.vision.face.models.LivenessWithVerifyOutputs + :ivar verify_image_hash: The sha256 hash of the verify-image in the request. + :vartype verify_image_hash: str """ - verify_image: "_models.LivenessWithVerifyImage" = rest_field(name="verifyImage") - """The detail of face for verification. Required.""" - match_confidence: float = rest_field(name="matchConfidence") - """The target face liveness face and comparison image face verification confidence. Required.""" - is_identical: bool = rest_field(name="isIdentical") - """Whether the target liveness face and comparison image face match. Required.""" + liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = rest_field( + name="livenessDecision", visibility=["read", "create", "update", "delete", "query"] + ) + """The liveness classification for the target face. Known values are: \"uncertain\", \"realface\", + and \"spoofface\".""" + targets: "_models.LivenessDecisionTargets" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Targets used for liveness classification. Required.""" + digest: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The server calculated digest for this request. If the client reported digest differs from the + server calculated digest, then the message integrity between the client and service has been + compromised and the result should not be trusted. For more information, see how to guides on + how to leverage this value to secure your end-to-end solution. Required.""" + session_image_id: Optional[str] = rest_field( + name="sessionImageId", visibility=["read", "create", "update", "delete", "query"] + ) + """The image ID of the session request.""" + verify_result: Optional["_models.LivenessWithVerifyOutputs"] = rest_field( + name="verifyResult", visibility=["read", "create", "update", "delete", "query"] + ) + """The face verification output. Only available when the request is liveness with verify.""" + verify_image_hash: Optional[str] = rest_field( + name="verifyImageHash", visibility=["read", "create", "update", "delete", "query"] + ) + """The sha256 hash of the verify-image in the request.""" @overload def __init__( self, *, - verify_image: "_models.LivenessWithVerifyImage", - match_confidence: float, - is_identical: bool, - ): ... + targets: "_models.LivenessDecisionTargets", + digest: str, + liveness_decision: Optional[Union[str, "_models.FaceLivenessDecision"]] = None, + session_image_id: Optional[str] = None, + verify_result: Optional["_models.LivenessWithVerifyOutputs"] = None, + verify_image_hash: Optional[str] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class LivenessWithVerifySession(_model_base.Model): +class LivenessWithVerifySession(_Model): """Session result of detect liveness with verify. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - - :ivar id: The unique ID to reference this session. Required. - :vartype id: str - :ivar created_date_time: DateTime when this session was created. Required. - :vartype created_date_time: ~datetime.datetime - :ivar session_start_date_time: DateTime when this session was started by the client. - :vartype session_start_date_time: ~datetime.datetime - :ivar session_expired: Whether or not the session is expired. Required. - :vartype session_expired: bool - :ivar device_correlation_id: Unique Guid per each end-user device. This is to provide rate - limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this - 'deviceCorrelationId' must be null. - :vartype device_correlation_id: str - :ivar auth_token_time_to_live_in_seconds: Seconds the session should last for. Range is 60 to - 86400 seconds. Default value is 600. - :vartype auth_token_time_to_live_in_seconds: int + :ivar session_id: The unique ID to reference this session. Required. + :vartype session_id: str + :ivar auth_token: Bearer token to provide authentication for the Vision SDK running on a client + application. This Bearer token has limited permissions to perform only the required action and + expires after the TTL time. It is also auditable. Required. + :vartype auth_token: str :ivar status: The current status of the session. Required. Known values are: "NotStarted", - "Started", and "ResultAvailable". - :vartype status: str or ~azure.ai.vision.face.models.FaceSessionStatus - :ivar result: The latest session audit result only populated if status == 'ResultAvailable'. - :vartype result: ~azure.ai.vision.face.models.LivenessSessionAuditEntry + "Running", "Succeeded", "Failed", and "Canceled". + :vartype status: str or ~azure.ai.vision.face.models.OperationState + :ivar model_version: The model version used for liveness classification. This is an optional + parameter, and if this is not specified, then the latest supported model version will be + chosen. "2024-11-15" + :vartype model_version: str or ~azure.ai.vision.face.models.LivenessModel + :ivar results: The results of the liveness with verify session. Required. + :vartype results: ~azure.ai.vision.face.models.LivenessWithVerifySessionResults """ - id: str = rest_field(visibility=["read"]) + session_id: str = rest_field(name="sessionId", visibility=["read"]) """The unique ID to reference this session. Required.""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") - """DateTime when this session was created. Required.""" - session_start_date_time: Optional[datetime.datetime] = rest_field(name="sessionStartDateTime", format="rfc3339") - """DateTime when this session was started by the client.""" - session_expired: bool = rest_field(name="sessionExpired") - """Whether or not the session is expired. Required.""" - device_correlation_id: Optional[str] = rest_field(name="deviceCorrelationId") - """Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If - 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be - null.""" - auth_token_time_to_live_in_seconds: Optional[int] = rest_field(name="authTokenTimeToLiveInSeconds") - """Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.""" - status: Union[str, "_models.FaceSessionStatus"] = rest_field() - """The current status of the session. Required. Known values are: \"NotStarted\", \"Started\", and - \"ResultAvailable\".""" - result: Optional["_models.LivenessSessionAuditEntry"] = rest_field() - """The latest session audit result only populated if status == 'ResultAvailable'.""" + auth_token: str = rest_field(name="authToken", visibility=["read", "create", "update", "delete", "query"]) + """Bearer token to provide authentication for the Vision SDK running on a client application. This + Bearer token has limited permissions to perform only the required action and expires after the + TTL time. It is also auditable. Required.""" + status: Union[str, "_models.OperationState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The current status of the session. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + model_version: Optional[Union[str, "_models.LivenessModel"]] = rest_field( + name="modelVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The model version used for liveness classification. This is an optional parameter, and if this + is not specified, then the latest supported model version will be chosen. \"2024-11-15\"""" + results: "_models.LivenessWithVerifySessionResults" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The results of the liveness with verify session. Required.""" @overload def __init__( self, *, - created_date_time: datetime.datetime, - session_expired: bool, - status: Union[str, "_models.FaceSessionStatus"], - session_start_date_time: Optional[datetime.datetime] = None, - device_correlation_id: Optional[str] = None, - auth_token_time_to_live_in_seconds: Optional[int] = None, - result: Optional["_models.LivenessSessionAuditEntry"] = None, - ): ... + auth_token: str, + status: Union[str, "_models.OperationState"], + results: "_models.LivenessWithVerifySessionResults", + model_version: Optional[Union[str, "_models.LivenessModel"]] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MaskProperties(_model_base.Model): - """Properties describing the presence of a mask on a given face. +class LivenessWithVerifySessionAttempt(_Model): + """The liveness with verify session attempt. + + :ivar attempt_id: The attempt ID, start from 1. Required. + :vartype attempt_id: int + :ivar attempt_status: The status of the attempt. Required. Known values are: "NotStarted", + "Running", "Succeeded", "Failed", and "Canceled". + :vartype attempt_status: str or ~azure.ai.vision.face.models.OperationState + :ivar result: The result of the liveness with verify call, will be null if there is error. + :vartype result: ~azure.ai.vision.face.models.LivenessWithVerifyResult + :ivar error: The error of the liveness with verify call, will be null if there is result. + :vartype error: ~azure.ai.vision.face.models.LivenessError + """ + attempt_id: int = rest_field(name="attemptId", visibility=["read", "create", "update", "delete", "query"]) + """The attempt ID, start from 1. Required.""" + attempt_status: Union[str, "_models.OperationState"] = rest_field( + name="attemptStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the attempt. Required. Known values are: \"NotStarted\", \"Running\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + result: Optional["_models.LivenessWithVerifyResult"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The result of the liveness with verify call, will be null if there is error.""" + error: Optional["_models.LivenessError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error of the liveness with verify call, will be null if there is result.""" + + @overload + def __init__( + self, + *, + attempt_id: int, + attempt_status: Union[str, "_models.OperationState"], + result: Optional["_models.LivenessWithVerifyResult"] = None, + error: Optional["_models.LivenessError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LivenessWithVerifySessionResults(_Model): + """The results of the liveness with verify session. + + :ivar verify_references: The references used for face verification. Required. + :vartype verify_references: list[~azure.ai.vision.face.models.LivenessWithVerifyReference] + :ivar attempts: The attempts data of underlying liveness with verify call with the session. + Required. + :vartype attempts: list[~azure.ai.vision.face.models.LivenessWithVerifySessionAttempt] + """ + + verify_references: List["_models.LivenessWithVerifyReference"] = rest_field( + name="verifyReferences", visibility=["read", "create", "update", "delete", "query"] + ) + """The references used for face verification. Required.""" + attempts: List["_models.LivenessWithVerifySessionAttempt"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attempts data of underlying liveness with verify call with the session. Required.""" + + @overload + def __init__( + self, + *, + verify_references: List["_models.LivenessWithVerifyReference"], + attempts: List["_models.LivenessWithVerifySessionAttempt"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaskProperties(_Model): + """Properties describing the presence of a mask on a given face. :ivar nose_and_mouth_covered: A boolean value indicating whether nose and mouth are covered. Required. @@ -2153,9 +2139,11 @@ class MaskProperties(_model_base.Model): :vartype type: str or ~azure.ai.vision.face.models.MaskType """ - nose_and_mouth_covered: bool = rest_field(name="noseAndMouthCovered") + nose_and_mouth_covered: bool = rest_field( + name="noseAndMouthCovered", visibility=["read", "create", "update", "delete", "query"] + ) """A boolean value indicating whether nose and mouth are covered. Required.""" - type: Union[str, "_models.MaskType"] = rest_field() + type: Union[str, "_models.MaskType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Type of the mask. Required. Known values are: \"faceMask\", \"noMask\", \"otherMaskOrOcclusion\", and \"uncertain\".""" @@ -2165,23 +2153,22 @@ def __init__( *, nose_and_mouth_covered: bool, type: Union[str, "_models.MaskType"], - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class NoiseProperties(_model_base.Model): +class NoiseProperties(_Model): """Properties describing noise level of the image. - :ivar noise_level: An enum value indicating level of noise. Required. Known values are: "low", "medium", and "high". :vartype noise_level: str or ~azure.ai.vision.face.models.NoiseLevel @@ -2191,10 +2178,12 @@ class NoiseProperties(_model_base.Model): :vartype value: float """ - noise_level: Union[str, "_models.NoiseLevel"] = rest_field(name="noiseLevel") + noise_level: Union[str, "_models.NoiseLevel"] = rest_field( + name="noiseLevel", visibility=["read", "create", "update", "delete", "query"] + ) """An enum value indicating level of noise. Required. Known values are: \"low\", \"medium\", and \"high\".""" - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. Required.""" @@ -2205,23 +2194,22 @@ def __init__( *, noise_level: Union[str, "_models.NoiseLevel"], value: float, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OcclusionProperties(_model_base.Model): +class OcclusionProperties(_Model): """Properties describing occlusions on a given face. - :ivar forehead_occluded: A boolean value indicating whether forehead is occluded. Required. :vartype forehead_occluded: bool :ivar eye_occluded: A boolean value indicating whether eyes are occluded. Required. @@ -2230,11 +2218,13 @@ class OcclusionProperties(_model_base.Model): :vartype mouth_occluded: bool """ - forehead_occluded: bool = rest_field(name="foreheadOccluded") + forehead_occluded: bool = rest_field( + name="foreheadOccluded", visibility=["read", "create", "update", "delete", "query"] + ) """A boolean value indicating whether forehead is occluded. Required.""" - eye_occluded: bool = rest_field(name="eyeOccluded") + eye_occluded: bool = rest_field(name="eyeOccluded", visibility=["read", "create", "update", "delete", "query"]) """A boolean value indicating whether eyes are occluded. Required.""" - mouth_occluded: bool = rest_field(name="mouthOccluded") + mouth_occluded: bool = rest_field(name="mouthOccluded", visibility=["read", "create", "update", "delete", "query"]) """A boolean value indicating whether the mouth is occluded. Required.""" @overload @@ -2244,14 +2234,14 @@ def __init__( forehead_occluded: bool, eye_occluded: bool, mouth_occluded: bool, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_patch.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_patch.py index 620f4d62e728..8bcb627aa475 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_patch.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_patch.py @@ -1,59 +1,15 @@ -# mypy: disable_error_code=misc -# pyright: reportGeneralTypeIssues=false -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from enum import Enum from typing import List -from azure.core import CaseInsensitiveEnumMeta - -from ._enums import FaceAttributeType - - -class FaceAttributeTypeDetection01(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Available attribute options for detection_01 model.""" - - ACCESSORIES = FaceAttributeType.ACCESSORIES.value - BLUR = FaceAttributeType.BLUR.value - EXPOSURE = FaceAttributeType.EXPOSURE.value - GLASSES = FaceAttributeType.GLASSES.value - HEAD_POSE = FaceAttributeType.HEAD_POSE.value - NOISE = FaceAttributeType.NOISE.value - OCCLUSION = FaceAttributeType.OCCLUSION.value - - -class FaceAttributeTypeDetection03(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Available attribute options for detection_03 model.""" - - BLUR = FaceAttributeType.BLUR.value - HEAD_POSE = FaceAttributeType.HEAD_POSE.value - MASK = FaceAttributeType.MASK.value - - -class FaceAttributeTypeRecognition03(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Available attribute options for recognition_03 model.""" - - QUALITY_FOR_RECOGNITION = FaceAttributeType.QUALITY_FOR_RECOGNITION.value - - -class FaceAttributeTypeRecognition04(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Available attribute options for recognition_04 model.""" - - QUALITY_FOR_RECOGNITION = FaceAttributeType.QUALITY_FOR_RECOGNITION.value - - -__all__: List[str] = [ - "FaceAttributeTypeDetection01", - "FaceAttributeTypeDetection03", - "FaceAttributeTypeRecognition03", - "FaceAttributeTypeRecognition04", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/__init__.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/__init__.py index d69ac05180a1..311b6f67a8ce 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/__init__.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/__init__.py @@ -5,21 +5,27 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import LargeFaceListOperations -from ._operations import LargePersonGroupOperations -from ._operations import FaceClientOperationsMixin -from ._operations import FaceSessionClientOperationsMixin +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import FaceClientOperationsMixin # type: ignore +from ._operations import FaceSessionClientOperationsMixin # type: ignore +from ._operations import LargeFaceListOperations # type: ignore +from ._operations import LargePersonGroupOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "LargeFaceListOperations", - "LargePersonGroupOperations", "FaceClientOperationsMixin", "FaceSessionClientOperationsMixin", + "LargeFaceListOperations", + "LargePersonGroupOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_operations.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_operations.py index d67833568b43..22eea05ecacd 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_operations.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,17 +29,18 @@ from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict -from .. import _model_base, models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .. import models as _models +from .._configuration import ( + FaceAdministrationClientConfiguration, + FaceClientConfiguration, + FaceSessionClientConfiguration, +) +from .._utils.model_base import Model as _Model, SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import ClientMixinABC, prepare_multipart_form_data from .._validation import api_version_validation -from .._vendor import FaceClientMixinABC, FaceSessionClientMixinABC, prepare_multipart_form_data -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] _Unset: Any = object() T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,255 +49,231 @@ _SERIALIZER.client_side_validation = False -def build_large_face_list_create_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: +def build_face_detect_from_url_request( + *, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } + _url = "/detect" - _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct parameters + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if recognition_model is not None: + _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") + if return_face_id is not None: + _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") + if return_face_attributes is not None: + _params["returnFaceAttributes"] = _SERIALIZER.query( + "return_face_attributes", return_face_attributes, "[str]", div="," + ) + if return_face_landmarks is not None: + _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") + if return_recognition_model is not None: + _params["returnRecognitionModel"] = _SERIALIZER.query( + "return_recognition_model", return_recognition_model, "bool" + ) + if face_id_time_to_live is not None: + _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") # Construct headers if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_face_list_delete_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: +def build_face_detect_request( + *, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: str = kwargs.pop("content_type") accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } + _url = "/detect" - _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct parameters + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if recognition_model is not None: + _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") + if return_face_id is not None: + _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") + if return_face_attributes is not None: + _params["returnFaceAttributes"] = _SERIALIZER.query( + "return_face_attributes", return_face_attributes, "[str]", div="," + ) + if return_face_landmarks is not None: + _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") + if return_recognition_model is not None: + _params["returnRecognitionModel"] = _SERIALIZER.query( + "return_recognition_model", return_recognition_model, "bool" + ) + if face_id_time_to_live is not None: + _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_face_list_get_request( - large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any -) -> HttpRequest: +def build_face_find_similar_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if return_recognition_model is not None: - _params["returnRecognitionModel"] = _SERIALIZER.query( - "return_recognition_model", return_recognition_model, "bool" - ) + _url = "/findsimilars" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_update_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: +def build_face_verify_face_to_face_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/verify" # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_get_large_face_lists_request( # pylint: disable=name-too-long - *, - start: Optional[str] = None, - top: Optional[int] = None, - return_recognition_model: Optional[bool] = None, - **kwargs: Any, -) -> HttpRequest: +def build_face_group_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists" - - # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if return_recognition_model is not None: - _params["returnRecognitionModel"] = _SERIALIZER.query( - "return_recognition_model", return_recognition_model, "bool" - ) + _url = "/group" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_get_training_status_request( # pylint: disable=name-too-long - large_face_list_id: str, **kwargs: Any -) -> HttpRequest: +def build_face_find_similar_from_large_face_list_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/training" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/findsimilars" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_train_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: +def build_face_identify_from_large_person_group_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/train" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/identify" # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_add_face_from_url_request( # pylint: disable=name-too-long - large_face_list_id: str, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any, -) -> HttpRequest: +def build_face_verify_from_large_person_group_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if target_face is not None: - _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if user_data is not None: - _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") + _url = "/verify" # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_add_face_request( - large_face_list_id: str, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any, -) -> HttpRequest: +def build_face_session_create_liveness_session_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: str = kwargs.pop("content_type") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if target_face is not None: - _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if user_data is not None: - _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") + _url = "/detectLiveness-sessions" # Construct headers - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_face_list_delete_face_request( # pylint: disable=name-too-long - large_face_list_id: str, persisted_face_id: str, **kwargs: Any +def build_face_session_delete_liveness_session_request( # pylint: disable=name-too-long + session_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" + _url = "/detectLiveness-sessions/{sessionId}" path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), + "sessionId": _SERIALIZER.url("session_id", session_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -306,18 +284,17 @@ def build_large_face_list_delete_face_request( # pylint: disable=name-too-long return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_large_face_list_get_face_request( - large_face_list_id: str, persisted_face_id: str, **kwargs: Any +def build_face_session_get_liveness_session_result_request( # pylint: disable=name-too-long + session_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" + _url = "/detectLiveness-sessions/{sessionId}" path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), + "sessionId": _SERIALIZER.url("session_id", session_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -328,69 +305,143 @@ def build_large_face_list_get_face_request( return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_large_face_list_update_face_request( # pylint: disable=name-too-long - large_face_list_id: str, persisted_face_id: str, **kwargs: Any +def build_face_session_create_liveness_with_verify_session_request( # pylint: disable=name-too-long + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" - path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), + _url = "/detectLivenessWithVerify-sessions" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_face_session_delete_liveness_with_verify_session_request( # pylint: disable=name-too-long + session_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/detectLivenessWithVerify-sessions/{sessionId}" + path_format_arguments = { + "sessionId": _SERIALIZER.url("session_id", session_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_large_face_list_get_faces_request( - large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_face_session_get_liveness_with_verify_session_result_request( # pylint: disable=name-too-long + session_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largefacelists/{largeFaceListId}/persistedfaces" + _url = "/detectLivenessWithVerify-sessions/{sessionId}" path_format_arguments = { - "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), + "sessionId": _SERIALIZER.url("session_id", session_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_face_session_detect_from_session_image_request( # pylint: disable=name-too-long + *, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/detect" + # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if recognition_model is not None: + _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") + if return_face_id is not None: + _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") + if return_face_attributes is not None: + _params["returnFaceAttributes"] = _SERIALIZER.query( + "return_face_attributes", return_face_attributes, "[str]", div="," + ) + if return_face_landmarks is not None: + _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") + if return_recognition_model is not None: + _params["returnRecognitionModel"] = _SERIALIZER.query( + "return_recognition_model", return_recognition_model, "bool" + ) + if face_id_time_to_live is not None: + _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") # Construct headers + if content_type is not None: + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_create_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: +def build_face_session_get_session_image_request( # pylint: disable=name-too-long + session_image_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/octet-stream") + + # Construct URL + _url = "/sessionImages/{sessionImageId}" + path_format_arguments = { + "sessionImageId": _SERIALIZER.url("session_image_id", session_image_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_large_face_list_create_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}" + _url = "/largefacelists/{largeFaceListId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -403,15 +454,15 @@ def build_large_person_group_create_request(large_person_group_id: str, **kwargs return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_large_person_group_delete_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: +def build_large_face_list_delete_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}" + _url = "/largefacelists/{largeFaceListId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -422,8 +473,8 @@ def build_large_person_group_delete_request(large_person_group_id: str, **kwargs return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_large_person_group_get_request( - large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any +def build_large_face_list_get_request( + large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -431,9 +482,9 @@ def build_large_person_group_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}" + _url = "/largefacelists/{largeFaceListId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -450,16 +501,16 @@ def build_large_person_group_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_update_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: +def build_large_face_list_update_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}" + _url = "/largefacelists/{largeFaceListId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -472,7 +523,7 @@ def build_large_person_group_update_request(large_person_group_id: str, **kwargs return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) -def build_large_person_group_get_large_person_groups_request( # pylint: disable=name-too-long +def build_large_face_list_get_large_face_lists_request( # pylint: disable=name-too-long *, start: Optional[str] = None, top: Optional[int] = None, @@ -485,7 +536,7 @@ def build_large_person_group_get_large_person_groups_request( # pylint: disable accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups" + _url = "/largefacelists" # Construct parameters if start is not None: @@ -503,17 +554,17 @@ def build_large_person_group_get_large_person_groups_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_get_training_status_request( # pylint: disable=name-too-long - large_person_group_id: str, **kwargs: Any +def build_large_face_list_get_training_status_request( # pylint: disable=name-too-long + large_face_list_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/training" + _url = "/largefacelists/{largeFaceListId}/training" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -524,15 +575,15 @@ def build_large_person_group_get_training_status_request( # pylint: disable=nam return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_large_person_group_train_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: +def build_large_face_list_train_request(large_face_list_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/train" + _url = "/largefacelists/{largeFaceListId}/train" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -543,42 +594,93 @@ def build_large_person_group_train_request(large_person_group_id: str, **kwargs: return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_large_person_group_create_person_request( # pylint: disable=name-too-long - large_person_group_id: str, **kwargs: Any +def build_large_face_list_add_face_from_url_request( # pylint: disable=name-too-long + large_face_list_id: str, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons" + _url = "/largefacelists/{largeFaceListId}/persistedfaces" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct parameters + if target_face is not None: + _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if user_data is not None: + _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") + # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_delete_person_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, **kwargs: Any +def build_large_face_list_add_face_request( + large_face_list_id: str, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: str = kwargs.pop("content_type") accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + _url = "/largefacelists/{largeFaceListId}/persistedfaces" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if target_face is not None: + _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if user_data is not None: + _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") + + # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_large_face_list_delete_face_request( # pylint: disable=name-too-long + large_face_list_id: str, persisted_face_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" + path_format_arguments = { + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -589,18 +691,18 @@ def build_large_person_group_delete_person_request( # pylint: disable=name-too- return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_large_person_group_get_person_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, **kwargs: Any +def build_large_face_list_get_face_request( + large_face_list_id: str, persisted_face_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -611,8 +713,8 @@ def build_large_person_group_get_person_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_large_person_group_update_person_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, **kwargs: Any +def build_large_face_list_update_face_request( # pylint: disable=name-too-long + large_face_list_id: str, persisted_face_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -620,10 +722,10 @@ def build_large_person_group_update_person_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + _url = "/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -636,8 +738,8 @@ def build_large_person_group_update_person_request( # pylint: disable=name-too- return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) -def build_large_person_group_get_persons_request( # pylint: disable=name-too-long - large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_large_face_list_get_faces_request( + large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -645,9 +747,9 @@ def build_large_person_group_get_persons_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons" + _url = "/largefacelists/{largeFaceListId}/persistedfaces" path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "largeFaceListId": _SERIALIZER.url("large_face_list_id", large_face_list_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -664,98 +766,37 @@ def build_large_person_group_get_persons_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_add_face_from_url_request( # pylint: disable=name-too-long - large_person_group_id: str, - person_id: str, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any, -) -> HttpRequest: +def build_large_person_group_create_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces" + _url = "/largepersongroups/{largePersonGroupId}" path_format_arguments = { "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore - # Construct parameters - if target_face is not None: - _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if user_data is not None: - _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") - # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_large_person_group_add_face_request( # pylint: disable=name-too-long - large_person_group_id: str, - person_id: str, - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: str = kwargs.pop("content_type") - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces" - path_format_arguments = { - "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if target_face is not None: - _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if user_data is not None: - _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") - - # Construct headers - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) -def build_large_person_group_delete_face_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any -) -> HttpRequest: +def build_large_person_group_delete_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" + _url = "/largepersongroups/{largePersonGroupId}" path_format_arguments = { "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -766,43 +807,44 @@ def build_large_person_group_delete_face_request( # pylint: disable=name-too-lo return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_large_person_group_get_face_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any +def build_large_person_group_get_request( + large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" + _url = "/largepersongroups/{largePersonGroupId}" path_format_arguments = { "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct parameters + if return_recognition_model is not None: + _params["returnRecognitionModel"] = _SERIALIZER.query( + "return_recognition_model", return_recognition_model, "bool" + ) + # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_large_person_group_update_face_request( # pylint: disable=name-too-long - large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any -) -> HttpRequest: +def build_large_person_group_update_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" + _url = "/largepersongroups/{largePersonGroupId}" path_format_arguments = { "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), - "personId": _SERIALIZER.url("person_id", person_id, "str"), - "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -815,126 +857,92 @@ def build_large_person_group_update_face_request( # pylint: disable=name-too-lo return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) -def build_face_detect_from_url_request( +def build_large_person_group_get_large_person_groups_request( # pylint: disable=name-too-long *, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, + start: Optional[str] = None, + top: Optional[int] = None, return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detect" + _url = "/largepersongroups" # Construct parameters - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if recognition_model is not None: - _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") - if return_face_id is not None: - _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") - if return_face_attributes is not None: - _params["returnFaceAttributes"] = _SERIALIZER.query( - "return_face_attributes", return_face_attributes, "[str]", div="," - ) - if return_face_landmarks is not None: - _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") + if start is not None: + _params["start"] = _SERIALIZER.query("start", start, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") if return_recognition_model is not None: _params["returnRecognitionModel"] = _SERIALIZER.query( "return_recognition_model", return_recognition_model, "bool" ) - if face_id_time_to_live is not None: - _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") # Construct headers - if content_type is not None: - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_face_detect_request( - *, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, +def build_large_person_group_get_training_status_request( # pylint: disable=name-too-long + large_person_group_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: str = kwargs.pop("content_type") accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detect" + _url = "/largepersongroups/{largePersonGroupId}/training" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + } - # Construct parameters - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if recognition_model is not None: - _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") - if return_face_id is not None: - _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") - if return_face_attributes is not None: - _params["returnFaceAttributes"] = _SERIALIZER.query( - "return_face_attributes", return_face_attributes, "[str]", div="," - ) - if return_face_landmarks is not None: - _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") - if return_recognition_model is not None: - _params["returnRecognitionModel"] = _SERIALIZER.query( - "return_recognition_model", return_recognition_model, "bool" - ) - if face_id_time_to_live is not None: - _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_face_find_similar_request(**kwargs: Any) -> HttpRequest: +def build_large_person_group_train_request(large_person_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/findsimilars" + _url = "/largepersongroups/{largePersonGroupId}/train" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_face_verify_face_to_face_request(**kwargs: Any) -> HttpRequest: +def build_large_person_group_create_person_request( # pylint: disable=name-too-long + large_person_group_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/verify" + _url = "/largepersongroups/{largePersonGroupId}/persons" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers if content_type is not None: @@ -944,230 +952,195 @@ def build_face_verify_face_to_face_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_face_group_request(**kwargs: Any) -> HttpRequest: +def build_large_person_group_delete_person_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/group" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_face_find_similar_from_large_face_list_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_large_person_group_get_person_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/findsimilars" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_face_identify_from_large_person_group_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_large_person_group_update_person_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/identify" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) -def build_face_verify_from_large_person_group_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_large_person_group_get_persons_request( # pylint: disable=name-too-long + large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/verify" + _url = "/largepersongroups/{largePersonGroupId}/persons" + path_format_arguments = { + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if start is not None: + _params["start"] = _SERIALIZER.query("start", start, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -def build_face_session_create_liveness_session_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLiveness/singleModal/sessions" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -def build_face_session_delete_liveness_session_request( # pylint: disable=name-too-long - session_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLiveness/singleModal/sessions/{sessionId}" - path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_face_session_get_liveness_session_result_request( # pylint: disable=name-too-long - session_id: str, **kwargs: Any +def build_large_person_group_add_face_from_url_request( # pylint: disable=name-too-long + large_person_group_id: str, + person_id: str, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detectLiveness/singleModal/sessions/{sessionId}" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces" path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) - - -def build_face_session_get_liveness_sessions_request( # pylint: disable=name-too-long - *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLiveness/singleModal/sessions" - # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") + if target_face is not None: + _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if user_data is not None: + _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_face_session_get_liveness_session_audit_entries_request( # pylint: disable=name-too-long - session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_large_person_group_add_face_request( # pylint: disable=name-too-long + large_person_group_id: str, + person_id: str, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: str = kwargs.pop("content_type") accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detectLiveness/singleModal/sessions/{sessionId}/audit" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces" path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_face_session_create_liveness_with_verify_session_request( # pylint: disable=name-too-long - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions" - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -def build_face_session_create_liveness_with_verify_session_with_verify_image_request( # pylint: disable=name-too-long - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions" + if target_face is not None: + _params["targetFace"] = _SERIALIZER.query("target_face", target_face, "[int]", div=",") + if detection_model is not None: + _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") + if user_data is not None: + _params["userData"] = _SERIALIZER.query("user_data", user_data, "str") # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_face_session_delete_liveness_with_verify_session_request( # pylint: disable=name-too-long - session_id: str, **kwargs: Any +def build_large_person_group_delete_face_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions/{sessionId}" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1178,17 +1151,19 @@ def build_face_session_delete_liveness_with_verify_session_request( # pylint: d return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) -def build_face_session_get_liveness_with_verify_session_result_request( # pylint: disable=name-too-long - session_id: str, **kwargs: Any +def build_large_person_group_get_face_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions/{sessionId}" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1199,271 +1174,140 @@ def build_face_session_get_liveness_with_verify_session_result_request( # pylin return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_face_session_get_liveness_with_verify_sessions_request( # pylint: disable=name-too-long - *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions" - - # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_face_session_get_liveness_with_verify_session_audit_entries_request( # pylint: disable=name-too-long - session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_large_person_group_update_face_request( # pylint: disable=name-too-long + large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/detectLivenessWithVerify/singleModal/sessions/{sessionId}/audit" + _url = "/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}" path_format_arguments = { - "sessionId": _SERIALIZER.url("session_id", session_id, "str"), + "largePersonGroupId": _SERIALIZER.url("large_person_group_id", large_person_group_id, "str"), + "personId": _SERIALIZER.url("person_id", person_id, "str"), + "persistedFaceId": _SERIALIZER.url("persisted_face_id", persisted_face_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore - # Construct parameters - if start is not None: - _params["start"] = _SERIALIZER.query("start", start, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_face_session_detect_from_session_image_request( # pylint: disable=name-too-long - *, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/detect" - - # Construct parameters - if detection_model is not None: - _params["detectionModel"] = _SERIALIZER.query("detection_model", detection_model, "str") - if recognition_model is not None: - _params["recognitionModel"] = _SERIALIZER.query("recognition_model", recognition_model, "str") - if return_face_id is not None: - _params["returnFaceId"] = _SERIALIZER.query("return_face_id", return_face_id, "bool") - if return_face_attributes is not None: - _params["returnFaceAttributes"] = _SERIALIZER.query( - "return_face_attributes", return_face_attributes, "[str]", div="," - ) - if return_face_landmarks is not None: - _params["returnFaceLandmarks"] = _SERIALIZER.query("return_face_landmarks", return_face_landmarks, "bool") - if return_recognition_model is not None: - _params["returnRecognitionModel"] = _SERIALIZER.query( - "return_recognition_model", return_recognition_model, "bool" - ) - if face_id_time_to_live is not None: - _params["faceIdTimeToLive"] = _SERIALIZER.query("face_id_time_to_live", face_id_time_to_live, "int") - # Construct headers if content_type is not None: - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_face_session_get_session_image_request( # pylint: disable=name-too-long - session_image_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - accept = _headers.pop("Accept", "application/octet-stream") + return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) - # Construct URL - _url = "/session/sessionImages/{sessionImageId}" - path_format_arguments = { - "sessionImageId": _SERIALIZER.url("session_image_id", session_image_id, "str"), - } - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) - - -class LargeFaceListOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.vision.face.FaceAdministrationClient`'s - :attr:`large_face_list` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") +class FaceClientOperationsMixin(ClientMixinABC[PipelineClient, FaceClientConfiguration]): @overload - def create( - self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - + def _detect_from_url( + self, + *, + url: str, + content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, + ) -> List[_models.FaceDetectionResult]: ... @overload - def create( + def _detect_from_url( self, - large_face_list_id: str, + body: JSON, *, - name: str, content_type: str = "application/json", - user_data: Optional[str] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any, - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> List[_models.FaceDetectionResult]: ... @overload - def create( - self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _detect_from_url( + self, + body: IO[bytes], + *, + content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, + ) -> List[_models.FaceDetectionResult]: ... @distributed_trace - def create( # pylint: disable=inconsistent-return-statements + def _detect_from_url( self, - large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - name: str = _Unset, - user_data: Optional[str] = None, + url: str = _Unset, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any, - ) -> None: - """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData - and recognitionModel. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list for more - details. + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url + `_ for + more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1477,13 +1321,13 @@ def create( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -1492,8 +1336,14 @@ def create( # pylint: disable=inconsistent-return-statements else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_create_request( - large_face_list_id=large_face_list_id, + _request = build_face_detect_from_url_request( + detection_model=detection_model, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, + return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, content_type=content_type, content=_content, headers=_headers, @@ -1505,7 +1355,7 @@ def create( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1513,83 +1363,81 @@ def create( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) - @distributed_trace - def delete(self, large_face_list_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a face from a Large Face List by specified largeFaceListId and persistedFaceId. + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_large_face_list_delete_request( - large_face_list_id=large_face_list_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore + return deserialized # type: ignore @distributed_trace - def get( - self, large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any - ) -> _models.LargeFaceList: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list for more + def _detect( + self, + image_content: bytes, + *, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. + + Please refer to `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str + :param image_content: The input image binary. Required. + :type image_content: bytes + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. + false. This is only applicable when returnFaceId = true. Default value is None. :paramtype return_recognition_model: bool - :return: LargeFaceList. The LargeFaceList is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargeFaceList + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1600,14 +1448,24 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargeFaceList] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) - _request = build_large_face_list_get_request( - large_face_list_id=large_face_list_id, + _content = image_content + + _request = build_face_detect_request( + detection_model=detection_model, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -1631,13 +1489,13 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargeFaceList, response.json()) + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1645,103 +1503,127 @@ def get( return deserialized # type: ignore @overload - def update( - self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + def find_similar( + self, + *, + face_id: str, + face_ids: List[str], + content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + **kwargs: Any, + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the + faceIds will expire 24 hours after the detection call. The number of faceIds is limited to + 1000. Required. + :paramtype face_ids: list[str] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, - large_face_list_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + def find_similar( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + def find_similar( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( # pylint: disable=inconsistent-return-statements + def find_similar( self, - large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - name: Optional[str] = None, - user_data: Optional[str] = None, + face_id: str = _Unset, + face_ids: List[str] = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list for more + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId + array contains the faces created by Detect. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the + faceIds will expire 24 hours after the detection call. The number of faceIds is limited to + 1000. Required. + :paramtype face_ids: list[str] + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1756,20 +1638,28 @@ def update( # pylint: disable=inconsistent-return-statements _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_face_list_update_request( - large_face_list_id=large_face_list_id, + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + body = { + "faceId": face_id, + "faceIds": face_ids, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + "mode": mode, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_find_similar_request( content_type=content_type, content=_content, headers=_headers, @@ -1781,7 +1671,7 @@ def update( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1789,39 +1679,109 @@ def update( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def verify_face_to_face( + self, *, face_id1: str, face_id2: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :keyword face_id1: The faceId of one face, come from "Detect". Required. + :paramtype face_id1: str + :keyword face_id2: The faceId of another face, come from "Detect". Required. + :paramtype face_id2: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify_face_to_face( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify_face_to_face( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get_large_face_lists( - self, - *, - start: Optional[str] = None, - top: Optional[int] = None, - return_recognition_model: Optional[bool] = None, - **kwargs: Any, - ) -> List[_models.LargeFaceList]: - """List Large Face Lists' information of largeFaceListId, name, userData and recognitionModel. + def verify_face_to_face( + self, body: Union[JSON, IO[bytes]] = _Unset, *, face_id1: str = _Unset, face_id2: str = _Unset, **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether two faces belong to a same person. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-lists for more - details. + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face + `_ + for more details. - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: list of LargeFaceList - :rtype: list[~azure.ai.vision.face.models.LargeFaceList] + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_id1: The faceId of one face, come from "Detect". Required. + :paramtype face_id1: str + :keyword face_id2: The faceId of another face, come from "Detect". Required. + :paramtype face_id2: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1832,15 +1792,29 @@ def get_large_face_lists( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LargeFaceList]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) - _request = build_large_face_list_get_large_face_lists_request( - start=start, - top=top, - return_recognition_model=return_recognition_model, + if body is _Unset: + if face_id1 is _Unset: + raise TypeError("missing required argument: face_id1") + if face_id2 is _Unset: + raise TypeError("missing required argument: face_id2") + body = {"faceId1": face_id1, "faceId2": face_id2} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_verify_face_to_face_request( + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -1864,30 +1838,95 @@ def get_large_face_lists( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LargeFaceList], response.json()) + deserialized = _deserialize(_models.FaceVerificationResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def group( + self, *, face_ids: List[str], content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. + + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. + + :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. + Required. + :paramtype face_ids: list[str] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def group(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. + + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. + + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models.FaceTrainingResult: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-training-status - for more details. + def group( + self, body: Union[JSON, IO[bytes]] = _Unset, *, face_ids: List[str] = _Unset, **kwargs: Any + ) -> _models.FaceGroupingResult: + """Divide candidate faces into groups based on face similarity. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceTrainingResult + Please refer to `https://learn.microsoft.com/rest/api/face/face-recognition-operations/group + `_ for more + details. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. + Required. + :paramtype face_ids: list[str] + :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceGroupingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1898,13 +1937,27 @@ def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FaceGroupingResult] = kwargs.pop("cls", None) - _request = build_large_face_list_get_training_status_request( - large_face_list_id=large_face_list_id, + if body is _Unset: + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + body = {"faceIds": face_ids} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_group_request( + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -1928,289 +1981,141 @@ def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceTrainingResult, response.json()) + deserialized = _deserialize(_models.FaceGroupingResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _train_initial(self, large_face_list_id: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_large_face_list_train_request( - large_face_list_id=large_face_list_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_train(self, large_face_list_id: str, **kwargs: Any) -> LROPoller[None]: - """Submit a Large Face List training task. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/train-large-face-list for more - details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._train_initial( - large_face_list_id=large_face_list_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @overload - def add_face_from_url( + def find_similar_from_large_face_list( self, - large_face_list_id: str, - body: JSON, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + face_id: str, + large_face_list_id: str, content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param body: Required. - :type body: JSON - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, + created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which + are persisted and will never expire. Required. + :paramtype large_face_list_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def add_face_from_url( - self, - large_face_list_id: str, - *, - url: str, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + def find_similar_from_large_face_list( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def add_face_from_url( - self, - large_face_list_id: str, - body: IO[bytes], - *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + def find_similar_from_large_face_list( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Required. :type body: IO[bytes] - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def add_face_from_url( + def find_similar_from_large_face_list( self, - large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - url: str = _Unset, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + face_id: str = _Unset, + large_face_list_id: str = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + ) -> List[_models.FaceFindSimilarResult]: + """Given query face's faceId, to search the similar-looking faces from a Large Face List. A + 'largeFaceListId' is created by Create Large Face List. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + `_ for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid + faceId. Note that this faceId is not persisted and will expire 24 hours after the detection + call. Required. + :paramtype face_id: str + :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, + created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which + are persisted and will never expire. Required. + :paramtype large_face_list_id: str + :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid + range is [1, 1000]. Default value is 20. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default + value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. + :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode + :return: list of FaceFindSimilarResult + :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2225,12 +2130,19 @@ def add_face_from_url( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if large_face_list_id is _Unset: + raise TypeError("missing required argument: large_face_list_id") + body = { + "faceId": face_id, + "largeFaceListId": large_face_list_id, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + "mode": mode, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -2239,11 +2151,7 @@ def add_face_from_url( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_add_face_from_url_request( - large_face_list_id=large_face_list_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, + _request = build_face_find_similar_from_large_face_list_request( content_type=content_type, content=_content, headers=_headers, @@ -2269,54 +2177,143 @@ def add_face_from_url( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def identify_from_large_person_group( + self, + *, + face_ids: List[str], + large_person_group_id: str, + content_type: str = "application/json", + max_num_of_candidates_returned: Optional[int] = None, + confidence_threshold: Optional[float] = None, + **kwargs: Any, + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are + identified independently. The valid number of faceIds is between [1, 10]. Required. + :paramtype face_ids: list[str] + :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by + "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be + provided at the same time. Required. + :paramtype large_person_group_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 + and 100. Default value is 10. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword confidence_threshold: Customized identification confidence threshold, in the range of + [0, 1]. Advanced user can tweak this value to override default internal threshold for better + precision on their scenario data. Note there is no guarantee of this threshold value working on + other data and after algorithm updates. Default value is None. + :paramtype confidence_threshold: float + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def identify_from_large_person_group( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def identify_from_large_person_group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def add_face( + def identify_from_large_person_group( self, - large_face_list_id: str, - image_content: bytes, + body: Union[JSON, IO[bytes]] = _Unset, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + face_ids: List[str] = _Unset, + large_person_group_id: str = _Unset, + max_num_of_candidates_returned: Optional[int] = None, + confidence_threshold: Optional[float] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a specified Large Face List, up to 1,000,000 faces. + ) -> List[_models.FaceIdentificationResult]: + """1-to-many identification to find the closest matches of the specific query person face from a + Large Person Group. Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face for - more details. + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `_ + for more details. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param image_content: The image to be analyzed. Required. - :type image_content: bytes - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are + identified independently. The valid number of faceIds is between [1, 10]. Required. + :paramtype face_ids: list[str] + :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by + "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be + provided at the same time. Required. + :paramtype large_person_group_id: str + :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 + and 100. Default value is 10. Default value is None. + :paramtype max_num_of_candidates_returned: int + :keyword confidence_threshold: Customized identification confidence threshold, in the range of + [0, 1]. Advanced user can tweak this value to override default internal threshold for better + precision on their scenario data. Note there is no guarantee of this threshold value working on + other data and after algorithm updates. Default value is None. + :paramtype confidence_threshold: float + :return: list of FaceIdentificationResult + :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2330,16 +2327,29 @@ def add_face( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.FaceIdentificationResult]] = kwargs.pop("cls", None) - _content = image_content + if body is _Unset: + if face_ids is _Unset: + raise TypeError("missing required argument: face_ids") + if large_person_group_id is _Unset: + raise TypeError("missing required argument: large_person_group_id") + body = { + "confidenceThreshold": confidence_threshold, + "faceIds": face_ids, + "largePersonGroupId": large_person_group_id, + "maxNumOfCandidatesReturned": max_num_of_candidates_returned, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_add_face_request( - large_face_list_id=large_face_list_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, + _request = build_face_identify_from_large_person_group_request( content_type=content_type, content=_content, headers=_headers, @@ -2365,89 +2375,121 @@ def add_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + deserialized = _deserialize(List[_models.FaceIdentificationResult], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete_face( # pylint: disable=inconsistent-return-statements - self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list-face for - more details. + @overload + def verify_from_large_person_group( + self, + *, + face_id: str, + large_person_group_id: str, + person_id: str, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: None - :rtype: None + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. + + :keyword face_id: The faceId of the face, come from "Detect". Required. + :paramtype face_id: str + :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading + a specified person. largePersonGroupId is created in "Create Large Person Group". Required. + :paramtype large_person_group_id: str + :keyword person_id: Specify a certain person in Large Person Group. Required. + :paramtype person_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + @overload + def verify_from_large_person_group( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - _request = build_large_face_list_delete_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - response = pipeline_response.http_response + @overload + def verify_from_large_person_group( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. - if cls: - return cls(pipeline_response, None, {}) # type: ignore + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any) -> _models.LargeFaceListFace: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-face for - more details. + def verify_from_large_person_group( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + face_id: str = _Unset, + large_person_group_id: str = _Unset, + person_id: str = _Unset, + **kwargs: Any, + ) -> _models.FaceVerificationResult: + """Verify whether a face belongs to a person in a Large Person Group. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: LargeFaceListFace. The LargeFaceListFace is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargeFaceListFace + Please refer to + `https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + `_ + for more details. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword face_id: The faceId of the face, come from "Detect". Required. + :paramtype face_id: str + :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading + a specified person. largePersonGroupId is created in "Create Large Person Group". Required. + :paramtype large_person_group_id: str + :keyword person_id: Specify a certain person in Large Person Group. Required. + :paramtype person_id: str + :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceVerificationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2458,14 +2500,31 @@ def get_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: An } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargeFaceListFace] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) - _request = build_large_face_list_get_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, + if body is _Unset: + if face_id is _Unset: + raise TypeError("missing required argument: face_id") + if large_person_group_id is _Unset: + raise TypeError("missing required argument: large_person_group_id") + if person_id is _Unset: + raise TypeError("missing required argument: person_id") + body = {"faceId": face_id, "largePersonGroupId": large_person_group_id, "personId": person_id} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_face_verify_from_large_person_group_request( + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -2489,133 +2548,105 @@ def get_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: An except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargeFaceListFace, response.json()) + deserialized = _deserialize(_models.FaceVerificationResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class FaceSessionClientOperationsMixin(ClientMixinABC[PipelineClient, FaceSessionClientConfiguration]): + @overload - def update_face( - self, - large_face_list_id: str, - persisted_face_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + def create_liveness_session( + self, body: _models.CreateLivenessSessionContent, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. - :type body: JSON + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. + + :param body: Body parameter. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update_face( - self, - large_face_list_id: str, - persisted_face_id: str, - *, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + def create_liveness_session( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. + + :param body: Body parameter. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update_face( - self, - large_face_list_id: str, - persisted_face_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + def create_liveness_session( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. + + :param body: Body parameter. Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update_face( # pylint: disable=inconsistent-return-statements - self, - large_face_list_id: str, - persisted_face_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face for - more details. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["content_type", "accept"]}, + ) + def create_liveness_session( + self, body: Union[_models.CreateLivenessSessionContent, JSON, IO[bytes]], **kwargs: Any + ) -> _models.LivenessSession: + """Create a new detect liveness session. - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + `_ + for more details. + + :param body: Body parameter. Is one of the following types: CreateLivenessSessionContent, JSON, + IO[bytes] Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent or JSON or IO[bytes] + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2630,11 +2661,8 @@ def update_face( # pylint: disable=inconsistent-return-statements _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) - if body is _Unset: - body = {"userData": user_data} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None if isinstance(body, (IOBase, bytes)): @@ -2642,9 +2670,7 @@ def update_face( # pylint: disable=inconsistent-return-statements else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_face_list_update_face_request( - large_face_list_id=large_face_list_id, - persisted_face_id=persisted_face_id, + _request = build_face_session_create_liveness_session_request( content_type=content_type, content=_content, headers=_headers, @@ -2656,70 +2682,6 @@ def update_face( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get_faces( - self, large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LargeFaceListFace]: - """List faces' persistedFaceId and userData in a specified Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-faces for - more details. - - :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', - maximum length is 64. Required. - :type large_face_list_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LargeFaceListFace - :rtype: list[~azure.ai.vision.face.models.LargeFaceListFace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LargeFaceListFace]] = kwargs.pop("cls", None) - - _request = build_large_face_list_get_faces_request( - large_face_list_id=large_face_list_id, - start=start, - top=top, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -2734,159 +2696,36 @@ def get_faces( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LargeFaceListFace], response.json()) + deserialized = _deserialize(_models.LivenessSession, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class LargePersonGroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.vision.face.FaceAdministrationClient`'s - :attr:`large_person_group` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - large_person_group_id: str, - *, - name: str, - content_type: str = "application/json", - user_data: Optional[str] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - **kwargs: Any, - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def create( # pylint: disable=inconsistent-return-statements - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - user_data: Optional[str] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - **kwargs: Any, + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + def delete_liveness_session( # pylint: disable=inconsistent-return-statements + self, session_id: str, **kwargs: Any ) -> None: - """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional - userData and recognitionModel. + """Delete all session related information for matching the specified session id. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-session + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported - 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and - 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since - its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall - accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: - "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is - None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :param session_id: The unique ID to reference this session. Required. + :type session_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -2899,28 +2738,13 @@ def create( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_create_request( - large_person_group_id=large_person_group_id, - content_type=content_type, - content=_content, + _request = build_face_session_delete_liveness_session_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -2937,26 +2761,29 @@ def create( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, large_person_group_id: str, **kwargs: Any - ) -> None: + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models.LivenessSession: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group for - more details. + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-result + `_ + for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :return: None - :rtype: None + :param session_id: The unique ID to reference this session. Required. + :type session_id: str + :return: LivenessSession. The LivenessSession is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessSession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2970,10 +2797,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) - _request = build_large_person_group_delete_request( - large_person_group_id=large_person_group_id, + _request = build_face_session_get_liveness_session_result_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -2983,7 +2810,7 @@ def delete( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2991,28 +2818,82 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get( - self, large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any - ) -> _models.LargePersonGroup: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group for - more details. + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.LivenessSession, response.json()) - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: LargePersonGroup. The LargePersonGroup is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroup + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_liveness_with_verify_session( + self, body: _models.CreateLivenessWithVerifySessionContent, **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. + + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. + + :param body: Request content of liveness with verify session creation. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_liveness_with_verify_session(self, body: JSON, **kwargs: Any) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. + + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. + + :param body: Request content of liveness with verify session creation. Required. + :type body: JSON + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["content_type", "accept"]}, + ) + def create_liveness_with_verify_session( + self, body: Union[_models.CreateLivenessWithVerifySessionContent, JSON], **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Create a new liveness session with verify. Provide the verify image during session creation. + + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + `_ + for more details. + + :param body: Request content of liveness with verify session creation. Is either a + CreateLivenessWithVerifySessionContent type or a JSON type. Required. + :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3026,11 +2907,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargePersonGroup] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) - _request = build_large_person_group_get_request( - large_person_group_id=large_person_group_id, - return_recognition_model=return_recognition_model, + _body = body.as_dict() if isinstance(body, _Model) else body + _file_fields: List[str] = ["verifyImage"] + _data_fields: List[str] = [ + "livenessOperationMode", + "deviceCorrelationIdSetInClient", + "enableSessionImage", + "livenessModelVersion", + "returnVerifyImageHash", + "verifyConfidenceThreshold", + "deviceCorrelationId", + "authTokenTimeToLiveInSeconds", + ] + _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) + + _request = build_face_session_create_liveness_with_verify_session_request( + files=_files, + data=_data, headers=_headers, params=_params, ) @@ -3054,111 +2949,36 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargePersonGroup, response.json()) + deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - large_person_group_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def update( # pylint: disable=inconsistent-return-statements - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any, + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + def delete_liveness_with_verify_session( # pylint: disable=inconsistent-return-statements + self, session_id: str, **kwargs: Any ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group for - more details. + """Delete all session related information for matching the specified session id. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str + Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-with-verify-session + `_ + for more details. + + :param session_id: The unique ID to reference this session. Required. + :type session_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -3171,26 +2991,13 @@ def update( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_update_request( - large_person_group_id=large_person_group_id, - content_type=content_type, - content=_content, + _request = build_face_session_delete_liveness_with_verify_session_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -3207,40 +3014,32 @@ def update( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get_large_person_groups( - self, - *, - start: Optional[str] = None, - top: Optional[int] = None, - return_recognition_model: Optional[bool] = None, - **kwargs: Any, - ) -> List[_models.LargePersonGroup]: - """List all existing Large Person Groups' largePersonGroupId, name, userData and recognitionModel. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-groups for - more details. + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_id", "accept"]}, + ) + def get_liveness_with_verify_session_result( + self, session_id: str, **kwargs: Any + ) -> _models.LivenessWithVerifySession: + """Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-result + `_ + for more details. - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. Default value is None. - :paramtype return_recognition_model: bool - :return: list of LargePersonGroup - :rtype: list[~azure.ai.vision.face.models.LargePersonGroup] + :param session_id: The unique ID to reference this session. Required. + :type session_id: str + :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3254,12 +3053,10 @@ def get_large_person_groups( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LargePersonGroup]] = kwargs.pop("cls", None) + cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) - _request = build_large_person_group_get_large_person_groups_request( - start=start, - top=top, - return_recognition_model=return_recognition_model, + _request = build_face_session_get_liveness_with_verify_session_result_request( + session_id=session_id, headers=_headers, params=_params, ) @@ -3283,910 +3080,287 @@ def get_large_person_groups( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LargePersonGroup], response.json()) + deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get_training_status(self, large_person_group_id: str, **kwargs: Any) -> _models.FaceTrainingResult: - """To check Large Person Group training status completed or still ongoing. Large Person Group - training is an asynchronous operation triggered by "Train Large Person Group" API. + @overload + def detect_from_session_image( + self, + *, + session_image_id: str, + content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, + **kwargs: Any, + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-training-status + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceTrainingResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) - - _request = build_large_person_group_get_training_status_request( - large_person_group_id=large_person_group_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.FaceTrainingResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _train_initial(self, large_person_group_id: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_large_person_group_train_request( - large_person_group_id=large_person_group_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_train(self, large_person_group_id: str, **kwargs: Any) -> LROPoller[None]: - """Submit a Large Person Group training task. Training is a crucial step that only a trained Large - Person Group can be used by "Identify From Large Person Group". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/train-large-person-group for - more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._train_initial( - large_person_group_id=large_person_group_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - def create_person( - self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_person( - self, - large_person_group_id: str, - *, - name: str, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any, - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_person( - self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_person( - self, - large_person_group_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> _models.CreatePersonResult: - """Create a new person in a specified Large Person Group. To add face to this person, please call - "Add Large Person Group Person Face". - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Required. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreatePersonResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreatePersonResult] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_create_person_request( - large_person_group_id=large_person_group_id, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreatePersonResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_person( # pylint: disable=inconsistent-return-statements - self, large_person_group_id: str, person_id: str, **kwargs: Any - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_large_person_group_delete_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get_person(self, large_person_group_id: str, person_id: str, **kwargs: Any) -> _models.LargePersonGroupPerson: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :return: LargePersonGroupPerson. The LargePersonGroupPerson is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroupPerson - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.LargePersonGroupPerson] = kwargs.pop("cls", None) - - _request = build_large_person_group_get_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.LargePersonGroupPerson, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update_person( - self, - large_person_group_id: str, - person_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_person( - self, - large_person_group_id: str, - person_id: str, - *, - content_type: str = "application/json", - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_person( - self, - large_person_group_id: str, - person_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_person( # pylint: disable=inconsistent-return-statements - self, - large_person_group_id: str, - person_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: Optional[str] = None, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: User defined name, maximum length is 128. Default value is None. - :paramtype name: str - :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is - None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"name": name, "userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_update_person_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get_persons( - self, large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LargePersonGroupPerson]: - """List all persons' information in the specified Large Person Group, including personId, name, - userData and persistedFaceIds of registered person faces. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-persons - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + :keyword session_image_id: Id of session image. Required. + :paramtype session_image_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value is None. - :paramtype top: int - :return: list of LargePersonGroupPerson - :rtype: list[~azure.ai.vision.face.models.LargePersonGroupPerson] + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LargePersonGroupPerson]] = kwargs.pop("cls", None) - - _request = build_large_person_group_get_persons_request( - large_person_group_id=large_person_group_id, - start=start, - top=top, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.LargePersonGroupPerson], response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore @overload - def add_face_from_url( + def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, body: JSON, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str :param body: Required. :type body: JSON - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def add_face_from_url( - self, - large_person_group_id: str, - person_id: str, - *, - url: str, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. - - Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def add_face_from_url( + def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, body: IO[bytes], *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, content_type: str = "application/json", + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str :param body: Required. :type body: IO[bytes] - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def add_face_from_url( + @api_version_validation( + method_added_on="v1.2-preview.1", + params_added_on={ + "v1.2-preview.1": [ + "content_type", + "detection_model", + "recognition_model", + "return_face_id", + "return_face_attributes", + "return_face_landmarks", + "return_recognition_model", + "face_id_time_to_live", + "accept", + ] + }, + ) + def detect_from_session_image( self, - large_person_group_id: str, - person_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - url: str = _Unset, - target_face: Optional[List[int]] = None, + session_image_id: str = _Unset, detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + return_face_id: Optional[bool] = None, + return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, + return_face_landmarks: Optional[bool] = None, + return_recognition_model: Optional[bool] = None, + face_id_time_to_live: Optional[int] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> List[_models.FaceDetectionResult]: + """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, + and attributes. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `_ for more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] + :keyword session_image_id: Id of session image. Required. + :paramtype session_image_id: str :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. + value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on + smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", + "detection_02", and "detection_03". Default value is None. :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. - :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. + Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', + 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' + is recommended since its accuracy is improved on faces wearing masks compared with + 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and + 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and + "recognition_04". Default value is None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :keyword return_face_id: Return faceIds of the detected faces or not. The default value is + true. Default value is None. + :paramtype return_face_id: bool + :keyword return_face_attributes: Analyze and return the one or more specified face attributes + in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute + analysis has additional computational and time cost. Default value is None. + :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] + :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default + value is false. Default value is None. + :paramtype return_face_landmarks: bool + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. This is only applicable when returnFaceId = true. Default value is None. + :paramtype return_recognition_model: bool + :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported + range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value + is None. + :paramtype face_id_time_to_live: int + :return: list of FaceDetectionResult + :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4200,13 +3374,13 @@ def add_face_from_url( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) + cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + if session_image_id is _Unset: + raise TypeError("missing required argument: session_image_id") + body = {"sessionImageId": session_image_id} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -4215,14 +3389,84 @@ def add_face_from_url( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_person_group_add_face_from_url_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, - content_type=content_type, - content=_content, + _request = build_face_session_detect_from_session_image_request( + detection_model=detection_model, + recognition_model=recognition_model, + return_face_id=return_face_id, + return_face_attributes=return_face_attributes, + return_face_landmarks=return_face_landmarks, + return_recognition_model=return_recognition_model, + face_id_time_to_live=face_id_time_to_live, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="v1.2", + params_added_on={"v1.2": ["session_image_id", "accept"]}, + ) + def get_session_image(self, session_image_id: str, **kwargs: Any) -> Iterator[bytes]: + """Please refer to + `https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-session-image + `_ for + more details. + + :param session_image_id: The request ID of the image to be retrieved. Required. + :type session_image_id: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_face_session_get_session_image_request( + session_image_id=session_image_id, headers=_headers, params=_params, ) @@ -4232,7 +3476,7 @@ def add_face_from_url( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4246,56 +3490,169 @@ def add_face_from_url( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + +class LargeFaceListOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.vision.face.FaceAdministrationClient`'s + :attr:`large_face_list` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FaceAdministrationClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create( + self, + large_face_list_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + **kwargs: Any, + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def add_face( + def create( # pylint: disable=inconsistent-return-statements self, - large_person_group_id: str, - person_id: str, - image_content: bytes, + large_face_list_id: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - target_face: Optional[List[int]] = None, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + name: str = _Unset, user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, **kwargs: Any, - ) -> _models.AddFaceResult: - """Add a face to a person into a Large Person Group for face identification or verification. + ) -> None: + """Create an empty Large Face List with user-specified largeFaceListId, name, an optional userData + and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/create-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param image_content: The image to be analyzed. Required. - :type image_content: bytes - :keyword target_face: A face rectangle to specify the target face to be added to a person, in - the format of 'targetFace=left,top,width,height'. Default value is None. - :paramtype target_face: list[int] - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". - Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default - value is None. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. :paramtype user_data: str - :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.AddFaceResult + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4309,17 +3666,23 @@ def add_face( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _content = image_content + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_large_person_group_add_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - target_face=target_face, - detection_model=detection_model, - user_data=user_data, + _request = build_large_face_list_create_request( + large_face_list_id=large_face_list_id, content_type=content_type, content=_content, headers=_headers, @@ -4331,7 +3694,7 @@ def add_face( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4339,42 +3702,25 @@ def add_face( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.AddFaceResult, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delete_face( # pylint: disable=inconsistent-return-statements - self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any - ) -> None: - """Delete a face from a person in a Large Person Group by specified largePersonGroupId, personId - and persistedFaceId. + def delete(self, large_face_list_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a face from a Large Face List by specified largeFaceListId and persistedFaceId. Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -4392,10 +3738,8 @@ def delete_face( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_large_person_group_delete_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, + _request = build_large_face_list_delete_request( + large_face_list_id=large_face_list_id, headers=_headers, params=_params, ) @@ -4414,29 +3758,29 @@ def delete_face( # pylint: disable=inconsistent-return-statements if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get_face( - self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any - ) -> _models.LargePersonGroupPersonFace: + def get( + self, large_face_list_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any + ) -> _models.LargeFaceList: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list + `_ for more + details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :return: LargePersonGroupPersonFace. The LargePersonGroupPersonFace is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.LargePersonGroupPersonFace + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: LargeFaceList. The LargeFaceList is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargeFaceList :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4450,12 +3794,11 @@ def get_face( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LargePersonGroupPersonFace] = kwargs.pop("cls", None) + cls: ClsType[_models.LargeFaceList] = kwargs.pop("cls", None) - _request = build_large_person_group_get_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, + _request = build_large_face_list_get_request( + large_face_list_id=large_face_list_id, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -4479,13 +3822,13 @@ def get_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LargePersonGroupPersonFace, response.json()) + deserialized = _deserialize(_models.LargeFaceList, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4493,89 +3836,70 @@ def get_face( return deserialized # type: ignore @overload - def update_face( + def update( self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: JSON, + large_face_list_id: str, *, content_type: str = "application/json", + name: Optional[str] = None, + user_data: Optional[str] = None, **kwargs: Any, ) -> None: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Required. - :type body: JSON + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - *, - content_type: str = "application/json", - user_data: Optional[str] = None, - **kwargs: Any, + def update( + self, large_face_list_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update_face( - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, + def update( + self, large_face_list_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -4587,197 +3911,32 @@ def update_face( """ @distributed_trace - def update_face( # pylint: disable=inconsistent-return-statements - self, - large_person_group_id: str, - person_id: str, - persisted_face_id: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - user_data: Optional[str] = None, - **kwargs: Any, - ) -> None: - """Please refer to - https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face - for more details. - - :param large_person_group_id: ID of the container. Required. - :type large_person_group_id: str - :param person_id: ID of the person. Required. - :type person_id: str - :param persisted_face_id: Face ID of the face. Required. - :type persisted_face_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default - value is None. - :paramtype user_data: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"userData": user_data} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_large_person_group_update_face_request( - large_person_group_id=large_person_group_id, - person_id=person_id, - persisted_face_id=persisted_face_id, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - -class FaceClientOperationsMixin(FaceClientMixinABC): - - @overload - def _detect_from_url( - self, - body: JSON, - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - @overload - def _detect_from_url( - self, - *, - url: str, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - @overload - def _detect_from_url( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: ... - - @distributed_trace - def _detect_from_url( + def update( # pylint: disable=inconsistent-return-statements self, + large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, - *, - url: str = _Unset, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-url for more - details. + *, + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list + `_ for + more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword url: URL of input image. Required. - :paramtype url: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4791,13 +3950,11 @@ def _detect_from_url( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if url is _Unset: - raise TypeError("missing required argument: url") - body = {"url": url} + body = {"name": name, "userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -4806,14 +3963,8 @@ def _detect_from_url( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_detect_from_url_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, + _request = build_large_face_list_update_request( + large_face_list_id=large_face_list_id, content_type=content_type, content=_content, headers=_headers, @@ -4825,6 +3976,76 @@ def _detect_from_url( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_large_face_lists( + self, + *, + start: Optional[str] = None, + top: Optional[int] = None, + return_recognition_model: Optional[bool] = None, + **kwargs: Any, + ) -> List[_models.LargeFaceList]: + """List Large Face Lists' information of largeFaceListId, name, userData and recognitionModel. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-lists + `_ for + more details. + + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: list of LargeFaceList + :rtype: list[~azure.ai.vision.face.models.LargeFaceList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LargeFaceList]] = kwargs.pop("cls", None) + + _request = build_large_face_list_get_large_face_lists_request( + start=start, + top=top, + return_recognition_model=return_recognition_model, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -4839,13 +4060,13 @@ def _detect_from_url( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + deserialized = _deserialize(List[_models.LargeFaceList], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4853,60 +4074,17 @@ def _detect_from_url( return deserialized # type: ignore @distributed_trace - def _detect( - self, - image_content: bytes, - *, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to https://learn.microsoft.com/rest/api/face/face-detection-operations/detect for - more details. + def get_training_status(self, large_face_list_id: str, **kwargs: Any) -> _models.FaceTrainingResult: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-training-status + `_ + for more details. - :param image_content: The input image binary. Required. - :type image_content: bytes - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceTrainingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4917,24 +4095,65 @@ def _detect( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) + cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) - _content = image_content + _request = build_large_face_list_get_training_status_request( + large_face_list_id=large_face_list_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_face_detect_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - content_type=content_type, - content=_content, + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.FaceTrainingResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _train_initial(self, large_face_list_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_large_face_list_train_request( + large_face_list_id=large_face_list_id, headers=_headers, params=_params, ) @@ -4944,151 +4163,256 @@ def _detect( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + response_headers = {} + response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @distributed_trace + def begin_train(self, large_face_list_id: str, **kwargs: Any) -> LROPoller[None]: + """Submit a Large Face List training task. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/train-large-face-list + `_ for + more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._train_initial( + large_face_list_id=large_face_list_id, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + @overload - def find_similar( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. + def add_face_from_url( + self, + large_face_list_id: str, + *, + url: str, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. - :param body: Required. - :type body: JSON + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def find_similar( + def add_face_from_url( self, + large_face_list_id: str, + body: JSON, *, - face_id: str, - face_ids: List[str], + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any, - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the - faceIds will expire 24 hours after the detection call. The number of faceIds is limited to - 1000. Required. - :paramtype face_ids: list[str] + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param body: Required. + :type body: JSON + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def find_similar( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. + def add_face_from_url( + self, + large_face_list_id: str, + body: IO[bytes], + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Required. :type body: IO[bytes] + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def find_similar( + def add_face_from_url( self, + large_face_list_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - face_id: str = _Unset, - face_ids: List[str] = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + url: str = _Unset, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, **kwargs: Any, - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a faceId array. A faceId - array contains the faces created by Detect. + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar for more - details. + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face-from-url + `_ + for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword face_ids: An array of candidate faceIds. All of them are created by "Detect" and the - faceIds will expire 24 hours after the detection call. The number of faceIds is limited to - 1000. Required. - :paramtype face_ids: list[str] - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :type body: JSON or IO[bytes] + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5103,19 +4427,12 @@ def find_similar( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - body = { - "faceId": face_id, - "faceIds": face_ids, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - "mode": mode, - } + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -5124,7 +4441,11 @@ def find_similar( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_find_similar_request( + _request = build_large_face_list_add_face_from_url_request( + large_face_list_id=large_face_list_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, content_type=content_type, content=_content, headers=_headers, @@ -5150,99 +4471,55 @@ def find_similar( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def verify_face_to_face( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. - - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def verify_face_to_face( - self, *, face_id1: str, face_id2: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. - - :keyword face_id1: The faceId of one face, come from "Detect". Required. - :paramtype face_id1: str - :keyword face_id2: The faceId of another face, come from "Detect". Required. - :paramtype face_id2: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def verify_face_to_face( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for - more details. - - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def verify_face_to_face( - self, body: Union[JSON, IO[bytes]] = _Unset, *, face_id1: str = _Unset, face_id2: str = _Unset, **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether two faces belong to a same person. + def add_face( + self, + large_face_list_id: str, + image_content: bytes, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a specified Large Face List, up to 1,000,000 faces. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-face-to-face for + `https://learn.microsoft.com/rest/api/face/face-list-operations/add-large-face-list-face + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_id1: The faceId of one face, come from "Detect". Required. - :paramtype face_id1: str - :keyword face_id2: The faceId of another face, come from "Detect". Required. - :paramtype face_id2: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param image_content: The image to be analyzed. Required. + :type image_content: bytes + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5256,24 +4533,16 @@ def verify_face_to_face( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - if body is _Unset: - if face_id1 is _Unset: - raise TypeError("missing required argument: face_id1") - if face_id2 is _Unset: - raise TypeError("missing required argument: face_id2") - body = {"faceId1": face_id1, "faceId2": face_id2} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = image_content - _request = build_face_verify_face_to_face_request( + _request = build_large_face_list_add_face_request( + large_face_list_id=large_face_list_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, content_type=content_type, content=_content, headers=_headers, @@ -5299,91 +4568,91 @@ def verify_face_to_face( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceVerificationResult, response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def group(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. - - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + @distributed_trace + def delete_face( # pylint: disable=inconsistent-return-statements + self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/delete-large-face-list-face + `_ + for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def group( - self, *, face_ids: List[str], content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. - - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. - Required. - :paramtype face_ids: list[str] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + cls: ClsType[None] = kwargs.pop("cls", None) - @overload - def group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + _request = build_large_face_list_delete_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for - more details. + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + response = pipeline_response.http_response - @distributed_trace - def group( - self, body: Union[JSON, IO[bytes]] = _Unset, *, face_ids: List[str] = _Unset, **kwargs: Any - ) -> _models.FaceGroupingResult: - """Divide candidate faces into groups based on face similarity. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) - Please refer to https://learn.microsoft.com/rest/api/face/face-recognition-operations/group for + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_face(self, large_face_list_id: str, persisted_face_id: str, **kwargs: Any) -> _models.LargeFaceListFace: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-face + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_ids: Array of candidate faceIds created by "Detect". The maximum is 1000 faces. - Required. - :paramtype face_ids: list[str] - :return: FaceGroupingResult. The FaceGroupingResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceGroupingResult + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: LargeFaceListFace. The LargeFaceListFace is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargeFaceListFace :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5394,27 +4663,14 @@ def group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceGroupingResult] = kwargs.pop("cls", None) - - if body is _Unset: - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - body = {"faceIds": face_ids} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargeFaceListFace] = kwargs.pop("cls", None) - _request = build_face_group_request( - content_type=content_type, - content=_content, + _request = build_large_face_list_get_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, headers=_headers, params=_params, ) @@ -5438,13 +4694,13 @@ def group( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceGroupingResult, response.json()) + deserialized = _deserialize(_models.LargeFaceListFace, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5452,123 +4708,123 @@ def group( return deserialized # type: ignore @overload - def find_similar_from_large_face_list( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + def update_face( + self, + large_face_list_id: str, + persisted_face_id: str, + *, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. - :param body: Required. - :type body: JSON + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def find_similar_from_large_face_list( + def update_face( self, - *, - face_id: str, large_face_list_id: str, + persisted_face_id: str, + body: JSON, + *, content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, **kwargs: Any, - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, - created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which - are persisted and will never expire. Required. - :paramtype large_face_list_id: str + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def find_similar_from_large_face_list( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + def update_face( + self, + large_face_list_id: str, + persisted_face_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def find_similar_from_large_face_list( + def update_face( # pylint: disable=inconsistent-return-statements self, + large_face_list_id: str, + persisted_face_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - face_id: str = _Unset, - large_face_list_id: str = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - mode: Optional[Union[str, _models.FindSimilarMatchMode]] = None, + user_data: Optional[str] = None, **kwargs: Any, - ) -> List[_models.FaceFindSimilarResult]: - """Given query face's faceId, to search the similar-looking faces from a Large Face List. A - 'largeFaceListId' is created by Create Large Face List. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/find-similar-from-large-face-list + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/update-large-face-list-face + `_ for more details. + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword face_id: faceId of the query face. User needs to call "Detect" first to get a valid - faceId. Note that this faceId is not persisted and will expire 24 hours after the detection - call. Required. - :paramtype face_id: str - :keyword large_face_list_id: An existing user-specified unique candidate Large Face List, - created in "Create Large Face List". Large Face List contains a set of persistedFaceIds which - are persisted and will never expire. Required. - :paramtype large_face_list_id: str - :keyword max_num_of_candidates_returned: The number of top similar faces returned. The valid - range is [1, 1000]. Default value is 20. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword mode: Similar face searching mode. It can be 'matchPerson' or 'matchFace'. Default - value is 'matchPerson'. Known values are: "matchPerson" and "matchFace". Default value is None. - :paramtype mode: str or ~azure.ai.vision.face.models.FindSimilarMatchMode - :return: list of FaceFindSimilarResult - :rtype: list[~azure.ai.vision.face.models.FaceFindSimilarResult] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5583,19 +4839,10 @@ def find_similar_from_large_face_list( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceFindSimilarResult]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if large_face_list_id is _Unset: - raise TypeError("missing required argument: large_face_list_id") - body = { - "faceId": face_id, - "largeFaceListId": large_face_list_id, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - "mode": mode, - } + body = {"userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -5604,9 +4851,76 @@ def find_similar_from_large_face_list( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_find_similar_from_large_face_list_request( - content_type=content_type, - content=_content, + _request = build_large_face_list_update_face_request( + large_face_list_id=large_face_list_id, + persisted_face_id=persisted_face_id, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_faces( + self, large_face_list_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> List[_models.LargeFaceListFace]: + """List faces' persistedFaceId and userData in a specified Large Face List. + + Please refer to + `https://learn.microsoft.com/rest/api/face/face-list-operations/get-large-face-list-faces + `_ + for more details. + + :param large_face_list_id: Valid character is letter in lower case or digit or '-' or '_', + maximum length is 64. Required. + :type large_face_list_id: str + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :return: list of LargeFaceListFace + :rtype: list[~azure.ai.vision.face.models.LargeFaceListFace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LargeFaceListFace]] = kwargs.pop("cls", None) + + _request = build_large_face_list_get_faces_request( + large_face_list_id=large_face_list_id, + start=start, + top=top, headers=_headers, params=_params, ) @@ -5630,139 +4944,165 @@ def find_similar_from_large_face_list( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceFindSimilarResult], response.json()) + deserialized = _deserialize(List[_models.LargeFaceListFace], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class LargePersonGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.vision.face.FaceAdministrationClient`'s + :attr:`large_person_group` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FaceAdministrationClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload - def identify_from_large_person_group( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + def create( + self, + large_person_group_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, + **kwargs: Any, + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. - :param body: Required. - :type body: JSON + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def identify_from_large_person_group( - self, - *, - face_ids: List[str], - large_person_group_id: str, - content_type: str = "application/json", - max_num_of_candidates_returned: Optional[int] = None, - confidence_threshold: Optional[float] = None, - **kwargs: Any, - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + def create( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. - :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are - identified independently. The valid number of faceIds is between [1, 10]. Required. - :paramtype face_ids: list[str] - :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by - "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be - provided at the same time. Required. - :paramtype large_person_group_id: str + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 - and 100. Default value is 10. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword confidence_threshold: Customized identification confidence threshold, in the range of - [0, 1]. Advanced user can tweak this value to override default internal threshold for better - precision on their scenario data. Note there is no guarantee of this threshold value working on - other data and after algorithm updates. Default value is None. - :paramtype confidence_threshold: float - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def identify_from_large_person_group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + def create( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def identify_from_large_person_group( + def create( # pylint: disable=inconsistent-return-statements self, + large_person_group_id: str, body: Union[JSON, IO[bytes]] = _Unset, *, - face_ids: List[str] = _Unset, - large_person_group_id: str = _Unset, - max_num_of_candidates_returned: Optional[int] = None, - confidence_threshold: Optional[float] = None, + name: str = _Unset, + user_data: Optional[str] = None, + recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, **kwargs: Any, - ) -> List[_models.FaceIdentificationResult]: - """1-to-many identification to find the closest matches of the specific query person face from a - Large Person Group. + ) -> None: + """Create a new Large Person Group with user-specified largePersonGroupId, name, an optional + userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/identify-from-person-group + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group + `_ for more details. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword face_ids: Array of query faces faceIds, created by the "Detect". Each of the faces are - identified independently. The valid number of faceIds is between [1, 10]. Required. - :paramtype face_ids: list[str] - :keyword large_person_group_id: largePersonGroupId of the target Large Person Group, created by - "Create Large Person Group". Parameter personGroupId and largePersonGroupId should not be - provided at the same time. Required. - :paramtype large_person_group_id: str - :keyword max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 - and 100. Default value is 10. Default value is None. - :paramtype max_num_of_candidates_returned: int - :keyword confidence_threshold: Customized identification confidence threshold, in the range of - [0, 1]. Advanced user can tweak this value to override default internal threshold for better - precision on their scenario data. Note there is no guarantee of this threshold value working on - other data and after algorithm updates. Default value is None. - :paramtype confidence_threshold: float - :return: list of FaceIdentificationResult - :rtype: list[~azure.ai.vision.face.models.FaceIdentificationResult] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :keyword recognition_model: The 'recognitionModel' associated with this face list. Supported + 'recognitionModel' values include 'recognition_01', 'recognition_02, 'recognition_03', and + 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since + its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall + accuracy is improved compared with 'recognition_01' and 'recognition_02'. Known values are: + "recognition_01", "recognition_02", "recognition_03", and "recognition_04". Default value is + None. + :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5777,19 +5117,12 @@ def identify_from_large_person_group( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[List[_models.FaceIdentificationResult]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) if body is _Unset: - if face_ids is _Unset: - raise TypeError("missing required argument: face_ids") - if large_person_group_id is _Unset: - raise TypeError("missing required argument: large_person_group_id") - body = { - "confidenceThreshold": confidence_threshold, - "faceIds": face_ids, - "largePersonGroupId": large_person_group_id, - "maxNumOfCandidatesReturned": max_num_of_candidates_returned, - } + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "recognitionModel": recognition_model, "userData": user_data} body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None @@ -5798,7 +5131,8 @@ def identify_from_large_person_group( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_identify_from_large_person_group_request( + _request = build_large_person_group_create_request( + large_person_group_id=large_person_group_id, content_type=content_type, content=_content, headers=_headers, @@ -5810,7 +5144,7 @@ def identify_from_large_person_group( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5818,123 +5152,83 @@ def identify_from_large_person_group( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.FaceIdentificationResult], response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def verify_from_large_person_group( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + return cls(pipeline_response, None, {}) # type: ignore - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, large_person_group_id: str, **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group + `_ for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def verify_from_large_person_group( - self, - *, - face_id: str, - large_person_group_id: str, - person_id: str, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group - for more details. + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_large_person_group_delete_request( + large_person_group_id=large_person_group_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :keyword face_id: The faceId of the face, come from "Detect". Required. - :paramtype face_id: str - :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading - a specified person. largePersonGroupId is created in "Create Large Person Group". Required. - :paramtype large_person_group_id: str - :keyword person_id: Specify a certain person in Large Person Group. Required. - :paramtype person_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - @overload - def verify_from_large_person_group( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. + response = pipeline_response.http_response - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group - for more details. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def verify_from_large_person_group( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - face_id: str = _Unset, - large_person_group_id: str = _Unset, - person_id: str = _Unset, - **kwargs: Any, - ) -> _models.FaceVerificationResult: - """Verify whether a face belongs to a person in a Large Person Group. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-recognition-operations/verify-from-large-person-group + def get( + self, large_person_group_id: str, *, return_recognition_model: Optional[bool] = None, **kwargs: Any + ) -> _models.LargePersonGroup: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword face_id: The faceId of the face, come from "Detect". Required. - :paramtype face_id: str - :keyword large_person_group_id: Using existing largePersonGroupId and personId for fast loading - a specified person. largePersonGroupId is created in "Create Large Person Group". Required. - :paramtype large_person_group_id: str - :keyword person_id: Specify a certain person in Large Person Group. Required. - :paramtype person_id: str - :return: FaceVerificationResult. The FaceVerificationResult is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.FaceVerificationResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: LargePersonGroup. The LargePersonGroup is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5945,31 +5239,14 @@ def verify_from_large_person_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FaceVerificationResult] = kwargs.pop("cls", None) - - if body is _Unset: - if face_id is _Unset: - raise TypeError("missing required argument: face_id") - if large_person_group_id is _Unset: - raise TypeError("missing required argument: large_person_group_id") - if person_id is _Unset: - raise TypeError("missing required argument: person_id") - body = {"faceId": face_id, "largePersonGroupId": large_person_group_id, "personId": person_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargePersonGroup] = kwargs.pop("cls", None) - _request = build_face_verify_from_large_person_group_request( - content_type=content_type, - content=_content, + _request = build_large_person_group_get_request( + large_person_group_id=large_person_group_id, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -5993,101 +5270,117 @@ def verify_from_large_person_group( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.FaceVerificationResult, response.json()) + deserialized = _deserialize(_models.LargePersonGroup, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class FaceSessionClientOperationsMixin(FaceSessionClientMixinABC): - @overload - def create_liveness_session( - self, body: _models.CreateLivenessSessionContent, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + def update( + self, + large_person_group_id: str, + *, + content_type: str = "application/json", + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_liveness_session( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + def update( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_liveness_session( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + def update( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Required. + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_liveness_session( - self, body: Union[_models.CreateLivenessSessionContent, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CreateLivenessSessionResult: - """Create a new detect liveness session. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-session + def update( # pylint: disable=inconsistent-return-statements + self, + large_person_group_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group + `_ for more details. - :param body: Body parameter. Is one of the following types: CreateLivenessSessionContent, JSON, - IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessSessionContent or JSON or IO[bytes] - :return: CreateLivenessSessionResult. The CreateLivenessSessionResult is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessSessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6102,8 +5395,11 @@ def create_liveness_session( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreateLivenessSessionResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) + if body is _Unset: + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None if isinstance(body, (IOBase, bytes)): @@ -6111,7 +5407,8 @@ def create_liveness_session( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_session_create_liveness_session_request( + _request = build_large_person_group_update_request( + large_person_group_id=large_person_group_id, content_type=content_type, content=_content, headers=_headers, @@ -6123,7 +5420,7 @@ def create_liveness_session( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -6131,39 +5428,40 @@ def create_liveness_session( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreateLivenessSessionResult, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delete_liveness_session( # pylint: disable=inconsistent-return-statements - self, session_id: str, **kwargs: Any - ) -> None: - """Delete all session related information for matching the specified session id. + def get_large_person_groups( + self, + *, + start: Optional[str] = None, + top: Optional[int] = None, + return_recognition_model: Optional[bool] = None, + **kwargs: Any, + ) -> List[_models.LargePersonGroup]: + """List all existing Large Person Groups' largePersonGroupId, name, userData and recognitionModel. Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-session + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-groups + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: None - :rtype: None + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is + false. Default value is None. + :paramtype return_recognition_model: bool + :return: list of LargePersonGroup + :rtype: list[~azure.ai.vision.face.models.LargePersonGroup] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6177,10 +5475,12 @@ def delete_liveness_session( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[List[_models.LargePersonGroup]] = kwargs.pop("cls", None) - _request = build_face_session_delete_liveness_session_request( - session_id=session_id, + _request = build_large_person_group_get_large_person_groups_request( + start=start, + top=top, + return_recognition_model=return_recognition_model, headers=_headers, params=_params, ) @@ -6190,7 +5490,7 @@ def delete_liveness_session( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -6198,23 +5498,39 @@ def delete_liveness_session( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(List[_models.LargePersonGroup], response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models.LivenessSession: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-result + def get_training_status(self, large_person_group_id: str, **kwargs: Any) -> _models.FaceTrainingResult: + """To check Large Person Group training status completed or still ongoing. Large Person Group + training is an asynchronous operation triggered by "Train Large Person Group" API. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-training-status + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: LivenessSession. The LivenessSession is compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.LivenessSession + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: FaceTrainingResult. The FaceTrainingResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.FaceTrainingResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6228,10 +5544,10 @@ def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LivenessSession] = kwargs.pop("cls", None) + cls: ClsType[_models.FaceTrainingResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_session_result_request( - session_id=session_id, + _request = build_large_person_group_get_training_status_request( + large_person_group_id=large_person_group_id, headers=_headers, params=_params, ) @@ -6255,39 +5571,20 @@ def get_liveness_session_result(self, session_id: str, **kwargs: Any) -> _models except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LivenessSession, response.json()) + deserialized = _deserialize(_models.FaceTrainingResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get_liveness_sessions( - self, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionItem]: - """Lists sessions for /detectLiveness/SingleModal. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-sessions for - more details. - - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionItem - :rtype: list[~azure.ai.vision.face.models.LivenessSessionItem] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _train_initial(self, large_person_group_id: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6299,11 +5596,10 @@ def get_liveness_sessions( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionItem]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_sessions_request( - start=start, - top=top, + _request = build_large_person_group_train_request( + large_person_group_id=large_person_group_id, headers=_headers, params=_params, ) @@ -6313,51 +5609,202 @@ def get_liveness_sessions( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(List[_models.LivenessSessionItem], response.json()) + response_headers = {} + response_headers["operation-Location"] = self._deserialize("str", response.headers.get("operation-Location")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def get_liveness_session_audit_entries( - self, session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionAuditEntry]: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-session-audit-entries + def begin_train(self, large_person_group_id: str, **kwargs: Any) -> LROPoller[None]: + """Submit a Large Person Group training task. Training is a crucial step that only a trained Large + Person Group can be used by "Identify From Large Person Group". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/train-large-person-group + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionAuditEntry - :rtype: list[~azure.ai.vision.face.models.LivenessSessionAuditEntry] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._train_initial( + large_person_group_id=large_person_group_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def create_person( + self, + large_person_group_id: str, + *, + name: str, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any, + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_person( + self, large_person_group_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_person( + self, large_person_group_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_person( + self, + large_person_group_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> _models.CreatePersonResult: + """Create a new person in a specified Large Person Group. To add face to this person, please call + "Add Large Person Group Person Face". + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/create-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Required. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: CreatePersonResult. The CreatePersonResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.CreatePersonResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6368,15 +5815,28 @@ def get_liveness_session_audit_entries( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionAuditEntry]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CreatePersonResult] = kwargs.pop("cls", None) + + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_face_session_get_liveness_session_audit_entries_request( - session_id=session_id, - start=start, - top=top, + _request = build_large_person_group_create_person_request( + large_person_group_id=large_person_group_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -6400,54 +5860,34 @@ def get_liveness_session_audit_entries( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionAuditEntry], response.json()) + deserialized = _deserialize(_models.CreatePersonResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def _create_liveness_with_verify_session( - self, - body: _models.CreateLivenessWithVerifySessionContent, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - def _create_liveness_with_verify_session( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - def _create_liveness_with_verify_session( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @distributed_trace - def _create_liveness_with_verify_session( - self, body: Union[_models.CreateLivenessWithVerifySessionContent, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Client device submits VerifyImage during the - /detectLivenessWithVerify/singleModal call. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session + def delete_person( # pylint: disable=inconsistent-return-statements + self, large_person_group_id: str, person_id: str, **kwargs: Any + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person + `_ for more details. - :param body: Body parameter. Is one of the following types: - CreateLivenessWithVerifySessionContent, JSON, IO[bytes] Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionContent or JSON or - IO[bytes] - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6458,22 +5898,14 @@ def _create_liveness_with_verify_session( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CreateLivenessWithVerifySessionResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_create_liveness_with_verify_session_request( - content_type=content_type, - content=_content, + _request = build_large_person_group_delete_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, headers=_headers, params=_params, ) @@ -6483,7 +5915,7 @@ def _create_liveness_with_verify_session( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -6491,51 +5923,26 @@ def _create_liveness_with_verify_session( response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.CreateLivenessWithVerifySessionResult, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: _models.CreateLivenessWithVerifySessionMultipartContent, **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... - @overload - def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: JSON, **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: ... + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=name-too-long - self, body: Union[_models.CreateLivenessWithVerifySessionMultipartContent, JSON], **kwargs: Any - ) -> _models.CreateLivenessWithVerifySessionResult: - """Create a new liveness session with verify. Provide the verify image during session creation. - - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/create-liveness-with-verify-session-with-verify-image + def get_person(self, large_person_group_id: str, person_id: str, **kwargs: Any) -> _models.LargePersonGroupPerson: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person + `_ for more details. - :param body: Request content of liveness with verify session creation. Is either a - CreateLivenessWithVerifySessionMultipartContent type or a JSON type. Required. - :type body: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionMultipartContent or - JSON - :return: CreateLivenessWithVerifySessionResult. The CreateLivenessWithVerifySessionResult is - compatible with MutableMapping - :rtype: ~azure.ai.vision.face.models.CreateLivenessWithVerifySessionResult + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :return: LargePersonGroupPerson. The LargePersonGroupPerson is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroupPerson :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6549,16 +5956,11 @@ def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=n _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.CreateLivenessWithVerifySessionResult] = kwargs.pop("cls", None) - - _body = body.as_dict() if isinstance(body, _model_base.Model) else body - _file_fields: List[str] = ["VerifyImage"] - _data_fields: List[str] = ["Parameters"] - _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) + cls: ClsType[_models.LargePersonGroupPerson] = kwargs.pop("cls", None) - _request = build_face_session_create_liveness_with_verify_session_with_verify_image_request( - files=_files, - data=_data, + _request = build_large_person_group_get_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, headers=_headers, params=_params, ) @@ -6582,31 +5984,137 @@ def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=n except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.CreateLivenessWithVerifySessionResult, response.json()) + deserialized = _deserialize(_models.LargePersonGroupPerson, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete_liveness_with_verify_session( # pylint: disable=inconsistent-return-statements - self, session_id: str, **kwargs: Any + @overload + def update_person( + self, + large_person_group_id: str, + person_id: str, + *, + content_type: str = "application/json", + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any, ) -> None: - """Delete all session related information for matching the specified session id. + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. - Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/delete-liveness-with-verify-session + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_person( + self, + large_person_group_id: str, + person_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_person( + self, + large_person_group_id: str, + person_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_person( # pylint: disable=inconsistent-return-statements + self, + large_person_group_id: str, + person_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: Optional[str] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: User defined name, maximum length is 128. Default value is None. + :paramtype name: str + :keyword user_data: Optional user defined data. Length should not exceed 16K. Default value is + None. + :paramtype user_data: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -6619,13 +6127,27 @@ def delete_liveness_with_verify_session( # pylint: disable=inconsistent-return- } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_delete_liveness_with_verify_session_request( - session_id=session_id, + if body is _Unset: + body = {"name": name, "userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_update_person_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -6644,25 +6166,34 @@ def delete_liveness_with_verify_session( # pylint: disable=inconsistent-return- if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get_liveness_with_verify_session_result( - self, session_id: str, **kwargs: Any - ) -> _models.LivenessWithVerifySession: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-result + def get_persons( + self, large_person_group_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> List[_models.LargePersonGroupPerson]: + """List all persons' information in the specified Large Person Group, including personId, name, + userData and persistedFaceIds of registered person faces. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-persons + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :return: LivenessWithVerifySession. The LivenessWithVerifySession is compatible with - MutableMapping - :rtype: ~azure.ai.vision.face.models.LivenessWithVerifySession + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :keyword start: List resources greater than the "start". It contains no more than 64 + characters. Default is empty. Default value is None. + :paramtype start: str + :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value + is None. + :paramtype top: int + :return: list of LargePersonGroupPerson + :rtype: list[~azure.ai.vision.face.models.LargePersonGroupPerson] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6676,10 +6207,12 @@ def get_liveness_with_verify_session_result( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.LivenessWithVerifySession] = kwargs.pop("cls", None) + cls: ClsType[List[_models.LargePersonGroupPerson]] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_session_result_request( - session_id=session_id, + _request = build_large_person_group_get_persons_request( + large_person_group_id=large_person_group_id, + start=start, + top=top, headers=_headers, params=_params, ) @@ -6703,37 +6236,195 @@ def get_liveness_with_verify_session_result( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.LivenessWithVerifySession, response.json()) + deserialized = _deserialize(List[_models.LargePersonGroupPerson], response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + *, + url: str, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: JSON, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: JSON + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: IO[bytes], + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Required. + :type body: IO[bytes] + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def get_liveness_with_verify_sessions( - self, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionItem]: - """Lists sessions for /detectLivenessWithVerify/SingleModal. + def add_face_from_url( + self, + large_person_group_id: str, + person_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + url: str = _Unset, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-sessions + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face-from-url + `_ for more details. - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionItem - :rtype: list[~azure.ai.vision.face.models.LivenessSessionItem] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword url: URL of input image. Required. + :paramtype url: str + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6744,14 +6435,32 @@ def get_liveness_with_verify_sessions( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionItem]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_sessions_request( - start=start, - top=top, + if body is _Unset: + if url is _Unset: + raise TypeError("missing required argument: url") + body = {"url": url} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_add_face_from_url_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -6775,13 +6484,13 @@ def get_liveness_with_verify_sessions( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionItem], response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6789,23 +6498,43 @@ def get_liveness_with_verify_sessions( return deserialized # type: ignore @distributed_trace - def get_liveness_with_verify_session_audit_entries( # pylint: disable=name-too-long - self, session_id: str, *, start: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> List[_models.LivenessSessionAuditEntry]: - """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-liveness-with-verify-session-audit-entries + def add_face( + self, + large_person_group_id: str, + person_id: str, + image_content: bytes, + *, + target_face: Optional[List[int]] = None, + detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> _models.AddFaceResult: + """Add a face to a person into a Large Person Group for face identification or verification. + + Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/add-large-person-group-person-face + `_ for more details. - :param session_id: The unique ID to reference this session. Required. - :type session_id: str - :keyword start: List resources greater than the "start". It contains no more than 64 - characters. Default is empty. Default value is None. - :paramtype start: str - :keyword top: The number of items to list, ranging in [1, 1000]. Default is 1000. Default value - is None. - :paramtype top: int - :return: list of LivenessSessionAuditEntry - :rtype: list[~azure.ai.vision.face.models.LivenessSessionAuditEntry] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param image_content: The image to be analyzed. Required. + :type image_content: bytes + :keyword target_face: A face rectangle to specify the target face to be added to a person, in + the format of 'targetFace=left,top,width,height'. Default value is None. + :paramtype target_face: list[int] + :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported + 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default + value is 'detection_01'. Known values are: "detection_01", "detection_02", and "detection_03". + Default value is None. + :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel + :keyword user_data: User-provided data attached to the face. The size limit is 1K. Default + value is None. + :paramtype user_data: str + :return: AddFaceResult. The AddFaceResult is compatible with MutableMapping + :rtype: ~azure.ai.vision.face.models.AddFaceResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6816,15 +6545,22 @@ def get_liveness_with_verify_session_audit_entries( # pylint: disable=name-too- } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.LivenessSessionAuditEntry]] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("content-type", "application/octet-stream")) + cls: ClsType[_models.AddFaceResult] = kwargs.pop("cls", None) - _request = build_face_session_get_liveness_with_verify_session_audit_entries_request( - session_id=session_id, - start=start, - top=top, + _content = image_content + + _request = build_large_person_group_add_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + target_face=target_face, + detection_model=detection_model, + user_data=user_data, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -6848,283 +6584,100 @@ def get_liveness_with_verify_session_audit_entries( # pylint: disable=name-too- except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.LivenessSessionAuditEntry], response.json()) + deserialized = _deserialize(_models.AddFaceResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def detect_from_session_image( - self, - body: JSON, - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + @distributed_trace + def delete_face( # pylint: disable=inconsistent-return-statements + self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any + ) -> None: + """Delete a face from a person in a Large Person Group by specified largePersonGroupId, personId + and persistedFaceId. Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + `https://learn.microsoft.com/rest/api/face/person-group-operations/delete-large-person-group-person-face + `_ for more details. - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def detect_from_session_image( - self, - *, - session_image_id: str, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. - - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id - for more details. - - :keyword session_image_id: Id of session image. Required. - :paramtype session_image_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def detect_from_session_image( - self, - body: IO[bytes], - *, - content_type: str = "application/json", - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + cls: ClsType[None] = kwargs.pop("cls", None) - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id - for more details. + _request = build_large_person_group_delete_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + "apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - @distributed_trace - @api_version_validation( - method_added_on="v1.2-preview.1", - params_added_on={ - "v1.2-preview.1": [ - "content_type", - "detection_model", - "recognition_model", - "return_face_id", - "return_face_attributes", - "return_face_landmarks", - "return_recognition_model", - "face_id_time_to_live", - "accept", - ] - }, - ) - def detect_from_session_image( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - session_image_id: str = _Unset, - detection_model: Optional[Union[str, _models.FaceDetectionModel]] = None, - recognition_model: Optional[Union[str, _models.FaceRecognitionModel]] = None, - return_face_id: Optional[bool] = None, - return_face_attributes: Optional[List[Union[str, _models.FaceAttributeType]]] = None, - return_face_landmarks: Optional[bool] = None, - return_recognition_model: Optional[bool] = None, - face_id_time_to_live: Optional[int] = None, - **kwargs: Any, - ) -> List[_models.FaceDetectionResult]: - """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, - and attributes. + response = pipeline_response.http_response - Please refer to - https://learn.microsoft.com/rest/api/face/face-detection-operations/detect-from-session-image-id + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_face( + self, large_person_group_id: str, person_id: str, persisted_face_id: str, **kwargs: Any + ) -> _models.LargePersonGroupPersonFace: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/get-large-person-group-person-face + `_ for more details. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword session_image_id: Id of session image. Required. - :paramtype session_image_id: str - :keyword detection_model: The 'detectionModel' associated with the detected faceIds. Supported - 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default - value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on - smaller faces (64x64 pixels) and rotated face orientations. Known values are: "detection_01", - "detection_02", and "detection_03". Default value is None. - :paramtype detection_model: str or ~azure.ai.vision.face.models.FaceDetectionModel - :keyword recognition_model: The 'recognitionModel' associated with the detected faceIds. - Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', - 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' - is recommended since its accuracy is improved on faces wearing masks compared with - 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and - 'recognition_02'. Known values are: "recognition_01", "recognition_02", "recognition_03", and - "recognition_04". Default value is None. - :paramtype recognition_model: str or ~azure.ai.vision.face.models.FaceRecognitionModel - :keyword return_face_id: Return faceIds of the detected faces or not. The default value is - true. Default value is None. - :paramtype return_face_id: bool - :keyword return_face_attributes: Analyze and return the one or more specified face attributes - in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute - analysis has additional computational and time cost. Default value is None. - :paramtype return_face_attributes: list[str or ~azure.ai.vision.face.models.FaceAttributeType] - :keyword return_face_landmarks: Return face landmarks of the detected faces or not. The default - value is false. Default value is None. - :paramtype return_face_landmarks: bool - :keyword return_recognition_model: Return 'recognitionModel' or not. The default value is - false. This is only applicable when returnFaceId = true. Default value is None. - :paramtype return_recognition_model: bool - :keyword face_id_time_to_live: The number of seconds for the face ID being cached. Supported - range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours). Default value - is None. - :paramtype face_id_time_to_live: int - :return: list of FaceDetectionResult - :rtype: list[~azure.ai.vision.face.models.FaceDetectionResult] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :return: LargePersonGroupPersonFace. The LargePersonGroupPersonFace is compatible with + MutableMapping + :rtype: ~azure.ai.vision.face.models.LargePersonGroupPersonFace :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7135,34 +6688,15 @@ def detect_from_session_image( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[List[_models.FaceDetectionResult]] = kwargs.pop("cls", None) - - if body is _Unset: - if session_image_id is _Unset: - raise TypeError("missing required argument: session_image_id") - body = {"sessionImageId": session_image_id} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.LargePersonGroupPersonFace] = kwargs.pop("cls", None) - _request = build_face_session_detect_from_session_image_request( - detection_model=detection_model, - recognition_model=recognition_model, - return_face_id=return_face_id, - return_face_attributes=return_face_attributes, - return_face_landmarks=return_face_landmarks, - return_recognition_model=return_recognition_model, - face_id_time_to_live=face_id_time_to_live, - content_type=content_type, - content=_content, + _request = build_large_person_group_get_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, headers=_headers, params=_params, ) @@ -7186,33 +6720,145 @@ def detect_from_session_image( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(List[_models.FaceDetectionResult], response.json()) + deserialized = _deserialize(_models.LargePersonGroupPersonFace, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + *, + content_type: str = "application/json", + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_face( + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Please refer to + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. + + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - @api_version_validation( - method_added_on="v1.2-preview.1", - params_added_on={"v1.2-preview.1": ["session_image_id", "accept"]}, - ) - def get_session_image(self, session_image_id: str, **kwargs: Any) -> Iterator[bytes]: + def update_face( # pylint: disable=inconsistent-return-statements + self, + large_person_group_id: str, + person_id: str, + persisted_face_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + user_data: Optional[str] = None, + **kwargs: Any, + ) -> None: """Please refer to - https://learn.microsoft.com/rest/api/face/liveness-session-operations/get-session-image for - more details. + `https://learn.microsoft.com/rest/api/face/person-group-operations/update-large-person-group-person-face + `_ + for more details. - :param session_image_id: The request ID of the image to be retrieved. Required. - :type session_image_id: str - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :param large_person_group_id: ID of the container. Required. + :type large_person_group_id: str + :param person_id: ID of the person. Required. + :type person_id: str + :param persisted_face_id: Face ID of the face. Required. + :type persisted_face_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword user_data: User-provided data attached to the face. The length limit is 1K. Default + value is None. + :paramtype user_data: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7223,13 +6869,28 @@ def get_session_image(self, session_image_id: str, **kwargs: Any) -> Iterator[by } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_face_session_get_session_image_request( - session_image_id=session_image_id, + if body is _Unset: + body = {"userData": user_data} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_large_person_group_update_face_request( + large_person_group_id=large_person_group_id, + person_id=person_id, + persisted_face_id=persisted_face_id, + content_type=content_type, + content=_content, headers=_headers, params=_params, ) @@ -7239,7 +6900,7 @@ def get_session_image(self, session_image_id: str, **kwargs: Any) -> Iterator[by } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -7247,21 +6908,9 @@ def get_session_image(self, session_image_id: str, **kwargs: Any) -> Iterator[by response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.FaceErrorResponse, response.json()) + error = _failsafe_deserialize(_models.FaceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_patch.py b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_patch.py +++ b/sdk/face/azure-ai-vision-face/azure/ai/vision/face/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_add_large_face_list_face_from_stream.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_add_large_face_list_face_from_stream.py index f928999a811a..020d84fdf6d7 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_add_large_face_list_face_from_stream.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_add_large_face_list_face_from_stream.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_AddLargeFaceListFaceFromStream.json +# x-ms-original-file: v1.2/FaceListOperations_AddLargeFaceListFaceFromStream.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list.py index a3983c7eab2e..948a38a49aac 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_DeleteLargeFaceList.json +# x-ms-original-file: v1.2/FaceListOperations_DeleteLargeFaceList.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list_face.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list_face.py index 40652c3a3381..1ece93566a7a 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_delete_large_face_list_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_DeleteLargeFaceListFace.json +# x-ms-original-file: v1.2/FaceListOperations_DeleteLargeFaceListFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list.py index c1e1af2fb3e8..54571a499bca 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_GetLargeFaceList.json +# x-ms-original-file: v1.2/FaceListOperations_GetLargeFaceList.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_face.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_face.py index 6efa6e2a1616..63f99eba95e9 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_GetLargeFaceListFace.json +# x-ms-original-file: v1.2/FaceListOperations_GetLargeFaceListFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_faces.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_faces.py index c32e1f741852..316204101835 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_faces.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_faces.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_GetLargeFaceListFaces.json +# x-ms-original-file: v1.2/FaceListOperations_GetLargeFaceListFaces.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_training_status.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_training_status.py index 3c8bdbb9cdc8..51f8fa594b43 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_training_status.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_list_training_status.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_GetLargeFaceListTrainingStatus.json +# x-ms-original-file: v1.2/FaceListOperations_GetLargeFaceListTrainingStatus.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_lists.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_lists.py index 656c12749622..aa788e3a8582 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_lists.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_get_large_face_lists.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -26,6 +26,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_GetLargeFaceLists.json +# x-ms-original-file: v1.2/FaceListOperations_GetLargeFaceLists.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_train_large_face_list.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_train_large_face_list.py index f7a75806cff7..280921e9e465 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_train_large_face_list.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_train_large_face_list.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ).result() -# x-ms-original-file: v1.2-preview.1/FaceListOperations_TrainLargeFaceList.json +# x-ms-original-file: v1.2/FaceListOperations_TrainLargeFaceList.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list.py index 2259f284a121..9d57ef29f9fb 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_UpdateLargeFaceList.json +# x-ms-original-file: v1.2/FaceListOperations_UpdateLargeFaceList.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list_face.py b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list_face.py index a0d72eab3f89..9fa8ea0c73fc 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/face_list_operations_update_large_face_list_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/FaceListOperations_UpdateLargeFaceListFace.json +# x-ms-original-file: v1.2/FaceListOperations_UpdateLargeFaceListFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_create_liveness_session.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_create_liveness_session.py index 870b2adf0dd5..e1c1b03f785a 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_create_liveness_session.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_create_liveness_session.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -26,14 +26,13 @@ def main(): body={ "authTokenTimeToLiveInSeconds": 60, "deviceCorrelationId": "your_device_correlation_id", - "deviceCorrelationIdSetInClient": True, + "deviceCorrelationIdSetInClient": False, "livenessOperationMode": "Passive", - "sendResultsToClient": True, }, ) print(response) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_CreateLivenessSession.json +# x-ms-original-file: v1.2/LivenessSessionOperations_CreateLivenessSession.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_session.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_session.py index 328aedebfcd2..23277cd798e3 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_session.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_session.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_DeleteLivenessSession.json +# x-ms-original-file: v1.2/LivenessSessionOperations_DeleteLivenessSession.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_with_verify_session.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_with_verify_session.py index 5a07df9ede03..e5c8d35f1d24 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_with_verify_session.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_delete_liveness_with_verify_session.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_DeleteLivenessWithVerifySession.json +# x-ms-original-file: v1.2/LivenessSessionOperations_DeleteLivenessWithVerifySession.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_audit_entries.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_audit_entries.py deleted file mode 100644 index 8e1378c21b41..000000000000 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_audit_entries.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.ai.vision.face import FaceAdministrationClient - -""" -# PREREQUISITES - pip install azure-ai-vision-face -# USAGE - python liveness_session_operations_get_liveness_session_audit_entries.py -""" - - -def main(): - client = FaceAdministrationClient( - endpoint="ENDPOINT", - credential="CREDENTIAL", - ) - - response = client.get_liveness_session_audit_entries( - session_id="b12e033e-bda7-4b83-a211-e721c661f30e", - ) - print(response) - - -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessSessionAuditEntries.json -if __name__ == "__main__": - main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_result.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_result.py index 171c716c0ddf..b60964360699 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_result.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_session_result.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessSessionResult.json +# x-ms-original-file: v1.2/LivenessSessionOperations_GetLivenessSessionResult.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_sessions.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_sessions.py deleted file mode 100644 index 0c5415da59b7..000000000000 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_sessions.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.ai.vision.face import FaceAdministrationClient - -""" -# PREREQUISITES - pip install azure-ai-vision-face -# USAGE - python liveness_session_operations_get_liveness_sessions.py -""" - - -def main(): - client = FaceAdministrationClient( - endpoint="ENDPOINT", - credential="CREDENTIAL", - ) - - response = client.get_liveness_sessions() - print(response) - - -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessSessions.json -if __name__ == "__main__": - main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_audit_entries.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_audit_entries.py deleted file mode 100644 index b7549952e8e8..000000000000 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_audit_entries.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.ai.vision.face import FaceAdministrationClient - -""" -# PREREQUISITES - pip install azure-ai-vision-face -# USAGE - python liveness_session_operations_get_liveness_with_verify_session_audit_entries.py -""" - - -def main(): - client = FaceAdministrationClient( - endpoint="ENDPOINT", - credential="CREDENTIAL", - ) - - response = client.get_liveness_with_verify_session_audit_entries( - session_id="b12e033e-bda7-4b83-a211-e721c661f30e", - ) - print(response) - - -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessWithVerifySessionAuditEntries.json -if __name__ == "__main__": - main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_result.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_result.py index ca331fd5c973..8789c051c74e 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_result.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_session_result.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessWithVerifySessionResult.json +# x-ms-original-file: v1.2/LivenessSessionOperations_GetLivenessWithVerifySessionResult.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_sessions.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_sessions.py deleted file mode 100644 index b1c6fa5efb4d..000000000000 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_liveness_with_verify_sessions.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.ai.vision.face import FaceAdministrationClient - -""" -# PREREQUISITES - pip install azure-ai-vision-face -# USAGE - python liveness_session_operations_get_liveness_with_verify_sessions.py -""" - - -def main(): - client = FaceAdministrationClient( - endpoint="ENDPOINT", - credential="CREDENTIAL", - ) - - response = client.get_liveness_with_verify_sessions() - print(response) - - -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetLivenessWithVerifySessions.json -if __name__ == "__main__": - main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_session_image.py b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_session_image.py index e809aacf02c0..c19add35c412 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_session_image.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/liveness_session_operations_get_session_image.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.ai.vision.face import FaceAdministrationClient +from azure.ai.vision.face import FaceSessionClient """ # PREREQUISITES @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/LivenessSessionOperations_GetSessionImage.json +# x-ms-original-file: v1.2/LivenessSessionOperations_GetSessionImage.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_add_large_person_group_person_face_from_stream.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_add_large_person_group_person_face_from_stream.py index 8b5fb2c3484b..65031c3b37a8 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_add_large_person_group_person_face_from_stream.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_add_large_person_group_person_face_from_stream.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -30,6 +30,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_AddLargePersonGroupPersonFaceFromStream.json +# x-ms-original-file: v1.2/PersonGroupOperations_AddLargePersonGroupPersonFaceFromStream.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group.py index aae50a47f38f..fbc8f509733d 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_DeleteLargePersonGroup.json +# x-ms-original-file: v1.2/PersonGroupOperations_DeleteLargePersonGroup.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person.py index 3c5018bc1b8e..32edc6c4aa0b 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_DeleteLargePersonGroupPerson.json +# x-ms-original-file: v1.2/PersonGroupOperations_DeleteLargePersonGroupPerson.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person_face.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person_face.py index 9b2abd194e32..3a19c14b1170 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_delete_large_person_group_person_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_DeleteLargePersonGroupPersonFace.json +# x-ms-original-file: v1.2/PersonGroupOperations_DeleteLargePersonGroupPersonFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group.py index 1443601f67ff..905982f5eca7 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroup.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroup.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person.py index eba005b7ab3a..ce47b6e67ddf 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroupPerson.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroupPerson.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person_face.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person_face.py index 77ac553f6538..293aa943cc37 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_person_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -30,6 +30,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroupPersonFace.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroupPersonFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_persons.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_persons.py index dd1e8776dc0b..8b8d51a0836b 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_persons.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_persons.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroupPersons.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroupPersons.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_training_status.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_training_status.py index 263bd708cb98..f0461d8cfc0f 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_training_status.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_group_training_status.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroupTrainingStatus.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroupTrainingStatus.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_groups.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_groups.py index c5c7fba6e248..d85933fce084 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_groups.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_get_large_person_groups.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -26,6 +26,6 @@ def main(): print(response) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_GetLargePersonGroups.json +# x-ms-original-file: v1.2/PersonGroupOperations_GetLargePersonGroups.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_train_large_person_group.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_train_large_person_group.py index 2498946b61e7..bbddc7501412 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_train_large_person_group.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_train_large_person_group.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -27,6 +27,6 @@ def main(): ).result() -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_TrainLargePersonGroup.json +# x-ms-original-file: v1.2/PersonGroupOperations_TrainLargePersonGroup.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group.py index ebd472d7bdb2..41b7de7a0bf5 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -28,6 +28,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_UpdateLargePersonGroup.json +# x-ms-original-file: v1.2/PersonGroupOperations_UpdateLargePersonGroup.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person.py index 030ccb8ef107..a89dae3648d3 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -29,6 +29,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_UpdateLargePersonGroupPerson.json +# x-ms-original-file: v1.2/PersonGroupOperations_UpdateLargePersonGroupPerson.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person_face.py b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person_face.py index a409df092146..1c5edf842955 100644 --- a/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person_face.py +++ b/sdk/face/azure-ai-vision-face/generated_samples/person_group_operations_update_large_person_group_person_face.py @@ -17,7 +17,7 @@ def main(): - client = FaceAdministrationClient( + client = FaceClient( endpoint="ENDPOINT", credential="CREDENTIAL", ) @@ -30,6 +30,6 @@ def main(): ) -# x-ms-original-file: v1.2-preview.1/PersonGroupOperations_UpdateLargePersonGroupPersonFace.json +# x-ms-original-file: v1.2/PersonGroupOperations_UpdateLargePersonGroupPersonFace.json if __name__ == "__main__": main() diff --git a/sdk/face/azure-ai-vision-face/generated_tests/conftest.py b/sdk/face/azure-ai-vision-face/generated_tests/conftest.py index 83118e9ab790..b4b4aca49584 100644 --- a/sdk/face/azure-ai-vision-face/generated_tests/conftest.py +++ b/sdk/face/azure-ai-vision-face/generated_tests/conftest.py @@ -21,23 +21,6 @@ # For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - faceadministration_subscription_id = os.environ.get( - "FACEADMINISTRATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" - ) - faceadministration_tenant_id = os.environ.get( - "FACEADMINISTRATION_TENANT_ID", "00000000-0000-0000-0000-000000000000" - ) - faceadministration_client_id = os.environ.get( - "FACEADMINISTRATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000" - ) - faceadministration_client_secret = os.environ.get( - "FACEADMINISTRATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" - ) - add_general_regex_sanitizer(regex=faceadministration_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=faceadministration_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=faceadministration_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=faceadministration_client_secret, value="00000000-0000-0000-0000-000000000000") - face_subscription_id = os.environ.get("FACE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") face_tenant_id = os.environ.get("FACE_TENANT_ID", "00000000-0000-0000-0000-000000000000") face_client_id = os.environ.get("FACE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") @@ -56,6 +39,23 @@ def add_sanitizers(test_proxy): add_general_regex_sanitizer(regex=facesession_client_id, value="00000000-0000-0000-0000-000000000000") add_general_regex_sanitizer(regex=facesession_client_secret, value="00000000-0000-0000-0000-000000000000") + faceadministration_subscription_id = os.environ.get( + "FACEADMINISTRATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + faceadministration_tenant_id = os.environ.get( + "FACEADMINISTRATION_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + faceadministration_client_id = os.environ.get( + "FACEADMINISTRATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + faceadministration_client_secret = os.environ.get( + "FACEADMINISTRATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=faceadministration_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=faceadministration_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=faceadministration_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=faceadministration_client_secret, value="00000000-0000-0000-0000-000000000000") + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/face/azure-ai-vision-face/generated_tests/test_face_session.py b/sdk/face/azure-ai-vision-face/generated_tests/test_face_session.py index 72a4b251ed5c..96ea9124d468 100644 --- a/sdk/face/azure-ai-vision-face/generated_tests/test_face_session.py +++ b/sdk/face/azure-ai-vision-face/generated_tests/test_face_session.py @@ -23,8 +23,7 @@ def test_create_liveness_session(self, facesession_endpoint): "deviceCorrelationId": "str", "deviceCorrelationIdSetInClient": bool, "enableSessionImage": bool, - "livenessSingleModalModel": "str", - "sendResultsToClient": bool, + "livenessModelVersion": "str", }, ) @@ -55,19 +54,20 @@ def test_get_liveness_session_result(self, facesession_endpoint): @FaceSessionPreparer() @recorded_by_proxy - def test_get_liveness_sessions(self, facesession_endpoint): + def test_create_liveness_with_verify_session(self, facesession_endpoint): client = self.create_client(endpoint=facesession_endpoint) - response = client.get_liveness_sessions() - - # please add some check logic here by yourself - # ... - - @FaceSessionPreparer() - @recorded_by_proxy - def test_get_liveness_session_audit_entries(self, facesession_endpoint): - client = self.create_client(endpoint=facesession_endpoint) - response = client.get_liveness_session_audit_entries( - session_id="str", + response = client.create_liveness_with_verify_session( + body={ + "livenessOperationMode": "str", + "verifyImage": "filetype", + "authTokenTimeToLiveInSeconds": 0, + "deviceCorrelationId": "str", + "deviceCorrelationIdSetInClient": bool, + "enableSessionImage": bool, + "livenessModelVersion": "str", + "returnVerifyImageHash": bool, + "verifyConfidenceThreshold": 0.0, + }, ) # please add some check logic here by yourself @@ -95,26 +95,6 @@ def test_get_liveness_with_verify_session_result(self, facesession_endpoint): # please add some check logic here by yourself # ... - @FaceSessionPreparer() - @recorded_by_proxy - def test_get_liveness_with_verify_sessions(self, facesession_endpoint): - client = self.create_client(endpoint=facesession_endpoint) - response = client.get_liveness_with_verify_sessions() - - # please add some check logic here by yourself - # ... - - @FaceSessionPreparer() - @recorded_by_proxy - def test_get_liveness_with_verify_session_audit_entries(self, facesession_endpoint): - client = self.create_client(endpoint=facesession_endpoint) - response = client.get_liveness_with_verify_session_audit_entries( - session_id="str", - ) - - # please add some check logic here by yourself - # ... - @FaceSessionPreparer() @recorded_by_proxy def test_detect_from_session_image(self, facesession_endpoint): diff --git a/sdk/face/azure-ai-vision-face/generated_tests/test_face_session_async.py b/sdk/face/azure-ai-vision-face/generated_tests/test_face_session_async.py index 305b3457df68..9228fad43fda 100644 --- a/sdk/face/azure-ai-vision-face/generated_tests/test_face_session_async.py +++ b/sdk/face/azure-ai-vision-face/generated_tests/test_face_session_async.py @@ -24,8 +24,7 @@ async def test_create_liveness_session(self, facesession_endpoint): "deviceCorrelationId": "str", "deviceCorrelationIdSetInClient": bool, "enableSessionImage": bool, - "livenessSingleModalModel": "str", - "sendResultsToClient": bool, + "livenessModelVersion": "str", }, ) @@ -56,19 +55,20 @@ async def test_get_liveness_session_result(self, facesession_endpoint): @FaceSessionPreparer() @recorded_by_proxy_async - async def test_get_liveness_sessions(self, facesession_endpoint): + async def test_create_liveness_with_verify_session(self, facesession_endpoint): client = self.create_async_client(endpoint=facesession_endpoint) - response = await client.get_liveness_sessions() - - # please add some check logic here by yourself - # ... - - @FaceSessionPreparer() - @recorded_by_proxy_async - async def test_get_liveness_session_audit_entries(self, facesession_endpoint): - client = self.create_async_client(endpoint=facesession_endpoint) - response = await client.get_liveness_session_audit_entries( - session_id="str", + response = await client.create_liveness_with_verify_session( + body={ + "livenessOperationMode": "str", + "verifyImage": "filetype", + "authTokenTimeToLiveInSeconds": 0, + "deviceCorrelationId": "str", + "deviceCorrelationIdSetInClient": bool, + "enableSessionImage": bool, + "livenessModelVersion": "str", + "returnVerifyImageHash": bool, + "verifyConfidenceThreshold": 0.0, + }, ) # please add some check logic here by yourself @@ -96,26 +96,6 @@ async def test_get_liveness_with_verify_session_result(self, facesession_endpoin # please add some check logic here by yourself # ... - @FaceSessionPreparer() - @recorded_by_proxy_async - async def test_get_liveness_with_verify_sessions(self, facesession_endpoint): - client = self.create_async_client(endpoint=facesession_endpoint) - response = await client.get_liveness_with_verify_sessions() - - # please add some check logic here by yourself - # ... - - @FaceSessionPreparer() - @recorded_by_proxy_async - async def test_get_liveness_with_verify_session_audit_entries(self, facesession_endpoint): - client = self.create_async_client(endpoint=facesession_endpoint) - response = await client.get_liveness_with_verify_session_audit_entries( - session_id="str", - ) - - # please add some check logic here by yourself - # ... - @FaceSessionPreparer() @recorded_by_proxy_async async def test_detect_from_session_image(self, facesession_endpoint): diff --git a/sdk/face/azure-ai-vision-face/generated_tests/testpreparer.py b/sdk/face/azure-ai-vision-face/generated_tests/testpreparer.py index eac137c4227c..55e422e010cf 100644 --- a/sdk/face/azure-ai-vision-face/generated_tests/testpreparer.py +++ b/sdk/face/azure-ai-vision-face/generated_tests/testpreparer.py @@ -10,47 +10,47 @@ import functools -class FaceAdministrationClientTestBase(AzureRecordedTestCase): +class FaceClientTestBase(AzureRecordedTestCase): def create_client(self, endpoint): - credential = self.get_credential(FaceAdministrationClient) + credential = self.get_credential(FaceClient) return self.create_client_from_credential( - FaceAdministrationClient, + FaceClient, credential=credential, endpoint=endpoint, ) -FaceAdministrationPreparer = functools.partial( - PowerShellPreparer, "faceadministration", faceadministration_endpoint="https://fake_faceadministration_endpoint.com" -) +FacePreparer = functools.partial(PowerShellPreparer, "face", face_endpoint="https://fake_face_endpoint.com") -class FaceClientTestBase(AzureRecordedTestCase): +class FaceSessionClientTestBase(AzureRecordedTestCase): def create_client(self, endpoint): - credential = self.get_credential(FaceClient) + credential = self.get_credential(FaceSessionClient) return self.create_client_from_credential( - FaceClient, + FaceSessionClient, credential=credential, endpoint=endpoint, ) -FacePreparer = functools.partial(PowerShellPreparer, "face", face_endpoint="https://fake_face_endpoint.com") +FaceSessionPreparer = functools.partial( + PowerShellPreparer, "facesession", facesession_endpoint="https://fake_facesession_endpoint.com" +) -class FaceSessionClientTestBase(AzureRecordedTestCase): +class FaceAdministrationClientTestBase(AzureRecordedTestCase): def create_client(self, endpoint): - credential = self.get_credential(FaceSessionClient) + credential = self.get_credential(FaceAdministrationClient) return self.create_client_from_credential( - FaceSessionClient, + FaceAdministrationClient, credential=credential, endpoint=endpoint, ) -FaceSessionPreparer = functools.partial( - PowerShellPreparer, "facesession", facesession_endpoint="https://fake_facesession_endpoint.com" +FaceAdministrationPreparer = functools.partial( + PowerShellPreparer, "faceadministration", faceadministration_endpoint="https://fake_faceadministration_endpoint.com" ) diff --git a/sdk/face/azure-ai-vision-face/generated_tests/testpreparer_async.py b/sdk/face/azure-ai-vision-face/generated_tests/testpreparer_async.py index 4ab6e112f20d..042bbe4d0f07 100644 --- a/sdk/face/azure-ai-vision-face/generated_tests/testpreparer_async.py +++ b/sdk/face/azure-ai-vision-face/generated_tests/testpreparer_async.py @@ -9,34 +9,34 @@ from devtools_testutils import AzureRecordedTestCase -class FaceAdministrationClientTestBaseAsync(AzureRecordedTestCase): +class FaceClientTestBaseAsync(AzureRecordedTestCase): def create_async_client(self, endpoint): - credential = self.get_credential(FaceAdministrationClient, is_async=True) + credential = self.get_credential(FaceClient, is_async=True) return self.create_client_from_credential( - FaceAdministrationClient, + FaceClient, credential=credential, endpoint=endpoint, ) -class FaceClientTestBaseAsync(AzureRecordedTestCase): +class FaceSessionClientTestBaseAsync(AzureRecordedTestCase): def create_async_client(self, endpoint): - credential = self.get_credential(FaceClient, is_async=True) + credential = self.get_credential(FaceSessionClient, is_async=True) return self.create_client_from_credential( - FaceClient, + FaceSessionClient, credential=credential, endpoint=endpoint, ) -class FaceSessionClientTestBaseAsync(AzureRecordedTestCase): +class FaceAdministrationClientTestBaseAsync(AzureRecordedTestCase): def create_async_client(self, endpoint): - credential = self.get_credential(FaceSessionClient, is_async=True) + credential = self.get_credential(FaceAdministrationClient, is_async=True) return self.create_client_from_credential( - FaceSessionClient, + FaceAdministrationClient, credential=credential, endpoint=endpoint, ) diff --git a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection.py b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection.py index e633fdc51f72..4485d3f198f8 100644 --- a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection.py +++ b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_async.py b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_async.py index cc8e0d301103..d6da0fc38606 100644 --- a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_async.py +++ b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification.py b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification.py index 3b8396d31b51..964510e46101 100644 --- a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification.py +++ b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification_async.py b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification_async.py index 00861e0a05f0..708a29cc4971 100644 --- a/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification_async.py +++ b/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/face/azure-ai-vision-face/setup.py b/sdk/face/azure-ai-vision-face/setup.py index 85c0e4ceb836..783365237501 100644 --- a/sdk/face/azure-ai-vision-face/setup.py +++ b/sdk/face/azure-ai-vision-face/setup.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# coding: utf-8 + import os import re @@ -29,7 +29,7 @@ setup( name=PACKAGE_NAME, version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME), long_description=open("README.md", "r").read(), long_description_content_type="text/markdown", license="MIT License", @@ -42,7 +42,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -68,5 +67,5 @@ "azure-core>=1.30.0", "typing-extensions>=4.6.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/face/azure-ai-vision-face/tsp-location.yaml b/sdk/face/azure-ai-vision-face/tsp-location.yaml index ceff84974c6e..ae0155362589 100644 --- a/sdk/face/azure-ai-vision-face/tsp-location.yaml +++ b/sdk/face/azure-ai-vision-face/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Face -commit: 4037b28c1014648f4cfa6f8c965e45f2476652e2 +commit: 0660a73ea14775552af66f95d92e1a0446a04b54 repo: Azure/azure-rest-api-specs -additionalDirectories: +additionalDirectories: