diff --git a/azure-cognitiveservices-vision-face/MANIFEST.in b/azure-cognitiveservices-vision-face/MANIFEST.in index bb37a2723dae..e437a6594c1b 100644 --- a/azure-cognitiveservices-vision-face/MANIFEST.in +++ b/azure-cognitiveservices-vision-face/MANIFEST.in @@ -1 +1,5 @@ include *.rst +include azure/__init__.py +include azure/cognitiveservices/__init__.py +include azure/cognitiveservices/vision/__init__.py + diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/__init__.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/__init__.py index 6fb1f4b18994..15376d8ae672 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/__init__.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/__init__.py @@ -9,10 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .face_api import FaceAPI +from .face_client import FaceClient from .version import VERSION -__all__ = ['FaceAPI'] +__all__ = ['FaceClient'] __version__ = VERSION diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_api.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_client.py similarity index 56% rename from azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_api.py rename to azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_client.py index 94e7879cfc9b..024f0fdac4c5 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_api.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/face_client.py @@ -9,55 +9,54 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import ServiceClient +from msrest.service_client import SDKClient from msrest import Configuration, Serializer, Deserializer from .version import VERSION from .operations.face_operations import FaceOperations from .operations.person_group_person_operations import PersonGroupPersonOperations from .operations.person_group_operations import PersonGroupOperations from .operations.face_list_operations import FaceListOperations +from .operations.large_person_group_person_operations import LargePersonGroupPersonOperations +from .operations.large_person_group_operations import LargePersonGroupOperations +from .operations.large_face_list_operations import LargeFaceListOperations from . import models -class FaceAPIConfiguration(Configuration): - """Configuration for FaceAPI +class FaceClientConfiguration(Configuration): + """Configuration for FaceClient Note that all parameters used to create this instance are saved as instance attributes. - :param azure_region: Supported Azure regions for Cognitive Services - endpoints. Possible values include: 'westus', 'westeurope', - 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', - 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', - 'brazilsouth' - :type azure_region: str or - ~azure.cognitiveservices.vision.face.models.AzureRegions + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus.api.cognitive.microsoft.com). + :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( - self, azure_region, credentials): + self, endpoint, credentials): - if azure_region is None: - raise ValueError("Parameter 'azure_region' must not be None.") + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = 'https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0' + base_url = '{Endpoint}/face/v1.0' - super(FaceAPIConfiguration, self).__init__(base_url) + super(FaceClientConfiguration, self).__init__(base_url) self.add_user_agent('azure-cognitiveservices-vision-face/{}'.format(VERSION)) - self.azure_region = azure_region + self.endpoint = endpoint self.credentials = credentials -class FaceAPI(object): +class FaceClient(SDKClient): """An API for face detection, verification, and identification. :ivar config: Configuration for client. - :vartype config: FaceAPIConfiguration + :vartype config: FaceClientConfiguration :ivar face: Face operations :vartype face: azure.cognitiveservices.vision.face.operations.FaceOperations @@ -67,24 +66,26 @@ class FaceAPI(object): :vartype person_group: azure.cognitiveservices.vision.face.operations.PersonGroupOperations :ivar face_list: FaceList operations :vartype face_list: azure.cognitiveservices.vision.face.operations.FaceListOperations - - :param azure_region: Supported Azure regions for Cognitive Services - endpoints. Possible values include: 'westus', 'westeurope', - 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', - 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', - 'brazilsouth' - :type azure_region: str or - ~azure.cognitiveservices.vision.face.models.AzureRegions + :ivar large_person_group_person: LargePersonGroupPerson operations + :vartype large_person_group_person: azure.cognitiveservices.vision.face.operations.LargePersonGroupPersonOperations + :ivar large_person_group: LargePersonGroup operations + :vartype large_person_group: azure.cognitiveservices.vision.face.operations.LargePersonGroupOperations + :ivar large_face_list: LargeFaceList operations + :vartype large_face_list: azure.cognitiveservices.vision.face.operations.LargeFaceListOperations + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus.api.cognitive.microsoft.com). + :type endpoint: str :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( - self, azure_region, credentials): + self, endpoint, credentials): - self.config = FaceAPIConfiguration(azure_region, credentials) - self._client = ServiceClient(self.config.credentials, self.config) + self.config = FaceClientConfiguration(endpoint, credentials) + super(FaceClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self.api_version = '1.0' @@ -99,3 +100,9 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.face_list = FaceListOperations( self._client, self.config, self._serialize, self._deserialize) + self.large_person_group_person = LargePersonGroupPersonOperations( + self._client, self.config, self._serialize, self._deserialize) + self.large_person_group = LargePersonGroupOperations( + self._client, self.config, self._serialize, self._deserialize) + self.large_face_list = LargeFaceListOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/__init__.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/__init__.py index 0284e92feffc..4b6874f172bf 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/__init__.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/__init__.py @@ -9,43 +9,85 @@ # regenerated. # -------------------------------------------------------------------------- -from .error import Error -from .api_error import APIError, APIErrorException -from .face_rectangle import FaceRectangle -from .coordinate import Coordinate -from .face_landmarks import FaceLandmarks -from .facial_hair import FacialHair -from .head_pose import HeadPose -from .emotion import Emotion -from .hair_color import HairColor -from .hair import Hair -from .makeup import Makeup -from .occlusion import Occlusion -from .accessory import Accessory -from .blur import Blur -from .exposure import Exposure -from .noise import Noise -from .face_attributes import FaceAttributes -from .detected_face import DetectedFace -from .find_similar_request import FindSimilarRequest -from .similar_face import SimilarFace -from .group_request import GroupRequest -from .group_result import GroupResult -from .identify_request import IdentifyRequest -from .identify_candidate import IdentifyCandidate -from .identify_result import IdentifyResult -from .verify_face_to_person_request import VerifyFaceToPersonRequest -from .verify_face_to_face_request import VerifyFaceToFaceRequest -from .verify_result import VerifyResult -from .persisted_face import PersistedFace -from .face_list import FaceList -from .person_group import PersonGroup -from .person import Person -from .update_person_face_request import UpdatePersonFaceRequest -from .training_status import TrainingStatus -from .name_and_user_data_contract import NameAndUserDataContract -from .image_url import ImageUrl -from .face_api_enums import ( +try: + from .error_py3 import Error + from .api_error_py3 import APIError, APIErrorException + from .face_rectangle_py3 import FaceRectangle + from .coordinate_py3 import Coordinate + from .face_landmarks_py3 import FaceLandmarks + from .facial_hair_py3 import FacialHair + from .head_pose_py3 import HeadPose + from .emotion_py3 import Emotion + from .hair_color_py3 import HairColor + from .hair_py3 import Hair + from .makeup_py3 import Makeup + from .occlusion_py3 import Occlusion + from .accessory_py3 import Accessory + from .blur_py3 import Blur + from .exposure_py3 import Exposure + from .noise_py3 import Noise + from .face_attributes_py3 import FaceAttributes + from .detected_face_py3 import DetectedFace + from .find_similar_request_py3 import FindSimilarRequest + from .similar_face_py3 import SimilarFace + from .group_request_py3 import GroupRequest + from .group_result_py3 import GroupResult + from .identify_request_py3 import IdentifyRequest + from .identify_candidate_py3 import IdentifyCandidate + from .identify_result_py3 import IdentifyResult + from .verify_face_to_person_request_py3 import VerifyFaceToPersonRequest + from .verify_face_to_face_request_py3 import VerifyFaceToFaceRequest + from .verify_result_py3 import VerifyResult + from .persisted_face_py3 import PersistedFace + from .face_list_py3 import FaceList + from .person_group_py3 import PersonGroup + from .person_py3 import Person + from .large_face_list_py3 import LargeFaceList + from .large_person_group_py3 import LargePersonGroup + from .update_face_request_py3 import UpdateFaceRequest + from .training_status_py3 import TrainingStatus + from .name_and_user_data_contract_py3 import NameAndUserDataContract + from .image_url_py3 import ImageUrl +except (SyntaxError, ImportError): + from .error import Error + from .api_error import APIError, APIErrorException + from .face_rectangle import FaceRectangle + from .coordinate import Coordinate + from .face_landmarks import FaceLandmarks + from .facial_hair import FacialHair + from .head_pose import HeadPose + from .emotion import Emotion + from .hair_color import HairColor + from .hair import Hair + from .makeup import Makeup + from .occlusion import Occlusion + from .accessory import Accessory + from .blur import Blur + from .exposure import Exposure + from .noise import Noise + from .face_attributes import FaceAttributes + from .detected_face import DetectedFace + from .find_similar_request import FindSimilarRequest + from .similar_face import SimilarFace + from .group_request import GroupRequest + from .group_result import GroupResult + from .identify_request import IdentifyRequest + from .identify_candidate import IdentifyCandidate + from .identify_result import IdentifyResult + from .verify_face_to_person_request import VerifyFaceToPersonRequest + from .verify_face_to_face_request import VerifyFaceToFaceRequest + from .verify_result import VerifyResult + from .persisted_face import PersistedFace + from .face_list import FaceList + from .person_group import PersonGroup + from .person import Person + from .large_face_list import LargeFaceList + from .large_person_group import LargePersonGroup + from .update_face_request import UpdateFaceRequest + from .training_status import TrainingStatus + from .name_and_user_data_contract import NameAndUserDataContract + from .image_url import ImageUrl +from .face_client_enums import ( Gender, GlassesType, HairColorType, @@ -56,7 +98,6 @@ FindSimilarMatchMode, TrainingStatusType, FaceAttributeType, - AzureRegions, ) __all__ = [ @@ -92,7 +133,9 @@ 'FaceList', 'PersonGroup', 'Person', - 'UpdatePersonFaceRequest', + 'LargeFaceList', + 'LargePersonGroup', + 'UpdateFaceRequest', 'TrainingStatus', 'NameAndUserDataContract', 'ImageUrl', @@ -106,5 +149,4 @@ 'FindSimilarMatchMode', 'TrainingStatusType', 'FaceAttributeType', - 'AzureRegions', ] diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory.py index d90e097955e6..b86acc571c10 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory.py @@ -28,7 +28,7 @@ class Accessory(Model): 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, type=None, confidence=None): - super(Accessory, self).__init__() - self.type = type - self.confidence = confidence + def __init__(self, **kwargs): + super(Accessory, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory_py3.py new file mode 100644 index 000000000000..76a6b68edbbd --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/accessory_py3.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Accessory(Model): + """Accessory item and corresponding confidence level. + + :param type: Type of an accessory. Possible values include: 'headWear', + 'glasses', 'mask' + :type type: str or + ~azure.cognitiveservices.vision.face.models.AccessoryType + :param confidence: Confidence level of an accessory + :type confidence: float + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'AccessoryType'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, type=None, confidence: float=None, **kwargs) -> None: + super(Accessory, self).__init__(**kwargs) + self.type = type + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error.py index 3c50d6f06c96..79e8c1765e4b 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error.py @@ -24,9 +24,9 @@ class APIError(Model): 'error': {'key': 'error', 'type': 'Error'}, } - def __init__(self, error=None): - super(APIError, self).__init__() - self.error = error + def __init__(self, **kwargs): + super(APIError, self).__init__(**kwargs) + self.error = kwargs.get('error', None) class APIErrorException(HttpOperationError): diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error_py3.py new file mode 100644 index 000000000000..4e362714807d --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/api_error_py3.py @@ -0,0 +1,41 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class APIError(Model): + """Error information returned by the API. + + :param error: + :type error: ~azure.cognitiveservices.vision.face.models.Error + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'Error'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(APIError, self).__init__(**kwargs) + self.error = error + + +class APIErrorException(HttpOperationError): + """Server responsed with exception of type: 'APIError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur.py index 79c8e0e2437d..f7dead76fcf1 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur.py @@ -28,7 +28,7 @@ class Blur(Model): 'value': {'key': 'value', 'type': 'float'}, } - def __init__(self, blur_level=None, value=None): - super(Blur, self).__init__() - self.blur_level = blur_level - self.value = value + def __init__(self, **kwargs): + super(Blur, self).__init__(**kwargs) + self.blur_level = kwargs.get('blur_level', None) + self.value = kwargs.get('value', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur_py3.py new file mode 100644 index 000000000000..db3c6f5860af --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/blur_py3.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Blur(Model): + """Properties describing any presence of blur within the image. + + :param blur_level: An enum value indicating level of blurriness. Possible + values include: 'Low', 'Medium', 'High' + :type blur_level: str or + ~azure.cognitiveservices.vision.face.models.BlurLevel + :param value: A number indicating level of blurriness ranging from 0 to 1. + :type value: float + """ + + _attribute_map = { + 'blur_level': {'key': 'blurLevel', 'type': 'BlurLevel'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, blur_level=None, value: float=None, **kwargs) -> None: + super(Blur, self).__init__(**kwargs) + self.blur_level = blur_level + self.value = value diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate.py index 6274f67828e3..c786707ccfb9 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate.py @@ -15,9 +15,11 @@ class Coordinate(Model): """Coordinates within an image. - :param x: The horizontal component, in pixels. + All required parameters must be populated in order to send to Azure. + + :param x: Required. The horizontal component, in pixels. :type x: float - :param y: The vertical component, in pixels. + :param y: Required. The vertical component, in pixels. :type y: float """ @@ -31,7 +33,7 @@ class Coordinate(Model): 'y': {'key': 'y', 'type': 'float'}, } - def __init__(self, x, y): - super(Coordinate, self).__init__() - self.x = x - self.y = y + def __init__(self, **kwargs): + super(Coordinate, self).__init__(**kwargs) + self.x = kwargs.get('x', None) + self.y = kwargs.get('y', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate_py3.py new file mode 100644 index 000000000000..5068b2380dd5 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/coordinate_py3.py @@ -0,0 +1,39 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Coordinate(Model): + """Coordinates within an image. + + All required parameters must be populated in order to send to Azure. + + :param x: Required. The horizontal component, in pixels. + :type x: float + :param y: Required. The vertical component, in pixels. + :type y: float + """ + + _validation = { + 'x': {'required': True}, + 'y': {'required': True}, + } + + _attribute_map = { + 'x': {'key': 'x', 'type': 'float'}, + 'y': {'key': 'y', 'type': 'float'}, + } + + def __init__(self, *, x: float, y: float, **kwargs) -> None: + super(Coordinate, self).__init__(**kwargs) + self.x = x + self.y = y diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face.py index 7710d8234b9b..1902cba2492a 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face.py @@ -15,9 +15,11 @@ class DetectedFace(Model): """Detected Face object. + All required parameters must be populated in order to send to Azure. + :param face_id: :type face_id: str - :param face_rectangle: + :param face_rectangle: Required. :type face_rectangle: ~azure.cognitiveservices.vision.face.models.FaceRectangle :param face_landmarks: @@ -39,9 +41,9 @@ class DetectedFace(Model): 'face_attributes': {'key': 'faceAttributes', 'type': 'FaceAttributes'}, } - def __init__(self, face_rectangle, face_id=None, face_landmarks=None, face_attributes=None): - super(DetectedFace, self).__init__() - self.face_id = face_id - self.face_rectangle = face_rectangle - self.face_landmarks = face_landmarks - self.face_attributes = face_attributes + def __init__(self, **kwargs): + super(DetectedFace, self).__init__(**kwargs) + self.face_id = kwargs.get('face_id', None) + self.face_rectangle = kwargs.get('face_rectangle', None) + self.face_landmarks = kwargs.get('face_landmarks', None) + self.face_attributes = kwargs.get('face_attributes', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face_py3.py new file mode 100644 index 000000000000..ebb54646574c --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/detected_face_py3.py @@ -0,0 +1,49 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class DetectedFace(Model): + """Detected Face object. + + All required parameters must be populated in order to send to Azure. + + :param face_id: + :type face_id: str + :param face_rectangle: Required. + :type face_rectangle: + ~azure.cognitiveservices.vision.face.models.FaceRectangle + :param face_landmarks: + :type face_landmarks: + ~azure.cognitiveservices.vision.face.models.FaceLandmarks + :param face_attributes: + :type face_attributes: + ~azure.cognitiveservices.vision.face.models.FaceAttributes + """ + + _validation = { + 'face_rectangle': {'required': True}, + } + + _attribute_map = { + 'face_id': {'key': 'faceId', 'type': 'str'}, + 'face_rectangle': {'key': 'faceRectangle', 'type': 'FaceRectangle'}, + 'face_landmarks': {'key': 'faceLandmarks', 'type': 'FaceLandmarks'}, + 'face_attributes': {'key': 'faceAttributes', 'type': 'FaceAttributes'}, + } + + def __init__(self, *, face_rectangle, face_id: str=None, face_landmarks=None, face_attributes=None, **kwargs) -> None: + super(DetectedFace, self).__init__(**kwargs) + self.face_id = face_id + self.face_rectangle = face_rectangle + self.face_landmarks = face_landmarks + self.face_attributes = face_attributes diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion.py index 16764d94baed..bd8a42b2306a 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion.py @@ -45,13 +45,13 @@ class Emotion(Model): 'surprise': {'key': 'surprise', 'type': 'float'}, } - def __init__(self, anger=None, contempt=None, disgust=None, fear=None, happiness=None, neutral=None, sadness=None, surprise=None): - super(Emotion, self).__init__() - self.anger = anger - self.contempt = contempt - self.disgust = disgust - self.fear = fear - self.happiness = happiness - self.neutral = neutral - self.sadness = sadness - self.surprise = surprise + def __init__(self, **kwargs): + super(Emotion, self).__init__(**kwargs) + self.anger = kwargs.get('anger', None) + self.contempt = kwargs.get('contempt', None) + self.disgust = kwargs.get('disgust', None) + self.fear = kwargs.get('fear', None) + self.happiness = kwargs.get('happiness', None) + self.neutral = kwargs.get('neutral', None) + self.sadness = kwargs.get('sadness', None) + self.surprise = kwargs.get('surprise', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion_py3.py new file mode 100644 index 000000000000..552f1b193389 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/emotion_py3.py @@ -0,0 +1,57 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Emotion(Model): + """Properties describing facial emotion in form of confidence ranging from 0 + to 1. + + :param anger: + :type anger: float + :param contempt: + :type contempt: float + :param disgust: + :type disgust: float + :param fear: + :type fear: float + :param happiness: + :type happiness: float + :param neutral: + :type neutral: float + :param sadness: + :type sadness: float + :param surprise: + :type surprise: float + """ + + _attribute_map = { + 'anger': {'key': 'anger', 'type': 'float'}, + 'contempt': {'key': 'contempt', 'type': 'float'}, + 'disgust': {'key': 'disgust', 'type': 'float'}, + 'fear': {'key': 'fear', 'type': 'float'}, + 'happiness': {'key': 'happiness', 'type': 'float'}, + 'neutral': {'key': 'neutral', 'type': 'float'}, + 'sadness': {'key': 'sadness', 'type': 'float'}, + 'surprise': {'key': 'surprise', 'type': 'float'}, + } + + def __init__(self, *, anger: float=None, contempt: float=None, disgust: float=None, fear: float=None, happiness: float=None, neutral: float=None, sadness: float=None, surprise: float=None, **kwargs) -> None: + super(Emotion, self).__init__(**kwargs) + self.anger = anger + self.contempt = contempt + self.disgust = disgust + self.fear = fear + self.happiness = happiness + self.neutral = neutral + self.sadness = sadness + self.surprise = surprise diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error.py index 8f2f89ad37e1..a41106cfaca6 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error.py @@ -26,7 +26,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, code=None, message=None): - super(Error, self).__init__() - self.code = code - self.message = message + def __init__(self, **kwargs): + super(Error, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error_py3.py new file mode 100644 index 000000000000..08e8cb04c44d --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/error_py3.py @@ -0,0 +1,32 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Error(Model): + """Error body. + + :param code: + :type code: str + :param message: + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.message = message diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure.py index 9aee1b9eb433..07c7359c6dab 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure.py @@ -30,7 +30,7 @@ class Exposure(Model): 'value': {'key': 'value', 'type': 'float'}, } - def __init__(self, exposure_level=None, value=None): - super(Exposure, self).__init__() - self.exposure_level = exposure_level - self.value = value + def __init__(self, **kwargs): + super(Exposure, self).__init__(**kwargs) + self.exposure_level = kwargs.get('exposure_level', None) + self.value = kwargs.get('value', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure_py3.py new file mode 100644 index 000000000000..efff64344121 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/exposure_py3.py @@ -0,0 +1,36 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Exposure(Model): + """Properties describing exposure level of the image. + + :param exposure_level: An enum value indicating level of exposure. + Possible values include: 'UnderExposure', 'GoodExposure', 'OverExposure' + :type exposure_level: str or + ~azure.cognitiveservices.vision.face.models.ExposureLevel + :param value: 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. + :type value: float + """ + + _attribute_map = { + 'exposure_level': {'key': 'exposureLevel', 'type': 'ExposureLevel'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, exposure_level=None, value: float=None, **kwargs) -> None: + super(Exposure, self).__init__(**kwargs) + self.exposure_level = exposure_level + self.value = value diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes.py index 3936b580b186..2f2903a85920 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes.py @@ -67,19 +67,19 @@ class FaceAttributes(Model): 'noise': {'key': 'noise', 'type': 'Noise'}, } - def __init__(self, age=None, gender=None, smile=None, facial_hair=None, glasses=None, head_pose=None, emotion=None, hair=None, makeup=None, occlusion=None, accessories=None, blur=None, exposure=None, noise=None): - super(FaceAttributes, self).__init__() - self.age = age - self.gender = gender - self.smile = smile - self.facial_hair = facial_hair - self.glasses = glasses - self.head_pose = head_pose - self.emotion = emotion - self.hair = hair - self.makeup = makeup - self.occlusion = occlusion - self.accessories = accessories - self.blur = blur - self.exposure = exposure - self.noise = noise + def __init__(self, **kwargs): + super(FaceAttributes, self).__init__(**kwargs) + self.age = kwargs.get('age', None) + self.gender = kwargs.get('gender', None) + self.smile = kwargs.get('smile', None) + self.facial_hair = kwargs.get('facial_hair', None) + self.glasses = kwargs.get('glasses', None) + self.head_pose = kwargs.get('head_pose', None) + self.emotion = kwargs.get('emotion', None) + self.hair = kwargs.get('hair', None) + self.makeup = kwargs.get('makeup', None) + self.occlusion = kwargs.get('occlusion', None) + self.accessories = kwargs.get('accessories', None) + self.blur = kwargs.get('blur', None) + self.exposure = kwargs.get('exposure', None) + self.noise = kwargs.get('noise', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes_py3.py new file mode 100644 index 000000000000..25cb9d63acea --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_attributes_py3.py @@ -0,0 +1,85 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FaceAttributes(Model): + """Face Attributes. + + :param age: Age in years + :type age: float + :param gender: Possible gender of the face. Possible values include: + 'male', 'female', 'genderless' + :type gender: str or ~azure.cognitiveservices.vision.face.models.Gender + :param smile: Smile intensity, a number between [0,1] + :type smile: float + :param facial_hair: Properties describing facial hair attributes. + :type facial_hair: ~azure.cognitiveservices.vision.face.models.FacialHair + :param glasses: Glasses type if any of the face. Possible values include: + 'noGlasses', 'readingGlasses', 'sunglasses', 'swimmingGoggles' + :type glasses: str or + ~azure.cognitiveservices.vision.face.models.GlassesType + :param head_pose: Properties indicating head pose of the face. + :type head_pose: ~azure.cognitiveservices.vision.face.models.HeadPose + :param emotion: Properties describing facial emotion in form of confidence + ranging from 0 to 1. + :type emotion: ~azure.cognitiveservices.vision.face.models.Emotion + :param hair: Properties describing hair attributes. + :type hair: ~azure.cognitiveservices.vision.face.models.Hair + :param makeup: Properties describing present makeups on a given face. + :type makeup: ~azure.cognitiveservices.vision.face.models.Makeup + :param occlusion: Properties describing occlusions on a given face. + :type occlusion: ~azure.cognitiveservices.vision.face.models.Occlusion + :param accessories: Properties describing any accessories on a given face. + :type accessories: + list[~azure.cognitiveservices.vision.face.models.Accessory] + :param blur: Properties describing any presence of blur within the image. + :type blur: ~azure.cognitiveservices.vision.face.models.Blur + :param exposure: Properties describing exposure level of the image. + :type exposure: ~azure.cognitiveservices.vision.face.models.Exposure + :param noise: Properties describing noise level of the image. + :type noise: ~azure.cognitiveservices.vision.face.models.Noise + """ + + _attribute_map = { + 'age': {'key': 'age', 'type': 'float'}, + 'gender': {'key': 'gender', 'type': 'Gender'}, + 'smile': {'key': 'smile', 'type': 'float'}, + 'facial_hair': {'key': 'facialHair', 'type': 'FacialHair'}, + 'glasses': {'key': 'glasses', 'type': 'GlassesType'}, + 'head_pose': {'key': 'headPose', 'type': 'HeadPose'}, + 'emotion': {'key': 'emotion', 'type': 'Emotion'}, + 'hair': {'key': 'hair', 'type': 'Hair'}, + 'makeup': {'key': 'makeup', 'type': 'Makeup'}, + 'occlusion': {'key': 'occlusion', 'type': 'Occlusion'}, + 'accessories': {'key': 'accessories', 'type': '[Accessory]'}, + 'blur': {'key': 'blur', 'type': 'Blur'}, + 'exposure': {'key': 'exposure', 'type': 'Exposure'}, + 'noise': {'key': 'noise', 'type': 'Noise'}, + } + + def __init__(self, *, age: float=None, gender=None, smile: float=None, facial_hair=None, glasses=None, head_pose=None, emotion=None, hair=None, makeup=None, occlusion=None, accessories=None, blur=None, exposure=None, noise=None, **kwargs) -> None: + super(FaceAttributes, self).__init__(**kwargs) + self.age = age + self.gender = gender + self.smile = smile + self.facial_hair = facial_hair + self.glasses = glasses + self.head_pose = head_pose + self.emotion = emotion + self.hair = hair + self.makeup = makeup + self.occlusion = occlusion + self.accessories = accessories + self.blur = blur + self.exposure = exposure + self.noise = noise diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_api_enums.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_client_enums.py similarity index 71% rename from azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_api_enums.py rename to azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_client_enums.py index 4906b26bd840..c7a86871cea2 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_api_enums.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_client_enums.py @@ -12,14 +12,14 @@ from enum import Enum -class Gender(Enum): +class Gender(str, Enum): male = "male" female = "female" genderless = "genderless" -class GlassesType(Enum): +class GlassesType(str, Enum): no_glasses = "noGlasses" reading_glasses = "readingGlasses" @@ -27,7 +27,7 @@ class GlassesType(Enum): swimming_goggles = "swimmingGoggles" -class HairColorType(Enum): +class HairColorType(str, Enum): unknown = "unknown" white = "white" @@ -39,41 +39,41 @@ class HairColorType(Enum): other = "other" -class AccessoryType(Enum): +class AccessoryType(str, Enum): head_wear = "headWear" glasses = "glasses" mask = "mask" -class BlurLevel(Enum): +class BlurLevel(str, Enum): low = "Low" medium = "Medium" high = "High" -class ExposureLevel(Enum): +class ExposureLevel(str, Enum): under_exposure = "UnderExposure" good_exposure = "GoodExposure" over_exposure = "OverExposure" -class NoiseLevel(Enum): +class NoiseLevel(str, Enum): low = "Low" medium = "Medium" high = "High" -class FindSimilarMatchMode(Enum): +class FindSimilarMatchMode(str, Enum): match_person = "matchPerson" match_face = "matchFace" -class TrainingStatusType(Enum): +class TrainingStatusType(str, Enum): nonstarted = "nonstarted" running = "running" @@ -81,7 +81,7 @@ class TrainingStatusType(Enum): failed = "failed" -class FaceAttributeType(Enum): +class FaceAttributeType(str, Enum): age = "age" gender = "gender" @@ -97,19 +97,3 @@ class FaceAttributeType(Enum): blur = "blur" exposure = "exposure" noise = "noise" - - -class AzureRegions(Enum): - - westus = "westus" - westeurope = "westeurope" - southeastasia = "southeastasia" - eastus2 = "eastus2" - westcentralus = "westcentralus" - westus2 = "westus2" - eastus = "eastus" - southcentralus = "southcentralus" - northeurope = "northeurope" - eastasia = "eastasia" - australiaeast = "australiaeast" - brazilsouth = "brazilsouth" diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks.py index 1f9eb72dd7b3..7e385f435b69 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks.py @@ -123,32 +123,32 @@ class FaceLandmarks(Model): 'under_lip_bottom': {'key': 'underLipBottom', 'type': 'Coordinate'}, } - def __init__(self, pupil_left=None, pupil_right=None, nose_tip=None, mouth_left=None, mouth_right=None, eyebrow_left_outer=None, eyebrow_left_inner=None, eye_left_outer=None, eye_left_top=None, eye_left_bottom=None, eye_left_inner=None, eyebrow_right_inner=None, eyebrow_right_outer=None, eye_right_inner=None, eye_right_top=None, eye_right_bottom=None, eye_right_outer=None, nose_root_left=None, nose_root_right=None, nose_left_alar_top=None, nose_right_alar_top=None, nose_left_alar_out_tip=None, nose_right_alar_out_tip=None, upper_lip_top=None, upper_lip_bottom=None, under_lip_top=None, under_lip_bottom=None): - super(FaceLandmarks, self).__init__() - self.pupil_left = pupil_left - self.pupil_right = pupil_right - self.nose_tip = nose_tip - self.mouth_left = mouth_left - self.mouth_right = mouth_right - self.eyebrow_left_outer = eyebrow_left_outer - self.eyebrow_left_inner = eyebrow_left_inner - self.eye_left_outer = eye_left_outer - self.eye_left_top = eye_left_top - self.eye_left_bottom = eye_left_bottom - self.eye_left_inner = eye_left_inner - self.eyebrow_right_inner = eyebrow_right_inner - self.eyebrow_right_outer = eyebrow_right_outer - self.eye_right_inner = eye_right_inner - self.eye_right_top = eye_right_top - self.eye_right_bottom = eye_right_bottom - self.eye_right_outer = eye_right_outer - self.nose_root_left = nose_root_left - self.nose_root_right = nose_root_right - self.nose_left_alar_top = nose_left_alar_top - self.nose_right_alar_top = nose_right_alar_top - self.nose_left_alar_out_tip = nose_left_alar_out_tip - self.nose_right_alar_out_tip = nose_right_alar_out_tip - self.upper_lip_top = upper_lip_top - self.upper_lip_bottom = upper_lip_bottom - self.under_lip_top = under_lip_top - self.under_lip_bottom = under_lip_bottom + def __init__(self, **kwargs): + super(FaceLandmarks, self).__init__(**kwargs) + self.pupil_left = kwargs.get('pupil_left', None) + self.pupil_right = kwargs.get('pupil_right', None) + self.nose_tip = kwargs.get('nose_tip', None) + self.mouth_left = kwargs.get('mouth_left', None) + self.mouth_right = kwargs.get('mouth_right', None) + self.eyebrow_left_outer = kwargs.get('eyebrow_left_outer', None) + self.eyebrow_left_inner = kwargs.get('eyebrow_left_inner', None) + self.eye_left_outer = kwargs.get('eye_left_outer', None) + self.eye_left_top = kwargs.get('eye_left_top', None) + self.eye_left_bottom = kwargs.get('eye_left_bottom', None) + self.eye_left_inner = kwargs.get('eye_left_inner', None) + self.eyebrow_right_inner = kwargs.get('eyebrow_right_inner', None) + self.eyebrow_right_outer = kwargs.get('eyebrow_right_outer', None) + self.eye_right_inner = kwargs.get('eye_right_inner', None) + self.eye_right_top = kwargs.get('eye_right_top', None) + self.eye_right_bottom = kwargs.get('eye_right_bottom', None) + self.eye_right_outer = kwargs.get('eye_right_outer', None) + self.nose_root_left = kwargs.get('nose_root_left', None) + self.nose_root_right = kwargs.get('nose_root_right', None) + self.nose_left_alar_top = kwargs.get('nose_left_alar_top', None) + self.nose_right_alar_top = kwargs.get('nose_right_alar_top', None) + self.nose_left_alar_out_tip = kwargs.get('nose_left_alar_out_tip', None) + self.nose_right_alar_out_tip = kwargs.get('nose_right_alar_out_tip', None) + self.upper_lip_top = kwargs.get('upper_lip_top', None) + self.upper_lip_bottom = kwargs.get('upper_lip_bottom', None) + self.under_lip_top = kwargs.get('under_lip_top', None) + self.under_lip_bottom = kwargs.get('under_lip_bottom', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks_py3.py new file mode 100644 index 000000000000..3bffe97ff181 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_landmarks_py3.py @@ -0,0 +1,154 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FaceLandmarks(Model): + """A collection of 27-point face landmarks pointing to the important positions + of face components. + + :param pupil_left: + :type pupil_left: ~azure.cognitiveservices.vision.face.models.Coordinate + :param pupil_right: + :type pupil_right: ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_tip: + :type nose_tip: ~azure.cognitiveservices.vision.face.models.Coordinate + :param mouth_left: + :type mouth_left: ~azure.cognitiveservices.vision.face.models.Coordinate + :param mouth_right: + :type mouth_right: ~azure.cognitiveservices.vision.face.models.Coordinate + :param eyebrow_left_outer: + :type eyebrow_left_outer: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eyebrow_left_inner: + :type eyebrow_left_inner: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_left_outer: + :type eye_left_outer: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_left_top: + :type eye_left_top: ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_left_bottom: + :type eye_left_bottom: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_left_inner: + :type eye_left_inner: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eyebrow_right_inner: + :type eyebrow_right_inner: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eyebrow_right_outer: + :type eyebrow_right_outer: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_right_inner: + :type eye_right_inner: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_right_top: + :type eye_right_top: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_right_bottom: + :type eye_right_bottom: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param eye_right_outer: + :type eye_right_outer: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_root_left: + :type nose_root_left: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_root_right: + :type nose_root_right: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_left_alar_top: + :type nose_left_alar_top: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_right_alar_top: + :type nose_right_alar_top: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_left_alar_out_tip: + :type nose_left_alar_out_tip: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param nose_right_alar_out_tip: + :type nose_right_alar_out_tip: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param upper_lip_top: + :type upper_lip_top: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param upper_lip_bottom: + :type upper_lip_bottom: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param under_lip_top: + :type under_lip_top: + ~azure.cognitiveservices.vision.face.models.Coordinate + :param under_lip_bottom: + :type under_lip_bottom: + ~azure.cognitiveservices.vision.face.models.Coordinate + """ + + _attribute_map = { + 'pupil_left': {'key': 'pupilLeft', 'type': 'Coordinate'}, + 'pupil_right': {'key': 'pupilRight', 'type': 'Coordinate'}, + 'nose_tip': {'key': 'noseTip', 'type': 'Coordinate'}, + 'mouth_left': {'key': 'mouthLeft', 'type': 'Coordinate'}, + 'mouth_right': {'key': 'mouthRight', 'type': 'Coordinate'}, + 'eyebrow_left_outer': {'key': 'eyebrowLeftOuter', 'type': 'Coordinate'}, + 'eyebrow_left_inner': {'key': 'eyebrowLeftInner', 'type': 'Coordinate'}, + 'eye_left_outer': {'key': 'eyeLeftOuter', 'type': 'Coordinate'}, + 'eye_left_top': {'key': 'eyeLeftTop', 'type': 'Coordinate'}, + 'eye_left_bottom': {'key': 'eyeLeftBottom', 'type': 'Coordinate'}, + 'eye_left_inner': {'key': 'eyeLeftInner', 'type': 'Coordinate'}, + 'eyebrow_right_inner': {'key': 'eyebrowRightInner', 'type': 'Coordinate'}, + 'eyebrow_right_outer': {'key': 'eyebrowRightOuter', 'type': 'Coordinate'}, + 'eye_right_inner': {'key': 'eyeRightInner', 'type': 'Coordinate'}, + 'eye_right_top': {'key': 'eyeRightTop', 'type': 'Coordinate'}, + 'eye_right_bottom': {'key': 'eyeRightBottom', 'type': 'Coordinate'}, + 'eye_right_outer': {'key': 'eyeRightOuter', 'type': 'Coordinate'}, + 'nose_root_left': {'key': 'noseRootLeft', 'type': 'Coordinate'}, + 'nose_root_right': {'key': 'noseRootRight', 'type': 'Coordinate'}, + 'nose_left_alar_top': {'key': 'noseLeftAlarTop', 'type': 'Coordinate'}, + 'nose_right_alar_top': {'key': 'noseRightAlarTop', 'type': 'Coordinate'}, + 'nose_left_alar_out_tip': {'key': 'noseLeftAlarOutTip', 'type': 'Coordinate'}, + 'nose_right_alar_out_tip': {'key': 'noseRightAlarOutTip', 'type': 'Coordinate'}, + 'upper_lip_top': {'key': 'upperLipTop', 'type': 'Coordinate'}, + 'upper_lip_bottom': {'key': 'upperLipBottom', 'type': 'Coordinate'}, + 'under_lip_top': {'key': 'underLipTop', 'type': 'Coordinate'}, + 'under_lip_bottom': {'key': 'underLipBottom', 'type': 'Coordinate'}, + } + + def __init__(self, *, pupil_left=None, pupil_right=None, nose_tip=None, mouth_left=None, mouth_right=None, eyebrow_left_outer=None, eyebrow_left_inner=None, eye_left_outer=None, eye_left_top=None, eye_left_bottom=None, eye_left_inner=None, eyebrow_right_inner=None, eyebrow_right_outer=None, eye_right_inner=None, eye_right_top=None, eye_right_bottom=None, eye_right_outer=None, nose_root_left=None, nose_root_right=None, nose_left_alar_top=None, nose_right_alar_top=None, nose_left_alar_out_tip=None, nose_right_alar_out_tip=None, upper_lip_top=None, upper_lip_bottom=None, under_lip_top=None, under_lip_bottom=None, **kwargs) -> None: + super(FaceLandmarks, self).__init__(**kwargs) + self.pupil_left = pupil_left + self.pupil_right = pupil_right + self.nose_tip = nose_tip + self.mouth_left = mouth_left + self.mouth_right = mouth_right + self.eyebrow_left_outer = eyebrow_left_outer + self.eyebrow_left_inner = eyebrow_left_inner + self.eye_left_outer = eye_left_outer + self.eye_left_top = eye_left_top + self.eye_left_bottom = eye_left_bottom + self.eye_left_inner = eye_left_inner + self.eyebrow_right_inner = eyebrow_right_inner + self.eyebrow_right_outer = eyebrow_right_outer + self.eye_right_inner = eye_right_inner + self.eye_right_top = eye_right_top + self.eye_right_bottom = eye_right_bottom + self.eye_right_outer = eye_right_outer + self.nose_root_left = nose_root_left + self.nose_root_right = nose_root_right + self.nose_left_alar_top = nose_left_alar_top + self.nose_right_alar_top = nose_right_alar_top + self.nose_left_alar_out_tip = nose_left_alar_out_tip + self.nose_right_alar_out_tip = nose_right_alar_out_tip + self.upper_lip_top = upper_lip_top + self.upper_lip_bottom = upper_lip_bottom + self.under_lip_top = under_lip_top + self.under_lip_bottom = under_lip_bottom diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list.py index 9ea18a585d45..2ca0b350d9b5 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list.py @@ -15,11 +15,13 @@ class FaceList(NameAndUserDataContract): """Face list object. + All required parameters must be populated in order to send to Azure. + :param name: User defined name, maximum length is 128. :type name: str :param user_data: User specified data. Length should not exceed 16KB. :type user_data: str - :param face_list_id: FaceListId of the target face list. + :param face_list_id: Required. FaceListId of the target face list. :type face_list_id: str :param persisted_faces: Persisted faces within the face list. :type persisted_faces: @@ -39,7 +41,7 @@ class FaceList(NameAndUserDataContract): 'persisted_faces': {'key': 'persistedFaces', 'type': '[PersistedFace]'}, } - def __init__(self, face_list_id, name=None, user_data=None, persisted_faces=None): - super(FaceList, self).__init__(name=name, user_data=user_data) - self.face_list_id = face_list_id - self.persisted_faces = persisted_faces + def __init__(self, **kwargs): + super(FaceList, self).__init__(**kwargs) + self.face_list_id = kwargs.get('face_list_id', None) + self.persisted_faces = kwargs.get('persisted_faces', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list_py3.py new file mode 100644 index 000000000000..b0c2a5587a31 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_list_py3.py @@ -0,0 +1,47 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract_py3 import NameAndUserDataContract + + +class FaceList(NameAndUserDataContract): + """Face list object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param face_list_id: Required. FaceListId of the target face list. + :type face_list_id: str + :param persisted_faces: Persisted faces within the face list. + :type persisted_faces: + list[~azure.cognitiveservices.vision.face.models.PersistedFace] + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'face_list_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'face_list_id': {'key': 'faceListId', 'type': 'str'}, + 'persisted_faces': {'key': 'persistedFaces', 'type': '[PersistedFace]'}, + } + + def __init__(self, *, face_list_id: str, name: str=None, user_data: str=None, persisted_faces=None, **kwargs) -> None: + super(FaceList, self).__init__(name=name, user_data=user_data, **kwargs) + self.face_list_id = face_list_id + self.persisted_faces = persisted_faces diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle.py index a61cfa6f1b09..025a99404fa8 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle.py @@ -15,15 +15,17 @@ class FaceRectangle(Model): """A rectangle within which a face can be found. - :param width: The width of the rectangle, in pixels. + All required parameters must be populated in order to send to Azure. + + :param width: Required. The width of the rectangle, in pixels. :type width: int - :param height: The height of the rectangle, in pixels. + :param height: Required. The height of the rectangle, in pixels. :type height: int - :param left: The distance from the left edge if the image to the left edge - of the rectangle, in pixels. + :param left: Required. The distance from the left edge if the image to the + left edge of the rectangle, in pixels. :type left: int - :param top: The distance from the top edge if the image to the top edge of - the rectangle, in pixels. + :param top: Required. The distance from the top edge if the image to the + top edge of the rectangle, in pixels. :type top: int """ @@ -41,9 +43,9 @@ class FaceRectangle(Model): 'top': {'key': 'top', 'type': 'int'}, } - def __init__(self, width, height, left, top): - super(FaceRectangle, self).__init__() - self.width = width - self.height = height - self.left = left - self.top = top + def __init__(self, **kwargs): + super(FaceRectangle, self).__init__(**kwargs) + self.width = kwargs.get('width', None) + self.height = kwargs.get('height', None) + self.left = kwargs.get('left', None) + self.top = kwargs.get('top', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle_py3.py new file mode 100644 index 000000000000..ff85626ad83f --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/face_rectangle_py3.py @@ -0,0 +1,51 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FaceRectangle(Model): + """A rectangle within which a face can be found. + + All required parameters must be populated in order to send to Azure. + + :param width: Required. The width of the rectangle, in pixels. + :type width: int + :param height: Required. The height of the rectangle, in pixels. + :type height: int + :param left: Required. The distance from the left edge if the image to the + left edge of the rectangle, in pixels. + :type left: int + :param top: Required. The distance from the top edge if the image to the + top edge of the rectangle, in pixels. + :type top: int + """ + + _validation = { + 'width': {'required': True}, + 'height': {'required': True}, + 'left': {'required': True}, + 'top': {'required': True}, + } + + _attribute_map = { + 'width': {'key': 'width', 'type': 'int'}, + 'height': {'key': 'height', 'type': 'int'}, + 'left': {'key': 'left', 'type': 'int'}, + 'top': {'key': 'top', 'type': 'int'}, + } + + def __init__(self, *, width: int, height: int, left: int, top: int, **kwargs) -> None: + super(FaceRectangle, self).__init__(**kwargs) + self.width = width + self.height = height + self.left = left + self.top = top diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair.py index 72e5b1240908..f030e5b75824 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair.py @@ -29,8 +29,8 @@ class FacialHair(Model): 'sideburns': {'key': 'sideburns', 'type': 'float'}, } - def __init__(self, moustache=None, beard=None, sideburns=None): - super(FacialHair, self).__init__() - self.moustache = moustache - self.beard = beard - self.sideburns = sideburns + def __init__(self, **kwargs): + super(FacialHair, self).__init__(**kwargs) + self.moustache = kwargs.get('moustache', None) + self.beard = kwargs.get('beard', None) + self.sideburns = kwargs.get('sideburns', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair_py3.py new file mode 100644 index 000000000000..261f55ed2b1b --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/facial_hair_py3.py @@ -0,0 +1,36 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacialHair(Model): + """Properties describing facial hair attributes. + + :param moustache: + :type moustache: float + :param beard: + :type beard: float + :param sideburns: + :type sideburns: float + """ + + _attribute_map = { + 'moustache': {'key': 'moustache', 'type': 'float'}, + 'beard': {'key': 'beard', 'type': 'float'}, + 'sideburns': {'key': 'sideburns', 'type': 'float'}, + } + + def __init__(self, *, moustache: float=None, beard: float=None, sideburns: float=None, **kwargs) -> None: + super(FacialHair, self).__init__(**kwargs) + self.moustache = moustache + self.beard = beard + self.sideburns = sideburns diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request.py index 11acb8bc2279..fb3fa5c2fdb4 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request.py @@ -15,18 +15,28 @@ class FindSimilarRequest(Model): """Request body for find similar operation. - :param face_id: FaceId of the query face. User needs to call Face - Detect - first to get a valid faceId. Note that this faceId is not persisted and - will expire 24 hours after the detection call + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the query face. User needs to call + Face - Detect first to get a valid faceId. Note that this faceId is not + persisted and will expire 24 hours after the detection call :type face_id: str :param face_list_id: An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter - faceListId and faceIds should not be provided at the same time + faceListId, largeFaceListId and faceIds should not be provided at the same + time。 :type face_list_id: str + :param large_face_list_id: An existing user-specified unique candidate + large face list, created in LargeFaceList - Create. Large face list + contains a set of persistedFaceIds which are persisted and will never + expire. Parameter faceListId, largeFaceListId and faceIds should not be + provided at the same time. + :type large_face_list_id: str :param face_ids: An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection - call. + call. The number of faceIds is limited to 1000. Parameter faceListId, + largeFaceListId and faceIds should not be provided at the same time. :type face_ids: list[str] :param max_num_of_candidates_returned: The number of top similar faces returned. The valid range is [1, 1000]. Default value: 20 . @@ -41,6 +51,7 @@ class FindSimilarRequest(Model): _validation = { 'face_id': {'required': True}, 'face_list_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_face_list_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, 'face_ids': {'max_items': 1000}, 'max_num_of_candidates_returned': {'maximum': 1000, 'minimum': 1}, } @@ -48,15 +59,17 @@ class FindSimilarRequest(Model): _attribute_map = { 'face_id': {'key': 'faceId', 'type': 'str'}, 'face_list_id': {'key': 'faceListId', 'type': 'str'}, + 'large_face_list_id': {'key': 'largeFaceListId', 'type': 'str'}, 'face_ids': {'key': 'faceIds', 'type': '[str]'}, 'max_num_of_candidates_returned': {'key': 'maxNumOfCandidatesReturned', 'type': 'int'}, 'mode': {'key': 'mode', 'type': 'FindSimilarMatchMode'}, } - def __init__(self, face_id, face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode="matchPerson"): - super(FindSimilarRequest, self).__init__() - self.face_id = face_id - self.face_list_id = face_list_id - self.face_ids = face_ids - self.max_num_of_candidates_returned = max_num_of_candidates_returned - self.mode = mode + def __init__(self, **kwargs): + super(FindSimilarRequest, self).__init__(**kwargs) + self.face_id = kwargs.get('face_id', None) + self.face_list_id = kwargs.get('face_list_id', None) + self.large_face_list_id = kwargs.get('large_face_list_id', None) + self.face_ids = kwargs.get('face_ids', None) + self.max_num_of_candidates_returned = kwargs.get('max_num_of_candidates_returned', 20) + self.mode = kwargs.get('mode', "matchPerson") diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request_py3.py new file mode 100644 index 000000000000..ea3cbc0c4295 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/find_similar_request_py3.py @@ -0,0 +1,75 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FindSimilarRequest(Model): + """Request body for find similar operation. + + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the query face. User needs to call + Face - Detect first to get a valid faceId. Note that this faceId is not + persisted and will expire 24 hours after the detection call + :type face_id: str + :param face_list_id: An existing user-specified unique candidate face + list, created in Face List - Create a Face List. Face list contains a set + of persistedFaceIds which are persisted and will never expire. Parameter + faceListId, largeFaceListId and faceIds should not be provided at the same + time。 + :type face_list_id: str + :param large_face_list_id: An existing user-specified unique candidate + large face list, created in LargeFaceList - Create. Large face list + contains a set of persistedFaceIds which are persisted and will never + expire. Parameter faceListId, largeFaceListId and faceIds should not be + provided at the same time. + :type large_face_list_id: str + :param face_ids: An array of candidate faceIds. All of them are created by + Face - Detect and the faceIds will expire 24 hours after the detection + call. The number of faceIds is limited to 1000. Parameter faceListId, + largeFaceListId and faceIds should not be provided at the same time. + :type face_ids: list[str] + :param max_num_of_candidates_returned: The number of top similar faces + returned. The valid range is [1, 1000]. Default value: 20 . + :type max_num_of_candidates_returned: int + :param mode: Similar face searching mode. It can be "matchPerson" or + "matchFace". Possible values include: 'matchPerson', 'matchFace'. Default + value: "matchPerson" . + :type mode: str or + ~azure.cognitiveservices.vision.face.models.FindSimilarMatchMode + """ + + _validation = { + 'face_id': {'required': True}, + 'face_list_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_face_list_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'face_ids': {'max_items': 1000}, + 'max_num_of_candidates_returned': {'maximum': 1000, 'minimum': 1}, + } + + _attribute_map = { + 'face_id': {'key': 'faceId', 'type': 'str'}, + 'face_list_id': {'key': 'faceListId', 'type': 'str'}, + 'large_face_list_id': {'key': 'largeFaceListId', 'type': 'str'}, + 'face_ids': {'key': 'faceIds', 'type': '[str]'}, + 'max_num_of_candidates_returned': {'key': 'maxNumOfCandidatesReturned', 'type': 'int'}, + 'mode': {'key': 'mode', 'type': 'FindSimilarMatchMode'}, + } + + def __init__(self, *, face_id: str, face_list_id: str=None, large_face_list_id: str=None, face_ids=None, max_num_of_candidates_returned: int=20, mode="matchPerson", **kwargs) -> None: + super(FindSimilarRequest, self).__init__(**kwargs) + self.face_id = face_id + self.face_list_id = face_list_id + self.large_face_list_id = large_face_list_id + self.face_ids = face_ids + self.max_num_of_candidates_returned = max_num_of_candidates_returned + self.mode = mode diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request.py index c5e483cea4f4..a7041836294d 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request.py @@ -15,8 +15,10 @@ class GroupRequest(Model): """Request body for group request. - :param face_ids: Array of candidate faceId created by Face - Detect. The - maximum is 1000 faces + All required parameters must be populated in order to send to Azure. + + :param face_ids: Required. Array of candidate faceId created by Face - + Detect. The maximum is 1000 faces :type face_ids: list[str] """ @@ -28,6 +30,6 @@ class GroupRequest(Model): 'face_ids': {'key': 'faceIds', 'type': '[str]'}, } - def __init__(self, face_ids): - super(GroupRequest, self).__init__() - self.face_ids = face_ids + def __init__(self, **kwargs): + super(GroupRequest, self).__init__(**kwargs) + self.face_ids = kwargs.get('face_ids', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request_py3.py new file mode 100644 index 000000000000..a30757a8d7c5 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_request_py3.py @@ -0,0 +1,35 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class GroupRequest(Model): + """Request body for group request. + + All required parameters must be populated in order to send to Azure. + + :param face_ids: Required. Array of candidate faceId created by Face - + Detect. The maximum is 1000 faces + :type face_ids: list[str] + """ + + _validation = { + 'face_ids': {'required': True, 'max_items': 1000}, + } + + _attribute_map = { + 'face_ids': {'key': 'faceIds', 'type': '[str]'}, + } + + def __init__(self, *, face_ids, **kwargs) -> None: + super(GroupRequest, self).__init__(**kwargs) + self.face_ids = face_ids diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result.py index 5902d1d3e8c5..7a5bdbb62e32 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result.py @@ -15,8 +15,10 @@ class GroupResult(Model): """An array of face groups based on face similarity. - :param groups: A partition of the original faces based on face similarity. - Groups are ranked by number of faces + All required parameters must be populated in order to send to Azure. + + :param groups: Required. A partition of the original faces based on face + similarity. Groups are ranked by number of faces :type groups: list[list[str]] :param messy_group: Face ids array of faces that cannot find any similar faces from original faces. @@ -32,7 +34,7 @@ class GroupResult(Model): 'messy_group': {'key': 'messyGroup', 'type': '[str]'}, } - def __init__(self, groups, messy_group=None): - super(GroupResult, self).__init__() - self.groups = groups - self.messy_group = messy_group + def __init__(self, **kwargs): + super(GroupResult, self).__init__(**kwargs) + self.groups = kwargs.get('groups', None) + self.messy_group = kwargs.get('messy_group', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result_py3.py new file mode 100644 index 000000000000..5eb92f3fa8f4 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/group_result_py3.py @@ -0,0 +1,40 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class GroupResult(Model): + """An array of face groups based on face similarity. + + All required parameters must be populated in order to send to Azure. + + :param groups: Required. A partition of the original faces based on face + similarity. Groups are ranked by number of faces + :type groups: list[list[str]] + :param messy_group: Face ids array of faces that cannot find any similar + faces from original faces. + :type messy_group: list[str] + """ + + _validation = { + 'groups': {'required': True}, + } + + _attribute_map = { + 'groups': {'key': 'groups', 'type': '[[str]]'}, + 'messy_group': {'key': 'messyGroup', 'type': '[str]'}, + } + + def __init__(self, *, groups, messy_group=None, **kwargs) -> None: + super(GroupResult, self).__init__(**kwargs) + self.groups = groups + self.messy_group = messy_group diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair.py index 58d37ae637ca..cb6fe7d530a1 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair.py @@ -33,8 +33,8 @@ class Hair(Model): 'hair_color': {'key': 'hairColor', 'type': '[HairColor]'}, } - def __init__(self, bald=None, invisible=None, hair_color=None): - super(Hair, self).__init__() - self.bald = bald - self.invisible = invisible - self.hair_color = hair_color + def __init__(self, **kwargs): + super(Hair, self).__init__(**kwargs) + self.bald = kwargs.get('bald', None) + self.invisible = kwargs.get('invisible', None) + self.hair_color = kwargs.get('hair_color', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color.py index 4093eef9e414..287ddbb6eca0 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color.py @@ -28,7 +28,7 @@ class HairColor(Model): 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, color=None, confidence=None): - super(HairColor, self).__init__() - self.color = color - self.confidence = confidence + def __init__(self, **kwargs): + super(HairColor, self).__init__(**kwargs) + self.color = kwargs.get('color', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color_py3.py new file mode 100644 index 000000000000..c520a106a3bc --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_color_py3.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class HairColor(Model): + """Hair color and associated confidence. + + :param color: Name of the hair color. Possible values include: 'unknown', + 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other' + :type color: str or + ~azure.cognitiveservices.vision.face.models.HairColorType + :param confidence: Confidence level of the color + :type confidence: float + """ + + _attribute_map = { + 'color': {'key': 'color', 'type': 'HairColorType'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, color=None, confidence: float=None, **kwargs) -> None: + super(HairColor, self).__init__(**kwargs) + self.color = color + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_py3.py new file mode 100644 index 000000000000..457a80fc7ad3 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/hair_py3.py @@ -0,0 +1,40 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Hair(Model): + """Properties describing hair attributes. + + :param bald: A number describing confidence level of whether the person is + bald. + :type bald: float + :param invisible: A boolean value describing whether the hair is visible + in the image. + :type invisible: bool + :param hair_color: An array of candidate colors and confidence level in + the presence of each. + :type hair_color: + list[~azure.cognitiveservices.vision.face.models.HairColor] + """ + + _attribute_map = { + 'bald': {'key': 'bald', 'type': 'float'}, + 'invisible': {'key': 'invisible', 'type': 'bool'}, + 'hair_color': {'key': 'hairColor', 'type': '[HairColor]'}, + } + + def __init__(self, *, bald: float=None, invisible: bool=None, hair_color=None, **kwargs) -> None: + super(Hair, self).__init__(**kwargs) + self.bald = bald + self.invisible = invisible + self.hair_color = hair_color diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose.py index 29f987351673..ddc42406f476 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose.py @@ -29,8 +29,8 @@ class HeadPose(Model): 'pitch': {'key': 'pitch', 'type': 'float'}, } - def __init__(self, roll=None, yaw=None, pitch=None): - super(HeadPose, self).__init__() - self.roll = roll - self.yaw = yaw - self.pitch = pitch + def __init__(self, **kwargs): + super(HeadPose, self).__init__(**kwargs) + self.roll = kwargs.get('roll', None) + self.yaw = kwargs.get('yaw', None) + self.pitch = kwargs.get('pitch', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose_py3.py new file mode 100644 index 000000000000..bad69304e32e --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/head_pose_py3.py @@ -0,0 +1,36 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class HeadPose(Model): + """Properties indicating head pose of the face. + + :param roll: + :type roll: float + :param yaw: + :type yaw: float + :param pitch: + :type pitch: float + """ + + _attribute_map = { + 'roll': {'key': 'roll', 'type': 'float'}, + 'yaw': {'key': 'yaw', 'type': 'float'}, + 'pitch': {'key': 'pitch', 'type': 'float'}, + } + + def __init__(self, *, roll: float=None, yaw: float=None, pitch: float=None, **kwargs) -> None: + super(HeadPose, self).__init__(**kwargs) + self.roll = roll + self.yaw = yaw + self.pitch = pitch diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate.py index baf6a7d41fd4..84588c7b1fed 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate.py @@ -15,11 +15,13 @@ class IdentifyCandidate(Model): """All possible faces that may qualify. - :param person_id: Id of candidate + All required parameters must be populated in order to send to Azure. + + :param person_id: Required. Id of candidate :type person_id: str - :param confidence: Confidence threshold of identification, used to judge - whether one face belong to one person. The range of confidenceThreshold is - [0, 1] (default specified by algorithm). + :param confidence: Required. Confidence threshold of identification, used + to judge whether one face belong to one person. The range of + confidenceThreshold is [0, 1] (default specified by algorithm). :type confidence: float """ @@ -33,7 +35,7 @@ class IdentifyCandidate(Model): 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, person_id, confidence): - super(IdentifyCandidate, self).__init__() - self.person_id = person_id - self.confidence = confidence + def __init__(self, **kwargs): + super(IdentifyCandidate, self).__init__(**kwargs) + self.person_id = kwargs.get('person_id', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate_py3.py new file mode 100644 index 000000000000..924a8bc33bf2 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_candidate_py3.py @@ -0,0 +1,41 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentifyCandidate(Model): + """All possible faces that may qualify. + + All required parameters must be populated in order to send to Azure. + + :param person_id: Required. Id of candidate + :type person_id: str + :param confidence: Required. Confidence threshold of identification, used + to judge whether one face belong to one person. The range of + confidenceThreshold is [0, 1] (default specified by algorithm). + :type confidence: float + """ + + _validation = { + 'person_id': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'person_id': {'key': 'personId', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, person_id: str, confidence: float, **kwargs) -> None: + super(IdentifyCandidate, self).__init__(**kwargs) + self.person_id = person_id + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request.py index 7c275a6140aa..5b7175b406e5 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request.py @@ -15,13 +15,21 @@ class IdentifyRequest(Model): """Request body for identify face operation. + All required parameters must be populated in order to send to Azure. + + :param face_ids: Required. Array of query faces faceIds, created by the + Face - Detect. Each of the faces are identified independently. The valid + number of faceIds is between [1, 10]. + :type face_ids: list[str] :param person_group_id: PersonGroupId of the target person group, created - by PersonGroups.Create + by PersonGroup - Create. Parameter personGroupId and largePersonGroupId + should not be provided at the same time. :type person_group_id: str - :param face_ids: Array of query faces faceIds, created by the Face - - Detect. Each of the faces are identified independently. The valid number - of faceIds is between [1, 10]. - :type face_ids: list[str] + :param large_person_group_id: LargePersonGroupId of the target large + person group, created by LargePersonGroup - Create. Parameter + personGroupId and largePersonGroupId should not be provided at the same + time. + :type large_person_group_id: str :param max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). Default value: 1 . @@ -33,21 +41,24 @@ class IdentifyRequest(Model): """ _validation = { - 'person_group_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, 'face_ids': {'required': True, 'max_items': 10}, + 'person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, 'max_num_of_candidates_returned': {'maximum': 5, 'minimum': 1}, } _attribute_map = { - 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, 'face_ids': {'key': 'faceIds', 'type': '[str]'}, + 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, 'max_num_of_candidates_returned': {'key': 'maxNumOfCandidatesReturned', 'type': 'int'}, 'confidence_threshold': {'key': 'confidenceThreshold', 'type': 'float'}, } - def __init__(self, person_group_id, face_ids, max_num_of_candidates_returned=1, confidence_threshold=None): - super(IdentifyRequest, self).__init__() - self.person_group_id = person_group_id - self.face_ids = face_ids - self.max_num_of_candidates_returned = max_num_of_candidates_returned - self.confidence_threshold = confidence_threshold + def __init__(self, **kwargs): + super(IdentifyRequest, self).__init__(**kwargs) + self.face_ids = kwargs.get('face_ids', None) + self.person_group_id = kwargs.get('person_group_id', None) + self.large_person_group_id = kwargs.get('large_person_group_id', None) + self.max_num_of_candidates_returned = kwargs.get('max_num_of_candidates_returned', 1) + self.confidence_threshold = kwargs.get('confidence_threshold', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request_py3.py new file mode 100644 index 000000000000..b9494964f853 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_request_py3.py @@ -0,0 +1,64 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentifyRequest(Model): + """Request body for identify face operation. + + All required parameters must be populated in order to send to Azure. + + :param face_ids: Required. Array of query faces faceIds, created by the + Face - Detect. Each of the faces are identified independently. The valid + number of faceIds is between [1, 10]. + :type face_ids: list[str] + :param person_group_id: PersonGroupId of the target person group, created + by PersonGroup - Create. Parameter personGroupId and largePersonGroupId + should not be provided at the same time. + :type person_group_id: str + :param large_person_group_id: LargePersonGroupId of the target large + person group, created by LargePersonGroup - Create. Parameter + personGroupId and largePersonGroupId should not be provided at the same + time. + :type large_person_group_id: str + :param max_num_of_candidates_returned: The range of + maxNumOfCandidatesReturned is between 1 and 5 (default is 1). Default + value: 1 . + :type max_num_of_candidates_returned: int + :param confidence_threshold: Confidence threshold of identification, used + to judge whether one face belong to one person. The range of + confidenceThreshold is [0, 1] (default specified by algorithm). + :type confidence_threshold: float + """ + + _validation = { + 'face_ids': {'required': True, 'max_items': 10}, + 'person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'max_num_of_candidates_returned': {'maximum': 5, 'minimum': 1}, + } + + _attribute_map = { + 'face_ids': {'key': 'faceIds', 'type': '[str]'}, + 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, + 'max_num_of_candidates_returned': {'key': 'maxNumOfCandidatesReturned', 'type': 'int'}, + 'confidence_threshold': {'key': 'confidenceThreshold', 'type': 'float'}, + } + + def __init__(self, *, face_ids, person_group_id: str=None, large_person_group_id: str=None, max_num_of_candidates_returned: int=1, confidence_threshold: float=None, **kwargs) -> None: + super(IdentifyRequest, self).__init__(**kwargs) + self.face_ids = face_ids + self.person_group_id = person_group_id + self.large_person_group_id = large_person_group_id + self.max_num_of_candidates_returned = max_num_of_candidates_returned + self.confidence_threshold = confidence_threshold diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result.py index 1642dcb1b252..4a371afc92fd 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result.py @@ -15,10 +15,12 @@ class IdentifyResult(Model): """Response body for identify face operation. - :param face_id: FaceId of the query face + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the query face :type face_id: str - :param candidates: Identified person candidates for that face (ranked by - confidence). Array size should be no larger than input + :param candidates: Required. 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. :type candidates: @@ -35,7 +37,7 @@ class IdentifyResult(Model): 'candidates': {'key': 'candidates', 'type': '[IdentifyCandidate]'}, } - def __init__(self, face_id, candidates): - super(IdentifyResult, self).__init__() - self.face_id = face_id - self.candidates = candidates + def __init__(self, **kwargs): + super(IdentifyResult, self).__init__(**kwargs) + self.face_id = kwargs.get('face_id', None) + self.candidates = kwargs.get('candidates', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result_py3.py new file mode 100644 index 000000000000..d629c03201f7 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/identify_result_py3.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentifyResult(Model): + """Response body for identify face operation. + + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the query face + :type face_id: str + :param candidates: Required. 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. + :type candidates: + list[~azure.cognitiveservices.vision.face.models.IdentifyCandidate] + """ + + _validation = { + 'face_id': {'required': True}, + 'candidates': {'required': True}, + } + + _attribute_map = { + 'face_id': {'key': 'faceId', 'type': 'str'}, + 'candidates': {'key': 'candidates', 'type': '[IdentifyCandidate]'}, + } + + def __init__(self, *, face_id: str, candidates, **kwargs) -> None: + super(IdentifyResult, self).__init__(**kwargs) + self.face_id = face_id + self.candidates = candidates diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url.py index 05f4dab7f611..25106793ad9c 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url.py @@ -15,7 +15,9 @@ class ImageUrl(Model): """ImageUrl. - :param url: + All required parameters must be populated in order to send to Azure. + + :param url: Required. Publicly reachable URL of an image :type url: str """ @@ -27,6 +29,6 @@ class ImageUrl(Model): 'url': {'key': 'url', 'type': 'str'}, } - def __init__(self, url): - super(ImageUrl, self).__init__() - self.url = url + def __init__(self, **kwargs): + super(ImageUrl, self).__init__(**kwargs) + self.url = kwargs.get('url', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url_py3.py new file mode 100644 index 000000000000..3e00709f804d --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/image_url_py3.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ImageUrl(Model): + """ImageUrl. + + All required parameters must be populated in order to send to Azure. + + :param url: Required. Publicly reachable URL of an image + :type url: str + """ + + _validation = { + 'url': {'required': True}, + } + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__(self, *, url: str, **kwargs) -> None: + super(ImageUrl, self).__init__(**kwargs) + self.url = url diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list.py new file mode 100644 index 000000000000..f6a6d5525543 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract import NameAndUserDataContract + + +class LargeFaceList(NameAndUserDataContract): + """Large face list object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param large_face_list_id: Required. LargeFaceListId of the target large + face list. + :type large_face_list_id: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'large_face_list_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'large_face_list_id': {'key': 'largeFaceListId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LargeFaceList, self).__init__(**kwargs) + self.large_face_list_id = kwargs.get('large_face_list_id', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list_py3.py new file mode 100644 index 000000000000..4a05214af516 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_face_list_py3.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract_py3 import NameAndUserDataContract + + +class LargeFaceList(NameAndUserDataContract): + """Large face list object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param large_face_list_id: Required. LargeFaceListId of the target large + face list. + :type large_face_list_id: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'large_face_list_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'large_face_list_id': {'key': 'largeFaceListId', 'type': 'str'}, + } + + def __init__(self, *, large_face_list_id: str, name: str=None, user_data: str=None, **kwargs) -> None: + super(LargeFaceList, self).__init__(name=name, user_data=user_data, **kwargs) + self.large_face_list_id = large_face_list_id diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group.py new file mode 100644 index 000000000000..f65f661b5057 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract import NameAndUserDataContract + + +class LargePersonGroup(NameAndUserDataContract): + """Large person group object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param large_person_group_id: Required. LargePersonGroupId of the target + large person groups + :type large_person_group_id: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'large_person_group_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LargePersonGroup, self).__init__(**kwargs) + self.large_person_group_id = kwargs.get('large_person_group_id', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group_py3.py new file mode 100644 index 000000000000..f28979ee5cfe --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/large_person_group_py3.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract_py3 import NameAndUserDataContract + + +class LargePersonGroup(NameAndUserDataContract): + """Large person group object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param large_person_group_id: Required. LargePersonGroupId of the target + large person groups + :type large_person_group_id: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'large_person_group_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, + } + + def __init__(self, *, large_person_group_id: str, name: str=None, user_data: str=None, **kwargs) -> None: + super(LargePersonGroup, self).__init__(name=name, user_data=user_data, **kwargs) + self.large_person_group_id = large_person_group_id diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup.py index 75da48f1bdc6..bc02e44ce561 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup.py @@ -28,7 +28,7 @@ class Makeup(Model): 'lip_makeup': {'key': 'lipMakeup', 'type': 'bool'}, } - def __init__(self, eye_makeup=None, lip_makeup=None): - super(Makeup, self).__init__() - self.eye_makeup = eye_makeup - self.lip_makeup = lip_makeup + def __init__(self, **kwargs): + super(Makeup, self).__init__(**kwargs) + self.eye_makeup = kwargs.get('eye_makeup', None) + self.lip_makeup = kwargs.get('lip_makeup', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup_py3.py new file mode 100644 index 000000000000..777f7bf25d19 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/makeup_py3.py @@ -0,0 +1,34 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Makeup(Model): + """Properties describing present makeups on a given face. + + :param eye_makeup: A boolean value describing whether eye makeup is + present on a face. + :type eye_makeup: bool + :param lip_makeup: A boolean value describing whether lip makeup is + present on a face. + :type lip_makeup: bool + """ + + _attribute_map = { + 'eye_makeup': {'key': 'eyeMakeup', 'type': 'bool'}, + 'lip_makeup': {'key': 'lipMakeup', 'type': 'bool'}, + } + + def __init__(self, *, eye_makeup: bool=None, lip_makeup: bool=None, **kwargs) -> None: + super(Makeup, self).__init__(**kwargs) + self.eye_makeup = eye_makeup + self.lip_makeup = lip_makeup diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract.py index 0b329f080cdd..ef1f79d83d24 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract.py @@ -14,7 +14,7 @@ class NameAndUserDataContract(Model): """A combination of user defined name and user specified data for the person, - personGroup, and faceList. + largePersonGroup/personGroup, and largeFaceList/faceList. :param name: User defined name, maximum length is 128. :type name: str @@ -32,7 +32,7 @@ class NameAndUserDataContract(Model): 'user_data': {'key': 'userData', 'type': 'str'}, } - def __init__(self, name=None, user_data=None): - super(NameAndUserDataContract, self).__init__() - self.name = name - self.user_data = user_data + def __init__(self, **kwargs): + super(NameAndUserDataContract, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.user_data = kwargs.get('user_data', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract_py3.py new file mode 100644 index 000000000000..29c856742584 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/name_and_user_data_contract_py3.py @@ -0,0 +1,38 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NameAndUserDataContract(Model): + """A combination of user defined name and user specified data for the person, + largePersonGroup/personGroup, and largeFaceList/faceList. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + } + + def __init__(self, *, name: str=None, user_data: str=None, **kwargs) -> None: + super(NameAndUserDataContract, self).__init__(**kwargs) + self.name = name + self.user_data = user_data diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise.py index 1d1a517e1aa9..565291f5b46d 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise.py @@ -31,7 +31,7 @@ class Noise(Model): 'value': {'key': 'value', 'type': 'float'}, } - def __init__(self, noise_level=None, value=None): - super(Noise, self).__init__() - self.noise_level = noise_level - self.value = value + def __init__(self, **kwargs): + super(Noise, self).__init__(**kwargs) + self.noise_level = kwargs.get('noise_level', None) + self.value = kwargs.get('value', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise_py3.py new file mode 100644 index 000000000000..f5445d995eda --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/noise_py3.py @@ -0,0 +1,37 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Noise(Model): + """Properties describing noise level of the image. + + :param noise_level: An enum value indicating level of noise. Possible + values include: 'Low', 'Medium', 'High' + :type noise_level: str or + ~azure.cognitiveservices.vision.face.models.NoiseLevel + :param value: 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. + :type value: float + """ + + _attribute_map = { + 'noise_level': {'key': 'noiseLevel', 'type': 'NoiseLevel'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, noise_level=None, value: float=None, **kwargs) -> None: + super(Noise, self).__init__(**kwargs) + self.noise_level = noise_level + self.value = value diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion.py index 3edcc3f80f18..c185869fb68d 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion.py @@ -31,8 +31,8 @@ class Occlusion(Model): 'mouth_occluded': {'key': 'mouthOccluded', 'type': 'bool'}, } - def __init__(self, forehead_occluded=None, eye_occluded=None, mouth_occluded=None): - super(Occlusion, self).__init__() - self.forehead_occluded = forehead_occluded - self.eye_occluded = eye_occluded - self.mouth_occluded = mouth_occluded + def __init__(self, **kwargs): + super(Occlusion, self).__init__(**kwargs) + self.forehead_occluded = kwargs.get('forehead_occluded', None) + self.eye_occluded = kwargs.get('eye_occluded', None) + self.mouth_occluded = kwargs.get('mouth_occluded', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion_py3.py new file mode 100644 index 000000000000..fd3cfed50f6a --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/occlusion_py3.py @@ -0,0 +1,38 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Occlusion(Model): + """Properties describing occlusions on a given face. + + :param forehead_occluded: A boolean value indicating whether forehead is + occluded. + :type forehead_occluded: bool + :param eye_occluded: A boolean value indicating whether eyes are occluded. + :type eye_occluded: bool + :param mouth_occluded: A boolean value indicating whether the mouth is + occluded. + :type mouth_occluded: bool + """ + + _attribute_map = { + 'forehead_occluded': {'key': 'foreheadOccluded', 'type': 'bool'}, + 'eye_occluded': {'key': 'eyeOccluded', 'type': 'bool'}, + 'mouth_occluded': {'key': 'mouthOccluded', 'type': 'bool'}, + } + + def __init__(self, *, forehead_occluded: bool=None, eye_occluded: bool=None, mouth_occluded: bool=None, **kwargs) -> None: + super(Occlusion, self).__init__(**kwargs) + self.forehead_occluded = forehead_occluded + self.eye_occluded = eye_occluded + self.mouth_occluded = mouth_occluded diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face.py index c1c31ef1c035..e8a1f236eaa1 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face.py @@ -15,9 +15,12 @@ class PersistedFace(Model): """PersonFace object. - :param persisted_face_id: The persistedFaceId of the target face, which is - persisted and will not expire. Different from faceId created by Face - - Detect and will expire in 24 hours after the detection call. + All required parameters must be populated in order to send to Azure. + + :param persisted_face_id: Required. The persistedFaceId of the target + face, which is persisted and will not expire. Different from faceId + created by Face - Detect and will expire in 24 hours after the detection + call. :type persisted_face_id: str :param user_data: User-provided data attached to the face. The size limit is 1KB. @@ -34,7 +37,7 @@ class PersistedFace(Model): 'user_data': {'key': 'userData', 'type': 'str'}, } - def __init__(self, persisted_face_id, user_data=None): - super(PersistedFace, self).__init__() - self.persisted_face_id = persisted_face_id - self.user_data = user_data + def __init__(self, **kwargs): + super(PersistedFace, self).__init__(**kwargs) + self.persisted_face_id = kwargs.get('persisted_face_id', None) + self.user_data = kwargs.get('user_data', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face_py3.py new file mode 100644 index 000000000000..f26dedad729c --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/persisted_face_py3.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PersistedFace(Model): + """PersonFace object. + + All required parameters must be populated in order to send to Azure. + + :param persisted_face_id: Required. The persistedFaceId of the target + face, which is persisted and will not expire. Different from faceId + created by Face - Detect and will expire in 24 hours after the detection + call. + :type persisted_face_id: str + :param user_data: User-provided data attached to the face. The size limit + is 1KB. + :type user_data: str + """ + + _validation = { + 'persisted_face_id': {'required': True}, + 'user_data': {'max_length': 1024}, + } + + _attribute_map = { + 'persisted_face_id': {'key': 'persistedFaceId', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + } + + def __init__(self, *, persisted_face_id: str, user_data: str=None, **kwargs) -> None: + super(PersistedFace, self).__init__(**kwargs) + self.persisted_face_id = persisted_face_id + self.user_data = user_data diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person.py index 5e22ffcec204..3e87905b2ded 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person.py @@ -15,11 +15,13 @@ class Person(NameAndUserDataContract): """Person object. + All required parameters must be populated in order to send to Azure. + :param name: User defined name, maximum length is 128. :type name: str :param user_data: User specified data. Length should not exceed 16KB. :type user_data: str - :param person_id: PersonId of the target face list. + :param person_id: Required. PersonId of the target face list. :type person_id: str :param persisted_face_ids: PersistedFaceIds of registered faces in the person. These persistedFaceIds are returned from Person - Add a Person @@ -40,7 +42,7 @@ class Person(NameAndUserDataContract): 'persisted_face_ids': {'key': 'persistedFaceIds', 'type': '[str]'}, } - def __init__(self, person_id, name=None, user_data=None, persisted_face_ids=None): - super(Person, self).__init__(name=name, user_data=user_data) - self.person_id = person_id - self.persisted_face_ids = persisted_face_ids + def __init__(self, **kwargs): + super(Person, self).__init__(**kwargs) + self.person_id = kwargs.get('person_id', None) + self.persisted_face_ids = kwargs.get('persisted_face_ids', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group.py index 8fdfebc1c92c..9e4eab234771 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group.py @@ -15,11 +15,14 @@ class PersonGroup(NameAndUserDataContract): """Person group object. + All required parameters must be populated in order to send to Azure. + :param name: User defined name, maximum length is 128. :type name: str :param user_data: User specified data. Length should not exceed 16KB. :type user_data: str - :param person_group_id: PersonGroupId of the existing person groups. + :param person_group_id: Required. PersonGroupId of the target person + group. :type person_group_id: str """ @@ -35,6 +38,6 @@ class PersonGroup(NameAndUserDataContract): 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, } - def __init__(self, person_group_id, name=None, user_data=None): - super(PersonGroup, self).__init__(name=name, user_data=user_data) - self.person_group_id = person_group_id + def __init__(self, **kwargs): + super(PersonGroup, self).__init__(**kwargs) + self.person_group_id = kwargs.get('person_group_id', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group_py3.py new file mode 100644 index 000000000000..c1fc341ed83b --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_group_py3.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract_py3 import NameAndUserDataContract + + +class PersonGroup(NameAndUserDataContract): + """Person group object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param person_group_id: Required. PersonGroupId of the target person + group. + :type person_group_id: str + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'person_group_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, + } + + def __init__(self, *, person_group_id: str, name: str=None, user_data: str=None, **kwargs) -> None: + super(PersonGroup, self).__init__(name=name, user_data=user_data, **kwargs) + self.person_group_id = person_group_id diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_py3.py new file mode 100644 index 000000000000..230f8afd82c5 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/person_py3.py @@ -0,0 +1,48 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .name_and_user_data_contract_py3 import NameAndUserDataContract + + +class Person(NameAndUserDataContract): + """Person object. + + All required parameters must be populated in order to send to Azure. + + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param person_id: Required. PersonId of the target face list. + :type person_id: str + :param persisted_face_ids: PersistedFaceIds of registered faces in the + person. These persistedFaceIds are returned from Person - Add a Person + Face, and will not expire. + :type persisted_face_ids: list[str] + """ + + _validation = { + 'name': {'max_length': 128}, + 'user_data': {'max_length': 16384}, + 'person_id': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'user_data': {'key': 'userData', 'type': 'str'}, + 'person_id': {'key': 'personId', 'type': 'str'}, + 'persisted_face_ids': {'key': 'persistedFaceIds', 'type': '[str]'}, + } + + def __init__(self, *, person_id: str, name: str=None, user_data: str=None, persisted_face_ids=None, **kwargs) -> None: + super(Person, self).__init__(name=name, user_data=user_data, **kwargs) + self.person_id = person_id + self.persisted_face_ids = persisted_face_ids diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face.py index 09c8a3b6912d..59006700234b 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face.py @@ -15,6 +15,8 @@ class SimilarFace(Model): """Response body for find similar face operation. + All required parameters must be populated in order to send to Azure. + :param face_id: FaceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire 24 hours after the detection call :type face_id: str @@ -22,8 +24,8 @@ class SimilarFace(Model): faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response :type persisted_face_id: str - :param confidence: Similarity confidence of the candidate face. The higher - confidence, the more similar. Range between [0,1]. + :param confidence: Required. Similarity confidence of the candidate face. + The higher confidence, the more similar. Range between [0,1]. :type confidence: float """ @@ -37,8 +39,8 @@ class SimilarFace(Model): 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, confidence, face_id=None, persisted_face_id=None): - super(SimilarFace, self).__init__() - self.face_id = face_id - self.persisted_face_id = persisted_face_id - self.confidence = confidence + def __init__(self, **kwargs): + super(SimilarFace, self).__init__(**kwargs) + self.face_id = kwargs.get('face_id', None) + self.persisted_face_id = kwargs.get('persisted_face_id', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face_py3.py new file mode 100644 index 000000000000..8d464fb315d5 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/similar_face_py3.py @@ -0,0 +1,46 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SimilarFace(Model): + """Response body for find similar face operation. + + All required parameters must be populated in order to send to Azure. + + :param face_id: FaceId of candidate face when find by faceIds. faceId is + created by Face - Detect and will expire 24 hours after the detection call + :type face_id: str + :param persisted_face_id: PersistedFaceId of candidate face when find by + faceListId. persistedFaceId in face list is persisted and will not expire. + As showed in below response + :type persisted_face_id: str + :param confidence: Required. Similarity confidence of the candidate face. + The higher confidence, the more similar. Range between [0,1]. + :type confidence: float + """ + + _validation = { + 'confidence': {'required': True}, + } + + _attribute_map = { + 'face_id': {'key': 'faceId', 'type': 'str'}, + 'persisted_face_id': {'key': 'persistedFaceId', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, confidence: float, face_id: str=None, persisted_face_id: str=None, **kwargs) -> None: + super(SimilarFace, self).__init__(**kwargs) + self.face_id = face_id + self.persisted_face_id = persisted_face_id + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status.py index eb5255c1d053..718da91dc34b 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status.py @@ -15,20 +15,31 @@ class TrainingStatus(Model): """Training status object. - :param status: Training status: notstarted, running, succeeded, failed. If - the training process is waiting to perform, the status is notstarted. If - the training is ongoing, the status is running. Status succeed means this - person group is ready for Face - Identify. Status failed is often caused - by no person or no persisted face exist in the person group. Possible - values include: 'nonstarted', 'running', 'succeeded', 'failed' + All required parameters must be populated in order to send to Azure. + + :param status: Required. Training status: notstarted, running, succeeded, + failed. If the training process is waiting to perform, the status is + notstarted. If the training is ongoing, the status is running. Status + succeed means this person group or large person group is ready for Face - + Identify, or this large face list is ready for Face - Find Similar. Status + failed is often caused by no person or no persisted face exist in the + person group or large person group, or no persisted face exist in the + large face list. Possible values include: 'nonstarted', 'running', + 'succeeded', 'failed' :type status: str or ~azure.cognitiveservices.vision.face.models.TrainingStatusType - :param created: A combined UTC date and time string that describes person - group created time. + :param created: Required. A combined UTC date and time string that + describes the created time of the person group, large person group or + large face list. :type created: datetime - :param last_action: Person group last modify time in the UTC, could be - null value when the person group is not successfully trained. + :param last_action: 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. :type last_action: datetime + :param last_successful_training: 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. + :type last_successful_training: datetime :param message: Show failure message when training failed (omitted when training succeed). :type message: str @@ -43,12 +54,14 @@ class TrainingStatus(Model): 'status': {'key': 'status', 'type': 'TrainingStatusType'}, 'created': {'key': 'createdDateTime', 'type': 'iso-8601'}, 'last_action': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'last_successful_training': {'key': 'lastSuccessfulTrainingDateTime', 'type': 'iso-8601'}, 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status, created, last_action=None, message=None): - super(TrainingStatus, self).__init__() - self.status = status - self.created = created - self.last_action = last_action - self.message = message + def __init__(self, **kwargs): + super(TrainingStatus, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.created = kwargs.get('created', None) + self.last_action = kwargs.get('last_action', None) + self.last_successful_training = kwargs.get('last_successful_training', None) + self.message = kwargs.get('message', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status_py3.py new file mode 100644 index 000000000000..50857f65cddb --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/training_status_py3.py @@ -0,0 +1,67 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TrainingStatus(Model): + """Training status object. + + All required parameters must be populated in order to send to Azure. + + :param status: Required. Training status: notstarted, running, succeeded, + failed. If the training process is waiting to perform, the status is + notstarted. If the training is ongoing, the status is running. Status + succeed means this person group or large person group is ready for Face - + Identify, or this large face list is ready for Face - Find Similar. Status + failed is often caused by no person or no persisted face exist in the + person group or large person group, or no persisted face exist in the + large face list. Possible values include: 'nonstarted', 'running', + 'succeeded', 'failed' + :type status: str or + ~azure.cognitiveservices.vision.face.models.TrainingStatusType + :param created: Required. A combined UTC date and time string that + describes the created time of the person group, large person group or + large face list. + :type created: datetime + :param last_action: 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. + :type last_action: datetime + :param last_successful_training: 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. + :type last_successful_training: datetime + :param message: Show failure message when training failed (omitted when + training succeed). + :type message: str + """ + + _validation = { + 'status': {'required': True}, + 'created': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'TrainingStatusType'}, + 'created': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_action': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'last_successful_training': {'key': 'lastSuccessfulTrainingDateTime', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, status, created, last_action=None, last_successful_training=None, message: str=None, **kwargs) -> None: + super(TrainingStatus, self).__init__(**kwargs) + self.status = status + self.created = created + self.last_action = last_action + self.last_successful_training = last_successful_training + self.message = message diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request.py new file mode 100644 index 000000000000..d2df86ba2b30 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request.py @@ -0,0 +1,33 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class UpdateFaceRequest(Model): + """Request to update face data. + + :param user_data: User-provided data attached to the face. The size limit + is 1KB. + :type user_data: str + """ + + _validation = { + 'user_data': {'max_length': 1024}, + } + + _attribute_map = { + 'user_data': {'key': 'userData', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(UpdateFaceRequest, self).__init__(**kwargs) + self.user_data = kwargs.get('user_data', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_person_face_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request_py3.py similarity index 81% rename from azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_person_face_request.py rename to azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request_py3.py index 6dc2950e7b81..2610f03251cd 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_person_face_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/update_face_request_py3.py @@ -12,8 +12,8 @@ from msrest.serialization import Model -class UpdatePersonFaceRequest(Model): - """Request to update person face data. +class UpdateFaceRequest(Model): + """Request to update face data. :param user_data: User-provided data attached to the face. The size limit is 1KB. @@ -28,6 +28,6 @@ class UpdatePersonFaceRequest(Model): 'user_data': {'key': 'userData', 'type': 'str'}, } - def __init__(self, user_data=None): - super(UpdatePersonFaceRequest, self).__init__() + def __init__(self, *, user_data: str=None, **kwargs) -> None: + super(UpdateFaceRequest, self).__init__(**kwargs) self.user_data = user_data diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request.py index 56341d56795a..9c22d1921f50 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request.py @@ -13,11 +13,15 @@ class VerifyFaceToFaceRequest(Model): - """Request body for verify operation. + """Request body for face to face verification. - :param face_id1: FaceId of the first face, comes from Face - Detect + All required parameters must be populated in order to send to Azure. + + :param face_id1: Required. FaceId of the first face, comes from Face - + Detect :type face_id1: str - :param face_id2: FaceId of the second face, comes from Face - Detect + :param face_id2: Required. FaceId of the second face, comes from Face - + Detect :type face_id2: str """ @@ -31,7 +35,7 @@ class VerifyFaceToFaceRequest(Model): 'face_id2': {'key': 'faceId2', 'type': 'str'}, } - def __init__(self, face_id1, face_id2): - super(VerifyFaceToFaceRequest, self).__init__() - self.face_id1 = face_id1 - self.face_id2 = face_id2 + def __init__(self, **kwargs): + super(VerifyFaceToFaceRequest, self).__init__(**kwargs) + self.face_id1 = kwargs.get('face_id1', None) + self.face_id2 = kwargs.get('face_id2', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request_py3.py new file mode 100644 index 000000000000..9c5f2f347255 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_face_request_py3.py @@ -0,0 +1,41 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class VerifyFaceToFaceRequest(Model): + """Request body for face to face verification. + + All required parameters must be populated in order to send to Azure. + + :param face_id1: Required. FaceId of the first face, comes from Face - + Detect + :type face_id1: str + :param face_id2: Required. FaceId of the second face, comes from Face - + Detect + :type face_id2: str + """ + + _validation = { + 'face_id1': {'required': True}, + 'face_id2': {'required': True}, + } + + _attribute_map = { + 'face_id1': {'key': 'faceId1', 'type': 'str'}, + 'face_id2': {'key': 'faceId2', 'type': 'str'}, + } + + def __init__(self, *, face_id1: str, face_id2: str, **kwargs) -> None: + super(VerifyFaceToFaceRequest, self).__init__(**kwargs) + self.face_id1 = face_id1 + self.face_id2 = face_id2 diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request.py index 62fb45530250..91169e15391e 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request.py @@ -13,33 +13,45 @@ class VerifyFaceToPersonRequest(Model): - """Request body for verify operation. + """Request body for face to person verification. - :param face_id: FaceId the face, comes from Face - Detect + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the face, comes from Face - Detect :type face_id: str :param person_group_id: Using existing personGroupId and personId for fast - loading a specified person. personGroupId is created in Person - Groups.Create. + loading a specified person. personGroupId is created in PersonGroup - + Create. Parameter personGroupId and largePersonGroupId should not be + provided at the same time. :type person_group_id: str - :param person_id: Specify a certain person in a person group. personId is - created in Persons.Create. + :param large_person_group_id: Using existing largePersonGroupId and + personId for fast loading a specified person. largePersonGroupId is + created in LargePersonGroup - Create. Parameter personGroupId and + largePersonGroupId should not be provided at the same time. + :type large_person_group_id: str + :param person_id: Required. Specify a certain person in a person group or + a large person group. personId is created in PersonGroup Person - Create + or LargePersonGroup Person - Create. :type person_id: str """ _validation = { 'face_id': {'required': True}, - 'person_group_id': {'required': True, 'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, 'person_id': {'required': True}, } _attribute_map = { 'face_id': {'key': 'faceId', 'type': 'str'}, 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, 'person_id': {'key': 'personId', 'type': 'str'}, } - def __init__(self, face_id, person_group_id, person_id): - super(VerifyFaceToPersonRequest, self).__init__() - self.face_id = face_id - self.person_group_id = person_group_id - self.person_id = person_id + def __init__(self, **kwargs): + super(VerifyFaceToPersonRequest, self).__init__(**kwargs) + self.face_id = kwargs.get('face_id', None) + self.person_group_id = kwargs.get('person_group_id', None) + self.large_person_group_id = kwargs.get('large_person_group_id', None) + self.person_id = kwargs.get('person_id', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request_py3.py new file mode 100644 index 000000000000..b5c7633d2c3a --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_face_to_person_request_py3.py @@ -0,0 +1,57 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class VerifyFaceToPersonRequest(Model): + """Request body for face to person verification. + + All required parameters must be populated in order to send to Azure. + + :param face_id: Required. FaceId of the face, comes from Face - Detect + :type face_id: str + :param person_group_id: Using existing personGroupId and personId for fast + loading a specified person. personGroupId is created in PersonGroup - + Create. Parameter personGroupId and largePersonGroupId should not be + provided at the same time. + :type person_group_id: str + :param large_person_group_id: Using existing largePersonGroupId and + personId for fast loading a specified person. largePersonGroupId is + created in LargePersonGroup - Create. Parameter personGroupId and + largePersonGroupId should not be provided at the same time. + :type large_person_group_id: str + :param person_id: Required. Specify a certain person in a person group or + a large person group. personId is created in PersonGroup Person - Create + or LargePersonGroup Person - Create. + :type person_id: str + """ + + _validation = { + 'face_id': {'required': True}, + 'person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'large_person_group_id': {'max_length': 64, 'pattern': r'^[a-z0-9-_]+$'}, + 'person_id': {'required': True}, + } + + _attribute_map = { + 'face_id': {'key': 'faceId', 'type': 'str'}, + 'person_group_id': {'key': 'personGroupId', 'type': 'str'}, + 'large_person_group_id': {'key': 'largePersonGroupId', 'type': 'str'}, + 'person_id': {'key': 'personId', 'type': 'str'}, + } + + def __init__(self, *, face_id: str, person_id: str, person_group_id: str=None, large_person_group_id: str=None, **kwargs) -> None: + super(VerifyFaceToPersonRequest, self).__init__(**kwargs) + self.face_id = face_id + self.person_group_id = person_group_id + self.large_person_group_id = large_person_group_id + self.person_id = person_id diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result.py index 5c748b1d5232..1d9fd6649696 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result.py @@ -15,14 +15,17 @@ class VerifyResult(Model): """Result of the verify operation. - :param is_identical: True if the two faces belong to the same person or - the face belongs to the person, otherwise false. + All required parameters must be populated in order to send to Azure. + + :param is_identical: Required. True if the two faces belong to the same + person or the face belongs to the person, otherwise false. :type is_identical: bool - :param confidence: 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 "isIdentical" and fine-tune the result on their own data. + :param confidence: Required. 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 "isIdentical" and fine-tune the result on their + own data. :type confidence: float """ @@ -36,7 +39,7 @@ class VerifyResult(Model): 'confidence': {'key': 'confidence', 'type': 'float'}, } - def __init__(self, is_identical, confidence): - super(VerifyResult, self).__init__() - self.is_identical = is_identical - self.confidence = confidence + def __init__(self, **kwargs): + super(VerifyResult, self).__init__(**kwargs) + self.is_identical = kwargs.get('is_identical', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result_py3.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result_py3.py new file mode 100644 index 000000000000..9e43db6908a8 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/models/verify_result_py3.py @@ -0,0 +1,45 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class VerifyResult(Model): + """Result of the verify operation. + + All required parameters must be populated in order to send to Azure. + + :param is_identical: Required. True if the two faces belong to the same + person or the face belongs to the person, otherwise false. + :type is_identical: bool + :param confidence: Required. 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 "isIdentical" and fine-tune the result on their + own data. + :type confidence: float + """ + + _validation = { + 'is_identical': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'is_identical': {'key': 'isIdentical', 'type': 'bool'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, is_identical: bool, confidence: float, **kwargs) -> None: + super(VerifyResult, self).__init__(**kwargs) + self.is_identical = is_identical + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/__init__.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/__init__.py index 76f00717fdfd..2e9a921167c3 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/__init__.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/__init__.py @@ -13,10 +13,16 @@ from .person_group_person_operations import PersonGroupPersonOperations from .person_group_operations import PersonGroupOperations from .face_list_operations import FaceListOperations +from .large_person_group_person_operations import LargePersonGroupPersonOperations +from .large_person_group_operations import LargePersonGroupOperations +from .large_face_list_operations import LargeFaceListOperations __all__ = [ 'FaceOperations', 'PersonGroupPersonOperations', 'PersonGroupOperations', 'FaceListOperations', + 'LargePersonGroupPersonOperations', + 'LargePersonGroupOperations', + 'LargeFaceListOperations', ] diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_list_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_list_operations.py index 0b517a64a848..83c7165e7625 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_list_operations.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_list_operations.py @@ -57,9 +57,9 @@ def create( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/facelists/{faceListId}' + url = self.create.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -77,9 +77,8 @@ def create( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -87,6 +86,7 @@ def create( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + create.metadata = {'url': '/facelists/{faceListId}'} def get( self, face_list_id, custom_headers=None, raw=False, **operation_config): @@ -106,9 +106,9 @@ def get( :class:`APIErrorException` """ # Construct URL - url = '/facelists/{faceListId}' + url = self.get.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -118,13 +118,13 @@ def get( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -139,6 +139,7 @@ def get( return client_raw_response return deserialized + get.metadata = {'url': '/facelists/{faceListId}'} def update( self, face_list_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): @@ -163,9 +164,9 @@ def update( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/facelists/{faceListId}' + url = self.update.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -183,9 +184,8 @@ def update( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -193,6 +193,7 @@ def update( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + update.metadata = {'url': '/facelists/{faceListId}'} def delete( self, face_list_id, custom_headers=None, raw=False, **operation_config): @@ -212,9 +213,9 @@ def delete( :class:`APIErrorException` """ # Construct URL - url = '/facelists/{faceListId}' + url = self.delete.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -224,13 +225,12 @@ def delete( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -238,6 +238,7 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete.metadata = {'url': '/facelists/{faceListId}'} def list( self, custom_headers=None, raw=False, **operation_config): @@ -256,9 +257,9 @@ def list( :class:`APIErrorException` """ # Construct URL - url = '/facelists' + url = self.list.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -267,13 +268,13 @@ def list( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -288,6 +289,7 @@ def list( return client_raw_response return deserialized + list.metadata = {'url': '/facelists'} def delete_face( self, face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): @@ -311,9 +313,9 @@ def delete_face( :class:`APIErrorException` """ # Construct URL - url = '/facelists/{faceListId}/persistedFaces/{persistedFaceId}' + url = self.delete_face.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') } @@ -324,13 +326,12 @@ def delete_face( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -338,6 +339,7 @@ def delete_face( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete_face.metadata = {'url': '/facelists/{faceListId}/persistedfaces/{persistedFaceId}'} def add_face_from_url( self, face_list_id, url, user_data=None, target_face=None, custom_headers=None, raw=False, **operation_config): @@ -347,7 +349,7 @@ def add_face_from_url( :param face_list_id: Id referencing a particular face list. :type face_list_id: str - :param url: + :param url: Publicly reachable URL of an image :type url: str :param user_data: User-specified data about the face for any purpose. The maximum length is 1KB. @@ -372,9 +374,9 @@ def add_face_from_url( image_url = models.ImageUrl(url=url) # Construct URL - url = '/facelists/{faceListId}/persistedFaces' + url = self.add_face_from_url.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -388,6 +390,7 @@ def add_face_from_url( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -396,9 +399,8 @@ def add_face_from_url( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -413,6 +415,7 @@ def add_face_from_url( return client_raw_response return deserialized + add_face_from_url.metadata = {'url': '/facelists/{faceListId}/persistedfaces'} def add_face_from_stream( self, face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): @@ -450,9 +453,9 @@ def add_face_from_stream( :class:`APIErrorException` """ # Construct URL - url = '/facelists/{faceListId}/persistedFaces' + url = self.add_face_from_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'faceListId': self._serialize.url("face_list_id", face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -466,6 +469,7 @@ def add_face_from_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -474,9 +478,8 @@ def add_face_from_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -491,3 +494,4 @@ def add_face_from_stream( return client_raw_response return deserialized + add_face_from_stream.metadata = {'url': '/facelists/{faceListId}/persistedfaces'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py index d8f156b55945..f0fc854c00fa 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py @@ -34,9 +34,9 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def find_similar( - self, face_id, face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode="matchPerson", custom_headers=None, raw=False, **operation_config): + self, face_id, face_list_id=None, large_face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode="matchPerson", custom_headers=None, raw=False, **operation_config): """Given query face's faceId, find the similar-looking faces from a faceId - array or a faceListId. + array, a face list or a large face list. :param face_id: FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not @@ -45,12 +45,20 @@ def find_similar( :param face_list_id: An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. - Parameter faceListId and faceIds should not be provided at the same - time + Parameter faceListId, largeFaceListId and faceIds should not be + provided at the same time。 :type face_list_id: str + :param large_face_list_id: An existing user-specified unique candidate + large face list, created in LargeFaceList - Create. Large face list + contains a set of persistedFaceIds which are persisted and will never + expire. Parameter faceListId, largeFaceListId and faceIds should not + be provided at the same time. + :type large_face_list_id: str :param face_ids: An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after - the detection call. + the detection call. The number of faceIds is limited to 1000. + Parameter faceListId, largeFaceListId and faceIds should not be + provided at the same time. :type face_ids: list[str] :param max_num_of_candidates_returned: The number of top similar faces returned. The valid range is [1, 1000]. @@ -70,12 +78,12 @@ def find_similar( :raises: :class:`APIErrorException` """ - body = models.FindSimilarRequest(face_id=face_id, face_list_id=face_list_id, face_ids=face_ids, max_num_of_candidates_returned=max_num_of_candidates_returned, mode=mode) + body = models.FindSimilarRequest(face_id=face_id, face_list_id=face_list_id, large_face_list_id=large_face_list_id, face_ids=face_ids, max_num_of_candidates_returned=max_num_of_candidates_returned, mode=mode) # Construct URL - url = '/findsimilars' + url = self.find_similar.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -84,6 +92,7 @@ def find_similar( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -92,9 +101,8 @@ def find_similar( body_content = self._serialize.body(body, 'FindSimilarRequest') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -109,6 +117,7 @@ def find_similar( return client_raw_response return deserialized + find_similar.metadata = {'url': '/findsimilars'} def group( self, face_ids, custom_headers=None, raw=False, **operation_config): @@ -131,9 +140,9 @@ def group( body = models.GroupRequest(face_ids=face_ids) # Construct URL - url = '/group' + url = self.group.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -142,6 +151,7 @@ def group( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -150,9 +160,8 @@ def group( body_content = self._serialize.body(body, 'GroupRequest') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -167,18 +176,26 @@ def group( return client_raw_response return deserialized + group.metadata = {'url': '/group'} def identify( - self, person_group_id, face_ids, max_num_of_candidates_returned=1, confidence_threshold=None, custom_headers=None, raw=False, **operation_config): - """Identify unknown faces from a person group. + self, face_ids, person_group_id=None, large_person_group_id=None, max_num_of_candidates_returned=1, confidence_threshold=None, custom_headers=None, raw=False, **operation_config): + """1-to-many identification to find the closest matches of the specific + query person face from a person group or large person group. - :param person_group_id: PersonGroupId of the target person group, - created by PersonGroups.Create - :type person_group_id: str :param face_ids: Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. :type face_ids: list[str] + :param person_group_id: PersonGroupId of the target person group, + created by PersonGroup - Create. Parameter personGroupId and + largePersonGroupId should not be provided at the same time. + :type person_group_id: str + :param large_person_group_id: LargePersonGroupId of the target large + person group, created by LargePersonGroup - Create. Parameter + personGroupId and largePersonGroupId should not be provided at the + same time. + :type large_person_group_id: str :param max_num_of_candidates_returned: The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). :type max_num_of_candidates_returned: int @@ -198,12 +215,12 @@ def identify( :raises: :class:`APIErrorException` """ - body = models.IdentifyRequest(person_group_id=person_group_id, face_ids=face_ids, max_num_of_candidates_returned=max_num_of_candidates_returned, confidence_threshold=confidence_threshold) + body = models.IdentifyRequest(face_ids=face_ids, person_group_id=person_group_id, large_person_group_id=large_person_group_id, max_num_of_candidates_returned=max_num_of_candidates_returned, confidence_threshold=confidence_threshold) # Construct URL - url = '/identify' + url = self.identify.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -212,6 +229,7 @@ def identify( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -220,9 +238,8 @@ def identify( body_content = self._serialize.body(body, 'IdentifyRequest') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -237,6 +254,7 @@ def identify( return client_raw_response return deserialized + identify.metadata = {'url': '/identify'} def verify_face_to_face( self, face_id1, face_id2, custom_headers=None, raw=False, **operation_config): @@ -261,9 +279,9 @@ def verify_face_to_face( body = models.VerifyFaceToFaceRequest(face_id1=face_id1, face_id2=face_id2) # Construct URL - url = '/verify' + url = self.verify_face_to_face.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -272,6 +290,7 @@ def verify_face_to_face( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -280,9 +299,8 @@ def verify_face_to_face( body_content = self._serialize.body(body, 'VerifyFaceToFaceRequest') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -297,13 +315,14 @@ def verify_face_to_face( return client_raw_response return deserialized + verify_face_to_face.metadata = {'url': '/verify'} def detect_with_url( self, url, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, custom_headers=None, raw=False, **operation_config): """Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. - :param url: + :param url: Publicly reachable URL of an image :type url: str :param return_face_id: A value indicating whether the operation should return faceIds of detected faces. @@ -333,9 +352,9 @@ def detect_with_url( image_url = models.ImageUrl(url=url) # Construct URL - url = '/detect' + url = self.detect_with_url.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -350,6 +369,7 @@ def detect_with_url( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -358,9 +378,8 @@ def detect_with_url( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -375,21 +394,29 @@ def detect_with_url( return client_raw_response return deserialized + detect_with_url.metadata = {'url': '/detect'} def verify_face_to_person( - self, face_id, person_group_id, person_id, custom_headers=None, raw=False, **operation_config): + self, face_id, person_id, person_group_id=None, large_person_group_id=None, custom_headers=None, raw=False, **operation_config): """Verify whether two faces belong to a same person. Compares a face Id with a Person Id. - :param face_id: FaceId the face, comes from Face - Detect + :param face_id: FaceId of the face, comes from Face - Detect :type face_id: str + :param person_id: Specify a certain person in a person group or a + large person group. personId is created in PersonGroup Person - Create + or LargePersonGroup Person - Create. + :type person_id: str :param person_group_id: Using existing personGroupId and personId for - fast loading a specified person. personGroupId is created in Person - Groups.Create. + fast loading a specified person. personGroupId is created in + PersonGroup - Create. Parameter personGroupId and largePersonGroupId + should not be provided at the same time. :type person_group_id: str - :param person_id: Specify a certain person in a person group. personId - is created in Persons.Create. - :type person_id: str + :param large_person_group_id: Using existing largePersonGroupId and + personId for fast loading a specified person. largePersonGroupId is + created in LargePersonGroup - Create. Parameter personGroupId and + largePersonGroupId should not be provided at the same time. + :type large_person_group_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -401,12 +428,12 @@ def verify_face_to_person( :raises: :class:`APIErrorException` """ - body = models.VerifyFaceToPersonRequest(face_id=face_id, person_group_id=person_group_id, person_id=person_id) + body = models.VerifyFaceToPersonRequest(face_id=face_id, person_group_id=person_group_id, large_person_group_id=large_person_group_id, person_id=person_id) # Construct URL - url = '/verify' + url = self.verify_face_to_person.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -415,6 +442,7 @@ def verify_face_to_person( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -423,9 +451,8 @@ def verify_face_to_person( body_content = self._serialize.body(body, 'VerifyFaceToPersonRequest') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -440,6 +467,7 @@ def verify_face_to_person( return client_raw_response return deserialized + verify_face_to_person.metadata = {'url': '/verify'} def detect_with_stream( self, image, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, custom_headers=None, raw=False, callback=None, **operation_config): @@ -479,9 +507,9 @@ def detect_with_stream( :class:`APIErrorException` """ # Construct URL - url = '/detect' + url = self.detect_with_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -496,6 +524,7 @@ def detect_with_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -504,9 +533,8 @@ def detect_with_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -521,3 +549,4 @@ def detect_with_stream( return client_raw_response return deserialized + detect_with_stream.metadata = {'url': '/detect'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py new file mode 100644 index 000000000000..02ce62b39fb9 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py @@ -0,0 +1,790 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class LargeFaceListOperations(object): + """LargeFaceListOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def create( + self, large_face_list_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Create an empty large face list. Up to 64 large face lists are allowed + to exist in one subscription. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + create.metadata = {'url': '/largefacelists/{largeFaceListId}'} + + def get( + self, large_face_list_id, custom_headers=None, raw=False, **operation_config): + """Retrieve a large face list's information. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LargeFaceList or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.LargeFaceList or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LargeFaceList', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/largefacelists/{largeFaceListId}'} + + def update( + self, large_face_list_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Update information of a large face list. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + update.metadata = {'url': '/largefacelists/{largeFaceListId}'} + + def delete( + self, large_face_list_id, custom_headers=None, raw=False, **operation_config): + """Delete an existing large face list according to faceListId. Persisted + face images in the large face list will also be deleted. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/largefacelists/{largeFaceListId}'} + + def get_training_status( + self, large_face_list_id, custom_headers=None, raw=False, **operation_config): + """Retrieve the training status of a large face list (completed or + ongoing). + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: TrainingStatus or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.TrainingStatus or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get_training_status.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('TrainingStatus', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_training_status.metadata = {'url': '/largefacelists/{largeFaceListId}/training'} + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Retrieve information about all existing large face lists. Only + largeFaceListId, name and userData will be returned. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: + list[~azure.cognitiveservices.vision.face.models.LargeFaceList] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('[LargeFaceList]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/largefacelists'} + + def train( + self, large_face_list_id, custom_headers=None, raw=False, **operation_config): + """Queue a large face list training task, the training task may not be + started immediately. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.train.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + train.metadata = {'url': '/largefacelists/{largeFaceListId}/train'} + + def delete_face( + self, large_face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): + """Delete an existing face from a large face list (given by a + persisitedFaceId and a largeFaceListId). Persisted image related to the + face will also be deleted. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.delete_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_face.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'} + + def get_face( + self, large_face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): + """Retrieve information about a persisted face (specified by + persistedFaceId and its belonging largeFaceListId). + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_face.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'} + + def update_face( + self, large_face_list_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config): + """Update a persisted face's userData field. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param user_data: User-provided data attached to the face. The size + limit is 1KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.UpdateFaceRequest(user_data=user_data) + + # Construct URL + url = self.update_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'UpdateFaceRequest') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + update_face.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}'} + + def add_face_from_url( + self, large_face_list_id, url, user_data=None, target_face=None, custom_headers=None, raw=False, **operation_config): + """Add a face to a large face list. The input face is specified as an + image with a targetFace rectangle. It returns a persistedFaceId + representing the added face, and persistedFaceId will not expire. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param url: Publicly reachable URL of an image + :type url: str + :param user_data: User-specified data about the face for any purpose. + The maximum length is 1KB. + :type user_data: str + :param 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". + E.g. "targetFace=10,10,100,100". If there is more than one face in the + image, targetFace is required to specify which face to add. No + targetFace means there is only one face detected in the entire image. + :type target_face: list[int] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + image_url = models.ImageUrl(url=url) + + # Construct URL + url = self.add_face_from_url.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if user_data is not None: + query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) + if target_face is not None: + query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(image_url, 'ImageUrl') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + add_face_from_url.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces'} + + def list_faces( + self, large_face_list_id, start=None, top=None, custom_headers=None, raw=False, **operation_config): + """List all faces in a large face list, and retrieve face information + (including userData and persistedFaceIds of registered faces of the + face). + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param start: Starting face id to return (used to list a range of + faces). + :type start: str + :param top: Number of faces to return starting with the face id + indicated by the 'start' parameter. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: + list[~azure.cognitiveservices.vision.face.models.PersistedFace] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.list_faces.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if start is not None: + query_parameters['start'] = self._serialize.query("start", start, 'str') + if top is not None: + query_parameters['top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('[PersistedFace]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_faces.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces'} + + def add_face_from_stream( + self, large_face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): + """Add a face to a large face list. The input face is specified as an + image with a targetFace rectangle. It returns a persistedFaceId + representing the added face, and persistedFaceId will not expire. + + :param large_face_list_id: Id referencing a particular large face + list. + :type large_face_list_id: str + :param image: An image stream. + :type image: Generator + :param user_data: User-specified data about the face for any purpose. + The maximum length is 1KB. + :type user_data: str + :param 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". + E.g. "targetFace=10,10,100,100". If there is more than one face in the + image, targetFace is required to specify which face to add. No + targetFace means there is only one face detected in the entire image. + :type target_face: list[int] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param callback: When specified, will be called with each chunk of + data that is streamed. The callback should take two arguments, the + bytes of the current chunk of data and the response object. If the + data is uploading, response will be None. + :type callback: Callable[Bytes, response=None] + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.add_face_from_stream.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if user_data is not None: + query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) + if target_face is not None: + query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/octet-stream' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._client.stream_upload(image, callback) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + add_face_from_stream.metadata = {'url': '/largefacelists/{largeFaceListId}/persistedfaces'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_operations.py new file mode 100644 index 000000000000..3e4bbf03c220 --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_operations.py @@ -0,0 +1,408 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class LargePersonGroupOperations(object): + """LargePersonGroupOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def create( + self, large_person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Create a new large person group with specified largePersonGroupId, name + and user-provided userData. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + create.metadata = {'url': '/largepersongroups/{largePersonGroupId}'} + + def delete( + self, large_person_group_id, custom_headers=None, raw=False, **operation_config): + """Delete an existing large person group. Persisted face features of all + people in the large person group will also be deleted. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/largepersongroups/{largePersonGroupId}'} + + def get( + self, large_person_group_id, custom_headers=None, raw=False, **operation_config): + """Retrieve the information of a large person group, including its name + and userData. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LargePersonGroup or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.LargePersonGroup + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LargePersonGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/largepersongroups/{largePersonGroupId}'} + + def update( + self, large_person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Update an existing large person group's display name and userData. The + properties which does not appear in request body will not be updated. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + update.metadata = {'url': '/largepersongroups/{largePersonGroupId}'} + + def get_training_status( + self, large_person_group_id, custom_headers=None, raw=False, **operation_config): + """Retrieve the training status of a large person group (completed or + ongoing). + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: TrainingStatus or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.TrainingStatus or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get_training_status.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('TrainingStatus', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_training_status.metadata = {'url': '/largepersongroups/{largePersonGroupId}/training'} + + def list( + self, start=None, top=1000, custom_headers=None, raw=False, **operation_config): + """List large person groups and their information. + + :param start: List large person groups from the least + largePersonGroupId greater than the "start". + :type start: str + :param top: The number of large person groups to list. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: + list[~azure.cognitiveservices.vision.face.models.LargePersonGroup] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if start is not None: + query_parameters['start'] = self._serialize.query("start", start, 'str', max_length=64) + if top is not None: + query_parameters['top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('[LargePersonGroup]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/largepersongroups'} + + def train( + self, large_person_group_id, custom_headers=None, raw=False, **operation_config): + """Queue a large person group training task, the training task may not be + started immediately. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.train.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + train.metadata = {'url': '/largepersongroups/{largePersonGroupId}/train'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_person_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_person_operations.py new file mode 100644 index 000000000000..a970a9ff50ae --- /dev/null +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_person_group_person_operations.py @@ -0,0 +1,666 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class LargePersonGroupPersonOperations(object): + """LargePersonGroupPersonOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def create( + self, large_person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Create a new person in a specified large person group. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Person or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.Person or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Person', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons'} + + def list( + self, large_person_group_id, start=None, top=None, custom_headers=None, raw=False, **operation_config): + """List all persons in a large person group, and retrieve person + information (including personId, name, userData and persistedFaceIds of + registered faces of the person). + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param start: Starting person id to return (used to list a range of + persons). + :type start: str + :param top: Number of persons to return starting with the person id + indicated by the 'start' parameter. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: list[~azure.cognitiveservices.vision.face.models.Person] or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if start is not None: + query_parameters['start'] = self._serialize.query("start", start, 'str') + if top is not None: + query_parameters['top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('[Person]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons'} + + def delete( + self, large_person_group_id, person_id, custom_headers=None, raw=False, **operation_config): + """Delete an existing person from a large person group. All stored person + data, and face features in the person entry will be deleted. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}'} + + def get( + self, large_person_group_id, person_id, custom_headers=None, raw=False, **operation_config): + """Retrieve a person's information, including registered persisted faces, + name and userData. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Person or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.Person or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Person', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}'} + + def update( + self, large_person_group_id, person_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): + """Update name or userData of a person. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param name: User defined name, maximum length is 128. + :type name: str + :param user_data: User specified data. Length should not exceed 16KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.NameAndUserDataContract(name=name, user_data=user_data) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'NameAndUserDataContract') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + update.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}'} + + def delete_face( + self, large_person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): + """Delete a face from a person. Relative feature for the persisted face + will also be deleted. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.delete_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_face.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} + + def get_face( + self, large_person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): + """Retrieve information about a persisted face (specified by + persistedFaceId, personId and its belonging largePersonGroupId). + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.get_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_face.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} + + def update_face( + self, large_person_group_id, person_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config): + """Update a person persisted face's userData field. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param persisted_face_id: Id referencing a particular persistedFaceId + of an existing face. + :type persisted_face_id: str + :param user_data: User-provided data attached to the face. The size + limit is 1KB. + :type user_data: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + body = models.UpdateFaceRequest(user_data=user_data) + + # Construct URL + url = self.update_face.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str'), + 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'UpdateFaceRequest') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + update_face.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} + + def add_face_from_url( + self, large_person_group_id, person_id, url, user_data=None, target_face=None, custom_headers=None, raw=False, **operation_config): + """Add a representative face to a person for identification. The input + face is specified as an image with a targetFace rectangle. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param url: Publicly reachable URL of an image + :type url: str + :param user_data: User-specified data about the face for any purpose. + The maximum length is 1KB. + :type user_data: str + :param 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". + E.g. "targetFace=10,10,100,100". If there is more than one face in the + image, targetFace is required to specify which face to add. No + targetFace means there is only one face detected in the entire image. + :type target_face: list[int] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + image_url = models.ImageUrl(url=url) + + # Construct URL + url = self.add_face_from_url.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if user_data is not None: + query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) + if target_face is not None: + query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(image_url, 'ImageUrl') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + add_face_from_url.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'} + + def add_face_from_stream( + self, large_person_group_id, person_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): + """Add a representative face to a person for identification. The input + face is specified as an image with a targetFace rectangle. + + :param large_person_group_id: Id referencing a particular large person + group. + :type large_person_group_id: str + :param person_id: Id referencing a particular person. + :type person_id: str + :param image: An image stream. + :type image: Generator + :param user_data: User-specified data about the face for any purpose. + The maximum length is 1KB. + :type user_data: str + :param 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". + E.g. "targetFace=10,10,100,100". If there is more than one face in the + image, targetFace is required to specify which face to add. No + targetFace means there is only one face detected in the entire image. + :type target_face: list[int] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param callback: When specified, will be called with each chunk of + data that is streamed. The callback should take two arguments, the + bytes of the current chunk of data and the response object. If the + data is uploading, response will be None. + :type callback: Callable[Bytes, response=None] + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PersistedFace or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.add_face_from_stream.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'largePersonGroupId': self._serialize.url("large_person_group_id", large_person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), + 'personId': self._serialize.url("person_id", person_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if user_data is not None: + query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024) + if target_face is not None: + query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/octet-stream' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._client.stream_upload(image, callback) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PersistedFace', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + add_face_from_stream.metadata = {'url': '/largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_operations.py index e0961c1e8940..aa609082f5de 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_operations.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_operations.py @@ -57,9 +57,9 @@ def create( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/persongroups/{personGroupId}' + url = self.create.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -77,9 +77,8 @@ def create( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -87,11 +86,12 @@ def create( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + create.metadata = {'url': '/persongroups/{personGroupId}'} def delete( self, person_group_id, custom_headers=None, raw=False, **operation_config): - """Delete an existing person group. Persisted face images of all people in - the person group will also be deleted. + """Delete an existing person group. Persisted face features of all people + in the person group will also be deleted. :param person_group_id: Id referencing a particular person group. :type person_group_id: str @@ -106,9 +106,9 @@ def delete( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}' + url = self.delete.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -118,13 +118,12 @@ def delete( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -132,6 +131,7 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete.metadata = {'url': '/persongroups/{personGroupId}'} def get( self, person_group_id, custom_headers=None, raw=False, **operation_config): @@ -152,9 +152,9 @@ def get( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}' + url = self.get.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -164,13 +164,13 @@ def get( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -185,6 +185,7 @@ def get( return client_raw_response return deserialized + get.metadata = {'url': '/persongroups/{personGroupId}'} def update( self, person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): @@ -210,9 +211,9 @@ def update( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/persongroups/{personGroupId}' + url = self.update.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -230,9 +231,8 @@ def update( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -240,6 +240,7 @@ def update( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + update.metadata = {'url': '/persongroups/{personGroupId}'} def get_training_status( self, person_group_id, custom_headers=None, raw=False, **operation_config): @@ -259,9 +260,9 @@ def get_training_status( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/training' + url = self.get_training_status.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -271,13 +272,13 @@ def get_training_status( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -292,6 +293,7 @@ def get_training_status( return client_raw_response return deserialized + get_training_status.metadata = {'url': '/persongroups/{personGroupId}/training'} def list( self, start=None, top=1000, custom_headers=None, raw=False, **operation_config): @@ -314,9 +316,9 @@ def list( :class:`APIErrorException` """ # Construct URL - url = '/persongroups' + url = self.list.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) @@ -329,13 +331,13 @@ def list( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -350,6 +352,7 @@ def list( return client_raw_response return deserialized + list.metadata = {'url': '/persongroups'} def train( self, person_group_id, custom_headers=None, raw=False, **operation_config): @@ -369,9 +372,9 @@ def train( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/train' + url = self.train.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -381,13 +384,12 @@ def train( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [202]: raise models.APIErrorException(self._deserialize, response) @@ -395,3 +397,4 @@ def train( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + train.metadata = {'url': '/persongroups/{personGroupId}/train'} diff --git a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_person_operations.py b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_person_operations.py index c80df1653c06..8458ff94102d 100644 --- a/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_person_operations.py +++ b/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/person_group_person_operations.py @@ -57,9 +57,9 @@ def create( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/persongroups/{personGroupId}/persons' + url = self.create.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -69,6 +69,7 @@ def create( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -77,9 +78,8 @@ def create( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -94,6 +94,7 @@ def create( return client_raw_response return deserialized + create.metadata = {'url': '/persongroups/{personGroupId}/persons'} def list( self, person_group_id, start=None, top=None, custom_headers=None, raw=False, **operation_config): @@ -121,9 +122,9 @@ def list( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons' + url = self.list.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$') } url = self._client.format_url(url, **path_format_arguments) @@ -137,13 +138,13 @@ def list( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -158,11 +159,12 @@ def list( return client_raw_response return deserialized + list.metadata = {'url': '/persongroups/{personGroupId}/persons'} def delete( self, person_group_id, person_id, custom_headers=None, raw=False, **operation_config): - """Delete an existing person from a person group. Persisted face images of - the person will also be deleted. + """Delete an existing person from a person group. All stored person data, + and face features in the person entry will be deleted. :param person_group_id: Id referencing a particular person group. :type person_group_id: str @@ -179,9 +181,9 @@ def delete( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}' + url = self.delete.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str') } @@ -192,13 +194,12 @@ def delete( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -206,6 +207,7 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}'} def get( self, person_group_id, person_id, custom_headers=None, raw=False, **operation_config): @@ -228,9 +230,9 @@ def get( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}' + url = self.get.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str') } @@ -241,13 +243,13 @@ def get( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -262,6 +264,7 @@ def get( return client_raw_response return deserialized + get.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}'} def update( self, person_group_id, person_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config): @@ -288,9 +291,9 @@ def update( body = models.NameAndUserDataContract(name=name, user_data=user_data) # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}' + url = self.update.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str') } @@ -309,9 +312,8 @@ def update( body_content = self._serialize.body(body, 'NameAndUserDataContract') # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -319,11 +321,12 @@ def update( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + update.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}'} def delete_face( self, person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): - """Delete a face from a person. Relative image for the persisted face will - also be deleted. + """Delete a face from a person. Relative feature for the persisted face + will also be deleted. :param person_group_id: Id referencing a particular person group. :type person_group_id: str @@ -343,9 +346,9 @@ def delete_face( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}' + url = self.delete_face.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str'), 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') @@ -357,13 +360,12 @@ def delete_face( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -371,6 +373,7 @@ def delete_face( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete_face.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} def get_face( self, person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config): @@ -396,9 +399,9 @@ def get_face( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}' + url = self.get_face.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str'), 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') @@ -410,13 +413,13 @@ def get_face( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -431,6 +434,7 @@ def get_face( return client_raw_response return deserialized + get_face.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} def update_face( self, person_group_id, person_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config): @@ -456,12 +460,12 @@ def update_face( :raises: :class:`APIErrorException` """ - body = models.UpdatePersonFaceRequest(user_data=user_data) + body = models.UpdateFaceRequest(user_data=user_data) # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}' + url = self.update_face.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str'), 'persistedFaceId': self._serialize.url("persisted_face_id", persisted_face_id, 'str') @@ -478,12 +482,11 @@ def update_face( header_parameters.update(custom_headers) # Construct body - body_content = self._serialize.body(body, 'UpdatePersonFaceRequest') + body_content = self._serialize.body(body, 'UpdateFaceRequest') # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -491,8 +494,9 @@ def update_face( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + update_face.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'} - def add_person_face_from_url( + def add_face_from_url( self, person_group_id, person_id, url, user_data=None, target_face=None, custom_headers=None, raw=False, **operation_config): """Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. @@ -501,7 +505,7 @@ def add_person_face_from_url( :type person_group_id: str :param person_id: Id referencing a particular person. :type person_id: str - :param url: + :param url: Publicly reachable URL of an image :type url: str :param user_data: User-specified data about the face for any purpose. The maximum length is 1KB. @@ -526,9 +530,9 @@ def add_person_face_from_url( image_url = models.ImageUrl(url=url) # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}/persistedFaces' + url = self.add_face_from_url.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str') } @@ -543,6 +547,7 @@ def add_person_face_from_url( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -551,9 +556,8 @@ def add_person_face_from_url( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -568,8 +572,9 @@ def add_person_face_from_url( return client_raw_response return deserialized + add_face_from_url.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}/persistedfaces'} - def add_person_face_from_stream( + def add_face_from_stream( self, person_group_id, person_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config): """Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. @@ -606,9 +611,9 @@ def add_person_face_from_stream( :class:`APIErrorException` """ # Construct URL - url = '/persongroups/{personGroupId}/persons/{personId}/persistedFaces' + url = self.add_face_from_stream.metadata['url'] path_format_arguments = { - 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'personGroupId': self._serialize.url("person_group_id", person_group_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$'), 'personId': self._serialize.url("person_id", person_id, 'str') } @@ -623,6 +628,7 @@ def add_person_face_from_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -631,9 +637,8 @@ def add_person_face_from_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) @@ -648,3 +653,4 @@ def add_person_face_from_stream( return client_raw_response return deserialized + add_face_from_stream.metadata = {'url': '/persongroups/{personGroupId}/persons/{personId}/persistedfaces'} diff --git a/azure-cognitiveservices-vision-face/setup.py b/azure-cognitiveservices-vision-face/setup.py index f7ab200174d8..0e930e682482 100644 --- a/azure-cognitiveservices-vision-face/setup.py +++ b/azure-cognitiveservices-vision-face/setup.py @@ -79,6 +79,7 @@ ]), install_requires=[ 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], extras_require={ diff --git a/azure-cognitiveservices-vision-face/tests/test_face.py b/azure-cognitiveservices-vision-face/tests/test_face.py index 93fa6537c356..0821ec48e2cf 100644 --- a/azure-cognitiveservices-vision-face/tests/test_face.py +++ b/azure-cognitiveservices-vision-face/tests/test_face.py @@ -10,7 +10,7 @@ # -------------------------------------------------------------------------- from os.path import dirname, join, realpath -from azure.cognitiveservices.vision.face import FaceAPI +from azure.cognitiveservices.vision.face import FaceClient from azure.cognitiveservices.vision.face.models import Gender from msrest.authentication import CognitiveServicesCredentials @@ -48,9 +48,9 @@ def test_face_detect(self): credentials = CognitiveServicesCredentials( self.settings.CS_SUBSCRIPTION_KEY ) - face_api = FaceAPI("westus2", credentials=credentials) + face_client = FaceClient("https://westus2.api.cognitive.microsoft.com", credentials=credentials) with open(join(CWD, "facefindsimilar.queryface.jpg"), "rb") as face_fd: - result = face_api.face.detect_with_stream( + result = face_client.face.detect_with_stream( face_fd, return_face_attributes=['age','gender','headPose','smile','facialHair','glasses','emotion','hair','makeup','occlusion','accessories','blur','exposure','noise'] )