From cd642597d7e0b35c286fac76279c16622219bab7 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 24 Feb 2020 20:37:10 +0000 Subject: [PATCH] Generated from 497f37d011e45d90e7a5f190b1326ec89e2719c8 Merge pull request #6 from Khushboo-Baheti/master merge --- .../customvision/prediction/__init__.py | 7 +- .../customvision/prediction/_configuration.py | 46 ++++++ .../_custom_vision_prediction_client.py | 43 ++++++ .../prediction/models/__init__.py | 28 ++-- ..._custom_vision_prediction_client_enums.py} | 0 .../{custom_vision_error.py => _models.py} | 142 ++++++++++++++++++ ...tom_vision_error_py3.py => _models_py3.py} | 142 ++++++++++++++++++ .../prediction/models/bounding_box.py | 49 ------ .../prediction/models/bounding_box_py3.py | 49 ------ .../prediction/models/image_prediction.py | 56 ------- .../prediction/models/image_prediction_py3.py | 56 ------- .../prediction/models/image_url.py | 34 ----- .../prediction/models/image_url_py3.py | 34 ----- .../prediction/models/prediction.py | 51 ------- .../prediction/models/prediction_py3.py | 51 ------- .../prediction/operations/__init__.py | 16 ++ ...om_vision_prediction_client_operations.py} | 73 +-------- 17 files changed, 409 insertions(+), 468 deletions(-) create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py rename sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/{custom_vision_prediction_client_enums.py => _custom_vision_prediction_client_enums.py} (100%) rename sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/{custom_vision_error.py => _models.py} (58%) rename sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/{custom_vision_error_py3.py => _models_py3.py} (58%) delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/__init__.py rename sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/{custom_vision_prediction_client.py => operations/_custom_vision_prediction_client_operations.py} (90%) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/__init__.py index fd2fe8a0a828..413d7019e9f0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/__init__.py @@ -9,10 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .custom_vision_prediction_client import CustomVisionPredictionClient -from .version import VERSION +from ._configuration import CustomVisionPredictionClientConfiguration +from ._custom_vision_prediction_client import CustomVisionPredictionClient +__all__ = ['CustomVisionPredictionClient', 'CustomVisionPredictionClientConfiguration'] -__all__ = ['CustomVisionPredictionClient'] +from .version import VERSION __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py new file mode 100644 index 000000000000..17c83361819f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.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 import Configuration + +from .version import VERSION + + +class CustomVisionPredictionClientConfiguration(Configuration): + """Configuration for CustomVisionPredictionClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoints. + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + 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 = '{Endpoint}/customvision/v3.0/prediction' + + super(CustomVisionPredictionClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-cognitiveservices-vision-customvision/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py new file mode 100644 index 000000000000..abfb4a51227f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.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.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import CustomVisionPredictionClientConfiguration +from .operations import CustomVisionPredictionClientOperationsMixin +from . import models + + +class CustomVisionPredictionClient(CustomVisionPredictionClientOperationsMixin, SDKClient): + """CustomVisionPredictionClient + + :ivar config: Configuration for client. + :vartype config: CustomVisionPredictionClientConfiguration + + :param endpoint: Supported Cognitive Services endpoints. + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = CustomVisionPredictionClientConfiguration(endpoint, credentials) + super(CustomVisionPredictionClient, 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 = '3.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py index 611e49961e38..d654981d00aa 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py @@ -10,26 +10,26 @@ # -------------------------------------------------------------------------- try: - from .image_url_py3 import ImageUrl - from .bounding_box_py3 import BoundingBox - from .prediction_py3 import Prediction - from .image_prediction_py3 import ImagePrediction - from .custom_vision_error_py3 import CustomVisionError, CustomVisionErrorException + from ._models_py3 import BoundingBox + from ._models_py3 import CustomVisionError, CustomVisionErrorException + from ._models_py3 import ImagePrediction + from ._models_py3 import ImageUrl + from ._models_py3 import Prediction except (SyntaxError, ImportError): - from .image_url import ImageUrl - from .bounding_box import BoundingBox - from .prediction import Prediction - from .image_prediction import ImagePrediction - from .custom_vision_error import CustomVisionError, CustomVisionErrorException -from .custom_vision_prediction_client_enums import ( + from ._models import BoundingBox + from ._models import CustomVisionError, CustomVisionErrorException + from ._models import ImagePrediction + from ._models import ImageUrl + from ._models import Prediction +from ._custom_vision_prediction_client_enums import ( CustomVisionErrorCodes, ) __all__ = [ - 'ImageUrl', 'BoundingBox', - 'Prediction', - 'ImagePrediction', 'CustomVisionError', 'CustomVisionErrorException', + 'ImagePrediction', + 'ImageUrl', + 'Prediction', 'CustomVisionErrorCodes', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_prediction_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py similarity index 100% rename from sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_prediction_client_enums.py rename to sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py similarity index 58% rename from sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error.py rename to sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py index 6de98ff9a616..6c4860c8748c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py @@ -13,6 +13,43 @@ from msrest.exceptions import HttpOperationError +class BoundingBox(Model): + """Bounding box that defines a region of an image. + + All required parameters must be populated in order to send to Azure. + + :param left: Required. Coordinate of the left boundary. + :type left: float + :param top: Required. Coordinate of the top boundary. + :type top: float + :param width: Required. Width. + :type width: float + :param height: Required. Height. + :type height: float + """ + + _validation = { + 'left': {'required': True}, + 'top': {'required': True}, + 'width': {'required': True}, + 'height': {'required': True}, + } + + _attribute_map = { + 'left': {'key': 'left', 'type': 'float'}, + 'top': {'key': 'top', 'type': 'float'}, + 'width': {'key': 'width', 'type': 'float'}, + 'height': {'key': 'height', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(BoundingBox, self).__init__(**kwargs) + self.left = kwargs.get('left', None) + self.top = kwargs.get('top', None) + self.width = kwargs.get('width', None) + self.height = kwargs.get('height', None) + + class CustomVisionError(Model): """CustomVisionError. @@ -116,3 +153,108 @@ class CustomVisionErrorException(HttpOperationError): def __init__(self, deserialize, response, *args): super(CustomVisionErrorException, self).__init__(deserialize, response, 'CustomVisionError', *args) + + +class ImagePrediction(Model): + """Result of an image prediction request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Prediction Id. + :vartype id: str + :ivar project: Project Id. + :vartype project: str + :ivar iteration: Iteration Id. + :vartype iteration: str + :ivar created: Date this prediction was created. + :vartype created: datetime + :ivar predictions: List of predictions. + :vartype predictions: + list[~azure.cognitiveservices.vision.customvision.prediction.models.Prediction] + """ + + _validation = { + 'id': {'readonly': True}, + 'project': {'readonly': True}, + 'iteration': {'readonly': True}, + 'created': {'readonly': True}, + 'predictions': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'str'}, + 'iteration': {'key': 'iteration', 'type': 'str'}, + 'created': {'key': 'created', 'type': 'iso-8601'}, + 'predictions': {'key': 'predictions', 'type': '[Prediction]'}, + } + + def __init__(self, **kwargs): + super(ImagePrediction, self).__init__(**kwargs) + self.id = None + self.project = None + self.iteration = None + self.created = None + self.predictions = None + + +class ImageUrl(Model): + """Image url. + + All required parameters must be populated in order to send to Azure. + + :param url: Required. Url of the image. + :type url: str + """ + + _validation = { + 'url': {'required': True}, + } + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ImageUrl, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + + +class Prediction(Model): + """Prediction result. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar probability: Probability of the tag. + :vartype probability: float + :ivar tag_id: Id of the predicted tag. + :vartype tag_id: str + :ivar tag_name: Name of the predicted tag. + :vartype tag_name: str + :ivar bounding_box: Bounding box of the prediction. + :vartype bounding_box: + ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox + """ + + _validation = { + 'probability': {'readonly': True}, + 'tag_id': {'readonly': True}, + 'tag_name': {'readonly': True}, + 'bounding_box': {'readonly': True}, + } + + _attribute_map = { + 'probability': {'key': 'probability', 'type': 'float'}, + 'tag_id': {'key': 'tagId', 'type': 'str'}, + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + } + + def __init__(self, **kwargs): + super(Prediction, self).__init__(**kwargs) + self.probability = None + self.tag_id = None + self.tag_name = None + self.bounding_box = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py similarity index 58% rename from sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error_py3.py rename to sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py index 16792df3412d..a7ef53998a0a 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/custom_vision_error_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py @@ -13,6 +13,43 @@ from msrest.exceptions import HttpOperationError +class BoundingBox(Model): + """Bounding box that defines a region of an image. + + All required parameters must be populated in order to send to Azure. + + :param left: Required. Coordinate of the left boundary. + :type left: float + :param top: Required. Coordinate of the top boundary. + :type top: float + :param width: Required. Width. + :type width: float + :param height: Required. Height. + :type height: float + """ + + _validation = { + 'left': {'required': True}, + 'top': {'required': True}, + 'width': {'required': True}, + 'height': {'required': True}, + } + + _attribute_map = { + 'left': {'key': 'left', 'type': 'float'}, + 'top': {'key': 'top', 'type': 'float'}, + 'width': {'key': 'width', 'type': 'float'}, + 'height': {'key': 'height', 'type': 'float'}, + } + + def __init__(self, *, left: float, top: float, width: float, height: float, **kwargs) -> None: + super(BoundingBox, self).__init__(**kwargs) + self.left = left + self.top = top + self.width = width + self.height = height + + class CustomVisionError(Model): """CustomVisionError. @@ -116,3 +153,108 @@ class CustomVisionErrorException(HttpOperationError): def __init__(self, deserialize, response, *args): super(CustomVisionErrorException, self).__init__(deserialize, response, 'CustomVisionError', *args) + + +class ImagePrediction(Model): + """Result of an image prediction request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Prediction Id. + :vartype id: str + :ivar project: Project Id. + :vartype project: str + :ivar iteration: Iteration Id. + :vartype iteration: str + :ivar created: Date this prediction was created. + :vartype created: datetime + :ivar predictions: List of predictions. + :vartype predictions: + list[~azure.cognitiveservices.vision.customvision.prediction.models.Prediction] + """ + + _validation = { + 'id': {'readonly': True}, + 'project': {'readonly': True}, + 'iteration': {'readonly': True}, + 'created': {'readonly': True}, + 'predictions': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'str'}, + 'iteration': {'key': 'iteration', 'type': 'str'}, + 'created': {'key': 'created', 'type': 'iso-8601'}, + 'predictions': {'key': 'predictions', 'type': '[Prediction]'}, + } + + def __init__(self, **kwargs) -> None: + super(ImagePrediction, self).__init__(**kwargs) + self.id = None + self.project = None + self.iteration = None + self.created = None + self.predictions = None + + +class ImageUrl(Model): + """Image url. + + All required parameters must be populated in order to send to Azure. + + :param url: Required. Url of the 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 + + +class Prediction(Model): + """Prediction result. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar probability: Probability of the tag. + :vartype probability: float + :ivar tag_id: Id of the predicted tag. + :vartype tag_id: str + :ivar tag_name: Name of the predicted tag. + :vartype tag_name: str + :ivar bounding_box: Bounding box of the prediction. + :vartype bounding_box: + ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox + """ + + _validation = { + 'probability': {'readonly': True}, + 'tag_id': {'readonly': True}, + 'tag_name': {'readonly': True}, + 'bounding_box': {'readonly': True}, + } + + _attribute_map = { + 'probability': {'key': 'probability', 'type': 'float'}, + 'tag_id': {'key': 'tagId', 'type': 'str'}, + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + } + + def __init__(self, **kwargs) -> None: + super(Prediction, self).__init__(**kwargs) + self.probability = None + self.tag_id = None + self.tag_name = None + self.bounding_box = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box.py deleted file mode 100644 index c5e07c1966a8..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class BoundingBox(Model): - """Bounding box that defines a region of an image. - - All required parameters must be populated in order to send to Azure. - - :param left: Required. Coordinate of the left boundary. - :type left: float - :param top: Required. Coordinate of the top boundary. - :type top: float - :param width: Required. Width. - :type width: float - :param height: Required. Height. - :type height: float - """ - - _validation = { - 'left': {'required': True}, - 'top': {'required': True}, - 'width': {'required': True}, - 'height': {'required': True}, - } - - _attribute_map = { - 'left': {'key': 'left', 'type': 'float'}, - 'top': {'key': 'top', 'type': 'float'}, - 'width': {'key': 'width', 'type': 'float'}, - 'height': {'key': 'height', 'type': 'float'}, - } - - def __init__(self, **kwargs): - super(BoundingBox, self).__init__(**kwargs) - self.left = kwargs.get('left', None) - self.top = kwargs.get('top', None) - self.width = kwargs.get('width', None) - self.height = kwargs.get('height', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box_py3.py deleted file mode 100644 index 42627ed3ed3d..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/bounding_box_py3.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class BoundingBox(Model): - """Bounding box that defines a region of an image. - - All required parameters must be populated in order to send to Azure. - - :param left: Required. Coordinate of the left boundary. - :type left: float - :param top: Required. Coordinate of the top boundary. - :type top: float - :param width: Required. Width. - :type width: float - :param height: Required. Height. - :type height: float - """ - - _validation = { - 'left': {'required': True}, - 'top': {'required': True}, - 'width': {'required': True}, - 'height': {'required': True}, - } - - _attribute_map = { - 'left': {'key': 'left', 'type': 'float'}, - 'top': {'key': 'top', 'type': 'float'}, - 'width': {'key': 'width', 'type': 'float'}, - 'height': {'key': 'height', 'type': 'float'}, - } - - def __init__(self, *, left: float, top: float, width: float, height: float, **kwargs) -> None: - super(BoundingBox, self).__init__(**kwargs) - self.left = left - self.top = top - self.width = width - self.height = height diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction.py deleted file mode 100644 index 854a21f250d2..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ImagePrediction(Model): - """Result of an image prediction request. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Prediction Id. - :vartype id: str - :ivar project: Project Id. - :vartype project: str - :ivar iteration: Iteration Id. - :vartype iteration: str - :ivar created: Date this prediction was created. - :vartype created: datetime - :ivar predictions: List of predictions. - :vartype predictions: - list[~azure.cognitiveservices.vision.customvision.prediction.models.Prediction] - """ - - _validation = { - 'id': {'readonly': True}, - 'project': {'readonly': True}, - 'iteration': {'readonly': True}, - 'created': {'readonly': True}, - 'predictions': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'project': {'key': 'project', 'type': 'str'}, - 'iteration': {'key': 'iteration', 'type': 'str'}, - 'created': {'key': 'created', 'type': 'iso-8601'}, - 'predictions': {'key': 'predictions', 'type': '[Prediction]'}, - } - - def __init__(self, **kwargs): - super(ImagePrediction, self).__init__(**kwargs) - self.id = None - self.project = None - self.iteration = None - self.created = None - self.predictions = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction_py3.py deleted file mode 100644 index e15f6cf05703..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_prediction_py3.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ImagePrediction(Model): - """Result of an image prediction request. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Prediction Id. - :vartype id: str - :ivar project: Project Id. - :vartype project: str - :ivar iteration: Iteration Id. - :vartype iteration: str - :ivar created: Date this prediction was created. - :vartype created: datetime - :ivar predictions: List of predictions. - :vartype predictions: - list[~azure.cognitiveservices.vision.customvision.prediction.models.Prediction] - """ - - _validation = { - 'id': {'readonly': True}, - 'project': {'readonly': True}, - 'iteration': {'readonly': True}, - 'created': {'readonly': True}, - 'predictions': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'project': {'key': 'project', 'type': 'str'}, - 'iteration': {'key': 'iteration', 'type': 'str'}, - 'created': {'key': 'created', 'type': 'iso-8601'}, - 'predictions': {'key': 'predictions', 'type': '[Prediction]'}, - } - - def __init__(self, **kwargs) -> None: - super(ImagePrediction, self).__init__(**kwargs) - self.id = None - self.project = None - self.iteration = None - self.created = None - self.predictions = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url.py deleted file mode 100644 index 1843cb88e722..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) 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): - """Image url. - - All required parameters must be populated in order to send to Azure. - - :param url: Required. Url of the image. - :type url: str - """ - - _validation = { - 'url': {'required': True}, - } - - _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ImageUrl, self).__init__(**kwargs) - self.url = kwargs.get('url', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url_py3.py deleted file mode 100644 index a219f5de8b08..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/image_url_py3.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) 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): - """Image url. - - All required parameters must be populated in order to send to Azure. - - :param url: Required. Url of the 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/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction.py deleted file mode 100644 index 7969f2f4e9dc..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class Prediction(Model): - """Prediction result. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar probability: Probability of the tag. - :vartype probability: float - :ivar tag_id: Id of the predicted tag. - :vartype tag_id: str - :ivar tag_name: Name of the predicted tag. - :vartype tag_name: str - :ivar bounding_box: Bounding box of the prediction. - :vartype bounding_box: - ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox - """ - - _validation = { - 'probability': {'readonly': True}, - 'tag_id': {'readonly': True}, - 'tag_name': {'readonly': True}, - 'bounding_box': {'readonly': True}, - } - - _attribute_map = { - 'probability': {'key': 'probability', 'type': 'float'}, - 'tag_id': {'key': 'tagId', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, - } - - def __init__(self, **kwargs): - super(Prediction, self).__init__(**kwargs) - self.probability = None - self.tag_id = None - self.tag_name = None - self.bounding_box = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction_py3.py deleted file mode 100644 index 056d57628062..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/prediction_py3.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class Prediction(Model): - """Prediction result. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar probability: Probability of the tag. - :vartype probability: float - :ivar tag_id: Id of the predicted tag. - :vartype tag_id: str - :ivar tag_name: Name of the predicted tag. - :vartype tag_name: str - :ivar bounding_box: Bounding box of the prediction. - :vartype bounding_box: - ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox - """ - - _validation = { - 'probability': {'readonly': True}, - 'tag_id': {'readonly': True}, - 'tag_name': {'readonly': True}, - 'bounding_box': {'readonly': True}, - } - - _attribute_map = { - 'probability': {'key': 'probability', 'type': 'float'}, - 'tag_id': {'key': 'tagId', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, - } - - def __init__(self, **kwargs) -> None: - super(Prediction, self).__init__(**kwargs) - self.probability = None - self.tag_id = None - self.tag_name = None - self.bounding_box = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/__init__.py new file mode 100644 index 000000000000..2bdfcda09f24 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/__init__.py @@ -0,0 +1,16 @@ +# 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 ._custom_vision_prediction_client_operations import CustomVisionPredictionClientOperationsMixin + +__all__ = [ + 'CustomVisionPredictionClientOperationsMixin', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/custom_vision_prediction_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py similarity index 90% rename from sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/custom_vision_prediction_client.py rename to sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py index 340bca2687bf..49127e2fb22c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/custom_vision_prediction_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py @@ -9,64 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Configuration, Serializer, Deserializer -from .version import VERSION from msrest.pipeline import ClientRawResponse -from . import models +from .. import models -class CustomVisionPredictionClientConfiguration(Configuration): - """Configuration for CustomVisionPredictionClient - Note that all parameters used to create this instance are saved as instance - attributes. - - :param api_key: API key. - :type api_key: str - :param endpoint: Supported Cognitive Services endpoints. - :type endpoint: str - """ - - def __init__( - self, api_key, endpoint): - - if api_key is None: - raise ValueError("Parameter 'api_key' must not be None.") - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - base_url = '{Endpoint}/customvision/v3.0/prediction' - - super(CustomVisionPredictionClientConfiguration, self).__init__(base_url) - - self.add_user_agent('azure-cognitiveservices-vision-customvision/{}'.format(VERSION)) - - self.api_key = api_key - self.endpoint = endpoint - - -class CustomVisionPredictionClient(SDKClient): - """CustomVisionPredictionClient - - :ivar config: Configuration for client. - :vartype config: CustomVisionPredictionClientConfiguration - - :param api_key: API key. - :type api_key: str - :param endpoint: Supported Cognitive Services endpoints. - :type endpoint: str - """ - - def __init__( - self, api_key, endpoint): - - self.config = CustomVisionPredictionClientConfiguration(api_key, endpoint) - super(CustomVisionPredictionClient, self).__init__(None, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '3.0' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - +class CustomVisionPredictionClientOperationsMixin(object): def classify_image_url( self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): @@ -116,7 +63,6 @@ def classify_image_url( header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') @@ -129,7 +75,6 @@ def classify_image_url( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -187,7 +132,6 @@ def classify_image( header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { @@ -202,7 +146,6 @@ def classify_image( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -261,7 +204,6 @@ def classify_image_url_with_no_store( header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') @@ -274,7 +216,6 @@ def classify_image_url_with_no_store( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -332,7 +273,6 @@ def classify_image_with_no_store( header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { @@ -347,7 +287,6 @@ def classify_image_with_no_store( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -406,7 +345,6 @@ def detect_image_url( header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') @@ -419,7 +357,6 @@ def detect_image_url( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -477,7 +414,6 @@ def detect_image( header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { @@ -492,7 +428,6 @@ def detect_image( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -551,7 +486,6 @@ def detect_image_url_with_no_store( header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') @@ -564,7 +498,6 @@ def detect_image_url_with_no_store( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response) @@ -622,7 +555,6 @@ def detect_image_with_no_store( header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { @@ -637,7 +569,6 @@ def detect_image_with_no_store( raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('ImagePrediction', response)