From 690a63fbdaa7d6af69942d70b2cf5748065176e8 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Tue, 17 Mar 2020 20:52:44 +0000 Subject: [PATCH] Generated from 57a5105d2ee4d19668f84904866ce27a145f6a1e Fix QnAMaker Python conf --- .../knowledge/qnamaker/authoring/__init__.py | 19 + .../qnamaker/authoring/_configuration.py | 47 + .../qnamaker/authoring/_qn_amaker_client.py | 69 ++ .../qnamaker/authoring/models/__init__.py | 135 ++ .../qnamaker/authoring/models/_models.py | 1100 +++++++++++++++++ .../qnamaker/authoring/models/_models_py3.py | 1100 +++++++++++++++++ .../models/_qn_amaker_client_enums.py | 44 + .../qnamaker/authoring/operations/__init__.py | 24 + .../operations/_alterations_operations.py | 136 ++ .../operations/_endpoint_keys_operations.py | 139 +++ .../_endpoint_settings_operations.py | 143 +++ .../operations/_knowledgebase_operations.py | 463 +++++++ .../authoring/operations/_operations.py | 94 ++ .../knowledge/qnamaker/authoring/version.py | 13 + .../knowledge/qnamaker/runtime/__init__.py | 19 + .../qnamaker/runtime/_configuration.py | 47 + .../runtime/_qn_amaker_runtime_client.py | 49 + .../qnamaker/runtime/models/__init__.py | 74 ++ .../qnamaker/runtime/models/_models.py | 590 +++++++++ .../qnamaker/runtime/models/_models_py3.py | 590 +++++++++ .../models/_qn_amaker_runtime_client_enums.py | 30 + .../qnamaker/runtime/operations/__init__.py | 16 + .../runtime/operations/_runtime_operations.py | 149 +++ .../knowledge/qnamaker/runtime/version.py | 13 + 24 files changed, 5103 insertions(+) create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_configuration.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_qn_amaker_client.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_qn_amaker_client_enums.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_alterations_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_keys_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_settings_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_knowledgebase_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/version.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_configuration.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_qn_amaker_runtime_client.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models_py3.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_qn_amaker_runtime_client_enums.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/__init__.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/_runtime_operations.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/version.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/__init__.py new file mode 100644 index 000000000000..fb3872ea774c --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/__init__.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 ._configuration import QnAMakerClientConfiguration +from ._qn_amaker_client import QnAMakerClient +__all__ = ['QnAMakerClient', 'QnAMakerClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_configuration.py new file mode 100644 index 000000000000..8a45eb6c340d --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_configuration.py @@ -0,0 +1,47 @@ +# 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 QnAMakerClientConfiguration(Configuration): + """Configuration for QnAMakerClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus.api.cognitive.microsoft.com). + :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}/qnamaker/v4.0' + + super(QnAMakerClientConfiguration, 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-knowledge-qnamaker/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_qn_amaker_client.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_qn_amaker_client.py new file mode 100644 index 000000000000..5b34d16cd1aa --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/_qn_amaker_client.py @@ -0,0 +1,69 @@ +# 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 QnAMakerClientConfiguration +from .operations import EndpointSettingsOperations +from .operations import EndpointKeysOperations +from .operations import AlterationsOperations +from .operations import KnowledgebaseOperations +from .operations import Operations +from . import models + + +class QnAMakerClient(SDKClient): + """An API for QnAMaker Service + + :ivar config: Configuration for client. + :vartype config: QnAMakerClientConfiguration + + :ivar endpoint_settings: EndpointSettings operations + :vartype endpoint_settings: azure.cognitiveservices.knowledge.qnamaker.authoring.operations.EndpointSettingsOperations + :ivar endpoint_keys: EndpointKeys operations + :vartype endpoint_keys: azure.cognitiveservices.knowledge.qnamaker.authoring.operations.EndpointKeysOperations + :ivar alterations: Alterations operations + :vartype alterations: azure.cognitiveservices.knowledge.qnamaker.authoring.operations.AlterationsOperations + :ivar knowledgebase: Knowledgebase operations + :vartype knowledgebase: azure.cognitiveservices.knowledge.qnamaker.authoring.operations.KnowledgebaseOperations + :ivar operations: Operations operations + :vartype operations: azure.cognitiveservices.knowledge.qnamaker.authoring.operations.Operations + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = QnAMakerClientConfiguration(endpoint, credentials) + super(QnAMakerClient, 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 = '4.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.endpoint_settings = EndpointSettingsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.endpoint_keys = EndpointKeysOperations( + self._client, self.config, self._serialize, self._deserialize) + self.alterations = AlterationsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.knowledgebase = KnowledgebaseOperations( + self._client, self.config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/__init__.py new file mode 100644 index 000000000000..451223ee9e77 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ActiveLearningSettingsDTO + from ._models_py3 import AlterationsDTO + from ._models_py3 import ContextDTO + from ._models_py3 import CreateKbDTO + from ._models_py3 import CreateKbInputDTO + from ._models_py3 import DeleteKbContentsDTO + from ._models_py3 import EndpointKeysDTO + from ._models_py3 import EndpointSettingsDTO + from ._models_py3 import EndpointSettingsDTOActiveLearning + from ._models_py3 import Error + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponseError + from ._models_py3 import FileDTO + from ._models_py3 import InnerErrorModel + from ._models_py3 import KnowledgebaseDTO + from ._models_py3 import KnowledgebasesDTO + from ._models_py3 import MetadataDTO + from ._models_py3 import Operation + from ._models_py3 import PromptDTO + from ._models_py3 import PromptDTOQna + from ._models_py3 import QnADocumentsDTO + from ._models_py3 import QnADTO + from ._models_py3 import QnADTOContext + from ._models_py3 import ReplaceKbDTO + from ._models_py3 import UpdateContextDTO + from ._models_py3 import UpdateKbContentsDTO + from ._models_py3 import UpdateKbOperationDTO + from ._models_py3 import UpdateKbOperationDTOAdd + from ._models_py3 import UpdateKbOperationDTODelete + from ._models_py3 import UpdateKbOperationDTOUpdate + from ._models_py3 import UpdateMetadataDTO + from ._models_py3 import UpdateQnaDTO + from ._models_py3 import UpdateQnaDTOContext + from ._models_py3 import UpdateQnaDTOMetadata + from ._models_py3 import UpdateQnaDTOQuestions + from ._models_py3 import UpdateQuestionsDTO + from ._models_py3 import WordAlterationsDTO +except (SyntaxError, ImportError): + from ._models import ActiveLearningSettingsDTO + from ._models import AlterationsDTO + from ._models import ContextDTO + from ._models import CreateKbDTO + from ._models import CreateKbInputDTO + from ._models import DeleteKbContentsDTO + from ._models import EndpointKeysDTO + from ._models import EndpointSettingsDTO + from ._models import EndpointSettingsDTOActiveLearning + from ._models import Error + from ._models import ErrorResponse, ErrorResponseException + from ._models import ErrorResponseError + from ._models import FileDTO + from ._models import InnerErrorModel + from ._models import KnowledgebaseDTO + from ._models import KnowledgebasesDTO + from ._models import MetadataDTO + from ._models import Operation + from ._models import PromptDTO + from ._models import PromptDTOQna + from ._models import QnADocumentsDTO + from ._models import QnADTO + from ._models import QnADTOContext + from ._models import ReplaceKbDTO + from ._models import UpdateContextDTO + from ._models import UpdateKbContentsDTO + from ._models import UpdateKbOperationDTO + from ._models import UpdateKbOperationDTOAdd + from ._models import UpdateKbOperationDTODelete + from ._models import UpdateKbOperationDTOUpdate + from ._models import UpdateMetadataDTO + from ._models import UpdateQnaDTO + from ._models import UpdateQnaDTOContext + from ._models import UpdateQnaDTOMetadata + from ._models import UpdateQnaDTOQuestions + from ._models import UpdateQuestionsDTO + from ._models import WordAlterationsDTO +from ._qn_amaker_client_enums import ( + EnvironmentType, + ErrorCodeType, + OperationStateType, +) + +__all__ = [ + 'ActiveLearningSettingsDTO', + 'AlterationsDTO', + 'ContextDTO', + 'CreateKbDTO', + 'CreateKbInputDTO', + 'DeleteKbContentsDTO', + 'EndpointKeysDTO', + 'EndpointSettingsDTO', + 'EndpointSettingsDTOActiveLearning', + 'Error', + 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponseError', + 'FileDTO', + 'InnerErrorModel', + 'KnowledgebaseDTO', + 'KnowledgebasesDTO', + 'MetadataDTO', + 'Operation', + 'PromptDTO', + 'PromptDTOQna', + 'QnADocumentsDTO', + 'QnADTO', + 'QnADTOContext', + 'ReplaceKbDTO', + 'UpdateContextDTO', + 'UpdateKbContentsDTO', + 'UpdateKbOperationDTO', + 'UpdateKbOperationDTOAdd', + 'UpdateKbOperationDTODelete', + 'UpdateKbOperationDTOUpdate', + 'UpdateMetadataDTO', + 'UpdateQnaDTO', + 'UpdateQnaDTOContext', + 'UpdateQnaDTOMetadata', + 'UpdateQnaDTOQuestions', + 'UpdateQuestionsDTO', + 'WordAlterationsDTO', + 'ErrorCodeType', + 'OperationStateType', + 'EnvironmentType', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models.py new file mode 100644 index 000000000000..6e754184be02 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models.py @@ -0,0 +1,1100 @@ +# 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 ActiveLearningSettingsDTO(Model): + """Active Learning settings of the endpoint. + + :param enable: True/False string providing Active Learning + :type enable: str + """ + + _attribute_map = { + 'enable': {'key': 'enable', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ActiveLearningSettingsDTO, self).__init__(**kwargs) + self.enable = kwargs.get('enable', None) + + +class AlterationsDTO(Model): + """Collection of words that are synonyms. + + All required parameters must be populated in order to send to Azure. + + :param alterations: Required. Words that are synonymous with each other. + :type alterations: list[str] + """ + + _validation = { + 'alterations': {'required': True}, + } + + _attribute_map = { + 'alterations': {'key': 'alterations', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(AlterationsDTO, self).__init__(**kwargs) + self.alterations = kwargs.get('alterations', None) + + +class ContextDTO(Model): + """Context associated with Qna. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(ContextDTO, self).__init__(**kwargs) + self.is_context_only = kwargs.get('is_context_only', None) + self.prompts = kwargs.get('prompts', None) + + +class CreateKbDTO(Model): + """Post body schema for CreateKb operation. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (QnADTO) to be added to the knowledgebase. + Q-A Ids are assigned by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be used for extracting Q-A. + :type urls: list[str] + :param files: List of files from which to Extract Q-A. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + :param enable_hierarchical_extraction: Enable hierarchical extraction of + Q-A from files and urls. Value to be considered False if this field is not + present. + :type enable_hierarchical_extraction: bool + :param default_answer_used_for_extraction: Text string to be used as the + answer in any Q-A which has no extracted answer from the document but has + a hierarchy. Required when EnableHierarchicalExtraction field is set to + True. + :type default_answer_used_for_extraction: str + :param language: Language of the knowledgebase. + :type language: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'default_answer_used_for_extraction': {'max_length': 300, 'min_length': 1}, + 'language': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + 'enable_hierarchical_extraction': {'key': 'enableHierarchicalExtraction', 'type': 'bool'}, + 'default_answer_used_for_extraction': {'key': 'defaultAnswerUsedForExtraction', 'type': 'str'}, + 'language': {'key': 'language', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CreateKbDTO, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.qna_list = kwargs.get('qna_list', None) + self.urls = kwargs.get('urls', None) + self.files = kwargs.get('files', None) + self.enable_hierarchical_extraction = kwargs.get('enable_hierarchical_extraction', None) + self.default_answer_used_for_extraction = kwargs.get('default_answer_used_for_extraction', None) + self.language = kwargs.get('language', None) + + +class CreateKbInputDTO(Model): + """Input to create KB. + + :param qna_list: List of QNA to be added to the index. Ids are generated + by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be added to knowledgebase. + :type urls: list[str] + :param files: List of files to be added to knowledgebase. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + """ + + _attribute_map = { + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + } + + def __init__(self, **kwargs): + super(CreateKbInputDTO, self).__init__(**kwargs) + self.qna_list = kwargs.get('qna_list', None) + self.urls = kwargs.get('urls', None) + self.files = kwargs.get('files', None) + + +class DeleteKbContentsDTO(Model): + """PATCH body schema of Delete Operation in UpdateKb. + + :param ids: List of Qna Ids to be deleted + :type ids: list[int] + :param sources: List of sources to be deleted from knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'ids': {'key': 'ids', 'type': '[int]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(DeleteKbContentsDTO, self).__init__(**kwargs) + self.ids = kwargs.get('ids', None) + self.sources = kwargs.get('sources', None) + + +class EndpointKeysDTO(Model): + """Schema for EndpointKeys generate/refresh operations. + + :param primary_endpoint_key: Primary Access Key. + :type primary_endpoint_key: str + :param secondary_endpoint_key: Secondary Access Key. + :type secondary_endpoint_key: str + :param installed_version: Current version of runtime. + :type installed_version: str + :param last_stable_version: Latest version of runtime. + :type last_stable_version: str + :param language: Language setting of runtime. + :type language: str + """ + + _attribute_map = { + 'primary_endpoint_key': {'key': 'primaryEndpointKey', 'type': 'str'}, + 'secondary_endpoint_key': {'key': 'secondaryEndpointKey', 'type': 'str'}, + 'installed_version': {'key': 'installedVersion', 'type': 'str'}, + 'last_stable_version': {'key': 'lastStableVersion', 'type': 'str'}, + 'language': {'key': 'language', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(EndpointKeysDTO, self).__init__(**kwargs) + self.primary_endpoint_key = kwargs.get('primary_endpoint_key', None) + self.secondary_endpoint_key = kwargs.get('secondary_endpoint_key', None) + self.installed_version = kwargs.get('installed_version', None) + self.last_stable_version = kwargs.get('last_stable_version', None) + self.language = kwargs.get('language', None) + + +class EndpointSettingsDTO(Model): + """Endpoint settings. + + :param active_learning: Active Learning settings of the endpoint. + :type active_learning: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointSettingsDTOActiveLearning + """ + + _attribute_map = { + 'active_learning': {'key': 'activeLearning', 'type': 'EndpointSettingsDTOActiveLearning'}, + } + + def __init__(self, **kwargs): + super(EndpointSettingsDTO, self).__init__(**kwargs) + self.active_learning = kwargs.get('active_learning', None) + + +class EndpointSettingsDTOActiveLearning(ActiveLearningSettingsDTO): + """Active Learning settings of the endpoint. + + :param enable: True/False string providing Active Learning + :type enable: str + """ + + _attribute_map = { + 'enable': {'key': 'enable', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(EndpointSettingsDTOActiveLearning, self).__init__(**kwargs) + + +class Error(Model): + """The error object. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(Error, 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 ErrorResponse(Model): + """Error response. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param error: The error object. + :type error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + 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 ErrorResponseError(Error): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(ErrorResponseError, self).__init__(**kwargs) + + +class FileDTO(Model): + """DTO to hold details of uploaded files. + + All required parameters must be populated in order to send to Azure. + + :param file_name: Required. File name. Supported file types are ".tsv", + ".pdf", ".txt", ".docx", ".xlsx". + :type file_name: str + :param file_uri: Required. Public URI of the file. + :type file_uri: str + """ + + _validation = { + 'file_name': {'required': True, 'max_length': 200, 'min_length': 1}, + 'file_uri': {'required': True}, + } + + _attribute_map = { + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'file_uri': {'key': 'fileUri', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(FileDTO, self).__init__(**kwargs) + self.file_name = kwargs.get('file_name', None) + self.file_uri = kwargs.get('file_uri', None) + + +class InnerErrorModel(Model): + """An object containing more specific information about the error. As per + Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param code: A more specific error code than was provided by the + containing error. + :type code: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(InnerErrorModel, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.inner_error = kwargs.get('inner_error', None) + + +class KnowledgebaseDTO(Model): + """Response schema for CreateKb operation. + + :param id: Unique id that identifies a knowledgebase. + :type id: str + :param host_name: URL host name at which the knowledgebase is hosted. + :type host_name: str + :param last_accessed_timestamp: Time stamp at which the knowledgebase was + last accessed (UTC). + :type last_accessed_timestamp: str + :param last_changed_timestamp: Time stamp at which the knowledgebase was + last modified (UTC). + :type last_changed_timestamp: str + :param last_published_timestamp: Time stamp at which the knowledgebase was + last published (UTC). + :type last_published_timestamp: str + :param name: Friendly name of the knowledgebase. + :type name: str + :param user_id: User who created / owns the knowledgebase. + :type user_id: str + :param urls: URL sources from which Q-A were extracted and added to the + knowledgebase. + :type urls: list[str] + :param sources: Custom sources from which Q-A were extracted or explicitly + added to the knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'host_name': {'key': 'hostName', 'type': 'str'}, + 'last_accessed_timestamp': {'key': 'lastAccessedTimestamp', 'type': 'str'}, + 'last_changed_timestamp': {'key': 'lastChangedTimestamp', 'type': 'str'}, + 'last_published_timestamp': {'key': 'lastPublishedTimestamp', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(KnowledgebaseDTO, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.host_name = kwargs.get('host_name', None) + self.last_accessed_timestamp = kwargs.get('last_accessed_timestamp', None) + self.last_changed_timestamp = kwargs.get('last_changed_timestamp', None) + self.last_published_timestamp = kwargs.get('last_published_timestamp', None) + self.name = kwargs.get('name', None) + self.user_id = kwargs.get('user_id', None) + self.urls = kwargs.get('urls', None) + self.sources = kwargs.get('sources', None) + + +class KnowledgebasesDTO(Model): + """Collection of knowledgebases owned by a user. + + :param knowledgebases: Collection of knowledgebase records. + :type knowledgebases: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.KnowledgebaseDTO] + """ + + _attribute_map = { + 'knowledgebases': {'key': 'knowledgebases', 'type': '[KnowledgebaseDTO]'}, + } + + def __init__(self, **kwargs): + super(KnowledgebasesDTO, self).__init__(**kwargs) + self.knowledgebases = kwargs.get('knowledgebases', None) + + +class MetadataDTO(Model): + """Name - value pair of metadata. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Metadata name. + :type name: str + :param value: Required. Metadata value. + :type value: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'value': {'required': True, 'max_length': 500, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(MetadataDTO, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + + +class Operation(Model): + """Record to track long running operation. + + :param operation_state: Operation state. Possible values include: + 'Failed', 'NotStarted', 'Running', 'Succeeded' + :type operation_state: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.OperationStateType + :param created_timestamp: Timestamp when the operation was created. + :type created_timestamp: str + :param last_action_timestamp: Timestamp when the current state was + entered. + :type last_action_timestamp: str + :param resource_location: Relative URI to the target resource location for + completed resources. + :type resource_location: str + :param user_id: User Id + :type user_id: str + :param operation_id: Operation Id. + :type operation_id: str + :param error_response: Error details in case of failures. + :type error_response: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorResponse + """ + + _attribute_map = { + 'operation_state': {'key': 'operationState', 'type': 'str'}, + 'created_timestamp': {'key': 'createdTimestamp', 'type': 'str'}, + 'last_action_timestamp': {'key': 'lastActionTimestamp', 'type': 'str'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'error_response': {'key': 'errorResponse', 'type': 'ErrorResponse'}, + } + + def __init__(self, **kwargs): + super(Operation, self).__init__(**kwargs) + self.operation_state = kwargs.get('operation_state', None) + self.created_timestamp = kwargs.get('created_timestamp', None) + self.last_action_timestamp = kwargs.get('last_action_timestamp', None) + self.resource_location = kwargs.get('resource_location', None) + self.user_id = kwargs.get('user_id', None) + self.operation_id = kwargs.get('operation_id', None) + self.error_response = kwargs.get('error_response', None) + + +class PromptDTO(Model): + """Prompt for an answer. + + :param display_order: Index of the prompt - used in ordering of the + prompts + :type display_order: int + :param qna_id: Qna id corresponding to the prompt - if QnaId is present, + QnADTO object is ignored. + :type qna_id: int + :param qna: QnADTO - Either QnaId or QnADTO needs to be present in a + PromptDTO object + :type qna: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTOQna + :param display_text: Text displayed to represent a follow up question + prompt + :type display_text: str + """ + + _validation = { + 'display_text': {'max_length': 200}, + } + + _attribute_map = { + 'display_order': {'key': 'displayOrder', 'type': 'int'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + 'qna': {'key': 'qna', 'type': 'PromptDTOQna'}, + 'display_text': {'key': 'displayText', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PromptDTO, self).__init__(**kwargs) + self.display_order = kwargs.get('display_order', None) + self.qna_id = kwargs.get('qna_id', None) + self.qna = kwargs.get('qna', None) + self.display_text = kwargs.get('display_text', None) + + +class QnADTO(Model): + """Q-A object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, **kwargs): + super(QnADTO, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.answer = kwargs.get('answer', None) + self.source = kwargs.get('source', None) + self.questions = kwargs.get('questions', None) + self.metadata = kwargs.get('metadata', None) + self.context = kwargs.get('context', None) + + +class PromptDTOQna(QnADTO): + """QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, **kwargs): + super(PromptDTOQna, self).__init__(**kwargs) + + +class QnADocumentsDTO(Model): + """List of QnADTO. + + :param qna_documents: List of answers. + :type qna_documents: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + """ + + _attribute_map = { + 'qna_documents': {'key': 'qnaDocuments', 'type': '[QnADTO]'}, + } + + def __init__(self, **kwargs): + super(QnADocumentsDTO, self).__init__(**kwargs) + self.qna_documents = kwargs.get('qna_documents', None) + + +class QnADTOContext(ContextDTO): + """Context of a QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(QnADTOContext, self).__init__(**kwargs) + + +class ReplaceKbDTO(Model): + """Post body schema for Replace KB operation. + + All required parameters must be populated in order to send to Azure. + + :param qn_alist: Required. List of Q-A (QnADTO) to be added to the + knowledgebase. Q-A Ids are assigned by the service and should be omitted. + :type qn_alist: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + """ + + _validation = { + 'qn_alist': {'required': True}, + } + + _attribute_map = { + 'qn_alist': {'key': 'qnAList', 'type': '[QnADTO]'}, + } + + def __init__(self, **kwargs): + super(ReplaceKbDTO, self).__init__(**kwargs) + self.qn_alist = kwargs.get('qn_alist', None) + + +class UpdateContextDTO(Model): + """Update Body schema to represent context to be updated. + + :param prompts_to_delete: List of prompts associated with qna to be + deleted + :type prompts_to_delete: list[int] + :param prompts_to_add: List of prompts to be added to the qna. + :type prompts_to_add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + """ + + _attribute_map = { + 'prompts_to_delete': {'key': 'promptsToDelete', 'type': '[int]'}, + 'prompts_to_add': {'key': 'promptsToAdd', 'type': '[PromptDTO]'}, + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(UpdateContextDTO, self).__init__(**kwargs) + self.prompts_to_delete = kwargs.get('prompts_to_delete', None) + self.prompts_to_add = kwargs.get('prompts_to_add', None) + self.is_context_only = kwargs.get('is_context_only', None) + + +class UpdateKbContentsDTO(Model): + """PATCH body schema for Update operation in Update Kb. + + :param name: Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (UpdateQnaDTO) to be added to the + knowledgebase. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTO] + :param urls: List of existing URLs to be refreshed. The content will be + extracted again and re-indexed. + :type urls: list[str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[UpdateQnaDTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(UpdateKbContentsDTO, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.qna_list = kwargs.get('qna_list', None) + self.urls = kwargs.get('urls', None) + + +class UpdateKbOperationDTO(Model): + """Contains list of QnAs to be updated. + + :param add: An instance of CreateKbInputDTO for add operation + :type add: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTOAdd + :param delete: An instance of DeleteKbContentsDTO for delete Operation + :type delete: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTODelete + :param update: An instance of UpdateKbContentsDTO for Update Operation + :type update: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTOUpdate + :param enable_hierarchical_extraction: Enable hierarchical extraction of + Q-A from files and urls. The value set during KB creation will be used if + this field is not present. + :type enable_hierarchical_extraction: bool + :param default_answer_used_for_extraction: Text string to be used as the + answer in any Q-A which has no extracted answer from the document but has + a hierarchy. Required when EnableHierarchicalExtraction field is set to + True. + :type default_answer_used_for_extraction: str + """ + + _validation = { + 'default_answer_used_for_extraction': {'max_length': 300, 'min_length': 1}, + } + + _attribute_map = { + 'add': {'key': 'add', 'type': 'UpdateKbOperationDTOAdd'}, + 'delete': {'key': 'delete', 'type': 'UpdateKbOperationDTODelete'}, + 'update': {'key': 'update', 'type': 'UpdateKbOperationDTOUpdate'}, + 'enable_hierarchical_extraction': {'key': 'enableHierarchicalExtraction', 'type': 'bool'}, + 'default_answer_used_for_extraction': {'key': 'defaultAnswerUsedForExtraction', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(UpdateKbOperationDTO, self).__init__(**kwargs) + self.add = kwargs.get('add', None) + self.delete = kwargs.get('delete', None) + self.update = kwargs.get('update', None) + self.enable_hierarchical_extraction = kwargs.get('enable_hierarchical_extraction', None) + self.default_answer_used_for_extraction = kwargs.get('default_answer_used_for_extraction', None) + + +class UpdateKbOperationDTOAdd(CreateKbInputDTO): + """An instance of CreateKbInputDTO for add operation. + + :param qna_list: List of QNA to be added to the index. Ids are generated + by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be added to knowledgebase. + :type urls: list[str] + :param files: List of files to be added to knowledgebase. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + """ + + _attribute_map = { + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + } + + def __init__(self, **kwargs): + super(UpdateKbOperationDTOAdd, self).__init__(**kwargs) + + +class UpdateKbOperationDTODelete(DeleteKbContentsDTO): + """An instance of DeleteKbContentsDTO for delete Operation. + + :param ids: List of Qna Ids to be deleted + :type ids: list[int] + :param sources: List of sources to be deleted from knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'ids': {'key': 'ids', 'type': '[int]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(UpdateKbOperationDTODelete, self).__init__(**kwargs) + + +class UpdateKbOperationDTOUpdate(UpdateKbContentsDTO): + """An instance of UpdateKbContentsDTO for Update Operation. + + :param name: Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (UpdateQnaDTO) to be added to the + knowledgebase. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTO] + :param urls: List of existing URLs to be refreshed. The content will be + extracted again and re-indexed. + :type urls: list[str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[UpdateQnaDTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(UpdateKbOperationDTOUpdate, self).__init__(**kwargs) + + +class UpdateMetadataDTO(Model): + """PATCH Body schema to represent list of Metadata to be updated. + + :param delete: List of Metadata associated with answer to be deleted + :type delete: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param add: List of metadata associated with answer to be added + :type add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + """ + + _attribute_map = { + 'delete': {'key': 'delete', 'type': '[MetadataDTO]'}, + 'add': {'key': 'add', 'type': '[MetadataDTO]'}, + } + + def __init__(self, **kwargs): + super(UpdateMetadataDTO, self).__init__(**kwargs) + self.delete = kwargs.get('delete', None) + self.add = kwargs.get('add', None) + + +class UpdateQnaDTO(Model): + """PATCH Body schema for Update Qna List. + + :param id: Unique id for the Q-A + :type id: int + :param answer: Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: List of questions associated with the answer. + :type questions: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOQuestions + :param metadata: List of metadata associated with the answer to be updated + :type metadata: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOMetadata + :param context: Context associated with Qna to be updated. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOContext + """ + + _validation = { + 'id': {'maximum': 2147483647, 'minimum': 0}, + 'source': {'max_length': 300}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': 'UpdateQnaDTOQuestions'}, + 'metadata': {'key': 'metadata', 'type': 'UpdateQnaDTOMetadata'}, + 'context': {'key': 'context', 'type': 'UpdateQnaDTOContext'}, + } + + def __init__(self, **kwargs): + super(UpdateQnaDTO, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.answer = kwargs.get('answer', None) + self.source = kwargs.get('source', None) + self.questions = kwargs.get('questions', None) + self.metadata = kwargs.get('metadata', None) + self.context = kwargs.get('context', None) + + +class UpdateQnaDTOContext(UpdateContextDTO): + """Context associated with Qna to be updated. + + :param prompts_to_delete: List of prompts associated with qna to be + deleted + :type prompts_to_delete: list[int] + :param prompts_to_add: List of prompts to be added to the qna. + :type prompts_to_add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + """ + + _attribute_map = { + 'prompts_to_delete': {'key': 'promptsToDelete', 'type': '[int]'}, + 'prompts_to_add': {'key': 'promptsToAdd', 'type': '[PromptDTO]'}, + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(UpdateQnaDTOContext, self).__init__(**kwargs) + + +class UpdateQnaDTOMetadata(UpdateMetadataDTO): + """List of metadata associated with the answer to be updated. + + :param delete: List of Metadata associated with answer to be deleted + :type delete: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param add: List of metadata associated with answer to be added + :type add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + """ + + _attribute_map = { + 'delete': {'key': 'delete', 'type': '[MetadataDTO]'}, + 'add': {'key': 'add', 'type': '[MetadataDTO]'}, + } + + def __init__(self, **kwargs): + super(UpdateQnaDTOMetadata, self).__init__(**kwargs) + + +class UpdateQuestionsDTO(Model): + """PATCH Body schema for Update Kb which contains list of questions to be + added and deleted. + + :param add: List of questions to be added + :type add: list[str] + :param delete: List of questions to be deleted. + :type delete: list[str] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'delete': {'key': 'delete', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(UpdateQuestionsDTO, self).__init__(**kwargs) + self.add = kwargs.get('add', None) + self.delete = kwargs.get('delete', None) + + +class UpdateQnaDTOQuestions(UpdateQuestionsDTO): + """List of questions associated with the answer. + + :param add: List of questions to be added + :type add: list[str] + :param delete: List of questions to be deleted. + :type delete: list[str] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'delete': {'key': 'delete', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(UpdateQnaDTOQuestions, self).__init__(**kwargs) + + +class WordAlterationsDTO(Model): + """Collection of word alterations. + + All required parameters must be populated in order to send to Azure. + + :param word_alterations: Required. Collection of word alterations. + :type word_alterations: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.AlterationsDTO] + """ + + _validation = { + 'word_alterations': {'required': True}, + } + + _attribute_map = { + 'word_alterations': {'key': 'wordAlterations', 'type': '[AlterationsDTO]'}, + } + + def __init__(self, **kwargs): + super(WordAlterationsDTO, self).__init__(**kwargs) + self.word_alterations = kwargs.get('word_alterations', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models_py3.py new file mode 100644 index 000000000000..52a9f96682f9 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_models_py3.py @@ -0,0 +1,1100 @@ +# 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 ActiveLearningSettingsDTO(Model): + """Active Learning settings of the endpoint. + + :param enable: True/False string providing Active Learning + :type enable: str + """ + + _attribute_map = { + 'enable': {'key': 'enable', 'type': 'str'}, + } + + def __init__(self, *, enable: str=None, **kwargs) -> None: + super(ActiveLearningSettingsDTO, self).__init__(**kwargs) + self.enable = enable + + +class AlterationsDTO(Model): + """Collection of words that are synonyms. + + All required parameters must be populated in order to send to Azure. + + :param alterations: Required. Words that are synonymous with each other. + :type alterations: list[str] + """ + + _validation = { + 'alterations': {'required': True}, + } + + _attribute_map = { + 'alterations': {'key': 'alterations', 'type': '[str]'}, + } + + def __init__(self, *, alterations, **kwargs) -> None: + super(AlterationsDTO, self).__init__(**kwargs) + self.alterations = alterations + + +class ContextDTO(Model): + """Context associated with Qna. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(ContextDTO, self).__init__(**kwargs) + self.is_context_only = is_context_only + self.prompts = prompts + + +class CreateKbDTO(Model): + """Post body schema for CreateKb operation. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (QnADTO) to be added to the knowledgebase. + Q-A Ids are assigned by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be used for extracting Q-A. + :type urls: list[str] + :param files: List of files from which to Extract Q-A. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + :param enable_hierarchical_extraction: Enable hierarchical extraction of + Q-A from files and urls. Value to be considered False if this field is not + present. + :type enable_hierarchical_extraction: bool + :param default_answer_used_for_extraction: Text string to be used as the + answer in any Q-A which has no extracted answer from the document but has + a hierarchy. Required when EnableHierarchicalExtraction field is set to + True. + :type default_answer_used_for_extraction: str + :param language: Language of the knowledgebase. + :type language: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'default_answer_used_for_extraction': {'max_length': 300, 'min_length': 1}, + 'language': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + 'enable_hierarchical_extraction': {'key': 'enableHierarchicalExtraction', 'type': 'bool'}, + 'default_answer_used_for_extraction': {'key': 'defaultAnswerUsedForExtraction', 'type': 'str'}, + 'language': {'key': 'language', 'type': 'str'}, + } + + def __init__(self, *, name: str, qna_list=None, urls=None, files=None, enable_hierarchical_extraction: bool=None, default_answer_used_for_extraction: str=None, language: str=None, **kwargs) -> None: + super(CreateKbDTO, self).__init__(**kwargs) + self.name = name + self.qna_list = qna_list + self.urls = urls + self.files = files + self.enable_hierarchical_extraction = enable_hierarchical_extraction + self.default_answer_used_for_extraction = default_answer_used_for_extraction + self.language = language + + +class CreateKbInputDTO(Model): + """Input to create KB. + + :param qna_list: List of QNA to be added to the index. Ids are generated + by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be added to knowledgebase. + :type urls: list[str] + :param files: List of files to be added to knowledgebase. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + """ + + _attribute_map = { + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + } + + def __init__(self, *, qna_list=None, urls=None, files=None, **kwargs) -> None: + super(CreateKbInputDTO, self).__init__(**kwargs) + self.qna_list = qna_list + self.urls = urls + self.files = files + + +class DeleteKbContentsDTO(Model): + """PATCH body schema of Delete Operation in UpdateKb. + + :param ids: List of Qna Ids to be deleted + :type ids: list[int] + :param sources: List of sources to be deleted from knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'ids': {'key': 'ids', 'type': '[int]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, *, ids=None, sources=None, **kwargs) -> None: + super(DeleteKbContentsDTO, self).__init__(**kwargs) + self.ids = ids + self.sources = sources + + +class EndpointKeysDTO(Model): + """Schema for EndpointKeys generate/refresh operations. + + :param primary_endpoint_key: Primary Access Key. + :type primary_endpoint_key: str + :param secondary_endpoint_key: Secondary Access Key. + :type secondary_endpoint_key: str + :param installed_version: Current version of runtime. + :type installed_version: str + :param last_stable_version: Latest version of runtime. + :type last_stable_version: str + :param language: Language setting of runtime. + :type language: str + """ + + _attribute_map = { + 'primary_endpoint_key': {'key': 'primaryEndpointKey', 'type': 'str'}, + 'secondary_endpoint_key': {'key': 'secondaryEndpointKey', 'type': 'str'}, + 'installed_version': {'key': 'installedVersion', 'type': 'str'}, + 'last_stable_version': {'key': 'lastStableVersion', 'type': 'str'}, + 'language': {'key': 'language', 'type': 'str'}, + } + + def __init__(self, *, primary_endpoint_key: str=None, secondary_endpoint_key: str=None, installed_version: str=None, last_stable_version: str=None, language: str=None, **kwargs) -> None: + super(EndpointKeysDTO, self).__init__(**kwargs) + self.primary_endpoint_key = primary_endpoint_key + self.secondary_endpoint_key = secondary_endpoint_key + self.installed_version = installed_version + self.last_stable_version = last_stable_version + self.language = language + + +class EndpointSettingsDTO(Model): + """Endpoint settings. + + :param active_learning: Active Learning settings of the endpoint. + :type active_learning: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointSettingsDTOActiveLearning + """ + + _attribute_map = { + 'active_learning': {'key': 'activeLearning', 'type': 'EndpointSettingsDTOActiveLearning'}, + } + + def __init__(self, *, active_learning=None, **kwargs) -> None: + super(EndpointSettingsDTO, self).__init__(**kwargs) + self.active_learning = active_learning + + +class EndpointSettingsDTOActiveLearning(ActiveLearningSettingsDTO): + """Active Learning settings of the endpoint. + + :param enable: True/False string providing Active Learning + :type enable: str + """ + + _attribute_map = { + 'enable': {'key': 'enable', 'type': 'str'}, + } + + def __init__(self, *, enable: str=None, **kwargs) -> None: + super(EndpointSettingsDTOActiveLearning, self).__init__(enable=enable, **kwargs) + + +class Error(Model): + """The error object. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code, message: str=None, target: str=None, details=None, inner_error=None, **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + self.inner_error = inner_error + + +class ErrorResponse(Model): + """Error response. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param error: The error object. + :type error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__(self, *, error=None, **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 ErrorResponseError(Error): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code, message: str=None, target: str=None, details=None, inner_error=None, **kwargs) -> None: + super(ErrorResponseError, self).__init__(code=code, message=message, target=target, details=details, inner_error=inner_error, **kwargs) + + +class FileDTO(Model): + """DTO to hold details of uploaded files. + + All required parameters must be populated in order to send to Azure. + + :param file_name: Required. File name. Supported file types are ".tsv", + ".pdf", ".txt", ".docx", ".xlsx". + :type file_name: str + :param file_uri: Required. Public URI of the file. + :type file_uri: str + """ + + _validation = { + 'file_name': {'required': True, 'max_length': 200, 'min_length': 1}, + 'file_uri': {'required': True}, + } + + _attribute_map = { + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'file_uri': {'key': 'fileUri', 'type': 'str'}, + } + + def __init__(self, *, file_name: str, file_uri: str, **kwargs) -> None: + super(FileDTO, self).__init__(**kwargs) + self.file_name = file_name + self.file_uri = file_uri + + +class InnerErrorModel(Model): + """An object containing more specific information about the error. As per + Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param code: A more specific error code than was provided by the + containing error. + :type code: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.InnerErrorModel + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code: str=None, inner_error=None, **kwargs) -> None: + super(InnerErrorModel, self).__init__(**kwargs) + self.code = code + self.inner_error = inner_error + + +class KnowledgebaseDTO(Model): + """Response schema for CreateKb operation. + + :param id: Unique id that identifies a knowledgebase. + :type id: str + :param host_name: URL host name at which the knowledgebase is hosted. + :type host_name: str + :param last_accessed_timestamp: Time stamp at which the knowledgebase was + last accessed (UTC). + :type last_accessed_timestamp: str + :param last_changed_timestamp: Time stamp at which the knowledgebase was + last modified (UTC). + :type last_changed_timestamp: str + :param last_published_timestamp: Time stamp at which the knowledgebase was + last published (UTC). + :type last_published_timestamp: str + :param name: Friendly name of the knowledgebase. + :type name: str + :param user_id: User who created / owns the knowledgebase. + :type user_id: str + :param urls: URL sources from which Q-A were extracted and added to the + knowledgebase. + :type urls: list[str] + :param sources: Custom sources from which Q-A were extracted or explicitly + added to the knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'host_name': {'key': 'hostName', 'type': 'str'}, + 'last_accessed_timestamp': {'key': 'lastAccessedTimestamp', 'type': 'str'}, + 'last_changed_timestamp': {'key': 'lastChangedTimestamp', 'type': 'str'}, + 'last_published_timestamp': {'key': 'lastPublishedTimestamp', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, *, id: str=None, host_name: str=None, last_accessed_timestamp: str=None, last_changed_timestamp: str=None, last_published_timestamp: str=None, name: str=None, user_id: str=None, urls=None, sources=None, **kwargs) -> None: + super(KnowledgebaseDTO, self).__init__(**kwargs) + self.id = id + self.host_name = host_name + self.last_accessed_timestamp = last_accessed_timestamp + self.last_changed_timestamp = last_changed_timestamp + self.last_published_timestamp = last_published_timestamp + self.name = name + self.user_id = user_id + self.urls = urls + self.sources = sources + + +class KnowledgebasesDTO(Model): + """Collection of knowledgebases owned by a user. + + :param knowledgebases: Collection of knowledgebase records. + :type knowledgebases: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.KnowledgebaseDTO] + """ + + _attribute_map = { + 'knowledgebases': {'key': 'knowledgebases', 'type': '[KnowledgebaseDTO]'}, + } + + def __init__(self, *, knowledgebases=None, **kwargs) -> None: + super(KnowledgebasesDTO, self).__init__(**kwargs) + self.knowledgebases = knowledgebases + + +class MetadataDTO(Model): + """Name - value pair of metadata. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Metadata name. + :type name: str + :param value: Required. Metadata value. + :type value: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'value': {'required': True, 'max_length': 500, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, *, name: str, value: str, **kwargs) -> None: + super(MetadataDTO, self).__init__(**kwargs) + self.name = name + self.value = value + + +class Operation(Model): + """Record to track long running operation. + + :param operation_state: Operation state. Possible values include: + 'Failed', 'NotStarted', 'Running', 'Succeeded' + :type operation_state: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.OperationStateType + :param created_timestamp: Timestamp when the operation was created. + :type created_timestamp: str + :param last_action_timestamp: Timestamp when the current state was + entered. + :type last_action_timestamp: str + :param resource_location: Relative URI to the target resource location for + completed resources. + :type resource_location: str + :param user_id: User Id + :type user_id: str + :param operation_id: Operation Id. + :type operation_id: str + :param error_response: Error details in case of failures. + :type error_response: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.ErrorResponse + """ + + _attribute_map = { + 'operation_state': {'key': 'operationState', 'type': 'str'}, + 'created_timestamp': {'key': 'createdTimestamp', 'type': 'str'}, + 'last_action_timestamp': {'key': 'lastActionTimestamp', 'type': 'str'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'error_response': {'key': 'errorResponse', 'type': 'ErrorResponse'}, + } + + def __init__(self, *, operation_state=None, created_timestamp: str=None, last_action_timestamp: str=None, resource_location: str=None, user_id: str=None, operation_id: str=None, error_response=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.operation_state = operation_state + self.created_timestamp = created_timestamp + self.last_action_timestamp = last_action_timestamp + self.resource_location = resource_location + self.user_id = user_id + self.operation_id = operation_id + self.error_response = error_response + + +class PromptDTO(Model): + """Prompt for an answer. + + :param display_order: Index of the prompt - used in ordering of the + prompts + :type display_order: int + :param qna_id: Qna id corresponding to the prompt - if QnaId is present, + QnADTO object is ignored. + :type qna_id: int + :param qna: QnADTO - Either QnaId or QnADTO needs to be present in a + PromptDTO object + :type qna: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTOQna + :param display_text: Text displayed to represent a follow up question + prompt + :type display_text: str + """ + + _validation = { + 'display_text': {'max_length': 200}, + } + + _attribute_map = { + 'display_order': {'key': 'displayOrder', 'type': 'int'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + 'qna': {'key': 'qna', 'type': 'PromptDTOQna'}, + 'display_text': {'key': 'displayText', 'type': 'str'}, + } + + def __init__(self, *, display_order: int=None, qna_id: int=None, qna=None, display_text: str=None, **kwargs) -> None: + super(PromptDTO, self).__init__(**kwargs) + self.display_order = display_order + self.qna_id = qna_id + self.qna = qna + self.display_text = display_text + + +class QnADTO(Model): + """Q-A object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, *, answer: str, questions, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(QnADTO, self).__init__(**kwargs) + self.id = id + self.answer = answer + self.source = source + self.questions = questions + self.metadata = metadata + self.context = context + + +class PromptDTOQna(QnADTO): + """QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, *, answer: str, questions, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(PromptDTOQna, self).__init__(id=id, answer=answer, source=source, questions=questions, metadata=metadata, context=context, **kwargs) + + +class QnADocumentsDTO(Model): + """List of QnADTO. + + :param qna_documents: List of answers. + :type qna_documents: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + """ + + _attribute_map = { + 'qna_documents': {'key': 'qnaDocuments', 'type': '[QnADTO]'}, + } + + def __init__(self, *, qna_documents=None, **kwargs) -> None: + super(QnADocumentsDTO, self).__init__(**kwargs) + self.qna_documents = qna_documents + + +class QnADTOContext(ContextDTO): + """Context of a QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(QnADTOContext, self).__init__(is_context_only=is_context_only, prompts=prompts, **kwargs) + + +class ReplaceKbDTO(Model): + """Post body schema for Replace KB operation. + + All required parameters must be populated in order to send to Azure. + + :param qn_alist: Required. List of Q-A (QnADTO) to be added to the + knowledgebase. Q-A Ids are assigned by the service and should be omitted. + :type qn_alist: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + """ + + _validation = { + 'qn_alist': {'required': True}, + } + + _attribute_map = { + 'qn_alist': {'key': 'qnAList', 'type': '[QnADTO]'}, + } + + def __init__(self, *, qn_alist, **kwargs) -> None: + super(ReplaceKbDTO, self).__init__(**kwargs) + self.qn_alist = qn_alist + + +class UpdateContextDTO(Model): + """Update Body schema to represent context to be updated. + + :param prompts_to_delete: List of prompts associated with qna to be + deleted + :type prompts_to_delete: list[int] + :param prompts_to_add: List of prompts to be added to the qna. + :type prompts_to_add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + """ + + _attribute_map = { + 'prompts_to_delete': {'key': 'promptsToDelete', 'type': '[int]'}, + 'prompts_to_add': {'key': 'promptsToAdd', 'type': '[PromptDTO]'}, + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + } + + def __init__(self, *, prompts_to_delete=None, prompts_to_add=None, is_context_only: bool=None, **kwargs) -> None: + super(UpdateContextDTO, self).__init__(**kwargs) + self.prompts_to_delete = prompts_to_delete + self.prompts_to_add = prompts_to_add + self.is_context_only = is_context_only + + +class UpdateKbContentsDTO(Model): + """PATCH body schema for Update operation in Update Kb. + + :param name: Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (UpdateQnaDTO) to be added to the + knowledgebase. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTO] + :param urls: List of existing URLs to be refreshed. The content will be + extracted again and re-indexed. + :type urls: list[str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[UpdateQnaDTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + } + + def __init__(self, *, name: str=None, qna_list=None, urls=None, **kwargs) -> None: + super(UpdateKbContentsDTO, self).__init__(**kwargs) + self.name = name + self.qna_list = qna_list + self.urls = urls + + +class UpdateKbOperationDTO(Model): + """Contains list of QnAs to be updated. + + :param add: An instance of CreateKbInputDTO for add operation + :type add: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTOAdd + :param delete: An instance of DeleteKbContentsDTO for delete Operation + :type delete: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTODelete + :param update: An instance of UpdateKbContentsDTO for Update Operation + :type update: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTOUpdate + :param enable_hierarchical_extraction: Enable hierarchical extraction of + Q-A from files and urls. The value set during KB creation will be used if + this field is not present. + :type enable_hierarchical_extraction: bool + :param default_answer_used_for_extraction: Text string to be used as the + answer in any Q-A which has no extracted answer from the document but has + a hierarchy. Required when EnableHierarchicalExtraction field is set to + True. + :type default_answer_used_for_extraction: str + """ + + _validation = { + 'default_answer_used_for_extraction': {'max_length': 300, 'min_length': 1}, + } + + _attribute_map = { + 'add': {'key': 'add', 'type': 'UpdateKbOperationDTOAdd'}, + 'delete': {'key': 'delete', 'type': 'UpdateKbOperationDTODelete'}, + 'update': {'key': 'update', 'type': 'UpdateKbOperationDTOUpdate'}, + 'enable_hierarchical_extraction': {'key': 'enableHierarchicalExtraction', 'type': 'bool'}, + 'default_answer_used_for_extraction': {'key': 'defaultAnswerUsedForExtraction', 'type': 'str'}, + } + + def __init__(self, *, add=None, delete=None, update=None, enable_hierarchical_extraction: bool=None, default_answer_used_for_extraction: str=None, **kwargs) -> None: + super(UpdateKbOperationDTO, self).__init__(**kwargs) + self.add = add + self.delete = delete + self.update = update + self.enable_hierarchical_extraction = enable_hierarchical_extraction + self.default_answer_used_for_extraction = default_answer_used_for_extraction + + +class UpdateKbOperationDTOAdd(CreateKbInputDTO): + """An instance of CreateKbInputDTO for add operation. + + :param qna_list: List of QNA to be added to the index. Ids are generated + by the service and should be omitted. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :param urls: List of URLs to be added to knowledgebase. + :type urls: list[str] + :param files: List of files to be added to knowledgebase. + :type files: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.FileDTO] + """ + + _attribute_map = { + 'qna_list': {'key': 'qnaList', 'type': '[QnADTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + 'files': {'key': 'files', 'type': '[FileDTO]'}, + } + + def __init__(self, *, qna_list=None, urls=None, files=None, **kwargs) -> None: + super(UpdateKbOperationDTOAdd, self).__init__(qna_list=qna_list, urls=urls, files=files, **kwargs) + + +class UpdateKbOperationDTODelete(DeleteKbContentsDTO): + """An instance of DeleteKbContentsDTO for delete Operation. + + :param ids: List of Qna Ids to be deleted + :type ids: list[int] + :param sources: List of sources to be deleted from knowledgebase. + :type sources: list[str] + """ + + _attribute_map = { + 'ids': {'key': 'ids', 'type': '[int]'}, + 'sources': {'key': 'sources', 'type': '[str]'}, + } + + def __init__(self, *, ids=None, sources=None, **kwargs) -> None: + super(UpdateKbOperationDTODelete, self).__init__(ids=ids, sources=sources, **kwargs) + + +class UpdateKbOperationDTOUpdate(UpdateKbContentsDTO): + """An instance of UpdateKbContentsDTO for Update Operation. + + :param name: Friendly name for the knowledgebase. + :type name: str + :param qna_list: List of Q-A (UpdateQnaDTO) to be added to the + knowledgebase. + :type qna_list: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTO] + :param urls: List of existing URLs to be refreshed. The content will be + extracted again and re-indexed. + :type urls: list[str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'qna_list': {'key': 'qnaList', 'type': '[UpdateQnaDTO]'}, + 'urls': {'key': 'urls', 'type': '[str]'}, + } + + def __init__(self, *, name: str=None, qna_list=None, urls=None, **kwargs) -> None: + super(UpdateKbOperationDTOUpdate, self).__init__(name=name, qna_list=qna_list, urls=urls, **kwargs) + + +class UpdateMetadataDTO(Model): + """PATCH Body schema to represent list of Metadata to be updated. + + :param delete: List of Metadata associated with answer to be deleted + :type delete: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param add: List of metadata associated with answer to be added + :type add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + """ + + _attribute_map = { + 'delete': {'key': 'delete', 'type': '[MetadataDTO]'}, + 'add': {'key': 'add', 'type': '[MetadataDTO]'}, + } + + def __init__(self, *, delete=None, add=None, **kwargs) -> None: + super(UpdateMetadataDTO, self).__init__(**kwargs) + self.delete = delete + self.add = add + + +class UpdateQnaDTO(Model): + """PATCH Body schema for Update Qna List. + + :param id: Unique id for the Q-A + :type id: int + :param answer: Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: List of questions associated with the answer. + :type questions: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOQuestions + :param metadata: List of metadata associated with the answer to be updated + :type metadata: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOMetadata + :param context: Context associated with Qna to be updated. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateQnaDTOContext + """ + + _validation = { + 'id': {'maximum': 2147483647, 'minimum': 0}, + 'source': {'max_length': 300}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': 'UpdateQnaDTOQuestions'}, + 'metadata': {'key': 'metadata', 'type': 'UpdateQnaDTOMetadata'}, + 'context': {'key': 'context', 'type': 'UpdateQnaDTOContext'}, + } + + def __init__(self, *, id: int=None, answer: str=None, source: str=None, questions=None, metadata=None, context=None, **kwargs) -> None: + super(UpdateQnaDTO, self).__init__(**kwargs) + self.id = id + self.answer = answer + self.source = source + self.questions = questions + self.metadata = metadata + self.context = context + + +class UpdateQnaDTOContext(UpdateContextDTO): + """Context associated with Qna to be updated. + + :param prompts_to_delete: List of prompts associated with qna to be + deleted + :type prompts_to_delete: list[int] + :param prompts_to_add: List of prompts to be added to the qna. + :type prompts_to_add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.PromptDTO] + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + """ + + _attribute_map = { + 'prompts_to_delete': {'key': 'promptsToDelete', 'type': '[int]'}, + 'prompts_to_add': {'key': 'promptsToAdd', 'type': '[PromptDTO]'}, + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + } + + def __init__(self, *, prompts_to_delete=None, prompts_to_add=None, is_context_only: bool=None, **kwargs) -> None: + super(UpdateQnaDTOContext, self).__init__(prompts_to_delete=prompts_to_delete, prompts_to_add=prompts_to_add, is_context_only=is_context_only, **kwargs) + + +class UpdateQnaDTOMetadata(UpdateMetadataDTO): + """List of metadata associated with the answer to be updated. + + :param delete: List of Metadata associated with answer to be deleted + :type delete: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + :param add: List of metadata associated with answer to be added + :type add: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.MetadataDTO] + """ + + _attribute_map = { + 'delete': {'key': 'delete', 'type': '[MetadataDTO]'}, + 'add': {'key': 'add', 'type': '[MetadataDTO]'}, + } + + def __init__(self, *, delete=None, add=None, **kwargs) -> None: + super(UpdateQnaDTOMetadata, self).__init__(delete=delete, add=add, **kwargs) + + +class UpdateQuestionsDTO(Model): + """PATCH Body schema for Update Kb which contains list of questions to be + added and deleted. + + :param add: List of questions to be added + :type add: list[str] + :param delete: List of questions to be deleted. + :type delete: list[str] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'delete': {'key': 'delete', 'type': '[str]'}, + } + + def __init__(self, *, add=None, delete=None, **kwargs) -> None: + super(UpdateQuestionsDTO, self).__init__(**kwargs) + self.add = add + self.delete = delete + + +class UpdateQnaDTOQuestions(UpdateQuestionsDTO): + """List of questions associated with the answer. + + :param add: List of questions to be added + :type add: list[str] + :param delete: List of questions to be deleted. + :type delete: list[str] + """ + + _attribute_map = { + 'add': {'key': 'add', 'type': '[str]'}, + 'delete': {'key': 'delete', 'type': '[str]'}, + } + + def __init__(self, *, add=None, delete=None, **kwargs) -> None: + super(UpdateQnaDTOQuestions, self).__init__(add=add, delete=delete, **kwargs) + + +class WordAlterationsDTO(Model): + """Collection of word alterations. + + All required parameters must be populated in order to send to Azure. + + :param word_alterations: Required. Collection of word alterations. + :type word_alterations: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.AlterationsDTO] + """ + + _validation = { + 'word_alterations': {'required': True}, + } + + _attribute_map = { + 'word_alterations': {'key': 'wordAlterations', 'type': '[AlterationsDTO]'}, + } + + def __init__(self, *, word_alterations, **kwargs) -> None: + super(WordAlterationsDTO, self).__init__(**kwargs) + self.word_alterations = word_alterations diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_qn_amaker_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_qn_amaker_client_enums.py new file mode 100644 index 000000000000..3d9f996b78b7 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/models/_qn_amaker_client_enums.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. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class ErrorCodeType(str, Enum): + + bad_argument = "BadArgument" + forbidden = "Forbidden" + not_found = "NotFound" + kb_not_found = "KbNotFound" + unauthorized = "Unauthorized" + unspecified = "Unspecified" + endpoint_keys_error = "EndpointKeysError" + quota_exceeded = "QuotaExceeded" + qna_runtime_error = "QnaRuntimeError" + sku_limit_exceeded = "SKULimitExceeded" + operation_not_found = "OperationNotFound" + service_error = "ServiceError" + validation_failure = "ValidationFailure" + extraction_failure = "ExtractionFailure" + + +class OperationStateType(str, Enum): + + failed = "Failed" + not_started = "NotStarted" + running = "Running" + succeeded = "Succeeded" + + +class EnvironmentType(str, Enum): + + prod = "Prod" + test = "Test" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/__init__.py new file mode 100644 index 000000000000..bdc2419b05d6 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/__init__.py @@ -0,0 +1,24 @@ +# 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 ._endpoint_settings_operations import EndpointSettingsOperations +from ._endpoint_keys_operations import EndpointKeysOperations +from ._alterations_operations import AlterationsOperations +from ._knowledgebase_operations import KnowledgebaseOperations +from ._operations import Operations + +__all__ = [ + 'EndpointSettingsOperations', + 'EndpointKeysOperations', + 'AlterationsOperations', + 'KnowledgebaseOperations', + 'Operations', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_alterations_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_alterations_operations.py new file mode 100644 index 000000000000..14c10df47edf --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_alterations_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class AlterationsOperations(object): + """AlterationsOperations 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): + """Download alterations from runtime. + + :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: WordAlterationsDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.WordAlterationsDTO + 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) + } + 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('WordAlterationsDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/alterations'} + + def replace( + self, word_alterations, custom_headers=None, raw=False, **operation_config): + """Replace alterations data. + + :param word_alterations: Collection of word alterations. + :type word_alterations: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.AlterationsDTO] + :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` + """ + word_alterations1 = models.WordAlterationsDTO(word_alterations=word_alterations) + + # Construct URL + url = self.replace.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(word_alterations1, 'WordAlterationsDTO') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + replace.metadata = {'url': '/alterations'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_keys_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_keys_operations.py new file mode 100644 index 000000000000..b394046f2e00 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_keys_operations.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class EndpointKeysOperations(object): + """EndpointKeysOperations 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_keys( + self, custom_headers=None, raw=False, **operation_config): + """Gets endpoint keys for an endpoint. + + :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: EndpointKeysDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointKeysDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_keys.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('EndpointKeysDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_keys.metadata = {'url': '/endpointkeys'} + + def refresh_keys( + self, key_type, custom_headers=None, raw=False, **operation_config): + """Re-generates an endpoint key. + + :param key_type: Type of Key + :type key_type: 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: EndpointKeysDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointKeysDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.refresh_keys.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'keyType': self._serialize.url("key_type", key_type, 'str') + } + 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.patch(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('EndpointKeysDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + refresh_keys.metadata = {'url': '/endpointkeys/{keyType}'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_settings_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_settings_operations.py new file mode 100644 index 000000000000..854fe14b883b --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_endpoint_settings_operations.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class EndpointSettingsOperations(object): + """EndpointSettingsOperations 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_settings( + self, custom_headers=None, raw=False, **operation_config): + """Gets endpoint settings for an endpoint. + + :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: EndpointSettingsDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointSettingsDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_settings.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('EndpointSettingsDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_settings.metadata = {'url': '/endpointSettings'} + + def update_settings( + self, active_learning=None, custom_headers=None, raw=False, **operation_config): + """Updates endpoint settings for an endpoint. + + :param active_learning: Active Learning settings of the endpoint. + :type active_learning: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EndpointSettingsDTOActiveLearning + :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: str or ClientRawResponse if raw=true + :rtype: str or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + endpoint_settings_payload = models.EndpointSettingsDTO(active_learning=active_learning) + + # Construct URL + url = self.update_settings.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(endpoint_settings_payload, 'EndpointSettingsDTO') + + # Construct and send request + request = self._client.patch(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('str', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update_settings.metadata = {'url': '/endpointSettings'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_knowledgebase_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_knowledgebase_operations.py new file mode 100644 index 000000000000..670ac93a11a9 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_knowledgebase_operations.py @@ -0,0 +1,463 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class KnowledgebaseOperations(object): + """KnowledgebaseOperations 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 list_all( + self, custom_headers=None, raw=False, **operation_config): + """Gets all knowledgebases for a user. + + :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: KnowledgebasesDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.KnowledgebasesDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list_all.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('KnowledgebasesDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_all.metadata = {'url': '/knowledgebases'} + + def get_details( + self, kb_id, custom_headers=None, raw=False, **operation_config): + """Gets details of a specific knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_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: KnowledgebaseDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.KnowledgebaseDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_details.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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('KnowledgebaseDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_details.metadata = {'url': '/knowledgebases/{kbId}'} + + def delete( + self, kb_id, custom_headers=None, raw=False, **operation_config): + """Deletes the knowledgebase and all its data. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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 + delete.metadata = {'url': '/knowledgebases/{kbId}'} + + def publish( + self, kb_id, custom_headers=None, raw=False, **operation_config): + """Publishes all changes in test index of a knowledgebase to its prod + index. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.publish.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + publish.metadata = {'url': '/knowledgebases/{kbId}'} + + def replace( + self, kb_id, qn_alist, custom_headers=None, raw=False, **operation_config): + """Replace knowledgebase contents. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param qn_alist: List of Q-A (QnADTO) to be added to the + knowledgebase. Q-A Ids are assigned by the service and should be + omitted. + :type qn_alist: + list[~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADTO] + :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` + """ + replace_kb = models.ReplaceKbDTO(qn_alist=qn_alist) + + # Construct URL + url = self.replace.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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(replace_kb, 'ReplaceKbDTO') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + replace.metadata = {'url': '/knowledgebases/{kbId}'} + + def update( + self, kb_id, update_kb, custom_headers=None, raw=False, **operation_config): + """Asynchronous operation to modify a knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param update_kb: Post body of the request. + :type update_kb: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.UpdateKbOperationDTO + :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: Operation or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Operation + 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), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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(update_kb, 'UpdateKbOperationDTO') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('Operation', 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 + update.metadata = {'url': '/knowledgebases/{kbId}'} + + def create( + self, create_kb_payload, custom_headers=None, raw=False, **operation_config): + """Asynchronous operation to create a new knowledgebase. + + :param create_kb_payload: Post body of the request. + :type create_kb_payload: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.CreateKbDTO + :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: Operation or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Operation + 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(create_kb_payload, 'CreateKbDTO') + + # 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 [202]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('Operation', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/knowledgebases/create'} + + def download( + self, kb_id, environment, custom_headers=None, raw=False, **operation_config): + """Download the knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param environment: Specifies whether environment is Test or Prod. + Possible values include: 'Prod', 'Test' + :type environment: str or + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.EnvironmentType + :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: QnADocumentsDTO or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.QnADocumentsDTO + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.download.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str'), + 'environment': self._serialize.url("environment", environment, 'str') + } + 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('QnADocumentsDTO', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + download.metadata = {'url': '/knowledgebases/{kbId}/{environment}/qna'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_operations.py new file mode 100644 index 000000000000..f0ab3fa49f09 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/operations/_operations.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class Operations(object): + """Operations 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_details( + self, operation_id, custom_headers=None, raw=False, **operation_config): + """Gets details of a specific long running operation. + + :param operation_id: Operation id. + :type operation_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: Operation or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.authoring.models.Operation + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_details.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str') + } + 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) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Operation', response) + header_dict = { + 'RetryAfter': 'int', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_details.metadata = {'url': '/operations/{operationId}'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/version.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/version.py new file mode 100644 index 000000000000..3faab2cb0b4a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/authoring/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 = "4.0" + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/__init__.py new file mode 100644 index 000000000000..f283c224f42c --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/__init__.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 ._configuration import QnAMakerRuntimeClientConfiguration +from ._qn_amaker_runtime_client import QnAMakerRuntimeClient +__all__ = ['QnAMakerRuntimeClient', 'QnAMakerRuntimeClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_configuration.py new file mode 100644 index 000000000000..57d958a26600 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_configuration.py @@ -0,0 +1,47 @@ +# 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 QnAMakerRuntimeClientConfiguration(Configuration): + """Configuration for QnAMakerRuntimeClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param runtime_endpoint: QnA Maker App Service endpoint (for example: + https://{qnaservice-hostname}.azurewebsites.net). + :type runtime_endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, runtime_endpoint, credentials): + + if runtime_endpoint is None: + raise ValueError("Parameter 'runtime_endpoint' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = '{RuntimeEndpoint}/qnamaker' + + super(QnAMakerRuntimeClientConfiguration, 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-knowledge-qnamaker/{}'.format(VERSION)) + + self.runtime_endpoint = runtime_endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_qn_amaker_runtime_client.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_qn_amaker_runtime_client.py new file mode 100644 index 000000000000..6aea45d358c7 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/_qn_amaker_runtime_client.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import QnAMakerRuntimeClientConfiguration +from .operations import RuntimeOperations +from . import models + + +class QnAMakerRuntimeClient(SDKClient): + """An API for QnAMaker runtime + + :ivar config: Configuration for client. + :vartype config: QnAMakerRuntimeClientConfiguration + + :ivar runtime: Runtime operations + :vartype runtime: azure.cognitiveservices.knowledge.qnamaker.runtime.operations.RuntimeOperations + + :param runtime_endpoint: QnA Maker App Service endpoint (for example: + https://{qnaservice-hostname}.azurewebsites.net). + :type runtime_endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, runtime_endpoint, credentials): + + self.config = QnAMakerRuntimeClientConfiguration(runtime_endpoint, credentials) + super(QnAMakerRuntimeClient, 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 = '4.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.runtime = RuntimeOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/__init__.py new file mode 100644 index 000000000000..a1181c783561 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ContextDTO + from ._models_py3 import Error + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponseError + from ._models_py3 import FeedbackRecordDTO + from ._models_py3 import FeedbackRecordsDTO + from ._models_py3 import InnerErrorModel + from ._models_py3 import MetadataDTO + from ._models_py3 import PromptDTO + from ._models_py3 import PromptDTOQna + from ._models_py3 import QnADTO + from ._models_py3 import QnADTOContext + from ._models_py3 import QnASearchResult + from ._models_py3 import QnASearchResultContext + from ._models_py3 import QnASearchResultList + from ._models_py3 import QueryContextDTO + from ._models_py3 import QueryDTO + from ._models_py3 import QueryDTOContext +except (SyntaxError, ImportError): + from ._models import ContextDTO + from ._models import Error + from ._models import ErrorResponse, ErrorResponseException + from ._models import ErrorResponseError + from ._models import FeedbackRecordDTO + from ._models import FeedbackRecordsDTO + from ._models import InnerErrorModel + from ._models import MetadataDTO + from ._models import PromptDTO + from ._models import PromptDTOQna + from ._models import QnADTO + from ._models import QnADTOContext + from ._models import QnASearchResult + from ._models import QnASearchResultContext + from ._models import QnASearchResultList + from ._models import QueryContextDTO + from ._models import QueryDTO + from ._models import QueryDTOContext +from ._qn_amaker_runtime_client_enums import ( + ErrorCodeType, +) + +__all__ = [ + 'ContextDTO', + 'Error', + 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponseError', + 'FeedbackRecordDTO', + 'FeedbackRecordsDTO', + 'InnerErrorModel', + 'MetadataDTO', + 'PromptDTO', + 'PromptDTOQna', + 'QnADTO', + 'QnADTOContext', + 'QnASearchResult', + 'QnASearchResultContext', + 'QnASearchResultList', + 'QueryContextDTO', + 'QueryDTO', + 'QueryDTOContext', + 'ErrorCodeType', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models.py new file mode 100644 index 000000000000..6a78d1b905f3 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models.py @@ -0,0 +1,590 @@ +# 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 ContextDTO(Model): + """Context associated with Qna. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(ContextDTO, self).__init__(**kwargs) + self.is_context_only = kwargs.get('is_context_only', None) + self.prompts = kwargs.get('prompts', None) + + +class Error(Model): + """The error object. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(Error, 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 ErrorResponse(Model): + """Error response. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param error: The error object. + :type error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + 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 ErrorResponseError(Error): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(ErrorResponseError, self).__init__(**kwargs) + + +class FeedbackRecordDTO(Model): + """Active learning feedback record. + + :param user_id: Unique identifier for the user. + :type user_id: str + :param user_question: The suggested question being provided as feedback. + :type user_question: str + :param qna_id: The qnaId for which the suggested question is provided as + feedback. + :type qna_id: int + """ + + _validation = { + 'user_question': {'max_length': 1000}, + } + + _attribute_map = { + 'user_id': {'key': 'userId', 'type': 'str'}, + 'user_question': {'key': 'userQuestion', 'type': 'str'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(FeedbackRecordDTO, self).__init__(**kwargs) + self.user_id = kwargs.get('user_id', None) + self.user_question = kwargs.get('user_question', None) + self.qna_id = kwargs.get('qna_id', None) + + +class FeedbackRecordsDTO(Model): + """Active learning feedback records. + + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.FeedbackRecordDTO] + """ + + _attribute_map = { + 'feedback_records': {'key': 'feedbackRecords', 'type': '[FeedbackRecordDTO]'}, + } + + def __init__(self, **kwargs): + super(FeedbackRecordsDTO, self).__init__(**kwargs) + self.feedback_records = kwargs.get('feedback_records', None) + + +class InnerErrorModel(Model): + """An object containing more specific information about the error. As per + Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param code: A more specific error code than was provided by the + containing error. + :type code: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, **kwargs): + super(InnerErrorModel, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.inner_error = kwargs.get('inner_error', None) + + +class MetadataDTO(Model): + """Name - value pair of metadata. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Metadata name. + :type name: str + :param value: Required. Metadata value. + :type value: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'value': {'required': True, 'max_length': 500, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(MetadataDTO, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + + +class PromptDTO(Model): + """Prompt for an answer. + + :param display_order: Index of the prompt - used in ordering of the + prompts + :type display_order: int + :param qna_id: Qna id corresponding to the prompt - if QnaId is present, + QnADTO object is ignored. + :type qna_id: int + :param qna: QnADTO - Either QnaId or QnADTO needs to be present in a + PromptDTO object + :type qna: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTOQna + :param display_text: Text displayed to represent a follow up question + prompt + :type display_text: str + """ + + _validation = { + 'display_text': {'max_length': 200}, + } + + _attribute_map = { + 'display_order': {'key': 'displayOrder', 'type': 'int'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + 'qna': {'key': 'qna', 'type': 'PromptDTOQna'}, + 'display_text': {'key': 'displayText', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PromptDTO, self).__init__(**kwargs) + self.display_order = kwargs.get('display_order', None) + self.qna_id = kwargs.get('qna_id', None) + self.qna = kwargs.get('qna', None) + self.display_text = kwargs.get('display_text', None) + + +class QnADTO(Model): + """Q-A object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, **kwargs): + super(QnADTO, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.answer = kwargs.get('answer', None) + self.source = kwargs.get('source', None) + self.questions = kwargs.get('questions', None) + self.metadata = kwargs.get('metadata', None) + self.context = kwargs.get('context', None) + + +class PromptDTOQna(QnADTO): + """QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, **kwargs): + super(PromptDTOQna, self).__init__(**kwargs) + + +class QnADTOContext(ContextDTO): + """Context of a QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(QnADTOContext, self).__init__(**kwargs) + + +class QnASearchResult(Model): + """Represents Search Result. + + :param questions: List of questions. + :type questions: list[str] + :param answer: Answer. + :type answer: str + :param score: Search result score. + :type score: float + :param id: Id of the QnA result. + :type id: int + :param source: Source of QnA result. + :type source: str + :param metadata: List of metadata. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context object of the QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnASearchResultContext + """ + + _attribute_map = { + 'questions': {'key': 'questions', 'type': '[str]'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + 'id': {'key': 'id', 'type': 'int'}, + 'source': {'key': 'source', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnASearchResultContext'}, + } + + def __init__(self, **kwargs): + super(QnASearchResult, self).__init__(**kwargs) + self.questions = kwargs.get('questions', None) + self.answer = kwargs.get('answer', None) + self.score = kwargs.get('score', None) + self.id = kwargs.get('id', None) + self.source = kwargs.get('source', None) + self.metadata = kwargs.get('metadata', None) + self.context = kwargs.get('context', None) + + +class QnASearchResultContext(ContextDTO): + """Context object of the QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(QnASearchResultContext, self).__init__(**kwargs) + + +class QnASearchResultList(Model): + """Represents List of Question Answers. + + :param answers: Represents Search Result list. + :type answers: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnASearchResult] + """ + + _attribute_map = { + 'answers': {'key': 'answers', 'type': '[QnASearchResult]'}, + } + + def __init__(self, **kwargs): + super(QnASearchResultList, self).__init__(**kwargs) + self.answers = kwargs.get('answers', None) + + +class QueryContextDTO(Model): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QueryContextDTO, self).__init__(**kwargs) + self.previous_qna_id = kwargs.get('previous_qna_id', None) + self.previous_user_query = kwargs.get('previous_user_query', None) + + +class QueryDTO(Model): + """POST body schema to query the knowledgebase. + + :param qna_id: Exact qnaId to fetch from the knowledgebase, this field + takes priority over question. + :type qna_id: str + :param question: User question to query against the knowledge base. + :type question: str + :param top: Max number of answers to be returned for the question. + :type top: int + :param user_id: Unique identifier for the user. + :type user_id: str + :param is_test: Query against the test index. + :type is_test: bool + :param score_threshold: Threshold for answers returned based on score. + :type score_threshold: float + :param context: Context object with previous QnA's information. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QueryDTOContext + :param ranker_type: Optional field. Set to 'QuestionOnly' for using a + question only Ranker. + :type ranker_type: str + :param strict_filters: Find only answers that contain these metadata. + :type strict_filters: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + """ + + _attribute_map = { + 'qna_id': {'key': 'qnaId', 'type': 'str'}, + 'question': {'key': 'question', 'type': 'str'}, + 'top': {'key': 'top', 'type': 'int'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'is_test': {'key': 'isTest', 'type': 'bool'}, + 'score_threshold': {'key': 'scoreThreshold', 'type': 'float'}, + 'context': {'key': 'context', 'type': 'QueryDTOContext'}, + 'ranker_type': {'key': 'rankerType', 'type': 'str'}, + 'strict_filters': {'key': 'strictFilters', 'type': '[MetadataDTO]'}, + } + + def __init__(self, **kwargs): + super(QueryDTO, self).__init__(**kwargs) + self.qna_id = kwargs.get('qna_id', None) + self.question = kwargs.get('question', None) + self.top = kwargs.get('top', None) + self.user_id = kwargs.get('user_id', None) + self.is_test = kwargs.get('is_test', None) + self.score_threshold = kwargs.get('score_threshold', None) + self.context = kwargs.get('context', None) + self.ranker_type = kwargs.get('ranker_type', None) + self.strict_filters = kwargs.get('strict_filters', None) + + +class QueryDTOContext(QueryContextDTO): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QueryDTOContext, self).__init__(**kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models_py3.py new file mode 100644 index 000000000000..9757dc2ce502 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_models_py3.py @@ -0,0 +1,590 @@ +# 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 ContextDTO(Model): + """Context associated with Qna. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(ContextDTO, self).__init__(**kwargs) + self.is_context_only = is_context_only + self.prompts = prompts + + +class Error(Model): + """The error object. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code, message: str=None, target: str=None, details=None, inner_error=None, **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + self.inner_error = inner_error + + +class ErrorResponse(Model): + """Error response. As per Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param error: The error object. + :type error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__(self, *, error=None, **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 ErrorResponseError(Error): + """The error object. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. One of a server-defined set of error codes. + Possible values include: 'BadArgument', 'Forbidden', 'NotFound', + 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + 'OperationNotFound', 'ServiceError', 'ValidationFailure', + 'ExtractionFailure' + :type code: str or + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.ErrorCodeType + :param message: A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of details about specific errors that led to this + reported error. + :type details: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.Error] + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code, message: str=None, target: str=None, details=None, inner_error=None, **kwargs) -> None: + super(ErrorResponseError, self).__init__(code=code, message=message, target=target, details=details, inner_error=inner_error, **kwargs) + + +class FeedbackRecordDTO(Model): + """Active learning feedback record. + + :param user_id: Unique identifier for the user. + :type user_id: str + :param user_question: The suggested question being provided as feedback. + :type user_question: str + :param qna_id: The qnaId for which the suggested question is provided as + feedback. + :type qna_id: int + """ + + _validation = { + 'user_question': {'max_length': 1000}, + } + + _attribute_map = { + 'user_id': {'key': 'userId', 'type': 'str'}, + 'user_question': {'key': 'userQuestion', 'type': 'str'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + } + + def __init__(self, *, user_id: str=None, user_question: str=None, qna_id: int=None, **kwargs) -> None: + super(FeedbackRecordDTO, self).__init__(**kwargs) + self.user_id = user_id + self.user_question = user_question + self.qna_id = qna_id + + +class FeedbackRecordsDTO(Model): + """Active learning feedback records. + + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.FeedbackRecordDTO] + """ + + _attribute_map = { + 'feedback_records': {'key': 'feedbackRecords', 'type': '[FeedbackRecordDTO]'}, + } + + def __init__(self, *, feedback_records=None, **kwargs) -> None: + super(FeedbackRecordsDTO, self).__init__(**kwargs) + self.feedback_records = feedback_records + + +class InnerErrorModel(Model): + """An object containing more specific information about the error. As per + Microsoft One API guidelines - + https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + + :param code: A more specific error code than was provided by the + containing error. + :type code: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.InnerErrorModel + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerErrorModel'}, + } + + def __init__(self, *, code: str=None, inner_error=None, **kwargs) -> None: + super(InnerErrorModel, self).__init__(**kwargs) + self.code = code + self.inner_error = inner_error + + +class MetadataDTO(Model): + """Name - value pair of metadata. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Metadata name. + :type name: str + :param value: Required. Metadata value. + :type value: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'value': {'required': True, 'max_length': 500, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, *, name: str, value: str, **kwargs) -> None: + super(MetadataDTO, self).__init__(**kwargs) + self.name = name + self.value = value + + +class PromptDTO(Model): + """Prompt for an answer. + + :param display_order: Index of the prompt - used in ordering of the + prompts + :type display_order: int + :param qna_id: Qna id corresponding to the prompt - if QnaId is present, + QnADTO object is ignored. + :type qna_id: int + :param qna: QnADTO - Either QnaId or QnADTO needs to be present in a + PromptDTO object + :type qna: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTOQna + :param display_text: Text displayed to represent a follow up question + prompt + :type display_text: str + """ + + _validation = { + 'display_text': {'max_length': 200}, + } + + _attribute_map = { + 'display_order': {'key': 'displayOrder', 'type': 'int'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + 'qna': {'key': 'qna', 'type': 'PromptDTOQna'}, + 'display_text': {'key': 'displayText', 'type': 'str'}, + } + + def __init__(self, *, display_order: int=None, qna_id: int=None, qna=None, display_text: str=None, **kwargs) -> None: + super(PromptDTO, self).__init__(**kwargs) + self.display_order = display_order + self.qna_id = qna_id + self.qna = qna + self.display_text = display_text + + +class QnADTO(Model): + """Q-A object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, *, answer: str, questions, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(QnADTO, self).__init__(**kwargs) + self.id = id + self.answer = answer + self.source = source + self.questions = questions + self.metadata = metadata + self.context = context + + +class PromptDTOQna(QnADTO): + """QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object. + + All required parameters must be populated in order to send to Azure. + + :param id: Unique id for the Q-A. + :type id: int + :param answer: Required. Answer text + :type answer: str + :param source: Source from which Q-A was indexed. eg. + https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + :type source: str + :param questions: Required. List of questions associated with the answer. + :type questions: list[str] + :param metadata: List of metadata associated with the answer. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context of a QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnADTOContext + """ + + _validation = { + 'answer': {'required': True, 'max_length': 25000, 'min_length': 1}, + 'source': {'max_length': 300}, + 'questions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'int'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + 'questions': {'key': 'questions', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnADTOContext'}, + } + + def __init__(self, *, answer: str, questions, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(PromptDTOQna, self).__init__(id=id, answer=answer, source=source, questions=questions, metadata=metadata, context=context, **kwargs) + + +class QnADTOContext(ContextDTO): + """Context of a QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(QnADTOContext, self).__init__(is_context_only=is_context_only, prompts=prompts, **kwargs) + + +class QnASearchResult(Model): + """Represents Search Result. + + :param questions: List of questions. + :type questions: list[str] + :param answer: Answer. + :type answer: str + :param score: Search result score. + :type score: float + :param id: Id of the QnA result. + :type id: int + :param source: Source of QnA result. + :type source: str + :param metadata: List of metadata. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + :param context: Context object of the QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnASearchResultContext + """ + + _attribute_map = { + 'questions': {'key': 'questions', 'type': '[str]'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + 'id': {'key': 'id', 'type': 'int'}, + 'source': {'key': 'source', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnASearchResultContext'}, + } + + def __init__(self, *, questions=None, answer: str=None, score: float=None, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(QnASearchResult, self).__init__(**kwargs) + self.questions = questions + self.answer = answer + self.score = score + self.id = id + self.source = source + self.metadata = metadata + self.context = context + + +class QnASearchResultContext(ContextDTO): + """Context object of the QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(QnASearchResultContext, self).__init__(is_context_only=is_context_only, prompts=prompts, **kwargs) + + +class QnASearchResultList(Model): + """Represents List of Question Answers. + + :param answers: Represents Search Result list. + :type answers: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnASearchResult] + """ + + _attribute_map = { + 'answers': {'key': 'answers', 'type': '[QnASearchResult]'}, + } + + def __init__(self, *, answers=None, **kwargs) -> None: + super(QnASearchResultList, self).__init__(**kwargs) + self.answers = answers + + +class QueryContextDTO(Model): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, *, previous_qna_id: str=None, previous_user_query: str=None, **kwargs) -> None: + super(QueryContextDTO, self).__init__(**kwargs) + self.previous_qna_id = previous_qna_id + self.previous_user_query = previous_user_query + + +class QueryDTO(Model): + """POST body schema to query the knowledgebase. + + :param qna_id: Exact qnaId to fetch from the knowledgebase, this field + takes priority over question. + :type qna_id: str + :param question: User question to query against the knowledge base. + :type question: str + :param top: Max number of answers to be returned for the question. + :type top: int + :param user_id: Unique identifier for the user. + :type user_id: str + :param is_test: Query against the test index. + :type is_test: bool + :param score_threshold: Threshold for answers returned based on score. + :type score_threshold: float + :param context: Context object with previous QnA's information. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QueryDTOContext + :param ranker_type: Optional field. Set to 'QuestionOnly' for using a + question only Ranker. + :type ranker_type: str + :param strict_filters: Find only answers that contain these metadata. + :type strict_filters: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.MetadataDTO] + """ + + _attribute_map = { + 'qna_id': {'key': 'qnaId', 'type': 'str'}, + 'question': {'key': 'question', 'type': 'str'}, + 'top': {'key': 'top', 'type': 'int'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'is_test': {'key': 'isTest', 'type': 'bool'}, + 'score_threshold': {'key': 'scoreThreshold', 'type': 'float'}, + 'context': {'key': 'context', 'type': 'QueryDTOContext'}, + 'ranker_type': {'key': 'rankerType', 'type': 'str'}, + 'strict_filters': {'key': 'strictFilters', 'type': '[MetadataDTO]'}, + } + + def __init__(self, *, qna_id: str=None, question: str=None, top: int=None, user_id: str=None, is_test: bool=None, score_threshold: float=None, context=None, ranker_type: str=None, strict_filters=None, **kwargs) -> None: + super(QueryDTO, self).__init__(**kwargs) + self.qna_id = qna_id + self.question = question + self.top = top + self.user_id = user_id + self.is_test = is_test + self.score_threshold = score_threshold + self.context = context + self.ranker_type = ranker_type + self.strict_filters = strict_filters + + +class QueryDTOContext(QueryContextDTO): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, *, previous_qna_id: str=None, previous_user_query: str=None, **kwargs) -> None: + super(QueryDTOContext, self).__init__(previous_qna_id=previous_qna_id, previous_user_query=previous_user_query, **kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_qn_amaker_runtime_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_qn_amaker_runtime_client_enums.py new file mode 100644 index 000000000000..c523cb290231 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/models/_qn_amaker_runtime_client_enums.py @@ -0,0 +1,30 @@ +# 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 ErrorCodeType(str, Enum): + + bad_argument = "BadArgument" + forbidden = "Forbidden" + not_found = "NotFound" + kb_not_found = "KbNotFound" + unauthorized = "Unauthorized" + unspecified = "Unspecified" + endpoint_keys_error = "EndpointKeysError" + quota_exceeded = "QuotaExceeded" + qna_runtime_error = "QnaRuntimeError" + sku_limit_exceeded = "SKULimitExceeded" + operation_not_found = "OperationNotFound" + service_error = "ServiceError" + validation_failure = "ValidationFailure" + extraction_failure = "ExtractionFailure" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/__init__.py new file mode 100644 index 000000000000..712a6199a8da --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/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 ._runtime_operations import RuntimeOperations + +__all__ = [ + 'RuntimeOperations', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/_runtime_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/_runtime_operations.py new file mode 100644 index 000000000000..13bae6091e50 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/operations/_runtime_operations.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class RuntimeOperations(object): + """RuntimeOperations 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 generate_answer( + self, kb_id, generate_answer_payload, custom_headers=None, raw=False, **operation_config): + """GenerateAnswer call to query the knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param generate_answer_payload: Post body of the request. + :type generate_answer_payload: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QueryDTO + :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: QnASearchResultList or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.runtime.models.QnASearchResultList + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.generate_answer.metadata['url'] + path_format_arguments = { + 'RuntimeEndpoint': self._serialize.url("self.config.runtime_endpoint", self.config.runtime_endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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(generate_answer_payload, 'QueryDTO') + + # 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 [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('QnASearchResultList', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + generate_answer.metadata = {'url': '/knowledgebases/{kbId}/generateAnswer'} + + def train( + self, kb_id, feedback_records=None, custom_headers=None, raw=False, **operation_config): + """Train call to add suggestions to the knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.runtime.models.FeedbackRecordDTO] + :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` + """ + train_payload = models.FeedbackRecordsDTO(feedback_records=feedback_records) + + # Construct URL + url = self.train.metadata['url'] + path_format_arguments = { + 'RuntimeEndpoint': self._serialize.url("self.config.runtime_endpoint", self.config.runtime_endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + 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(train_payload, 'FeedbackRecordsDTO') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + train.metadata = {'url': '/knowledgebases/{kbId}/train'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/version.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/version.py new file mode 100644 index 000000000000..3faab2cb0b4a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/runtime/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 = "4.0" +