diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md index 824eba6f559d..a0315c545ada 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md @@ -1,7 +1,6 @@ ## An isomorphic javascript sdk for - QnAMakerClient -This package contains an isomorphic SDK for editing and creating Knowledge Bases, its endpoints and keys. -For interacting with QnAMaker such as training and asking questions please see @azure/cognitiveservices-qnamaker-runtime. +This package contains an isomorphic SDK for QnAMakerClient. ### Currently supported environments @@ -18,31 +17,30 @@ npm install @azure/cognitiveservices-qnamaker #### nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript. -##### Install @azure/ms-rest-azure-js +##### Install @azure/ms-rest-nodeauth +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/ms-rest-nodeauth@"^3.0.0" ``` ##### Sample code -```javascript -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); -const { QnAMakerClient } = require("@azure/cognitiveservices-qnamaker"); - -async function main() { - const QNAMAKER_KEY = process.env["QNAMAKER_KEY"] || ""; - const QNAMAKER_ENDPOINT = process.env["QNAMAKER_ENDPOINT"] || ""; - - const cognitiveServicesCredentials = new CognitiveServicesCredentials(QNAMAKER_KEY); - const client = new QnAMakerClient(cognitiveServicesCredentials, QNAMAKER_ENDPOINT); - - const settings = await client.endpointSettings.getSettings(); - - console.log(`The result is: ${JSON.stringify(settings)}`); -} - -main(); +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { QnAMakerClient, QnAMakerModels, QnAMakerMappers } from "@azure/cognitiveservices-qnamaker"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new QnAMakerClient(creds, subscriptionId); + client.endpointSettings.getSettings().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); ``` #### browser - Authentication, client creation and getSettings endpointSettings as an example written in JavaScript. @@ -58,34 +56,34 @@ npm install @azure/ms-rest-browserauth See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - index.html - ```html @azure/cognitiveservices-qnamaker sample + @@ -96,4 +94,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/README.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-qnamaker/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/LICENSE.txt b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/LICENSE.txt new file mode 100644 index 000000000000..ea8fb1516028 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/README.md b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/README.md new file mode 100644 index 000000000000..7de9f7ccff10 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/README.md @@ -0,0 +1,97 @@ +## An isomorphic javascript sdk for - QnAMakerClient + +This package contains an isomorphic SDK for QnAMakerClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/cognitiveservices-qnamaker +``` + +### How to use + +#### nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. +```bash +npm install @azure/ms-rest-nodeauth@"^3.0.0" +``` + +##### Sample code + +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { QnAMakerClient, QnAMakerModels, QnAMakerMappers } from "@azure/cognitiveservices-qnamaker"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new QnAMakerClient(creds, subscriptionId); + client.endpointSettings.getSettings().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and getSettings endpointSettings as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` + +##### Sample code + +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + +- index.html +```html + + + + @azure/cognitiveservices-qnamaker sample + + + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/package.json b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/package.json new file mode 100644 index 000000000000..2cac394749d3 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/package.json @@ -0,0 +1,57 @@ +{ + "name": "@azure/cognitiveservices-qnamaker", + "author": "Microsoft Corporation", + "description": "QnAMakerClient Library with typescript type definitions for node.js and browser.", + "version": "3.1.1", + "dependencies": { + "@azure/ms-rest-js": "^2.0.4", + "tslib": "^1.10.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/cognitiveservices-qnamaker.js", + "module": "./esm/qnAMakerClient.js", + "types": "./esm/qnAMakerClient.d.ts", + "devDependencies": { + "typescript": "^3.5.3", + "rollup": "^1.18.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.6.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-qnamaker/preview", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-qnamaker.js.map'\" -o ./dist/cognitiveservices-qnamaker.min.js ./dist/cognitiveservices-qnamaker.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/rollup.config.js new file mode 100644 index 000000000000..aa740262d6cc --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/rollup.config.js @@ -0,0 +1,37 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/qnAMakerClient.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/cognitiveservices-qnamaker.js", + format: "umd", + name: "Azure.CognitiveservicesQnamaker", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */` + }, + plugins: [ + nodeResolve({ mainFields: ['module', 'main'] }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/alterationsMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/alterationsMappers.ts new file mode 100644 index 000000000000..bb61c2cf1a47 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/alterationsMappers.ts @@ -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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + AlterationsDTO, + ErrorModel, + ErrorResponse, + ErrorResponseError, + InnerErrorModel, + WordAlterationsDTO +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointKeysMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointKeysMappers.ts new file mode 100644 index 000000000000..b236c184044f --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointKeysMappers.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + EndpointKeysDTO, + ErrorModel, + ErrorResponse, + ErrorResponseError, + InnerErrorModel +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointSettingsMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointSettingsMappers.ts new file mode 100644 index 000000000000..41a5e8575e4f --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/endpointSettingsMappers.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ActiveLearningSettingsDTO, + EndpointSettingsDTO, + EndpointSettingsDTOActiveLearning, + ErrorModel, + ErrorResponse, + ErrorResponseError, + InnerErrorModel +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/index.ts new file mode 100644 index 000000000000..21fb89c5a6b4 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/index.ts @@ -0,0 +1,1121 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + + +import * as msRest from "@azure/ms-rest-js"; + +/** + * Input to create KB. + */ +export interface CreateKbInputDTO { + /** + * List of QNA to be added to the index. Ids are generated by the service and should be omitted. + */ + qnaList?: QnADTO[]; + /** + * List of URLs to be added to knowledgebase. + */ + urls?: string[]; + /** + * List of files to be added to knowledgebase. + */ + files?: FileDTO[]; +} + +/** + * An instance of CreateKbInputDTO for add operation + */ +export interface UpdateKbOperationDTOAdd extends CreateKbInputDTO { +} + +/** + * PATCH body schema of Delete Operation in UpdateKb + */ +export interface DeleteKbContentsDTO { + /** + * List of Qna Ids to be deleted + */ + ids?: number[]; + /** + * List of sources to be deleted from knowledgebase. + */ + sources?: string[]; +} + +/** + * An instance of DeleteKbContentsDTO for delete Operation + */ +export interface UpdateKbOperationDTODelete extends DeleteKbContentsDTO { +} + +/** + * PATCH body schema for Update operation in Update Kb + */ +export interface UpdateKbContentsDTO { + /** + * Friendly name for the knowledgebase. + */ + name?: string; + /** + * List of Q-A (UpdateQnaDTO) to be added to the knowledgebase. + */ + qnaList?: UpdateQnaDTO[]; + /** + * List of existing URLs to be refreshed. The content will be extracted again and re-indexed. + */ + urls?: string[]; +} + +/** + * An instance of UpdateKbContentsDTO for Update Operation + */ +export interface UpdateKbOperationDTOUpdate extends UpdateKbContentsDTO { +} + +/** + * Contains list of QnAs to be updated + */ +export interface UpdateKbOperationDTO { + /** + * An instance of CreateKbInputDTO for add operation + */ + add?: UpdateKbOperationDTOAdd; + /** + * An instance of DeleteKbContentsDTO for delete Operation + */ + deleteProperty?: UpdateKbOperationDTODelete; + /** + * An instance of UpdateKbContentsDTO for Update Operation + */ + update?: UpdateKbOperationDTOUpdate; + /** + * Enable hierarchical extraction of Q-A from files and urls. The value set during KB creation + * will be used if this field is not present. + */ + enableHierarchicalExtraction?: boolean; + /** + * Text string to be used as the answer in any Q-A which has no extracted answer from the + * document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. + */ + defaultAnswerUsedForExtraction?: string; +} + +/** + * PATCH Body schema for Update Kb which contains list of questions to be added and deleted + */ +export interface UpdateQuestionsDTO { + /** + * List of questions to be added + */ + add?: string[]; + /** + * List of questions to be deleted. + */ + deleteProperty?: string[]; +} + +/** + * List of questions associated with the answer. + */ +export interface UpdateQnaDTOQuestions extends UpdateQuestionsDTO { +} + +/** + * PATCH Body schema to represent list of Metadata to be updated + */ +export interface UpdateMetadataDTO { + /** + * List of Metadata associated with answer to be deleted + */ + deleteProperty?: MetadataDTO[]; + /** + * List of metadata associated with answer to be added + */ + add?: MetadataDTO[]; +} + +/** + * List of metadata associated with the answer to be updated + */ +export interface UpdateQnaDTOMetadata extends UpdateMetadataDTO { +} + +/** + * Update Body schema to represent context to be updated + */ +export interface UpdateContextDTO { + /** + * List of prompts associated with qna to be deleted + */ + promptsToDelete?: number[]; + /** + * List of prompts to be added to the qna. + */ + promptsToAdd?: PromptDTO[]; + /** + * To mark if a prompt is relevant only with a previous question or not. + * true - Do not include this QnA as search result for queries without context + * false - ignores context and includes this QnA in search result + */ + isContextOnly?: boolean; +} + +/** + * Context associated with Qna to be updated. + */ +export interface UpdateQnaDTOContext extends UpdateContextDTO { +} + +/** + * PATCH Body schema for Update Qna List + */ +export interface UpdateQnaDTO { + /** + * Unique id for the Q-A + */ + id?: number; + /** + * Answer text + */ + answer?: string; + /** + * Source from which Q-A was indexed. eg. + * https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + */ + source?: string; + /** + * List of questions associated with the answer. + */ + questions?: UpdateQnaDTOQuestions; + /** + * List of metadata associated with the answer to be updated + */ + metadata?: UpdateQnaDTOMetadata; + /** + * Context associated with Qna to be updated. + */ + context?: UpdateQnaDTOContext; +} + +/** + * Name - value pair of metadata. + */ +export interface MetadataDTO { + /** + * Metadata name. + */ + name: string; + /** + * Metadata value. + */ + value: string; +} + +/** + * Q-A object. + */ +export interface QnADTO { + /** + * Unique id for the Q-A. + */ + id?: number; + /** + * Answer text + */ + answer: string; + /** + * Source from which Q-A was indexed. eg. + * https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + */ + source?: string; + /** + * List of questions associated with the answer. + */ + questions: string[]; + /** + * List of metadata associated with the answer. + */ + metadata?: MetadataDTO[]; + /** + * Context of a QnA + */ + context?: QnADTOContext; + /** + * Timestamp when the QnA was last updated. + */ + lastUpdatedTimestamp?: string; +} + +/** + * QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object + */ +export interface PromptDTOQna extends QnADTO { +} + +/** + * Prompt for an answer. + */ +export interface PromptDTO { + /** + * Index of the prompt - used in ordering of the prompts + */ + displayOrder?: number; + /** + * Qna id corresponding to the prompt - if QnaId is present, QnADTO object is ignored. + */ + qnaId?: number; + /** + * QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object + */ + qna?: PromptDTOQna; + /** + * Text displayed to represent a follow up question prompt + */ + displayText?: string; +} + +/** + * Context associated with Qna. + */ +export interface ContextDTO { + /** + * To mark if a prompt is relevant only with a previous question or not. + * true - Do not include this QnA as search result for queries without context + * false - ignores context and includes this QnA in search result + */ + isContextOnly?: boolean; + /** + * List of prompts associated with the answer. + */ + prompts?: PromptDTO[]; +} + +/** + * Context of a QnA + */ +export interface QnADTOContext extends ContextDTO { +} + +/** + * DTO to hold details of uploaded files. + */ +export interface FileDTO { + /** + * File name. Supported file types are ".tsv", ".pdf", ".txt", ".docx", ".xlsx". + */ + fileName: string; + /** + * Public URI of the file. + */ + fileUri: string; +} + +/** + * List of QnADTO + */ +export interface QnADocumentsDTO { + /** + * List of answers. + */ + qnaDocuments?: QnADTO[]; +} + +/** + * Post body schema for CreateKb operation. + */ +export interface CreateKbDTO { + /** + * Friendly name for the knowledgebase. + */ + name: string; + /** + * List of Q-A (QnADTO) to be added to the knowledgebase. Q-A Ids are assigned by the service and + * should be omitted. + */ + qnaList?: QnADTO[]; + /** + * List of URLs to be used for extracting Q-A. + */ + urls?: string[]; + /** + * List of files from which to Extract Q-A. + */ + files?: FileDTO[]; + /** + * Enable hierarchical extraction of Q-A from files and urls. Value to be considered False if + * this field is not present. + */ + enableHierarchicalExtraction?: boolean; + /** + * Text string to be used as the answer in any Q-A which has no extracted answer from the + * document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. + */ + defaultAnswerUsedForExtraction?: string; + /** + * Language of the knowledgebase. Please find the list of supported languages here. + */ + language?: string; +} + +/** + * Post body schema for Replace KB operation. + */ +export interface ReplaceKbDTO { + /** + * List of Q-A (QnADTO) to be added to the knowledgebase. Q-A Ids are assigned by the service and + * should be omitted. + */ + qnAList: QnADTO[]; +} + +/** + * The error object. As per Microsoft One API guidelines - + * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + */ +export interface ErrorModel { + /** + * One of a server-defined set of error codes. Possible values include: 'BadArgument', + * 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', + * 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', 'OperationNotFound', 'ServiceError', + * 'ValidationFailure', 'ExtractionFailure' + */ + code: ErrorCodeType; + /** + * A human-readable representation of the error. + */ + message?: string; + /** + * The target of the error. + */ + target?: string; + /** + * An array of details about specific errors that led to this reported error. + */ + details?: ErrorModel[]; + /** + * An object containing more specific information than the current object about the error. + */ + innerError?: InnerErrorModel; +} + +/** + * The error object. + */ +export interface ErrorResponseError extends ErrorModel { +} + +/** + * Error response. As per Microsoft One API guidelines - + * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + */ +export interface ErrorResponse { + /** + * The error object. + */ + error?: ErrorResponseError; +} + +/** + * An object containing more specific information about the error. As per Microsoft One API + * guidelines - + * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + */ +export interface InnerErrorModel { + /** + * A more specific error code than was provided by the containing error. + */ + code?: string; + /** + * An object containing more specific information than the current object about the error. + */ + innerError?: InnerErrorModel; +} + +/** + * Record to track long running operation. + */ +export interface Operation { + /** + * Operation state. Possible values include: 'Failed', 'NotStarted', 'Running', 'Succeeded' + */ + operationState?: OperationStateType; + /** + * Timestamp when the operation was created. + */ + createdTimestamp?: string; + /** + * Timestamp when the current state was entered. + */ + lastActionTimestamp?: string; + /** + * Relative URI to the target resource location for completed resources. + */ + resourceLocation?: string; + /** + * User Id + */ + userId?: string; + /** + * Operation Id. + */ + operationId?: string; + /** + * Error details in case of failures. + */ + errorResponse?: ErrorResponse; +} + +/** + * Response schema for CreateKb operation. + */ +export interface KnowledgebaseDTO { + /** + * Unique id that identifies a knowledgebase. + */ + id?: string; + /** + * URL host name at which the knowledgebase is hosted. + */ + hostName?: string; + /** + * Time stamp at which the knowledgebase was last accessed (UTC). + */ + lastAccessedTimestamp?: string; + /** + * Time stamp at which the knowledgebase was last modified (UTC). + */ + lastChangedTimestamp?: string; + /** + * Time stamp at which the knowledgebase was last published (UTC). + */ + lastPublishedTimestamp?: string; + /** + * Friendly name of the knowledgebase. + */ + name?: string; + /** + * User who created / owns the knowledgebase. + */ + userId?: string; + /** + * URL sources from which Q-A were extracted and added to the knowledgebase. + */ + urls?: string[]; + /** + * Custom sources from which Q-A were extracted or explicitly added to the knowledgebase. + */ + sources?: string[]; +} + +/** + * Collection of knowledgebases owned by a user. + */ +export interface KnowledgebasesDTO { + /** + * Collection of knowledgebase records. + */ + knowledgebases?: KnowledgebaseDTO[]; +} + +/** + * Active Learning settings of the endpoint. + */ +export interface ActiveLearningSettingsDTO { + /** + * True/False string providing Active Learning + */ + enable?: string; +} + +/** + * Active Learning settings of the endpoint. + */ +export interface EndpointSettingsDTOActiveLearning extends ActiveLearningSettingsDTO { +} + +/** + * Endpoint settings. + */ +export interface EndpointSettingsDTO { + /** + * Active Learning settings of the endpoint. + */ + activeLearning?: EndpointSettingsDTOActiveLearning; +} + +/** + * Collection of words that are synonyms. + */ +export interface AlterationsDTO { + /** + * Words that are synonymous with each other. + */ + alterations: string[]; +} + +/** + * Collection of word alterations. + */ +export interface WordAlterationsDTO { + /** + * Collection of word alterations. + */ + wordAlterations: AlterationsDTO[]; +} + +/** + * Schema for EndpointKeys generate/refresh operations. + */ +export interface EndpointKeysDTO { + /** + * Primary Access Key. + */ + primaryEndpointKey?: string; + /** + * Secondary Access Key. + */ + secondaryEndpointKey?: string; + /** + * Current version of runtime. + */ + installedVersion?: string; + /** + * Latest version of runtime. + */ + lastStableVersion?: string; + /** + * Language setting of runtime. + */ + language?: string; +} + +/** + * Context object with previous QnA's information. + */ +export interface QueryContextDTO { + /** + * Previous QnA Id - qnaId of the top result. + */ + previousQnaId?: number; + /** + * Previous user query. + */ + previousUserQuery?: string; +} + +/** + * Context object with previous QnA's information. + */ +export interface QueryDTOContext extends QueryContextDTO { +} + +/** + * To configure Answer span prediction feature. + */ +export interface AnswerSpanRequestDTO { + /** + * Enable or Disable Answer Span prediction. + */ + enable?: boolean; + /** + * Minimum threshold score required to include an answer span. + */ + scoreThreshold?: number; + /** + * Number of Top answers to be considered for span prediction. + */ + topAnswersWithSpan?: number; +} + +/** + * To configure Answer span prediction feature. + */ +export interface QueryDTOAnswerSpanRequest extends AnswerSpanRequestDTO { +} + +/** + * POST body schema to query the knowledgebase. + */ +export interface QueryDTO { + /** + * Exact qnaId to fetch from the knowledgebase, this field takes priority over question. + */ + qnaId?: string; + /** + * User question to query against the knowledge base. + */ + question?: string; + /** + * Max number of answers to be returned for the question. + */ + top?: number; + /** + * Unique identifier for the user. + */ + userId?: string; + /** + * Query against the test index. + */ + isTest?: boolean; + /** + * Minimum threshold score for answers. + */ + scoreThreshold?: number; + /** + * Context object with previous QnA's information. + */ + context?: QueryDTOContext; + /** + * Optional field. Set to 'QuestionOnly' for using a question only Ranker. + */ + rankerType?: string; + /** + * Find QnAs that are associated with the given list of metadata. + */ + strictFilters?: MetadataDTO[]; + /** + * Optional field. Set to 'OR' for using OR operation for strict filters. Possible values + * include: 'AND', 'OR' + */ + strictFiltersCompoundOperationType?: StrictFiltersCompoundOperationType; + /** + * To configure Answer span prediction feature. + */ + answerSpanRequest?: QueryDTOAnswerSpanRequest; +} + +/** + * Context object of the QnA + */ +export interface QnASearchResultContext extends ContextDTO { +} + +/** + * Answer span object of QnA. + */ +export interface AnswerSpanResponseDTO { + /** + * Predicted text of answer span. + */ + text?: string; + /** + * Predicted score of answer span. + */ + score?: number; + /** + * Start index of answer span in answer. + */ + startIndex?: number; + /** + * End index of answer span in answer. + */ + endIndex?: number; +} + +/** + * Answer span object of QnA with respect to user's question. + */ +export interface QnASearchResultAnswerSpan extends AnswerSpanResponseDTO { +} + +/** + * Represents Search Result. + */ +export interface QnASearchResult { + /** + * List of questions. + */ + questions?: string[]; + /** + * Answer. + */ + answer?: string; + /** + * Search result score. + */ + score?: number; + /** + * Id of the QnA result. + */ + id?: number; + /** + * Source of QnA result. + */ + source?: string; + /** + * List of metadata. + */ + metadata?: MetadataDTO[]; + /** + * Context object of the QnA + */ + context?: QnASearchResultContext; + /** + * Answer span object of QnA with respect to user's question. + */ + answerSpan?: QnASearchResultAnswerSpan; +} + +/** + * Represents List of Question Answers. + */ +export interface QnASearchResultList { + /** + * Represents Search Result list. + */ + answers?: QnASearchResult[]; +} + +/** + * Active learning feedback record. + */ +export interface FeedbackRecordDTO { + /** + * Unique identifier for the user. + */ + userId?: string; + /** + * The suggested question being provided as feedback. + */ + userQuestion?: string; + /** + * The qnaId for which the suggested question is provided as feedback. + */ + qnaId?: number; +} + +/** + * Active learning feedback records. + */ +export interface FeedbackRecordsDTO { + /** + * List of feedback records. + */ + feedbackRecords?: FeedbackRecordDTO[]; +} + +/** + * Optional Parameters. + */ +export interface KnowledgebaseDownloadOptionalParams extends msRest.RequestOptionsBase { + /** + * The source property filter to apply. + */ + source?: string; + /** + * The last changed status property filter to apply. + */ + changedSince?: string; +} + +/** + * Defines headers for GetDetails operation. + */ +export interface OperationsGetDetailsHeaders { + /** + * Indicates how long the client should wait before sending a follow up request. The header will + * be present only if the operation is running or has not started yet. + */ + retryAfter: number; +} + +/** + * Defines headers for Update operation. + */ +export interface KnowledgebaseUpdateHeaders { + /** + * Relative URI to the target location of the asynchronous operation. Client should poll this + * resource to get status of the operation. + */ + location: string; +} + +/** + * Defines values for ErrorCodeType. + * Possible values include: 'BadArgument', 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', + * 'Unspecified', 'EndpointKeysError', 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + * 'OperationNotFound', 'ServiceError', 'ValidationFailure', 'ExtractionFailure' + * @readonly + * @enum {string} + */ +export type ErrorCodeType = 'BadArgument' | 'Forbidden' | 'NotFound' | 'KbNotFound' | 'Unauthorized' | 'Unspecified' | 'EndpointKeysError' | 'QuotaExceeded' | 'QnaRuntimeError' | 'SKULimitExceeded' | 'OperationNotFound' | 'ServiceError' | 'ValidationFailure' | 'ExtractionFailure'; + +/** + * Defines values for OperationStateType. + * Possible values include: 'Failed', 'NotStarted', 'Running', 'Succeeded' + * @readonly + * @enum {string} + */ +export type OperationStateType = 'Failed' | 'NotStarted' | 'Running' | 'Succeeded'; + +/** + * Defines values for StrictFiltersCompoundOperationType. + * Possible values include: 'AND', 'OR' + * @readonly + * @enum {string} + */ +export type StrictFiltersCompoundOperationType = 'AND' | 'OR'; + +/** + * Defines values for EnvironmentType. + * Possible values include: 'Prod', 'Test' + * @readonly + * @enum {string} + */ +export type EnvironmentType = 'Prod' | 'Test'; + +/** + * Contains response data for the getSettings operation. + */ +export type EndpointSettingsGetSettingsResponse = EndpointSettingsDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: EndpointSettingsDTO; + }; +}; + +/** + * Contains response data for the getKeys operation. + */ +export type EndpointKeysGetKeysResponse = EndpointKeysDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: EndpointKeysDTO; + }; +}; + +/** + * Contains response data for the refreshKeys operation. + */ +export type EndpointKeysRefreshKeysResponse = EndpointKeysDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: EndpointKeysDTO; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type AlterationsGetResponse = WordAlterationsDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: WordAlterationsDTO; + }; +}; + +/** + * Contains response data for the getAlterationsForKb operation. + */ +export type AlterationsGetAlterationsForKbResponse = WordAlterationsDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: WordAlterationsDTO; + }; +}; + +/** + * Contains response data for the listAll operation. + */ +export type KnowledgebaseListAllResponse = KnowledgebasesDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KnowledgebasesDTO; + }; +}; + +/** + * Contains response data for the getDetails operation. + */ +export type KnowledgebaseGetDetailsResponse = KnowledgebaseDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: KnowledgebaseDTO; + }; +}; + +/** + * Contains response data for the update operation. + */ +export type KnowledgebaseUpdateResponse = Operation & KnowledgebaseUpdateHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: KnowledgebaseUpdateHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Operation; + }; +}; + +/** + * Contains response data for the create operation. + */ +export type KnowledgebaseCreateResponse = Operation & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Operation; + }; +}; + +/** + * Contains response data for the download operation. + */ +export type KnowledgebaseDownloadResponse = QnADocumentsDTO & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: QnADocumentsDTO; + }; +}; + +/** + * Contains response data for the generateAnswer operation. + */ +export type KnowledgebaseGenerateAnswerResponse = QnASearchResultList & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: QnASearchResultList; + }; +}; + +/** + * Contains response data for the getDetails operation. + */ +export type OperationsGetDetailsResponse = Operation & OperationsGetDetailsHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: OperationsGetDetailsHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Operation; + }; +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/knowledgebaseMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/knowledgebaseMappers.ts new file mode 100644 index 000000000000..720fade307f8 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/knowledgebaseMappers.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + AnswerSpanRequestDTO, + AnswerSpanResponseDTO, + ContextDTO, + CreateKbDTO, + CreateKbInputDTO, + DeleteKbContentsDTO, + ErrorModel, + ErrorResponse, + ErrorResponseError, + FeedbackRecordDTO, + FeedbackRecordsDTO, + FileDTO, + InnerErrorModel, + KnowledgebaseDTO, + KnowledgebasesDTO, + KnowledgebaseUpdateHeaders, + MetadataDTO, + Operation, + PromptDTO, + PromptDTOQna, + QnADocumentsDTO, + QnADTO, + QnADTOContext, + QnASearchResult, + QnASearchResultAnswerSpan, + QnASearchResultContext, + QnASearchResultList, + QueryContextDTO, + QueryDTO, + QueryDTOAnswerSpanRequest, + QueryDTOContext, + ReplaceKbDTO, + UpdateContextDTO, + UpdateKbContentsDTO, + UpdateKbOperationDTO, + UpdateKbOperationDTOAdd, + UpdateKbOperationDTODelete, + UpdateKbOperationDTOUpdate, + UpdateMetadataDTO, + UpdateQnaDTO, + UpdateQnaDTOContext, + UpdateQnaDTOMetadata, + UpdateQnaDTOQuestions, + UpdateQuestionsDTO +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/mappers.ts new file mode 100644 index 000000000000..1db9b5e952e5 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/mappers.ts @@ -0,0 +1,1525 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +export const CreateKbInputDTO: msRest.CompositeMapper = { + serializedName: "CreateKbInputDTO", + type: { + name: "Composite", + className: "CreateKbInputDTO", + modelProperties: { + qnaList: { + serializedName: "qnaList", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QnADTO" + } + } + } + }, + urls: { + serializedName: "urls", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + files: { + serializedName: "files", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "FileDTO" + } + } + } + } + } + } +}; + +export const UpdateKbOperationDTOAdd: msRest.CompositeMapper = { + serializedName: "UpdateKbOperationDTO_add", + type: { + name: "Composite", + className: "UpdateKbOperationDTOAdd", + modelProperties: { + ...CreateKbInputDTO.type.modelProperties + } + } +}; + +export const DeleteKbContentsDTO: msRest.CompositeMapper = { + serializedName: "DeleteKbContentsDTO", + type: { + name: "Composite", + className: "DeleteKbContentsDTO", + modelProperties: { + ids: { + serializedName: "ids", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + sources: { + serializedName: "sources", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const UpdateKbOperationDTODelete: msRest.CompositeMapper = { + serializedName: "UpdateKbOperationDTO_delete", + type: { + name: "Composite", + className: "UpdateKbOperationDTODelete", + modelProperties: { + ...DeleteKbContentsDTO.type.modelProperties + } + } +}; + +export const UpdateKbContentsDTO: msRest.CompositeMapper = { + serializedName: "UpdateKbContentsDTO", + type: { + name: "Composite", + className: "UpdateKbContentsDTO", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + qnaList: { + serializedName: "qnaList", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "UpdateQnaDTO" + } + } + } + }, + urls: { + serializedName: "urls", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const UpdateKbOperationDTOUpdate: msRest.CompositeMapper = { + serializedName: "UpdateKbOperationDTO_update", + type: { + name: "Composite", + className: "UpdateKbOperationDTOUpdate", + modelProperties: { + ...UpdateKbContentsDTO.type.modelProperties + } + } +}; + +export const UpdateKbOperationDTO: msRest.CompositeMapper = { + serializedName: "UpdateKbOperationDTO", + type: { + name: "Composite", + className: "UpdateKbOperationDTO", + modelProperties: { + add: { + serializedName: "add", + type: { + name: "Composite", + className: "UpdateKbOperationDTOAdd" + } + }, + deleteProperty: { + serializedName: "delete", + type: { + name: "Composite", + className: "UpdateKbOperationDTODelete" + } + }, + update: { + serializedName: "update", + type: { + name: "Composite", + className: "UpdateKbOperationDTOUpdate" + } + }, + enableHierarchicalExtraction: { + serializedName: "enableHierarchicalExtraction", + type: { + name: "Boolean" + } + }, + defaultAnswerUsedForExtraction: { + serializedName: "defaultAnswerUsedForExtraction", + constraints: { + MaxLength: 300, + MinLength: 1 + }, + type: { + name: "String" + } + } + } + } +}; + +export const UpdateQuestionsDTO: msRest.CompositeMapper = { + serializedName: "UpdateQuestionsDTO", + type: { + name: "Composite", + className: "UpdateQuestionsDTO", + modelProperties: { + add: { + serializedName: "add", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + deleteProperty: { + serializedName: "delete", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const UpdateQnaDTOQuestions: msRest.CompositeMapper = { + serializedName: "UpdateQnaDTO_questions", + type: { + name: "Composite", + className: "UpdateQnaDTOQuestions", + modelProperties: { + ...UpdateQuestionsDTO.type.modelProperties + } + } +}; + +export const UpdateMetadataDTO: msRest.CompositeMapper = { + serializedName: "UpdateMetadataDTO", + type: { + name: "Composite", + className: "UpdateMetadataDTO", + modelProperties: { + deleteProperty: { + serializedName: "delete", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataDTO" + } + } + } + }, + add: { + serializedName: "add", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataDTO" + } + } + } + } + } + } +}; + +export const UpdateQnaDTOMetadata: msRest.CompositeMapper = { + serializedName: "UpdateQnaDTO_metadata", + type: { + name: "Composite", + className: "UpdateQnaDTOMetadata", + modelProperties: { + ...UpdateMetadataDTO.type.modelProperties + } + } +}; + +export const UpdateContextDTO: msRest.CompositeMapper = { + serializedName: "UpdateContextDTO", + type: { + name: "Composite", + className: "UpdateContextDTO", + modelProperties: { + promptsToDelete: { + serializedName: "promptsToDelete", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + promptsToAdd: { + serializedName: "promptsToAdd", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PromptDTO" + } + } + } + }, + isContextOnly: { + serializedName: "isContextOnly", + type: { + name: "Boolean" + } + } + } + } +}; + +export const UpdateQnaDTOContext: msRest.CompositeMapper = { + serializedName: "UpdateQnaDTO_context", + type: { + name: "Composite", + className: "UpdateQnaDTOContext", + modelProperties: { + ...UpdateContextDTO.type.modelProperties + } + } +}; + +export const UpdateQnaDTO: msRest.CompositeMapper = { + serializedName: "UpdateQnaDTO", + type: { + name: "Composite", + className: "UpdateQnaDTO", + modelProperties: { + id: { + serializedName: "id", + constraints: { + InclusiveMaximum: 2147483647, + InclusiveMinimum: 0 + }, + type: { + name: "Number" + } + }, + answer: { + serializedName: "answer", + type: { + name: "String" + } + }, + source: { + serializedName: "source", + constraints: { + MaxLength: 300 + }, + type: { + name: "String" + } + }, + questions: { + serializedName: "questions", + type: { + name: "Composite", + className: "UpdateQnaDTOQuestions" + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Composite", + className: "UpdateQnaDTOMetadata" + } + }, + context: { + serializedName: "context", + type: { + name: "Composite", + className: "UpdateQnaDTOContext" + } + } + } + } +}; + +export const MetadataDTO: msRest.CompositeMapper = { + serializedName: "MetadataDTO", + type: { + name: "Composite", + className: "MetadataDTO", + modelProperties: { + name: { + required: true, + serializedName: "name", + constraints: { + MaxLength: 100, + MinLength: 1 + }, + type: { + name: "String" + } + }, + value: { + required: true, + serializedName: "value", + constraints: { + MaxLength: 500, + MinLength: 1 + }, + type: { + name: "String" + } + } + } + } +}; + +export const QnADTO: msRest.CompositeMapper = { + serializedName: "QnADTO", + type: { + name: "Composite", + className: "QnADTO", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "Number" + } + }, + answer: { + required: true, + serializedName: "answer", + constraints: { + MaxLength: 25000, + MinLength: 1 + }, + type: { + name: "String" + } + }, + source: { + serializedName: "source", + constraints: { + MaxLength: 300 + }, + type: { + name: "String" + } + }, + questions: { + required: true, + serializedName: "questions", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataDTO" + } + } + } + }, + context: { + serializedName: "context", + type: { + name: "Composite", + className: "QnADTOContext" + } + }, + lastUpdatedTimestamp: { + serializedName: "lastUpdatedTimestamp", + constraints: { + MaxLength: 300 + }, + type: { + name: "String" + } + } + } + } +}; + +export const PromptDTOQna: msRest.CompositeMapper = { + serializedName: "PromptDTO_qna", + type: { + name: "Composite", + className: "PromptDTOQna", + modelProperties: { + ...QnADTO.type.modelProperties + } + } +}; + +export const PromptDTO: msRest.CompositeMapper = { + serializedName: "PromptDTO", + type: { + name: "Composite", + className: "PromptDTO", + modelProperties: { + displayOrder: { + serializedName: "displayOrder", + type: { + name: "Number" + } + }, + qnaId: { + serializedName: "qnaId", + type: { + name: "Number" + } + }, + qna: { + serializedName: "qna", + type: { + name: "Composite", + className: "PromptDTOQna" + } + }, + displayText: { + serializedName: "displayText", + constraints: { + MaxLength: 200 + }, + type: { + name: "String" + } + } + } + } +}; + +export const ContextDTO: msRest.CompositeMapper = { + serializedName: "ContextDTO", + type: { + name: "Composite", + className: "ContextDTO", + modelProperties: { + isContextOnly: { + serializedName: "isContextOnly", + type: { + name: "Boolean" + } + }, + prompts: { + serializedName: "prompts", + constraints: { + MaxItems: 20 + }, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PromptDTO" + } + } + } + } + } + } +}; + +export const QnADTOContext: msRest.CompositeMapper = { + serializedName: "QnADTO_context", + type: { + name: "Composite", + className: "QnADTOContext", + modelProperties: { + ...ContextDTO.type.modelProperties + } + } +}; + +export const FileDTO: msRest.CompositeMapper = { + serializedName: "FileDTO", + type: { + name: "Composite", + className: "FileDTO", + modelProperties: { + fileName: { + required: true, + serializedName: "fileName", + constraints: { + MaxLength: 200, + MinLength: 1 + }, + type: { + name: "String" + } + }, + fileUri: { + required: true, + serializedName: "fileUri", + type: { + name: "String" + } + } + } + } +}; + +export const QnADocumentsDTO: msRest.CompositeMapper = { + serializedName: "QnADocumentsDTO", + type: { + name: "Composite", + className: "QnADocumentsDTO", + modelProperties: { + qnaDocuments: { + serializedName: "qnaDocuments", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QnADTO" + } + } + } + } + } + } +}; + +export const CreateKbDTO: msRest.CompositeMapper = { + serializedName: "CreateKbDTO", + type: { + name: "Composite", + className: "CreateKbDTO", + modelProperties: { + name: { + required: true, + serializedName: "name", + constraints: { + MaxLength: 100, + MinLength: 1 + }, + type: { + name: "String" + } + }, + qnaList: { + serializedName: "qnaList", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QnADTO" + } + } + } + }, + urls: { + serializedName: "urls", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + files: { + serializedName: "files", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "FileDTO" + } + } + } + }, + enableHierarchicalExtraction: { + serializedName: "enableHierarchicalExtraction", + type: { + name: "Boolean" + } + }, + defaultAnswerUsedForExtraction: { + serializedName: "defaultAnswerUsedForExtraction", + constraints: { + MaxLength: 300, + MinLength: 1 + }, + type: { + name: "String" + } + }, + language: { + serializedName: "language", + constraints: { + MaxLength: 100, + MinLength: 1 + }, + type: { + name: "String" + } + } + } + } +}; + +export const ReplaceKbDTO: msRest.CompositeMapper = { + serializedName: "ReplaceKbDTO", + type: { + name: "Composite", + className: "ReplaceKbDTO", + modelProperties: { + qnAList: { + required: true, + serializedName: "qnAList", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QnADTO" + } + } + } + } + } + } +}; + +export const ErrorModel: msRest.CompositeMapper = { + serializedName: "Error", + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + code: { + required: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + }, + target: { + serializedName: "target", + type: { + name: "String" + } + }, + details: { + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + }, + innerError: { + serializedName: "innerError", + type: { + name: "Composite", + className: "InnerErrorModel" + } + } + } + } +}; + +export const ErrorResponseError: msRest.CompositeMapper = { + serializedName: "ErrorResponse_error", + type: { + name: "Composite", + className: "ErrorResponseError", + modelProperties: { + ...ErrorModel.type.modelProperties + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorResponseError" + } + } + } + } +}; + +export const InnerErrorModel: msRest.CompositeMapper = { + serializedName: "InnerErrorModel", + type: { + name: "Composite", + className: "InnerErrorModel", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + innerError: { + serializedName: "innerError", + type: { + name: "Composite", + className: "InnerErrorModel" + } + } + } + } +}; + +export const Operation: msRest.CompositeMapper = { + serializedName: "Operation", + type: { + name: "Composite", + className: "Operation", + modelProperties: { + operationState: { + serializedName: "operationState", + type: { + name: "String" + } + }, + createdTimestamp: { + serializedName: "createdTimestamp", + type: { + name: "String" + } + }, + lastActionTimestamp: { + serializedName: "lastActionTimestamp", + type: { + name: "String" + } + }, + resourceLocation: { + serializedName: "resourceLocation", + type: { + name: "String" + } + }, + userId: { + serializedName: "userId", + type: { + name: "String" + } + }, + operationId: { + serializedName: "operationId", + type: { + name: "String" + } + }, + errorResponse: { + serializedName: "errorResponse", + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + } +}; + +export const KnowledgebaseDTO: msRest.CompositeMapper = { + serializedName: "KnowledgebaseDTO", + type: { + name: "Composite", + className: "KnowledgebaseDTO", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + hostName: { + serializedName: "hostName", + type: { + name: "String" + } + }, + lastAccessedTimestamp: { + serializedName: "lastAccessedTimestamp", + type: { + name: "String" + } + }, + lastChangedTimestamp: { + serializedName: "lastChangedTimestamp", + type: { + name: "String" + } + }, + lastPublishedTimestamp: { + serializedName: "lastPublishedTimestamp", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + userId: { + serializedName: "userId", + type: { + name: "String" + } + }, + urls: { + serializedName: "urls", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + sources: { + serializedName: "sources", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const KnowledgebasesDTO: msRest.CompositeMapper = { + serializedName: "KnowledgebasesDTO", + type: { + name: "Composite", + className: "KnowledgebasesDTO", + modelProperties: { + knowledgebases: { + serializedName: "knowledgebases", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "KnowledgebaseDTO" + } + } + } + } + } + } +}; + +export const ActiveLearningSettingsDTO: msRest.CompositeMapper = { + serializedName: "ActiveLearningSettingsDTO", + type: { + name: "Composite", + className: "ActiveLearningSettingsDTO", + modelProperties: { + enable: { + serializedName: "enable", + type: { + name: "String" + } + } + } + } +}; + +export const EndpointSettingsDTOActiveLearning: msRest.CompositeMapper = { + serializedName: "EndpointSettingsDTO_activeLearning", + type: { + name: "Composite", + className: "EndpointSettingsDTOActiveLearning", + modelProperties: { + ...ActiveLearningSettingsDTO.type.modelProperties + } + } +}; + +export const EndpointSettingsDTO: msRest.CompositeMapper = { + serializedName: "EndpointSettingsDTO", + type: { + name: "Composite", + className: "EndpointSettingsDTO", + modelProperties: { + activeLearning: { + serializedName: "activeLearning", + type: { + name: "Composite", + className: "EndpointSettingsDTOActiveLearning" + } + } + } + } +}; + +export const AlterationsDTO: msRest.CompositeMapper = { + serializedName: "AlterationsDTO", + type: { + name: "Composite", + className: "AlterationsDTO", + modelProperties: { + alterations: { + required: true, + serializedName: "alterations", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const WordAlterationsDTO: msRest.CompositeMapper = { + serializedName: "WordAlterationsDTO", + type: { + name: "Composite", + className: "WordAlterationsDTO", + modelProperties: { + wordAlterations: { + required: true, + serializedName: "wordAlterations", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AlterationsDTO" + } + } + } + } + } + } +}; + +export const EndpointKeysDTO: msRest.CompositeMapper = { + serializedName: "EndpointKeysDTO", + type: { + name: "Composite", + className: "EndpointKeysDTO", + modelProperties: { + primaryEndpointKey: { + serializedName: "primaryEndpointKey", + type: { + name: "String" + } + }, + secondaryEndpointKey: { + serializedName: "secondaryEndpointKey", + type: { + name: "String" + } + }, + installedVersion: { + serializedName: "installedVersion", + type: { + name: "String" + } + }, + lastStableVersion: { + serializedName: "lastStableVersion", + type: { + name: "String" + } + }, + language: { + serializedName: "language", + type: { + name: "String" + } + } + } + } +}; + +export const QueryContextDTO: msRest.CompositeMapper = { + serializedName: "QueryContextDTO", + type: { + name: "Composite", + className: "QueryContextDTO", + modelProperties: { + previousQnaId: { + serializedName: "previousQnaId", + type: { + name: "Number" + } + }, + previousUserQuery: { + serializedName: "previousUserQuery", + type: { + name: "String" + } + } + } + } +}; + +export const QueryDTOContext: msRest.CompositeMapper = { + serializedName: "QueryDTO_context", + type: { + name: "Composite", + className: "QueryDTOContext", + modelProperties: { + ...QueryContextDTO.type.modelProperties + } + } +}; + +export const AnswerSpanRequestDTO: msRest.CompositeMapper = { + serializedName: "AnswerSpanRequestDTO", + type: { + name: "Composite", + className: "AnswerSpanRequestDTO", + modelProperties: { + enable: { + serializedName: "enable", + type: { + name: "Boolean" + } + }, + scoreThreshold: { + serializedName: "scoreThreshold", + type: { + name: "Number" + } + }, + topAnswersWithSpan: { + serializedName: "topAnswersWithSpan", + constraints: { + InclusiveMaximum: 10, + InclusiveMinimum: 1 + }, + type: { + name: "Number" + } + } + } + } +}; + +export const QueryDTOAnswerSpanRequest: msRest.CompositeMapper = { + serializedName: "QueryDTO_answerSpanRequest", + type: { + name: "Composite", + className: "QueryDTOAnswerSpanRequest", + modelProperties: { + ...AnswerSpanRequestDTO.type.modelProperties + } + } +}; + +export const QueryDTO: msRest.CompositeMapper = { + serializedName: "QueryDTO", + type: { + name: "Composite", + className: "QueryDTO", + modelProperties: { + qnaId: { + serializedName: "qnaId", + type: { + name: "String" + } + }, + question: { + serializedName: "question", + type: { + name: "String" + } + }, + top: { + serializedName: "top", + type: { + name: "Number" + } + }, + userId: { + serializedName: "userId", + type: { + name: "String" + } + }, + isTest: { + serializedName: "isTest", + type: { + name: "Boolean" + } + }, + scoreThreshold: { + serializedName: "scoreThreshold", + type: { + name: "Number" + } + }, + context: { + serializedName: "context", + type: { + name: "Composite", + className: "QueryDTOContext" + } + }, + rankerType: { + serializedName: "rankerType", + type: { + name: "String" + } + }, + strictFilters: { + serializedName: "strictFilters", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataDTO" + } + } + } + }, + strictFiltersCompoundOperationType: { + serializedName: "strictFiltersCompoundOperationType", + type: { + name: "String" + } + }, + answerSpanRequest: { + serializedName: "answerSpanRequest", + type: { + name: "Composite", + className: "QueryDTOAnswerSpanRequest" + } + } + } + } +}; + +export const QnASearchResultContext: msRest.CompositeMapper = { + serializedName: "QnASearchResult_context", + type: { + name: "Composite", + className: "QnASearchResultContext", + modelProperties: { + ...ContextDTO.type.modelProperties + } + } +}; + +export const AnswerSpanResponseDTO: msRest.CompositeMapper = { + serializedName: "AnswerSpanResponseDTO", + type: { + name: "Composite", + className: "AnswerSpanResponseDTO", + modelProperties: { + text: { + serializedName: "text", + type: { + name: "String" + } + }, + score: { + serializedName: "score", + type: { + name: "Number" + } + }, + startIndex: { + serializedName: "startIndex", + type: { + name: "Number" + } + }, + endIndex: { + serializedName: "endIndex", + type: { + name: "Number" + } + } + } + } +}; + +export const QnASearchResultAnswerSpan: msRest.CompositeMapper = { + serializedName: "QnASearchResult_answerSpan", + type: { + name: "Composite", + className: "QnASearchResultAnswerSpan", + modelProperties: { + ...AnswerSpanResponseDTO.type.modelProperties + } + } +}; + +export const QnASearchResult: msRest.CompositeMapper = { + serializedName: "QnASearchResult", + type: { + name: "Composite", + className: "QnASearchResult", + modelProperties: { + questions: { + serializedName: "questions", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + answer: { + serializedName: "answer", + type: { + name: "String" + } + }, + score: { + serializedName: "score", + type: { + name: "Number" + } + }, + id: { + serializedName: "id", + type: { + name: "Number" + } + }, + source: { + serializedName: "source", + type: { + name: "String" + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataDTO" + } + } + } + }, + context: { + serializedName: "context", + type: { + name: "Composite", + className: "QnASearchResultContext" + } + }, + answerSpan: { + serializedName: "answerSpan", + type: { + name: "Composite", + className: "QnASearchResultAnswerSpan" + } + } + } + } +}; + +export const QnASearchResultList: msRest.CompositeMapper = { + serializedName: "QnASearchResultList", + type: { + name: "Composite", + className: "QnASearchResultList", + modelProperties: { + answers: { + serializedName: "answers", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QnASearchResult" + } + } + } + } + } + } +}; + +export const FeedbackRecordDTO: msRest.CompositeMapper = { + serializedName: "FeedbackRecordDTO", + type: { + name: "Composite", + className: "FeedbackRecordDTO", + modelProperties: { + userId: { + serializedName: "userId", + type: { + name: "String" + } + }, + userQuestion: { + serializedName: "userQuestion", + constraints: { + MaxLength: 1000 + }, + type: { + name: "String" + } + }, + qnaId: { + serializedName: "qnaId", + type: { + name: "Number" + } + } + } + } +}; + +export const FeedbackRecordsDTO: msRest.CompositeMapper = { + serializedName: "FeedbackRecordsDTO", + type: { + name: "Composite", + className: "FeedbackRecordsDTO", + modelProperties: { + feedbackRecords: { + serializedName: "feedbackRecords", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "FeedbackRecordDTO" + } + } + } + } + } + } +}; + +export const OperationsGetDetailsHeaders: msRest.CompositeMapper = { + serializedName: "operations-getdetails-headers", + type: { + name: "Composite", + className: "OperationsGetDetailsHeaders", + modelProperties: { + retryAfter: { + serializedName: "retryafter", + type: { + name: "Number" + } + } + } + } +}; + +export const KnowledgebaseUpdateHeaders: msRest.CompositeMapper = { + serializedName: "knowledgebase-update-headers", + type: { + name: "Composite", + className: "KnowledgebaseUpdateHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/operationsMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/operationsMappers.ts new file mode 100644 index 000000000000..7887207338c4 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/operationsMappers.ts @@ -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. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorModel, + ErrorResponse, + ErrorResponseError, + InnerErrorModel, + Operation, + OperationsGetDetailsHeaders +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/parameters.ts new file mode 100644 index 000000000000..6030e4432a1e --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/models/parameters.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +export const changedSince: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "changedSince" + ], + mapper: { + serializedName: "changedSince", + type: { + name: "String" + } + } +}; +export const endpoint: msRest.OperationURLParameter = { + parameterPath: "endpoint", + mapper: { + required: true, + serializedName: "Endpoint", + defaultValue: '', + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const environment: msRest.OperationURLParameter = { + parameterPath: "environment", + mapper: { + required: true, + serializedName: "environment", + type: { + name: "String" + } + } +}; +export const kbId: msRest.OperationURLParameter = { + parameterPath: "kbId", + mapper: { + required: true, + serializedName: "kbId", + type: { + name: "String" + } + } +}; +export const keyType: msRest.OperationURLParameter = { + parameterPath: "keyType", + mapper: { + required: true, + serializedName: "keyType", + type: { + name: "String" + } + } +}; +export const operationId: msRest.OperationURLParameter = { + parameterPath: "operationId", + mapper: { + required: true, + serializedName: "operationId", + type: { + name: "String" + } + } +}; +export const source: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "source" + ], + mapper: { + serializedName: "source", + type: { + name: "String" + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/alterations.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/alterations.ts new file mode 100644 index 000000000000..19f9d2691467 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/alterations.ts @@ -0,0 +1,222 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/alterationsMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a Alterations. */ +export class Alterations { + private readonly client: QnAMakerClientContext; + + /** + * Create a Alterations. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Download alterations from runtime. + * @param [options] The optional parameters + * @returns Promise + */ + get(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + get(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + get(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * @summary Replace alterations data. + * @param wordAlterations New alterations data. + * @param [options] The optional parameters + * @returns Promise + */ + replace(wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param wordAlterations New alterations data. + * @param callback The callback + */ + replace(wordAlterations: Models.WordAlterationsDTO, callback: msRest.ServiceCallback): void; + /** + * @param wordAlterations New alterations data. + * @param options The optional parameters + * @param callback The callback + */ + replace(wordAlterations: Models.WordAlterationsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + replace(wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + wordAlterations, + options + }, + replaceOperationSpec, + callback); + } + + /** + * @summary Download alterations per Knowledgebase (QnAMaker Managed). + * @param kbId Knowledgebase id. + * @param [options] The optional parameters + * @returns Promise + */ + getAlterationsForKb(kbId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param callback The callback + */ + getAlterationsForKb(kbId: string, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param options The optional parameters + * @param callback The callback + */ + getAlterationsForKb(kbId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getAlterationsForKb(kbId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + options + }, + getAlterationsForKbOperationSpec, + callback) as Promise; + } + + /** + * @summary Replace alterations data per Knowledgebase (QnAMaker Managed). + * @param kbId Knowledgebase id. + * @param wordAlterations New alterations data. + * @param [options] The optional parameters + * @returns Promise + */ + replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param wordAlterations New alterations data. + * @param callback The callback + */ + replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param wordAlterations New alterations data. + * @param options The optional parameters + * @param callback The callback + */ + replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + wordAlterations, + options + }, + replaceAlterationsForKbOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "alterations", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.WordAlterationsDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const replaceOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "alterations", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "wordAlterations", + mapper: { + ...Mappers.WordAlterationsDTO, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const getAlterationsForKbOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "alterations/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + responses: { + 200: { + bodyMapper: Mappers.WordAlterationsDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const replaceAlterationsForKbOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "alterations/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + requestBody: { + parameterPath: "wordAlterations", + mapper: { + ...Mappers.WordAlterationsDTO, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointKeys.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointKeys.ts new file mode 100644 index 000000000000..99dcc6869859 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointKeys.ts @@ -0,0 +1,117 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/endpointKeysMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a EndpointKeys. */ +export class EndpointKeys { + private readonly client: QnAMakerClientContext; + + /** + * Create a EndpointKeys. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets endpoint keys for an endpoint + * @param [options] The optional parameters + * @returns Promise + */ + getKeys(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getKeys(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getKeys(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getKeys(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getKeysOperationSpec, + callback) as Promise; + } + + /** + * @summary Re-generates an endpoint key. + * @param keyType Type of Key + * @param [options] The optional parameters + * @returns Promise + */ + refreshKeys(keyType: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param keyType Type of Key + * @param callback The callback + */ + refreshKeys(keyType: string, callback: msRest.ServiceCallback): void; + /** + * @param keyType Type of Key + * @param options The optional parameters + * @param callback The callback + */ + refreshKeys(keyType: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + refreshKeys(keyType: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + keyType, + options + }, + refreshKeysOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getKeysOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "endpointkeys", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointKeysDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const refreshKeysOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "endpointkeys/{keyType}", + urlParameters: [ + Parameters.endpoint, + Parameters.keyType + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointKeysDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointSettings.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointSettings.ts new file mode 100644 index 000000000000..bd092c5dd289 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/endpointSettings.ts @@ -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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/endpointSettingsMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a EndpointSettings. */ +export class EndpointSettings { + private readonly client: QnAMakerClientContext; + + /** + * Create a EndpointSettings. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets endpoint settings for an endpoint. + * @param [options] The optional parameters + * @returns Promise + */ + getSettings(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getSettings(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getSettings(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getSettings(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getSettingsOperationSpec, + callback) as Promise; + } + + /** + * @summary Updates endpoint settings for an endpoint. + * @param endpointSettingsPayload Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param endpointSettingsPayload Post body of the request. + * @param callback The callback + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, callback: msRest.ServiceCallback): void; + /** + * @param endpointSettingsPayload Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + endpointSettingsPayload, + options + }, + updateSettingsOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getSettingsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "endpointSettings", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointSettingsDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const updateSettingsOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "endpointSettings", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "endpointSettingsPayload", + mapper: { + ...Mappers.EndpointSettingsDTO, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/index.ts new file mode 100644 index 000000000000..e67a8e209eb3 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export * from "./endpointSettings"; +export * from "./endpointKeys"; +export * from "./alterations"; +export * from "./knowledgebase"; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/knowledgebase.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/knowledgebase.ts new file mode 100644 index 000000000000..cddde7bc181a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/knowledgebase.ts @@ -0,0 +1,541 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/knowledgebaseMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a Knowledgebase. */ +export class Knowledgebase { + private readonly client: QnAMakerClientContext; + + /** + * Create a Knowledgebase. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets all knowledgebases for a user. + * @param [options] The optional parameters + * @returns Promise + */ + listAll(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + listAll(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listAll(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listAll(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listAllOperationSpec, + callback) as Promise; + } + + /** + * @summary Gets details of a specific knowledgebase. + * @param kbId Knowledgebase id. + * @param [options] The optional parameters + * @returns Promise + */ + getDetails(kbId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param callback The callback + */ + getDetails(kbId: string, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param options The optional parameters + * @param callback The callback + */ + getDetails(kbId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getDetails(kbId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + options + }, + getDetailsOperationSpec, + callback) as Promise; + } + + /** + * @summary Deletes the knowledgebase and all its data. + * @param kbId Knowledgebase id. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(kbId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param callback The callback + */ + deleteMethod(kbId: string, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(kbId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(kbId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * @summary Publishes all changes in test index of a knowledgebase to its prod index. + * @param kbId Knowledgebase id. + * @param [options] The optional parameters + * @returns Promise + */ + publish(kbId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param callback The callback + */ + publish(kbId: string, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param options The optional parameters + * @param callback The callback + */ + publish(kbId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + publish(kbId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + options + }, + publishOperationSpec, + callback); + } + + /** + * @summary Replace knowledgebase contents. + * @param kbId Knowledgebase id. + * @param replaceKb An instance of ReplaceKbDTO which contains list of qnas to be uploaded + * @param [options] The optional parameters + * @returns Promise + */ + replace(kbId: string, replaceKb: Models.ReplaceKbDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param replaceKb An instance of ReplaceKbDTO which contains list of qnas to be uploaded + * @param callback The callback + */ + replace(kbId: string, replaceKb: Models.ReplaceKbDTO, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param replaceKb An instance of ReplaceKbDTO which contains list of qnas to be uploaded + * @param options The optional parameters + * @param callback The callback + */ + replace(kbId: string, replaceKb: Models.ReplaceKbDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + replace(kbId: string, replaceKb: Models.ReplaceKbDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + replaceKb, + options + }, + replaceOperationSpec, + callback); + } + + /** + * @summary Asynchronous operation to modify a knowledgebase. + * @param kbId Knowledgebase id. + * @param updateKb Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + update(kbId: string, updateKb: Models.UpdateKbOperationDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param updateKb Post body of the request. + * @param callback The callback + */ + update(kbId: string, updateKb: Models.UpdateKbOperationDTO, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param updateKb Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + update(kbId: string, updateKb: Models.UpdateKbOperationDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + update(kbId: string, updateKb: Models.UpdateKbOperationDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + updateKb, + options + }, + updateOperationSpec, + callback) as Promise; + } + + /** + * @summary Asynchronous operation to create a new knowledgebase. + * @param createKbPayload Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + create(createKbPayload: Models.CreateKbDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param createKbPayload Post body of the request. + * @param callback The callback + */ + create(createKbPayload: Models.CreateKbDTO, callback: msRest.ServiceCallback): void; + /** + * @param createKbPayload Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + create(createKbPayload: Models.CreateKbDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + create(createKbPayload: Models.CreateKbDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + createKbPayload, + options + }, + createOperationSpec, + callback) as Promise; + } + + /** + * @summary Download the knowledgebase. + * @param kbId Knowledgebase id. + * @param environment Specifies whether environment is Test or Prod. Possible values include: + * 'Prod', 'Test' + * @param [options] The optional parameters + * @returns Promise + */ + download(kbId: string, environment: Models.EnvironmentType, options?: Models.KnowledgebaseDownloadOptionalParams): Promise; + /** + * @param kbId Knowledgebase id. + * @param environment Specifies whether environment is Test or Prod. Possible values include: + * 'Prod', 'Test' + * @param callback The callback + */ + download(kbId: string, environment: Models.EnvironmentType, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param environment Specifies whether environment is Test or Prod. Possible values include: + * 'Prod', 'Test' + * @param options The optional parameters + * @param callback The callback + */ + download(kbId: string, environment: Models.EnvironmentType, options: Models.KnowledgebaseDownloadOptionalParams, callback: msRest.ServiceCallback): void; + download(kbId: string, environment: Models.EnvironmentType, options?: Models.KnowledgebaseDownloadOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + environment, + options + }, + downloadOperationSpec, + callback) as Promise; + } + + /** + * @summary GenerateAnswer call to query knowledgebase (QnA Maker Managed). + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @param callback The callback + */ + generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param generateAnswerPayload Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + generateAnswerPayload, + options + }, + generateAnswerOperationSpec, + callback) as Promise; + } + + /** + * @summary Train call to add suggestions to knowledgebase (QnAMaker Managed). + * @param kbId Knowledgebase id. + * @param trainPayload Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param kbId Knowledgebase id. + * @param trainPayload Post body of the request. + * @param callback The callback + */ + train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, callback: msRest.ServiceCallback): void; + /** + * @param kbId Knowledgebase id. + * @param trainPayload Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + kbId, + trainPayload, + options + }, + trainOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listAllOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "knowledgebases", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.KnowledgebasesDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const getDetailsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "knowledgebases/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + responses: { + 200: { + bodyMapper: Mappers.KnowledgebaseDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "knowledgebases/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const publishOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "knowledgebases/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const replaceOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "knowledgebases/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + requestBody: { + parameterPath: "replaceKb", + mapper: { + ...Mappers.ReplaceKbDTO, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const updateOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "knowledgebases/{kbId}", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + requestBody: { + parameterPath: "updateKb", + mapper: { + ...Mappers.UpdateKbOperationDTO, + required: true + } + }, + responses: { + 202: { + bodyMapper: Mappers.Operation, + headersMapper: Mappers.KnowledgebaseUpdateHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: Mappers.KnowledgebaseUpdateHeaders + } + }, + serializer +}; + +const createOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "knowledgebases/create", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "createKbPayload", + mapper: { + ...Mappers.CreateKbDTO, + required: true + } + }, + responses: { + 202: { + bodyMapper: Mappers.Operation + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const downloadOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "knowledgebases/{kbId}/{environment}/qna", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId, + Parameters.environment + ], + queryParameters: [ + Parameters.source, + Parameters.changedSince + ], + responses: { + 200: { + bodyMapper: Mappers.QnADocumentsDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const generateAnswerOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "knowledgebases/{kbId}/generateAnswer", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + requestBody: { + parameterPath: "generateAnswerPayload", + mapper: { + ...Mappers.QueryDTO, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.QnASearchResultList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const trainOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "knowledgebases/{kbId}/train", + urlParameters: [ + Parameters.endpoint, + Parameters.kbId + ], + requestBody: { + parameterPath: "trainPayload", + mapper: { + ...Mappers.FeedbackRecordsDTO, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/operations.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/operations.ts new file mode 100644 index 000000000000..d87b07af05c8 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/operations/operations.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/operationsMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a Operations. */ +export class Operations { + private readonly client: QnAMakerClientContext; + + /** + * Create a Operations. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets details of a specific long running operation. + * @param operationId Operation id. + * @param [options] The optional parameters + * @returns Promise + */ + getDetails(operationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param operationId Operation id. + * @param callback The callback + */ + getDetails(operationId: string, callback: msRest.ServiceCallback): void; + /** + * @param operationId Operation id. + * @param options The optional parameters + * @param callback The callback + */ + getDetails(operationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getDetails(operationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + operationId, + options + }, + getDetailsOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getDetailsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "operations/{operationId}", + urlParameters: [ + Parameters.endpoint, + Parameters.operationId + ], + responses: { + 200: { + bodyMapper: Mappers.Operation, + headersMapper: Mappers.OperationsGetDetailsHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: Mappers.OperationsGetDetailsHeaders + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClient.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClient.ts new file mode 100644 index 000000000000..841765040e39 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClient.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as operations from "./operations"; +import { QnAMakerClientContext } from "./qnAMakerClientContext"; + +class QnAMakerClient extends QnAMakerClientContext { + // Operation groups + endpointSettings: operations.EndpointSettings; + endpointKeys: operations.EndpointKeys; + alterations: operations.Alterations; + knowledgebase: operations.Knowledgebase; + operations: operations.Operations; + + /** + * Initializes a new instance of the QnAMakerClient class. + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name + * >.api.cognitiveservices.azure.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { + super(credentials, endpoint, options); + this.endpointSettings = new operations.EndpointSettings(this); + this.endpointKeys = new operations.EndpointKeys(this); + this.alterations = new operations.Alterations(this); + this.knowledgebase = new operations.Knowledgebase(this); + this.operations = new operations.Operations(this); + } +} + +// Operation Specifications + +export { + QnAMakerClient, + QnAMakerClientContext, + Models as QnAMakerModels, + Mappers as QnAMakerMappers +}; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClientContext.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClientContext.ts new file mode 100644 index 000000000000..47acb202cce3 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/src/qnAMakerClientContext.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +const packageName = "@azure/cognitiveservices-qnamaker"; +const packageVersion = "3.1.1"; + +export class QnAMakerClientContext extends msRest.ServiceClient { + endpoint: string; + credentials: msRest.ServiceClientCredentials; + + /** + * Initializes a new instance of the QnAMakerClientContext class. + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name + * >.api.cognitiveservices.azure.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { + if (endpoint == undefined) { + throw new Error("'endpoint' cannot be null."); + } + if (credentials == undefined) { + throw new Error("'credentials' cannot be null."); + } + + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{Endpoint}/qnamaker/v5.0-preview.1"; + this.requestContentType = "application/json; charset=utf-8"; + this.endpoint = endpoint; + this.credentials = credentials; + } +} diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/tsconfig.json b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/tsconfig.json new file mode 100644 index 000000000000..422b584abd5e --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/preview/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es5", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6", "dom"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts index a8899db2a92b..bb45348c1887 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts @@ -353,7 +353,8 @@ export interface CreateKbDTO { */ defaultAnswerUsedForExtraction?: string; /** - * Language of the knowledgebase. + * Language of the knowledgebase. Please find the list of supported languages here. */ language?: string; } @@ -590,6 +591,23 @@ export interface EndpointKeysDTO { language?: string; } +/** + * Optional Parameters. + */ +export interface KnowledgebaseDownloadOptionalParams extends msRest.RequestOptionsBase { + /** + * The source property filter to apply. Sample value: Editorial, smartLight%20FAQ.tsv . + */ + source?: string; + /** + * changedSince property is used to return all QnAs created or updated after a specific time + * duration. The user can filter QnAs by seconds (s), minutes (m), hours (h) and days (d). The + * user may use any integral value along with the suffix for time. For instance, the value of 5m + * returns all QnA pairs updated or created in the last 5 minutes. + */ + changedSince?: string; +} + /** * Defines headers for GetDetails operation. */ @@ -658,31 +676,6 @@ export type EndpointSettingsGetSettingsResponse = EndpointSettingsDTO & { }; }; -/** - * Contains response data for the updateSettings operation. - */ -export type EndpointSettingsUpdateSettingsResponse = { - /** - * The parsed response body. - */ - body: string; - - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: string; - }; -}; - /** * Contains response data for the getKeys operation. */ diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts index a9c7055c493d..6030e4432a1e 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts @@ -10,6 +10,18 @@ import * as msRest from "@azure/ms-rest-js"; +export const changedSince: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "changedSince" + ], + mapper: { + serializedName: "changedSince", + type: { + name: "String" + } + } +}; export const endpoint: msRest.OperationURLParameter = { parameterPath: "endpoint", mapper: { @@ -62,3 +74,15 @@ export const operationId: msRest.OperationURLParameter = { } } }; +export const source: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "source" + ], + mapper: { + serializedName: "source", + type: { + name: "String" + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts index 9b21f50dbcdf..bd092c5dd289 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts @@ -54,28 +54,28 @@ export class EndpointSettings { * @summary Updates endpoint settings for an endpoint. * @param endpointSettingsPayload Post body of the request. * @param [options] The optional parameters - * @returns Promise + * @returns Promise */ - updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): Promise; + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): Promise; /** * @param endpointSettingsPayload Post body of the request. * @param callback The callback */ - updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, callback: msRest.ServiceCallback): void; + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, callback: msRest.ServiceCallback): void; /** * @param endpointSettingsPayload Post body of the request. * @param options The optional parameters * @param callback The callback */ - updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { endpointSettingsPayload, options }, updateSettingsOperationSpec, - callback) as Promise; + callback); } } @@ -112,14 +112,7 @@ const updateSettingsOperationSpec: msRest.OperationSpec = { } }, responses: { - 200: { - bodyMapper: { - serializedName: "parsedResponse", - type: { - name: "String" - } - } - }, + 204: {}, default: { bodyMapper: Mappers.ErrorResponse } diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts index f51df77ef345..aae921cc9a47 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts @@ -234,7 +234,7 @@ export class Knowledgebase { * @param [options] The optional parameters * @returns Promise */ - download(kbId: string, environment: Models.EnvironmentType, options?: msRest.RequestOptionsBase): Promise; + download(kbId: string, environment: Models.EnvironmentType, options?: Models.KnowledgebaseDownloadOptionalParams): Promise; /** * @param kbId Knowledgebase id. * @param environment Specifies whether environment is Test or Prod. Possible values include: @@ -249,8 +249,8 @@ export class Knowledgebase { * @param options The optional parameters * @param callback The callback */ - download(kbId: string, environment: Models.EnvironmentType, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - download(kbId: string, environment: Models.EnvironmentType, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + download(kbId: string, environment: Models.EnvironmentType, options: Models.KnowledgebaseDownloadOptionalParams, callback: msRest.ServiceCallback): void; + download(kbId: string, environment: Models.EnvironmentType, options?: Models.KnowledgebaseDownloadOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { kbId, @@ -413,6 +413,10 @@ const downloadOperationSpec: msRest.OperationSpec = { Parameters.kbId, Parameters.environment ], + queryParameters: [ + Parameters.source, + Parameters.changedSince + ], responses: { 200: { bodyMapper: Mappers.QnADocumentsDTO diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts index bf1194ce9e10..0105bd1cc007 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts @@ -24,8 +24,8 @@ class QnAMakerClient extends QnAMakerClientContext { /** * Initializes a new instance of the QnAMakerClient class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus.api.cognitive.microsoft.com). + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name> + * .api.cognitiveservices.azure.com). * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts index 223a50238000..665558d6e725 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts @@ -19,8 +19,8 @@ export class QnAMakerClientContext extends msRest.ServiceClient { /** * Initializes a new instance of the QnAMakerClientContext class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus.api.cognitive.microsoft.com). + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name> + * .api.cognitiveservices.azure.com). * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */