Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR] cognitiveservices/data-plane/Face #3011

Merged
merged 8 commits into from
Oct 17, 2018
4 changes: 4 additions & 0 deletions azure-cognitiveservices-vision-face/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include *.rst
include azure/__init__.py
include azure/cognitiveservices/__init__.py
include azure/cognitiveservices/vision/__init__.py

Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -56,7 +98,6 @@
FindSimilarMatchMode,
TrainingStatusType,
FaceAttributeType,
AzureRegions,
)

__all__ = [
Expand Down Expand Up @@ -92,7 +133,9 @@
'FaceList',
'PersonGroup',
'Person',
'UpdatePersonFaceRequest',
'LargeFaceList',
'LargePersonGroup',
'UpdateFaceRequest',
'TrainingStatus',
'NameAndUserDataContract',
'ImageUrl',
Expand All @@ -106,5 +149,4 @@
'FindSimilarMatchMode',
'TrainingStatusType',
'FaceAttributeType',
'AzureRegions',
]
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Loading