From edb5fcab2d93321f8945f6cc49cc95dd8f9d6c02 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 28 May 2019 14:54:14 -0700 Subject: [PATCH 1/6] [AutoPR cognitiveservices/data-plane/Personalizer] Personlizer Python (#5496) * Generated from b6fe4016187aaea619e850a0cda7cb6c5fff837f Personlizer Python * Packaging update of azure-cognitiveservices-personalizer --- .../HISTORY.rst | 9 ++ .../MANIFEST.in | 5 + .../README.rst | 33 +++++ .../azure/__init__.py | 1 + .../azure/cognitiveservices/__init__.py | 1 + .../personalizer/__init__.py | 18 +++ .../personalizer/models/__init__.py | 44 ++++++ .../personalizer/models/error_response.py | 48 +++++++ .../personalizer/models/error_response_py3.py | 48 +++++++ .../personalizer/models/internal_error.py | 34 +++++ .../personalizer/models/internal_error_py3.py | 34 +++++ .../models/personalizer_client_enums.py | 19 +++ .../personalizer/models/personalizer_error.py | 56 ++++++++ .../models/personalizer_error_py3.py | 56 ++++++++ .../personalizer/models/rank_request.py | 74 ++++++++++ .../personalizer/models/rank_request_py3.py | 74 ++++++++++ .../personalizer/models/rank_response.py | 49 +++++++ .../personalizer/models/rank_response_py3.py | 49 +++++++ .../personalizer/models/rankable_action.py | 39 +++++ .../models/rankable_action_py3.py | 39 +++++ .../personalizer/models/ranked_action.py | 40 ++++++ .../personalizer/models/ranked_action_py3.py | 40 ++++++ .../personalizer/models/reward_request.py | 35 +++++ .../personalizer/models/reward_request_py3.py | 35 +++++ .../personalizer/operations/__init__.py | 16 +++ .../operations/events_operations.py | 134 +++++++++++++++++ .../personalizer/personalizer_client.py | 135 ++++++++++++++++++ .../cognitiveservices/personalizer/version.py | 13 ++ .../sdk_packaging.toml | 8 ++ .../setup.cfg | 2 + .../setup.py | 88 ++++++++++++ 31 files changed, 1276 insertions(+) create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/events_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.cfg create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst new file mode 100644 index 000000000000..8924d5d6c445 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (1970-01-01) +++++++++++++++++++ + +* Initial Release diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in new file mode 100644 index 000000000000..b0e4c732e4ce --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/MANIFEST.in @@ -0,0 +1,5 @@ +recursive-include tests *.py *.yaml +include *.rst +include azure/__init__.py +include azure/cognitiveservices/__init__.py + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst new file mode 100644 index 000000000000..beb4a05e0028 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst @@ -0,0 +1,33 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure MyService Management Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Usage +===== + +For code examples, see `MyService Management +`__ +on docs.microsoft.com. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. + + +.. image:: https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-personalizer%2FREADME.png diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ 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 new file mode 100644 index 000000000000..50d6c96bf888 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/__init__.py @@ -0,0 +1,18 @@ +# 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 .personalizer_client import PersonalizerClient +from .version import VERSION + +__all__ = ['PersonalizerClient'] + +__version__ = VERSION + 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 new file mode 100644 index 000000000000..2f33d5a2bc5e --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/__init__.py @@ -0,0 +1,44 @@ +# 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. +# -------------------------------------------------------------------------- + +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 +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, +) + +__all__ = [ + 'InternalError', + 'PersonalizerError', + 'ErrorResponse', 'ErrorResponseException', + 'RewardRequest', + 'RankableAction', + 'RankRequest', + 'RankedAction', + 'RankResponse', + 'ErrorCode', +] 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 new file mode 100644 index 000000000000..f18e28c56cdd --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response.py @@ -0,0 +1,48 @@ +# 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 new file mode 100644 index 000000000000..e9a8d26d2d59 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/error_response_py3.py @@ -0,0 +1,48 @@ +# 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 new file mode 100644 index 000000000000..59fd86cf5475 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class 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 new file mode 100644 index 000000000000..65d1e4290432 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/internal_error_py3.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class 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 new file mode 100644 index 000000000000..4782ec9e9354 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_client_enums.py @@ -0,0 +1,19 @@ +# 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 new file mode 100644 index 000000000000..fa66768e93a9 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error.py @@ -0,0 +1,56 @@ +# 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 new file mode 100644 index 000000000000..6b8fc62ebb5d --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/personalizer_error_py3.py @@ -0,0 +1,56 @@ +# 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 new file mode 100644 index 000000000000..1adabd6f6f0f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request.py @@ -0,0 +1,74 @@ +# 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 new file mode 100644 index 000000000000..5e1b306ce4a2 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_request_py3.py @@ -0,0 +1,74 @@ +# 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 new file mode 100644 index 000000000000..f831b5389402 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.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 new file mode 100644 index 000000000000..e75da88b8cce --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rank_response_py3.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.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 new file mode 100644 index 000000000000..a26c453ccba9 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action.py @@ -0,0 +1,39 @@ +# 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 new file mode 100644 index 000000000000..18de4a0a9014 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/rankable_action_py3.py @@ -0,0 +1,39 @@ +# 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 new file mode 100644 index 000000000000..379956ff7f58 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action.py @@ -0,0 +1,40 @@ +# 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 new file mode 100644 index 000000000000..367bb71c38a7 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/ranked_action_py3.py @@ -0,0 +1,40 @@ +# 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 new file mode 100644 index 000000000000..083d90332935 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request.py @@ -0,0 +1,35 @@ +# 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 new file mode 100644 index 000000000000..e8a91e550599 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/models/reward_request_py3.py @@ -0,0 +1,35 @@ +# 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 new file mode 100644 index 000000000000..8edd718f964f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .events_operations import EventsOperations + +__all__ = [ + 'EventsOperations', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/events_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/events_operations.py new file mode 100644 index 000000000000..6d4481fe8b02 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/operations/events_operations.py @@ -0,0 +1,134 @@ +# 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 EventsOperations(object): + """EventsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def reward( + self, event_id, value, custom_headers=None, raw=False, **operation_config): + """Report reward to allocate to the top ranked action for the specified + event. + + :param event_id: The event id this reward applies to. + :type event_id: str + :param value: Reward to be assigned to an action. Value should be + between -1 and 1 inclusive. + :type value: float + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + reward1 = models.RewardRequest(value=value) + + # Construct URL + url = self.reward.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(reward1, 'RewardRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + reward.metadata = {'url': '/events/{eventId}/reward'} + + def activate( + self, event_id, custom_headers=None, raw=False, **operation_config): + """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. + :type event_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.activate.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'eventId': self._serialize.url("event_id", event_id, 'str', max_length=256) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + activate.metadata = {'url': '/events/{eventId}/activate'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py new file mode 100644 index 000000000000..672fc01fd864 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/personalizer_client.py @@ -0,0 +1,135 @@ +# 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 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 + + +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) + + def rank( + self, rank_request, custom_headers=None, raw=False, **operation_config): + """A Personalizer rank request. + + :param rank_request: A Personalizer request. + :type rank_request: + ~azure.cognitiveservices.personalizer.models.RankRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: RankResponse or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.personalizer.models.RankResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.rank.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(rank_request, 'RankRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 201: + deserialized = self._deserialize('RankResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + rank.metadata = {'url': '/rank'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py new file mode 100644 index 000000000000..238fe3769b1a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "v1.0" + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml new file mode 100644 index 000000000000..a296d095c04f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml @@ -0,0 +1,8 @@ +[packaging] +package_name = "azure-cognitiveservices-personalizer" +package_nspkg = "azure-cognitiveservices-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = true diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.cfg b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py new file mode 100644 index 000000000000..a80b61968f51 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-cognitiveservices-personalizer" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + long_description_content_type='text/x-rst', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.cognitiveservices', + ]), + install_requires=[ + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + extras_require={ + ":python_version<'3.0'": ['azure-cognitiveservices-nspkg'], + } +) From 81b32804ce808ad00295e8608d42ffc15b6cd4db Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Wed, 29 May 2019 13:04:01 -0700 Subject: [PATCH 2/6] Update .docsettings.yml --- .docsettings.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.docsettings.yml b/.docsettings.yml index 84f6141f1450..05862b761668 100644 --- a/.docsettings.yml +++ b/.docsettings.yml @@ -21,6 +21,8 @@ known_content_issues: - ['sdk/servicebus/azure-servicebus/README.rst', '#4554'] - ['sdk/applicationinsights/azure-applicationinsights/README.rst', '#4554'] - ['sdk/batch/azure-batch/README.rst', '#4554'] + - ['sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst', '#4554'] + - ['sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.rst', '#4554'] - ['sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/README.rst', '#4554'] - ['sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/README.rst', '#4554'] - ['sdk/cognitiveservices/azure-cognitiveservices-language-luis/README.rst', '#4554'] @@ -45,8 +47,7 @@ known_content_issues: - ['sdk/loganalytics/azure-loganalytics/README.rst', '#4554'] - ['azure-servicefabric/README.rst', '#4554'] - ['azure-servicemanagement-legacy/README.rst', '#4554'] - - ['sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.rst', '#4554'] - + # nspckg and common. - ['sdk/cognitiveservices/azure-cognitiveservices-nspkg/README.rst', 'nspkg and common'] - ['sdk/core/azure/README.rst', 'nspkg and common'] From 203ea24b8f4ac7461790e5c17d338e690987c945 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Wed, 29 May 2019 13:04:43 -0700 Subject: [PATCH 3/6] Update sdk_packaging.toml --- .../azure-cognitiveservices-personalizer/sdk_packaging.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml index a296d095c04f..6bd981674ff4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/sdk_packaging.toml @@ -1,8 +1,8 @@ [packaging] package_name = "azure-cognitiveservices-personalizer" package_nspkg = "azure-cognitiveservices-nspkg" -package_pprint_name = "MyService Management" +package_pprint_name = "Personalizer" package_doc_id = "" is_stable = false -is_arm = true -need_msrestazure = true +is_arm = false +need_msrestazure = false From 33a7fc0216a30232b19520c0ed96dd3da21fd105 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 29 May 2019 20:07:32 +0000 Subject: [PATCH 4/6] Packaging update of azure-cognitiveservices-personalizer --- .../azure-cognitiveservices-personalizer/README.rst | 10 ++-------- .../azure-cognitiveservices-personalizer/setup.py | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst index beb4a05e0028..ccf7874c3305 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/README.rst @@ -1,23 +1,17 @@ Microsoft Azure SDK for Python ============================== -This is the Microsoft Azure MyService Management Client Library. - -Azure Resource Manager (ARM) is the next generation of management APIs that -replace the old Azure Service Management (ASM). +This is the Microsoft Azure Personalizer Client Library. This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. -For the older Azure Service Management (ASM) libraries, see -`azure-servicemanagement-legacy `__ library. - For a more complete set of Azure libraries, see the `azure `__ bundle package. Usage ===== -For code examples, see `MyService Management +For code examples, see `Personalizer `__ on docs.microsoft.com. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py index a80b61968f51..f4b22ddd03c0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/setup.py @@ -13,7 +13,7 @@ # Change the PACKAGE_NAME only to change folder and different name PACKAGE_NAME = "azure-cognitiveservices-personalizer" -PACKAGE_PPRINT_NAME = "MyService Management" +PACKAGE_PPRINT_NAME = "Personalizer" # a-b-c => a/b/c package_folder_path = PACKAGE_NAME.replace('-', '/') @@ -79,7 +79,6 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], extras_require={ From 0860b1f3581a3378b17da98a889dcaf3ccdbaaaa Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Wed, 29 May 2019 16:23:17 -0700 Subject: [PATCH 5/6] Update version.py --- .../azure/cognitiveservices/personalizer/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py index 238fe3769b1a..e0ec669828cb 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/azure/cognitiveservices/personalizer/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "v1.0" +VERSION = "0.1.0" From e95790f5d6415e37764f26003f7b5a5a182c35e2 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Wed, 29 May 2019 16:23:39 -0700 Subject: [PATCH 6/6] Update HISTORY.rst --- .../azure-cognitiveservices-personalizer/HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst index 8924d5d6c445..68dac1202e3f 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst +++ b/sdk/cognitiveservices/azure-cognitiveservices-personalizer/HISTORY.rst @@ -3,7 +3,7 @@ Release History =============== -0.1.0 (1970-01-01) +0.1.0 (2019-05-29) ++++++++++++++++++ * Initial Release