diff --git a/lib/services/luis/authoring/.scripts/postinstall.js b/lib/services/luis/authoring/.scripts/postinstall.js new file mode 100644 index 0000000000..539f39a79d --- /dev/null +++ b/lib/services/luis/authoring/.scripts/postinstall.js @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +const resetColor = "\x1b[0m"; +const brightColor = "\x1b[1m"; +const highlightColor = "\x1b[31m"; + +try { + const invisibleCharactersLength = resetColor.length + brightColor.length + highlightColor.length; + + const firstLine = `Active development of this SDK has been moved to ${highlightColor}@azure/cognitiveservices-luis-authoring${resetColor}${brightColor} package.`; + const secondLine = "This package is in maintenance mode and will be deprecated in July 2018."; + const thirdLine = "Visit https://aka.ms/azure-sdk-for-js-migration for more information."; + + const framePadding = 4; + const adjustedFirstLineLength = firstLine.length - invisibleCharactersLength; + const width = Math.max(adjustedFirstLineLength, secondLine.length, thirdLine.length) + framePadding; + const getPaddingLength = (strLength) => width - strLength - framePadding; + + const firstLinePaddingLength = getPaddingLength(adjustedFirstLineLength); + const secondLinePaddingLength = getPaddingLength(secondLine.length); + const thirdLinePaddingLength = getPaddingLength(thirdLine.length); + const line = "#".repeat(width); + + const formatTextLine = (text, padding) => `#${" ".repeat(Math.floor(padding / 2))} ${text} ${" ".repeat(Math.ceil(padding / 2))}#`; + + console.log(brightColor); + console.log("\n" + line); + console.log(formatTextLine(firstLine, firstLinePaddingLength)); + console.log(formatTextLine(secondLine, secondLinePaddingLength)); + console.log(formatTextLine(thirdLine, thirdLinePaddingLength)); + console.log(line + "\n"); + console.log(resetColor); +} catch (err) { + // ignore +} diff --git a/lib/services/luis/authoring/LICENSE.txt b/lib/services/luis/authoring/LICENSE.txt index a70e8cf660..8f3d856145 100644 --- a/lib/services/luis/authoring/LICENSE.txt +++ b/lib/services/luis/authoring/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2018 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. +The MIT License (MIT) + +Copyright (c) 2019 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/lib/services/luis/authoring/README.md b/lib/services/luis/authoring/README.md index 94432e30af..97f3f639bb 100644 --- a/lib/services/luis/authoring/README.md +++ b/lib/services/luis/authoring/README.md @@ -1,48 +1,49 @@ ---- -uid: azure-cognitiveservices-luis-authoring -summary: *content - ---- -**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** -## Microsoft Azure SDK for Node.js - LUISAuthoringClient - -This project provides a Node.js package for accessing Azure. Right now it supports: -- **Node.js version 6.x.x or higher** - -### Features - - -### How to Install - -```bash -npm install azure-cognitiveservices-luis-authoring -``` - -### How to use - -#### Authentication, client creation, and listPhraseLists features as an example. - -```javascript -const msRest = require("ms-rest"); -const LUISAuthoringClient = require("azure-cognitiveservices-luis-authoring"); -const token = ""; -const creds = new msRest.TokenCredentials(token); -const subscriptionId = ""; -const client = new LUISAuthoringClient(creds, subscriptionId); -const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; -const versionId = "testversionId"; -const skip = 1; -const take = 1; - -client.features.listPhraseLists(appId, versionId, skip, take).then((result) => { - console.log("The result is:"); - console.log(result); -}).catch((err) => { - console.log('An error occurred:'); - console.dir(err, {depth: null, colors: true}); -}); -``` - -### Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-cognitiveservices-luis-authoring +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://www.npmjs.com/package/@azure/cognitiveservices-luis-authoring) which works on Node.js and browsers.** +**See https://aka.ms/azure-sdk-for-js-migration to learn more.** +## Microsoft Azure SDK for Node.js - LUISAuthoringClient + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-cognitiveservices-luis-authoring +``` + +### How to use + +#### Authentication, client creation, and listPhraseLists features as an example. + +```javascript +const msRest = require("ms-rest"); +const LUISAuthoringClient = require("azure-cognitiveservices-luis-authoring"); +const token = ""; +const creds = new msRest.TokenCredentials(token); +const subscriptionId = ""; +const client = new LUISAuthoringClient(creds, subscriptionId); +const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; +const versionId = "testversionId"; +const skip = 1; +const take = 1; + +client.features.listPhraseLists(appId, versionId, skip, take).then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` + +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/luis/authoring/lib/lUISAuthoringClient.d.ts b/lib/services/luis/authoring/lib/lUISAuthoringClient.d.ts index 016adef630..0cd61d5b41 100644 --- a/lib/services/luis/authoring/lib/lUISAuthoringClient.d.ts +++ b/lib/services/luis/authoring/lib/lUISAuthoringClient.d.ts @@ -48,6 +48,7 @@ export default class LUISAuthoringClient extends ServiceClient { permissions: operations.Permissions; pattern: operations.Pattern; settings: operations.Settings; + azureAccounts: operations.AzureAccounts; } export { LUISAuthoringClient, models as LUISAuthoringModels }; diff --git a/lib/services/luis/authoring/lib/lUISAuthoringClient.js b/lib/services/luis/authoring/lib/lUISAuthoringClient.js index ada27b1c25..f2a5adc93a 100644 --- a/lib/services/luis/authoring/lib/lUISAuthoringClient.js +++ b/lib/services/luis/authoring/lib/lUISAuthoringClient.js @@ -60,6 +60,7 @@ class LUISAuthoringClient extends ServiceClient { this.permissions = new operations.Permissions(this); this.pattern = new operations.Pattern(this); this.settings = new operations.Settings(this); + this.azureAccounts = new operations.AzureAccounts(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/luis/authoring/lib/models/azureAccountInfoObject.js b/lib/services/luis/authoring/lib/models/azureAccountInfoObject.js new file mode 100644 index 0000000000..423feb78a3 --- /dev/null +++ b/lib/services/luis/authoring/lib/models/azureAccountInfoObject.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Defines the azure account information object. + * + */ +class AzureAccountInfoObject { + /** + * Create a AzureAccountInfoObject. + * @property {string} azureSubscriptionId The id for the azure subscription. + * @property {string} resourceGroup The azure resource group name. + * @property {string} accountName The azure account name. + */ + constructor() { + } + + /** + * Defines the metadata of AzureAccountInfoObject + * + * @returns {object} metadata of AzureAccountInfoObject + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureAccountInfoObject', + type: { + name: 'Composite', + className: 'AzureAccountInfoObject', + modelProperties: { + azureSubscriptionId: { + required: true, + serializedName: 'azureSubscriptionId', + type: { + name: 'String' + } + }, + resourceGroup: { + required: true, + serializedName: 'resourceGroup', + type: { + name: 'String' + } + }, + accountName: { + required: true, + serializedName: 'accountName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AzureAccountInfoObject; diff --git a/lib/services/luis/authoring/lib/models/endpointInfo.js b/lib/services/luis/authoring/lib/models/endpointInfo.js index 1adc49815f..b297b86e6d 100644 --- a/lib/services/luis/authoring/lib/models/endpointInfo.js +++ b/lib/services/luis/authoring/lib/models/endpointInfo.js @@ -26,6 +26,7 @@ class EndpointInfo { * published to. * @property {string} [assignedEndpointKey] The endpoint key. * @property {string} [endpointRegion] The endpoint's region. + * @property {string} [failedRegions] Regions where publishing failed. * @property {string} [publishedDateTime] Timestamp when was last published. */ constructor() { @@ -87,6 +88,13 @@ class EndpointInfo { name: 'String' } }, + failedRegions: { + required: false, + serializedName: 'failedRegions', + type: { + name: 'String' + } + }, publishedDateTime: { required: false, serializedName: 'publishedDateTime', diff --git a/lib/services/luis/authoring/lib/models/exampleLabelObject.js b/lib/services/luis/authoring/lib/models/exampleLabelObject.js index f7027e948c..5794f1c8d5 100644 --- a/lib/services/luis/authoring/lib/models/exampleLabelObject.js +++ b/lib/services/luis/authoring/lib/models/exampleLabelObject.js @@ -18,9 +18,9 @@ class ExampleLabelObject { /** * Create a ExampleLabelObject. * @property {string} [text] The sample's utterance. - * @property {array} [entityLabels] The idenfied entities within the + * @property {array} [entityLabels] The identified entities within the * utterance. - * @property {string} [intentName] The idenfitied intent representing the + * @property {string} [intentName] The identified intent representing the * utterance. */ constructor() { diff --git a/lib/services/luis/authoring/lib/models/index.d.ts b/lib/services/luis/authoring/lib/models/index.d.ts index 6e54d47206..3bad6fe75e 100644 --- a/lib/services/luis/authoring/lib/models/index.d.ts +++ b/lib/services/luis/authoring/lib/models/index.d.ts @@ -160,7 +160,7 @@ export interface ApplicationSettingUpdateObject { export interface PublishSettingUpdateObject { /** * Setting sentiment analysis as true returns the Sentiment of the input utterance along with the - * resopnse + * response */ sentimentAnalysis?: boolean; /** @@ -182,11 +182,11 @@ export interface ExampleLabelObject { */ text?: string; /** - * The idenfied entities within the utterance. + * The identified entities within the utterance. */ entityLabels?: EntityLabelObject[]; /** - * The idenfitied intent representing the utterance. + * The identified intent representing the utterance. */ intentName?: string; } @@ -1334,6 +1334,10 @@ export interface EndpointInfo { * The endpoint's region. */ endpointRegion?: string; + /** + * Regions where publishing failed. + */ + failedRegions?: string; /** * Timestamp when was last published. */ @@ -1382,7 +1386,7 @@ export interface PublishSettings { id: string; /** * Setting sentiment analysis as true returns the Sentiment of the input utterance along with the - * resopnse + * response */ isSentimentAnalysisEnabled: boolean; /** @@ -1757,6 +1761,24 @@ export interface AppVersionSettingObject { value?: string; } +/** + * Defines the azure account information object. +*/ +export interface AzureAccountInfoObject { + /** + * The id for the azure subscription. + */ + azureSubscriptionId: string; + /** + * The azure resource group name. + */ + resourceGroup: string; + /** + * The azure account name. + */ + accountName: string; +} + export interface HierarchicalChildModelUpdateObject { name?: string; } diff --git a/lib/services/luis/authoring/lib/models/index.js b/lib/services/luis/authoring/lib/models/index.js index 2063beae51..0054ec81d6 100644 --- a/lib/services/luis/authoring/lib/models/index.js +++ b/lib/services/luis/authoring/lib/models/index.js @@ -113,6 +113,7 @@ exports.PatternAnyEntityExtractor = require('./patternAnyEntityExtractor'); exports.PatternRuleInfo = require('./patternRuleInfo'); exports.LabelTextObject = require('./labelTextObject'); exports.AppVersionSettingObject = require('./appVersionSettingObject'); +exports.AzureAccountInfoObject = require('./azureAccountInfoObject'); exports.HierarchicalChildModelUpdateObject = require('./hierarchicalChildModelUpdateObject'); exports.HierarchicalChildModelCreateObject = require('./hierarchicalChildModelCreateObject'); exports.CompositeChildModelCreateObject = require('./compositeChildModelCreateObject'); diff --git a/lib/services/luis/authoring/lib/models/productionOrStagingEndpointInfo.js b/lib/services/luis/authoring/lib/models/productionOrStagingEndpointInfo.js index dbabb69efc..ec3740b9a0 100644 --- a/lib/services/luis/authoring/lib/models/productionOrStagingEndpointInfo.js +++ b/lib/services/luis/authoring/lib/models/productionOrStagingEndpointInfo.js @@ -80,6 +80,13 @@ class ProductionOrStagingEndpointInfo extends models['EndpointInfo'] { name: 'String' } }, + failedRegions: { + required: false, + serializedName: 'failedRegions', + type: { + name: 'String' + } + }, publishedDateTime: { required: false, serializedName: 'publishedDateTime', diff --git a/lib/services/luis/authoring/lib/models/publishSettingUpdateObject.js b/lib/services/luis/authoring/lib/models/publishSettingUpdateObject.js index 6deca9104c..6afaa8f01e 100644 --- a/lib/services/luis/authoring/lib/models/publishSettingUpdateObject.js +++ b/lib/services/luis/authoring/lib/models/publishSettingUpdateObject.js @@ -18,7 +18,7 @@ class PublishSettingUpdateObject { /** * Create a PublishSettingUpdateObject. * @property {boolean} [sentimentAnalysis] Setting sentiment analysis as true - * returns the Sentiment of the input utterance along with the resopnse + * returns the Sentiment of the input utterance along with the response * @property {boolean} [speech] Setting speech as public enables speech * priming in your app * @property {boolean} [spellChecker] Setting spell checker as public enables diff --git a/lib/services/luis/authoring/lib/models/publishSettings.js b/lib/services/luis/authoring/lib/models/publishSettings.js index 45f0fa30e0..2af4911173 100644 --- a/lib/services/luis/authoring/lib/models/publishSettings.js +++ b/lib/services/luis/authoring/lib/models/publishSettings.js @@ -20,7 +20,7 @@ class PublishSettings { * @property {uuid} id The application ID. * @property {boolean} isSentimentAnalysisEnabled Setting sentiment analysis * as true returns the Sentiment of the input utterance along with the - * resopnse + * response * @property {boolean} isSpeechEnabled Setting speech as public enables * speech priming in your app * @property {boolean} isSpellCheckerEnabled Setting spell checker as public diff --git a/lib/services/luis/authoring/lib/operations/apps.js b/lib/services/luis/authoring/lib/operations/apps.js index 4c43862aeb..94bf56443a 100644 --- a/lib/services/luis/authoring/lib/operations/apps.js +++ b/lib/services/luis/authoring/lib/operations/apps.js @@ -349,7 +349,7 @@ function _list(options, callback) { /** * Imports an application to LUIS, the application's structure should be - * included in in the request body. + * included in the request body. * * @param {object} luisApp A LUIS application structure. * @@ -1422,6 +1422,9 @@ function _update(appId, applicationUpdateObject, options, callback) { * * @param {object} [options] Optional Parameters. * + * @param {boolean} [options.force] A flag to indicate whether to force an + * operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1448,6 +1451,7 @@ function _deleteMethod(appId, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let force = (options && options.force !== undefined) ? options.force : false; // Validate try { if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { @@ -1456,6 +1460,9 @@ function _deleteMethod(appId, options, callback) { if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } + if (force !== null && force !== undefined && typeof force !== 'boolean') { + throw new Error('force must be of type boolean.'); + } } catch (error) { return callback(error); } @@ -1465,6 +1472,13 @@ function _deleteMethod(appId, options, callback) { let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'apps/{appId}'; requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + let queryParameters = []; + if (force !== null && force !== undefined) { + queryParameters.push('force=' + encodeURIComponent(force.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1637,7 +1651,7 @@ function _publish(appId, applicationPublishObject, options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 201) { + if (statusCode !== 201 && statusCode !== 207) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -1683,6 +1697,23 @@ function _publish(appId, applicationPublishObject, options, callback) { return callback(deserializationError); } } + // Deserialize Response + if (statusCode === 207) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ProductionOrStagingEndpointInfo']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } return callback(null, result, httpRequest, response); }); @@ -2091,7 +2122,7 @@ function _getPublishSettings(appId, options, callback) { * * @param {boolean} [publishSettingUpdateObject.sentimentAnalysis] Setting * sentiment analysis as true returns the Sentiment of the input utterance - * along with the resopnse + * along with the response * * @param {boolean} [publishSettingUpdateObject.speech] Setting speech as * public enables speech priming in your app @@ -2782,6 +2813,236 @@ function _listAvailableCustomPrebuiltDomainsForCulture(culture, options, callbac }); } +/** + * @summary package - Gets published LUIS application package in binary stream + * GZip format + * + * Packages published LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {uuid} slotName The publishing slot name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _packagePublishedApplicationAsGzip(appId, slotName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { + throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (slotName === null || slotName === undefined || typeof slotName.valueOf() !== 'string' || !msRest.isValidUuid(slotName)) { + throw new Error('slotName cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'package/{appId}/slot/{slotName}/gzip'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + requestUrl = requestUrl.replace('{slotName}', encodeURIComponent(slotName.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + httpRequest.streamedResponse = true; + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(`Unexpected status code: ${statusCode}`); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + if (responseBody !== undefined) parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + + // Create Result + let result = response; + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary package - Gets trained LUIS application package in binary stream + * GZip format + * + * Packages trained LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {string} versionId The version ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _packageTrainedApplicationAsGzip(appId, versionId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { + throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (versionId === null || versionId === undefined || typeof versionId.valueOf() !== 'string') { + throw new Error('versionId cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'package/{appId}/versions/{versionId}/gzip'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + requestUrl = requestUrl.replace('{versionId}', encodeURIComponent(versionId)); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + httpRequest.streamedResponse = true; + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(`Unexpected status code: ${statusCode}`); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + if (responseBody !== undefined) parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + + // Create Result + let result = response; + return callback(null, result, httpRequest, response); + }); +} + /** Class representing a Apps. */ class Apps { /** @@ -2810,6 +3071,8 @@ class Apps { this._listAvailableCustomPrebuiltDomains = _listAvailableCustomPrebuiltDomains; this._addCustomPrebuiltDomain = _addCustomPrebuiltDomain; this._listAvailableCustomPrebuiltDomainsForCulture = _listAvailableCustomPrebuiltDomainsForCulture; + this._packagePublishedApplicationAsGzip = _packagePublishedApplicationAsGzip; + this._packageTrainedApplicationAsGzip = _packageTrainedApplicationAsGzip; } /** @@ -3030,7 +3293,7 @@ class Apps { /** * Imports an application to LUIS, the application's structure should be - * included in in the request body. + * included in the request body. * * @param {object} luisApp A LUIS application structure. * @@ -3096,7 +3359,7 @@ class Apps { /** * Imports an application to LUIS, the application's structure should be - * included in in the request body. + * included in the request body. * * @param {object} luisApp A LUIS application structure. * @@ -3760,6 +4023,9 @@ class Apps { * * @param {object} [options] Optional Parameters. * + * @param {boolean} [options.force] A flag to indicate whether to force an + * operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3790,6 +4056,9 @@ class Apps { * * @param {object} [options] Optional Parameters. * + * @param {boolean} [options.force] A flag to indicate whether to force an + * operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4206,7 +4475,7 @@ class Apps { * * @param {boolean} [publishSettingUpdateObject.sentimentAnalysis] Setting * sentiment analysis as true returns the Sentiment of the input utterance - * along with the resopnse + * along with the response * * @param {boolean} [publishSettingUpdateObject.speech] Setting speech as * public enables speech priming in your app @@ -4249,7 +4518,7 @@ class Apps { * * @param {boolean} [publishSettingUpdateObject.sentimentAnalysis] Setting * sentiment analysis as true returns the Sentiment of the input utterance - * along with the resopnse + * along with the response * * @param {boolean} [publishSettingUpdateObject.speech] Setting speech as * public enables speech priming in your app @@ -4636,6 +4905,188 @@ class Apps { } } + /** + * @summary package - Gets published LUIS application package in binary stream + * GZip format + * + * Packages published LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {uuid} slotName The publishing slot name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + packagePublishedApplicationAsGzipWithHttpOperationResponse(appId, slotName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._packagePublishedApplicationAsGzip(appId, slotName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary package - Gets published LUIS application package in binary stream + * GZip format + * + * Packages published LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {uuid} slotName The publishing slot name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + packagePublishedApplicationAsGzip(appId, slotName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._packagePublishedApplicationAsGzip(appId, slotName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._packagePublishedApplicationAsGzip(appId, slotName, options, optionalCallback); + } + } + + /** + * @summary package - Gets trained LUIS application package in binary stream + * GZip format + * + * Packages trained LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {string} versionId The version ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + packageTrainedApplicationAsGzipWithHttpOperationResponse(appId, versionId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._packageTrainedApplicationAsGzip(appId, versionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary package - Gets trained LUIS application package in binary stream + * GZip format + * + * Packages trained LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {string} versionId The version ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + packageTrainedApplicationAsGzip(appId, versionId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._packageTrainedApplicationAsGzip(appId, versionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._packageTrainedApplicationAsGzip(appId, versionId, options, optionalCallback); + } + } + } module.exports = Apps; diff --git a/lib/services/luis/authoring/lib/operations/azureAccounts.js b/lib/services/luis/authoring/lib/operations/azureAccounts.js new file mode 100644 index 0000000000..c4c85f6166 --- /dev/null +++ b/lib/services/luis/authoring/lib/operations/azureAccounts.js @@ -0,0 +1,995 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * @summary apps - Assign a LUIS azure account to an application + * + * Assigns an azure account to the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _assignToApp(appId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let azureAccountInfoObject = (options && options.azureAccountInfoObject !== undefined) ? options.azureAccountInfoObject : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { + throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'apps/{appId}/azureaccounts'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (azureAccountInfoObject !== null && azureAccountInfoObject !== undefined) { + let requestModelMapper = new client.models['AzureAccountInfoObject']().mapper(); + requestModel = client.serialize(requestModelMapper, azureAccountInfoObject, 'azureAccountInfoObject'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(azureAccountInfoObject, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationStatus']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary apps - Get LUIS azure accounts assigned to the application + * + * Gets the LUIS azure accounts assigned to the application for the user using + * his ARM token. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getAssigned(appId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { + throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'apps/{appId}/azureaccounts'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AzureAccountInfoObjectElementType', + type: { + name: 'Composite', + className: 'AzureAccountInfoObject' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary apps - Removes an assigned LUIS azure account from an application + * + * Removes assigned azure account from the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _removeFromApp(appId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let azureAccountInfoObject = (options && options.azureAccountInfoObject !== undefined) ? options.azureAccountInfoObject : undefined; + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + if (appId === null || appId === undefined || typeof appId.valueOf() !== 'string' || !msRest.isValidUuid(appId)) { + throw new Error('appId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'apps/{appId}/azureaccounts'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + requestUrl = requestUrl.replace('{appId}', encodeURIComponent(appId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (azureAccountInfoObject !== null && azureAccountInfoObject !== undefined) { + let requestModelMapper = new client.models['AzureAccountInfoObject']().mapper(); + requestModel = client.serialize(requestModelMapper, azureAccountInfoObject, 'azureAccountInfoObject'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(azureAccountInfoObject, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationStatus']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary user - Get LUIS azure accounts + * + * Gets the LUIS azure accounts for the user using his ARM token. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _getUserLUISAccounts(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (this.client.endpoint === null || this.client.endpoint === undefined || typeof this.client.endpoint.valueOf() !== 'string') { + throw new Error('this.client.endpoint cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'azureaccounts'; + requestUrl = requestUrl.replace('{Endpoint}', this.client.endpoint); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AzureAccountInfoObjectElementType', + type: { + name: 'Composite', + className: 'AzureAccountInfoObject' + } + } + } + }; + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AzureAccounts. */ +class AzureAccounts { + /** + * Create a AzureAccounts. + * @param {LUISAuthoringClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._assignToApp = _assignToApp; + this._getAssigned = _getAssigned; + this._removeFromApp = _removeFromApp; + this._getUserLUISAccounts = _getUserLUISAccounts; + } + + /** + * @summary apps - Assign a LUIS azure account to an application + * + * Assigns an azure account to the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + assignToAppWithHttpOperationResponse(appId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._assignToApp(appId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary apps - Assign a LUIS azure account to an application + * + * Assigns an azure account to the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationStatus} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + assignToApp(appId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._assignToApp(appId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._assignToApp(appId, options, optionalCallback); + } + } + + /** + * @summary apps - Get LUIS azure accounts assigned to the application + * + * Gets the LUIS azure accounts assigned to the application for the user using + * his ARM token. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getAssignedWithHttpOperationResponse(appId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getAssigned(appId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary apps - Get LUIS azure accounts assigned to the application + * + * Gets the LUIS azure accounts assigned to the application for the user using + * his ARM token. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getAssigned(appId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getAssigned(appId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getAssigned(appId, options, optionalCallback); + } + } + + /** + * @summary apps - Removes an assigned LUIS azure account from an application + * + * Removes assigned azure account from the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + removeFromAppWithHttpOperationResponse(appId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._removeFromApp(appId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary apps - Removes an assigned LUIS azure account from an application + * + * Removes assigned azure account from the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationStatus} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + removeFromApp(appId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._removeFromApp(appId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._removeFromApp(appId, options, optionalCallback); + } + } + + /** + * @summary user - Get LUIS azure accounts + * + * Gets the LUIS azure accounts for the user using his ARM token. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getUserLUISAccountsWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getUserLUISAccounts(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary user - Get LUIS azure accounts + * + * Gets the LUIS azure accounts for the user using his ARM token. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {array} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + getUserLUISAccounts(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._getUserLUISAccounts(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getUserLUISAccounts(options, optionalCallback); + } + } + +} + +module.exports = AzureAccounts; diff --git a/lib/services/luis/authoring/lib/operations/examples.js b/lib/services/luis/authoring/lib/operations/examples.js index a2775d143d..43e6ed39c1 100644 --- a/lib/services/luis/authoring/lib/operations/examples.js +++ b/lib/services/luis/authoring/lib/operations/examples.js @@ -25,10 +25,10 @@ const WebResource = msRest.WebResource; * * @param {string} [exampleLabelObject.text] The sample's utterance. * - * @param {array} [exampleLabelObject.entityLabels] The idenfied entities + * @param {array} [exampleLabelObject.entityLabels] The identified entities * within the utterance. * - * @param {string} [exampleLabelObject.intentName] The idenfitied intent + * @param {string} [exampleLabelObject.intentName] The identified intent * representing the utterance. * * @param {object} [options] Optional Parameters. @@ -716,10 +716,10 @@ class Examples { * * @param {string} [exampleLabelObject.text] The sample's utterance. * - * @param {array} [exampleLabelObject.entityLabels] The idenfied entities + * @param {array} [exampleLabelObject.entityLabels] The identified entities * within the utterance. * - * @param {string} [exampleLabelObject.intentName] The idenfitied intent + * @param {string} [exampleLabelObject.intentName] The identified intent * representing the utterance. * * @param {object} [options] Optional Parameters. @@ -759,10 +759,10 @@ class Examples { * * @param {string} [exampleLabelObject.text] The sample's utterance. * - * @param {array} [exampleLabelObject.entityLabels] The idenfied entities + * @param {array} [exampleLabelObject.entityLabels] The identified entities * within the utterance. * - * @param {string} [exampleLabelObject.intentName] The idenfitied intent + * @param {string} [exampleLabelObject.intentName] The identified intent * representing the utterance. * * @param {object} [options] Optional Parameters. diff --git a/lib/services/luis/authoring/lib/operations/index.d.ts b/lib/services/luis/authoring/lib/operations/index.d.ts index 5318661967..73414afd2f 100644 --- a/lib/services/luis/authoring/lib/operations/index.d.ts +++ b/lib/services/luis/authoring/lib/operations/index.d.ts @@ -524,10 +524,10 @@ export interface Examples { * * @param {string} [exampleLabelObject.text] The sample's utterance. * - * @param {array} [exampleLabelObject.entityLabels] The idenfied entities + * @param {array} [exampleLabelObject.entityLabels] The identified entities * within the utterance. * - * @param {string} [exampleLabelObject.intentName] The idenfitied intent + * @param {string} [exampleLabelObject.intentName] The identified intent * representing the utterance. * * @param {object} [options] Optional Parameters. @@ -555,10 +555,10 @@ export interface Examples { * * @param {string} [exampleLabelObject.text] The sample's utterance. * - * @param {array} [exampleLabelObject.entityLabels] The idenfied entities + * @param {array} [exampleLabelObject.entityLabels] The identified entities * within the utterance. * - * @param {string} [exampleLabelObject.intentName] The idenfitied intent + * @param {string} [exampleLabelObject.intentName] The identified intent * representing the utterance. * * @param {object} [options] Optional Parameters. @@ -8264,7 +8264,7 @@ export interface Apps { /** * Imports an application to LUIS, the application's structure should be - * included in in the request body. + * included in the request body. * * @param {object} luisApp A LUIS application structure. * @@ -8318,7 +8318,7 @@ export interface Apps { /** * Imports an application to LUIS, the application's structure should be - * included in in the request body. + * included in the request body. * * @param {object} luisApp A LUIS application structure. * @@ -8778,6 +8778,9 @@ export interface Apps { * * @param {object} [options] Optional Parameters. * + * @param {boolean} [options.force] A flag to indicate whether to force an + * operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -8787,7 +8790,7 @@ export interface Apps { * * @reject {Error|ServiceError} - The error object. */ - deleteMethodWithHttpOperationResponse(appId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(appId: string, options?: { force? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Deletes an application. @@ -8796,6 +8799,9 @@ export interface Apps { * * @param {object} [options] Optional Parameters. * + * @param {boolean} [options.force] A flag to indicate whether to force an + * operation. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -8821,9 +8827,9 @@ export interface Apps { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - deleteMethod(appId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(appId: string, options?: { force? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; deleteMethod(appId: string, callback: ServiceCallback): void; - deleteMethod(appId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + deleteMethod(appId: string, options: { force? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -9089,7 +9095,7 @@ export interface Apps { * * @param {boolean} [publishSettingUpdateObject.sentimentAnalysis] Setting * sentiment analysis as true returns the Sentiment of the input utterance - * along with the resopnse + * along with the response * * @param {boolean} [publishSettingUpdateObject.speech] Setting speech as * public enables speech priming in your app @@ -9120,7 +9126,7 @@ export interface Apps { * * @param {boolean} [publishSettingUpdateObject.sentimentAnalysis] Setting * sentiment analysis as true returns the Sentiment of the input utterance - * along with the resopnse + * along with the response * * @param {boolean} [publishSettingUpdateObject.speech] Setting speech as * public enables speech priming in your app @@ -9382,6 +9388,134 @@ export interface Apps { listAvailableCustomPrebuiltDomainsForCulture(culture: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; listAvailableCustomPrebuiltDomainsForCulture(culture: string, callback: ServiceCallback): void; listAvailableCustomPrebuiltDomainsForCulture(culture: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary package - Gets published LUIS application package in binary stream + * GZip format + * + * Packages published LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {uuid} slotName The publishing slot name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + packagePublishedApplicationAsGzipWithHttpOperationResponse(appId: string, slotName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary package - Gets published LUIS application package in binary stream + * GZip format + * + * Packages published LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {uuid} slotName The publishing slot name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Object} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + packagePublishedApplicationAsGzip(appId: string, slotName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + packagePublishedApplicationAsGzip(appId: string, slotName: string, callback: ServiceCallback): void; + packagePublishedApplicationAsGzip(appId: string, slotName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary package - Gets trained LUIS application package in binary stream + * GZip format + * + * Packages trained LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {string} versionId The version ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + packageTrainedApplicationAsGzipWithHttpOperationResponse(appId: string, versionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary package - Gets trained LUIS application package in binary stream + * GZip format + * + * Packages trained LUIS application as GZip. + * + * @param {uuid} appId The application ID. + * + * @param {string} versionId The version ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Object} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Object} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + packageTrainedApplicationAsGzip(appId: string, versionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + packageTrainedApplicationAsGzip(appId: string, versionId: string, callback: ServiceCallback): void; + packageTrainedApplicationAsGzip(appId: string, versionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -11080,3 +11214,292 @@ export interface Settings { update(appId: string, versionId: string, listOfAppVersionSettingObject: models.AppVersionSettingObject, callback: ServiceCallback): void; update(appId: string, versionId: string, listOfAppVersionSettingObject: models.AppVersionSettingObject, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * AzureAccounts + * __NOTE__: An instance of this class is automatically created for an + * instance of the LUISAuthoringClient. + */ +export interface AzureAccounts { + + + /** + * @summary apps - Assign a LUIS azure account to an application + * + * Assigns an azure account to the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + assignToAppWithHttpOperationResponse(appId: string, options?: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary apps - Assign a LUIS azure account to an application + * + * Assigns an azure account to the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationStatus} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationStatus} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + assignToApp(appId: string, options?: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }): Promise; + assignToApp(appId: string, callback: ServiceCallback): void; + assignToApp(appId: string, options: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary apps - Get LUIS azure accounts assigned to the application + * + * Gets the LUIS azure accounts assigned to the application for the user using + * his ARM token. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getAssignedWithHttpOperationResponse(appId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary apps - Get LUIS azure accounts assigned to the application + * + * Gets the LUIS azure accounts assigned to the application for the user using + * his ARM token. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getAssigned(appId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getAssigned(appId: string, callback: ServiceCallback): void; + getAssigned(appId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary apps - Removes an assigned LUIS azure account from an application + * + * Removes assigned azure account from the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + removeFromAppWithHttpOperationResponse(appId: string, options?: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary apps - Removes an assigned LUIS azure account from an application + * + * Removes assigned azure account from the application. + * + * @param {uuid} appId The application ID. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.azureAccountInfoObject] The azure account + * information object. + * + * @param {string} options.azureAccountInfoObject.azureSubscriptionId The id + * for the azure subscription. + * + * @param {string} options.azureAccountInfoObject.resourceGroup The azure + * resource group name. + * + * @param {string} options.azureAccountInfoObject.accountName The azure account + * name. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {OperationStatus} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {OperationStatus} [result] - The deserialized result object if an error did not occur. + * See {@link OperationStatus} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + removeFromApp(appId: string, options?: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }): Promise; + removeFromApp(appId: string, callback: ServiceCallback): void; + removeFromApp(appId: string, options: { azureAccountInfoObject? : models.AzureAccountInfoObject, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary user - Get LUIS azure accounts + * + * Gets the LUIS azure accounts for the user using his ARM token. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getUserLUISAccountsWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary user - Get LUIS azure accounts + * + * Gets the LUIS azure accounts for the user using his ARM token. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Array} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Array} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + getUserLUISAccounts(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getUserLUISAccounts(callback: ServiceCallback): void; + getUserLUISAccounts(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/luis/authoring/lib/operations/index.js b/lib/services/luis/authoring/lib/operations/index.js index 3cefaa62cb..f19b125d25 100644 --- a/lib/services/luis/authoring/lib/operations/index.js +++ b/lib/services/luis/authoring/lib/operations/index.js @@ -23,3 +23,4 @@ exports.Train = require('./train'); exports.Permissions = require('./permissions'); exports.Pattern = require('./pattern'); exports.Settings = require('./settings'); +exports.AzureAccounts = require('./azureAccounts'); diff --git a/lib/services/luis/authoring/package.json b/lib/services/luis/authoring/package.json index 42f2b42fbc..6b790e1478 100644 --- a/lib/services/luis/authoring/package.json +++ b/lib/services/luis/authoring/package.json @@ -2,9 +2,9 @@ "name": "azure-cognitiveservices-luis-authoring", "author": "Microsoft Corporation", "description": "LUISAuthoringClient Library with typescript type definitions for node", - "version": "2.0.0", + "version": "2.1.0", "dependencies": { - "ms-rest": "^2.3.3" + "ms-rest": "^2.5.0" }, "keywords": [ "node", @@ -20,5 +20,8 @@ }, "bugs": { "url": "https://github.com/azure/azure-sdk-for-node/issues" + }, + "scripts": { + "postinstall": "node .scripts/postinstall.js" } }