diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in index 223bdb9a7fe1..e4224dfe1cad 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/_meta.json b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/_meta.json new file mode 100644 index 000000000000..cbe176eff3f7 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "V2", + "use": "@microsoft.azure/autorest.python@~4.0.71", + "commit": "89e7397cdb309ca81b3f1e823b98af25550df5c1", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/cognitiveservices/data-plane/Personalizer/readme.md --keep-version-file --multiapi --no-async --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --use=@microsoft.azure/autorest.python@~4.0.71 --version=V2", + "readme": "specification/cognitiveservices/data-plane/Personalizer/readme.md" +} \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py index 50d6c96bf888..80d35b9b9904 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py @@ -9,10 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .personalizer_client import PersonalizerClient -from .version import VERSION +from ._configuration import PersonalizerClientv11Preview1Configuration +from ._personalizer_clientv11_preview1 import PersonalizerClientv11Preview1 +__all__ = ['PersonalizerClientv11Preview1', 'PersonalizerClientv11Preview1Configuration'] -__all__ = ['PersonalizerClient'] +from .version import VERSION __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_configuration.py new file mode 100644 index 000000000000..30cfbea782ea --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_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 PersonalizerClientv11Preview1Configuration(Configuration): + """Configuration for PersonalizerClientv11Preview1 + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoint. + :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}/personalizer/v1.1-preview.1' + + super(PersonalizerClientv11Preview1Configuration, 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-personalizer/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_clientv11_preview1.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_clientv11_preview1.py new file mode 100644 index 000000000000..6dd6bdf0ef4a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_clientv11_preview1.py @@ -0,0 +1,90 @@ +# 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 PersonalizerClientv11Preview1Configuration +from .operations import PersonalizerClientv11Preview1OperationsMixin +from msrest.exceptions import HttpOperationError +from .operations import ServiceConfigurationOperations +from .operations import PolicyOperations +from .operations import EvaluationOperations +from .operations import EvaluationsOperations +from .operations import EventsOperations +from .operations import LogOperations +from .operations import ModelOperations +from .operations import MultiSlotEventsOperations +from .operations import MultiSlotOperations +from . import models + + +class PersonalizerClientv11Preview1(PersonalizerClientv11Preview1OperationsMixin, SDKClient): + """Personalizer Service is an Azure Cognitive Service that makes it easy to target content and experiences without complex pre-analysis or cleanup of past data. Given a context and featurized content, the Personalizer Service returns which content item to show to users in rewardActionId. As rewards are sent in response to the use of rewardActionId, the reinforcement learning algorithm will improve the model and improve performance of future rank calls. + + :ivar config: Configuration for client. + :vartype config: PersonalizerClientv11Preview1Configuration + + :ivar service_configuration: ServiceConfiguration operations + :vartype service_configuration: azure.cognitiveservices.personalizer.operations.ServiceConfigurationOperations + :ivar policy: Policy operations + :vartype policy: azure.cognitiveservices.personalizer.operations.PolicyOperations + :ivar evaluation: Evaluation operations + :vartype evaluation: azure.cognitiveservices.personalizer.operations.EvaluationOperations + :ivar evaluations: Evaluations operations + :vartype evaluations: azure.cognitiveservices.personalizer.operations.EvaluationsOperations + :ivar events: Events operations + :vartype events: azure.cognitiveservices.personalizer.operations.EventsOperations + :ivar log: Log operations + :vartype log: azure.cognitiveservices.personalizer.operations.LogOperations + :ivar model: Model operations + :vartype model: azure.cognitiveservices.personalizer.operations.ModelOperations + :ivar multi_slot_events: MultiSlotEvents operations + :vartype multi_slot_events: azure.cognitiveservices.personalizer.operations.MultiSlotEventsOperations + :ivar multi_slot: MultiSlot operations + :vartype multi_slot: azure.cognitiveservices.personalizer.operations.MultiSlotOperations + + :param endpoint: Supported Cognitive Services endpoint. + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = PersonalizerClientv11Preview1Configuration(endpoint, credentials) + super(PersonalizerClientv11Preview1, 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 = 'v1.1-preview.1' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.service_configuration = ServiceConfigurationOperations( + self._client, self.config, self._serialize, self._deserialize) + self.policy = PolicyOperations( + self._client, self.config, self._serialize, self._deserialize) + self.evaluation = EvaluationOperations( + self._client, self.config, self._serialize, self._deserialize) + self.evaluations = EvaluationsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.events = EventsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.log = LogOperations( + self._client, self.config, self._serialize, self._deserialize) + self.model = ModelOperations( + self._client, self.config, self._serialize, self._deserialize) + self.multi_slot_events = MultiSlotEventsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.multi_slot = MultiSlotOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py index 2f33d5a2bc5e..b7787652a5e3 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py @@ -10,35 +10,106 @@ # -------------------------------------------------------------------------- try: - from .internal_error_py3 import InternalError - from .personalizer_error_py3 import PersonalizerError - from .error_response_py3 import ErrorResponse, ErrorResponseException - from .reward_request_py3 import RewardRequest - from .rankable_action_py3 import RankableAction - from .rank_request_py3 import RankRequest - from .ranked_action_py3 import RankedAction - from .rank_response_py3 import RankResponse + from ._models_py3 import ApprenticeLearningMetrics + from ._models_py3 import ApprenticeModeMetrics + from ._models_py3 import DateRange + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import Evaluation + from ._models_py3 import EvaluationContract + from ._models_py3 import InternalError + from ._models_py3 import LogsProperties + from ._models_py3 import LogsPropertiesDateRange + from ._models_py3 import ModelProperties + from ._models_py3 import MultiSlotRankRequest + from ._models_py3 import MultiSlotRankResponse + from ._models_py3 import MultiSlotRewardRequest + from ._models_py3 import PersonalizerError + from ._models_py3 import PolicyContract + from ._models_py3 import PolicyReferenceContract + from ._models_py3 import PolicyResult + from ._models_py3 import PolicyResultSummary + from ._models_py3 import PolicyResultTotalSummary + from ._models_py3 import RankableAction + from ._models_py3 import RankedAction + from ._models_py3 import RankRequest + from ._models_py3 import RankResponse + from ._models_py3 import RewardRequest + from ._models_py3 import ServiceConfiguration + from ._models_py3 import ServiceStatus + from ._models_py3 import SlotRequest + from ._models_py3 import SlotResponse + from ._models_py3 import SlotReward except (SyntaxError, ImportError): - from .internal_error import InternalError - from .personalizer_error import PersonalizerError - from .error_response import ErrorResponse, ErrorResponseException - from .reward_request import RewardRequest - from .rankable_action import RankableAction - from .rank_request import RankRequest - from .ranked_action import RankedAction - from .rank_response import RankResponse -from .personalizer_client_enums import ( - ErrorCode, + from ._models import ApprenticeLearningMetrics + from ._models import ApprenticeModeMetrics + from ._models import DateRange + from ._models import ErrorResponse, ErrorResponseException + from ._models import Evaluation + from ._models import EvaluationContract + from ._models import InternalError + from ._models import LogsProperties + from ._models import LogsPropertiesDateRange + from ._models import ModelProperties + from ._models import MultiSlotRankRequest + from ._models import MultiSlotRankResponse + from ._models import MultiSlotRewardRequest + from ._models import PersonalizerError + from ._models import PolicyContract + from ._models import PolicyReferenceContract + from ._models import PolicyResult + from ._models import PolicyResultSummary + from ._models import PolicyResultTotalSummary + from ._models import RankableAction + from ._models import RankedAction + from ._models import RankRequest + from ._models import RankResponse + from ._models import RewardRequest + from ._models import ServiceConfiguration + from ._models import ServiceStatus + from ._models import SlotRequest + from ._models import SlotResponse + from ._models import SlotReward +from ._personalizer_clientv11_preview1_enums import ( + EvaluationJobStatus, + EvaluationType, + LearningMode, + PersonalizerErrorCode, + PolicySource, ) __all__ = [ + 'ApprenticeLearningMetrics', + 'ApprenticeModeMetrics', + 'DateRange', + 'ErrorResponse', 'ErrorResponseException', + 'Evaluation', + 'EvaluationContract', 'InternalError', + 'LogsProperties', + 'LogsPropertiesDateRange', + 'ModelProperties', + 'MultiSlotRankRequest', + 'MultiSlotRankResponse', + 'MultiSlotRewardRequest', 'PersonalizerError', - 'ErrorResponse', 'ErrorResponseException', - 'RewardRequest', + 'PolicyContract', + 'PolicyReferenceContract', + 'PolicyResult', + 'PolicyResultSummary', + 'PolicyResultTotalSummary', 'RankableAction', - 'RankRequest', 'RankedAction', + 'RankRequest', 'RankResponse', - 'ErrorCode', + 'RewardRequest', + 'ServiceConfiguration', + 'ServiceStatus', + 'SlotRequest', + 'SlotResponse', + 'SlotReward', + 'LearningMode', + 'PersonalizerErrorCode', + 'PolicySource', + 'EvaluationJobStatus', + 'EvaluationType', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py new file mode 100644 index 000000000000..d1f642b153eb --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py @@ -0,0 +1,1207 @@ +# 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 ApprenticeLearningMetrics(Model): + """ApprenticeLearningMetrics. + + All required parameters must be populated in order to send to Azure. + + :param number_of_events: Required. + :type number_of_events: long + :param sum_of_rewards: Required. + :type sum_of_rewards: float + :param number_of_imitated_events: Required. + :type number_of_imitated_events: long + :param sum_of_imitated_rewards: Required. + :type sum_of_imitated_rewards: float + """ + + _validation = { + 'number_of_events': {'required': True}, + 'sum_of_rewards': {'required': True}, + 'number_of_imitated_events': {'required': True}, + 'sum_of_imitated_rewards': {'required': True}, + } + + _attribute_map = { + 'number_of_events': {'key': 'numberOfEvents', 'type': 'long'}, + 'sum_of_rewards': {'key': 'sumOfRewards', 'type': 'float'}, + 'number_of_imitated_events': {'key': 'numberOfImitatedEvents', 'type': 'long'}, + 'sum_of_imitated_rewards': {'key': 'sumOfImitatedRewards', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(ApprenticeLearningMetrics, self).__init__(**kwargs) + self.number_of_events = kwargs.get('number_of_events', None) + self.sum_of_rewards = kwargs.get('sum_of_rewards', None) + self.number_of_imitated_events = kwargs.get('number_of_imitated_events', None) + self.sum_of_imitated_rewards = kwargs.get('sum_of_imitated_rewards', None) + + +class ApprenticeModeMetrics(Model): + """ApprenticeModeMetrics. + + All required parameters must be populated in order to send to Azure. + + :param start_time: Required. + :type start_time: datetime + :param last_processed_event_time: Required. + :type last_processed_event_time: datetime + :param last_batch_metrics: + :type last_batch_metrics: + ~azure.cognitiveservices.personalizer.models.ApprenticeLearningMetrics + :param number_of_events: Required. + :type number_of_events: long + :param sum_of_rewards: Required. + :type sum_of_rewards: float + :param number_of_imitated_events: Required. + :type number_of_imitated_events: long + :param sum_of_imitated_rewards: Required. + :type sum_of_imitated_rewards: float + """ + + _validation = { + 'start_time': {'required': True}, + 'last_processed_event_time': {'required': True}, + 'number_of_events': {'required': True}, + 'sum_of_rewards': {'required': True}, + 'number_of_imitated_events': {'required': True}, + 'sum_of_imitated_rewards': {'required': True}, + } + + _attribute_map = { + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'last_processed_event_time': {'key': 'lastProcessedEventTime', 'type': 'iso-8601'}, + 'last_batch_metrics': {'key': 'lastBatchMetrics', 'type': 'ApprenticeLearningMetrics'}, + 'number_of_events': {'key': 'numberOfEvents', 'type': 'long'}, + 'sum_of_rewards': {'key': 'sumOfRewards', 'type': 'float'}, + 'number_of_imitated_events': {'key': 'numberOfImitatedEvents', 'type': 'long'}, + 'sum_of_imitated_rewards': {'key': 'sumOfImitatedRewards', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(ApprenticeModeMetrics, self).__init__(**kwargs) + self.start_time = kwargs.get('start_time', None) + self.last_processed_event_time = kwargs.get('last_processed_event_time', None) + self.last_batch_metrics = kwargs.get('last_batch_metrics', None) + self.number_of_events = kwargs.get('number_of_events', None) + self.sum_of_rewards = kwargs.get('sum_of_rewards', None) + self.number_of_imitated_events = kwargs.get('number_of_imitated_events', None) + self.sum_of_imitated_rewards = kwargs.get('sum_of_imitated_rewards', None) + + +class DateRange(Model): + """A date range starting at From and ending at To. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: Start date for the range. + :vartype from_property: datetime + :ivar to: End date for the range. + :vartype to: datetime + """ + + _validation = { + 'from_property': {'readonly': True}, + 'to': {'readonly': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(DateRange, self).__init__(**kwargs) + self.from_property = None + self.to = None + + +class ErrorResponse(Model): + """Used to return an error to the client. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. + :type error: + ~azure.cognitiveservices.personalizer.models.PersonalizerError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'PersonalizerError'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class Evaluation(Model): + """A counterfactual evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The ID of the evaluation. + :vartype id: str + :ivar name: The name of the evaluation. + :vartype name: str + :ivar start_time: The start time of the evaluation. + :vartype start_time: datetime + :ivar end_time: The end time of the evaluation. + :vartype end_time: datetime + :ivar job_id: The ID of the job processing the evaluation. + :vartype job_id: str + :ivar status: The status of the job processing the evaluation. Possible + values include: 'completed', 'pending', 'failed', 'notSubmitted', + 'timeout', 'optimalPolicyApplied', 'onlinePolicyRetained' + :vartype status: str or + ~azure.cognitiveservices.personalizer.models.EvaluationJobStatus + :param policy_results: The results of the evaluation. + :type policy_results: + list[~azure.cognitiveservices.personalizer.models.PolicyResult] + :param feature_importance: + :type feature_importance: list[list[str]] + :param evaluation_type: Possible values include: 'Manual', 'Auto' + :type evaluation_type: str or + ~azure.cognitiveservices.personalizer.models.EvaluationType + :param optimal_policy: + :type optimal_policy: str + :param creation_time: + :type creation_time: datetime + """ + + _validation = { + 'id': {'readonly': True, 'max_length': 256}, + 'name': {'readonly': True, 'max_length': 256}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + 'job_id': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'job_id': {'key': 'jobId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'policy_results': {'key': 'policyResults', 'type': '[PolicyResult]'}, + 'feature_importance': {'key': 'featureImportance', 'type': '[[str]]'}, + 'evaluation_type': {'key': 'evaluationType', 'type': 'str'}, + 'optimal_policy': {'key': 'optimalPolicy', 'type': 'str'}, + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(Evaluation, self).__init__(**kwargs) + self.id = None + self.name = None + self.start_time = None + self.end_time = None + self.job_id = None + self.status = None + self.policy_results = kwargs.get('policy_results', None) + self.feature_importance = kwargs.get('feature_importance', None) + self.evaluation_type = kwargs.get('evaluation_type', None) + self.optimal_policy = kwargs.get('optimal_policy', None) + self.creation_time = kwargs.get('creation_time', None) + + +class EvaluationContract(Model): + """A counterfactual evaluation. + + All required parameters must be populated in order to send to Azure. + + :param enable_offline_experimentation: True if the evaluation should + explore for a more optimal learning settings. + :type enable_offline_experimentation: bool + :param name: Required. The name of the evaluation. + :type name: str + :param start_time: Required. The start time of the evaluation. + :type start_time: datetime + :param end_time: Required. The end time of the evaluation. + :type end_time: datetime + :param policies: Required. Additional learning settings to evaluate. + :type policies: + list[~azure.cognitiveservices.personalizer.models.PolicyContract] + """ + + _validation = { + 'name': {'required': True, 'max_length': 256}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + 'policies': {'required': True}, + } + + _attribute_map = { + 'enable_offline_experimentation': {'key': 'enableOfflineExperimentation', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'policies': {'key': 'policies', 'type': '[PolicyContract]'}, + } + + def __init__(self, **kwargs): + super(EvaluationContract, self).__init__(**kwargs) + self.enable_offline_experimentation = kwargs.get('enable_offline_experimentation', None) + self.name = kwargs.get('name', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.policies = kwargs.get('policies', None) + + +class InternalError(Model): + """An object containing more specific information than the parent object about + the error. + + :param code: Detailed error code. + :type code: str + :param innererror: + :type innererror: + ~azure.cognitiveservices.personalizer.models.InternalError + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'innererror': {'key': 'innererror', 'type': 'InternalError'}, + } + + def __init__(self, **kwargs): + super(InternalError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.innererror = kwargs.get('innererror', None) + + +class LogsProperties(Model): + """Properties related to data used to train the model. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar date_range: + :vartype date_range: + ~azure.cognitiveservices.personalizer.models.LogsPropertiesDateRange + """ + + _validation = { + 'date_range': {'readonly': True}, + } + + _attribute_map = { + 'date_range': {'key': 'dateRange', 'type': 'LogsPropertiesDateRange'}, + } + + def __init__(self, **kwargs): + super(LogsProperties, self).__init__(**kwargs) + self.date_range = None + + +class LogsPropertiesDateRange(DateRange): + """LogsPropertiesDateRange. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: Start date for the range. + :vartype from_property: datetime + :ivar to: End date for the range. + :vartype to: datetime + """ + + _validation = { + 'from_property': {'readonly': True}, + 'to': {'readonly': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(LogsPropertiesDateRange, self).__init__(**kwargs) + + +class ModelProperties(Model): + """Properties related to the trained model. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar creation_time: Creation time of the model. + :vartype creation_time: datetime + :ivar last_modified_time: Last time the model was modified. + :vartype last_modified_time: datetime + """ + + _validation = { + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + } + + _attribute_map = { + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ModelProperties, self).__init__(**kwargs) + self.creation_time = None + self.last_modified_time = None + + +class MultiSlotRankRequest(Model): + """MultiSlotRankRequest. + + All required parameters must be populated in order to send to Azure. + + :param context_features: Features of the context used for Personalizer as + a + dictionary of dictionaries. This is determined by your application, and + typically includes features about the current user, their + device, profile information, aggregated data about time and date, etc. + Features should not include personally identifiable information (PII), + unique UserIDs, or precise timestamps. + :type context_features: list[object] + :param actions: Required. The set of actions the Personalizer service can + pick from. + The set should not contain more than 50 actions. + The order of the actions does not affect the rank result but the order + should match the sequence your application would have used to display + them. + The first item in the array will be used as Baseline item in Offline + Evaluations. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param slots: Required. The set of slots the Personalizer service should + select actions for. + The set should not contain more than 50 slots. + :type slots: + list[~azure.cognitiveservices.personalizer.models.SlotRequest] + :param event_id: Optionally pass an eventId that uniquely identifies this + Rank event. + If null, the service generates a unique eventId. The eventId will be used + for + associating this request with its reward, as well as seeding the + pseudo-random + generator when making a Personalizer call. + :type event_id: str + :param defer_activation: Send false if it is certain the rewardActionId in + rank results will be shown to the user, therefore + Personalizer will expect a Reward call, otherwise it will assign the + default + Reward to the event. Send true if it is possible the user will not see the + action specified in the rank results, + (e.g. because the page is rendering later, or the Rank results may be + overridden by code further downstream). + You must call the Activate Event API if the event output is shown to + users, otherwise Rewards will be ignored. Default value: False . + :type defer_activation: bool + """ + + _validation = { + 'actions': {'required': True}, + 'slots': {'required': True}, + 'event_id': {'max_length': 256}, + } + + _attribute_map = { + 'context_features': {'key': 'contextFeatures', 'type': '[object]'}, + 'actions': {'key': 'actions', 'type': '[RankableAction]'}, + 'slots': {'key': 'slots', 'type': '[SlotRequest]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'defer_activation': {'key': 'deferActivation', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(MultiSlotRankRequest, self).__init__(**kwargs) + self.context_features = kwargs.get('context_features', None) + self.actions = kwargs.get('actions', None) + self.slots = kwargs.get('slots', None) + self.event_id = kwargs.get('event_id', None) + self.defer_activation = kwargs.get('defer_activation', False) + + +class MultiSlotRankResponse(Model): + """MultiSlotRankResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar slots: Each slot has a corresponding rewardActionID which is the + action ID recommended by Personalizer. + :vartype slots: + list[~azure.cognitiveservices.personalizer.models.SlotResponse] + :ivar event_id: The eventId for the round trip from request to response. + :vartype event_id: str + """ + + _validation = { + 'slots': {'readonly': True}, + 'event_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'slots': {'key': 'slots', 'type': '[SlotResponse]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(MultiSlotRankResponse, self).__init__(**kwargs) + self.slots = None + self.event_id = None + + +class MultiSlotRewardRequest(Model): + """Reward given to a list of slots. + + All required parameters must be populated in order to send to Azure. + + :param reward: Required. + :type reward: + list[~azure.cognitiveservices.personalizer.models.SlotReward] + """ + + _validation = { + 'reward': {'required': True}, + } + + _attribute_map = { + 'reward': {'key': 'reward', 'type': '[SlotReward]'}, + } + + def __init__(self, **kwargs): + super(MultiSlotRewardRequest, self).__init__(**kwargs) + self.reward = kwargs.get('reward', None) + + +class PersonalizerError(Model): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Error Codes returned by Personalizer. Possible + values include: 'BadRequest', 'InvalidServiceConfiguration', + 'InvalidLearningModeServiceConfiguration', 'InvalidPolicyConfiguration', + 'InvalidPolicyContract', 'InvalidEvaluationContract', + 'DuplicateCustomPolicyNames', 'NoLogsExistInDateRange', + 'LogsSizeExceedAllowedLimit', 'InvalidRewardRequest', + 'InvalidEventIdToActivate', 'InvalidRankRequest', + 'InvalidExportLogsRequest', 'InvalidContainer', 'InvalidModelMetadata', + 'ApprenticeModeNeverTurnedOn', 'MissingAppId', 'InvalidRewardWaitTime', + 'InvalidMultiSlotApiAccess', 'ModelFileAccessDenied', + 'ProblemTypeIncompatibleWithAutoOptimization', 'ResourceNotFound', + 'FrontEndNotFound', 'EvaluationNotFound', 'LearningSettingsNotFound', + 'EvaluationModelNotFound', 'LogsPropertiesNotFound', 'ModelRankingError', + 'InternalServerError', 'RankNullResponse', 'UpdateConfigurationFailed', + 'ModelResetFailed', 'ModelPublishFailed', 'ModelMetadataUpdateFailed', + 'OperationNotAllowed' + :type code: str or + ~azure.cognitiveservices.personalizer.models.PersonalizerErrorCode + :param message: Required. A message explaining the error reported by the + service. + :type message: str + :param target: Error source element. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.personalizer.models.PersonalizerError] + :param inner_error: + :type inner_error: + ~azure.cognitiveservices.personalizer.models.InternalError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[PersonalizerError]'}, + 'inner_error': {'key': 'innerError', 'type': 'InternalError'}, + } + + def __init__(self, **kwargs): + super(PersonalizerError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + self.inner_error = kwargs.get('inner_error', None) + + +class PolicyContract(Model): + """Learning settings specifying how to train the model. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the learning settings. + :type name: str + :param arguments: Required. Arguments of the learning settings. + :type arguments: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 256}, + 'arguments': {'required': True, 'max_length': 1024}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PolicyContract, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.arguments = kwargs.get('arguments', None) + + +class PolicyReferenceContract(Model): + """Reference to the policy within the evaluation. + + All required parameters must be populated in order to send to Azure. + + :param evaluation_id: Required. Evaluation Id of the evaluation. + :type evaluation_id: str + :param policy_name: Required. Name of the learning settings. + :type policy_name: str + """ + + _validation = { + 'evaluation_id': {'required': True, 'max_length': 256}, + 'policy_name': {'required': True, 'max_length': 256}, + } + + _attribute_map = { + 'evaluation_id': {'key': 'evaluationId', 'type': 'str'}, + 'policy_name': {'key': 'policyName', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PolicyReferenceContract, self).__init__(**kwargs) + self.evaluation_id = kwargs.get('evaluation_id', None) + self.policy_name = kwargs.get('policy_name', None) + + +class PolicyResult(Model): + """This class contains the Learning Settings information and the results of + the Offline Evaluation using that policy. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: The name of the Learning Settings. + :vartype name: str + :ivar arguments: The arguments of the Learning Settings. + :vartype arguments: str + :ivar policy_source: The source of the Learning Settings. Possible values + include: 'Online', 'Baseline', 'Random', 'Custom', + 'OfflineExperimentation' + :vartype policy_source: str or + ~azure.cognitiveservices.personalizer.models.PolicySource + :ivar summary: The aggregate results of the Offline Evaluation. + :vartype summary: + list[~azure.cognitiveservices.personalizer.models.PolicyResultSummary] + :ivar total_summary: + :vartype total_summary: + ~azure.cognitiveservices.personalizer.models.PolicyResultTotalSummary + """ + + _validation = { + 'name': {'readonly': True}, + 'arguments': {'readonly': True}, + 'policy_source': {'readonly': True}, + 'summary': {'readonly': True}, + 'total_summary': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'policy_source': {'key': 'policySource', 'type': 'str'}, + 'summary': {'key': 'summary', 'type': '[PolicyResultSummary]'}, + 'total_summary': {'key': 'totalSummary', 'type': 'PolicyResultTotalSummary'}, + } + + def __init__(self, **kwargs): + super(PolicyResult, self).__init__(**kwargs) + self.name = None + self.arguments = None + self.policy_source = None + self.summary = None + self.total_summary = None + + +class PolicyResultSummary(Model): + """This class contains the summary of evaluating a policy on a counterfactual + evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: Timestamp of the aggregation. + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: Numerator for IPS estimator. + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: Denominator for IPS estimator. + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: Denominator for SNIPS estimator. + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: Time window for aggregation. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :vartype aggregate_time_window: timedelta + :param non_zero_probability: Probability of non-zero values for the Policy + evaluation. + :type non_zero_probability: float + :ivar sum_of_squares: Sum of Squares for the Policy evaluation results. + :vartype sum_of_squares: float + :ivar confidence_interval: Gaussian confidence interval for the Policy + evaluation. + :vartype confidence_interval: float + :ivar average_reward: Average reward. + :vartype average_reward: float + """ + + _validation = { + 'time_stamp': {'readonly': True}, + 'ips_estimator_numerator': {'readonly': True}, + 'ips_estimator_denominator': {'readonly': True}, + 'snips_estimator_denominator': {'readonly': True}, + 'aggregate_time_window': {'readonly': True}, + 'sum_of_squares': {'readonly': True}, + 'confidence_interval': {'readonly': True}, + 'average_reward': {'readonly': True}, + } + + _attribute_map = { + 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, + 'ips_estimator_numerator': {'key': 'ipsEstimatorNumerator', 'type': 'float'}, + 'ips_estimator_denominator': {'key': 'ipsEstimatorDenominator', 'type': 'float'}, + 'snips_estimator_denominator': {'key': 'snipsEstimatorDenominator', 'type': 'float'}, + 'aggregate_time_window': {'key': 'aggregateTimeWindow', 'type': 'duration'}, + 'non_zero_probability': {'key': 'nonZeroProbability', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', 'type': 'float'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'average_reward': {'key': 'averageReward', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(PolicyResultSummary, self).__init__(**kwargs) + self.time_stamp = None + self.ips_estimator_numerator = None + self.ips_estimator_denominator = None + self.snips_estimator_denominator = None + self.aggregate_time_window = None + self.non_zero_probability = kwargs.get('non_zero_probability', None) + self.sum_of_squares = None + self.confidence_interval = None + self.average_reward = None + + +class PolicyResultTotalSummary(PolicyResultSummary): + """PolicyResultTotalSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: Timestamp of the aggregation. + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: Numerator for IPS estimator. + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: Denominator for IPS estimator. + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: Denominator for SNIPS estimator. + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: Time window for aggregation. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :vartype aggregate_time_window: timedelta + :param non_zero_probability: Probability of non-zero values for the Policy + evaluation. + :type non_zero_probability: float + :ivar sum_of_squares: Sum of Squares for the Policy evaluation results. + :vartype sum_of_squares: float + :ivar confidence_interval: Gaussian confidence interval for the Policy + evaluation. + :vartype confidence_interval: float + :ivar average_reward: Average reward. + :vartype average_reward: float + """ + + _validation = { + 'time_stamp': {'readonly': True}, + 'ips_estimator_numerator': {'readonly': True}, + 'ips_estimator_denominator': {'readonly': True}, + 'snips_estimator_denominator': {'readonly': True}, + 'aggregate_time_window': {'readonly': True}, + 'sum_of_squares': {'readonly': True}, + 'confidence_interval': {'readonly': True}, + 'average_reward': {'readonly': True}, + } + + _attribute_map = { + 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, + 'ips_estimator_numerator': {'key': 'ipsEstimatorNumerator', 'type': 'float'}, + 'ips_estimator_denominator': {'key': 'ipsEstimatorDenominator', 'type': 'float'}, + 'snips_estimator_denominator': {'key': 'snipsEstimatorDenominator', 'type': 'float'}, + 'aggregate_time_window': {'key': 'aggregateTimeWindow', 'type': 'duration'}, + 'non_zero_probability': {'key': 'nonZeroProbability', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', 'type': 'float'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'average_reward': {'key': 'averageReward', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(PolicyResultTotalSummary, self).__init__(**kwargs) + + +class RankableAction(Model): + """An action with its associated features used for ranking. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Id of the action. + :type id: str + :param features: Required. List of dictionaries containing features. + :type features: list[object] + """ + + _validation = { + 'id': {'required': True, 'max_length': 256}, + 'features': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'features': {'key': 'features', 'type': '[object]'}, + } + + def __init__(self, **kwargs): + super(RankableAction, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.features = kwargs.get('features', None) + + +class RankedAction(Model): + """A ranked action with its resulting probability. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Id of the action + :vartype id: str + :ivar probability: Probability of the action + :vartype probability: float + """ + + _validation = { + 'id': {'readonly': True, 'max_length': 256}, + 'probability': {'readonly': True, 'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'probability': {'key': 'probability', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(RankedAction, self).__init__(**kwargs) + self.id = None + self.probability = None + + +class RankRequest(Model): + """Request a set of actions to be ranked by the Personalizer service. + + All required parameters must be populated in order to send to Azure. + + :param context_features: Features of the context used for Personalizer as + a + dictionary of dictionaries. This is determined by your application, and + typically includes features about the current user, their + device, profile information, aggregated data about time and date, etc. + Features should not include personally identifiable information (PII), + unique UserIDs, or precise timestamps. + :type context_features: list[object] + :param actions: Required. The set of actions the Personalizer service can + pick from. + The set should not contain more than 50 actions. + The order of the actions does not affect the rank result but the order + should match the sequence your application would have used to display + them. + The first item in the array will be used as Baseline item in Offline + Evaluations. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param excluded_actions: The set of action ids to exclude from ranking. + Personalizer will consider the first non-excluded item in the array as the + Baseline action when performing Offline Evaluations. + :type excluded_actions: list[str] + :param event_id: Optionally pass an eventId that uniquely identifies this + Rank event. + If null, the service generates a unique eventId. The eventId will be used + for + associating this request with its reward, as well as seeding the + pseudo-random + generator when making a Personalizer call. + :type event_id: str + :param defer_activation: Send false if it is certain the rewardActionId in + rank results will be shown to the user, therefore + Personalizer will expect a Reward call, otherwise it will assign the + default + Reward to the event. Send true if it is possible the user will not see the + action specified in the rank results, + (e.g. because the page is rendering later, or the Rank results may be + overridden by code further downstream). + You must call the Activate Event API if the event output is shown to + users, otherwise Rewards will be ignored. Default value: False . + :type defer_activation: bool + """ + + _validation = { + 'actions': {'required': True}, + 'event_id': {'max_length': 256}, + } + + _attribute_map = { + 'context_features': {'key': 'contextFeatures', 'type': '[object]'}, + 'actions': {'key': 'actions', 'type': '[RankableAction]'}, + 'excluded_actions': {'key': 'excludedActions', 'type': '[str]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'defer_activation': {'key': 'deferActivation', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(RankRequest, self).__init__(**kwargs) + self.context_features = kwargs.get('context_features', None) + self.actions = kwargs.get('actions', None) + self.excluded_actions = kwargs.get('excluded_actions', None) + self.event_id = kwargs.get('event_id', None) + self.defer_activation = kwargs.get('defer_activation', False) + + +class RankResponse(Model): + """Returns which action to use as rewardActionId, and additional information + about each action as a result of a Rank request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar ranking: The calculated ranking for the current request. + :vartype ranking: + list[~azure.cognitiveservices.personalizer.models.RankedAction] + :ivar event_id: The eventId for the round trip from request to response. + :vartype event_id: str + :ivar reward_action_id: The action chosen by the Personalizer service. + This is the action your application should display, and for which to + report the reward. + This might not be the first found in 'ranking'. + :vartype reward_action_id: str + """ + + _validation = { + 'ranking': {'readonly': True}, + 'event_id': {'readonly': True, 'max_length': 256}, + 'reward_action_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'ranking': {'key': 'ranking', 'type': '[RankedAction]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'reward_action_id': {'key': 'rewardActionId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(RankResponse, self).__init__(**kwargs) + self.ranking = None + self.event_id = None + self.reward_action_id = None + + +class RewardRequest(Model): + """Reward given to a rank response. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. Reward to be assigned to an action. Value is a + float calculated by your application, typically between 0 and 1, and must + be between -1 and 1. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(RewardRequest, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class ServiceConfiguration(Model): + """The configuration of the service. + + All required parameters must be populated in order to send to Azure. + + :param reward_wait_time: Required. The time span waited until a request is + marked with the default reward + and should be between 5 seconds and 2 days. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :type reward_wait_time: timedelta + :param default_reward: Required. The reward given if a reward is not + received within the specified wait time. + :type default_reward: float + :param reward_aggregation: Required. The function used to process rewards, + if multiple reward scores are received before rewardWaitTime is over. + :type reward_aggregation: str + :param exploration_percentage: Required. The percentage of rank responses + that will use exploration. + :type exploration_percentage: float + :param model_export_frequency: Required. Personalizer will start using the + most updated trained model for online ranks automatically every specified + time period. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :type model_export_frequency: timedelta + :param log_mirror_enabled: Flag indicates whether log mirroring is + enabled. + :type log_mirror_enabled: bool + :param log_mirror_sas_uri: Azure storage account container SAS URI for log + mirroring. + :type log_mirror_sas_uri: str + :param log_retention_days: Required. Number of days historical logs are to + be maintained. -1 implies the logs will never be deleted. + :type log_retention_days: int + :param last_configuration_edit_date: Last time model training + configuration was updated + :type last_configuration_edit_date: datetime + :param learning_mode: Learning Modes for Personalizer. Possible values + include: 'Online', 'Apprentice', 'LoggingOnly' + :type learning_mode: str or + ~azure.cognitiveservices.personalizer.models.LearningMode + :param latest_apprentice_mode_metrics: + :type latest_apprentice_mode_metrics: + ~azure.cognitiveservices.personalizer.models.ApprenticeModeMetrics + :param is_auto_optimization_enabled: Flag indicating whether Personalizer + will automatically optimize Learning Settings by running Offline + Evaluations periodically. + :type is_auto_optimization_enabled: bool + :param auto_optimization_frequency: Frequency of automatic optimization. + Only relevant if IsAutoOptimizationEnabled is true. + For example, PT5M (5 mins). For information about the time format, + \\r\\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations + :type auto_optimization_frequency: timedelta + :param auto_optimization_start_date: Date when the first automatic + optimization evaluation must be performed. Only relevant if + IsAutoOptimizationEnabled is true. + :type auto_optimization_start_date: datetime + """ + + _validation = { + 'reward_wait_time': {'required': True}, + 'default_reward': {'required': True, 'maximum': 1, 'minimum': -1}, + 'reward_aggregation': {'required': True, 'max_length': 256}, + 'exploration_percentage': {'required': True, 'maximum': 1, 'minimum': 0}, + 'model_export_frequency': {'required': True}, + 'log_retention_days': {'required': True, 'maximum': 2147483647, 'minimum': -1}, + } + + _attribute_map = { + 'reward_wait_time': {'key': 'rewardWaitTime', 'type': 'duration'}, + 'default_reward': {'key': 'defaultReward', 'type': 'float'}, + 'reward_aggregation': {'key': 'rewardAggregation', 'type': 'str'}, + 'exploration_percentage': {'key': 'explorationPercentage', 'type': 'float'}, + 'model_export_frequency': {'key': 'modelExportFrequency', 'type': 'duration'}, + 'log_mirror_enabled': {'key': 'logMirrorEnabled', 'type': 'bool'}, + 'log_mirror_sas_uri': {'key': 'logMirrorSasUri', 'type': 'str'}, + 'log_retention_days': {'key': 'logRetentionDays', 'type': 'int'}, + 'last_configuration_edit_date': {'key': 'lastConfigurationEditDate', 'type': 'iso-8601'}, + 'learning_mode': {'key': 'learningMode', 'type': 'str'}, + 'latest_apprentice_mode_metrics': {'key': 'latestApprenticeModeMetrics', 'type': 'ApprenticeModeMetrics'}, + 'is_auto_optimization_enabled': {'key': 'isAutoOptimizationEnabled', 'type': 'bool'}, + 'auto_optimization_frequency': {'key': 'autoOptimizationFrequency', 'type': 'duration'}, + 'auto_optimization_start_date': {'key': 'autoOptimizationStartDate', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ServiceConfiguration, self).__init__(**kwargs) + self.reward_wait_time = kwargs.get('reward_wait_time', None) + self.default_reward = kwargs.get('default_reward', None) + self.reward_aggregation = kwargs.get('reward_aggregation', None) + self.exploration_percentage = kwargs.get('exploration_percentage', None) + self.model_export_frequency = kwargs.get('model_export_frequency', None) + self.log_mirror_enabled = kwargs.get('log_mirror_enabled', None) + self.log_mirror_sas_uri = kwargs.get('log_mirror_sas_uri', None) + self.log_retention_days = kwargs.get('log_retention_days', None) + self.last_configuration_edit_date = kwargs.get('last_configuration_edit_date', None) + self.learning_mode = kwargs.get('learning_mode', None) + self.latest_apprentice_mode_metrics = kwargs.get('latest_apprentice_mode_metrics', None) + self.is_auto_optimization_enabled = kwargs.get('is_auto_optimization_enabled', None) + self.auto_optimization_frequency = kwargs.get('auto_optimization_frequency', None) + self.auto_optimization_start_date = kwargs.get('auto_optimization_start_date', None) + + +class ServiceStatus(Model): + """ServiceStatus. + + :param service: + :type service: str + :param api_status: + :type api_status: str + :param api_status_message: + :type api_status_message: str + """ + + _attribute_map = { + 'service': {'key': 'service', 'type': 'str'}, + 'api_status': {'key': 'apiStatus', 'type': 'str'}, + 'api_status_message': {'key': 'apiStatusMessage', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ServiceStatus, self).__init__(**kwargs) + self.service = kwargs.get('service', None) + self.api_status = kwargs.get('api_status', None) + self.api_status_message = kwargs.get('api_status_message', None) + + +class SlotRequest(Model): + """A slot with it's associated features and list of excluded actions. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Slot ID + :type id: str + :param features: List of dictionaries containing slot features. + :type features: list[object] + :param excluded_actions: List of excluded action Ids. + :type excluded_actions: list[str] + :param baseline_action: Required. The 'baseline action' ID for the slot. + The BaselineAction is the Id of the Action your application would use in + that slot if Personalizer didn't exist. + BaselineAction must be defined for every slot. + BaselineAction should never be part of ExcludedActions. + Each slot must have a unique BaselineAction which corresponds to an an + action from the event's Actions list. + :type baseline_action: str + """ + + _validation = { + 'id': {'required': True}, + 'baseline_action': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'features': {'key': 'features', 'type': '[object]'}, + 'excluded_actions': {'key': 'excludedActions', 'type': '[str]'}, + 'baseline_action': {'key': 'baselineAction', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SlotRequest, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.features = kwargs.get('features', None) + self.excluded_actions = kwargs.get('excluded_actions', None) + self.baseline_action = kwargs.get('baseline_action', None) + + +class SlotResponse(Model): + """SlotResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Id is the slot ID. + :type id: str + :ivar reward_action_id: RewardActionID is the action ID recommended by + Personalizer. + :vartype reward_action_id: str + """ + + _validation = { + 'id': {'required': True, 'max_length': 256}, + 'reward_action_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'reward_action_id': {'key': 'rewardActionId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SlotResponse, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.reward_action_id = None + + +class SlotReward(Model): + """SlotReward. + + All required parameters must be populated in order to send to Azure. + + :param slot_id: Required. Slot id for which we are sending the reward. + :type slot_id: str + :param value: Required. Reward to be assigned to slotId. Value should be + between -1 and 1 inclusive. + :type value: float + """ + + _validation = { + 'slot_id': {'required': True, 'max_length': 256, 'min_length': 1}, + 'value': {'required': True}, + } + + _attribute_map = { + 'slot_id': {'key': 'slotId', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(SlotReward, self).__init__(**kwargs) + self.slot_id = kwargs.get('slot_id', None) + self.value = kwargs.get('value', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py new file mode 100644 index 000000000000..00083a740afb --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py @@ -0,0 +1,1207 @@ +# 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 ApprenticeLearningMetrics(Model): + """ApprenticeLearningMetrics. + + All required parameters must be populated in order to send to Azure. + + :param number_of_events: Required. + :type number_of_events: long + :param sum_of_rewards: Required. + :type sum_of_rewards: float + :param number_of_imitated_events: Required. + :type number_of_imitated_events: long + :param sum_of_imitated_rewards: Required. + :type sum_of_imitated_rewards: float + """ + + _validation = { + 'number_of_events': {'required': True}, + 'sum_of_rewards': {'required': True}, + 'number_of_imitated_events': {'required': True}, + 'sum_of_imitated_rewards': {'required': True}, + } + + _attribute_map = { + 'number_of_events': {'key': 'numberOfEvents', 'type': 'long'}, + 'sum_of_rewards': {'key': 'sumOfRewards', 'type': 'float'}, + 'number_of_imitated_events': {'key': 'numberOfImitatedEvents', 'type': 'long'}, + 'sum_of_imitated_rewards': {'key': 'sumOfImitatedRewards', 'type': 'float'}, + } + + def __init__(self, *, number_of_events: int, sum_of_rewards: float, number_of_imitated_events: int, sum_of_imitated_rewards: float, **kwargs) -> None: + super(ApprenticeLearningMetrics, self).__init__(**kwargs) + self.number_of_events = number_of_events + self.sum_of_rewards = sum_of_rewards + self.number_of_imitated_events = number_of_imitated_events + self.sum_of_imitated_rewards = sum_of_imitated_rewards + + +class ApprenticeModeMetrics(Model): + """ApprenticeModeMetrics. + + All required parameters must be populated in order to send to Azure. + + :param start_time: Required. + :type start_time: datetime + :param last_processed_event_time: Required. + :type last_processed_event_time: datetime + :param last_batch_metrics: + :type last_batch_metrics: + ~azure.cognitiveservices.personalizer.models.ApprenticeLearningMetrics + :param number_of_events: Required. + :type number_of_events: long + :param sum_of_rewards: Required. + :type sum_of_rewards: float + :param number_of_imitated_events: Required. + :type number_of_imitated_events: long + :param sum_of_imitated_rewards: Required. + :type sum_of_imitated_rewards: float + """ + + _validation = { + 'start_time': {'required': True}, + 'last_processed_event_time': {'required': True}, + 'number_of_events': {'required': True}, + 'sum_of_rewards': {'required': True}, + 'number_of_imitated_events': {'required': True}, + 'sum_of_imitated_rewards': {'required': True}, + } + + _attribute_map = { + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'last_processed_event_time': {'key': 'lastProcessedEventTime', 'type': 'iso-8601'}, + 'last_batch_metrics': {'key': 'lastBatchMetrics', 'type': 'ApprenticeLearningMetrics'}, + 'number_of_events': {'key': 'numberOfEvents', 'type': 'long'}, + 'sum_of_rewards': {'key': 'sumOfRewards', 'type': 'float'}, + 'number_of_imitated_events': {'key': 'numberOfImitatedEvents', 'type': 'long'}, + 'sum_of_imitated_rewards': {'key': 'sumOfImitatedRewards', 'type': 'float'}, + } + + def __init__(self, *, start_time, last_processed_event_time, number_of_events: int, sum_of_rewards: float, number_of_imitated_events: int, sum_of_imitated_rewards: float, last_batch_metrics=None, **kwargs) -> None: + super(ApprenticeModeMetrics, self).__init__(**kwargs) + self.start_time = start_time + self.last_processed_event_time = last_processed_event_time + self.last_batch_metrics = last_batch_metrics + self.number_of_events = number_of_events + self.sum_of_rewards = sum_of_rewards + self.number_of_imitated_events = number_of_imitated_events + self.sum_of_imitated_rewards = sum_of_imitated_rewards + + +class DateRange(Model): + """A date range starting at From and ending at To. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: Start date for the range. + :vartype from_property: datetime + :ivar to: End date for the range. + :vartype to: datetime + """ + + _validation = { + 'from_property': {'readonly': True}, + 'to': {'readonly': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs) -> None: + super(DateRange, self).__init__(**kwargs) + self.from_property = None + self.to = None + + +class ErrorResponse(Model): + """Used to return an error to the client. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. + :type error: + ~azure.cognitiveservices.personalizer.models.PersonalizerError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'PersonalizerError'}, + } + + def __init__(self, *, error, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class Evaluation(Model): + """A counterfactual evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The ID of the evaluation. + :vartype id: str + :ivar name: The name of the evaluation. + :vartype name: str + :ivar start_time: The start time of the evaluation. + :vartype start_time: datetime + :ivar end_time: The end time of the evaluation. + :vartype end_time: datetime + :ivar job_id: The ID of the job processing the evaluation. + :vartype job_id: str + :ivar status: The status of the job processing the evaluation. Possible + values include: 'completed', 'pending', 'failed', 'notSubmitted', + 'timeout', 'optimalPolicyApplied', 'onlinePolicyRetained' + :vartype status: str or + ~azure.cognitiveservices.personalizer.models.EvaluationJobStatus + :param policy_results: The results of the evaluation. + :type policy_results: + list[~azure.cognitiveservices.personalizer.models.PolicyResult] + :param feature_importance: + :type feature_importance: list[list[str]] + :param evaluation_type: Possible values include: 'Manual', 'Auto' + :type evaluation_type: str or + ~azure.cognitiveservices.personalizer.models.EvaluationType + :param optimal_policy: + :type optimal_policy: str + :param creation_time: + :type creation_time: datetime + """ + + _validation = { + 'id': {'readonly': True, 'max_length': 256}, + 'name': {'readonly': True, 'max_length': 256}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + 'job_id': {'readonly': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'job_id': {'key': 'jobId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'policy_results': {'key': 'policyResults', 'type': '[PolicyResult]'}, + 'feature_importance': {'key': 'featureImportance', 'type': '[[str]]'}, + 'evaluation_type': {'key': 'evaluationType', 'type': 'str'}, + 'optimal_policy': {'key': 'optimalPolicy', 'type': 'str'}, + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, policy_results=None, feature_importance=None, evaluation_type=None, optimal_policy: str=None, creation_time=None, **kwargs) -> None: + super(Evaluation, self).__init__(**kwargs) + self.id = None + self.name = None + self.start_time = None + self.end_time = None + self.job_id = None + self.status = None + self.policy_results = policy_results + self.feature_importance = feature_importance + self.evaluation_type = evaluation_type + self.optimal_policy = optimal_policy + self.creation_time = creation_time + + +class EvaluationContract(Model): + """A counterfactual evaluation. + + All required parameters must be populated in order to send to Azure. + + :param enable_offline_experimentation: True if the evaluation should + explore for a more optimal learning settings. + :type enable_offline_experimentation: bool + :param name: Required. The name of the evaluation. + :type name: str + :param start_time: Required. The start time of the evaluation. + :type start_time: datetime + :param end_time: Required. The end time of the evaluation. + :type end_time: datetime + :param policies: Required. Additional learning settings to evaluate. + :type policies: + list[~azure.cognitiveservices.personalizer.models.PolicyContract] + """ + + _validation = { + 'name': {'required': True, 'max_length': 256}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + 'policies': {'required': True}, + } + + _attribute_map = { + 'enable_offline_experimentation': {'key': 'enableOfflineExperimentation', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'policies': {'key': 'policies', 'type': '[PolicyContract]'}, + } + + def __init__(self, *, name: str, start_time, end_time, policies, enable_offline_experimentation: bool=None, **kwargs) -> None: + super(EvaluationContract, self).__init__(**kwargs) + self.enable_offline_experimentation = enable_offline_experimentation + self.name = name + self.start_time = start_time + self.end_time = end_time + self.policies = policies + + +class InternalError(Model): + """An object containing more specific information than the parent object about + the error. + + :param code: Detailed error code. + :type code: str + :param innererror: + :type innererror: + ~azure.cognitiveservices.personalizer.models.InternalError + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'innererror': {'key': 'innererror', 'type': 'InternalError'}, + } + + def __init__(self, *, code: str=None, innererror=None, **kwargs) -> None: + super(InternalError, self).__init__(**kwargs) + self.code = code + self.innererror = innererror + + +class LogsProperties(Model): + """Properties related to data used to train the model. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar date_range: + :vartype date_range: + ~azure.cognitiveservices.personalizer.models.LogsPropertiesDateRange + """ + + _validation = { + 'date_range': {'readonly': True}, + } + + _attribute_map = { + 'date_range': {'key': 'dateRange', 'type': 'LogsPropertiesDateRange'}, + } + + def __init__(self, **kwargs) -> None: + super(LogsProperties, self).__init__(**kwargs) + self.date_range = None + + +class LogsPropertiesDateRange(DateRange): + """LogsPropertiesDateRange. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: Start date for the range. + :vartype from_property: datetime + :ivar to: End date for the range. + :vartype to: datetime + """ + + _validation = { + 'from_property': {'readonly': True}, + 'to': {'readonly': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs) -> None: + super(LogsPropertiesDateRange, self).__init__(**kwargs) + + +class ModelProperties(Model): + """Properties related to the trained model. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar creation_time: Creation time of the model. + :vartype creation_time: datetime + :ivar last_modified_time: Last time the model was modified. + :vartype last_modified_time: datetime + """ + + _validation = { + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + } + + _attribute_map = { + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs) -> None: + super(ModelProperties, self).__init__(**kwargs) + self.creation_time = None + self.last_modified_time = None + + +class MultiSlotRankRequest(Model): + """MultiSlotRankRequest. + + All required parameters must be populated in order to send to Azure. + + :param context_features: Features of the context used for Personalizer as + a + dictionary of dictionaries. This is determined by your application, and + typically includes features about the current user, their + device, profile information, aggregated data about time and date, etc. + Features should not include personally identifiable information (PII), + unique UserIDs, or precise timestamps. + :type context_features: list[object] + :param actions: Required. The set of actions the Personalizer service can + pick from. + The set should not contain more than 50 actions. + The order of the actions does not affect the rank result but the order + should match the sequence your application would have used to display + them. + The first item in the array will be used as Baseline item in Offline + Evaluations. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param slots: Required. The set of slots the Personalizer service should + select actions for. + The set should not contain more than 50 slots. + :type slots: + list[~azure.cognitiveservices.personalizer.models.SlotRequest] + :param event_id: Optionally pass an eventId that uniquely identifies this + Rank event. + If null, the service generates a unique eventId. The eventId will be used + for + associating this request with its reward, as well as seeding the + pseudo-random + generator when making a Personalizer call. + :type event_id: str + :param defer_activation: Send false if it is certain the rewardActionId in + rank results will be shown to the user, therefore + Personalizer will expect a Reward call, otherwise it will assign the + default + Reward to the event. Send true if it is possible the user will not see the + action specified in the rank results, + (e.g. because the page is rendering later, or the Rank results may be + overridden by code further downstream). + You must call the Activate Event API if the event output is shown to + users, otherwise Rewards will be ignored. Default value: False . + :type defer_activation: bool + """ + + _validation = { + 'actions': {'required': True}, + 'slots': {'required': True}, + 'event_id': {'max_length': 256}, + } + + _attribute_map = { + 'context_features': {'key': 'contextFeatures', 'type': '[object]'}, + 'actions': {'key': 'actions', 'type': '[RankableAction]'}, + 'slots': {'key': 'slots', 'type': '[SlotRequest]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'defer_activation': {'key': 'deferActivation', 'type': 'bool'}, + } + + def __init__(self, *, actions, slots, context_features=None, event_id: str=None, defer_activation: bool=False, **kwargs) -> None: + super(MultiSlotRankRequest, self).__init__(**kwargs) + self.context_features = context_features + self.actions = actions + self.slots = slots + self.event_id = event_id + self.defer_activation = defer_activation + + +class MultiSlotRankResponse(Model): + """MultiSlotRankResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar slots: Each slot has a corresponding rewardActionID which is the + action ID recommended by Personalizer. + :vartype slots: + list[~azure.cognitiveservices.personalizer.models.SlotResponse] + :ivar event_id: The eventId for the round trip from request to response. + :vartype event_id: str + """ + + _validation = { + 'slots': {'readonly': True}, + 'event_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'slots': {'key': 'slots', 'type': '[SlotResponse]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(MultiSlotRankResponse, self).__init__(**kwargs) + self.slots = None + self.event_id = None + + +class MultiSlotRewardRequest(Model): + """Reward given to a list of slots. + + All required parameters must be populated in order to send to Azure. + + :param reward: Required. + :type reward: + list[~azure.cognitiveservices.personalizer.models.SlotReward] + """ + + _validation = { + 'reward': {'required': True}, + } + + _attribute_map = { + 'reward': {'key': 'reward', 'type': '[SlotReward]'}, + } + + def __init__(self, *, reward, **kwargs) -> None: + super(MultiSlotRewardRequest, self).__init__(**kwargs) + self.reward = reward + + +class PersonalizerError(Model): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Error Codes returned by Personalizer. Possible + values include: 'BadRequest', 'InvalidServiceConfiguration', + 'InvalidLearningModeServiceConfiguration', 'InvalidPolicyConfiguration', + 'InvalidPolicyContract', 'InvalidEvaluationContract', + 'DuplicateCustomPolicyNames', 'NoLogsExistInDateRange', + 'LogsSizeExceedAllowedLimit', 'InvalidRewardRequest', + 'InvalidEventIdToActivate', 'InvalidRankRequest', + 'InvalidExportLogsRequest', 'InvalidContainer', 'InvalidModelMetadata', + 'ApprenticeModeNeverTurnedOn', 'MissingAppId', 'InvalidRewardWaitTime', + 'InvalidMultiSlotApiAccess', 'ModelFileAccessDenied', + 'ProblemTypeIncompatibleWithAutoOptimization', 'ResourceNotFound', + 'FrontEndNotFound', 'EvaluationNotFound', 'LearningSettingsNotFound', + 'EvaluationModelNotFound', 'LogsPropertiesNotFound', 'ModelRankingError', + 'InternalServerError', 'RankNullResponse', 'UpdateConfigurationFailed', + 'ModelResetFailed', 'ModelPublishFailed', 'ModelMetadataUpdateFailed', + 'OperationNotAllowed' + :type code: str or + ~azure.cognitiveservices.personalizer.models.PersonalizerErrorCode + :param message: Required. A message explaining the error reported by the + service. + :type message: str + :param target: Error source element. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.personalizer.models.PersonalizerError] + :param inner_error: + :type inner_error: + ~azure.cognitiveservices.personalizer.models.InternalError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[PersonalizerError]'}, + 'inner_error': {'key': 'innerError', 'type': 'InternalError'}, + } + + def __init__(self, *, code, message: str, target: str=None, details=None, inner_error=None, **kwargs) -> None: + super(PersonalizerError, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + self.inner_error = inner_error + + +class PolicyContract(Model): + """Learning settings specifying how to train the model. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the learning settings. + :type name: str + :param arguments: Required. Arguments of the learning settings. + :type arguments: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 256}, + 'arguments': {'required': True, 'max_length': 1024}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + } + + def __init__(self, *, name: str, arguments: str, **kwargs) -> None: + super(PolicyContract, self).__init__(**kwargs) + self.name = name + self.arguments = arguments + + +class PolicyReferenceContract(Model): + """Reference to the policy within the evaluation. + + All required parameters must be populated in order to send to Azure. + + :param evaluation_id: Required. Evaluation Id of the evaluation. + :type evaluation_id: str + :param policy_name: Required. Name of the learning settings. + :type policy_name: str + """ + + _validation = { + 'evaluation_id': {'required': True, 'max_length': 256}, + 'policy_name': {'required': True, 'max_length': 256}, + } + + _attribute_map = { + 'evaluation_id': {'key': 'evaluationId', 'type': 'str'}, + 'policy_name': {'key': 'policyName', 'type': 'str'}, + } + + def __init__(self, *, evaluation_id: str, policy_name: str, **kwargs) -> None: + super(PolicyReferenceContract, self).__init__(**kwargs) + self.evaluation_id = evaluation_id + self.policy_name = policy_name + + +class PolicyResult(Model): + """This class contains the Learning Settings information and the results of + the Offline Evaluation using that policy. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: The name of the Learning Settings. + :vartype name: str + :ivar arguments: The arguments of the Learning Settings. + :vartype arguments: str + :ivar policy_source: The source of the Learning Settings. Possible values + include: 'Online', 'Baseline', 'Random', 'Custom', + 'OfflineExperimentation' + :vartype policy_source: str or + ~azure.cognitiveservices.personalizer.models.PolicySource + :ivar summary: The aggregate results of the Offline Evaluation. + :vartype summary: + list[~azure.cognitiveservices.personalizer.models.PolicyResultSummary] + :ivar total_summary: + :vartype total_summary: + ~azure.cognitiveservices.personalizer.models.PolicyResultTotalSummary + """ + + _validation = { + 'name': {'readonly': True}, + 'arguments': {'readonly': True}, + 'policy_source': {'readonly': True}, + 'summary': {'readonly': True}, + 'total_summary': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'policy_source': {'key': 'policySource', 'type': 'str'}, + 'summary': {'key': 'summary', 'type': '[PolicyResultSummary]'}, + 'total_summary': {'key': 'totalSummary', 'type': 'PolicyResultTotalSummary'}, + } + + def __init__(self, **kwargs) -> None: + super(PolicyResult, self).__init__(**kwargs) + self.name = None + self.arguments = None + self.policy_source = None + self.summary = None + self.total_summary = None + + +class PolicyResultSummary(Model): + """This class contains the summary of evaluating a policy on a counterfactual + evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: Timestamp of the aggregation. + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: Numerator for IPS estimator. + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: Denominator for IPS estimator. + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: Denominator for SNIPS estimator. + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: Time window for aggregation. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :vartype aggregate_time_window: timedelta + :param non_zero_probability: Probability of non-zero values for the Policy + evaluation. + :type non_zero_probability: float + :ivar sum_of_squares: Sum of Squares for the Policy evaluation results. + :vartype sum_of_squares: float + :ivar confidence_interval: Gaussian confidence interval for the Policy + evaluation. + :vartype confidence_interval: float + :ivar average_reward: Average reward. + :vartype average_reward: float + """ + + _validation = { + 'time_stamp': {'readonly': True}, + 'ips_estimator_numerator': {'readonly': True}, + 'ips_estimator_denominator': {'readonly': True}, + 'snips_estimator_denominator': {'readonly': True}, + 'aggregate_time_window': {'readonly': True}, + 'sum_of_squares': {'readonly': True}, + 'confidence_interval': {'readonly': True}, + 'average_reward': {'readonly': True}, + } + + _attribute_map = { + 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, + 'ips_estimator_numerator': {'key': 'ipsEstimatorNumerator', 'type': 'float'}, + 'ips_estimator_denominator': {'key': 'ipsEstimatorDenominator', 'type': 'float'}, + 'snips_estimator_denominator': {'key': 'snipsEstimatorDenominator', 'type': 'float'}, + 'aggregate_time_window': {'key': 'aggregateTimeWindow', 'type': 'duration'}, + 'non_zero_probability': {'key': 'nonZeroProbability', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', 'type': 'float'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'average_reward': {'key': 'averageReward', 'type': 'float'}, + } + + def __init__(self, *, non_zero_probability: float=None, **kwargs) -> None: + super(PolicyResultSummary, self).__init__(**kwargs) + self.time_stamp = None + self.ips_estimator_numerator = None + self.ips_estimator_denominator = None + self.snips_estimator_denominator = None + self.aggregate_time_window = None + self.non_zero_probability = non_zero_probability + self.sum_of_squares = None + self.confidence_interval = None + self.average_reward = None + + +class PolicyResultTotalSummary(PolicyResultSummary): + """PolicyResultTotalSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: Timestamp of the aggregation. + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: Numerator for IPS estimator. + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: Denominator for IPS estimator. + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: Denominator for SNIPS estimator. + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: Time window for aggregation. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :vartype aggregate_time_window: timedelta + :param non_zero_probability: Probability of non-zero values for the Policy + evaluation. + :type non_zero_probability: float + :ivar sum_of_squares: Sum of Squares for the Policy evaluation results. + :vartype sum_of_squares: float + :ivar confidence_interval: Gaussian confidence interval for the Policy + evaluation. + :vartype confidence_interval: float + :ivar average_reward: Average reward. + :vartype average_reward: float + """ + + _validation = { + 'time_stamp': {'readonly': True}, + 'ips_estimator_numerator': {'readonly': True}, + 'ips_estimator_denominator': {'readonly': True}, + 'snips_estimator_denominator': {'readonly': True}, + 'aggregate_time_window': {'readonly': True}, + 'sum_of_squares': {'readonly': True}, + 'confidence_interval': {'readonly': True}, + 'average_reward': {'readonly': True}, + } + + _attribute_map = { + 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, + 'ips_estimator_numerator': {'key': 'ipsEstimatorNumerator', 'type': 'float'}, + 'ips_estimator_denominator': {'key': 'ipsEstimatorDenominator', 'type': 'float'}, + 'snips_estimator_denominator': {'key': 'snipsEstimatorDenominator', 'type': 'float'}, + 'aggregate_time_window': {'key': 'aggregateTimeWindow', 'type': 'duration'}, + 'non_zero_probability': {'key': 'nonZeroProbability', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', 'type': 'float'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'average_reward': {'key': 'averageReward', 'type': 'float'}, + } + + def __init__(self, *, non_zero_probability: float=None, **kwargs) -> None: + super(PolicyResultTotalSummary, self).__init__(non_zero_probability=non_zero_probability, **kwargs) + + +class RankableAction(Model): + """An action with its associated features used for ranking. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Id of the action. + :type id: str + :param features: Required. List of dictionaries containing features. + :type features: list[object] + """ + + _validation = { + 'id': {'required': True, 'max_length': 256}, + 'features': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'features': {'key': 'features', 'type': '[object]'}, + } + + def __init__(self, *, id: str, features, **kwargs) -> None: + super(RankableAction, self).__init__(**kwargs) + self.id = id + self.features = features + + +class RankedAction(Model): + """A ranked action with its resulting probability. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Id of the action + :vartype id: str + :ivar probability: Probability of the action + :vartype probability: float + """ + + _validation = { + 'id': {'readonly': True, 'max_length': 256}, + 'probability': {'readonly': True, 'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'probability': {'key': 'probability', 'type': 'float'}, + } + + def __init__(self, **kwargs) -> None: + super(RankedAction, self).__init__(**kwargs) + self.id = None + self.probability = None + + +class RankRequest(Model): + """Request a set of actions to be ranked by the Personalizer service. + + All required parameters must be populated in order to send to Azure. + + :param context_features: Features of the context used for Personalizer as + a + dictionary of dictionaries. This is determined by your application, and + typically includes features about the current user, their + device, profile information, aggregated data about time and date, etc. + Features should not include personally identifiable information (PII), + unique UserIDs, or precise timestamps. + :type context_features: list[object] + :param actions: Required. The set of actions the Personalizer service can + pick from. + The set should not contain more than 50 actions. + The order of the actions does not affect the rank result but the order + should match the sequence your application would have used to display + them. + The first item in the array will be used as Baseline item in Offline + Evaluations. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param excluded_actions: The set of action ids to exclude from ranking. + Personalizer will consider the first non-excluded item in the array as the + Baseline action when performing Offline Evaluations. + :type excluded_actions: list[str] + :param event_id: Optionally pass an eventId that uniquely identifies this + Rank event. + If null, the service generates a unique eventId. The eventId will be used + for + associating this request with its reward, as well as seeding the + pseudo-random + generator when making a Personalizer call. + :type event_id: str + :param defer_activation: Send false if it is certain the rewardActionId in + rank results will be shown to the user, therefore + Personalizer will expect a Reward call, otherwise it will assign the + default + Reward to the event. Send true if it is possible the user will not see the + action specified in the rank results, + (e.g. because the page is rendering later, or the Rank results may be + overridden by code further downstream). + You must call the Activate Event API if the event output is shown to + users, otherwise Rewards will be ignored. Default value: False . + :type defer_activation: bool + """ + + _validation = { + 'actions': {'required': True}, + 'event_id': {'max_length': 256}, + } + + _attribute_map = { + 'context_features': {'key': 'contextFeatures', 'type': '[object]'}, + 'actions': {'key': 'actions', 'type': '[RankableAction]'}, + 'excluded_actions': {'key': 'excludedActions', 'type': '[str]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'defer_activation': {'key': 'deferActivation', 'type': 'bool'}, + } + + def __init__(self, *, actions, context_features=None, excluded_actions=None, event_id: str=None, defer_activation: bool=False, **kwargs) -> None: + super(RankRequest, self).__init__(**kwargs) + self.context_features = context_features + self.actions = actions + self.excluded_actions = excluded_actions + self.event_id = event_id + self.defer_activation = defer_activation + + +class RankResponse(Model): + """Returns which action to use as rewardActionId, and additional information + about each action as a result of a Rank request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar ranking: The calculated ranking for the current request. + :vartype ranking: + list[~azure.cognitiveservices.personalizer.models.RankedAction] + :ivar event_id: The eventId for the round trip from request to response. + :vartype event_id: str + :ivar reward_action_id: The action chosen by the Personalizer service. + This is the action your application should display, and for which to + report the reward. + This might not be the first found in 'ranking'. + :vartype reward_action_id: str + """ + + _validation = { + 'ranking': {'readonly': True}, + 'event_id': {'readonly': True, 'max_length': 256}, + 'reward_action_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'ranking': {'key': 'ranking', 'type': '[RankedAction]'}, + 'event_id': {'key': 'eventId', 'type': 'str'}, + 'reward_action_id': {'key': 'rewardActionId', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(RankResponse, self).__init__(**kwargs) + self.ranking = None + self.event_id = None + self.reward_action_id = None + + +class RewardRequest(Model): + """Reward given to a rank response. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. Reward to be assigned to an action. Value is a + float calculated by your application, typically between 0 and 1, and must + be between -1 and 1. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, value: float, **kwargs) -> None: + super(RewardRequest, self).__init__(**kwargs) + self.value = value + + +class ServiceConfiguration(Model): + """The configuration of the service. + + All required parameters must be populated in order to send to Azure. + + :param reward_wait_time: Required. The time span waited until a request is + marked with the default reward + and should be between 5 seconds and 2 days. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :type reward_wait_time: timedelta + :param default_reward: Required. The reward given if a reward is not + received within the specified wait time. + :type default_reward: float + :param reward_aggregation: Required. The function used to process rewards, + if multiple reward scores are received before rewardWaitTime is over. + :type reward_aggregation: str + :param exploration_percentage: Required. The percentage of rank responses + that will use exploration. + :type exploration_percentage: float + :param model_export_frequency: Required. Personalizer will start using the + most updated trained model for online ranks automatically every specified + time period. + For example, PT5M (5 mins). For information about the time format, + see http://en.wikipedia.org/wiki/ISO_8601#Durations + :type model_export_frequency: timedelta + :param log_mirror_enabled: Flag indicates whether log mirroring is + enabled. + :type log_mirror_enabled: bool + :param log_mirror_sas_uri: Azure storage account container SAS URI for log + mirroring. + :type log_mirror_sas_uri: str + :param log_retention_days: Required. Number of days historical logs are to + be maintained. -1 implies the logs will never be deleted. + :type log_retention_days: int + :param last_configuration_edit_date: Last time model training + configuration was updated + :type last_configuration_edit_date: datetime + :param learning_mode: Learning Modes for Personalizer. Possible values + include: 'Online', 'Apprentice', 'LoggingOnly' + :type learning_mode: str or + ~azure.cognitiveservices.personalizer.models.LearningMode + :param latest_apprentice_mode_metrics: + :type latest_apprentice_mode_metrics: + ~azure.cognitiveservices.personalizer.models.ApprenticeModeMetrics + :param is_auto_optimization_enabled: Flag indicating whether Personalizer + will automatically optimize Learning Settings by running Offline + Evaluations periodically. + :type is_auto_optimization_enabled: bool + :param auto_optimization_frequency: Frequency of automatic optimization. + Only relevant if IsAutoOptimizationEnabled is true. + For example, PT5M (5 mins). For information about the time format, + \\r\\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations + :type auto_optimization_frequency: timedelta + :param auto_optimization_start_date: Date when the first automatic + optimization evaluation must be performed. Only relevant if + IsAutoOptimizationEnabled is true. + :type auto_optimization_start_date: datetime + """ + + _validation = { + 'reward_wait_time': {'required': True}, + 'default_reward': {'required': True, 'maximum': 1, 'minimum': -1}, + 'reward_aggregation': {'required': True, 'max_length': 256}, + 'exploration_percentage': {'required': True, 'maximum': 1, 'minimum': 0}, + 'model_export_frequency': {'required': True}, + 'log_retention_days': {'required': True, 'maximum': 2147483647, 'minimum': -1}, + } + + _attribute_map = { + 'reward_wait_time': {'key': 'rewardWaitTime', 'type': 'duration'}, + 'default_reward': {'key': 'defaultReward', 'type': 'float'}, + 'reward_aggregation': {'key': 'rewardAggregation', 'type': 'str'}, + 'exploration_percentage': {'key': 'explorationPercentage', 'type': 'float'}, + 'model_export_frequency': {'key': 'modelExportFrequency', 'type': 'duration'}, + 'log_mirror_enabled': {'key': 'logMirrorEnabled', 'type': 'bool'}, + 'log_mirror_sas_uri': {'key': 'logMirrorSasUri', 'type': 'str'}, + 'log_retention_days': {'key': 'logRetentionDays', 'type': 'int'}, + 'last_configuration_edit_date': {'key': 'lastConfigurationEditDate', 'type': 'iso-8601'}, + 'learning_mode': {'key': 'learningMode', 'type': 'str'}, + 'latest_apprentice_mode_metrics': {'key': 'latestApprenticeModeMetrics', 'type': 'ApprenticeModeMetrics'}, + 'is_auto_optimization_enabled': {'key': 'isAutoOptimizationEnabled', 'type': 'bool'}, + 'auto_optimization_frequency': {'key': 'autoOptimizationFrequency', 'type': 'duration'}, + 'auto_optimization_start_date': {'key': 'autoOptimizationStartDate', 'type': 'iso-8601'}, + } + + def __init__(self, *, reward_wait_time, default_reward: float, reward_aggregation: str, exploration_percentage: float, model_export_frequency, log_retention_days: int, log_mirror_enabled: bool=None, log_mirror_sas_uri: str=None, last_configuration_edit_date=None, learning_mode=None, latest_apprentice_mode_metrics=None, is_auto_optimization_enabled: bool=None, auto_optimization_frequency=None, auto_optimization_start_date=None, **kwargs) -> None: + super(ServiceConfiguration, self).__init__(**kwargs) + self.reward_wait_time = reward_wait_time + self.default_reward = default_reward + self.reward_aggregation = reward_aggregation + self.exploration_percentage = exploration_percentage + self.model_export_frequency = model_export_frequency + self.log_mirror_enabled = log_mirror_enabled + self.log_mirror_sas_uri = log_mirror_sas_uri + self.log_retention_days = log_retention_days + self.last_configuration_edit_date = last_configuration_edit_date + self.learning_mode = learning_mode + self.latest_apprentice_mode_metrics = latest_apprentice_mode_metrics + self.is_auto_optimization_enabled = is_auto_optimization_enabled + self.auto_optimization_frequency = auto_optimization_frequency + self.auto_optimization_start_date = auto_optimization_start_date + + +class ServiceStatus(Model): + """ServiceStatus. + + :param service: + :type service: str + :param api_status: + :type api_status: str + :param api_status_message: + :type api_status_message: str + """ + + _attribute_map = { + 'service': {'key': 'service', 'type': 'str'}, + 'api_status': {'key': 'apiStatus', 'type': 'str'}, + 'api_status_message': {'key': 'apiStatusMessage', 'type': 'str'}, + } + + def __init__(self, *, service: str=None, api_status: str=None, api_status_message: str=None, **kwargs) -> None: + super(ServiceStatus, self).__init__(**kwargs) + self.service = service + self.api_status = api_status + self.api_status_message = api_status_message + + +class SlotRequest(Model): + """A slot with it's associated features and list of excluded actions. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Slot ID + :type id: str + :param features: List of dictionaries containing slot features. + :type features: list[object] + :param excluded_actions: List of excluded action Ids. + :type excluded_actions: list[str] + :param baseline_action: Required. The 'baseline action' ID for the slot. + The BaselineAction is the Id of the Action your application would use in + that slot if Personalizer didn't exist. + BaselineAction must be defined for every slot. + BaselineAction should never be part of ExcludedActions. + Each slot must have a unique BaselineAction which corresponds to an an + action from the event's Actions list. + :type baseline_action: str + """ + + _validation = { + 'id': {'required': True}, + 'baseline_action': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'features': {'key': 'features', 'type': '[object]'}, + 'excluded_actions': {'key': 'excludedActions', 'type': '[str]'}, + 'baseline_action': {'key': 'baselineAction', 'type': 'str'}, + } + + def __init__(self, *, id: str, baseline_action: str, features=None, excluded_actions=None, **kwargs) -> None: + super(SlotRequest, self).__init__(**kwargs) + self.id = id + self.features = features + self.excluded_actions = excluded_actions + self.baseline_action = baseline_action + + +class SlotResponse(Model): + """SlotResponse. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Id is the slot ID. + :type id: str + :ivar reward_action_id: RewardActionID is the action ID recommended by + Personalizer. + :vartype reward_action_id: str + """ + + _validation = { + 'id': {'required': True, 'max_length': 256}, + 'reward_action_id': {'readonly': True, 'max_length': 256}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'reward_action_id': {'key': 'rewardActionId', 'type': 'str'}, + } + + def __init__(self, *, id: str, **kwargs) -> None: + super(SlotResponse, self).__init__(**kwargs) + self.id = id + self.reward_action_id = None + + +class SlotReward(Model): + """SlotReward. + + All required parameters must be populated in order to send to Azure. + + :param slot_id: Required. Slot id for which we are sending the reward. + :type slot_id: str + :param value: Required. Reward to be assigned to slotId. Value should be + between -1 and 1 inclusive. + :type value: float + """ + + _validation = { + 'slot_id': {'required': True, 'max_length': 256, 'min_length': 1}, + 'value': {'required': True}, + } + + _attribute_map = { + 'slot_id': {'key': 'slotId', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, slot_id: str, value: float, **kwargs) -> None: + super(SlotReward, self).__init__(**kwargs) + self.slot_id = slot_id + self.value = value diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_clientv11_preview1_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_clientv11_preview1_enums.py new file mode 100644 index 000000000000..b712435cc840 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_clientv11_preview1_enums.py @@ -0,0 +1,84 @@ +# 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 enum import Enum + + +class LearningMode(str, Enum): + + online = "Online" + apprentice = "Apprentice" + logging_only = "LoggingOnly" + + +class PersonalizerErrorCode(str, Enum): + + bad_request = "BadRequest" #: Request could not be understood by the server. + invalid_service_configuration = "InvalidServiceConfiguration" #: Invalid service configuration. + invalid_learning_mode_service_configuration = "InvalidLearningModeServiceConfiguration" #: Updating defaultReward, rewardWaitTime and rewardAggregation when changing learning mode from Online to Apprentice mode and vice versa is not allowed. Make the mode change and then change the additional settings with an additional API call. + invalid_policy_configuration = "InvalidPolicyConfiguration" #: Invalid policy configuration. + invalid_policy_contract = "InvalidPolicyContract" #: Invalid policy contract. + invalid_evaluation_contract = "InvalidEvaluationContract" #: Invalid evaluation contract. + duplicate_custom_policy_names = "DuplicateCustomPolicyNames" #: Custom policy names should be unique. + no_logs_exist_in_date_range = "NoLogsExistInDateRange" #: No logs exist in date range. + logs_size_exceed_allowed_limit = "LogsSizeExceedAllowedLimit" #: Total size of logs exceed allowed limit. + invalid_reward_request = "InvalidRewardRequest" #: Invalid reward request. + invalid_event_id_to_activate = "InvalidEventIdToActivate" #: Invalid activate event request. + invalid_rank_request = "InvalidRankRequest" #: Invalid request. + invalid_export_logs_request = "InvalidExportLogsRequest" #: Invalid request. + invalid_container = "InvalidContainer" #: SAS Uri must be the Uri to a container that has write permissions. + invalid_model_metadata = "InvalidModelMetadata" #: Invalid model metadata. + apprentice_mode_never_turned_on = "ApprenticeModeNeverTurnedOn" #: Apprentice mode never turned on. + missing_app_id = "MissingAppId" #: AppId is missing in the header. + invalid_reward_wait_time = "InvalidRewardWaitTime" #: Reward wait time should be between 5 seconds and 2 days + invalid_multi_slot_api_access = "InvalidMultiSlotApiAccess" #: Multi-slot feature is currently disabled. Please follow multi-slot Personalizer documentation to update your loop settings to enable multi-slot functionality. + model_file_access_denied = "ModelFileAccessDenied" #: Key vault Key used for customer managed key cannot be accessed. + problem_type_incompatible_with_auto_optimization = "ProblemTypeIncompatibleWithAutoOptimization" #: Auto-optimization is not compatible with multi-slot personalization. + resource_not_found = "ResourceNotFound" #: Requested resource does not exist on the server. + front_end_not_found = "FrontEndNotFound" #: Front end not found. + evaluation_not_found = "EvaluationNotFound" #: Offline Evaluation not found. + learning_settings_not_found = "LearningSettingsNotFound" #: Learning Settings not found in evaluation. + evaluation_model_not_found = "EvaluationModelNotFound" #: Model not found in evaluation. + logs_properties_not_found = "LogsPropertiesNotFound" #: Log properties not found. + model_ranking_error = "ModelRankingError" #: Error while ranking actions using model. Please verify the learning settings are valid. + internal_server_error = "InternalServerError" #: A generic error has occurred on the server. + rank_null_response = "RankNullResponse" #: Rank call returned null response. + update_configuration_failed = "UpdateConfigurationFailed" #: Failed to update configuration. + model_reset_failed = "ModelResetFailed" #: Model reset failed. + model_publish_failed = "ModelPublishFailed" #: Model publish failed. + model_metadata_update_failed = "ModelMetadataUpdateFailed" #: Model metadata update failed. + operation_not_allowed = "OperationNotAllowed" #: This operation is not allowed at this time. + + +class PolicySource(str, Enum): + + online = "Online" + baseline = "Baseline" + random = "Random" + custom = "Custom" + offline_experimentation = "OfflineExperimentation" + + +class EvaluationJobStatus(str, Enum): + + completed = "completed" + pending = "pending" + failed = "failed" + not_submitted = "notSubmitted" + timeout = "timeout" + optimal_policy_applied = "optimalPolicyApplied" + online_policy_retained = "onlinePolicyRetained" + + +class EvaluationType(str, Enum): + + manual = "Manual" + auto = "Auto" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py index 8edd718f964f..2135c65d3597 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py @@ -9,8 +9,26 @@ # regenerated. # -------------------------------------------------------------------------- -from .events_operations import EventsOperations +from ._service_configuration_operations import ServiceConfigurationOperations +from ._policy_operations import PolicyOperations +from ._evaluation_operations import EvaluationOperations +from ._evaluations_operations import EvaluationsOperations +from ._events_operations import EventsOperations +from ._log_operations import LogOperations +from ._model_operations import ModelOperations +from ._multi_slot_events_operations import MultiSlotEventsOperations +from ._multi_slot_operations import MultiSlotOperations +from ._personalizer_clientv11_preview1_operations import PersonalizerClientv11Preview1OperationsMixin __all__ = [ + 'ServiceConfigurationOperations', + 'PolicyOperations', + 'EvaluationOperations', + 'EvaluationsOperations', 'EventsOperations', + 'LogOperations', + 'ModelOperations', + 'MultiSlotEventsOperations', + 'MultiSlotOperations', + 'PersonalizerClientv11Preview1OperationsMixin', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluation_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluation_operations.py new file mode 100644 index 000000000000..77925bac0a29 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluation_operations.py @@ -0,0 +1,89 @@ +# 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 EvaluationOperations(object): + """EvaluationOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 apply( + self, evaluation_id, policy_name, custom_headers=None, raw=False, **operation_config): + """Apply Learning Settings and model from a pre-existing Offline + Evaluation, making them the current online Learning Settings and model + and replacing the previous ones. + + :param evaluation_id: Evaluation Id of the evaluation. + :type evaluation_id: str + :param policy_name: Name of the learning settings. + :type policy_name: 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:`ErrorResponseException` + """ + body = models.PolicyReferenceContract(evaluation_id=evaluation_id, policy_name=policy_name) + + # Construct URL + url = self.apply.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['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'PolicyReferenceContract') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + apply.metadata = {'url': '/configurations/applyFromEvaluation'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluations_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluations_operations.py new file mode 100644 index 000000000000..c861eb009f6c --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_evaluations_operations.py @@ -0,0 +1,251 @@ +# 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 msrest.exceptions import HttpOperationError + +from .. import models + + +class EvaluationsOperations(object): + """EvaluationsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 delete( + self, evaluation_id, custom_headers=None, raw=False, **operation_config): + """Delete Evaluation. + + Delete the Offline Evaluation associated with the Id. + + :param evaluation_id: Id of the Offline Evaluation to delete. + :type evaluation_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:`HttpOperationError` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'evaluationId': self._serialize.url("evaluation_id", evaluation_id, 'str', max_length=256) + } + 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 [204]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/evaluations/{evaluationId}'} + + def get( + self, evaluation_id, custom_headers=None, raw=False, **operation_config): + """Get Evaluation. + + Get the Offline Evaluation associated with the Id. + + :param evaluation_id: Id of the Offline Evaluation. + :type evaluation_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: Evaluation or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.Evaluation or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'evaluationId': self._serialize.url("evaluation_id", evaluation_id, 'str', max_length=256) + } + 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Evaluation', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/evaluations/{evaluationId}'} + + def list( + self, custom_headers=None, raw=False, **operation_config): + """List Offline Evaluations. + + List of all Offline Evaluations. + + :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.personalizer.models.Evaluation] + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # 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 HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[Evaluation]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/evaluations'} + + def create( + self, evaluation, custom_headers=None, raw=False, **operation_config): + """Create Offline Evaluation. + + Submit a new Offline Evaluation job. + + :param evaluation: The Offline Evaluation job definition. + :type evaluation: + ~azure.cognitiveservices.personalizer.models.EvaluationContract + :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: Evaluation or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.Evaluation or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create.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' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(evaluation, 'EvaluationContract') + + # 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 [201]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('Evaluation', response) + header_dict = { + 'Location': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + create.metadata = {'url': '/evaluations'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_events_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_events_operations.py new file mode 100644 index 000000000000..4938ab6db53e --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_events_operations.py @@ -0,0 +1,140 @@ +# 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 EventsOperations(object): + """EventsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 reward( + self, event_id, value, custom_headers=None, raw=False, **operation_config): + """Post Reward. + + Report reward between 0 and 1 that resulted from using the action + specified in rewardActionId, for the specified event. + + :param event_id: The event id this reward applies to. + :type event_id: str + :param value: Reward to be assigned to an action. Value is a float + calculated by your application, typically between 0 and 1, and must be + between -1 and 1. + :type value: float + :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:`ErrorResponseException` + """ + reward1 = models.RewardRequest(value=value) + + # Construct URL + url = self.reward.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + 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(reward1, 'RewardRequest') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + reward.metadata = {'url': '/events/{eventId}/reward'} + + def activate( + self, event_id, custom_headers=None, raw=False, **operation_config): + """Activate Event. + + Report that the specified event was actually used (e.g. by being + displayed to the user) and a reward should be expected for it. + + :param event_id: The event ID to be activated. + :type event_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:`ErrorResponseException` + """ + # Construct URL + url = self.activate.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + activate.metadata = {'url': '/events/{eventId}/activate'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_log_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_log_operations.py new file mode 100644 index 000000000000..494c0a00a8dd --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_log_operations.py @@ -0,0 +1,131 @@ +# 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 msrest.exceptions import HttpOperationError + +from .. import models + + +class LogOperations(object): + """LogOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 delete( + self, custom_headers=None, raw=False, **operation_config): + """Deletes Logs. + + Delete all logs of Rank and Reward calls stored by Personalizer. + + :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:`HttpOperationError` + """ + # Construct URL + url = self.delete.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 = {} + 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 [204]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/logs'} + + def get_properties( + self, custom_headers=None, raw=False, **operation_config): + """Get Log Properties. + + Get properties of the Personalizer logs. + + :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: LogsProperties or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.LogsProperties or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_properties.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.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LogsProperties', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_properties.metadata = {'url': '/logs/properties'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_model_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_model_operations.py new file mode 100644 index 000000000000..d2f00272e1f6 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_model_operations.py @@ -0,0 +1,184 @@ +# 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 msrest.exceptions import HttpOperationError + +from .. import models + + +class ModelOperations(object): + """ModelOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 get( + self, custom_headers=None, raw=False, callback=None, **operation_config): + """Get Model. + + Get the model file generated by Personalizer service. + + :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: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.get.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/octet-stream' + 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=True, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = self._client.stream_download(response, callback) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/model'} + + def reset( + self, custom_headers=None, raw=False, **operation_config): + """Reset Model. + + Resets the model file generated by Personalizer service. + + :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:`ErrorResponseException` + """ + # Construct URL + url = self.reset.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 = {} + 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + reset.metadata = {'url': '/model'} + + def get_properties( + self, custom_headers=None, raw=False, **operation_config): + """Get Model Properties. + + Get properties of the model file generated by Personalizer service. + + :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: ModelProperties or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.ModelProperties + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.get_properties.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 HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ModelProperties', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_properties.metadata = {'url': '/model/properties'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_events_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_events_operations.py new file mode 100644 index 000000000000..5af9c075693d --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_events_operations.py @@ -0,0 +1,139 @@ +# 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 MultiSlotEventsOperations(object): + """MultiSlotEventsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 reward( + self, event_id, reward, custom_headers=None, raw=False, **operation_config): + """Post multi-slot Rewards. + + Report reward that resulted from using the action specified in + rewardActionId for the slot. + + :param event_id: The event id this reward applies to. + :type event_id: str + :param reward: + :type reward: + list[~azure.cognitiveservices.personalizer.models.SlotReward] + :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:`ErrorResponseException` + """ + body = models.MultiSlotRewardRequest(reward=reward) + + # Construct URL + url = self.reward.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + 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, 'MultiSlotRewardRequest') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + reward.metadata = {'url': '/multislot/events/{eventId}/reward'} + + def activate( + self, event_id, custom_headers=None, raw=False, **operation_config): + """Activate multi-slot Event. + + Report that the specified event was actually used or displayed to the + user and a rewards should be expected for it. + + :param event_id: The event ID this activation applies to. + :type event_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:`ErrorResponseException` + """ + # Construct URL + url = self.activate.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + activate.metadata = {'url': '/multislot/events/{eventId}/activate'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_operations.py new file mode 100644 index 000000000000..d83bed7a8bdf --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_multi_slot_operations.py @@ -0,0 +1,97 @@ +# 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 MultiSlotOperations(object): + """MultiSlotOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 rank( + self, body, custom_headers=None, raw=False, **operation_config): + """Post multi-slot Rank. + + Submit a Personalizer multi-slot rank request. Receives a context, a + list of actions, and a list of slots. Returns which of the provided + actions should be used in each slot, in each rewardActionId. + + :param body: A Personalizer multi-slot Rank request. + :type body: + ~azure.cognitiveservices.personalizer.models.MultiSlotRankRequest + :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: MultiSlotRankResponse or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.personalizer.models.MultiSlotRankResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.rank.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' + 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, 'MultiSlotRankRequest') + + # 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 [201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('MultiSlotRankResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + rank.metadata = {'url': '/multislot/rank'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_clientv11_preview1_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_clientv11_preview1_operations.py new file mode 100644 index 000000000000..50158cabd638 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_clientv11_preview1_operations.py @@ -0,0 +1,77 @@ +# 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 msrest.exceptions import HttpOperationError +from .. import models + + +class PersonalizerClientv11Preview1OperationsMixin(object): + + def rank( + self, rank_request, custom_headers=None, raw=False, **operation_config): + """Post Rank. + + Submit a Personalizer rank request. Receives a context and a list of + actions. Returns which of the provided actions should be used by your + application, in rewardActionId. + + :param rank_request: A Personalizer Rank request. + :type rank_request: + ~azure.cognitiveservices.personalizer.models.RankRequest + :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: RankResponse or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.RankResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.rank.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' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(rank_request, 'RankRequest') + + # 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 [201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('RankResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + rank.metadata = {'url': '/rank'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_policy_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_policy_operations.py new file mode 100644 index 000000000000..75ee6419bec9 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_policy_operations.py @@ -0,0 +1,201 @@ +# 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 msrest.exceptions import HttpOperationError + +from .. import models + + +class PolicyOperations(object): + """PolicyOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 get( + self, custom_headers=None, raw=False, **operation_config): + """Get Policy. + + Get the Learning Settings currently used by the Personalizer service. + + :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: PolicyContract or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.PolicyContract or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.get.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 HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyContract', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/configurations/policy'} + + def update( + self, name, arguments, custom_headers=None, raw=False, **operation_config): + """Update Policy. + + Update the Learning Settings that the Personalizer service will use to + train models. + + :param name: Name of the learning settings. + :type name: str + :param arguments: Arguments of the learning settings. + :type arguments: 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: PolicyContract or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.PolicyContract or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + policy = models.PolicyContract(name=name, arguments=arguments) + + # Construct URL + url = self.update.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' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(policy, 'PolicyContract') + + # 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyContract', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/configurations/policy'} + + def reset( + self, custom_headers=None, raw=False, **operation_config): + """Reset Policy. + + Resets the learning settings of the Personalizer service to default. + + :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: PolicyContract or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.PolicyContract or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.reset.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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyContract', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + reset.metadata = {'url': '/configurations/policy'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_service_configuration_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_service_configuration_operations.py new file mode 100644 index 000000000000..6ab7844727e5 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_service_configuration_operations.py @@ -0,0 +1,148 @@ +# 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 msrest.exceptions import HttpOperationError + +from .. import models + + +class ServiceConfigurationOperations(object): + """ServiceConfigurationOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 update( + self, config, custom_headers=None, raw=False, **operation_config): + """Update Service Configuration. + + Update the Personalizer service configuration. + + :param config: The personalizer service configuration. + :type config: + ~azure.cognitiveservices.personalizer.models.ServiceConfiguration + :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: ServiceConfiguration or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.personalizer.models.ServiceConfiguration or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.update.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' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(config, 'ServiceConfiguration') + + # 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServiceConfiguration', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/configurations/service'} + + def get( + self, custom_headers=None, raw=False, **operation_config): + """Get Service Configuration. + + Get the Personalizer service configuration. + + :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: ServiceConfiguration or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.personalizer.models.ServiceConfiguration or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.get.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 HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServiceConfiguration', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/configurations/service'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/MANIFEST.in b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/MANIFEST.in index 546f3a3d5dcc..20501c996d91 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/_meta.json b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/_meta.json new file mode 100644 index 000000000000..5778322f057a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "V2", + "use": "@microsoft.azure/autorest.python@~4.0.71", + "commit": "89e7397cdb309ca81b3f1e823b98af25550df5c1", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/cognitiveservices/data-plane/ComputerVision/readme.md --keep-version-file --multiapi --no-async --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --use=@microsoft.azure/autorest.python@~4.0.71 --version=V2", + "readme": "specification/cognitiveservices/data-plane/ComputerVision/readme.md" +} \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py index e2d380c69638..c05e93c09ab4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py @@ -38,7 +38,8 @@ def __init__( super(ComputerVisionClient, 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.api_version = '3.2' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py index 7a5c5c553bc9..a76cee839ea0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py @@ -33,7 +33,7 @@ def __init__( raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/vision/v3.0' + base_url = '{Endpoint}/vision/v3.2' super(ComputerVisionClientConfiguration, self).__init__(base_url) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 5633061bc93b..ef1f516e48e0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -12,14 +12,17 @@ try: from ._models_py3 import AdultInfo from ._models_py3 import AnalyzeResults + from ._models_py3 import Appearance from ._models_py3 import AreaOfInterestResult from ._models_py3 import BoundingRect from ._models_py3 import Category from ._models_py3 import CategoryDetail from ._models_py3 import CelebritiesModel - from ._models_py3 import CelebrityResults from ._models_py3 import ColorInfo - from ._models_py3 import ComputerVisionError, ComputerVisionErrorException + from ._models_py3 import ComputerVisionError + from ._models_py3 import ComputerVisionErrorResponse, ComputerVisionErrorResponseException + from ._models_py3 import ComputerVisionInnerError + from ._models_py3 import ComputerVisionOcrError, ComputerVisionOcrErrorException from ._models_py3 import DetectedBrand from ._models_py3 import DetectedObject from ._models_py3 import DetectResult @@ -34,7 +37,6 @@ from ._models_py3 import ImageTag from ._models_py3 import ImageType from ._models_py3 import ImageUrl - from ._models_py3 import LandmarkResults from ._models_py3 import LandmarksModel from ._models_py3 import Line from ._models_py3 import ListModelsResult @@ -46,19 +48,23 @@ from ._models_py3 import OcrWord from ._models_py3 import ReadOperationResult from ._models_py3 import ReadResult + from ._models_py3 import Style from ._models_py3 import TagResult from ._models_py3 import Word except (SyntaxError, ImportError): from ._models import AdultInfo from ._models import AnalyzeResults + from ._models import Appearance from ._models import AreaOfInterestResult from ._models import BoundingRect from ._models import Category from ._models import CategoryDetail from ._models import CelebritiesModel - from ._models import CelebrityResults from ._models import ColorInfo - from ._models import ComputerVisionError, ComputerVisionErrorException + from ._models import ComputerVisionError + from ._models import ComputerVisionErrorResponse, ComputerVisionErrorResponseException + from ._models import ComputerVisionInnerError + from ._models import ComputerVisionOcrError, ComputerVisionOcrErrorException from ._models import DetectedBrand from ._models import DetectedObject from ._models import DetectResult @@ -73,7 +79,6 @@ from ._models import ImageTag from ._models import ImageType from ._models import ImageUrl - from ._models import LandmarkResults from ._models import LandmarksModel from ._models import Line from ._models import ListModelsResult @@ -85,9 +90,12 @@ from ._models import OcrWord from ._models import ReadOperationResult from ._models import ReadResult + from ._models import Style from ._models import TagResult from ._models import Word from ._computer_vision_client_enums import ( + ComputerVisionErrorCodes, + ComputerVisionInnerErrorCodeValue, DescriptionExclude, Details, Gender, @@ -95,20 +103,24 @@ OcrLanguages, OperationStatusCodes, TextRecognitionResultDimensionUnit, + TextStyle, VisualFeatureTypes, ) __all__ = [ 'AdultInfo', 'AnalyzeResults', + 'Appearance', 'AreaOfInterestResult', 'BoundingRect', 'Category', 'CategoryDetail', 'CelebritiesModel', - 'CelebrityResults', 'ColorInfo', - 'ComputerVisionError', 'ComputerVisionErrorException', + 'ComputerVisionError', + 'ComputerVisionErrorResponse', 'ComputerVisionErrorResponseException', + 'ComputerVisionInnerError', + 'ComputerVisionOcrError', 'ComputerVisionOcrErrorException', 'DetectedBrand', 'DetectedObject', 'DetectResult', @@ -123,7 +135,6 @@ 'ImageTag', 'ImageType', 'ImageUrl', - 'LandmarkResults', 'LandmarksModel', 'Line', 'ListModelsResult', @@ -135,11 +146,15 @@ 'OcrWord', 'ReadOperationResult', 'ReadResult', + 'Style', 'TagResult', 'Word', 'Gender', + 'ComputerVisionErrorCodes', + 'ComputerVisionInnerErrorCodeValue', 'OperationStatusCodes', 'TextRecognitionResultDimensionUnit', + 'TextStyle', 'DescriptionExclude', 'OcrLanguages', 'VisualFeatureTypes', diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py index d8cb9260286e..e75022fa8589 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py @@ -18,6 +18,37 @@ class Gender(str, Enum): female = "Female" +class ComputerVisionErrorCodes(str, Enum): + + invalid_request = "InvalidRequest" + invalid_argument = "InvalidArgument" + internal_server_error = "InternalServerError" + service_unavailable = "ServiceUnavailable" + + +class ComputerVisionInnerErrorCodeValue(str, Enum): + + invalid_image_format = "InvalidImageFormat" + unsupported_media_type = "UnsupportedMediaType" + invalid_image_url = "InvalidImageUrl" + not_supported_feature = "NotSupportedFeature" + not_supported_image = "NotSupportedImage" + timeout = "Timeout" + internal_server_error = "InternalServerError" + invalid_image_size = "InvalidImageSize" + bad_argument = "BadArgument" + detect_face_error = "DetectFaceError" + not_supported_language = "NotSupportedLanguage" + invalid_thumbnail_size = "InvalidThumbnailSize" + invalid_details = "InvalidDetails" + invalid_model = "InvalidModel" + cancelled_request = "CancelledRequest" + not_supported_visual_feature = "NotSupportedVisualFeature" + failed_to_process = "FailedToProcess" + unspecified = "Unspecified" + storage_exception = "StorageException" + + class OperationStatusCodes(str, Enum): not_started = "notStarted" @@ -32,6 +63,12 @@ class TextRecognitionResultDimensionUnit(str, Enum): inch = "inch" +class TextStyle(str, Enum): + + other = "other" + handwriting = "handwriting" + + class DescriptionExclude(str, Enum): celebrities = "Celebrities" @@ -84,13 +121,79 @@ class VisualFeatureTypes(str, Enum): class OcrDetectionLanguage(str, Enum): + af = "af" + ast = "ast" + bi = "bi" + br = "br" + ca = "ca" + ceb = "ceb" + ch = "ch" + co = "co" + crh = "crh" + cs = "cs" + csb = "csb" + da = "da" + de = "de" en = "en" es = "es" + et = "et" + eu = "eu" + fi = "fi" + fil = "fil" + fj = "fj" fr = "fr" - de = "de" + fur = "fur" + fy = "fy" + ga = "ga" + gd = "gd" + gil = "gil" + gl = "gl" + gv = "gv" + hni = "hni" + hsb = "hsb" + ht = "ht" + hu = "hu" + ia = "ia" + id = "id" it = "it" + iu = "iu" + ja = "ja" + jv = "jv" + kaa = "kaa" + kac = "kac" + kea = "kea" + kha = "kha" + kl = "kl" + ko = "ko" + ku = "ku" + kw = "kw" + lb = "lb" + ms = "ms" + mww = "mww" + nap = "nap" nl = "nl" + no = "no" + oc = "oc" + pl = "pl" pt = "pt" + quc = "quc" + rm = "rm" + sco = "sco" + sl = "sl" + sq = "sq" + sv = "sv" + sw = "sw" + tet = "tet" + tr = "tr" + tt = "tt" + uz = "uz" + vo = "vo" + wae = "wae" + yua = "yua" + za = "za" + zh_hans = "zh-Hans" + zh_hant = "zh-Hant" + zu = "zu" class Details(str, Enum): diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py index f0ef37445759..129c4e04fcfa 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py @@ -60,6 +60,9 @@ class AnalyzeResults(Model): :param version: Required. Version of schema used for this result. :type version: str + :param model_version: Required. Version of the OCR model used for text + extraction. + :type model_version: str :param read_results: Required. Text extracted from the input. :type read_results: list[~azure.cognitiveservices.vision.computervision.models.ReadResult] @@ -67,20 +70,45 @@ class AnalyzeResults(Model): _validation = { 'version': {'required': True}, + 'model_version': {'required': True, 'pattern': r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$'}, 'read_results': {'required': True}, } _attribute_map = { 'version': {'key': 'version', 'type': 'str'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, } def __init__(self, **kwargs): super(AnalyzeResults, self).__init__(**kwargs) self.version = kwargs.get('version', None) + self.model_version = kwargs.get('model_version', None) self.read_results = kwargs.get('read_results', None) +class Appearance(Model): + """An object representing the appearance of the text line. + + All required parameters must be populated in order to send to Azure. + + :param style: Required. An object representing the style of the text line. + :type style: ~azure.cognitiveservices.vision.computervision.models.Style + """ + + _validation = { + 'style': {'required': True}, + } + + _attribute_map = { + 'style': {'key': 'style', 'type': 'Style'}, + } + + def __init__(self, **kwargs): + super(Appearance, self).__init__(**kwargs) + self.style = kwargs.get('style', None) + + class AreaOfInterestResult(Model): """Result of AreaOfInterest operation. @@ -96,6 +124,8 @@ class AreaOfInterestResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _validation = { @@ -106,6 +136,7 @@ class AreaOfInterestResult(Model): 'area_of_interest': {'key': 'areaOfInterest', 'type': 'BoundingRect'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -113,6 +144,7 @@ def __init__(self, **kwargs): self.area_of_interest = None self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class BoundingRect(Model): @@ -216,32 +248,6 @@ def __init__(self, **kwargs): self.face_rectangle = kwargs.get('face_rectangle', None) -class CelebrityResults(Model): - """Result of domain-specific classifications for the domain of celebrities. - - :param celebrities: List of celebrities recognized in the image. - :type celebrities: - list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, **kwargs): - super(CelebrityResults, self).__init__(**kwargs) - self.celebrities = kwargs.get('celebrities', None) - self.request_id = kwargs.get('request_id', None) - self.metadata = kwargs.get('metadata', None) - - class ColorInfo(Model): """An object providing additional metadata describing color attributes. @@ -275,6 +281,112 @@ def __init__(self, **kwargs): class ComputerVisionError(Model): + """The API request error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. Possible values include: + 'InvalidRequest', 'InvalidArgument', 'InternalServerError', + 'ServiceUnavailable' + :type code: str or + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorCodes + :param message: Required. A message explaining the error reported by the + service. + :type message: str + :param innererror: Inner error contains more specific information. + :type innererror: + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionInnerError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'innererror': {'key': 'innererror', 'type': 'ComputerVisionInnerError'}, + } + + def __init__(self, **kwargs): + super(ComputerVisionError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.innererror = kwargs.get('innererror', None) + + +class ComputerVisionErrorResponse(Model): + """The API error response. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. Error contents. + :type error: + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ComputerVisionError'}, + } + + def __init__(self, **kwargs): + super(ComputerVisionErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ComputerVisionErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ComputerVisionErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ComputerVisionErrorResponseException, self).__init__(deserialize, response, 'ComputerVisionErrorResponse', *args) + + +class ComputerVisionInnerError(Model): + """Details about the API request error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. Possible values include: + 'InvalidImageFormat', 'UnsupportedMediaType', 'InvalidImageUrl', + 'NotSupportedFeature', 'NotSupportedImage', 'Timeout', + 'InternalServerError', 'InvalidImageSize', 'BadArgument', + 'DetectFaceError', 'NotSupportedLanguage', 'InvalidThumbnailSize', + 'InvalidDetails', 'InvalidModel', 'CancelledRequest', + 'NotSupportedVisualFeature', 'FailedToProcess', 'Unspecified', + 'StorageException' + :type code: str or + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionInnerErrorCodeValue + :param message: Required. Error message. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ComputerVisionInnerError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ComputerVisionOcrError(Model): """Details about the API request error. All required parameters must be populated in order to send to Azure. @@ -300,14 +412,14 @@ class ComputerVisionError(Model): } def __init__(self, **kwargs): - super(ComputerVisionError, self).__init__(**kwargs) + super(ComputerVisionOcrError, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) self.request_id = kwargs.get('request_id', None) -class ComputerVisionErrorException(HttpOperationError): - """Server responsed with exception of type: 'ComputerVisionError'. +class ComputerVisionOcrErrorException(HttpOperationError): + """Server responsed with exception of type: 'ComputerVisionOcrError'. :param deserialize: A deserializer :param response: Server response to be deserialized. @@ -315,7 +427,7 @@ class ComputerVisionErrorException(HttpOperationError): def __init__(self, deserialize, response, *args): - super(ComputerVisionErrorException, self).__init__(deserialize, response, 'ComputerVisionError', *args) + super(ComputerVisionOcrErrorException, self).__init__(deserialize, response, 'ComputerVisionOcrError', *args) class DetectedBrand(Model): @@ -407,6 +519,8 @@ class DetectResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _validation = { @@ -417,6 +531,7 @@ class DetectResult(Model): 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -424,6 +539,7 @@ def __init__(self, **kwargs): self.objects = None self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class DomainModelResults(Model): @@ -437,12 +553,15 @@ class DomainModelResults(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { 'result': {'key': 'result', 'type': 'object'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -450,6 +569,7 @@ def __init__(self, **kwargs): self.result = kwargs.get('result', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class FaceDescription(Model): @@ -550,6 +670,8 @@ class ImageAnalysis(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { @@ -564,6 +686,7 @@ class ImageAnalysis(Model): 'brands': {'key': 'brands', 'type': '[DetectedBrand]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -579,6 +702,7 @@ def __init__(self, **kwargs): self.brands = kwargs.get('brands', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class ImageCaption(Model): @@ -615,6 +739,8 @@ class ImageDescription(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { @@ -622,6 +748,7 @@ class ImageDescription(Model): 'captions': {'key': 'description.captions', 'type': '[ImageCaption]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -630,6 +757,7 @@ def __init__(self, **kwargs): self.captions = kwargs.get('captions', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class ImageDescriptionDetails(Model): @@ -745,32 +873,6 @@ def __init__(self, **kwargs): self.url = kwargs.get('url', None) -class LandmarkResults(Model): - """Result of domain-specific classifications for the domain of landmarks. - - :param landmarks: List of landmarks recognized in the image. - :type landmarks: - list[~azure.cognitiveservices.vision.computervision.models.LandmarksModel] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'landmarks': {'key': 'landmarks', 'type': '[LandmarksModel]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, **kwargs): - super(LandmarkResults, self).__init__(**kwargs) - self.landmarks = kwargs.get('landmarks', None) - self.request_id = kwargs.get('request_id', None) - self.metadata = kwargs.get('metadata', None) - - class LandmarksModel(Model): """A landmark recognized in the image. @@ -802,6 +904,9 @@ class Line(Model): :type language: str :param bounding_box: Required. Bounding box of a recognized line. :type bounding_box: list[float] + :param appearance: Appearance of the text line. + :type appearance: + ~azure.cognitiveservices.vision.computervision.models.Appearance :param text: Required. The text content of the line. :type text: str :param words: Required. List of words in the text line. @@ -818,6 +923,7 @@ class Line(Model): _attribute_map = { 'language': {'key': 'language', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'appearance': {'key': 'appearance', 'type': 'Appearance'}, 'text': {'key': 'text', 'type': 'str'}, 'words': {'key': 'words', 'type': '[Word]'}, } @@ -826,6 +932,7 @@ def __init__(self, **kwargs): super(Line, self).__init__(**kwargs) self.language = kwargs.get('language', None) self.bounding_box = kwargs.get('bounding_box', None) + self.appearance = kwargs.get('appearance', None) self.text = kwargs.get('text', None) self.words = kwargs.get('words', None) @@ -984,6 +1091,8 @@ class OcrResult(Model): of recognized text. :type regions: list[~azure.cognitiveservices.vision.computervision.models.OcrRegion] + :param model_version: + :type model_version: str """ _attribute_map = { @@ -991,6 +1100,7 @@ class OcrResult(Model): 'text_angle': {'key': 'textAngle', 'type': 'float'}, 'orientation': {'key': 'orientation', 'type': 'str'}, 'regions': {'key': 'regions', 'type': '[OcrRegion]'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -999,6 +1109,7 @@ def __init__(self, **kwargs): self.text_angle = kwargs.get('text_angle', None) self.orientation = kwargs.get('orientation', None) self.regions = kwargs.get('regions', None) + self.model_version = kwargs.get('model_version', None) class OcrWord(Model): @@ -1117,6 +1228,35 @@ def __init__(self, **kwargs): self.lines = kwargs.get('lines', None) +class Style(Model): + """An object representing the style of the text line. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The text line style name, including handwriting and + other. Possible values include: 'other', 'handwriting' + :type name: str or + ~azure.cognitiveservices.vision.computervision.models.TextStyle + :param confidence: Required. The confidence of text line style. + :type confidence: float + """ + + _validation = { + 'name': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(Style, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.confidence = kwargs.get('confidence', None) + + class TagResult(Model): """The results of a image tag operation, including any tags and image metadata. @@ -1129,12 +1269,15 @@ class TagResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } def __init__(self, **kwargs): @@ -1142,6 +1285,7 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) + self.model_version = kwargs.get('model_version', None) class Word(Model): diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py index 09951eeef9a3..9184286931b4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py @@ -60,6 +60,9 @@ class AnalyzeResults(Model): :param version: Required. Version of schema used for this result. :type version: str + :param model_version: Required. Version of the OCR model used for text + extraction. + :type model_version: str :param read_results: Required. Text extracted from the input. :type read_results: list[~azure.cognitiveservices.vision.computervision.models.ReadResult] @@ -67,20 +70,45 @@ class AnalyzeResults(Model): _validation = { 'version': {'required': True}, + 'model_version': {'required': True, 'pattern': r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$'}, 'read_results': {'required': True}, } _attribute_map = { 'version': {'key': 'version', 'type': 'str'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, } - def __init__(self, *, version: str, read_results, **kwargs) -> None: + def __init__(self, *, version: str, model_version: str, read_results, **kwargs) -> None: super(AnalyzeResults, self).__init__(**kwargs) self.version = version + self.model_version = model_version self.read_results = read_results +class Appearance(Model): + """An object representing the appearance of the text line. + + All required parameters must be populated in order to send to Azure. + + :param style: Required. An object representing the style of the text line. + :type style: ~azure.cognitiveservices.vision.computervision.models.Style + """ + + _validation = { + 'style': {'required': True}, + } + + _attribute_map = { + 'style': {'key': 'style', 'type': 'Style'}, + } + + def __init__(self, *, style, **kwargs) -> None: + super(Appearance, self).__init__(**kwargs) + self.style = style + + class AreaOfInterestResult(Model): """Result of AreaOfInterest operation. @@ -96,6 +124,8 @@ class AreaOfInterestResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _validation = { @@ -106,13 +136,15 @@ class AreaOfInterestResult(Model): 'area_of_interest': {'key': 'areaOfInterest', 'type': 'BoundingRect'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(AreaOfInterestResult, self).__init__(**kwargs) self.area_of_interest = None self.request_id = request_id self.metadata = metadata + self.model_version = model_version class BoundingRect(Model): @@ -216,32 +248,6 @@ def __init__(self, *, name: str=None, confidence: float=None, face_rectangle=Non self.face_rectangle = face_rectangle -class CelebrityResults(Model): - """Result of domain-specific classifications for the domain of celebrities. - - :param celebrities: List of celebrities recognized in the image. - :type celebrities: - list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, *, celebrities=None, request_id: str=None, metadata=None, **kwargs) -> None: - super(CelebrityResults, self).__init__(**kwargs) - self.celebrities = celebrities - self.request_id = request_id - self.metadata = metadata - - class ColorInfo(Model): """An object providing additional metadata describing color attributes. @@ -275,6 +281,112 @@ def __init__(self, *, dominant_color_foreground: str=None, dominant_color_backgr class ComputerVisionError(Model): + """The API request error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. Possible values include: + 'InvalidRequest', 'InvalidArgument', 'InternalServerError', + 'ServiceUnavailable' + :type code: str or + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionErrorCodes + :param message: Required. A message explaining the error reported by the + service. + :type message: str + :param innererror: Inner error contains more specific information. + :type innererror: + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionInnerError + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'innererror': {'key': 'innererror', 'type': 'ComputerVisionInnerError'}, + } + + def __init__(self, *, code, message: str, innererror=None, **kwargs) -> None: + super(ComputerVisionError, self).__init__(**kwargs) + self.code = code + self.message = message + self.innererror = innererror + + +class ComputerVisionErrorResponse(Model): + """The API error response. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. Error contents. + :type error: + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionError + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ComputerVisionError'}, + } + + def __init__(self, *, error, **kwargs) -> None: + super(ComputerVisionErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ComputerVisionErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ComputerVisionErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ComputerVisionErrorResponseException, self).__init__(deserialize, response, 'ComputerVisionErrorResponse', *args) + + +class ComputerVisionInnerError(Model): + """Details about the API request error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. Possible values include: + 'InvalidImageFormat', 'UnsupportedMediaType', 'InvalidImageUrl', + 'NotSupportedFeature', 'NotSupportedImage', 'Timeout', + 'InternalServerError', 'InvalidImageSize', 'BadArgument', + 'DetectFaceError', 'NotSupportedLanguage', 'InvalidThumbnailSize', + 'InvalidDetails', 'InvalidModel', 'CancelledRequest', + 'NotSupportedVisualFeature', 'FailedToProcess', 'Unspecified', + 'StorageException' + :type code: str or + ~azure.cognitiveservices.vision.computervision.models.ComputerVisionInnerErrorCodeValue + :param message: Required. Error message. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code, message: str, **kwargs) -> None: + super(ComputerVisionInnerError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ComputerVisionOcrError(Model): """Details about the API request error. All required parameters must be populated in order to send to Azure. @@ -300,14 +412,14 @@ class ComputerVisionError(Model): } def __init__(self, *, code, message: str, request_id: str=None, **kwargs) -> None: - super(ComputerVisionError, self).__init__(**kwargs) + super(ComputerVisionOcrError, self).__init__(**kwargs) self.code = code self.message = message self.request_id = request_id -class ComputerVisionErrorException(HttpOperationError): - """Server responsed with exception of type: 'ComputerVisionError'. +class ComputerVisionOcrErrorException(HttpOperationError): + """Server responsed with exception of type: 'ComputerVisionOcrError'. :param deserialize: A deserializer :param response: Server response to be deserialized. @@ -315,7 +427,7 @@ class ComputerVisionErrorException(HttpOperationError): def __init__(self, deserialize, response, *args): - super(ComputerVisionErrorException, self).__init__(deserialize, response, 'ComputerVisionError', *args) + super(ComputerVisionOcrErrorException, self).__init__(deserialize, response, 'ComputerVisionOcrError', *args) class DetectedBrand(Model): @@ -407,6 +519,8 @@ class DetectResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _validation = { @@ -417,13 +531,15 @@ class DetectResult(Model): 'objects': {'key': 'objects', 'type': '[DetectedObject]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(DetectResult, self).__init__(**kwargs) self.objects = None self.request_id = request_id self.metadata = metadata + self.model_version = model_version class DomainModelResults(Model): @@ -437,19 +553,23 @@ class DomainModelResults(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { 'result': {'key': 'result', 'type': 'object'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, result=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, result=None, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(DomainModelResults, self).__init__(**kwargs) self.result = result self.request_id = request_id self.metadata = metadata + self.model_version = model_version class FaceDescription(Model): @@ -550,6 +670,8 @@ class ImageAnalysis(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { @@ -564,9 +686,10 @@ class ImageAnalysis(Model): 'brands': {'key': 'brands', 'type': '[DetectedBrand]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, brands=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, brands=None, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(ImageAnalysis, self).__init__(**kwargs) self.categories = categories self.adult = adult @@ -579,6 +702,7 @@ def __init__(self, *, categories=None, adult=None, color=None, image_type=None, self.brands = brands self.request_id = request_id self.metadata = metadata + self.model_version = model_version class ImageCaption(Model): @@ -615,6 +739,8 @@ class ImageDescription(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { @@ -622,14 +748,16 @@ class ImageDescription(Model): 'captions': {'key': 'description.captions', 'type': '[ImageCaption]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, tags=None, captions=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, tags=None, captions=None, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(ImageDescription, self).__init__(**kwargs) self.tags = tags self.captions = captions self.request_id = request_id self.metadata = metadata + self.model_version = model_version class ImageDescriptionDetails(Model): @@ -745,32 +873,6 @@ def __init__(self, *, url: str, **kwargs) -> None: self.url = url -class LandmarkResults(Model): - """Result of domain-specific classifications for the domain of landmarks. - - :param landmarks: List of landmarks recognized in the image. - :type landmarks: - list[~azure.cognitiveservices.vision.computervision.models.LandmarksModel] - :param request_id: Id of the REST API request. - :type request_id: str - :param metadata: - :type metadata: - ~azure.cognitiveservices.vision.computervision.models.ImageMetadata - """ - - _attribute_map = { - 'landmarks': {'key': 'landmarks', 'type': '[LandmarksModel]'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, - } - - def __init__(self, *, landmarks=None, request_id: str=None, metadata=None, **kwargs) -> None: - super(LandmarkResults, self).__init__(**kwargs) - self.landmarks = landmarks - self.request_id = request_id - self.metadata = metadata - - class LandmarksModel(Model): """A landmark recognized in the image. @@ -802,6 +904,9 @@ class Line(Model): :type language: str :param bounding_box: Required. Bounding box of a recognized line. :type bounding_box: list[float] + :param appearance: Appearance of the text line. + :type appearance: + ~azure.cognitiveservices.vision.computervision.models.Appearance :param text: Required. The text content of the line. :type text: str :param words: Required. List of words in the text line. @@ -818,14 +923,16 @@ class Line(Model): _attribute_map = { 'language': {'key': 'language', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'appearance': {'key': 'appearance', 'type': 'Appearance'}, 'text': {'key': 'text', 'type': 'str'}, 'words': {'key': 'words', 'type': '[Word]'}, } - def __init__(self, *, bounding_box, text: str, words, language: str=None, **kwargs) -> None: + def __init__(self, *, bounding_box, text: str, words, language: str=None, appearance=None, **kwargs) -> None: super(Line, self).__init__(**kwargs) self.language = language self.bounding_box = bounding_box + self.appearance = appearance self.text = text self.words = words @@ -984,6 +1091,8 @@ class OcrResult(Model): of recognized text. :type regions: list[~azure.cognitiveservices.vision.computervision.models.OcrRegion] + :param model_version: + :type model_version: str """ _attribute_map = { @@ -991,14 +1100,16 @@ class OcrResult(Model): 'text_angle': {'key': 'textAngle', 'type': 'float'}, 'orientation': {'key': 'orientation', 'type': 'str'}, 'regions': {'key': 'regions', 'type': '[OcrRegion]'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, language: str=None, text_angle: float=None, orientation: str=None, regions=None, **kwargs) -> None: + def __init__(self, *, language: str=None, text_angle: float=None, orientation: str=None, regions=None, model_version: str=None, **kwargs) -> None: super(OcrResult, self).__init__(**kwargs) self.language = language self.text_angle = text_angle self.orientation = orientation self.regions = regions + self.model_version = model_version class OcrWord(Model): @@ -1117,6 +1228,35 @@ def __init__(self, *, page: int, angle: float, width: float, height: float, unit self.lines = lines +class Style(Model): + """An object representing the style of the text line. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The text line style name, including handwriting and + other. Possible values include: 'other', 'handwriting' + :type name: str or + ~azure.cognitiveservices.vision.computervision.models.TextStyle + :param confidence: Required. The confidence of text line style. + :type confidence: float + """ + + _validation = { + 'name': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, name, confidence: float, **kwargs) -> None: + super(Style, self).__init__(**kwargs) + self.name = name + self.confidence = confidence + + class TagResult(Model): """The results of a image tag operation, including any tags and image metadata. @@ -1129,19 +1269,23 @@ class TagResult(Model): :param metadata: :type metadata: ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + :param model_version: + :type model_version: str """ _attribute_map = { 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + 'model_version': {'key': 'modelVersion', 'type': 'str'}, } - def __init__(self, *, tags=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, tags=None, request_id: str=None, metadata=None, model_version: str=None, **kwargs) -> None: super(TagResult, self).__init__(**kwargs) self.tags = tags self.request_id = request_id self.metadata = metadata + self.model_version = model_version class Word(Model): diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py index a2417588988b..32f0d59809f7 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py @@ -17,7 +17,7 @@ class ComputerVisionClientOperationsMixin(object): def analyze_image( - self, url, visual_features=None, details=None, language="en", description_exclude=None, custom_headers=None, raw=False, **operation_config): + self, url, visual_features=None, details=None, language="en", description_exclude=None, model_version="latest", custom_headers=None, raw=False, **operation_config): """This operation extracts a rich set of visual features based on the image content. Two input methods are supported -- (1) Uploading an image or (2) @@ -66,6 +66,10 @@ def analyze_image( generating the description. :type description_exclude: list[str or ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -76,7 +80,7 @@ def analyze_image( ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -97,6 +101,8 @@ def analyze_image( query_parameters['language'] = self._serialize.query("language", language, 'str') if description_exclude is not None: query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -113,7 +119,7 @@ def analyze_image( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -127,7 +133,7 @@ def analyze_image( analyze_image.metadata = {'url': '/analyze'} def describe_image( - self, url, max_candidates=1, language="en", description_exclude=None, custom_headers=None, raw=False, **operation_config): + self, url, max_candidates=1, language="en", description_exclude=None, model_version="latest", custom_headers=None, raw=False, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. @@ -155,6 +161,10 @@ def describe_image( generating the description. :type description_exclude: list[str or ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -165,7 +175,7 @@ def describe_image( ~azure.cognitiveservices.vision.computervision.models.ImageDescription or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -184,6 +194,8 @@ def describe_image( query_parameters['language'] = self._serialize.query("language", language, 'str') if description_exclude is not None: query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -200,7 +212,7 @@ def describe_image( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -214,7 +226,7 @@ def describe_image( describe_image.metadata = {'url': '/describe'} def detect_objects( - self, url, custom_headers=None, raw=False, **operation_config): + self, url, model_version="latest", custom_headers=None, raw=False, **operation_config): """Performs object detection on the specified image. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. @@ -224,6 +236,10 @@ def detect_objects( :param url: Publicly reachable URL of an image. :type url: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -234,7 +250,7 @@ def detect_objects( ~azure.cognitiveservices.vision.computervision.models.DetectResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -247,6 +263,8 @@ def detect_objects( # Construct parameters query_parameters = {} + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -263,7 +281,7 @@ def detect_objects( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -296,7 +314,7 @@ def list_models( ~azure.cognitiveservices.vision.computervision.models.ListModelsResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.list_models.metadata['url'] @@ -319,7 +337,7 @@ def list_models( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -333,7 +351,7 @@ def list_models( list_models.metadata = {'url': '/models'} def analyze_image_by_domain( - self, model, url, language="en", custom_headers=None, raw=False, **operation_config): + self, model, url, language="en", model_version="latest", custom_headers=None, raw=False, **operation_config): """This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models @@ -355,6 +373,10 @@ def analyze_image_by_domain( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -365,7 +387,7 @@ def analyze_image_by_domain( ~azure.cognitiveservices.vision.computervision.models.DomainModelResults or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -381,6 +403,8 @@ def analyze_image_by_domain( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -397,7 +421,7 @@ def analyze_image_by_domain( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -411,7 +435,7 @@ def analyze_image_by_domain( analyze_image_by_domain.metadata = {'url': '/models/{model}/analyze'} def recognize_printed_text( - self, url, detect_orientation=True, language="unk", custom_headers=None, raw=False, **operation_config): + self, url, detect_orientation=True, language="unk", model_version="latest", custom_headers=None, raw=False, **operation_config): """Optical Character Recognition (OCR) detects text in an image and extracts the recognized characters into a machine-usable character stream. @@ -435,6 +459,10 @@ def recognize_printed_text( 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' :type language: str or ~azure.cognitiveservices.vision.computervision.models.OcrLanguages + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -445,7 +473,7 @@ def recognize_printed_text( ~azure.cognitiveservices.vision.computervision.models.OcrResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -461,6 +489,8 @@ def recognize_printed_text( query_parameters['detectOrientation'] = self._serialize.query("detect_orientation", detect_orientation, 'bool') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'OcrLanguages') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -477,7 +507,7 @@ def recognize_printed_text( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -491,7 +521,7 @@ def recognize_printed_text( recognize_printed_text.metadata = {'url': '/ocr'} def tag_image( - self, url, language="en", custom_headers=None, raw=False, **operation_config): + self, url, language="en", model_version="latest", custom_headers=None, raw=False, **operation_config): """This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in @@ -513,6 +543,10 @@ def tag_image( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -523,7 +557,7 @@ def tag_image( ~azure.cognitiveservices.vision.computervision.models.TagResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -538,6 +572,8 @@ def tag_image( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -554,7 +590,7 @@ def tag_image( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -568,7 +604,7 @@ def tag_image( tag_image.metadata = {'url': '/tag'} def generate_thumbnail( - self, width, height, url, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): + self, width, height, url, smart_cropping=False, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping @@ -592,6 +628,10 @@ def generate_thumbnail( :type url: str :param smart_cropping: Boolean flag for enabling smart cropping. :type smart_cropping: bool + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -622,6 +662,8 @@ def generate_thumbnail( query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1024, minimum=1) if smart_cropping is not None: query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -650,7 +692,7 @@ def generate_thumbnail( generate_thumbnail.metadata = {'url': '/generateThumbnail'} def get_area_of_interest( - self, url, custom_headers=None, raw=False, **operation_config): + self, url, model_version="latest", custom_headers=None, raw=False, **operation_config): """This operation returns a bounding box around the most important area of the image. A successful response will be returned in JSON. If the request failed, @@ -663,6 +705,10 @@ def get_area_of_interest( :param url: Publicly reachable URL of an image. :type url: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -673,7 +719,7 @@ def get_area_of_interest( ~azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ image_url = models.ImageUrl(url=url) @@ -686,6 +732,8 @@ def get_area_of_interest( # Construct parameters query_parameters = {} + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -702,7 +750,7 @@ def get_area_of_interest( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -716,7 +764,7 @@ def get_area_of_interest( get_area_of_interest.metadata = {'url': '/areaOfInterest'} def read( - self, url, language="en", custom_headers=None, raw=False, **operation_config): + self, url, language=None, pages=None, model_version="latest", reading_order="basic", custom_headers=None, raw=False, **operation_config): """Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, @@ -726,16 +774,33 @@ def read( :param url: Publicly reachable URL of an image. :type url: str - :param language: The BCP-47 language code of the text to be detected - in the image. In future versions, when language parameter is not - passed, language detection will be used to determine the language. - However, in the current version, missing language parameter will cause - English to be used. To ensure that your document is always parsed in - English without the use of language detection in the future, pass “en” - in the language parameter. Possible values include: 'en', 'es', 'fr', - 'de', 'it', 'nl', 'pt' + :param language: The BCP-47 language code of the text in the document. + Read supports auto language identification and multi-language + documents, so only provide a language code if you would like to force + the document to be processed in that specific language. See + https://aka.ms/ocr-languages for list of supported languages. Possible + values include: 'af', 'ast', 'bi', 'br', 'ca', 'ceb', 'ch', 'co', + 'crh', 'cs', 'csb', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fil', + 'fj', 'fr', 'fur', 'fy', 'ga', 'gd', 'gil', 'gl', 'gv', 'hni', 'hsb', + 'ht', 'hu', 'ia', 'id', 'it', 'iu', 'ja', 'jv', 'kaa', 'kac', 'kea', + 'kha', 'kl', 'ko', 'ku', 'kw', 'lb', 'ms', 'mww', 'nap', 'nl', 'no', + 'oc', 'pl', 'pt', 'quc', 'rm', 'sco', 'sl', 'sq', 'sv', 'sw', 'tet', + 'tr', 'tt', 'uz', 'vo', 'wae', 'yua', 'za', 'zh-Hans', 'zh-Hant', 'zu' :type language: str or ~azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage + :param pages: Custom page numbers for multi-page documents(PDF/TIFF), + input the number of the pages you want to get OCR result. For a range + of pages, use a hyphen. Separate each page or range with a comma. + :type pages: list[str] + :param model_version: Optional parameter to specify the version of the + OCR model used for text extraction. Accepted values are: "latest", + "latest-preview", "2021-04-12". Defaults to "latest". + :type model_version: str + :param reading_order: Optional parameter to specify which reading + order algorithm should be applied when ordering the extract text + elements. Can be either 'basic' or 'natural'. Will default to 'basic' + if not specified + :type reading_order: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -744,7 +809,7 @@ def read( :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionOcrErrorException` """ image_url = models.ImageUrl(url=url) @@ -759,6 +824,12 @@ def read( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if pages is not None: + query_parameters['pages'] = self._serialize.query("pages", pages, '[str]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') + if reading_order is not None: + query_parameters['readingOrder'] = self._serialize.query("reading_order", reading_order, 'str') # Construct headers header_parameters = {} @@ -774,7 +845,7 @@ def read( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [202]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionOcrErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) @@ -803,7 +874,7 @@ def get_read_result( ~azure.cognitiveservices.vision.computervision.models.ReadOperationResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionOcrErrorException` """ # Construct URL url = self.get_read_result.metadata['url'] @@ -827,7 +898,7 @@ def get_read_result( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionOcrErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -841,7 +912,7 @@ def get_read_result( get_read_result.metadata = {'url': '/read/analyzeResults/{operationId}'} def analyze_image_in_stream( - self, image, visual_features=None, details=None, language="en", description_exclude=None, custom_headers=None, raw=False, callback=None, **operation_config): + self, image, visual_features=None, details=None, language="en", description_exclude=None, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation extracts a rich set of visual features based on the image content. Two input methods are supported -- (1) Uploading an image or (2) @@ -890,6 +961,10 @@ def analyze_image_in_stream( generating the description. :type description_exclude: list[str or ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -905,7 +980,7 @@ def analyze_image_in_stream( ~azure.cognitiveservices.vision.computervision.models.ImageAnalysis or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.analyze_image_in_stream.metadata['url'] @@ -924,6 +999,8 @@ def analyze_image_in_stream( query_parameters['language'] = self._serialize.query("language", language, 'str') if description_exclude is not None: query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -940,7 +1017,7 @@ def analyze_image_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -954,7 +1031,7 @@ def analyze_image_in_stream( analyze_image_in_stream.metadata = {'url': '/analyze'} def get_area_of_interest_in_stream( - self, image, custom_headers=None, raw=False, callback=None, **operation_config): + self, image, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation returns a bounding box around the most important area of the image. A successful response will be returned in JSON. If the request failed, @@ -967,6 +1044,10 @@ def get_area_of_interest_in_stream( :param image: An image stream. :type image: Generator + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -982,7 +1063,7 @@ def get_area_of_interest_in_stream( ~azure.cognitiveservices.vision.computervision.models.AreaOfInterestResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.get_area_of_interest_in_stream.metadata['url'] @@ -993,6 +1074,8 @@ def get_area_of_interest_in_stream( # Construct parameters query_parameters = {} + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1009,7 +1092,7 @@ def get_area_of_interest_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1023,7 +1106,7 @@ def get_area_of_interest_in_stream( get_area_of_interest_in_stream.metadata = {'url': '/areaOfInterest'} def describe_image_in_stream( - self, image, max_candidates=1, language="en", description_exclude=None, custom_headers=None, raw=False, callback=None, **operation_config): + self, image, max_candidates=1, language="en", description_exclude=None, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. @@ -1051,6 +1134,10 @@ def describe_image_in_stream( generating the description. :type description_exclude: list[str or ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1066,7 +1153,7 @@ def describe_image_in_stream( ~azure.cognitiveservices.vision.computervision.models.ImageDescription or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.describe_image_in_stream.metadata['url'] @@ -1083,6 +1170,8 @@ def describe_image_in_stream( query_parameters['language'] = self._serialize.query("language", language, 'str') if description_exclude is not None: query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1099,7 +1188,7 @@ def describe_image_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1113,7 +1202,7 @@ def describe_image_in_stream( describe_image_in_stream.metadata = {'url': '/describe'} def detect_objects_in_stream( - self, image, custom_headers=None, raw=False, callback=None, **operation_config): + self, image, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """Performs object detection on the specified image. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. @@ -1123,6 +1212,10 @@ def detect_objects_in_stream( :param image: An image stream. :type image: Generator + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1138,7 +1231,7 @@ def detect_objects_in_stream( ~azure.cognitiveservices.vision.computervision.models.DetectResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.detect_objects_in_stream.metadata['url'] @@ -1149,6 +1242,8 @@ def detect_objects_in_stream( # Construct parameters query_parameters = {} + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1165,7 +1260,7 @@ def detect_objects_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1179,7 +1274,7 @@ def detect_objects_in_stream( detect_objects_in_stream.metadata = {'url': '/detect'} def generate_thumbnail_in_stream( - self, width, height, image, smart_cropping=False, custom_headers=None, raw=False, callback=None, **operation_config): + self, width, height, image, smart_cropping=False, model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping @@ -1203,6 +1298,10 @@ def generate_thumbnail_in_stream( :type image: Generator :param smart_cropping: Boolean flag for enabling smart cropping. :type smart_cropping: bool + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1231,6 +1330,8 @@ def generate_thumbnail_in_stream( query_parameters['height'] = self._serialize.query("height", height, 'int', maximum=1024, minimum=1) if smart_cropping is not None: query_parameters['smartCropping'] = self._serialize.query("smart_cropping", smart_cropping, 'bool') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1259,7 +1360,7 @@ def generate_thumbnail_in_stream( generate_thumbnail_in_stream.metadata = {'url': '/generateThumbnail'} def analyze_image_by_domain_in_stream( - self, model, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, model, image, language="en", model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models @@ -1281,6 +1382,10 @@ def analyze_image_by_domain_in_stream( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1296,7 +1401,7 @@ def analyze_image_by_domain_in_stream( ~azure.cognitiveservices.vision.computervision.models.DomainModelResults or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.analyze_image_by_domain_in_stream.metadata['url'] @@ -1310,6 +1415,8 @@ def analyze_image_by_domain_in_stream( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1326,7 +1433,7 @@ def analyze_image_by_domain_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1340,7 +1447,7 @@ def analyze_image_by_domain_in_stream( analyze_image_by_domain_in_stream.metadata = {'url': '/models/{model}/analyze'} def recognize_printed_text_in_stream( - self, image, detect_orientation=True, language="unk", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, detect_orientation=True, language="unk", model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """Optical Character Recognition (OCR) detects text in an image and extracts the recognized characters into a machine-usable character stream. @@ -1364,6 +1471,10 @@ def recognize_printed_text_in_stream( 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' :type language: str or ~azure.cognitiveservices.vision.computervision.models.OcrLanguages + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1379,7 +1490,7 @@ def recognize_printed_text_in_stream( ~azure.cognitiveservices.vision.computervision.models.OcrResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.recognize_printed_text_in_stream.metadata['url'] @@ -1393,6 +1504,8 @@ def recognize_printed_text_in_stream( query_parameters['detectOrientation'] = self._serialize.query("detect_orientation", detect_orientation, 'bool') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'OcrLanguages') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1409,7 +1522,7 @@ def recognize_printed_text_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1423,7 +1536,7 @@ def recognize_printed_text_in_stream( recognize_printed_text_in_stream.metadata = {'url': '/ocr'} def tag_image_in_stream( - self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, language="en", model_version="latest", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in @@ -1445,6 +1558,10 @@ def tag_image_in_stream( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param model_version: Optional parameter to specify the version of the + AI model. Accepted values are: "latest", "2021-04-01". Defaults to + "latest". + :type model_version: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1460,7 +1577,7 @@ def tag_image_in_stream( ~azure.cognitiveservices.vision.computervision.models.TagResult or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionErrorResponseException` """ # Construct URL url = self.tag_image_in_stream.metadata['url'] @@ -1473,6 +1590,8 @@ def tag_image_in_stream( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') # Construct headers header_parameters = {} @@ -1489,7 +1608,7 @@ def tag_image_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: @@ -1503,7 +1622,7 @@ def tag_image_in_stream( tag_image_in_stream.metadata = {'url': '/tag'} def read_in_stream( - self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, language=None, pages=None, model_version="latest", reading_order="basic", custom_headers=None, raw=False, callback=None, **operation_config): """Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, @@ -1513,16 +1632,33 @@ def read_in_stream( :param image: An image stream. :type image: Generator - :param language: The BCP-47 language code of the text to be detected - in the image. In future versions, when language parameter is not - passed, language detection will be used to determine the language. - However, in the current version, missing language parameter will cause - English to be used. To ensure that your document is always parsed in - English without the use of language detection in the future, pass “en” - in the language parameter. Possible values include: 'en', 'es', 'fr', - 'de', 'it', 'nl', 'pt' + :param language: The BCP-47 language code of the text in the document. + Read supports auto language identification and multi-language + documents, so only provide a language code if you would like to force + the document to be processed in that specific language. See + https://aka.ms/ocr-languages for list of supported languages. Possible + values include: 'af', 'ast', 'bi', 'br', 'ca', 'ceb', 'ch', 'co', + 'crh', 'cs', 'csb', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fil', + 'fj', 'fr', 'fur', 'fy', 'ga', 'gd', 'gil', 'gl', 'gv', 'hni', 'hsb', + 'ht', 'hu', 'ia', 'id', 'it', 'iu', 'ja', 'jv', 'kaa', 'kac', 'kea', + 'kha', 'kl', 'ko', 'ku', 'kw', 'lb', 'ms', 'mww', 'nap', 'nl', 'no', + 'oc', 'pl', 'pt', 'quc', 'rm', 'sco', 'sl', 'sq', 'sv', 'sw', 'tet', + 'tr', 'tt', 'uz', 'vo', 'wae', 'yua', 'za', 'zh-Hans', 'zh-Hant', 'zu' :type language: str or ~azure.cognitiveservices.vision.computervision.models.OcrDetectionLanguage + :param pages: Custom page numbers for multi-page documents(PDF/TIFF), + input the number of the pages you want to get OCR result. For a range + of pages, use a hyphen. Separate each page or range with a comma. + :type pages: list[str] + :param model_version: Optional parameter to specify the version of the + OCR model used for text extraction. Accepted values are: "latest", + "latest-preview", "2021-04-12". Defaults to "latest". + :type model_version: str + :param reading_order: Optional parameter to specify which reading + order algorithm should be applied when ordering the extract text + elements. Can be either 'basic' or 'natural'. Will default to 'basic' + if not specified + :type reading_order: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1536,7 +1672,7 @@ def read_in_stream( :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: - :class:`ComputerVisionErrorException` + :class:`ComputerVisionOcrErrorException` """ # Construct URL url = self.read_in_stream.metadata['url'] @@ -1549,6 +1685,12 @@ def read_in_stream( query_parameters = {} if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if pages is not None: + query_parameters['pages'] = self._serialize.query("pages", pages, '[str]', div=',') + if model_version is not None: + query_parameters['model-version'] = self._serialize.query("model_version", model_version, 'str', pattern=r'^(latest|\d{4}-\d{2}-\d{2})(-preview)?$') + if reading_order is not None: + query_parameters['readingOrder'] = self._serialize.query("reading_order", reading_order, 'str') # Construct headers header_parameters = {} @@ -1564,7 +1706,7 @@ def read_in_stream( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [202]: - raise models.ComputerVisionErrorException(self._deserialize, response) + raise models.ComputerVisionOcrErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response)