From 423673d3418e5af1ae7ffce5dc249f75bb4f9189 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 9 Nov 2020 16:22:16 -0800 Subject: [PATCH] Regenerate QnAMaker with 5.0-preview1 API (#17365) * Regenerate QnAMaker with 5.0-preview1 API * Remove code model v1 file * Bump pom version --- eng/versioning/version_data.txt | 2 +- .../ms-azure-cs-qnamaker/pom.xml | 2 +- .../knowledge/qnamaker/Alterations.java | 45 +++ .../knowledge/qnamaker/EndpointSettings.java | 17 +- .../knowledge/qnamaker/Knowledgebases.java | 202 +++++++++- .../knowledge/qnamaker/QnAMakerClient.java | 4 +- .../knowledge/qnamaker/QnAMakerManager.java | 4 +- .../qnamaker/QnAMakerRuntimeClient.java | 104 ----- .../qnamaker/QnAMakerRuntimeManager.java | 94 ----- .../knowledge/qnamaker/Runtimes.java | 133 ------- .../implementation/AlterationsImpl.java | 172 +++++++++ .../implementation/EndpointSettingsImpl.java | 45 ++- .../implementation/KnowledgebasesImpl.java | 365 +++++++++++++++++- .../implementation/QnAMakerClientImpl.java | 10 +- .../QnAMakerRuntimeClientImpl.java | 185 --------- .../qnamaker/implementation/RuntimesImpl.java | 311 --------------- .../qnamaker/implementation/package-info.java | 4 +- .../qnamaker/models/AnswerSpanRequestDTO.java | 95 +++++ .../models/AnswerSpanResponseDTO.java | 121 ++++++ .../qnamaker/models/CreateKbDTO.java | 58 ++- .../models/DownloadOptionalParameter.java | 91 +++++ .../knowledge/qnamaker/models/QnADTO.java | 26 ++ .../qnamaker/models/QnASearchResult.java | 26 ++ .../models/QnASearchResultAnswerSpan.java | 16 + .../qnamaker/models/QueryContextDTO.java | 6 +- .../knowledge/qnamaker/models/QueryDTO.java | 57 ++- .../models/QueryDTOAnswerSpanRequest.java | 16 + .../StrictFiltersCompoundOperationType.java | 41 ++ .../qnamaker/models/UpdateKbContentsDTO.java | 26 ++ .../qnamaker/models/package-info.java | 4 +- .../knowledge/qnamaker/package-info.java | 4 +- 31 files changed, 1391 insertions(+), 895 deletions(-) delete mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeClient.java delete mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeManager.java delete mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Runtimes.java delete mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerRuntimeClientImpl.java delete mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/RuntimesImpl.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanRequestDTO.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanResponseDTO.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/DownloadOptionalParameter.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResultAnswerSpan.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTOAnswerSpanRequest.java create mode 100644 sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/StrictFiltersCompoundOperationType.java diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index 3e76bb3e0023e..d56fc84facdc2 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -23,7 +23,7 @@ com.microsoft.azure.cognitiveservices:azure-cognitiveservices-contentmoderator;1 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-prediction;1.1.0-beta.3;1.1.0-beta.3 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-customvision-training;1.1.0-beta.3;1.1.0-beta.3 com.microsoft.azure.cognitiveservices:azure-cognitiveservices-faceapi;1.1.0-beta.1;1.1.0-beta.1 -com.microsoft.azure.cognitiveservices:azure-cognitiveservices-qnamaker;1.0.0-beta.1;1.0.0-beta.1 +com.microsoft.azure.cognitiveservices:azure-cognitiveservices-qnamaker;1.0.0-beta.2;1.0.0-beta.2 com.microsoft.azure:azure-eventhubs;3.2.2;3.3.0-beta.1 com.microsoft.azure:azure-eventhubs-eph;3.2.2;3.3.0-beta.1 com.microsoft.azure:azure-eventhubs-extensions;3.2.2;3.3.0-beta.1 diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/pom.xml b/sdk/cognitiveservices/ms-azure-cs-qnamaker/pom.xml index 0a84d4541bd27..550233824d824 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/pom.xml +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/pom.xml @@ -15,7 +15,7 @@ azure-cognitiveservices-qnamaker com.microsoft.azure.cognitiveservices - 1.0.0-beta.1 + 1.0.0-beta.2 jar Microsoft Azure SDK for Cognitive Service QnA Maker This package contains Microsoft Cognitive Service QnA Maker SDK. diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Alterations.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Alterations.java index 6a697f2f506c6..757727f4eccdd 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Alterations.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Alterations.java @@ -61,4 +61,49 @@ public interface Alterations { Observable replaceAsync(List wordAlterations); + + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the WordAlterationsDTO object if successful. + */ + WordAlterationsDTO getAlterationsForKb(String kbId); + + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the WordAlterationsDTO object + */ + Observable getAlterationsForKbAsync(String kbId); + + + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void replaceAlterationsForKb(String kbId, List wordAlterations); + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the deferred computation of this call if successful. + */ + Observable replaceAlterationsForKbAsync(String kbId, List wordAlterations); + + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java index 1ce0610ad85c7..5604faeb24b44 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java @@ -8,11 +8,10 @@ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.UpdateSettingsOptionalParameter; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTOActiveLearning; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; -import java.io.IOException; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.UpdateSettingsOptionalParameter; import rx.Observable; /** @@ -47,18 +46,17 @@ public interface EndpointSettings { * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ErrorResponseException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the String object if successful. */ - String updateSettings(UpdateSettingsOptionalParameter updateSettingsOptionalParameter); + void updateSettings(UpdateSettingsOptionalParameter updateSettingsOptionalParameter); /** * Updates endpoint settings for an endpoint. * * @param updateSettingsOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the String object + * @return a representation of the deferred computation of this call if successful. */ - Observable updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter); + Observable updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter); /** * Updates endpoint settings for an endpoint. @@ -92,16 +90,15 @@ interface WithExecute extends EndpointSettingsUpdateSettingsDefinitionStages.Wit /** * Execute the request. * - * @return the String object if successful. */ - String execute(); + void execute(); /** * Execute the request asynchronously. * - * @return the observable to the String object + * @return a representation of the deferred computation of this call if successful. */ - Observable executeAsync(); + Observable executeAsync(); } } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Knowledgebases.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Knowledgebases.java index 8295af0a61678..45cf630ca7a3f 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Knowledgebases.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Knowledgebases.java @@ -8,15 +8,20 @@ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.DownloadOptionalParameter; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.TrainOptionalParameter; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.CreateKbDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EnvironmentType; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebaseDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebasesDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebaseUpdateHeaders; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.Operation; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnADocumentsDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnADTO; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultList; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QueryDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.UpdateKbOperationDTO; import java.io.IOException; import java.util.List; @@ -182,28 +187,219 @@ public interface Knowledgebases { Observable createAsync(CreateKbDTO createKbPayload); - /** * Download the knowledgebase. * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test'. + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ErrorResponseException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the QnADocumentsDTO object if successful. */ - QnADocumentsDTO download(String kbId, EnvironmentType environment); + QnADocumentsDTO download(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter); /** * Download the knowledgebase. * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test'. + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the QnADocumentsDTO object */ - Observable downloadAsync(String kbId, EnvironmentType environment); + Observable downloadAsync(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter); + + /** + * Download the knowledgebase. + * + * @return the first stage of the download call + */ + KnowledgebasesDownloadDefinitionStages.WithKbId download(); + + /** + * Grouping of download definition stages. + */ + interface KnowledgebasesDownloadDefinitionStages { + /** + * The stage of the definition to be specify kbId. + */ + interface WithKbId { + /** + * Knowledgebase id. + * + * @return next definition stage + */ + WithEnvironment withKbId(String kbId); + } + /** + * The stage of the definition to be specify environment. + */ + interface WithEnvironment { + /** + * Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test'. + * + * @return next definition stage + */ + KnowledgebasesDownloadDefinitionStages.WithExecute withEnvironment(EnvironmentType environment); + } + + /** + * The stage of the definition which allows for any other optional settings to be specified. + */ + interface WithAllOptions { + /** + * The source property filter to apply. + * + * @return next definition stage + */ + KnowledgebasesDownloadDefinitionStages.WithExecute withSource(String source); + + /** + * The last changed status property filter to apply. + * + * @return next definition stage + */ + KnowledgebasesDownloadDefinitionStages.WithExecute withChangedSince(String changedSince); + + } + + /** + * The last stage of the definition which will make the operation call. + */ + interface WithExecute extends KnowledgebasesDownloadDefinitionStages.WithAllOptions { + /** + * Execute the request. + * + * @return the QnADocumentsDTO object if successful. + */ + QnADocumentsDTO execute(); + + /** + * Execute the request asynchronously. + * + * @return the observable to the QnADocumentsDTO object + */ + Observable executeAsync(); + } + } + + /** + * The entirety of download definition. + */ + interface KnowledgebasesDownloadDefinition extends + KnowledgebasesDownloadDefinitionStages.WithKbId, + KnowledgebasesDownloadDefinitionStages.WithEnvironment, + KnowledgebasesDownloadDefinitionStages.WithExecute { + } + + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the QnASearchResultList object if successful. + */ + QnASearchResultList generateAnswer(String kbId, QueryDTO generateAnswerPayload); + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QnASearchResultList object + */ + Observable generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload); + + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void train(String kbId, TrainOptionalParameter trainOptionalParameter); + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return a representation of the deferred computation of this call if successful. + */ + Observable trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter); + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @return the first stage of the train call + */ + KnowledgebasesTrainDefinitionStages.WithKbId train(); + + /** + * Grouping of train definition stages. + */ + interface KnowledgebasesTrainDefinitionStages { + /** + * The stage of the definition to be specify kbId. + */ + interface WithKbId { + /** + * Knowledgebase id. + * + * @return next definition stage + */ + KnowledgebasesTrainDefinitionStages.WithExecute withKbId(String kbId); + } + + /** + * The stage of the definition which allows for any other optional settings to be specified. + */ + interface WithAllOptions { + /** + * List of feedback records. + * + * @return next definition stage + */ + KnowledgebasesTrainDefinitionStages.WithExecute withFeedbackRecords(List feedbackRecords); + + } + + /** + * The last stage of the definition which will make the operation call. + */ + interface WithExecute extends KnowledgebasesTrainDefinitionStages.WithAllOptions { + /** + * Execute the request. + * + */ + void execute(); + + /** + * Execute the request asynchronously. + * + * @return a representation of the deferred computation of this call if successful. + */ + Observable executeAsync(); + } + } + + /** + * The entirety of train definition. + */ + interface KnowledgebasesTrainDefinition extends + KnowledgebasesTrainDefinitionStages.WithKbId, + KnowledgebasesTrainDefinitionStages.WithExecute { + } } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java index b03cd2879769b..c0004d48095aa 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java @@ -36,14 +36,14 @@ public interface QnAMakerClient { String userAgent(); /** - * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * Gets Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name >.api.cognitiveservices.azure.com).. * * @return the endpoint value. */ String endpoint(); /** - * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * Sets Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name >.api.cognitiveservices.azure.com).. * * @param endpoint the endpoint value. * @return the service client itself diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerManager.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerManager.java index 524e099c227bf..ebf613087d5ff 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerManager.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerManager.java @@ -27,7 +27,7 @@ public class QnAMakerManager { * @return the QnA Maker API client */ public static QnAMakerClient authenticate(String subscriptionKey) { - return authenticate("https://{Endpoint}/qnamaker/v4.0", subscriptionKey); + return authenticate("https://{Endpoint}/qnamaker/v5.0-preview.1", subscriptionKey); } /** @@ -67,7 +67,7 @@ public Response intercept(Chain chain) throws IOException { * @return the QnA Maker API client */ public static QnAMakerClient authenticate(ServiceClientCredentials credentials, String endpoint) { - return authenticate("https://{Endpoint}/qnamaker/v4.0", credentials) + return authenticate("https://{Endpoint}/qnamaker/v5.0-preview.1", credentials) .withEndpoint(endpoint); } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeClient.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeClient.java deleted file mode 100644 index b4278a21f52c1..0000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeClient.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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. - */ - -package com.microsoft.azure.cognitiveservices.knowledge.qnamaker; - -import com.microsoft.azure.AzureClient; -import com.microsoft.rest.RestClient; - -/** - * The interface for QnAMakerRuntimeClient class. - */ -public interface QnAMakerRuntimeClient { - /** - * Gets the REST client. - * - * @return the {@link RestClient} object. - */ - RestClient restClient(); - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - AzureClient getAzureClient(); - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - String userAgent(); - - /** - * Gets QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net).. - * - * @return the runtimeEndpoint value. - */ - String runtimeEndpoint(); - - /** - * Sets QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net).. - * - * @param runtimeEndpoint the runtimeEndpoint value. - * @return the service client itself - */ - QnAMakerRuntimeClient withRuntimeEndpoint(String runtimeEndpoint); - - /** - * Gets Gets or sets the preferred language for the response.. - * - * @return the acceptLanguage value. - */ - String acceptLanguage(); - - /** - * Sets Gets or sets the preferred language for the response.. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - QnAMakerRuntimeClient withAcceptLanguage(String acceptLanguage); - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @return the longRunningOperationRetryTimeout value. - */ - int longRunningOperationRetryTimeout(); - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - QnAMakerRuntimeClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @return the generateClientRequestId value. - */ - boolean generateClientRequestId(); - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - QnAMakerRuntimeClient withGenerateClientRequestId(boolean generateClientRequestId); - - /** - * Gets the Runtimes object to access its operations. - * @return the Runtimes object. - */ - Runtimes runtimes(); - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeManager.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeManager.java deleted file mode 100644 index 64900525a93ad..0000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerRuntimeManager.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - */ - -package com.microsoft.azure.cognitiveservices.knowledge.qnamaker; - -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.implementation.QnAMakerRuntimeClientImpl; -import com.microsoft.rest.RestClient; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; - -import java.io.IOException; - -/** - * Entry point to Azure Cognitive Services QnA Maker Runtime manager. - */ -public class QnAMakerRuntimeManager { - /** - * Initializes an instance of QnA Maker Runtime API client. - * - * @param subscriptionKey the QnA Maker Runtime API key - * @return the QnA Maker Runtime API client - */ - public static QnAMakerRuntimeClient authenticate(String subscriptionKey) { - return authenticate("https://{RuntimeEndpoint}/qnamaker", subscriptionKey); - } - - /** - * Initializes an instance of QnA Maker Runtime API client. - * - * @param baseUrl the base URL of the service - * @param subscriptionKey the QnA Maker Runtime API key - * @return the QnA Maker Runtime API client - */ - public static QnAMakerRuntimeClient authenticate(String baseUrl, final String subscriptionKey) { - ServiceClientCredentials serviceClientCredentials = new ServiceClientCredentials() { - @Override - public void applyCredentialsFilter(OkHttpClient.Builder builder) { - builder.addNetworkInterceptor( - new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - Request request = null; - Request original = chain.request(); - // Request customization: add request headers - Request.Builder requestBuilder = original.newBuilder() - .addHeader("Authorization", "EndpointKey " + subscriptionKey); - request = requestBuilder.build(); - return chain.proceed(request); - } - }); - } - }; - return authenticate(baseUrl, serviceClientCredentials); - } - - /** - * Initializes an instance of QnA Maker Runtime API client. - * - * @param credentials the management credentials for Azure - * @param endpoint Supported Cognitive Services endpoints. - * @return the QnA Maker Runtime API client - */ - public static QnAMakerRuntimeClient authenticate(ServiceClientCredentials credentials, String endpoint) { - return authenticate("https://{RuntimeEndpoint}/qnamaker", credentials) - .withRuntimeEndpoint(endpoint); - } - - /** - * Initializes an instance of QnA Maker Runtime API client. - * - * @param baseUrl the base URL of the service - * @param credentials the management credentials for Azure - * @return the QnA Maker Runtime API client - */ - public static QnAMakerRuntimeClient authenticate(String baseUrl, ServiceClientCredentials credentials) { - return new QnAMakerRuntimeClientImpl(baseUrl, credentials); - } - - /** - * Initializes an instance of QnA Maker Runtime API client. - * - * @param restClient the REST client to connect to Azure. - * @return the QnA Maker Runtime API client - */ - public static QnAMakerRuntimeClient authenticate(RestClient restClient) { - return new QnAMakerRuntimeClientImpl(restClient); - } -} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Runtimes.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Runtimes.java deleted file mode 100644 index 525d08febe615..0000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/Runtimes.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * 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. - */ - -package com.microsoft.azure.cognitiveservices.knowledge.qnamaker; - -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.TrainOptionalParameter; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultList; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QueryDTO; -import java.io.IOException; -import java.util.List; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Runtimes. - */ -public interface Runtimes { - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorResponseException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the QnASearchResultList object if successful. - */ - QnASearchResultList generateAnswer(String kbId, QueryDTO generateAnswerPayload); - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the QnASearchResultList object - */ - Observable generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload); - - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorResponseException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - void train(String kbId, TrainOptionalParameter trainOptionalParameter); - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. - */ - Observable trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter); - - /** - * Train call to add suggestions to the knowledgebase. - * - * @return the first stage of the train call - */ - RuntimesTrainDefinitionStages.WithKbId train(); - - /** - * Grouping of train definition stages. - */ - interface RuntimesTrainDefinitionStages { - /** - * The stage of the definition to be specify kbId. - */ - interface WithKbId { - /** - * Knowledgebase id. - * - * @return next definition stage - */ - RuntimesTrainDefinitionStages.WithExecute withKbId(String kbId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * List of feedback records. - * - * @return next definition stage - */ - RuntimesTrainDefinitionStages.WithExecute withFeedbackRecords(List feedbackRecords); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends RuntimesTrainDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); - - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } - - /** - * The entirety of train definition. - */ - interface RuntimesTrainDefinition extends - RuntimesTrainDefinitionStages.WithKbId, - RuntimesTrainDefinitionStages.WithExecute { - } - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/AlterationsImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/AlterationsImpl.java index befd34464d853..283e289a5aa3e 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/AlterationsImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/AlterationsImpl.java @@ -26,6 +26,7 @@ import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; +import retrofit2.http.Path; import retrofit2.http.PUT; import retrofit2.Response; import rx.functions.Func1; @@ -65,6 +66,14 @@ interface AlterationsService { @PUT("alterations") Observable> replace(@Header("accept-language") String acceptLanguage, @Body WordAlterationsDTO wordAlterations, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Alterations getAlterationsForKb" }) + @GET("alterations/{kbId}") + Observable> getAlterationsForKb(@Path("kbId") String kbId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Alterations replaceAlterationsForKb" }) + @PUT("alterations/{kbId}") + Observable> replaceAlterationsForKb(@Path("kbId") String kbId, @Header("accept-language") String acceptLanguage, @Body WordAlterationsDTO wordAlterations, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + } /** @@ -216,4 +225,167 @@ private ServiceResponse replaceDelegate(Response response) t .build(response); } + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the WordAlterationsDTO object if successful. + */ + public WordAlterationsDTO getAlterationsForKb(String kbId) { + return getAlterationsForKbWithServiceResponseAsync(kbId).toBlocking().single().body(); + } + + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAlterationsForKbAsync(String kbId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getAlterationsForKbWithServiceResponseAsync(kbId), serviceCallback); + } + + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the WordAlterationsDTO object + */ + public Observable getAlterationsForKbAsync(String kbId) { + return getAlterationsForKbWithServiceResponseAsync(kbId).map(new Func1, WordAlterationsDTO>() { + @Override + public WordAlterationsDTO call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Download alterations per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the WordAlterationsDTO object + */ + public Observable> getAlterationsForKbWithServiceResponseAsync(String kbId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getAlterationsForKb(kbId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getAlterationsForKbDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getAlterationsForKbDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void replaceAlterationsForKb(String kbId, List wordAlterations) { + replaceAlterationsForKbWithServiceResponseAsync(kbId, wordAlterations).toBlocking().single().body(); + } + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture replaceAlterationsForKbAsync(String kbId, List wordAlterations, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(replaceAlterationsForKbWithServiceResponseAsync(kbId, wordAlterations), serviceCallback); + } + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable replaceAlterationsForKbAsync(String kbId, List wordAlterations) { + return replaceAlterationsForKbWithServiceResponseAsync(kbId, wordAlterations).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Replace alterations data per Knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param wordAlterations Collection of word alterations. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> replaceAlterationsForKbWithServiceResponseAsync(String kbId, List wordAlterations) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + if (wordAlterations == null) { + throw new IllegalArgumentException("Parameter wordAlterations is required and cannot be null."); + } + Validator.validate(wordAlterations); + WordAlterationsDTO wordAlterations1 = new WordAlterationsDTO(); + wordAlterations1.withWordAlterations(wordAlterations); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.replaceAlterationsForKb(kbId, this.client.acceptLanguage(), wordAlterations1, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = replaceAlterationsForKbDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse replaceAlterationsForKbDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java index 43208396d0154..1879f81a3836d 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java @@ -145,10 +145,9 @@ private ServiceResponse getSettingsDelegate(Response updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter, final ServiceCallback serviceCallback) { + public ServiceFuture updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter, final ServiceCallback serviceCallback) { return ServiceFuture.fromResponse(updateSettingsWithServiceResponseAsync(updateSettingsOptionalParameter), serviceCallback); } @@ -168,12 +167,12 @@ public ServiceFuture updateSettingsAsync(UpdateSettingsOptionalParameter * * @param updateSettingsOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the String object + * @return the {@link ServiceResponse} object if successful. */ - public Observable updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter) { - return updateSettingsWithServiceResponseAsync(updateSettingsOptionalParameter).map(new Func1, String>() { + public Observable updateSettingsAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter) { + return updateSettingsWithServiceResponseAsync(updateSettingsOptionalParameter).map(new Func1, Void>() { @Override - public String call(ServiceResponse response) { + public Void call(ServiceResponse response) { return response.body(); } }); @@ -184,9 +183,9 @@ public String call(ServiceResponse response) { * * @param updateSettingsOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the String object + * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateSettingsWithServiceResponseAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter) { + public Observable> updateSettingsWithServiceResponseAsync(UpdateSettingsOptionalParameter updateSettingsOptionalParameter) { if (this.client.endpoint() == null) { throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } @@ -200,9 +199,9 @@ public Observable> updateSettingsWithServiceResponseAsyn * * @param activeLearning Active Learning settings of the endpoint. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the String object + * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateSettingsWithServiceResponseAsync(EndpointSettingsDTOActiveLearning activeLearning) { + public Observable> updateSettingsWithServiceResponseAsync(EndpointSettingsDTOActiveLearning activeLearning) { if (this.client.endpoint() == null) { throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } @@ -211,11 +210,11 @@ public Observable> updateSettingsWithServiceResponseAsyn endpointSettingsPayload.withActiveLearning(activeLearning); String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.updateSettings(this.client.acceptLanguage(), endpointSettingsPayload, parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = updateSettingsDelegate(response); + ServiceResponse clientResponse = updateSettingsDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -224,9 +223,9 @@ public Observable> call(Response response) }); } - private ServiceResponse updateSettingsDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateSettingsDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) .registerError(ErrorResponseException.class) .build(response); } @@ -258,15 +257,15 @@ public EndpointSettingsUpdateSettingsParameters withActiveLearning(EndpointSetti } @Override - public String execute() { - return updateSettingsWithServiceResponseAsync(activeLearning).toBlocking().single().body(); + public void execute() { + updateSettingsWithServiceResponseAsync(activeLearning).toBlocking().single().body(); } @Override - public Observable executeAsync() { - return updateSettingsWithServiceResponseAsync(activeLearning).map(new Func1, String>() { + public Observable executeAsync() { + return updateSettingsWithServiceResponseAsync(activeLearning).map(new Func1, Void>() { @Override - public String call(ServiceResponse response) { + public Void call(ServiceResponse response) { return response.body(); } }); diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/KnowledgebasesImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/KnowledgebasesImpl.java index d69791cf0a567..0bdec13e415b2 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/KnowledgebasesImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/KnowledgebasesImpl.java @@ -8,6 +8,8 @@ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.implementation; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.DownloadOptionalParameter; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.TrainOptionalParameter; import retrofit2.Retrofit; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Knowledgebases; import com.google.common.base.Joiner; @@ -15,12 +17,16 @@ import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.CreateKbDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EnvironmentType; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordsDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebaseDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebasesDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.KnowledgebaseUpdateHeaders; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.Operation; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnADocumentsDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnADTO; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultList; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QueryDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ReplaceKbDTO; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.UpdateKbOperationDTO; import com.microsoft.rest.ServiceCallback; @@ -40,6 +46,7 @@ import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; +import retrofit2.http.Query; import retrofit2.Response; import rx.functions.Func1; import rx.Observable; @@ -100,7 +107,15 @@ interface KnowledgebasesService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Knowledgebases download" }) @GET("knowledgebases/{kbId}/{environment}/qna") - Observable> download(@Path("kbId") String kbId, @Path("environment") EnvironmentType environment, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> download(@Path("kbId") String kbId, @Path("environment") EnvironmentType environment, @Query("source") String source, @Query("changedSince") String changedSince, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Knowledgebases generateAnswer" }) + @POST("knowledgebases/{kbId}/generateAnswer") + Observable> generateAnswer(@Path("kbId") String kbId, @Body QueryDTO generateAnswerPayload, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Knowledgebases train" }) + @POST("knowledgebases/{kbId}/train") + Observable> train(@Path("kbId") String kbId, @Header("accept-language") String acceptLanguage, @Body FeedbackRecordsDTO trainPayload, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } @@ -652,18 +667,20 @@ private ServiceResponse createDelegate(Response respons .build(response); } + /** * Download the knowledgebase. * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test' + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ErrorResponseException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the QnADocumentsDTO object if successful. */ - public QnADocumentsDTO download(String kbId, EnvironmentType environment) { - return downloadWithServiceResponseAsync(kbId, environment).toBlocking().single().body(); + public QnADocumentsDTO download(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter) { + return downloadWithServiceResponseAsync(kbId, environment, downloadOptionalParameter).toBlocking().single().body(); } /** @@ -671,12 +688,13 @@ public QnADocumentsDTO download(String kbId, EnvironmentType environment) { * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test' + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture downloadAsync(String kbId, EnvironmentType environment, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(downloadWithServiceResponseAsync(kbId, environment), serviceCallback); + public ServiceFuture downloadAsync(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(downloadWithServiceResponseAsync(kbId, environment, downloadOptionalParameter), serviceCallback); } /** @@ -684,11 +702,12 @@ public ServiceFuture downloadAsync(String kbId, EnvironmentType * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test' + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the QnADocumentsDTO object */ - public Observable downloadAsync(String kbId, EnvironmentType environment) { - return downloadWithServiceResponseAsync(kbId, environment).map(new Func1, QnADocumentsDTO>() { + public Observable downloadAsync(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter) { + return downloadWithServiceResponseAsync(kbId, environment, downloadOptionalParameter).map(new Func1, QnADocumentsDTO>() { @Override public QnADocumentsDTO call(ServiceResponse response) { return response.body(); @@ -701,10 +720,37 @@ public QnADocumentsDTO call(ServiceResponse response) { * * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test' + * @param downloadOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the QnADocumentsDTO object */ - public Observable> downloadWithServiceResponseAsync(String kbId, EnvironmentType environment) { + public Observable> downloadWithServiceResponseAsync(String kbId, EnvironmentType environment, DownloadOptionalParameter downloadOptionalParameter) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + if (environment == null) { + throw new IllegalArgumentException("Parameter environment is required and cannot be null."); + } + final String source = downloadOptionalParameter != null ? downloadOptionalParameter.source() : null; + final String changedSince = downloadOptionalParameter != null ? downloadOptionalParameter.changedSince() : null; + + return downloadWithServiceResponseAsync(kbId, environment, source, changedSince); + } + + /** + * Download the knowledgebase. + * + * @param kbId Knowledgebase id. + * @param environment Specifies whether environment is Test or Prod. Possible values include: 'Prod', 'Test' + * @param source The source property filter to apply. + * @param changedSince The last changed status property filter to apply. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QnADocumentsDTO object + */ + public Observable> downloadWithServiceResponseAsync(String kbId, EnvironmentType environment, String source, String changedSince) { if (this.client.endpoint() == null) { throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } @@ -715,7 +761,7 @@ public Observable> downloadWithServiceResponseA throw new IllegalArgumentException("Parameter environment is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); - return service.download(kbId, environment, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + return service.download(kbId, environment, source, changedSince, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -736,4 +782,305 @@ private ServiceResponse downloadDelegate(Response .build(response); } + @Override + public KnowledgebasesDownloadParameters download() { + return new KnowledgebasesDownloadParameters(this); + } + + /** + * Internal class implementing KnowledgebasesDownloadDefinition. + */ + class KnowledgebasesDownloadParameters implements KnowledgebasesDownloadDefinition { + private KnowledgebasesImpl parent; + private String kbId; + private EnvironmentType environment; + private String source; + private String changedSince; + + /** + * Constructor. + * @param parent the parent object. + */ + KnowledgebasesDownloadParameters(KnowledgebasesImpl parent) { + this.parent = parent; + } + + @Override + public KnowledgebasesDownloadParameters withKbId(String kbId) { + this.kbId = kbId; + return this; + } + + @Override + public KnowledgebasesDownloadParameters withEnvironment(EnvironmentType environment) { + this.environment = environment; + return this; + } + + @Override + public KnowledgebasesDownloadParameters withSource(String source) { + this.source = source; + return this; + } + + @Override + public KnowledgebasesDownloadParameters withChangedSince(String changedSince) { + this.changedSince = changedSince; + return this; + } + + @Override + public QnADocumentsDTO execute() { + return downloadWithServiceResponseAsync(kbId, environment, source, changedSince).toBlocking().single().body(); + } + + @Override + public Observable executeAsync() { + return downloadWithServiceResponseAsync(kbId, environment, source, changedSince).map(new Func1, QnADocumentsDTO>() { + @Override + public QnADocumentsDTO call(ServiceResponse response) { + return response.body(); + } + }); + } + } + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the QnASearchResultList object if successful. + */ + public QnASearchResultList generateAnswer(String kbId, QueryDTO generateAnswerPayload) { + return generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload).toBlocking().single().body(); + } + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload), serviceCallback); + } + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QnASearchResultList object + */ + public Observable generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload) { + return generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload).map(new Func1, QnASearchResultList>() { + @Override + public QnASearchResultList call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QnASearchResultList object + */ + public Observable> generateAnswerWithServiceResponseAsync(String kbId, QueryDTO generateAnswerPayload) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + if (generateAnswerPayload == null) { + throw new IllegalArgumentException("Parameter generateAnswerPayload is required and cannot be null."); + } + Validator.validate(generateAnswerPayload); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.generateAnswer(kbId, generateAnswerPayload, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = generateAnswerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse generateAnswerDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void train(String kbId, TrainOptionalParameter trainOptionalParameter) { + trainWithServiceResponseAsync(kbId, trainOptionalParameter).toBlocking().single().body(); + } + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(trainWithServiceResponseAsync(kbId, trainOptionalParameter), serviceCallback); + } + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter) { + return trainWithServiceResponseAsync(kbId, trainOptionalParameter).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> trainWithServiceResponseAsync(String kbId, TrainOptionalParameter trainOptionalParameter) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + final List feedbackRecords = trainOptionalParameter != null ? trainOptionalParameter.feedbackRecords() : null; + + return trainWithServiceResponseAsync(kbId, feedbackRecords); + } + + /** + * Train call to add suggestions to knowledgebase (QnAMaker Managed). + * + * @param kbId Knowledgebase id. + * @param feedbackRecords List of feedback records. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> trainWithServiceResponseAsync(String kbId, List feedbackRecords) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (kbId == null) { + throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); + } + Validator.validate(feedbackRecords); + FeedbackRecordsDTO trainPayload = new FeedbackRecordsDTO(); + trainPayload.withFeedbackRecords(feedbackRecords); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.train(kbId, this.client.acceptLanguage(), trainPayload, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = trainDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse trainDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(204, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + @Override + public KnowledgebasesTrainParameters train() { + return new KnowledgebasesTrainParameters(this); + } + + /** + * Internal class implementing KnowledgebasesTrainDefinition. + */ + class KnowledgebasesTrainParameters implements KnowledgebasesTrainDefinition { + private KnowledgebasesImpl parent; + private String kbId; + private List feedbackRecords; + + /** + * Constructor. + * @param parent the parent object. + */ + KnowledgebasesTrainParameters(KnowledgebasesImpl parent) { + this.parent = parent; + } + + @Override + public KnowledgebasesTrainParameters withKbId(String kbId) { + this.kbId = kbId; + return this; + } + + @Override + public KnowledgebasesTrainParameters withFeedbackRecords(List feedbackRecords) { + this.feedbackRecords = feedbackRecords; + return this; + } + + @Override + public void execute() { + trainWithServiceResponseAsync(kbId, feedbackRecords).toBlocking().single().body(); + } + + @Override + public Observable executeAsync() { + return trainWithServiceResponseAsync(kbId, feedbackRecords).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java index dcdc128b0fb09..65264a41b8698 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java @@ -34,11 +34,11 @@ public AzureClient getAzureClient() { return this.azureClient; } - /** Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). */ + /** Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name >.api.cognitiveservices.azure.com). */ private String endpoint; /** - * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * Gets Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name >.api.cognitiveservices.azure.com). * * @return the endpoint value. */ @@ -47,7 +47,7 @@ public String endpoint() { } /** - * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * Sets Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name >.api.cognitiveservices.azure.com). * * @param endpoint the endpoint value. * @return the service client itself @@ -197,7 +197,7 @@ public Operations operations() { * @param credentials the management credentials for Azure */ public QnAMakerClientImpl(ServiceClientCredentials credentials) { - this("https://{Endpoint}/qnamaker/v4.0", credentials); + this("https://{Endpoint}/qnamaker/v5.0-preview.1", credentials); } /** @@ -240,6 +240,6 @@ protected void initialize() { */ @Override public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "QnAMakerClient", "4.0"); + return String.format("%s (%s, %s)", super.userAgent(), "QnAMakerClient", "v5.0-preview.1"); } } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerRuntimeClientImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerRuntimeClientImpl.java deleted file mode 100644 index 68a86e944118b..0000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerRuntimeClientImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * 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. - */ - -package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.implementation; - -import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceClient; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.QnAMakerRuntimeClient; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Runtimes; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestClient; - -/** - * Initializes a new instance of the QnAMakerRuntimeClientImpl class. - */ -public class QnAMakerRuntimeClientImpl extends AzureServiceClient implements QnAMakerRuntimeClient { - /** the {@link AzureClient} used for long running operations. */ - private AzureClient azureClient; - - /** - * Gets the {@link AzureClient} used for long running operations. - * @return the azure client; - */ - public AzureClient getAzureClient() { - return this.azureClient; - } - - /** QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net). */ - private String runtimeEndpoint; - - /** - * Gets QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net). - * - * @return the runtimeEndpoint value. - */ - public String runtimeEndpoint() { - return this.runtimeEndpoint; - } - - /** - * Sets QnA Maker App Service endpoint (for example: https://{qnaservice-hostname}.azurewebsites.net). - * - * @param runtimeEndpoint the runtimeEndpoint value. - * @return the service client itself - */ - public QnAMakerRuntimeClientImpl withRuntimeEndpoint(String runtimeEndpoint) { - this.runtimeEndpoint = runtimeEndpoint; - return this; - } - - /** Gets or sets the preferred language for the response. */ - private String acceptLanguage; - - /** - * Gets Gets or sets the preferred language for the response. - * - * @return the acceptLanguage value. - */ - public String acceptLanguage() { - return this.acceptLanguage; - } - - /** - * Sets Gets or sets the preferred language for the response. - * - * @param acceptLanguage the acceptLanguage value. - * @return the service client itself - */ - public QnAMakerRuntimeClientImpl withAcceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return this; - } - - /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ - private int longRunningOperationRetryTimeout; - - /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @return the longRunningOperationRetryTimeout value. - */ - public int longRunningOperationRetryTimeout() { - return this.longRunningOperationRetryTimeout; - } - - /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. - * - * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. - * @return the service client itself - */ - public QnAMakerRuntimeClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { - this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; - return this; - } - - /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ - private boolean generateClientRequestId; - - /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @return the generateClientRequestId value. - */ - public boolean generateClientRequestId() { - return this.generateClientRequestId; - } - - /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. - * - * @param generateClientRequestId the generateClientRequestId value. - * @return the service client itself - */ - public QnAMakerRuntimeClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { - this.generateClientRequestId = generateClientRequestId; - return this; - } - - /** - * The Runtimes object to access its operations. - */ - private Runtimes runtimes; - - /** - * Gets the Runtimes object to access its operations. - * @return the Runtimes object. - */ - public Runtimes runtimes() { - return this.runtimes; - } - - /** - * Initializes an instance of QnAMakerRuntimeClient client. - * - * @param credentials the management credentials for Azure - */ - public QnAMakerRuntimeClientImpl(ServiceClientCredentials credentials) { - this("https://{RuntimeEndpoint}/qnamaker", credentials); - } - - /** - * Initializes an instance of QnAMakerRuntimeClient client. - * - * @param baseUrl the base URL of the host - * @param credentials the management credentials for Azure - */ - public QnAMakerRuntimeClientImpl(String baseUrl, ServiceClientCredentials credentials) { - super(baseUrl, credentials); - initialize(); - } - - /** - * Initializes an instance of QnAMakerRuntimeClient client. - * - * @param restClient the REST client to connect to Azure. - */ - public QnAMakerRuntimeClientImpl(RestClient restClient) { - super(restClient); - initialize(); - } - - protected void initialize() { - this.acceptLanguage = "en-US"; - this.longRunningOperationRetryTimeout = 30; - this.generateClientRequestId = true; - this.runtimes = new RuntimesImpl(restClient().retrofit(), this); - this.azureClient = new AzureClient(this); - } - - /** - * Gets the User-Agent header for the client. - * - * @return the user agent string. - */ - @Override - public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "QnAMakerRuntimeClient", "4.0"); - } -} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/RuntimesImpl.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/RuntimesImpl.java deleted file mode 100644 index ea3a678a18cae..0000000000000 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/RuntimesImpl.java +++ /dev/null @@ -1,311 +0,0 @@ -/** - * 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. - */ - -package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.implementation; - -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.TrainOptionalParameter; -import retrofit2.Retrofit; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Runtimes; -import com.google.common.base.Joiner; -import com.google.common.reflect.TypeToken; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordsDTO; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultList; -import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.QueryDTO; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceFuture; -import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.Validator; -import java.io.IOException; -import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.http.Body; -import retrofit2.http.Header; -import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.POST; -import retrofit2.Response; -import rx.functions.Func1; -import rx.Observable; - -/** - * An instance of this class provides access to all the operations defined - * in Runtimes. - */ -public class RuntimesImpl implements Runtimes { - /** The Retrofit service to perform REST calls. */ - private RuntimesService service; - /** The service client containing this operation class. */ - private QnAMakerRuntimeClientImpl client; - - /** - * Initializes an instance of RuntimesImpl. - * - * @param retrofit the Retrofit instance built from a Retrofit Builder. - * @param client the instance of the service client containing this operation class. - */ - public RuntimesImpl(Retrofit retrofit, QnAMakerRuntimeClientImpl client) { - this.service = retrofit.create(RuntimesService.class); - this.client = client; - } - - /** - * The interface defining all the services for Runtimes to be - * used by Retrofit to perform actually REST calls. - */ - interface RuntimesService { - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Runtimes generateAnswer" }) - @POST("knowledgebases/{kbId}/generateAnswer") - Observable> generateAnswer(@Path("kbId") String kbId, @Body QueryDTO generateAnswerPayload, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Runtimes train" }) - @POST("knowledgebases/{kbId}/train") - Observable> train(@Path("kbId") String kbId, @Header("accept-language") String acceptLanguage, @Body FeedbackRecordsDTO trainPayload, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - - } - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorResponseException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the QnASearchResultList object if successful. - */ - public QnASearchResultList generateAnswer(String kbId, QueryDTO generateAnswerPayload) { - return generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload).toBlocking().single().body(); - } - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload), serviceCallback); - } - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the QnASearchResultList object - */ - public Observable generateAnswerAsync(String kbId, QueryDTO generateAnswerPayload) { - return generateAnswerWithServiceResponseAsync(kbId, generateAnswerPayload).map(new Func1, QnASearchResultList>() { - @Override - public QnASearchResultList call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * GenerateAnswer call to query the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the QnASearchResultList object - */ - public Observable> generateAnswerWithServiceResponseAsync(String kbId, QueryDTO generateAnswerPayload) { - if (this.client.runtimeEndpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.runtimeEndpoint() is required and cannot be null."); - } - if (kbId == null) { - throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); - } - if (generateAnswerPayload == null) { - throw new IllegalArgumentException("Parameter generateAnswerPayload is required and cannot be null."); - } - Validator.validate(generateAnswerPayload); - String parameterizedHost = Joiner.on(", ").join("{RuntimeEndpoint}", this.client.runtimeEndpoint()); - return service.generateAnswer(kbId, generateAnswerPayload, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = generateAnswerDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse generateAnswerDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(ErrorResponseException.class) - .build(response); - } - - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @throws IllegalArgumentException thrown if parameters fail the validation - * @throws ErrorResponseException thrown if the request is rejected by server - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - */ - public void train(String kbId, TrainOptionalParameter trainOptionalParameter) { - trainWithServiceResponseAsync(kbId, trainOptionalParameter).toBlocking().single().body(); - } - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceFuture} object - */ - public ServiceFuture trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(trainWithServiceResponseAsync(kbId, trainOptionalParameter), serviceCallback); - } - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable trainAsync(String kbId, TrainOptionalParameter trainOptionalParameter) { - return trainWithServiceResponseAsync(kbId, trainOptionalParameter).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param trainOptionalParameter the object representing the optional parameters to be set before calling this API - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> trainWithServiceResponseAsync(String kbId, TrainOptionalParameter trainOptionalParameter) { - if (this.client.runtimeEndpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.runtimeEndpoint() is required and cannot be null."); - } - if (kbId == null) { - throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); - } - final List feedbackRecords = trainOptionalParameter != null ? trainOptionalParameter.feedbackRecords() : null; - - return trainWithServiceResponseAsync(kbId, feedbackRecords); - } - - /** - * Train call to add suggestions to the knowledgebase. - * - * @param kbId Knowledgebase id. - * @param feedbackRecords List of feedback records. - * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> trainWithServiceResponseAsync(String kbId, List feedbackRecords) { - if (this.client.runtimeEndpoint() == null) { - throw new IllegalArgumentException("Parameter this.client.runtimeEndpoint() is required and cannot be null."); - } - if (kbId == null) { - throw new IllegalArgumentException("Parameter kbId is required and cannot be null."); - } - Validator.validate(feedbackRecords); - FeedbackRecordsDTO trainPayload = new FeedbackRecordsDTO(); - trainPayload.withFeedbackRecords(feedbackRecords); - String parameterizedHost = Joiner.on(", ").join("{RuntimeEndpoint}", this.client.runtimeEndpoint()); - return service.train(kbId, this.client.acceptLanguage(), trainPayload, parameterizedHost, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = trainDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse trainDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { - return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) - .register(204, new TypeToken() { }.getType()) - .registerError(ErrorResponseException.class) - .build(response); - } - - @Override - public RuntimesTrainParameters train() { - return new RuntimesTrainParameters(this); - } - - /** - * Internal class implementing RuntimesTrainDefinition. - */ - class RuntimesTrainParameters implements RuntimesTrainDefinition { - private RuntimesImpl parent; - private String kbId; - private List feedbackRecords; - - /** - * Constructor. - * @param parent the parent object. - */ - RuntimesTrainParameters(RuntimesImpl parent) { - this.parent = parent; - } - - @Override - public RuntimesTrainParameters withKbId(String kbId) { - this.kbId = kbId; - return this; - } - - @Override - public RuntimesTrainParameters withFeedbackRecords(List feedbackRecords) { - this.feedbackRecords = feedbackRecords; - return this; - } - - @Override - public void execute() { - trainWithServiceResponseAsync(kbId, feedbackRecords).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return trainWithServiceResponseAsync(kbId, feedbackRecords).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - -} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/package-info.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/package-info.java index e83ba0e3df813..9a1079b4bf859 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/package-info.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the implementation classes for QnAMakerRuntimeClient. - * An API for QnAMaker runtime. + * This package contains the implementation classes for QnAMakerClient. + * An API for QnAMaker Service. */ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.implementation; diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanRequestDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanRequestDTO.java new file mode 100644 index 0000000000000..34911712081c4 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanRequestDTO.java @@ -0,0 +1,95 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * To configure Answer span prediction feature. + */ +public class AnswerSpanRequestDTO { + /** + * Enable or Disable Answer Span prediction. + */ + @JsonProperty(value = "enable") + private Boolean enable; + + /** + * Minimum threshold score required to include an answer span. + */ + @JsonProperty(value = "scoreThreshold") + private Double scoreThreshold; + + /** + * Number of Top answers to be considered for span prediction. + */ + @JsonProperty(value = "topAnswersWithSpan") + private Integer topAnswersWithSpan; + + /** + * Get the enable value. + * + * @return the enable value + */ + public Boolean enable() { + return this.enable; + } + + /** + * Set the enable value. + * + * @param enable the enable value to set + * @return the AnswerSpanRequestDTO object itself. + */ + public AnswerSpanRequestDTO withEnable(Boolean enable) { + this.enable = enable; + return this; + } + + /** + * Get the scoreThreshold value. + * + * @return the scoreThreshold value + */ + public Double scoreThreshold() { + return this.scoreThreshold; + } + + /** + * Set the scoreThreshold value. + * + * @param scoreThreshold the scoreThreshold value to set + * @return the AnswerSpanRequestDTO object itself. + */ + public AnswerSpanRequestDTO withScoreThreshold(Double scoreThreshold) { + this.scoreThreshold = scoreThreshold; + return this; + } + + /** + * Get the topAnswersWithSpan value. + * + * @return the topAnswersWithSpan value + */ + public Integer topAnswersWithSpan() { + return this.topAnswersWithSpan; + } + + /** + * Set the topAnswersWithSpan value. + * + * @param topAnswersWithSpan the topAnswersWithSpan value to set + * @return the AnswerSpanRequestDTO object itself. + */ + public AnswerSpanRequestDTO withTopAnswersWithSpan(Integer topAnswersWithSpan) { + this.topAnswersWithSpan = topAnswersWithSpan; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanResponseDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanResponseDTO.java new file mode 100644 index 0000000000000..9bd74a36fb9b2 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/AnswerSpanResponseDTO.java @@ -0,0 +1,121 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Answer span object of QnA. + */ +public class AnswerSpanResponseDTO { + /** + * Predicted text of answer span. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Predicted score of answer span. + */ + @JsonProperty(value = "score") + private Double score; + + /** + * Start index of answer span in answer. + */ + @JsonProperty(value = "startIndex") + private Integer startIndex; + + /** + * End index of answer span in answer. + */ + @JsonProperty(value = "endIndex") + private Integer endIndex; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the AnswerSpanResponseDTO object itself. + */ + public AnswerSpanResponseDTO withText(String text) { + this.text = text; + return this; + } + + /** + * Get the score value. + * + * @return the score value + */ + public Double score() { + return this.score; + } + + /** + * Set the score value. + * + * @param score the score value to set + * @return the AnswerSpanResponseDTO object itself. + */ + public AnswerSpanResponseDTO withScore(Double score) { + this.score = score; + return this; + } + + /** + * Get the startIndex value. + * + * @return the startIndex value + */ + public Integer startIndex() { + return this.startIndex; + } + + /** + * Set the startIndex value. + * + * @param startIndex the startIndex value to set + * @return the AnswerSpanResponseDTO object itself. + */ + public AnswerSpanResponseDTO withStartIndex(Integer startIndex) { + this.startIndex = startIndex; + return this; + } + + /** + * Get the endIndex value. + * + * @return the endIndex value + */ + public Integer endIndex() { + return this.endIndex; + } + + /** + * Set the endIndex value. + * + * @param endIndex the endIndex value to set + * @return the AnswerSpanResponseDTO object itself. + */ + public AnswerSpanResponseDTO withEndIndex(Integer endIndex) { + this.endIndex = endIndex; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/CreateKbDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/CreateKbDTO.java index 22567df6fbff2..6913669276577 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/CreateKbDTO.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/CreateKbDTO.java @@ -56,11 +56,27 @@ public class CreateKbDTO { private String defaultAnswerUsedForExtraction; /** - * Language of the knowledgebase. + * Language of the knowledgebase. Please find the list of supported + * languages <a + * href="https://aka.ms/qnamaker-languages#languages-supported" + * target="_blank">here</a>. */ @JsonProperty(value = "language") private String language; + /** + * Set to true to enable creating KBs in different languages for the same + * resource. + */ + @JsonProperty(value = "enableMultipleLanguages") + private Boolean enableMultipleLanguages; + + /** + * Default answer sent to user if no good match is found in the KB. + */ + @JsonProperty(value = "defaultAnswer") + private String defaultAnswer; + /** * Get the name value. * @@ -201,4 +217,44 @@ public CreateKbDTO withLanguage(String language) { return this; } + /** + * Get the enableMultipleLanguages value. + * + * @return the enableMultipleLanguages value + */ + public Boolean enableMultipleLanguages() { + return this.enableMultipleLanguages; + } + + /** + * Set the enableMultipleLanguages value. + * + * @param enableMultipleLanguages the enableMultipleLanguages value to set + * @return the CreateKbDTO object itself. + */ + public CreateKbDTO withEnableMultipleLanguages(Boolean enableMultipleLanguages) { + this.enableMultipleLanguages = enableMultipleLanguages; + return this; + } + + /** + * Get the defaultAnswer value. + * + * @return the defaultAnswer value + */ + public String defaultAnswer() { + return this.defaultAnswer; + } + + /** + * Set the defaultAnswer value. + * + * @param defaultAnswer the defaultAnswer value to set + * @return the CreateKbDTO object itself. + */ + public CreateKbDTO withDefaultAnswer(String defaultAnswer) { + this.defaultAnswer = defaultAnswer; + return this; + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/DownloadOptionalParameter.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/DownloadOptionalParameter.java new file mode 100644 index 0000000000000..c1a030ece9ffa --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/DownloadOptionalParameter.java @@ -0,0 +1,91 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + + +/** + * The DownloadOptionalParameter model. + */ +public class DownloadOptionalParameter { + /** + * The source property filter to apply. + */ + private String source; + + /** + * The last changed status property filter to apply. + */ + private String changedSince; + + /** + * Gets or sets the preferred language for the response. + */ + private String thisclientacceptLanguage; + + /** + * Get the source value. + * + * @return the source value + */ + public String source() { + return this.source; + } + + /** + * Set the source value. + * + * @param source the source value to set + * @return the DownloadOptionalParameter object itself. + */ + public DownloadOptionalParameter withSource(String source) { + this.source = source; + return this; + } + + /** + * Get the changedSince value. + * + * @return the changedSince value + */ + public String changedSince() { + return this.changedSince; + } + + /** + * Set the changedSince value. + * + * @param changedSince the changedSince value to set + * @return the DownloadOptionalParameter object itself. + */ + public DownloadOptionalParameter withChangedSince(String changedSince) { + this.changedSince = changedSince; + return this; + } + + /** + * Get the thisclientacceptLanguage value. + * + * @return the thisclientacceptLanguage value + */ + public String thisclientacceptLanguage() { + return this.thisclientacceptLanguage; + } + + /** + * Set the thisclientacceptLanguage value. + * + * @param thisclientacceptLanguage the thisclientacceptLanguage value to set + * @return the DownloadOptionalParameter object itself. + */ + public DownloadOptionalParameter withThisclientacceptLanguage(String thisclientacceptLanguage) { + this.thisclientacceptLanguage = thisclientacceptLanguage; + return this; + } + +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnADTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnADTO.java index 12b51ec828db3..3e4e4246118bc 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnADTO.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnADTO.java @@ -52,6 +52,12 @@ public class QnADTO { @JsonProperty(value = "context") private QnADTOContext context; + /** + * Timestamp when the QnA was last updated. + */ + @JsonProperty(value = "lastUpdatedTimestamp") + private String lastUpdatedTimestamp; + /** * Get the id value. * @@ -172,4 +178,24 @@ public QnADTO withContext(QnADTOContext context) { return this; } + /** + * Get the lastUpdatedTimestamp value. + * + * @return the lastUpdatedTimestamp value + */ + public String lastUpdatedTimestamp() { + return this.lastUpdatedTimestamp; + } + + /** + * Set the lastUpdatedTimestamp value. + * + * @param lastUpdatedTimestamp the lastUpdatedTimestamp value to set + * @return the QnADTO object itself. + */ + public QnADTO withLastUpdatedTimestamp(String lastUpdatedTimestamp) { + this.lastUpdatedTimestamp = lastUpdatedTimestamp; + return this; + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResult.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResult.java index a80c7092d3b73..72e709cd8caa2 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResult.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResult.java @@ -57,6 +57,12 @@ public class QnASearchResult { @JsonProperty(value = "context") private QnASearchResultContext context; + /** + * Answer span object of QnA with respect to user's question. + */ + @JsonProperty(value = "answerSpan") + private QnASearchResultAnswerSpan answerSpan; + /** * Get the questions value. * @@ -197,4 +203,24 @@ public QnASearchResult withContext(QnASearchResultContext context) { return this; } + /** + * Get the answerSpan value. + * + * @return the answerSpan value + */ + public QnASearchResultAnswerSpan answerSpan() { + return this.answerSpan; + } + + /** + * Set the answerSpan value. + * + * @param answerSpan the answerSpan value to set + * @return the QnASearchResult object itself. + */ + public QnASearchResult withAnswerSpan(QnASearchResultAnswerSpan answerSpan) { + this.answerSpan = answerSpan; + return this; + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResultAnswerSpan.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResultAnswerSpan.java new file mode 100644 index 0000000000000..b65603261a26a --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QnASearchResultAnswerSpan.java @@ -0,0 +1,16 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + + +/** + * Answer span object of QnA with respect to user's question. + */ +public class QnASearchResultAnswerSpan extends AnswerSpanResponseDTO { +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryContextDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryContextDTO.java index 4198cef140326..c99aa2cde7dc5 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryContextDTO.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryContextDTO.java @@ -18,7 +18,7 @@ public class QueryContextDTO { * Previous QnA Id - qnaId of the top result. */ @JsonProperty(value = "previousQnaId") - private String previousQnaId; + private Integer previousQnaId; /** * Previous user query. @@ -31,7 +31,7 @@ public class QueryContextDTO { * * @return the previousQnaId value */ - public String previousQnaId() { + public Integer previousQnaId() { return this.previousQnaId; } @@ -41,7 +41,7 @@ public String previousQnaId() { * @param previousQnaId the previousQnaId value to set * @return the QueryContextDTO object itself. */ - public QueryContextDTO withPreviousQnaId(String previousQnaId) { + public QueryContextDTO withPreviousQnaId(Integer previousQnaId) { this.previousQnaId = previousQnaId; return this; } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTO.java index a0ef2c71bd4c2..9f1e7b5a4c450 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTO.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTO.java @@ -47,7 +47,7 @@ public class QueryDTO { private Boolean isTest; /** - * Threshold for answers returned based on score. + * Minimum threshold score for answers. */ @JsonProperty(value = "scoreThreshold") private Double scoreThreshold; @@ -65,11 +65,24 @@ public class QueryDTO { private String rankerType; /** - * Find only answers that contain these metadata. + * Find QnAs that are associated with the given list of metadata. */ @JsonProperty(value = "strictFilters") private List strictFilters; + /** + * Optional field. Set to 'OR' for using OR operation for strict filters. + * Possible values include: 'AND', 'OR'. + */ + @JsonProperty(value = "strictFiltersCompoundOperationType") + private StrictFiltersCompoundOperationType strictFiltersCompoundOperationType; + + /** + * To configure Answer span prediction feature. + */ + @JsonProperty(value = "answerSpanRequest") + private QueryDTOAnswerSpanRequest answerSpanRequest; + /** * Get the qnaId value. * @@ -250,4 +263,44 @@ public QueryDTO withStrictFilters(List strictFilters) { return this; } + /** + * Get the strictFiltersCompoundOperationType value. + * + * @return the strictFiltersCompoundOperationType value + */ + public StrictFiltersCompoundOperationType strictFiltersCompoundOperationType() { + return this.strictFiltersCompoundOperationType; + } + + /** + * Set the strictFiltersCompoundOperationType value. + * + * @param strictFiltersCompoundOperationType the strictFiltersCompoundOperationType value to set + * @return the QueryDTO object itself. + */ + public QueryDTO withStrictFiltersCompoundOperationType(StrictFiltersCompoundOperationType strictFiltersCompoundOperationType) { + this.strictFiltersCompoundOperationType = strictFiltersCompoundOperationType; + return this; + } + + /** + * Get the answerSpanRequest value. + * + * @return the answerSpanRequest value + */ + public QueryDTOAnswerSpanRequest answerSpanRequest() { + return this.answerSpanRequest; + } + + /** + * Set the answerSpanRequest value. + * + * @param answerSpanRequest the answerSpanRequest value to set + * @return the QueryDTO object itself. + */ + public QueryDTO withAnswerSpanRequest(QueryDTOAnswerSpanRequest answerSpanRequest) { + this.answerSpanRequest = answerSpanRequest; + return this; + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTOAnswerSpanRequest.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTOAnswerSpanRequest.java new file mode 100644 index 0000000000000..651327630f050 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/QueryDTOAnswerSpanRequest.java @@ -0,0 +1,16 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + + +/** + * To configure Answer span prediction feature. + */ +public class QueryDTOAnswerSpanRequest extends AnswerSpanRequestDTO { +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/StrictFiltersCompoundOperationType.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/StrictFiltersCompoundOperationType.java new file mode 100644 index 0000000000000..bd0f0c6480dd7 --- /dev/null +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/StrictFiltersCompoundOperationType.java @@ -0,0 +1,41 @@ +/** + * 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. + */ + +package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for StrictFiltersCompoundOperationType. + */ +public final class StrictFiltersCompoundOperationType extends ExpandableStringEnum { + /** Static value AND for StrictFiltersCompoundOperationType. */ + public static final StrictFiltersCompoundOperationType AND = fromString("AND"); + + /** Static value OR for StrictFiltersCompoundOperationType. */ + public static final StrictFiltersCompoundOperationType OR = fromString("OR"); + + /** + * Creates or finds a StrictFiltersCompoundOperationType from its string representation. + * @param name a name to look for + * @return the corresponding StrictFiltersCompoundOperationType + */ + @JsonCreator + public static StrictFiltersCompoundOperationType fromString(String name) { + return fromString(name, StrictFiltersCompoundOperationType.class); + } + + /** + * @return known StrictFiltersCompoundOperationType values + */ + public static Collection values() { + return values(StrictFiltersCompoundOperationType.class); + } +} diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/UpdateKbContentsDTO.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/UpdateKbContentsDTO.java index d05d4089e824a..92e3c026ff275 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/UpdateKbContentsDTO.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/UpdateKbContentsDTO.java @@ -34,6 +34,12 @@ public class UpdateKbContentsDTO { @JsonProperty(value = "urls") private List urls; + /** + * Default answer sent to user if no good match is found in the KB. + */ + @JsonProperty(value = "defaultAnswer") + private String defaultAnswer; + /** * Get the name value. * @@ -94,4 +100,24 @@ public UpdateKbContentsDTO withUrls(List urls) { return this; } + /** + * Get the defaultAnswer value. + * + * @return the defaultAnswer value + */ + public String defaultAnswer() { + return this.defaultAnswer; + } + + /** + * Set the defaultAnswer value. + * + * @param defaultAnswer the defaultAnswer value to set + * @return the UpdateKbContentsDTO object itself. + */ + public UpdateKbContentsDTO withDefaultAnswer(String defaultAnswer) { + this.defaultAnswer = defaultAnswer; + return this; + } + } diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/package-info.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/package-info.java index 100ce321977aa..e6a75733fa37f 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/package-info.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the models classes for QnAMakerRuntimeClient. - * An API for QnAMaker runtime. + * This package contains the models classes for QnAMakerClient. + * An API for QnAMaker Service. */ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models; diff --git a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/package-info.java b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/package-info.java index 3d3345e1812e2..3fb934d575e85 100644 --- a/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/package-info.java +++ b/sdk/cognitiveservices/ms-azure-cs-qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the classes for QnAMakerRuntimeClient. - * An API for QnAMaker runtime. + * This package contains the classes for QnAMakerClient. + * An API for QnAMaker Service. */ package com.microsoft.azure.cognitiveservices.knowledge.qnamaker;