From d263a95e5976061fb5f6912ed9ef31f9c76a825b Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 25 Oct 2019 09:45:47 +0000 Subject: [PATCH] Generated from a71df15a587ec060147aaef2dcfc12d19500fdc8 Fix json format by prettier --- .../personalizer/__init__.py | 7 +- .../personalizer/_configuration.py | 46 +++ .../personalizer/_personalizer_client.py | 49 +++ .../personalizer/models/__init__.py | 40 +-- .../personalizer/models/_models.py | 291 ++++++++++++++++++ .../personalizer/models/_models_py3.py | 291 ++++++++++++++++++ ...enums.py => _personalizer_client_enums.py} | 0 .../personalizer/models/error_response.py | 48 --- .../personalizer/models/error_response_py3.py | 48 --- .../personalizer/models/internal_error.py | 34 -- .../personalizer/models/internal_error_py3.py | 34 -- .../personalizer/models/personalizer_error.py | 56 ---- .../models/personalizer_error_py3.py | 56 ---- .../personalizer/models/rank_request.py | 74 ----- .../personalizer/models/rank_request_py3.py | 74 ----- .../personalizer/models/rank_response.py | 49 --- .../personalizer/models/rank_response_py3.py | 49 --- .../personalizer/models/rankable_action.py | 39 --- .../models/rankable_action_py3.py | 39 --- .../personalizer/models/ranked_action.py | 40 --- .../personalizer/models/ranked_action_py3.py | 40 --- .../personalizer/models/reward_request.py | 35 --- .../personalizer/models/reward_request_py3.py | 35 --- .../personalizer/operations/__init__.py | 4 +- ...ts_operations.py => _events_operations.py} | 11 +- .../_personalizer_client_operations.py} | 67 +--- 26 files changed, 712 insertions(+), 844 deletions(-) create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_configuration.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_client.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py rename sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/{personalizer_client_enums.py => _personalizer_client_enums.py} (100%) delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py delete mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py rename sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/{events_operations.py => _events_operations.py} (90%) rename sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/{personalizer_client.py => operations/_personalizer_client_operations.py} (50%) 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..c116b2e71773 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 PersonalizerClientConfiguration +from ._personalizer_client import PersonalizerClient +__all__ = ['PersonalizerClient', 'PersonalizerClientConfiguration'] -__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..fb511b5eae15 --- /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 PersonalizerClientConfiguration(Configuration): + """Configuration for PersonalizerClient + 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.0' + + super(PersonalizerClientConfiguration, 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_client.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_client.py new file mode 100644 index 000000000000..13213cc088b3 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_client.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import PersonalizerClientConfiguration +from .operations import PersonalizerClientOperationsMixin +from .operations import EventsOperations +from . import models + + +class PersonalizerClient(PersonalizerClientOperationsMixin, 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 your content in a ranked list. As rewards are sent in response to the ranked list, the reinforcement learning algorithm will improve the model and improve performance of future rank calls. + + :ivar config: Configuration for client. + :vartype config: PersonalizerClientConfiguration + + :ivar events: Events operations + :vartype events: azure.cognitiveservices.personalizer.operations.EventsOperations + + :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 = PersonalizerClientConfiguration(endpoint, credentials) + super(PersonalizerClient, 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.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.events = EventsOperations( + 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..6b29a7935f92 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,35 @@ # -------------------------------------------------------------------------- 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 ErrorResponse, ErrorResponseException + from ._models_py3 import InternalError + from ._models_py3 import PersonalizerError + 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 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 ( + from ._models import ErrorResponse, ErrorResponseException + from ._models import InternalError + from ._models import PersonalizerError + from ._models import RankableAction + from ._models import RankedAction + from ._models import RankRequest + from ._models import RankResponse + from ._models import RewardRequest +from ._personalizer_client_enums import ( ErrorCode, ) __all__ = [ + 'ErrorResponse', 'ErrorResponseException', 'InternalError', 'PersonalizerError', - 'ErrorResponse', 'ErrorResponseException', - 'RewardRequest', 'RankableAction', - 'RankRequest', 'RankedAction', + 'RankRequest', 'RankResponse', + 'RewardRequest', 'ErrorCode', ] 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..3c6c7661846e --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py @@ -0,0 +1,291 @@ +# 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 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. The error object. + :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 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: The error object. + :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 PersonalizerError(Model): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. High level error code. Possible values include: + 'BadRequest', 'ResourceNotFound', 'InternalServerError' + :type code: str or ~azure.cognitiveservices.personalizer.models.ErrorCode + :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: Finer error details. + :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 RankableAction(Model): + """An action with it's 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 depends on the application, and + typically includes features about the current user, their + device, profile information, data about time and date, etc. + :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. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param excluded_actions: The set of action ids to exclude from ranking. + :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 the user will see the rank results, + 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 + rank results, because the page is rendering later, or the Rank results may + be + overridden by code further downstream. 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): + """A resulting ordered list of actions that result from 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 for which to report the reward. This might not be the + first found in 'ranking' if an action in the request in first position was + part of the excluded ids. + :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 should + be between -1 and 1 inclusive. + :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) 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..fcdb9107da05 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py @@ -0,0 +1,291 @@ +# 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 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. The error object. + :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 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: The error object. + :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 PersonalizerError(Model): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. High level error code. Possible values include: + 'BadRequest', 'ResourceNotFound', 'InternalServerError' + :type code: str or ~azure.cognitiveservices.personalizer.models.ErrorCode + :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: Finer error details. + :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 RankableAction(Model): + """An action with it's 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 depends on the application, and + typically includes features about the current user, their + device, profile information, data about time and date, etc. + :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. + :type actions: + list[~azure.cognitiveservices.personalizer.models.RankableAction] + :param excluded_actions: The set of action ids to exclude from ranking. + :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 the user will see the rank results, + 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 + rank results, because the page is rendering later, or the Rank results may + be + overridden by code further downstream. 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): + """A resulting ordered list of actions that result from 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 for which to report the reward. This might not be the + first found in 'ranking' if an action in the request in first position was + part of the excluded ids. + :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 should + be between -1 and 1 inclusive. + :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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_client_enums.py similarity index 100% rename from sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py rename to sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_client_enums.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py deleted file mode 100644 index f18e28c56cdd..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError - - -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. The error object. - :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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py deleted file mode 100644 index e9a8d26d2d59..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError - - -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. The error object. - :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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py deleted file mode 100644 index 59fd86cf5475..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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: The error object. - :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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py deleted file mode 100644 index 65d1e4290432..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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: The error object. - :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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py deleted file mode 100644 index fa66768e93a9..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class PersonalizerError(Model): - """The error object. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. High level error code. Possible values include: - 'BadRequest', 'ResourceNotFound', 'InternalServerError' - :type code: str or ~azure.cognitiveservices.personalizer.models.ErrorCode - :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: Finer error details. - :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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py deleted file mode 100644 index 6b8fc62ebb5d..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class PersonalizerError(Model): - """The error object. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. High level error code. Possible values include: - 'BadRequest', 'ResourceNotFound', 'InternalServerError' - :type code: str or ~azure.cognitiveservices.personalizer.models.ErrorCode - :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: Finer error details. - :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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py deleted file mode 100644 index 1adabd6f6f0f..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 depends on the application, and - typically includes features about the current user, their - device, profile information, data about time and date, etc. - :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. - :type actions: - list[~azure.cognitiveservices.personalizer.models.RankableAction] - :param excluded_actions: The set of action ids to exclude from ranking. - :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 the user will see the rank results, - 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 - rank results, because the page is rendering later, or the Rank results may - be - overridden by code further downstream. 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py deleted file mode 100644 index 5e1b306ce4a2..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 depends on the application, and - typically includes features about the current user, their - device, profile information, data about time and date, etc. - :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. - :type actions: - list[~azure.cognitiveservices.personalizer.models.RankableAction] - :param excluded_actions: The set of action ids to exclude from ranking. - :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 the user will see the rank results, - 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 - rank results, because the page is rendering later, or the Rank results may - be - overridden by code further downstream. 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py deleted file mode 100644 index f831b5389402..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RankResponse(Model): - """A resulting ordered list of actions that result from 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 for which to report the reward. This might not be the - first found in 'ranking' if an action in the request in first position was - part of the excluded ids. - :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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py deleted file mode 100644 index e75da88b8cce..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RankResponse(Model): - """A resulting ordered list of actions that result from 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 for which to report the reward. This might not be the - first found in 'ranking' if an action in the request in first position was - part of the excluded ids. - :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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py deleted file mode 100644 index a26c453ccba9..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RankableAction(Model): - """An action with it's 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py deleted file mode 100644 index 18de4a0a9014..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class RankableAction(Model): - """An action with it's 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py deleted file mode 100644 index 379956ff7f58..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py deleted file mode 100644 index 367bb71c38a7..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py deleted file mode 100644 index 083d90332935..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 should - be between -1 and 1 inclusive. - :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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py deleted file mode 100644 index e8a91e550599..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class 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 should - be between -1 and 1 inclusive. - :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 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..45c6891cd35e 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,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .events_operations import EventsOperations +from ._events_operations import EventsOperations +from ._personalizer_client_operations import PersonalizerClientOperationsMixin __all__ = [ 'EventsOperations', + 'PersonalizerClientOperationsMixin', ] 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 similarity index 90% rename from sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/events_operations.py rename to sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_events_operations.py index 6d4481fe8b02..24819c091988 100644 --- 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 @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- from msrest.pipeline import ClientRawResponse -from msrest.exceptions import HttpOperationError from .. import models @@ -18,6 +17,8 @@ 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. @@ -52,7 +53,7 @@ def reward( :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: - :class:`HttpOperationError` + :class:`ErrorResponseException` """ reward1 = models.RewardRequest(value=value) @@ -81,7 +82,7 @@ def reward( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [204]: - raise HttpOperationError(self._deserialize, response) + raise models.ErrorResponseException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) @@ -103,7 +104,7 @@ def activate( :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: - :class:`HttpOperationError` + :class:`ErrorResponseException` """ # Construct URL url = self.activate.metadata['url'] @@ -126,7 +127,7 @@ def activate( response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [204]: - raise HttpOperationError(self._deserialize, response) + raise models.ErrorResponseException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_client_operations.py similarity index 50% rename from sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py rename to sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_client_operations.py index 672fc01fd864..478abfc28051 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_client_operations.py @@ -9,73 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Configuration, Serializer, Deserializer -from .version import VERSION from msrest.pipeline import ClientRawResponse -from msrest.exceptions import HttpOperationError -from .operations.events_operations import EventsOperations -from . import models +from .. import models -class PersonalizerClientConfiguration(Configuration): - """Configuration for PersonalizerClient - 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.0' - - super(PersonalizerClientConfiguration, self).__init__(base_url) - - self.add_user_agent('azure-cognitiveservices-personalizer/{}'.format(VERSION)) - - self.endpoint = endpoint - self.credentials = credentials - - -class PersonalizerClient(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 your content in a ranked list. As rewards are sent in response to the ranked list, the reinforcement learning algorithm will improve the model and improve performance of future rank calls. - - :ivar config: Configuration for client. - :vartype config: PersonalizerClientConfiguration - - :ivar events: Events operations - :vartype events: azure.cognitiveservices.personalizer.operations.EventsOperations - - :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 = PersonalizerClientConfiguration(endpoint, credentials) - super(PersonalizerClient, 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.0' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.events = EventsOperations( - self._client, self.config, self._serialize, self._deserialize) +class PersonalizerClientOperationsMixin(object): def rank( self, rank_request, custom_headers=None, raw=False, **operation_config): @@ -123,7 +61,6 @@ def rank( raise models.ErrorResponseException(self._deserialize, response) deserialized = None - if response.status_code == 201: deserialized = self._deserialize('RankResponse', response)