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..85868ea0535b --- /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": "d7c0c63648d78efc9ddf2a85a5afbb3e70062eea", + "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..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..6721d39acf94 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/_personalizer_client.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import PersonalizerClientConfiguration +from .operations import PersonalizerClientOperationsMixin +from msrest.exceptions import HttpOperationError +from .operations import ServiceConfigurationOperations +from .operations import PolicyOperations +from .operations import EvaluationsOperations +from .operations import EventsOperations +from .operations import LogOperations +from .operations import ModelOperations +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 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: PersonalizerClientConfiguration + + :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 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 + + :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.service_configuration = ServiceConfigurationOperations( + self._client, self.config, self._serialize, self._deserialize) + self.policy = PolicyOperations( + 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) 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..2c8df73a9fbf 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,73 @@ # -------------------------------------------------------------------------- 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 ContainerStatus + 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 PersonalizerError + from ._models_py3 import PolicyContract + 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 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 ContainerStatus + 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 PersonalizerError + from ._models import PolicyContract + 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 ._personalizer_client_enums import ( + EvaluationJobStatus, + PersonalizerErrorCode, ) __all__ = [ + 'ContainerStatus', + 'DateRange', + 'ErrorResponse', 'ErrorResponseException', + 'Evaluation', + 'EvaluationContract', 'InternalError', + 'LogsProperties', + 'LogsPropertiesDateRange', + 'ModelProperties', 'PersonalizerError', - 'ErrorResponse', 'ErrorResponseException', - 'RewardRequest', + 'PolicyContract', + 'PolicyResult', + 'PolicyResultSummary', + 'PolicyResultTotalSummary', 'RankableAction', - 'RankRequest', 'RankedAction', + 'RankRequest', 'RankResponse', - 'ErrorCode', + 'RewardRequest', + 'ServiceConfiguration', + 'PersonalizerErrorCode', + 'EvaluationJobStatus', ] 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..f1cee0a3c3ed --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models.py @@ -0,0 +1,777 @@ +# 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 ContainerStatus(Model): + """ContainerStatus. + + :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(ContainerStatus, 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 DateRange(Model): + """DateRange. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: + :vartype from_property: datetime + :ivar to: + :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. 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 Evaluation(Model): + """Evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar start_time: + :vartype start_time: datetime + :ivar end_time: + :vartype end_time: datetime + :ivar job_id: + :vartype job_id: str + :ivar status: Possible values include: 'completed', 'pending', 'failed', + 'notSubmitted' + :vartype status: str or + ~azure.cognitiveservices.personalizer.models.EvaluationJobStatus + :param policy_results: + :type policy_results: + list[~azure.cognitiveservices.personalizer.models.PolicyResult] + :param feature_importance: + :type feature_importance: list[list[str]] + """ + + _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]]'}, + } + + 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) + + +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: 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 LogsProperties(Model): + """LogsProperties. + + 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: + :vartype from_property: datetime + :ivar to: + :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): + """ModelProperties. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar creation_time: + :vartype creation_time: datetime + :ivar last_modified_time: + :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 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', + 'InvalidServiceConfiguration', 'InvalidPolicyConfiguration', + 'InvalidPolicyContract', 'InvalidEvaluationContract', + 'InvalidRewardRequest', 'InvalidEventIdToActivate', 'InvalidRankRequest', + 'InvalidExportLogsRequest', 'InvalidContainer', 'FrontEndNotFound', + 'EvaluationNotFound', 'LogsPropertiesNotFound', 'RankNullResponse', + 'UpdateConfigurationFailed', 'ModelResetFailed' + :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: 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 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 PolicyResult(Model): + """PolicyResult. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: + :vartype name: str + :ivar arguments: + :vartype arguments: str + :ivar summary: + :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}, + 'summary': {'readonly': True}, + 'total_summary': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', '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.summary = None + self.total_summary = None + + +class PolicyResultSummary(Model): + """PolicyResultSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: + :vartype aggregate_time_window: timedelta + :param non_zero_probability: + :type non_zero_probability: float + :ivar confidence_interval: + :vartype confidence_interval: float + :ivar sum_of_squares: + :vartype sum_of_squares: 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}, + 'confidence_interval': {'readonly': True}, + 'sum_of_squares': {'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'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', '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.confidence_interval = None + self.sum_of_squares = None + + +class PolicyResultTotalSummary(PolicyResultSummary): + """PolicyResultTotalSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: + :vartype aggregate_time_window: timedelta + :param non_zero_probability: + :type non_zero_probability: float + :ivar confidence_interval: + :vartype confidence_interval: float + :ivar sum_of_squares: + :vartype sum_of_squares: 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}, + 'confidence_interval': {'readonly': True}, + 'sum_of_squares': {'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'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(PolicyResultTotalSummary, self).__init__(**kwargs) + + +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, 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. + :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, 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): + """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' 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) + + +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. + 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 + """ + + _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'}, + } + + 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) 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..0392ed6a2166 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_models_py3.py @@ -0,0 +1,777 @@ +# 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 ContainerStatus(Model): + """ContainerStatus. + + :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(ContainerStatus, self).__init__(**kwargs) + self.service = service + self.api_status = api_status + self.api_status_message = api_status_message + + +class DateRange(Model): + """DateRange. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar from_property: + :vartype from_property: datetime + :ivar to: + :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. 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 Evaluation(Model): + """Evaluation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar start_time: + :vartype start_time: datetime + :ivar end_time: + :vartype end_time: datetime + :ivar job_id: + :vartype job_id: str + :ivar status: Possible values include: 'completed', 'pending', 'failed', + 'notSubmitted' + :vartype status: str or + ~azure.cognitiveservices.personalizer.models.EvaluationJobStatus + :param policy_results: + :type policy_results: + list[~azure.cognitiveservices.personalizer.models.PolicyResult] + :param feature_importance: + :type feature_importance: list[list[str]] + """ + + _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]]'}, + } + + def __init__(self, *, policy_results=None, feature_importance=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 + + +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: 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 LogsProperties(Model): + """LogsProperties. + + 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: + :vartype from_property: datetime + :ivar to: + :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): + """ModelProperties. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar creation_time: + :vartype creation_time: datetime + :ivar last_modified_time: + :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 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', + 'InvalidServiceConfiguration', 'InvalidPolicyConfiguration', + 'InvalidPolicyContract', 'InvalidEvaluationContract', + 'InvalidRewardRequest', 'InvalidEventIdToActivate', 'InvalidRankRequest', + 'InvalidExportLogsRequest', 'InvalidContainer', 'FrontEndNotFound', + 'EvaluationNotFound', 'LogsPropertiesNotFound', 'RankNullResponse', + 'UpdateConfigurationFailed', 'ModelResetFailed' + :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: 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 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 PolicyResult(Model): + """PolicyResult. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: + :vartype name: str + :ivar arguments: + :vartype arguments: str + :ivar summary: + :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}, + 'summary': {'readonly': True}, + 'total_summary': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'arguments': {'key': 'arguments', '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.summary = None + self.total_summary = None + + +class PolicyResultSummary(Model): + """PolicyResultSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: + :vartype aggregate_time_window: timedelta + :param non_zero_probability: + :type non_zero_probability: float + :ivar confidence_interval: + :vartype confidence_interval: float + :ivar sum_of_squares: + :vartype sum_of_squares: 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}, + 'confidence_interval': {'readonly': True}, + 'sum_of_squares': {'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'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', '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.confidence_interval = None + self.sum_of_squares = None + + +class PolicyResultTotalSummary(PolicyResultSummary): + """PolicyResultTotalSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar time_stamp: + :vartype time_stamp: datetime + :ivar ips_estimator_numerator: + :vartype ips_estimator_numerator: float + :ivar ips_estimator_denominator: + :vartype ips_estimator_denominator: float + :ivar snips_estimator_denominator: + :vartype snips_estimator_denominator: float + :ivar aggregate_time_window: + :vartype aggregate_time_window: timedelta + :param non_zero_probability: + :type non_zero_probability: float + :ivar confidence_interval: + :vartype confidence_interval: float + :ivar sum_of_squares: + :vartype sum_of_squares: 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}, + 'confidence_interval': {'readonly': True}, + 'sum_of_squares': {'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'}, + 'confidence_interval': {'key': 'confidenceInterval', 'type': 'float'}, + 'sum_of_squares': {'key': 'sumOfSquares', '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 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, 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. + :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, 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): + """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' 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 + + +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. + 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 + """ + + _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'}, + } + + 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, **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 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 new file mode 100644 index 000000000000..d4fb8fafa605 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/_personalizer_client_enums.py @@ -0,0 +1,42 @@ +# 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 PersonalizerErrorCode(str, Enum): + + bad_request = "BadRequest" #: Request could not be understood by the server. + resource_not_found = "ResourceNotFound" #: Requested resource does not exist on the server. + internal_server_error = "InternalServerError" #: A generic error has occurred on the server. + invalid_service_configuration = "InvalidServiceConfiguration" #: Invalid service configuration. + invalid_policy_configuration = "InvalidPolicyConfiguration" #: Invalid policy configuration. + invalid_policy_contract = "InvalidPolicyContract" #: Invalid policy contract. + invalid_evaluation_contract = "InvalidEvaluationContract" #: Invalid evaluation contract. + invalid_reward_request = "InvalidRewardRequest" #: Invalid reward request. + invalid_event_id_to_activate = "InvalidEventIdToActivate" #: Invalid activate event request. + invalid_rank_request = "InvalidRankRequest" #: Invalid rank request. + invalid_export_logs_request = "InvalidExportLogsRequest" #: Invalid export logs request. + invalid_container = "InvalidContainer" #: SAS Uri must be the Uri to a container that has write permissions. + front_end_not_found = "FrontEndNotFound" #: Front end not found. + evaluation_not_found = "EvaluationNotFound" #: Evaluation not found. + logs_properties_not_found = "LogsPropertiesNotFound" #: Logs properties not found. + rank_null_response = "RankNullResponse" #: Rank call returned null response. + update_configuration_failed = "UpdateConfigurationFailed" #: Failed to update configuration. + model_reset_failed = "ModelResetFailed" #: Model reset failed. + + +class EvaluationJobStatus(str, Enum): + + completed = "completed" + pending = "pending" + failed = "failed" + not_submitted = "notSubmitted" 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_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py deleted file mode 100644 index 4782ec9e9354..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py +++ /dev/null @@ -1,19 +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 enum import Enum - - -class ErrorCode(str, Enum): - - bad_request = "BadRequest" #: Request could not be understood by the server. - resource_not_found = "ResourceNotFound" #: Requested resource does not exist on the server. - internal_server_error = "InternalServerError" #: A generic error has occurred on the server. 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..a46980c419fc 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,20 @@ # regenerated. # -------------------------------------------------------------------------- -from .events_operations import EventsOperations +from ._service_configuration_operations import ServiceConfigurationOperations +from ._policy_operations import PolicyOperations +from ._evaluations_operations import EvaluationsOperations +from ._events_operations import EventsOperations +from ._log_operations import LogOperations +from ._model_operations import ModelOperations +from ._personalizer_client_operations import PersonalizerClientOperationsMixin __all__ = [ + 'ServiceConfigurationOperations', + 'PolicyOperations', + 'EvaluationsOperations', 'EventsOperations', + 'LogOperations', + 'ModelOperations', + 'PersonalizerClientOperationsMixin', ] 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..df6773173e4c --- /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 get( + self, evaluation_id, custom_headers=None, raw=False, **operation_config): + """Get Evaluation. + + Get the evaluation associated with the Id. + + :param evaluation_id: Id of the 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 delete( + self, evaluation_id, custom_headers=None, raw=False, **operation_config): + """Delete Evaluation. + + Delete the evaluation associated with the Id. + + :param evaluation_id: Id of the 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 list( + self, custom_headers=None, raw=False, **operation_config): + """List Evaluations. + + List all the submitted 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 Evaluation. + + Submit a new evaluation job. + + :param evaluation: The 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 similarity index 86% 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..69ebe5930916 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. @@ -36,8 +37,10 @@ def __init__(self, client, config, serializer, deserializer): def reward( self, event_id, value, custom_headers=None, raw=False, **operation_config): - """Report reward to allocate to the top ranked action for the specified - event. + """Post Reward. + + Report reward 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 @@ -52,7 +55,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 +84,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) @@ -90,7 +93,9 @@ def reward( def activate( self, event_id, custom_headers=None, raw=False, **operation_config): - """Report that the specified event was actually displayed to the user and + """Activate Event. + + Report that the specified event was actually displayed to the user and a reward should be expected for it. :param event_id: The event ID this activation applies to. @@ -103,7 +108,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 +131,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/operations/_log_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_log_operations.py new file mode 100644 index 000000000000..80f0a1f5bf44 --- /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 generated 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: 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 generated 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/personalizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/_personalizer_client_operations.py similarity index 51% 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..be1edd6484d6 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,77 +9,19 @@ # 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): - """A Personalizer rank request. + """Post Rank. + + Submit a Personalizer rank request, to get which of the provided + actions should be used in the provided context. :param rank_request: A Personalizer request. :type rank_request: @@ -123,7 +65,6 @@ def rank( raise models.ErrorResponseException(self._deserialize, response) deserialized = None - if response.status_code == 201: deserialized = self._deserialize('RankResponse', response) 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..a6353a35b0bc --- /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..468ac88bebc6 --- /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 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'} + + 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'}