From ea1e704c44ecb79b559af175d8bc9fa3f9ec74ae Mon Sep 17 00:00:00 2001 From: Partik SIngh Date: Thu, 22 Jun 2023 20:08:14 +0530 Subject: [PATCH 1/4] Added linode data extractor Signed-off-by: Partik SIngh --- generator/generators/linode/generator.ts | 132 +++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 generator/generators/linode/generator.ts diff --git a/generator/generators/linode/generator.ts b/generator/generators/linode/generator.ts new file mode 100644 index 00000000..5693489d --- /dev/null +++ b/generator/generators/linode/generator.ts @@ -0,0 +1,132 @@ +import { SyntaxKind } from 'typescript'; +// import { getAST } from '../../parsers/linode/parser'; + +interface SDKClassData { + pkgName: string; + fileName: string; + functionName: string; + SDKFunctionName: string; + params: param[]; + returnType: string; + client: string; +} + +interface FunctionData { + functionName: string; + SDKFunctionName: string; + params: param[]; +} + +interface ClassData { + className: string; + functions: FunctionData[]; + serviceName: string; +} + +interface param { + name: string; + type: string; + typeName: string; + optional: boolean; +} + +export function extractSDKData(sdkAst, serviceClass) { + let methods: FunctionData[] = []; + const functions = []; + + Object.keys(serviceClass).map((key, index) => { + functions.push(serviceClass[key].split(' ')[2]); + }); + + sdkAst.map(method => { + const methodName = method.name.escapedText; + if (methodName && functions.includes(methodName)) { + let name; + Object.keys(serviceClass).map((key, index) => { + if (serviceClass.split(' ')[2] === methodName) { + name = key; + } + }); + + const parameters = []; + + const methodParameters = method.type.parameters; + + methodParameters.map(param => { + if (param.name.excapedText !== 'callback') { + const parameter: param = { + name: param.name.escapedText, + optional: param.questionToken ? true : false, + type: SyntaxKind[param.type.kind], + typeName: null, + }; + // common type + if (param.type.typeName) { + parameter.typeName = param.type.typeName.excapedText; + } + parameters.push(parameter); + } + }); + + methods.push({ + functionName: name.toString(), + SDKFunctionName: methodName, + params: parameters, + }); + } + }); + + const classData: ClassData = { + className: '', + functions: methods, + serviceName: null, + }; + + return classData; +} + +export async function generateLinodeClass(serviceClass, serviceName) { + let methods: SDKClassData[] = []; + if (serviceClass == null) return; + Object.keys(serviceClass).map((key, index) => { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null, + }); + }); + + const files = Array.from(new Set(methods.map(method => method.fileName))); + + const sdkFiles = files.map(file => { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(method => method.fileName === file) + .map(method => method.SDKFunctionName), + }; + }); + console.log(sdkFiles); + + sdkFiles.map(async file => { + // getAST(file).then(async result => { + // const sdkAst = result; + // try { + // const classData: ClassData = extractSDKData( + // sdkAst, + // serviceClass + // ); + // classData.serviceName = serviceName; + // } catch (e) { + // console.error(e); + // } + // }); + }); +} From 7c74be529091608e950e04cf78ea96ce7a59097f Mon Sep 17 00:00:00 2001 From: Partik SIngh Date: Fri, 23 Jun 2023 22:45:39 +0530 Subject: [PATCH 2/4] Changed Data Extractor Signed-off-by: Partik SIngh --- .../AWS/appServices/aws-paaS.js | 557 +++++------ .../artificialinteligence/aws-translation.js | 189 ++-- .../AWS/compute/aws-computeInstance.js | 321 +++--- .../AWS/compute/aws-container.js | 156 +-- .../AWS/compute/aws-kubernetes.js | 354 +++---- .../AWS/database/aws-RDBMS.js | 222 +++-- .../AWS/database/aws-noSql.js | 222 +++-- .../AWS/database/aws-noSqlIndexed.js | 321 +++--- .../AWS/management/aws-keyManagement.js | 189 ++-- .../AWS/management/aws-monitoring.js | 156 +-- .../AWS/management/aws-notificationService.js | 288 +++--- .../generatedClasses/AWS/network/aws-DNS.js | 156 +-- .../AWS/network/aws-loadBalancer.js | 189 ++-- .../generatedClasses/AWS/security/aws-IAM.js | 189 ++-- .../AWS/storage/aws-archivalStorage.js | 189 ++-- .../AWS/storage/aws-blockStorage.js | 156 +-- .../AWS/storage/aws-storageBucket.js | 187 ++-- .../Azure/appServices/azure-paaS.js | 646 +++++------- .../Azure/compute/azure-computeInstance.js | 308 +++--- .../Azure/compute/azure-container.js | 218 ++-- .../Azure/compute/azure-kubernetes.js | 544 ++++------ .../Azure/database/azure-RDBMS.js | 330 +++---- .../Azure/database/azure-noSql.js | 305 +++--- .../Azure/management/azure-keyManagement.js | 279 +++--- .../Azure/management/azure-monitoring.js | 264 ++--- .../Azure/network/azure-DNS.js | 228 ++--- .../Azure/network/azure-loadBalancer.js | 276 ++---- .../Azure/storage/azure-blockStorage.js | 259 ++--- .../Azure/storage/azure-storageBucket.js | 184 ++-- .../DO/compute/do-computeInstance.js | 139 ++- .../DO/compute/do-kubernetes.js | 247 +++-- .../generatedClasses/DO/database/do-RDBMS.js | 139 ++- .../generatedClasses/DO/database/do-noSql.js | 139 ++- .../DO/management/do-keyManagement.js | 137 ++- .../generatedClasses/DO/network/do-DNS.js | 175 ++-- .../DO/network/do-loadBalancer.js | 126 ++- .../DO/storage/do-blockStorage.js | 126 ++- .../artificialinteligence/gcp-translation.js | 179 ++-- .../googleCloud/compute/gcp-kubernetes.js | 311 +++--- .../googleCloud/database/gcp-RDBMS.js | 232 +++-- .../googleCloud/database/gcp-noSql.js | 131 ++- .../management/gcp-keyManagement.js | 181 ++-- .../googleCloud/management/gcp-monitoring.js | 197 ++-- .../management/gcp-notificationService.js | 280 +++--- .../googleCloud/network/gcp-DNS.js | 175 ++-- .../storage/gcp-archivalStorage.js | 186 ++-- .../googleCloud/storage/gcp-storageBucket.js | 186 ++-- generator/generators/aws/generator.js | 356 +++---- generator/generators/azure/generator.js | 437 +++----- generator/generators/do/generator.js | 350 +++---- generator/generators/googleCloud/generator.js | 934 +++++++----------- generator/generators/lib/aws/awsHelper.js | 52 +- generator/generators/lib/azure/azureHelper.js | 89 +- .../generators/lib/googleCloud/gcpHelper.js | 95 +- generator/generators/lib/helper.js | 55 +- generator/generators/linode/generator.js | 144 +++ generator/generators/linode/generator.ts | 34 +- generator/main.js | 41 +- generator/main.ts | 20 +- generator/node-cloud.yml | 701 ++++++------- generator/parsers/aws/parser.js | 250 ++--- generator/parsers/azure/parser.js | 252 ++--- generator/parsers/do/parser.js | 251 ++--- generator/parsers/googleCloud/parser.js | 296 ++---- generator/parsers/linode/parser.js | 98 ++ generator/parsers/linode/parser.ts | 61 ++ generator/transformers/aws/transformer.js | 561 ++++------- generator/transformers/azure/transformer.js | 594 ++++------- generator/transformers/do/transformer.js | 593 ++++------- .../googleCloud/classBasedTransformer.js | 680 +++++-------- .../googleCloud/clientBasedTransformer.js | 656 ++++-------- 71 files changed, 8059 insertions(+), 10709 deletions(-) create mode 100644 generator/generators/linode/generator.js create mode 100644 generator/parsers/linode/parser.js create mode 100644 generator/parsers/linode/parser.ts diff --git a/generator/generatedClasses/AWS/appServices/aws-paaS.js b/generator/generatedClasses/AWS/appServices/aws-paaS.js index f6eee331..b1acbd1e 100644 --- a/generator/generatedClasses/AWS/appServices/aws-paaS.js +++ b/generator/generatedClasses/AWS/appServices/aws-paaS.js @@ -4,280 +4,287 @@ * @category AWS */ class AWS_PaaS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._elasticBeanstalk = new this._AWS.ElasticBeanstalk({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the checkDNSAvailability function of ElasticBeanstalk - * @param {CheckDNSAvailabilityMessage} params - Data required for checkDNSAvailability - * @returns {Promise} - */ - checkDNSAvailability(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.checkDNSAvailability(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the composeEnvironments function of ElasticBeanstalk - * @param {ComposeEnvironmentsMessage} params - Data required for composeEnvironments - * @returns {Promise} - */ - composeEnvironments(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.composeEnvironments(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createApplication function of ElasticBeanstalk - * @param {CreateApplicationMessage} params - Data required for createApplication - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createApplication(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createConfigurationTemplate function of ElasticBeanstalk - * @param {CreateConfigurationTemplateMessage} params - Data required for createConfigurationTemplate - * @returns {Promise} - */ - createConfigTemplate(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createConfigurationTemplate( - params, - (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - } - ); - }); - } - /** - * Trigers the createEnvironment function of ElasticBeanstalk - * @param {CreateEnvironmentMessage} params - Data required for createEnvironment - * @returns {Promise} - */ - createEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createEnvironment(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createStorageLocation function of ElasticBeanstalk - * @returns {Promise} - */ - createStorageLocation() { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createStorageLocation((error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteApplication function of ElasticBeanstalk - * @param {DeleteApplicationMessage} params - Data required for deleteApplication - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.deleteApplication(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteConfigurationTemplate function of ElasticBeanstalk - * @param {DeleteConfigurationTemplateMessage} params - Data required for deleteConfigurationTemplate - * @returns {Promise} - */ - deleteConfigTemplate(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.deleteConfigurationTemplate( - params, - (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - } - ); - }); - } - /** - * Trigers the describeAccountAttributes function of ElasticBeanstalk - * @returns {Promise} - */ - describeAccountAttributes() { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeAccountAttributes((error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeApplications function of ElasticBeanstalk - * @param {DescribeApplicationsMessage} params - Data required for describeApplications - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeApplications(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeConfigurationSettings function of ElasticBeanstalk - * @param {DescribeConfigurationSettingsMessage} params - Data required for describeConfigurationSettings - * @returns {Promise} - */ - describeConfigSettings(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeConfigurationSettings( - params, - (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - } - ); - }); - } - /** - * Trigers the listPlatformVersions function of ElasticBeanstalk - * @param {ListPlatformVersionsRequest} params - Data required for listPlatformVersions - * @returns {Promise} - */ - listVersions(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.listPlatformVersions(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the restartAppServer function of ElasticBeanstalk - * @param {RestartAppServerMessage} params - Data required for restartAppServer - * @returns {Promise} - */ - restart(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.restartAppServer(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the terminateEnvironment function of ElasticBeanstalk - * @param {TerminateEnvironmentMessage} params - Data required for terminateEnvironment - * @returns {Promise} - */ - terminateEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.terminateEnvironment(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateApplication function of ElasticBeanstalk - * @param {UpdateApplicationMessage} params - Data required for updateApplication - * @returns {Promise} - */ - update(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.updateApplication(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateEnvironment function of ElasticBeanstalk - * @param {UpdateEnvironmentMessage} params - Data required for updateEnvironment - * @returns {Promise} - */ - updateEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.updateEnvironment(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._elasticBeanstalk = new this._AWS.ElasticBeanstalk({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the checkDNSAvailability function of ElasticBeanstalk + * @param {CheckDNSAvailabilityMessage} params - Data required for checkDNSAvailability + * @returns {Promise} + */ + checkDNSAvailability(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.checkDNSAvailability(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the composeEnvironments function of ElasticBeanstalk + * @param {ComposeEnvironmentsMessage} params - Data required for composeEnvironments + * @returns {Promise} + */ + composeEnvironments(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.composeEnvironments(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createApplication function of ElasticBeanstalk + * @param {CreateApplicationMessage} params - Data required for createApplication + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createApplication(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createConfigurationTemplate function of ElasticBeanstalk + * @param {CreateConfigurationTemplateMessage} params - Data required for createConfigurationTemplate + * @returns {Promise} + */ + createConfigTemplate(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createConfigurationTemplate(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createEnvironment function of ElasticBeanstalk + * @param {CreateEnvironmentMessage} params - Data required for createEnvironment + * @returns {Promise} + */ + createEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createEnvironment(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createStorageLocation function of ElasticBeanstalk + * @returns {Promise} + */ + createStorageLocation() { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createStorageLocation((error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteApplication function of ElasticBeanstalk + * @param {DeleteApplicationMessage} params - Data required for deleteApplication + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.deleteApplication(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteConfigurationTemplate function of ElasticBeanstalk + * @param {DeleteConfigurationTemplateMessage} params - Data required for deleteConfigurationTemplate + * @returns {Promise} + */ + deleteConfigTemplate(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.deleteConfigurationTemplate(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeAccountAttributes function of ElasticBeanstalk + * @returns {Promise} + */ + describeAccountAttributes() { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeAccountAttributes((error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeApplications function of ElasticBeanstalk + * @param {DescribeApplicationsMessage} params - Data required for describeApplications + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeApplications(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeConfigurationSettings function of ElasticBeanstalk + * @param {DescribeConfigurationSettingsMessage} params - Data required for describeConfigurationSettings + * @returns {Promise} + */ + describeConfigSettings(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeConfigurationSettings(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listPlatformVersions function of ElasticBeanstalk + * @param {ListPlatformVersionsRequest} params - Data required for listPlatformVersions + * @returns {Promise} + */ + listVersions(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.listPlatformVersions(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the restartAppServer function of ElasticBeanstalk + * @param {RestartAppServerMessage} params - Data required for restartAppServer + * @returns {Promise} + */ + restart(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.restartAppServer(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the terminateEnvironment function of ElasticBeanstalk + * @param {TerminateEnvironmentMessage} params - Data required for terminateEnvironment + * @returns {Promise} + */ + terminateEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.terminateEnvironment(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateApplication function of ElasticBeanstalk + * @param {UpdateApplicationMessage} params - Data required for updateApplication + * @returns {Promise} + */ + update(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.updateApplication(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateEnvironment function of ElasticBeanstalk + * @param {UpdateEnvironmentMessage} params - Data required for updateEnvironment + * @returns {Promise} + */ + updateEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.updateEnvironment(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_PaaS; diff --git a/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js b/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js index 978c2249..0c4caf7b 100644 --- a/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js +++ b/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js @@ -4,97 +4,102 @@ * @category AWS */ class AWS_Translation { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._translate = new this._AWS.Translate({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the deleteTerminology function of Translate - * @param {DeleteTerminologyRequest} params - Data required for deleteTerminology - * @returns {Promise} - */ - deleteGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.deleteTerminology(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getTerminology function of Translate - * @param {GetTerminologyRequest} params - Data required for getTerminology - * @returns {Promise} - */ - getGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.getTerminology(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the importTerminology function of Translate - * @param {ImportTerminologyRequest} params - Data required for importTerminology - * @returns {Promise} - */ - createGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.importTerminology(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the startTextTranslationJob function of Translate - * @param {StartTextTranslationJobRequest} params - Data required for startTextTranslationJob - * @returns {Promise} - */ - batchTranslate(params) { - return new Promise((resolve, reject) => { - this._translate.startTextTranslationJob(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the translateText function of Translate - * @param {TranslateTextRequest} params - Data required for translateText - * @returns {Promise} - */ - translate(params) { - return new Promise((resolve, reject) => { - this._translate.translateText(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._translate = new this._AWS.Translate({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the deleteTerminology function of Translate + * @param {DeleteTerminologyRequest} params - Data required for deleteTerminology + * @returns {Promise} + */ + deleteGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.deleteTerminology(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getTerminology function of Translate + * @param {GetTerminologyRequest} params - Data required for getTerminology + * @returns {Promise} + */ + getGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.getTerminology(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the importTerminology function of Translate + * @param {ImportTerminologyRequest} params - Data required for importTerminology + * @returns {Promise} + */ + createGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.importTerminology(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the startTextTranslationJob function of Translate + * @param {StartTextTranslationJobRequest} params - Data required for startTextTranslationJob + * @returns {Promise} + */ + batchTranslate(params) { + return new Promise((resolve, reject) => { + this._translate.startTextTranslationJob(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the translateText function of Translate + * @param {TranslateTextRequest} params - Data required for translateText + * @returns {Promise} + */ + translate(params) { + return new Promise((resolve, reject) => { + this._translate.translateText(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Translation; diff --git a/generator/generatedClasses/AWS/compute/aws-computeInstance.js b/generator/generatedClasses/AWS/compute/aws-computeInstance.js index e3010568..569ca6fe 100644 --- a/generator/generatedClasses/AWS/compute/aws-computeInstance.js +++ b/generator/generatedClasses/AWS/compute/aws-computeInstance.js @@ -4,161 +4,170 @@ * @category AWS */ class AWS_ComputeInstance { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eC2 = new this._AWS.EC2({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTags function of EC2 - * @param {CreateTagsRequest} params - Data required for createTags - * @returns {Promise} - */ - addTags(params) { - return new Promise((resolve, reject) => { - this._eC2.createTags(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeInstances function of EC2 - * @param {DescribeInstancesRequest} params - Data required for describeInstances - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eC2.describeInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the monitorInstances function of EC2 - * @param {MonitorInstancesRequest} params - Data required for monitorInstances - * @returns {Promise} - */ - monitor(params) { - return new Promise((resolve, reject) => { - this._eC2.monitorInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the rebootInstances function of EC2 - * @param {RebootInstancesRequest} params - Data required for rebootInstances - * @returns {Promise} - */ - reboot(params) { - return new Promise((resolve, reject) => { - this._eC2.rebootInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the runInstances function of EC2 - * @param {RunInstancesRequest} params - Data required for runInstances - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eC2.runInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the startInstances function of EC2 - * @param {StartInstancesRequest} params - Data required for startInstances - * @returns {Promise} - */ - start(params) { - return new Promise((resolve, reject) => { - this._eC2.startInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the stopInstances function of EC2 - * @param {StopInstancesRequest} params - Data required for stopInstances - * @returns {Promise} - */ - stop(params) { - return new Promise((resolve, reject) => { - this._eC2.stopInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the terminateInstances function of EC2 - * @param {TerminateInstancesRequest} params - Data required for terminateInstances - * @returns {Promise} - */ - destroy(params) { - return new Promise((resolve, reject) => { - this._eC2.terminateInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the unmonitorInstances function of EC2 - * @param {UnmonitorInstancesRequest} params - Data required for unmonitorInstances - * @returns {Promise} - */ - unmonitor(params) { - return new Promise((resolve, reject) => { - this._eC2.unmonitorInstances(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eC2 = new this._AWS.EC2({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createTags function of EC2 + * @param {CreateTagsRequest} params - Data required for createTags + * @returns {Promise} + */ + addTags(params) { + return new Promise((resolve, reject) => { + this._eC2.createTags(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeInstances function of EC2 + * @param {DescribeInstancesRequest} params - Data required for describeInstances + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eC2.describeInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the monitorInstances function of EC2 + * @param {MonitorInstancesRequest} params - Data required for monitorInstances + * @returns {Promise} + */ + monitor(params) { + return new Promise((resolve, reject) => { + this._eC2.monitorInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the rebootInstances function of EC2 + * @param {RebootInstancesRequest} params - Data required for rebootInstances + * @returns {Promise} + */ + reboot(params) { + return new Promise((resolve, reject) => { + this._eC2.rebootInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the runInstances function of EC2 + * @param {RunInstancesRequest} params - Data required for runInstances + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eC2.runInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the startInstances function of EC2 + * @param {StartInstancesRequest} params - Data required for startInstances + * @returns {Promise} + */ + start(params) { + return new Promise((resolve, reject) => { + this._eC2.startInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the stopInstances function of EC2 + * @param {StopInstancesRequest} params - Data required for stopInstances + * @returns {Promise} + */ + stop(params) { + return new Promise((resolve, reject) => { + this._eC2.stopInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the terminateInstances function of EC2 + * @param {TerminateInstancesRequest} params - Data required for terminateInstances + * @returns {Promise} + */ + destroy(params) { + return new Promise((resolve, reject) => { + this._eC2.terminateInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the unmonitorInstances function of EC2 + * @param {UnmonitorInstancesRequest} params - Data required for unmonitorInstances + * @returns {Promise} + */ + unmonitor(params) { + return new Promise((resolve, reject) => { + this._eC2.unmonitorInstances(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_ComputeInstance; diff --git a/generator/generatedClasses/AWS/compute/aws-container.js b/generator/generatedClasses/AWS/compute/aws-container.js index 2e9e6863..1b5ec5a5 100644 --- a/generator/generatedClasses/AWS/compute/aws-container.js +++ b/generator/generatedClasses/AWS/compute/aws-container.js @@ -4,81 +4,85 @@ * @category AWS */ class AWS_Container { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eCS = new this._AWS.ECS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createCluster function of ECS - * @param {CreateClusterRequest} params - Data required for createCluster - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eCS.createCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCluster function of ECS - * @param {DeleteClusterRequest} params - Data required for deleteCluster - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eCS.deleteCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeClusters function of ECS - * @param {DescribeClustersRequest} params - Data required for describeClusters - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eCS.describeClusters(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listClusters function of ECS - * @param {ListClustersRequest} params - Data required for listClusters - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eCS.listClusters(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eCS = new this._AWS.ECS({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createCluster function of ECS + * @param {CreateClusterRequest} params - Data required for createCluster + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eCS.createCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCluster function of ECS + * @param {DeleteClusterRequest} params - Data required for deleteCluster + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eCS.deleteCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeClusters function of ECS + * @param {DescribeClustersRequest} params - Data required for describeClusters + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eCS.describeClusters(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listClusters function of ECS + * @param {ListClustersRequest} params - Data required for listClusters + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eCS.listClusters(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Container; diff --git a/generator/generatedClasses/AWS/compute/aws-kubernetes.js b/generator/generatedClasses/AWS/compute/aws-kubernetes.js index 394d8b9a..bf31ba19 100644 --- a/generator/generatedClasses/AWS/compute/aws-kubernetes.js +++ b/generator/generatedClasses/AWS/compute/aws-kubernetes.js @@ -4,177 +4,187 @@ * @category AWS */ class AWS_Kubernetes { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eKS = new this._AWS.EKS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createCluster function of EKS - * @param {CreateClusterRequest} params - Data required for createCluster - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eKS.createCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createNodegroup function of EKS - * @param {CreateNodegroupRequest} params - Data required for createNodegroup - * @returns {Promise} - */ - createNodeGroup(params) { - return new Promise((resolve, reject) => { - this._eKS.createNodegroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCluster function of EKS - * @param {DeleteClusterRequest} params - Data required for deleteCluster - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eKS.deleteCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteNodegroup function of EKS - * @param {DeleteNodegroupRequest} params - Data required for deleteNodegroup - * @returns {Promise} - */ - deleteNodegroup(params) { - return new Promise((resolve, reject) => { - this._eKS.deleteNodegroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeCluster function of EKS - * @param {DescribeClusterRequest} params - Data required for describeCluster - * @returns {Promise} - */ - describeCluster(params) { - return new Promise((resolve, reject) => { - this._eKS.describeCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeNodegroup function of EKS - * @param {DescribeNodegroupRequest} params - Data required for describeNodegroup - * @returns {Promise} - */ - describeNodeGroup(params) { - return new Promise((resolve, reject) => { - this._eKS.describeNodegroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listClusters function of EKS - * @param {ListClustersRequest} params - Data required for listClusters - * @returns {Promise} - */ - listClusters(params) { - return new Promise((resolve, reject) => { - this._eKS.listClusters(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listNodegroups function of EKS - * @param {ListNodegroupsRequest} params - Data required for listNodegroups - * @returns {Promise} - */ - listNodegroups(params) { - return new Promise((resolve, reject) => { - this._eKS.listNodegroups(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the tagResource function of EKS - * @param {TagResourceRequest} params - Data required for tagResource - * @returns {Promise} - */ - updateTags(params) { - return new Promise((resolve, reject) => { - this._eKS.tagResource(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateClusterConfig function of EKS - * @param {UpdateClusterConfigRequest} params - Data required for updateClusterConfig - * @returns {Promise} - */ - updateConfig(params) { - return new Promise((resolve, reject) => { - this._eKS.updateClusterConfig(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eKS = new this._AWS.EKS({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createCluster function of EKS + * @param {CreateClusterRequest} params - Data required for createCluster + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eKS.createCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createNodegroup function of EKS + * @param {CreateNodegroupRequest} params - Data required for createNodegroup + * @returns {Promise} + */ + createNodeGroup(params) { + return new Promise((resolve, reject) => { + this._eKS.createNodegroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCluster function of EKS + * @param {DeleteClusterRequest} params - Data required for deleteCluster + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eKS.deleteCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteNodegroup function of EKS + * @param {DeleteNodegroupRequest} params - Data required for deleteNodegroup + * @returns {Promise} + */ + deleteNodegroup(params) { + return new Promise((resolve, reject) => { + this._eKS.deleteNodegroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeCluster function of EKS + * @param {DescribeClusterRequest} params - Data required for describeCluster + * @returns {Promise} + */ + describeCluster(params) { + return new Promise((resolve, reject) => { + this._eKS.describeCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeNodegroup function of EKS + * @param {DescribeNodegroupRequest} params - Data required for describeNodegroup + * @returns {Promise} + */ + describeNodeGroup(params) { + return new Promise((resolve, reject) => { + this._eKS.describeNodegroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listClusters function of EKS + * @param {ListClustersRequest} params - Data required for listClusters + * @returns {Promise} + */ + listClusters(params) { + return new Promise((resolve, reject) => { + this._eKS.listClusters(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listNodegroups function of EKS + * @param {ListNodegroupsRequest} params - Data required for listNodegroups + * @returns {Promise} + */ + listNodegroups(params) { + return new Promise((resolve, reject) => { + this._eKS.listNodegroups(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the tagResource function of EKS + * @param {TagResourceRequest} params - Data required for tagResource + * @returns {Promise} + */ + updateTags(params) { + return new Promise((resolve, reject) => { + this._eKS.tagResource(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateClusterConfig function of EKS + * @param {UpdateClusterConfigRequest} params - Data required for updateClusterConfig + * @returns {Promise} + */ + updateConfig(params) { + return new Promise((resolve, reject) => { + this._eKS.updateClusterConfig(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Kubernetes; diff --git a/generator/generatedClasses/AWS/database/aws-RDBMS.js b/generator/generatedClasses/AWS/database/aws-RDBMS.js index 215ab2fb..7983b58e 100644 --- a/generator/generatedClasses/AWS/database/aws-RDBMS.js +++ b/generator/generatedClasses/AWS/database/aws-RDBMS.js @@ -4,113 +4,119 @@ * @category AWS */ class AWS_RDBMS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._rDS = new this._AWS.RDS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createDBCluster function of RDS - * @param {CreateDBClusterMessage} params - Data required for createDBCluster - * @returns {Promise} - */ - createDatabse(params) { - return new Promise((resolve, reject) => { - this._rDS.createDBCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createDBSnapshot function of RDS - * @param {CreateDBSnapshotMessage} params - Data required for createDBSnapshot - * @returns {Promise} - */ - createSnapshots(params) { - return new Promise((resolve, reject) => { - this._rDS.createDBSnapshot(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDBCluster function of RDS - * @param {DeleteDBClusterMessage} params - Data required for deleteDBCluster - * @returns {Promise} - */ - deleteDatabase(params) { - return new Promise((resolve, reject) => { - this._rDS.deleteDBCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDBSnapshot function of RDS - * @param {DeleteDBSnapshotMessage} params - Data required for deleteDBSnapshot - * @returns {Promise} - */ - deleteDBSnapshot(params) { - return new Promise((resolve, reject) => { - this._rDS.deleteDBSnapshot(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the modifyDBCluster function of RDS - * @param {ModifyDBClusterMessage} params - Data required for modifyDBCluster - * @returns {Promise} - */ - modifyDB(params) { - return new Promise((resolve, reject) => { - this._rDS.modifyDBCluster(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the rebootDBInstance function of RDS - * @param {RebootDBInstanceMessage} params - Data required for rebootDBInstance - * @returns {Promise} - */ - restoreDatabase(params) { - return new Promise((resolve, reject) => { - this._rDS.rebootDBInstance(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._rDS = new this._AWS.RDS({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createDBCluster function of RDS + * @param {CreateDBClusterMessage} params - Data required for createDBCluster + * @returns {Promise} + */ + createDatabse(params) { + return new Promise((resolve, reject) => { + this._rDS.createDBCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createDBSnapshot function of RDS + * @param {CreateDBSnapshotMessage} params - Data required for createDBSnapshot + * @returns {Promise} + */ + createSnapshots(params) { + return new Promise((resolve, reject) => { + this._rDS.createDBSnapshot(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDBCluster function of RDS + * @param {DeleteDBClusterMessage} params - Data required for deleteDBCluster + * @returns {Promise} + */ + deleteDatabase(params) { + return new Promise((resolve, reject) => { + this._rDS.deleteDBCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDBSnapshot function of RDS + * @param {DeleteDBSnapshotMessage} params - Data required for deleteDBSnapshot + * @returns {Promise} + */ + deleteDBSnapshot(params) { + return new Promise((resolve, reject) => { + this._rDS.deleteDBSnapshot(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the modifyDBCluster function of RDS + * @param {ModifyDBClusterMessage} params - Data required for modifyDBCluster + * @returns {Promise} + */ + modifyDB(params) { + return new Promise((resolve, reject) => { + this._rDS.modifyDBCluster(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the rebootDBInstance function of RDS + * @param {RebootDBInstanceMessage} params - Data required for rebootDBInstance + * @returns {Promise} + */ + restoreDatabase(params) { + return new Promise((resolve, reject) => { + this._rDS.rebootDBInstance(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_RDBMS; diff --git a/generator/generatedClasses/AWS/database/aws-noSql.js b/generator/generatedClasses/AWS/database/aws-noSql.js index c11898c9..3af86a16 100644 --- a/generator/generatedClasses/AWS/database/aws-noSql.js +++ b/generator/generatedClasses/AWS/database/aws-noSql.js @@ -4,113 +4,119 @@ * @category AWS */ class AWS_NoSql { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._dynamoDB = new this._AWS.DynamoDB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTable function of DynamoDB - * @param {CreateTableInput} params - Data required for createTable - * @returns {Promise} - */ - createTable(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.createTable(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteItem function of DynamoDB - * @param {DeleteItemInput} params - Data required for deleteItem - * @returns {Promise} - */ - deleteItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.deleteItem(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteTable function of DynamoDB - * @param {DeleteTableInput} params - Data required for deleteTable - * @returns {Promise} - */ - deleteTable(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.deleteTable(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putItem function of DynamoDB - * @param {PutItemInput} params - Data required for putItem - * @returns {Promise} - */ - createItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.putItem(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the query function of DynamoDB - * @param {QueryInput} params - Data required for query - * @returns {Promise} - */ - query(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.query(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateItem function of DynamoDB - * @param {UpdateItemInput} params - Data required for updateItem - * @returns {Promise} - */ - updateItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.updateItem(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._dynamoDB = new this._AWS.DynamoDB({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createTable function of DynamoDB + * @param {CreateTableInput} params - Data required for createTable + * @returns {Promise} + */ + createTable(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.createTable(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteItem function of DynamoDB + * @param {DeleteItemInput} params - Data required for deleteItem + * @returns {Promise} + */ + deleteItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.deleteItem(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteTable function of DynamoDB + * @param {DeleteTableInput} params - Data required for deleteTable + * @returns {Promise} + */ + deleteTable(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.deleteTable(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putItem function of DynamoDB + * @param {PutItemInput} params - Data required for putItem + * @returns {Promise} + */ + createItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.putItem(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the query function of DynamoDB + * @param {QueryInput} params - Data required for query + * @returns {Promise} + */ + query(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.query(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateItem function of DynamoDB + * @param {UpdateItemInput} params - Data required for updateItem + * @returns {Promise} + */ + updateItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.updateItem(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NoSql; diff --git a/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js b/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js index c86ffc13..d55afca0 100644 --- a/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js +++ b/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js @@ -4,161 +4,170 @@ * @category AWS */ class AWS_NoSqlIndexed { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._simpleDB = new this._AWS.SimpleDB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the batchDeleteAttributes function of SimpleDB - * @param {BatchDeleteAttributesRequest} params - Data required for batchDeleteAttributes - * @returns {Promise} - */ - batchDelete(params) { - return new Promise((resolve, reject) => { - this._simpleDB.batchDeleteAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the batchPutAttributes function of SimpleDB - * @param {BatchPutAttributesRequest} params - Data required for batchPutAttributes - * @returns {Promise} - */ - batchWrite(params) { - return new Promise((resolve, reject) => { - this._simpleDB.batchPutAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createDomain function of SimpleDB - * @param {CreateDomainRequest} params - Data required for createDomain - * @returns {Promise} - */ - createCollection(params) { - return new Promise((resolve, reject) => { - this._simpleDB.createDomain(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteAttributes function of SimpleDB - * @param {DeleteAttributesRequest} params - Data required for deleteAttributes - * @returns {Promise} - */ - deleteAttribute(params) { - return new Promise((resolve, reject) => { - this._simpleDB.deleteAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDomain function of SimpleDB - * @param {DeleteDomainRequest} params - Data required for deleteDomain - * @returns {Promise} - */ - deleteCollection(params) { - return new Promise((resolve, reject) => { - this._simpleDB.deleteDomain(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getAttributes function of SimpleDB - * @param {GetAttributesRequest} params - Data required for getAttributes - * @returns {Promise} - */ - getAttributes(params) { - return new Promise((resolve, reject) => { - this._simpleDB.getAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listDomains function of SimpleDB - * @param {ListDomainsRequest} params - Data required for listDomains - * @returns {Promise} - */ - listCollections(params) { - return new Promise((resolve, reject) => { - this._simpleDB.listDomains(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putAttributes function of SimpleDB - * @param {PutAttributesRequest} params - Data required for putAttributes - * @returns {Promise} - */ - setAttribute(params) { - return new Promise((resolve, reject) => { - this._simpleDB.putAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the select function of SimpleDB - * @param {SelectRequest} params - Data required for select - * @returns {Promise} - */ - query(params) { - return new Promise((resolve, reject) => { - this._simpleDB.select(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._simpleDB = new this._AWS.SimpleDB({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the batchDeleteAttributes function of SimpleDB + * @param {BatchDeleteAttributesRequest} params - Data required for batchDeleteAttributes + * @returns {Promise} + */ + batchDelete(params) { + return new Promise((resolve, reject) => { + this._simpleDB.batchDeleteAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the batchPutAttributes function of SimpleDB + * @param {BatchPutAttributesRequest} params - Data required for batchPutAttributes + * @returns {Promise} + */ + batchWrite(params) { + return new Promise((resolve, reject) => { + this._simpleDB.batchPutAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createDomain function of SimpleDB + * @param {CreateDomainRequest} params - Data required for createDomain + * @returns {Promise} + */ + createCollection(params) { + return new Promise((resolve, reject) => { + this._simpleDB.createDomain(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteAttributes function of SimpleDB + * @param {DeleteAttributesRequest} params - Data required for deleteAttributes + * @returns {Promise} + */ + deleteAttribute(params) { + return new Promise((resolve, reject) => { + this._simpleDB.deleteAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDomain function of SimpleDB + * @param {DeleteDomainRequest} params - Data required for deleteDomain + * @returns {Promise} + */ + deleteCollection(params) { + return new Promise((resolve, reject) => { + this._simpleDB.deleteDomain(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getAttributes function of SimpleDB + * @param {GetAttributesRequest} params - Data required for getAttributes + * @returns {Promise} + */ + getAttributes(params) { + return new Promise((resolve, reject) => { + this._simpleDB.getAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listDomains function of SimpleDB + * @param {ListDomainsRequest} params - Data required for listDomains + * @returns {Promise} + */ + listCollections(params) { + return new Promise((resolve, reject) => { + this._simpleDB.listDomains(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putAttributes function of SimpleDB + * @param {PutAttributesRequest} params - Data required for putAttributes + * @returns {Promise} + */ + setAttribute(params) { + return new Promise((resolve, reject) => { + this._simpleDB.putAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the select function of SimpleDB + * @param {SelectRequest} params - Data required for select + * @returns {Promise} + */ + query(params) { + return new Promise((resolve, reject) => { + this._simpleDB.select(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NoSqlIndexed; diff --git a/generator/generatedClasses/AWS/management/aws-keyManagement.js b/generator/generatedClasses/AWS/management/aws-keyManagement.js index 7bab4b56..225039c8 100644 --- a/generator/generatedClasses/AWS/management/aws-keyManagement.js +++ b/generator/generatedClasses/AWS/management/aws-keyManagement.js @@ -4,97 +4,102 @@ * @category AWS */ class AWS_KeyManagement { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._kMS = new this._AWS.KMS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createKey function of KMS - * @param {CreateKeyRequest} params - Data required for createKey - * @returns {Promise} - */ - createKey(params) { - return new Promise((resolve, reject) => { - this._kMS.createKey(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCustomKeyStore function of KMS - * @param {DeleteCustomKeyStoreRequest} params - Data required for deleteCustomKeyStore - * @returns {Promise} - */ - deleteKey(params) { - return new Promise((resolve, reject) => { - this._kMS.deleteCustomKeyStore(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeKey function of KMS - * @param {DescribeKeyRequest} params - Data required for describeKey - * @returns {Promise} - */ - describeKey(params) { - return new Promise((resolve, reject) => { - this._kMS.describeKey(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putKeyPolicy function of KMS - * @param {PutKeyPolicyRequest} params - Data required for putKeyPolicy - * @returns {Promise} - */ - putKeyPolicy(params) { - return new Promise((resolve, reject) => { - this._kMS.putKeyPolicy(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateKeyDescription function of KMS - * @param {UpdateKeyDescriptionRequest} params - Data required for updateKeyDescription - * @returns {Promise} - */ - update(params) { - return new Promise((resolve, reject) => { - this._kMS.updateKeyDescription(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._kMS = new this._AWS.KMS({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createKey function of KMS + * @param {CreateKeyRequest} params - Data required for createKey + * @returns {Promise} + */ + createKey(params) { + return new Promise((resolve, reject) => { + this._kMS.createKey(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCustomKeyStore function of KMS + * @param {DeleteCustomKeyStoreRequest} params - Data required for deleteCustomKeyStore + * @returns {Promise} + */ + deleteKey(params) { + return new Promise((resolve, reject) => { + this._kMS.deleteCustomKeyStore(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeKey function of KMS + * @param {DescribeKeyRequest} params - Data required for describeKey + * @returns {Promise} + */ + describeKey(params) { + return new Promise((resolve, reject) => { + this._kMS.describeKey(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putKeyPolicy function of KMS + * @param {PutKeyPolicyRequest} params - Data required for putKeyPolicy + * @returns {Promise} + */ + putKeyPolicy(params) { + return new Promise((resolve, reject) => { + this._kMS.putKeyPolicy(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateKeyDescription function of KMS + * @param {UpdateKeyDescriptionRequest} params - Data required for updateKeyDescription + * @returns {Promise} + */ + update(params) { + return new Promise((resolve, reject) => { + this._kMS.updateKeyDescription(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_KeyManagement; diff --git a/generator/generatedClasses/AWS/management/aws-monitoring.js b/generator/generatedClasses/AWS/management/aws-monitoring.js index ba4a17de..aa89282a 100644 --- a/generator/generatedClasses/AWS/management/aws-monitoring.js +++ b/generator/generatedClasses/AWS/management/aws-monitoring.js @@ -4,81 +4,85 @@ * @category AWS */ class AWS_Monitoring { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._cloudWatch = new this._AWS.CloudWatch({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the deleteAlarms function of CloudWatch - * @param {DeleteAlarmsInput} params - Data required for deleteAlarms - * @returns {Promise} - */ - deleteAlarm(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.deleteAlarms(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getMetricData function of CloudWatch - * @param {GetMetricDataInput} params - Data required for getMetricData - * @returns {Promise} - */ - getMetricData(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.getMetricData(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listMetrics function of CloudWatch - * @param {ListMetricsInput} params - Data required for listMetrics - * @returns {Promise} - */ - listAlarms(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.listMetrics(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putMetricAlarm function of CloudWatch - * @param {PutMetricAlarmInput} params - Data required for putMetricAlarm - * @returns {Promise} - */ - updateAlarm(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.putMetricAlarm(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._cloudWatch = new this._AWS.CloudWatch({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the deleteAlarms function of CloudWatch + * @param {DeleteAlarmsInput} params - Data required for deleteAlarms + * @returns {Promise} + */ + deleteAlarm(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.deleteAlarms(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getMetricData function of CloudWatch + * @param {GetMetricDataInput} params - Data required for getMetricData + * @returns {Promise} + */ + getMetricData(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.getMetricData(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listMetrics function of CloudWatch + * @param {ListMetricsInput} params - Data required for listMetrics + * @returns {Promise} + */ + listAlarms(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.listMetrics(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putMetricAlarm function of CloudWatch + * @param {PutMetricAlarmInput} params - Data required for putMetricAlarm + * @returns {Promise} + */ + updateAlarm(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.putMetricAlarm(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Monitoring; diff --git a/generator/generatedClasses/AWS/management/aws-notificationService.js b/generator/generatedClasses/AWS/management/aws-notificationService.js index 7e37e378..fb80c822 100644 --- a/generator/generatedClasses/AWS/management/aws-notificationService.js +++ b/generator/generatedClasses/AWS/management/aws-notificationService.js @@ -4,145 +4,153 @@ * @category AWS */ class AWS_NotificationService { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._sNS = new this._AWS.SNS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTopic function of SNS - * @param {CreateTopicInput} params - Data required for createTopic - * @returns {Promise} - */ - createTopic(params) { - return new Promise((resolve, reject) => { - this._sNS.createTopic(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteTopic function of SNS - * @param {DeleteTopicInput} params - Data required for deleteTopic - * @returns {Promise} - */ - deleteTopic(params) { - return new Promise((resolve, reject) => { - this._sNS.deleteTopic(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getTopicAttributes function of SNS - * @param {GetTopicAttributesInput} params - Data required for getTopicAttributes - * @returns {Promise} - */ - getTopicAttributes(params) { - return new Promise((resolve, reject) => { - this._sNS.getTopicAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listSubscriptions function of SNS - * @param {ListSubscriptionsInput} params - Data required for listSubscriptions - * @returns {Promise} - */ - listSubscriptions(params) { - return new Promise((resolve, reject) => { - this._sNS.listSubscriptions(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listTopics function of SNS - * @param {ListTopicsInput} params - Data required for listTopics - * @returns {Promise} - */ - listTopics(params) { - return new Promise((resolve, reject) => { - this._sNS.listTopics(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the publish function of SNS - * @param {PublishInput} params - Data required for publish - * @returns {Promise} - */ - publish(params) { - return new Promise((resolve, reject) => { - this._sNS.publish(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the subscribe function of SNS - * @param {SubscribeInput} params - Data required for subscribe - * @returns {Promise} - */ - subscribe(params) { - return new Promise((resolve, reject) => { - this._sNS.subscribe(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the unsubscribe function of SNS - * @param {UnsubscribeInput} params - Data required for unsubscribe - * @returns {Promise} - */ - unsubscribe(params) { - return new Promise((resolve, reject) => { - this._sNS.unsubscribe(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._sNS = new this._AWS.SNS({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createTopic function of SNS + * @param {CreateTopicInput} params - Data required for createTopic + * @returns {Promise} + */ + createTopic(params) { + return new Promise((resolve, reject) => { + this._sNS.createTopic(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteTopic function of SNS + * @param {DeleteTopicInput} params - Data required for deleteTopic + * @returns {Promise} + */ + deleteTopic(params) { + return new Promise((resolve, reject) => { + this._sNS.deleteTopic(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getTopicAttributes function of SNS + * @param {GetTopicAttributesInput} params - Data required for getTopicAttributes + * @returns {Promise} + */ + getTopicAttributes(params) { + return new Promise((resolve, reject) => { + this._sNS.getTopicAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listSubscriptions function of SNS + * @param {ListSubscriptionsInput} params - Data required for listSubscriptions + * @returns {Promise} + */ + listSubscriptions(params) { + return new Promise((resolve, reject) => { + this._sNS.listSubscriptions(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listTopics function of SNS + * @param {ListTopicsInput} params - Data required for listTopics + * @returns {Promise} + */ + listTopics(params) { + return new Promise((resolve, reject) => { + this._sNS.listTopics(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the publish function of SNS + * @param {PublishInput} params - Data required for publish + * @returns {Promise} + */ + publish(params) { + return new Promise((resolve, reject) => { + this._sNS.publish(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the subscribe function of SNS + * @param {SubscribeInput} params - Data required for subscribe + * @returns {Promise} + */ + subscribe(params) { + return new Promise((resolve, reject) => { + this._sNS.subscribe(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the unsubscribe function of SNS + * @param {UnsubscribeInput} params - Data required for unsubscribe + * @returns {Promise} + */ + unsubscribe(params) { + return new Promise((resolve, reject) => { + this._sNS.unsubscribe(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NotificationService; diff --git a/generator/generatedClasses/AWS/network/aws-DNS.js b/generator/generatedClasses/AWS/network/aws-DNS.js index 422f035b..2a9330da 100644 --- a/generator/generatedClasses/AWS/network/aws-DNS.js +++ b/generator/generatedClasses/AWS/network/aws-DNS.js @@ -4,81 +4,85 @@ * @category AWS */ class AWS_DNS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._route53 = new this._AWS.Route53({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the changeResourceRecordSets function of Route53 - * @param {ChangeResourceRecordSetsRequest} params - Data required for changeResourceRecordSets - * @returns {Promise} - */ - changeRecordSets(params) { - return new Promise((resolve, reject) => { - this._route53.changeResourceRecordSets(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createHostedZone function of Route53 - * @param {CreateHostedZoneRequest} params - Data required for createHostedZone - * @returns {Promise} - */ - createZone(params) { - return new Promise((resolve, reject) => { - this._route53.createHostedZone(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteHostedZone function of Route53 - * @param {DeleteHostedZoneRequest} params - Data required for deleteHostedZone - * @returns {Promise} - */ - deleteZone(params) { - return new Promise((resolve, reject) => { - this._route53.deleteHostedZone(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listHostedZones function of Route53 - * @param {ListHostedZonesRequest} params - Data required for listHostedZones - * @returns {Promise} - */ - listZones(params) { - return new Promise((resolve, reject) => { - this._route53.listHostedZones(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._route53 = new this._AWS.Route53({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the changeResourceRecordSets function of Route53 + * @param {ChangeResourceRecordSetsRequest} params - Data required for changeResourceRecordSets + * @returns {Promise} + */ + changeRecordSets(params) { + return new Promise((resolve, reject) => { + this._route53.changeResourceRecordSets(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createHostedZone function of Route53 + * @param {CreateHostedZoneRequest} params - Data required for createHostedZone + * @returns {Promise} + */ + createZone(params) { + return new Promise((resolve, reject) => { + this._route53.createHostedZone(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteHostedZone function of Route53 + * @param {DeleteHostedZoneRequest} params - Data required for deleteHostedZone + * @returns {Promise} + */ + deleteZone(params) { + return new Promise((resolve, reject) => { + this._route53.deleteHostedZone(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listHostedZones function of Route53 + * @param {ListHostedZonesRequest} params - Data required for listHostedZones + * @returns {Promise} + */ + listZones(params) { + return new Promise((resolve, reject) => { + this._route53.listHostedZones(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_DNS; diff --git a/generator/generatedClasses/AWS/network/aws-loadBalancer.js b/generator/generatedClasses/AWS/network/aws-loadBalancer.js index f722dd14..7731152c 100644 --- a/generator/generatedClasses/AWS/network/aws-loadBalancer.js +++ b/generator/generatedClasses/AWS/network/aws-loadBalancer.js @@ -4,97 +4,102 @@ * @category AWS */ class AWS_LoadBalancer { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eLB = new this._AWS.ELB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the addTags function of ELB - * @param {AddTagsInput} params - Data required for addTags - * @returns {Promise} - */ - addTags(params) { - return new Promise((resolve, reject) => { - this._eLB.addTags(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createLoadBalancer function of ELB - * @param {CreateAccessPointInput} params - Data required for createLoadBalancer - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eLB.createLoadBalancer(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteLoadBalancer function of ELB - * @param {DeleteAccessPointInput} params - Data required for deleteLoadBalancer - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eLB.deleteLoadBalancer(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeLoadBalancerAttributes function of ELB - * @param {DescribeLoadBalancerAttributesInput} params - Data required for describeLoadBalancerAttributes - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eLB.describeLoadBalancerAttributes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeLoadBalancers function of ELB - * @param {DescribeAccessPointsInput} params - Data required for describeLoadBalancers - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eLB.describeLoadBalancers(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eLB = new this._AWS.ELB({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the addTags function of ELB + * @param {AddTagsInput} params - Data required for addTags + * @returns {Promise} + */ + addTags(params) { + return new Promise((resolve, reject) => { + this._eLB.addTags(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createLoadBalancer function of ELB + * @param {CreateAccessPointInput} params - Data required for createLoadBalancer + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eLB.createLoadBalancer(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteLoadBalancer function of ELB + * @param {DeleteAccessPointInput} params - Data required for deleteLoadBalancer + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eLB.deleteLoadBalancer(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeLoadBalancerAttributes function of ELB + * @param {DescribeLoadBalancerAttributesInput} params - Data required for describeLoadBalancerAttributes + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eLB.describeLoadBalancerAttributes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeLoadBalancers function of ELB + * @param {DescribeAccessPointsInput} params - Data required for describeLoadBalancers + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eLB.describeLoadBalancers(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_LoadBalancer; diff --git a/generator/generatedClasses/AWS/security/aws-IAM.js b/generator/generatedClasses/AWS/security/aws-IAM.js index 265a6a31..b643c521 100644 --- a/generator/generatedClasses/AWS/security/aws-IAM.js +++ b/generator/generatedClasses/AWS/security/aws-IAM.js @@ -4,97 +4,102 @@ * @category AWS */ class AWS_IAM { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._iAM = new this._AWS.IAM({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the attachGroupPolicy function of IAM - * @param {AttachGroupPolicyRequest} params - Data required for attachGroupPolicy - * @returns {Promise} - */ - attachGroupPolicy(params) { - return new Promise((resolve, reject) => { - this._iAM.attachGroupPolicy(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createGroup function of IAM - * @param {CreateGroupRequest} params - Data required for createGroup - * @returns {Promise} - */ - createGroup(params) { - return new Promise((resolve, reject) => { - this._iAM.createGroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteGroup function of IAM - * @param {DeleteGroupRequest} params - Data required for deleteGroup - * @returns {Promise} - */ - deleteGroup(params) { - return new Promise((resolve, reject) => { - this._iAM.deleteGroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the detachGroupPolicy function of IAM - * @param {DetachGroupPolicyRequest} params - Data required for detachGroupPolicy - * @returns {Promise} - */ - detachGroupPolicy(params) { - return new Promise((resolve, reject) => { - this._iAM.detachGroupPolicy(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getGroup function of IAM - * @param {GetGroupRequest} params - Data required for getGroup - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._iAM.getGroup(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._iAM = new this._AWS.IAM({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the attachGroupPolicy function of IAM + * @param {AttachGroupPolicyRequest} params - Data required for attachGroupPolicy + * @returns {Promise} + */ + attachGroupPolicy(params) { + return new Promise((resolve, reject) => { + this._iAM.attachGroupPolicy(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createGroup function of IAM + * @param {CreateGroupRequest} params - Data required for createGroup + * @returns {Promise} + */ + createGroup(params) { + return new Promise((resolve, reject) => { + this._iAM.createGroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteGroup function of IAM + * @param {DeleteGroupRequest} params - Data required for deleteGroup + * @returns {Promise} + */ + deleteGroup(params) { + return new Promise((resolve, reject) => { + this._iAM.deleteGroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the detachGroupPolicy function of IAM + * @param {DetachGroupPolicyRequest} params - Data required for detachGroupPolicy + * @returns {Promise} + */ + detachGroupPolicy(params) { + return new Promise((resolve, reject) => { + this._iAM.detachGroupPolicy(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getGroup function of IAM + * @param {GetGroupRequest} params - Data required for getGroup + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._iAM.getGroup(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_IAM; diff --git a/generator/generatedClasses/AWS/storage/aws-archivalStorage.js b/generator/generatedClasses/AWS/storage/aws-archivalStorage.js index 2b5236ec..44aa797f 100644 --- a/generator/generatedClasses/AWS/storage/aws-archivalStorage.js +++ b/generator/generatedClasses/AWS/storage/aws-archivalStorage.js @@ -4,97 +4,102 @@ * @category AWS */ class AWS_ArchivalStorage { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._glacier = new this._AWS.Glacier({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createVault function of Glacier - * @param {CreateVaultInput} params - Data required for createVault - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._glacier.createVault(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteArchive function of Glacier - * @param {DeleteArchiveInput} params - Data required for deleteArchive - * @returns {Promise} - */ - deleteFiles(params) { - return new Promise((resolve, reject) => { - this._glacier.deleteArchive(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteVault function of Glacier - * @param {DeleteVaultInput} params - Data required for deleteVault - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._glacier.deleteVault(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the initiateMultipartUpload function of Glacier - * @param {InitiateMultipartUploadInput} params - Data required for initiateMultipartUpload - * @returns {Promise} - */ - upload(params) { - return new Promise((resolve, reject) => { - this._glacier.initiateMultipartUpload(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listParts function of Glacier - * @param {ListPartsInput} params - Data required for listParts - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._glacier.listParts(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._glacier = new this._AWS.Glacier({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createVault function of Glacier + * @param {CreateVaultInput} params - Data required for createVault + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._glacier.createVault(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteArchive function of Glacier + * @param {DeleteArchiveInput} params - Data required for deleteArchive + * @returns {Promise} + */ + deleteFiles(params) { + return new Promise((resolve, reject) => { + this._glacier.deleteArchive(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteVault function of Glacier + * @param {DeleteVaultInput} params - Data required for deleteVault + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._glacier.deleteVault(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the initiateMultipartUpload function of Glacier + * @param {InitiateMultipartUploadInput} params - Data required for initiateMultipartUpload + * @returns {Promise} + */ + upload(params) { + return new Promise((resolve, reject) => { + this._glacier.initiateMultipartUpload(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listParts function of Glacier + * @param {ListPartsInput} params - Data required for listParts + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._glacier.listParts(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_ArchivalStorage; diff --git a/generator/generatedClasses/AWS/storage/aws-blockStorage.js b/generator/generatedClasses/AWS/storage/aws-blockStorage.js index 8ada4a2a..d1c77717 100644 --- a/generator/generatedClasses/AWS/storage/aws-blockStorage.js +++ b/generator/generatedClasses/AWS/storage/aws-blockStorage.js @@ -4,81 +4,85 @@ * @category AWS */ class AWS_BlockStorage { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eC2 = new this._AWS.EC2({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createVolume function of EC2 - * @param {CreateVolumeRequest} params - Data required for createVolume - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eC2.createVolume(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteVolume function of EC2 - * @param {DeleteVolumeRequest} params - Data required for deleteVolume - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eC2.deleteVolume(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeVolumeAttribute function of EC2 - * @param {DescribeVolumeAttributeRequest} params - Data required for describeVolumeAttribute - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eC2.describeVolumeAttribute(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeVolumes function of EC2 - * @param {DescribeVolumesRequest} params - Data required for describeVolumes - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eC2.describeVolumes(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eC2 = new this._AWS.EC2({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createVolume function of EC2 + * @param {CreateVolumeRequest} params - Data required for createVolume + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eC2.createVolume(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteVolume function of EC2 + * @param {DeleteVolumeRequest} params - Data required for deleteVolume + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eC2.deleteVolume(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeVolumeAttribute function of EC2 + * @param {DescribeVolumeAttributeRequest} params - Data required for describeVolumeAttribute + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eC2.describeVolumeAttribute(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeVolumes function of EC2 + * @param {DescribeVolumesRequest} params - Data required for describeVolumes + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eC2.describeVolumes(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_BlockStorage; diff --git a/generator/generatedClasses/AWS/storage/aws-storageBucket.js b/generator/generatedClasses/AWS/storage/aws-storageBucket.js index ef50b831..eb483a51 100644 --- a/generator/generatedClasses/AWS/storage/aws-storageBucket.js +++ b/generator/generatedClasses/AWS/storage/aws-storageBucket.js @@ -4,96 +4,101 @@ * @category AWS */ class AWS_StorageBucket { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._s3 = new this._AWS.S3({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createBucket function of S3 - * @param {CreateBucketRequest} params - Data required for createBucket - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._s3.createBucket(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteBucket function of S3 - * @param {DeleteBucketRequest} params - Data required for deleteBucket - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._s3.deleteBucket(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteObjects function of S3 - * @param {DeleteObjectsRequest} params - Data required for deleteObjects - * @returns {Promise} - */ - deleteFiles(params) { - return new Promise((resolve, reject) => { - this._s3.deleteObjects(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listBuckets function of S3 - * @returns {Promise} - */ - list() { - return new Promise((resolve, reject) => { - this._s3.listBuckets((error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } - /** - * Trigers the uploadPart function of S3 - * @param {UploadPartRequest} params - Data required for uploadPart - * @returns {Promise} - */ - upload(params) { - return new Promise((resolve, reject) => { - this._s3.uploadPart(params, (error, data) => { - if (error) { - reject(error); - } else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._s3 = new this._AWS.S3({ + apiVersion: this._apiVersion + }); + } + /** + * Trigers the createBucket function of S3 + * @param {CreateBucketRequest} params - Data required for createBucket + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._s3.createBucket(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteBucket function of S3 + * @param {DeleteBucketRequest} params - Data required for deleteBucket + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._s3.deleteBucket(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteObjects function of S3 + * @param {DeleteObjectsRequest} params - Data required for deleteObjects + * @returns {Promise} + */ + deleteFiles(params) { + return new Promise((resolve, reject) => { + this._s3.deleteObjects(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listBuckets function of S3 + * @returns {Promise} + */ + list() { + return new Promise((resolve, reject) => { + this._s3.listBuckets((error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } + /** + * Trigers the uploadPart function of S3 + * @param {UploadPartRequest} params - Data required for uploadPart + * @returns {Promise} + */ + upload(params) { + return new Promise((resolve, reject) => { + this._s3.uploadPart(params, (error, data) => { + if (error) { + reject(error); + } + else { + resolve(data); + } + }); + }); + } } module.exports = AWS_StorageBucket; diff --git a/generator/generatedClasses/Azure/appServices/azure-paaS.js b/generator/generatedClasses/Azure/appServices/azure-paaS.js index 02c914e5..226bbc2a 100644 --- a/generator/generatedClasses/Azure/appServices/azure-paaS.js +++ b/generator/generatedClasses/Azure/appServices/azure-paaS.js @@ -5,418 +5,282 @@ const { WebSiteManagementClient } = require("@azure/arm-appservice"); * @category Azure */ class Azure_PaaS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, name, siteEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .createOrUpdate(resourceGroupName, name, siteEnvelope, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, name, siteEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.createOrUpdate(resourceGroupName, name, siteEnvelope, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the update function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, name, siteEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .update(resourceGroupName, name, siteEnvelope, options) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, name, siteEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.update(resourceGroupName, name, siteEnvelope, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps.get(resourceGroupName, name, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the get function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.get(resourceGroupName, name, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteMethod function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .deleteMethod(resourceGroupName, name, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.deleteMethod(resourceGroupName, name, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the restart function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - restart(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .restart(resourceGroupName, name, options) - .then(result => { - resolve(result); + } + /** + * Trigers the restart function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + restart(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.restart(resourceGroupName, name, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the createOrUpdate function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createEnvironment( - resourceGroupName, - name, - hostingEnvironmentEnvelope, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.appServiceEnvironments - .createOrUpdate( - resourceGroupName, - name, - hostingEnvironmentEnvelope, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the createOrUpdate function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createEnvironment(resourceGroupName, name, hostingEnvironmentEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.appServiceEnvironments.createOrUpdate(resourceGroupName, name, hostingEnvironmentEnvelope, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the update function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateEnvironment( - resourceGroupName, - name, - hostingEnvironmentEnvelope, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.appServiceEnvironments - .update( - resourceGroupName, - name, - hostingEnvironmentEnvelope, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateEnvironment(resourceGroupName, name, hostingEnvironmentEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.appServiceEnvironments.update(resourceGroupName, name, hostingEnvironmentEnvelope, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the createOrUpdateSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createConfigTemplate( - resourceGroupName, - name, - siteEnvelope, - slot, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .createOrUpdateSlot( - resourceGroupName, - name, - siteEnvelope, - slot, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the createOrUpdateSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createConfigTemplate(resourceGroupName, name, siteEnvelope, slot, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.createOrUpdateSlot(resourceGroupName, name, siteEnvelope, slot, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the getSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeConfigSettings(resourceGroupName, name, slot, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .getSlot(resourceGroupName, name, slot, options) - .then(result => { - resolve(result); + } + /** + * Trigers the getSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeConfigSettings(resourceGroupName, name, slot, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.getSlot(resourceGroupName, name, slot, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteConfigTemplate(resourceGroupName, name, slot, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.webApps - .deleteSlot(resourceGroupName, name, slot, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteConfigTemplate(resourceGroupName, name, slot, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.webApps.deleteSlot(resourceGroupName, name, slot, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the checkAvailability function of appservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - checkDNSAvailability(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.domains.checkAvailability(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the checkAvailability function of appservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + checkDNSAvailability(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.domains.checkAvailability(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteMethod function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - terminateEnvironment(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new WebSiteManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.appServiceEnvironments - .deleteMethod(resourceGroupName, name, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + terminateEnvironment(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.appServiceEnvironments.deleteMethod(resourceGroupName, name, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_PaaS; diff --git a/generator/generatedClasses/Azure/compute/azure-computeInstance.js b/generator/generatedClasses/Azure/compute/azure-computeInstance.js index 8029d665..1ff4472f 100644 --- a/generator/generatedClasses/Azure/compute/azure-computeInstance.js +++ b/generator/generatedClasses/Azure/compute/azure-computeInstance.js @@ -5,198 +5,144 @@ const { ComputeManagementClient } = require("@azure/arm-compute"); * @category Azure */ class Azure_ComputeInstance { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, vmName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .createOrUpdate(resourceGroupName, vmName, parameters, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, vmName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.createOrUpdate(resourceGroupName, vmName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .list(resourceGroupName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the list function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.list(resourceGroupName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the start function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - start(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .start(resourceGroupName, vmName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the start function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + start(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.start(resourceGroupName, vmName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the powerOff function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - stop(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .powerOff(resourceGroupName, vmName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the powerOff function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + stop(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.powerOff(resourceGroupName, vmName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the restart function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - reboot(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .restart(resourceGroupName, vmName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the restart function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + reboot(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.restart(resourceGroupName, vmName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - destroy(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.virtualMachines - .deleteMethod(resourceGroupName, vmName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + destroy(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.virtualMachines.deleteMethod(resourceGroupName, vmName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_ComputeInstance; diff --git a/generator/generatedClasses/Azure/compute/azure-container.js b/generator/generatedClasses/Azure/compute/azure-container.js index 14991423..7ae30f1e 100644 --- a/generator/generatedClasses/Azure/compute/azure-container.js +++ b/generator/generatedClasses/Azure/compute/azure-container.js @@ -5,143 +5,99 @@ const { ContainerServiceClient } = require("@azure/arm-containerservice"); * @category Azure */ class Azure_Container { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create( - resourceGroupName, - containerServiceName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.containerServices - .createOrUpdate( - resourceGroupName, - containerServiceName, - parameters, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, containerServiceName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.containerServices.createOrUpdate(resourceGroupName, containerServiceName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, containerServiceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.containerServices - .deleteMethod(resourceGroupName, containerServiceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, containerServiceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.containerServices.deleteMethod(resourceGroupName, containerServiceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, containerServiceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.containerServices - .get(resourceGroupName, containerServiceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, containerServiceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.containerServices.get(resourceGroupName, containerServiceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of containerservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.containerServices.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the list function of containerservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.containerServices.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = Azure_Container; diff --git a/generator/generatedClasses/Azure/compute/azure-kubernetes.js b/generator/generatedClasses/Azure/compute/azure-kubernetes.js index 3e5f50a2..8f01c7c1 100644 --- a/generator/generatedClasses/Azure/compute/azure-kubernetes.js +++ b/generator/generatedClasses/Azure/compute/azure-kubernetes.js @@ -5,356 +5,236 @@ const { ContainerServiceClient } = require("@azure/arm-containerservice"); * @category Azure */ class Azure_Kubernetes { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, resourceName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters - .createOrUpdate( - resourceGroupName, - resourceName, - parameters, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, resourceName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.createOrUpdate(resourceGroupName, resourceName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters - .deleteMethod(resourceGroupName, resourceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.deleteMethod(resourceGroupName, resourceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the updateTags function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateTags(resourceGroupName, resourceName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters - .updateTags(resourceGroupName, resourceName, parameters, options) - .then(result => { - resolve(result); + } + /** + * Trigers the updateTags function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateTags(resourceGroupName, resourceName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.updateTags(resourceGroupName, resourceName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of containerservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listClusters(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the list function of containerservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listClusters(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeCluster(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters - .get(resourceGroupName, resourceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeCluster(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.get(resourceGroupName, resourceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createNodeGroup( - resourceGroupName, - resourceName, - agentPoolName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.agentPools - .createOrUpdate( - resourceGroupName, - resourceName, - agentPoolName, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createNodeGroup(resourceGroupName, resourceName, agentPoolName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.agentPools.createOrUpdate(resourceGroupName, resourceName, agentPoolName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteNodegroup( - resourceGroupName, - resourceName, - agentPoolName, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.agentPools - .deleteMethod( - resourceGroupName, - resourceName, - agentPoolName, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteNodegroup(resourceGroupName, resourceName, agentPoolName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.agentPools.deleteMethod(resourceGroupName, resourceName, agentPoolName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeNodeGroup( - resourceGroupName, - resourceName, - agentPoolName, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.agentPools - .get(resourceGroupName, resourceName, agentPoolName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeNodeGroup(resourceGroupName, resourceName, agentPoolName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.agentPools.get(resourceGroupName, resourceName, agentPoolName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listNodegroups(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.agentPools - .list(resourceGroupName, resourceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the list function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listNodegroups(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.agentPools.list(resourceGroupName, resourceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the rotateClusterCertificates function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateConfig(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ContainerServiceClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedClusters - .rotateClusterCertificates(resourceGroupName, resourceName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the rotateClusterCertificates function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateConfig(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedClusters.rotateClusterCertificates(resourceGroupName, resourceName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_Kubernetes; diff --git a/generator/generatedClasses/Azure/database/azure-RDBMS.js b/generator/generatedClasses/Azure/database/azure-RDBMS.js index 8767d939..f2665dd0 100644 --- a/generator/generatedClasses/Azure/database/azure-RDBMS.js +++ b/generator/generatedClasses/Azure/database/azure-RDBMS.js @@ -5,229 +5,131 @@ const { SqlManagementClient } = require("@azure/arm-sql"); * @category Azure */ class Azure_RDBMS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createDatabse( - resourceGroupName, - serverName, - databaseName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new SqlManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.databases - .createOrUpdate( - resourceGroupName, - serverName, - databaseName, - parameters, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createDatabse(resourceGroupName, serverName, databaseName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.databases.createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteDatabase( - resourceGroupName, - serverName, - databaseName, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new SqlManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.databases - .deleteMethod(resourceGroupName, serverName, databaseName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteDatabase(resourceGroupName, serverName, databaseName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.databases.deleteMethod(resourceGroupName, serverName, databaseName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the exportMethod function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createSnapshots( - resourceGroupName, - serverName, - databaseName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new SqlManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.databases - .exportMethod( - resourceGroupName, - serverName, - databaseName, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the exportMethod function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createSnapshots(resourceGroupName, serverName, databaseName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.databases.exportMethod(resourceGroupName, serverName, databaseName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the update function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - modifyDB( - resourceGroupName, - serverName, - databaseName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new SqlManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.databases - .update( - resourceGroupName, - serverName, - databaseName, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + modifyDB(resourceGroupName, serverName, databaseName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.databases.update(resourceGroupName, serverName, databaseName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the completeRestore function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} managedInstanceName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - restoreDatabase( - resourceGroupName, - managedInstanceName, - databaseName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new SqlManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.managedDatabases - .completeRestore( - resourceGroupName, - managedInstanceName, - databaseName, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the completeRestore function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} managedInstanceName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + restoreDatabase(resourceGroupName, managedInstanceName, databaseName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.managedDatabases.completeRestore(resourceGroupName, managedInstanceName, databaseName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_RDBMS; diff --git a/generator/generatedClasses/Azure/database/azure-noSql.js b/generator/generatedClasses/Azure/database/azure-noSql.js index c59fe9dd..190ed4f2 100644 --- a/generator/generatedClasses/Azure/database/azure-noSql.js +++ b/generator/generatedClasses/Azure/database/azure-noSql.js @@ -5,207 +5,128 @@ const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb"); * @category Azure */ class Azure_NoSql { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createUpdateTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} createUpdateTableParameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createCollection( - resourceGroupName, - accountName, - tableName, - createUpdateTableParameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new CosmosDBManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.tableResources - .createUpdateTable( - resourceGroupName, - accountName, - tableName, - createUpdateTableParameters, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createUpdateTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} createUpdateTableParameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createCollection(resourceGroupName, accountName, tableName, createUpdateTableParameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.tableResources.createUpdateTable(resourceGroupName, accountName, tableName, createUpdateTableParameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteCollection( - resourceGroupName, - accountName, - tableName, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new CosmosDBManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.tableResources - .deleteTable(resourceGroupName, accountName, tableName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteCollection(resourceGroupName, accountName, tableName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.tableResources.deleteTable(resourceGroupName, accountName, tableName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the listTables function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listCollections(resourceGroupName, accountName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new CosmosDBManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.tableResources - .listTables(resourceGroupName, accountName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the listTables function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listCollections(resourceGroupName, accountName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.tableResources.listTables(resourceGroupName, accountName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the updateTableThroughput function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} updateThroughputParameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - setAttribute( - resourceGroupName, - accountName, - tableName, - updateThroughputParameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new CosmosDBManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.tableResources - .updateTableThroughput( - resourceGroupName, - accountName, - tableName, - updateThroughputParameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the updateTableThroughput function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} updateThroughputParameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + setAttribute(resourceGroupName, accountName, tableName, updateThroughputParameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.tableResources.updateTableThroughput(resourceGroupName, accountName, tableName, updateThroughputParameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the getTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - getAttributes( - resourceGroupName, - accountName, - tableName, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new CosmosDBManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.tableResources - .getTable(resourceGroupName, accountName, tableName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the getTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + getAttributes(resourceGroupName, accountName, tableName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.tableResources.getTable(resourceGroupName, accountName, tableName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_NoSql; diff --git a/generator/generatedClasses/Azure/management/azure-keyManagement.js b/generator/generatedClasses/Azure/management/azure-keyManagement.js index 2a6a8316..2d594150 100644 --- a/generator/generatedClasses/Azure/management/azure-keyManagement.js +++ b/generator/generatedClasses/Azure/management/azure-keyManagement.js @@ -5,183 +5,126 @@ const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); * @category Azure */ class Azure_KeyManagement { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createKey(resourceGroupName, vaultName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new KeyVaultManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.vaults - .createOrUpdate(resourceGroupName, vaultName, parameters, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createKey(resourceGroupName, vaultName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.vaults.createOrUpdate(resourceGroupName, vaultName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteKey(resourceGroupName, vaultName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new KeyVaultManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.vaults - .deleteMethod(resourceGroupName, vaultName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteKey(resourceGroupName, vaultName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.vaults.deleteMethod(resourceGroupName, vaultName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the update function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, vaultName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new KeyVaultManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.vaults - .update(resourceGroupName, vaultName, parameters, options) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, vaultName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.vaults.update(resourceGroupName, vaultName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeKey(resourceGroupName, vaultName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new KeyVaultManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.vaults - .get(resourceGroupName, vaultName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeKey(resourceGroupName, vaultName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.vaults.get(resourceGroupName, vaultName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the updateAccessPolicy function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} operationKind - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - putKeyPolicy( - resourceGroupName, - vaultName, - operationKind, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new KeyVaultManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.vaults - .updateAccessPolicy( - resourceGroupName, - vaultName, - operationKind, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the updateAccessPolicy function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} operationKind - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + putKeyPolicy(resourceGroupName, vaultName, operationKind, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.vaults.updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_KeyManagement; diff --git a/generator/generatedClasses/Azure/management/azure-monitoring.js b/generator/generatedClasses/Azure/management/azure-monitoring.js index f365ad1d..e7b373c0 100644 --- a/generator/generatedClasses/Azure/management/azure-monitoring.js +++ b/generator/generatedClasses/Azure/management/azure-monitoring.js @@ -5,170 +5,122 @@ const { MonitorManagementClient } = require("@azure/arm-monitor"); * @category Azure */ class Azure_Monitoring { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createAlarm(resourceGroupName, ruleName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new MonitorManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.alertRules - .createOrUpdate(resourceGroupName, ruleName, parameters, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createAlarm(resourceGroupName, ruleName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.alertRules.createOrUpdate(resourceGroupName, ruleName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteAlarm(resourceGroupName, ruleName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new MonitorManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.alertRules - .deleteMethod(resourceGroupName, ruleName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteAlarm(resourceGroupName, ruleName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.alertRules.deleteMethod(resourceGroupName, ruleName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the update function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} alertRulesResource - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateAlarm( - resourceGroupName, - ruleName, - alertRulesResource, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new MonitorManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.alertRules - .update(resourceGroupName, ruleName, alertRulesResource, options) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} alertRulesResource - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateAlarm(resourceGroupName, ruleName, alertRulesResource, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.alertRules.update(resourceGroupName, ruleName, alertRulesResource, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the listBySubscription function of monitor - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listAlarms(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new MonitorManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.alertRules.listBySubscription(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listBySubscription function of monitor + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listAlarms(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.alertRules.listBySubscription(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the get function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - getMetricData(resourceGroupName, ruleName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new MonitorManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.alertRules - .get(resourceGroupName, ruleName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + getMetricData(resourceGroupName, ruleName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.alertRules.get(resourceGroupName, ruleName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_Monitoring; diff --git a/generator/generatedClasses/Azure/network/azure-DNS.js b/generator/generatedClasses/Azure/network/azure-DNS.js index 9e52b9cb..17a86c4b 100644 --- a/generator/generatedClasses/Azure/network/azure-DNS.js +++ b/generator/generatedClasses/Azure/network/azure-DNS.js @@ -5,150 +5,102 @@ const { DnsManagementClient } = require("@azure/arm-dns"); * @category Azure */ class Azure_DNS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createZone(resourceGroupName, zoneName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new DnsManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.zones - .createOrUpdate(resourceGroupName, zoneName, parameters, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createZone(resourceGroupName, zoneName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.zones.createOrUpdate(resourceGroupName, zoneName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteZone(resourceGroupName, zoneName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new DnsManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.zones - .deleteMethod(resourceGroupName, zoneName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteZone(resourceGroupName, zoneName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.zones.deleteMethod(resourceGroupName, zoneName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of dns - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listZones(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new DnsManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.zones.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the list function of dns + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listZones(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.zones.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createOrUpdate function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {StringKeyword} relativeRecordSetName - Mandatory parameter - * @param {TypeReference} recordType - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - changeRecordSets( - resourceGroupName, - zoneName, - relativeRecordSetName, - recordType, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new DnsManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.recordSets - .createOrUpdate( - resourceGroupName, - zoneName, - relativeRecordSetName, - recordType, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the createOrUpdate function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {StringKeyword} relativeRecordSetName - Mandatory parameter + * @param {TypeReference} recordType - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + changeRecordSets(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.recordSets.createOrUpdate(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_DNS; diff --git a/generator/generatedClasses/Azure/network/azure-loadBalancer.js b/generator/generatedClasses/Azure/network/azure-loadBalancer.js index 437a80c8..0d7ea4bc 100644 --- a/generator/generatedClasses/Azure/network/azure-loadBalancer.js +++ b/generator/generatedClasses/Azure/network/azure-loadBalancer.js @@ -5,181 +5,123 @@ const { NetworkManagementClient } = require("@azure/arm-network"); * @category Azure */ class Azure_LoadBalancer { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, loadBalancerName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new NetworkManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.loadBalancers - .createOrUpdate( - resourceGroupName, - loadBalancerName, - parameters, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, loadBalancerName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.loadBalancers.createOrUpdate(resourceGroupName, loadBalancerName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, loadBalancerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new NetworkManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.loadBalancers - .deleteMethod(resourceGroupName, loadBalancerName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, loadBalancerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.loadBalancers.deleteMethod(resourceGroupName, loadBalancerName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new NetworkManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.loadBalancers.list(resourceGroupName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the list function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.loadBalancers.list(resourceGroupName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the updateTags function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - addTags( - resourceGroupName, - loadBalancerName, - parameters, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new NetworkManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.loadBalancers - .updateTags( - resourceGroupName, - loadBalancerName, - parameters, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the updateTags function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + addTags(resourceGroupName, loadBalancerName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.loadBalancers.updateTags(resourceGroupName, loadBalancerName, parameters, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, loadBalancerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new NetworkManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.loadBalancers - .get(resourceGroupName, loadBalancerName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, loadBalancerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.loadBalancers.get(resourceGroupName, loadBalancerName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_LoadBalancer; diff --git a/generator/generatedClasses/Azure/storage/azure-blockStorage.js b/generator/generatedClasses/Azure/storage/azure-blockStorage.js index 638df80b..13ea3e7d 100644 --- a/generator/generatedClasses/Azure/storage/azure-blockStorage.js +++ b/generator/generatedClasses/Azure/storage/azure-blockStorage.js @@ -5,165 +5,122 @@ const { ComputeManagementClient } = require("@azure/arm-compute"); * @category Azure */ class Azure_BlockStorage { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} disk - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, diskName, disk, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.disks - .createOrUpdate(resourceGroupName, diskName, disk, options) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} disk - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, diskName, disk, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.disks.createOrUpdate(resourceGroupName, diskName, disk, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, diskName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.disks - .deleteMethod(resourceGroupName, diskName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, diskName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.disks.deleteMethod(resourceGroupName, diskName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the get function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, diskName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.disks - .get(resourceGroupName, diskName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the get function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, diskName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.disks.get(resourceGroupName, diskName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of compute - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.disks.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the list function of compute + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.disks.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the update function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} disk - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, diskName, disk, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new ComputeManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.disks - .update(resourceGroupName, diskName, disk, options) - .then(result => { - resolve(result); + } + /** + * Trigers the update function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} disk - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, diskName, disk, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.disks.update(resourceGroupName, diskName, disk, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_BlockStorage; diff --git a/generator/generatedClasses/Azure/storage/azure-storageBucket.js b/generator/generatedClasses/Azure/storage/azure-storageBucket.js index b060e6fc..f2e9e22c 100644 --- a/generator/generatedClasses/Azure/storage/azure-storageBucket.js +++ b/generator/generatedClasses/Azure/storage/azure-storageBucket.js @@ -5,125 +5,81 @@ const { StorageManagementClient } = require("@azure/arm-storage"); * @category Azure */ class Azure_StorageBucket { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the create function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} containerName - Mandatory parameter - * @param {TypeReference} blobContainer - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create( - resourceGroupName, - accountName, - containerName, - blobContainer, - options = undefined - ) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new StorageManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.blobContainers - .create( - resourceGroupName, - accountName, - containerName, - blobContainer, - options - ) - .then(result => { - resolve(result); + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the create function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} containerName - Mandatory parameter + * @param {TypeReference} blobContainer - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, accountName, containerName, blobContainer, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.blobContainers.create(resourceGroupName, accountName, containerName, blobContainer, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the deleteMethod function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} containerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, accountName, containerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new StorageManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.blobContainers - .deleteMethod( - resourceGroupName, - accountName, - containerName, - options - ) - .then(result => { - resolve(result); + } + /** + * Trigers the deleteMethod function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} containerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, accountName, containerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.blobContainers.deleteMethod(resourceGroupName, accountName, containerName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } - /** - * Trigers the list function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, accountName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse( - process.env.AZURE_CLIENT_ID, - process.env.AZURE_CLIENT_SECRET, - process.env.AZURE_TENANT_ID - ) - .then(authres => { - const client = new StorageManagementClient( - authres.credentials, - process.env.AZURE_SUBSCRIPTION_ID - ); - client.blobContainers - .list(resourceGroupName, accountName, options) - .then(result => { - resolve(result); + } + /** + * Trigers the list function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, accountName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) + .then(authres => { + const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); + client.blobContainers.list(resourceGroupName, accountName, options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); }); - }) - .catch(err => { - reject(err); }); - }); - } + } } module.exports = Azure_StorageBucket; diff --git a/generator/generatedClasses/DO/compute/do-computeInstance.js b/generator/generatedClasses/DO/compute/do-computeInstance.js index 7f925773..70594a63 100644 --- a/generator/generatedClasses/DO/compute/do-computeInstance.js +++ b/generator/generatedClasses/DO/compute/do-computeInstance.js @@ -1,79 +1,70 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Droplets object - * @category Digital Ocean - */ +* Class to create a Droplets object +* @category Digital Ocean +*/ class DO_ComputeInstance { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._droplets = this._instance.droplets; - } - /** - * Trigers the getAll function of Droplets - * @param {StringKeyword} tagName - Data required for getAll - * @param {BooleanKeyword} includeAll - Data required for getAll - * @param {NumberKeyword} page - Data required for getAll - * @param {NumberKeyword} pageSize - Data required for getAll - * @returns {Promise} - */ - list( - tagName, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._droplets - .getAll(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Droplets - * @param {DropletCreationRequest} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._droplets - .create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteById function of Droplets - * @param {StringKeyword} dropletId - Data required for deleteById - * @returns {Promise} - */ - destroy(dropletId) { - return new Promise((resolve, reject) => { - this._droplets - .deleteById(dropletId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the requestAction function of Droplets - * @param {StringKeyword} dropletId - Data required for requestAction - * @param {AnyKeyword} action - Data required for requestAction - * @returns {Promise} - */ - stop(dropletId, action) { - return new Promise((resolve, reject) => { - this._droplets - .requestAction(dropletId, action) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._droplets = this._instance.droplets; + } + /** + * Trigers the getAll function of Droplets + * @param {StringKeyword} tagName - Data required for getAll + * @param {BooleanKeyword} includeAll - Data required for getAll + * @param {NumberKeyword} page - Data required for getAll + * @param {NumberKeyword} pageSize - Data required for getAll + * @returns {Promise} + */ + list(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._droplets.getAll(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Droplets + * @param {DropletCreationRequest} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._droplets.create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteById function of Droplets + * @param {StringKeyword} dropletId - Data required for deleteById + * @returns {Promise} + */ + destroy(dropletId) { + return new Promise((resolve, reject) => { + this._droplets.deleteById(dropletId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the requestAction function of Droplets + * @param {StringKeyword} dropletId - Data required for requestAction + * @param {AnyKeyword} action - Data required for requestAction + * @returns {Promise} + */ + stop(dropletId, action) { + return new Promise((resolve, reject) => { + this._droplets.requestAction(dropletId, action) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_ComputeInstance; diff --git a/generator/generatedClasses/DO/compute/do-kubernetes.js b/generator/generatedClasses/DO/compute/do-kubernetes.js index ae3db733..e5bacb21 100644 --- a/generator/generatedClasses/DO/compute/do-kubernetes.js +++ b/generator/generatedClasses/DO/compute/do-kubernetes.js @@ -1,135 +1,122 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Kubernetes object - * @category Digital Ocean - */ +* Class to create a Kubernetes object +* @category Digital Ocean +*/ class DO_Kubernetes { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._kubernetes = this._instance.kubernetes; - } - /** - * Trigers the getClusters function of Kubernetes - * @param {BooleanKeyword} includeAll - Data required for getClusters - * @param {NumberKeyword} page - Data required for getClusters - * @param {NumberKeyword} pageSize - Data required for getClusters - * @returns {Promise} - */ - listClusters(includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._kubernetes - .getClusters(includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Kubernetes - * @param {NewClusterRequest} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._kubernetes - .create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getById - * @returns {Promise} - */ - describeCluster(clusterId) { - return new Promise((resolve, reject) => { - this._kubernetes - .getById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of Kubernetes - * @param {StringKeyword} clusterId - Data required for delete - * @returns {Promise} - */ - delete(clusterId) { - return new Promise((resolve, reject) => { - this._kubernetes - .delete(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getNodePools function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getNodePools - * @param {BooleanKeyword} includeAll - Data required for getNodePools - * @param {NumberKeyword} page - Data required for getNodePools - * @param {NumberKeyword} pageSize - Data required for getNodePools - * @returns {Promise} - */ - listNodegroups( - clusterId, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._kubernetes - .getNodePools(clusterId, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getNodePoolById function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getNodePoolById - * @param {StringKeyword} nodePoolId - Data required for getNodePoolById - * @returns {Promise} - */ - describeNodeGroup(clusterId, nodePoolId) { - return new Promise((resolve, reject) => { - this._kubernetes - .getNodePoolById(clusterId, nodePoolId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the addNodePool function of Kubernetes - * @param {StringKeyword} clusterId - Data required for addNodePool - * @param {ClusterNodePool} nodePool - Data required for addNodePool - * @returns {Promise} - */ - createNodeGroup(clusterId, nodePool) { - return new Promise((resolve, reject) => { - this._kubernetes - .addNodePool(clusterId, nodePool) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteNodePool function of Kubernetes - * @param {StringKeyword} clusterId - Data required for deleteNodePool - * @param {StringKeyword} nodePoolId - Data required for deleteNodePool - * @returns {Promise} - */ - deleteNodegroup(clusterId, nodePoolId) { - return new Promise((resolve, reject) => { - this._kubernetes - .deleteNodePool(clusterId, nodePoolId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._kubernetes = this._instance.kubernetes; + } + /** + * Trigers the getClusters function of Kubernetes + * @param {BooleanKeyword} includeAll - Data required for getClusters + * @param {NumberKeyword} page - Data required for getClusters + * @param {NumberKeyword} pageSize - Data required for getClusters + * @returns {Promise} + */ + listClusters(includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._kubernetes.getClusters(includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Kubernetes + * @param {NewClusterRequest} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._kubernetes.create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getById + * @returns {Promise} + */ + describeCluster(clusterId) { + return new Promise((resolve, reject) => { + this._kubernetes.getById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of Kubernetes + * @param {StringKeyword} clusterId - Data required for delete + * @returns {Promise} + */ + delete(clusterId) { + return new Promise((resolve, reject) => { + this._kubernetes.delete(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getNodePools function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getNodePools + * @param {BooleanKeyword} includeAll - Data required for getNodePools + * @param {NumberKeyword} page - Data required for getNodePools + * @param {NumberKeyword} pageSize - Data required for getNodePools + * @returns {Promise} + */ + listNodegroups(clusterId, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._kubernetes.getNodePools(clusterId, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getNodePoolById function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getNodePoolById + * @param {StringKeyword} nodePoolId - Data required for getNodePoolById + * @returns {Promise} + */ + describeNodeGroup(clusterId, nodePoolId) { + return new Promise((resolve, reject) => { + this._kubernetes.getNodePoolById(clusterId, nodePoolId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the addNodePool function of Kubernetes + * @param {StringKeyword} clusterId - Data required for addNodePool + * @param {ClusterNodePool} nodePool - Data required for addNodePool + * @returns {Promise} + */ + createNodeGroup(clusterId, nodePool) { + return new Promise((resolve, reject) => { + this._kubernetes.addNodePool(clusterId, nodePool) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteNodePool function of Kubernetes + * @param {StringKeyword} clusterId - Data required for deleteNodePool + * @param {StringKeyword} nodePoolId - Data required for deleteNodePool + * @returns {Promise} + */ + deleteNodegroup(clusterId, nodePoolId) { + return new Promise((resolve, reject) => { + this._kubernetes.deleteNodePool(clusterId, nodePoolId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_Kubernetes; diff --git a/generator/generatedClasses/DO/database/do-RDBMS.js b/generator/generatedClasses/DO/database/do-RDBMS.js index 9363be19..fa59255a 100644 --- a/generator/generatedClasses/DO/database/do-RDBMS.js +++ b/generator/generatedClasses/DO/database/do-RDBMS.js @@ -1,79 +1,70 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Databases object - * @category Digital Ocean - */ +* Class to create a Databases object +* @category Digital Ocean +*/ class DO_RDBMS { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._databases = this._instance.databases; - } - /** - * Trigers the getAllClusters function of Databases - * @param {StringKeyword} tagName - Data required for getAllClusters - * @param {BooleanKeyword} includeAll - Data required for getAllClusters - * @param {NumberKeyword} page - Data required for getAllClusters - * @param {NumberKeyword} pageSize - Data required for getAllClusters - * @returns {Promise} - */ - getClusters( - tagName, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._databases - .getAllClusters(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createCluster function of Databases - * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster - * @returns {Promise} - */ - createCluster(clusterOptions) { - return new Promise((resolve, reject) => { - this._databases - .createCluster(clusterOptions) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getClusterById function of Databases - * @param {StringKeyword} clusterId - Data required for getClusterById - * @returns {Promise} - */ - getCluster(clusterId) { - return new Promise((resolve, reject) => { - this._databases - .getClusterById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the resizeCluster function of Databases - * @param {StringKeyword} clusterId - Data required for resizeCluster - * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster - * @returns {Promise} - */ - updateCluster(clusterId, configuration) { - return new Promise((resolve, reject) => { - this._databases - .resizeCluster(clusterId, configuration) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._databases = this._instance.databases; + } + /** + * Trigers the getAllClusters function of Databases + * @param {StringKeyword} tagName - Data required for getAllClusters + * @param {BooleanKeyword} includeAll - Data required for getAllClusters + * @param {NumberKeyword} page - Data required for getAllClusters + * @param {NumberKeyword} pageSize - Data required for getAllClusters + * @returns {Promise} + */ + getClusters(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._databases.getAllClusters(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createCluster function of Databases + * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster + * @returns {Promise} + */ + createCluster(clusterOptions) { + return new Promise((resolve, reject) => { + this._databases.createCluster(clusterOptions) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getClusterById function of Databases + * @param {StringKeyword} clusterId - Data required for getClusterById + * @returns {Promise} + */ + getCluster(clusterId) { + return new Promise((resolve, reject) => { + this._databases.getClusterById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the resizeCluster function of Databases + * @param {StringKeyword} clusterId - Data required for resizeCluster + * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster + * @returns {Promise} + */ + updateCluster(clusterId, configuration) { + return new Promise((resolve, reject) => { + this._databases.resizeCluster(clusterId, configuration) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_RDBMS; diff --git a/generator/generatedClasses/DO/database/do-noSql.js b/generator/generatedClasses/DO/database/do-noSql.js index 808b12d4..7d7650f5 100644 --- a/generator/generatedClasses/DO/database/do-noSql.js +++ b/generator/generatedClasses/DO/database/do-noSql.js @@ -1,79 +1,70 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Databases object - * @category Digital Ocean - */ +* Class to create a Databases object +* @category Digital Ocean +*/ class DO_NoSql { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._databases = this._instance.databases; - } - /** - * Trigers the getAllClusters function of Databases - * @param {StringKeyword} tagName - Data required for getAllClusters - * @param {BooleanKeyword} includeAll - Data required for getAllClusters - * @param {NumberKeyword} page - Data required for getAllClusters - * @param {NumberKeyword} pageSize - Data required for getAllClusters - * @returns {Promise} - */ - getClusters( - tagName, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._databases - .getAllClusters(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createCluster function of Databases - * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster - * @returns {Promise} - */ - createCluster(clusterOptions) { - return new Promise((resolve, reject) => { - this._databases - .createCluster(clusterOptions) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getClusterById function of Databases - * @param {StringKeyword} clusterId - Data required for getClusterById - * @returns {Promise} - */ - getCluster(clusterId) { - return new Promise((resolve, reject) => { - this._databases - .getClusterById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the resizeCluster function of Databases - * @param {StringKeyword} clusterId - Data required for resizeCluster - * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster - * @returns {Promise} - */ - updateCluster(clusterId, configuration) { - return new Promise((resolve, reject) => { - this._databases - .resizeCluster(clusterId, configuration) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._databases = this._instance.databases; + } + /** + * Trigers the getAllClusters function of Databases + * @param {StringKeyword} tagName - Data required for getAllClusters + * @param {BooleanKeyword} includeAll - Data required for getAllClusters + * @param {NumberKeyword} page - Data required for getAllClusters + * @param {NumberKeyword} pageSize - Data required for getAllClusters + * @returns {Promise} + */ + getClusters(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._databases.getAllClusters(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createCluster function of Databases + * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster + * @returns {Promise} + */ + createCluster(clusterOptions) { + return new Promise((resolve, reject) => { + this._databases.createCluster(clusterOptions) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getClusterById function of Databases + * @param {StringKeyword} clusterId - Data required for getClusterById + * @returns {Promise} + */ + getCluster(clusterId) { + return new Promise((resolve, reject) => { + this._databases.getClusterById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the resizeCluster function of Databases + * @param {StringKeyword} clusterId - Data required for resizeCluster + * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster + * @returns {Promise} + */ + updateCluster(clusterId, configuration) { + return new Promise((resolve, reject) => { + this._databases.resizeCluster(clusterId, configuration) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_NoSql; diff --git a/generator/generatedClasses/DO/management/do-keyManagement.js b/generator/generatedClasses/DO/management/do-keyManagement.js index ec2921ee..d4e8f11a 100644 --- a/generator/generatedClasses/DO/management/do-keyManagement.js +++ b/generator/generatedClasses/DO/management/do-keyManagement.js @@ -1,78 +1,69 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Keys object - * @category Digital Ocean - */ +* Class to create a Keys object +* @category Digital Ocean +*/ class DO_KeyManagement { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._keys = this._instance.keys; - } - /** - * Trigers the getAll function of Keys - * @param {StringKeyword} tagName - Data required for getAll - * @param {BooleanKeyword} includeAll - Data required for getAll - * @param {NumberKeyword} page - Data required for getAll - * @param {NumberKeyword} pageSize - Data required for getAll - * @returns {Promise} - */ - list( - tagName, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._keys - .getAll(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Keys - * @param {NumberKeyword} keyId - Data required for getById - * @returns {Promise} - */ - describeKey(keyId) { - return new Promise((resolve, reject) => { - this._keys - .getById(keyId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the add function of Keys - * @param {AddKeyRequest} addKeyRequest - Data required for add - * @returns {Promise} - */ - createKey(addKeyRequest) { - return new Promise((resolve, reject) => { - this._keys - .add(addKeyRequest) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of Keys - * @param {StringKeyword} identifier - Data required for delete - * @returns {Promise} - */ - deleteKey(identifier) { - return new Promise((resolve, reject) => { - this._keys - .delete(identifier) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._keys = this._instance.keys; + } + /** + * Trigers the getAll function of Keys + * @param {StringKeyword} tagName - Data required for getAll + * @param {BooleanKeyword} includeAll - Data required for getAll + * @param {NumberKeyword} page - Data required for getAll + * @param {NumberKeyword} pageSize - Data required for getAll + * @returns {Promise} + */ + list(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._keys.getAll(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Keys + * @param {NumberKeyword} keyId - Data required for getById + * @returns {Promise} + */ + describeKey(keyId) { + return new Promise((resolve, reject) => { + this._keys.getById(keyId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the add function of Keys + * @param {AddKeyRequest} addKeyRequest - Data required for add + * @returns {Promise} + */ + createKey(addKeyRequest) { + return new Promise((resolve, reject) => { + this._keys.add(addKeyRequest) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of Keys + * @param {StringKeyword} identifier - Data required for delete + * @returns {Promise} + */ + deleteKey(identifier) { + return new Promise((resolve, reject) => { + this._keys.delete(identifier) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_KeyManagement; diff --git a/generator/generatedClasses/DO/network/do-DNS.js b/generator/generatedClasses/DO/network/do-DNS.js index 377e3bb7..ced40bd0 100644 --- a/generator/generatedClasses/DO/network/do-DNS.js +++ b/generator/generatedClasses/DO/network/do-DNS.js @@ -1,98 +1,87 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Domains object - * @category Digital Ocean - */ +* Class to create a Domains object +* @category Digital Ocean +*/ class DO_DNS { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._domains = this._instance.domains; - } - /** - * Trigers the getAllRecords function of Domains - * @param {StringKeyword} domainName - Data required for getAllRecords - * @param {StringKeyword} tagName - Data required for getAllRecords - * @param {BooleanKeyword} includeAll - Data required for getAllRecords - * @param {NumberKeyword} page - Data required for getAllRecords - * @param {NumberKeyword} pageSize - Data required for getAllRecords - * @returns {Promise} - */ - getRecords( - domainName, - tagName, - includeAll = undefined, - page = undefined, - pageSize = undefined - ) { - return new Promise((resolve, reject) => { - this._domains - .getAllRecords(domainName, tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createRecord function of Domains - * @param {StringKeyword} domainName - Data required for createRecord - * @param {DomainRecordRequestOptions} options - Data required for createRecord - * @returns {Promise} - */ - createRecord(domainName, options) { - return new Promise((resolve, reject) => { - this._domains - .createRecord(domainName, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getRecord function of Domains - * @param {StringKeyword} domainName - Data required for getRecord - * @param {StringKeyword} recordId - Data required for getRecord - * @returns {Promise} - */ - getRecord(domainName, recordId) { - return new Promise((resolve, reject) => { - this._domains - .getRecord(domainName, recordId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteRecord function of Domains - * @param {StringKeyword} domainName - Data required for deleteRecord - * @param {StringKeyword} recordId - Data required for deleteRecord - * @returns {Promise} - */ - deleteRecord(domainName, recordId) { - return new Promise((resolve, reject) => { - this._domains - .deleteRecord(domainName, recordId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the updateRecord function of Domains - * @param {StringKeyword} domainName - Data required for updateRecord - * @param {StringKeyword} recordId - Data required for updateRecord - * @param {DomainRecordRequestOptions} options - Data required for updateRecord - * @returns {Promise} - */ - changeRecordSets(domainName, recordId, options) { - return new Promise((resolve, reject) => { - this._domains - .updateRecord(domainName, recordId, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._domains = this._instance.domains; + } + /** + * Trigers the getAllRecords function of Domains + * @param {StringKeyword} domainName - Data required for getAllRecords + * @param {StringKeyword} tagName - Data required for getAllRecords + * @param {BooleanKeyword} includeAll - Data required for getAllRecords + * @param {NumberKeyword} page - Data required for getAllRecords + * @param {NumberKeyword} pageSize - Data required for getAllRecords + * @returns {Promise} + */ + getRecords(domainName, tagName, includeAll = undefined, page = undefined, pageSize = undefined) { + return new Promise((resolve, reject) => { + this._domains.getAllRecords(domainName, tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createRecord function of Domains + * @param {StringKeyword} domainName - Data required for createRecord + * @param {DomainRecordRequestOptions} options - Data required for createRecord + * @returns {Promise} + */ + createRecord(domainName, options) { + return new Promise((resolve, reject) => { + this._domains.createRecord(domainName, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getRecord function of Domains + * @param {StringKeyword} domainName - Data required for getRecord + * @param {StringKeyword} recordId - Data required for getRecord + * @returns {Promise} + */ + getRecord(domainName, recordId) { + return new Promise((resolve, reject) => { + this._domains.getRecord(domainName, recordId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteRecord function of Domains + * @param {StringKeyword} domainName - Data required for deleteRecord + * @param {StringKeyword} recordId - Data required for deleteRecord + * @returns {Promise} + */ + deleteRecord(domainName, recordId) { + return new Promise((resolve, reject) => { + this._domains.deleteRecord(domainName, recordId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the updateRecord function of Domains + * @param {StringKeyword} domainName - Data required for updateRecord + * @param {StringKeyword} recordId - Data required for updateRecord + * @param {DomainRecordRequestOptions} options - Data required for updateRecord + * @returns {Promise} + */ + changeRecordSets(domainName, recordId, options) { + return new Promise((resolve, reject) => { + this._domains.updateRecord(domainName, recordId, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_DNS; diff --git a/generator/generatedClasses/DO/network/do-loadBalancer.js b/generator/generatedClasses/DO/network/do-loadBalancer.js index c1d64d0b..cd02d3c1 100644 --- a/generator/generatedClasses/DO/network/do-loadBalancer.js +++ b/generator/generatedClasses/DO/network/do-loadBalancer.js @@ -1,70 +1,66 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a LoadBalancers object - * @category Digital Ocean - */ +* Class to create a LoadBalancers object +* @category Digital Ocean +*/ class DO_LoadBalancer { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._loadBalancers = this._instance.loadBalancers; - } - /** - * Trigers the create function of LoadBalancers - * @param {LoadBalancerCreationOptions} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._loadBalancers - .create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getAll function of LoadBalancers - * @returns {Promise} - */ - list() { - return new Promise((resolve, reject) => { - this._loadBalancers - .getAll() - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the update function of LoadBalancers - * @param {StringKeyword} loadBalancerId - Data required for update - * @param {AnyKeyword} options - Data required for update - * @returns {Promise} - */ - update(loadBalancerId, options) { - return new Promise((resolve, reject) => { - this._loadBalancers - .update(loadBalancerId, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of LoadBalancers - * @param {StringKeyword} loadBalancerId - Data required for delete - * @returns {Promise} - */ - delete(loadBalancerId) { - return new Promise((resolve, reject) => { - this._loadBalancers - .delete(loadBalancerId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._loadBalancers = this._instance.loadBalancers; + } + /** + * Trigers the create function of LoadBalancers + * @param {LoadBalancerCreationOptions} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._loadBalancers.create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getAll function of LoadBalancers + * @returns {Promise} + */ + list() { + return new Promise((resolve, reject) => { + this._loadBalancers.getAll() + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the update function of LoadBalancers + * @param {StringKeyword} loadBalancerId - Data required for update + * @param {AnyKeyword} options - Data required for update + * @returns {Promise} + */ + update(loadBalancerId, options) { + return new Promise((resolve, reject) => { + this._loadBalancers.update(loadBalancerId, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of LoadBalancers + * @param {StringKeyword} loadBalancerId - Data required for delete + * @returns {Promise} + */ + delete(loadBalancerId) { + return new Promise((resolve, reject) => { + this._loadBalancers.delete(loadBalancerId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_LoadBalancer; diff --git a/generator/generatedClasses/DO/storage/do-blockStorage.js b/generator/generatedClasses/DO/storage/do-blockStorage.js index 2a2c86f5..5724610c 100644 --- a/generator/generatedClasses/DO/storage/do-blockStorage.js +++ b/generator/generatedClasses/DO/storage/do-blockStorage.js @@ -1,70 +1,66 @@ /*This is an auto generated class, please do not change.*/ /** - * Class to create a Volumes object - * @category Digital Ocean - */ +* Class to create a Volumes object +* @category Digital Ocean +*/ class DO_BlockStorage { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._volumes = this._instance.volumes; - } - /** - * Trigers the getAll function of Volumes - * @param {StringKeyword} region - Data required for getAll - * @returns {Promise} - */ - list(region) { - return new Promise((resolve, reject) => { - this._volumes - .getAll(region) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Volumes - * @param {VolumeCreationOptions} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._volumes - .create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Volumes - * @param {StringKeyword} volumeId - Data required for getById - * @returns {Promise} - */ - describe(volumeId) { - return new Promise((resolve, reject) => { - this._volumes - .getById(volumeId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteById function of Volumes - * @param {StringKeyword} volumeId - Data required for deleteById - * @returns {Promise} - */ - delete(volumeId) { - return new Promise((resolve, reject) => { - this._volumes - .deleteById(volumeId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._volumes = this._instance.volumes; + } + /** + * Trigers the getAll function of Volumes + * @param {StringKeyword} region - Data required for getAll + * @returns {Promise} + */ + list(region) { + return new Promise((resolve, reject) => { + this._volumes.getAll(region) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Volumes + * @param {VolumeCreationOptions} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._volumes.create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Volumes + * @param {StringKeyword} volumeId - Data required for getById + * @returns {Promise} + */ + describe(volumeId) { + return new Promise((resolve, reject) => { + this._volumes.getById(volumeId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteById function of Volumes + * @param {StringKeyword} volumeId - Data required for deleteById + * @returns {Promise} + */ + delete(volumeId) { + return new Promise((resolve, reject) => { + this._volumes.deleteById(volumeId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_BlockStorage; diff --git a/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js b/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js index bcc03216..dd66d85f 100644 --- a/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js +++ b/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js @@ -5,102 +5,97 @@ const { TranslationServiceClient } = require("@google-cloud/translate"); * @category Google Cloud */ class GCP_Translation { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._translationServiceClient = new TranslationServiceClient(config); - } - /** - * Trigers the translateText function of undefined - * @param {TypeReference} request - Data required for translateText - * @param {TypeReference} [options] - Data required for translateText - * @returns {Promise} - */ - translate(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient - .translateText(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._translationServiceClient = new TranslationServiceClient(config); + } + /** + * Trigers the translateText function of undefined + * @param {TypeReference} request - Data required for translateText + * @param {TypeReference} [options] - Data required for translateText + * @returns {Promise} + */ + translate(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient.translateText(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the batchTranslateText function of undefined - * @param {TypeReference} request - Data required for batchTranslateText - * @param {TypeReference} [options] - Data required for batchTranslateText - * @returns {Promise} - */ - batchTranslate(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient - .batchTranslateText(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the batchTranslateText function of undefined + * @param {TypeReference} request - Data required for batchTranslateText + * @param {TypeReference} [options] - Data required for batchTranslateText + * @returns {Promise} + */ + batchTranslate(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient.batchTranslateText(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getGlossary function of undefined - * @param {TypeReference} request - Data required for getGlossary - * @param {TypeReference} [options] - Data required for getGlossary - * @returns {Promise} - */ - getGlossary(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient - .getGlossary(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getGlossary function of undefined + * @param {TypeReference} request - Data required for getGlossary + * @param {TypeReference} [options] - Data required for getGlossary + * @returns {Promise} + */ + getGlossary(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient.getGlossary(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createGlossary function of undefined - * @param {TypeReference} request - Data required for createGlossary - * @param {TypeReference} [options] - Data required for createGlossary - * @returns {Promise} - */ - createGlossary(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient - .createGlossary(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createGlossary function of undefined + * @param {TypeReference} request - Data required for createGlossary + * @param {TypeReference} [options] - Data required for createGlossary + * @returns {Promise} + */ + createGlossary(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient.createGlossary(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the detectLanguage function of undefined - * @param {TypeReference} request - Data required for detectLanguage - * @param {TypeReference} [options] - Data required for detectLanguage - * @returns {Promise} - */ - detectLanguage(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient - .detectLanguage(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the detectLanguage function of undefined + * @param {TypeReference} request - Data required for detectLanguage + * @param {TypeReference} [options] - Data required for detectLanguage + * @returns {Promise} + */ + detectLanguage(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient.detectLanguage(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_Translation; diff --git a/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js b/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js index e0c08e67..340e295b 100644 --- a/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js +++ b/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js @@ -5,174 +5,165 @@ const { ClusterManagerClient } = require("@google-cloud/container"); * @category Google Cloud */ class GCP_Kubernetes { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._clusterManagerClient = new ClusterManagerClient(config); - } - /** - * Trigers the createCluster function of undefined - * @param {TypeReference} request - Data required for createCluster - * @param {TypeReference} [options] - Data required for createCluster - * @returns {Promise} - */ - create(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .createCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._clusterManagerClient = new ClusterManagerClient(config); + } + /** + * Trigers the createCluster function of undefined + * @param {TypeReference} request - Data required for createCluster + * @param {TypeReference} [options] - Data required for createCluster + * @returns {Promise} + */ + create(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.createCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteCluster function of undefined - * @param {TypeReference} request - Data required for deleteCluster - * @param {TypeReference} [options] - Data required for deleteCluster - * @returns {Promise} - */ - delete(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .deleteCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteCluster function of undefined + * @param {TypeReference} request - Data required for deleteCluster + * @param {TypeReference} [options] - Data required for deleteCluster + * @returns {Promise} + */ + delete(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.deleteCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the listClusters function of undefined - * @param {TypeReference} request - Data required for listClusters - * @param {TypeReference} [options] - Data required for listClusters - * @returns {Promise} - */ - listClusters(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .listClusters(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listClusters function of undefined + * @param {TypeReference} request - Data required for listClusters + * @param {TypeReference} [options] - Data required for listClusters + * @returns {Promise} + */ + listClusters(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.listClusters(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getCluster function of undefined - * @param {TypeReference} request - Data required for getCluster - * @param {TypeReference} [options] - Data required for getCluster - * @returns {Promise} - */ - describeCluster(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .getCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getCluster function of undefined + * @param {TypeReference} request - Data required for getCluster + * @param {TypeReference} [options] - Data required for getCluster + * @returns {Promise} + */ + describeCluster(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.getCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createNodePool function of undefined - * @param {TypeReference} request - Data required for createNodePool - * @param {TypeReference} [options] - Data required for createNodePool - * @returns {Promise} - */ - createNodeGroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .createNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createNodePool function of undefined + * @param {TypeReference} request - Data required for createNodePool + * @param {TypeReference} [options] - Data required for createNodePool + * @returns {Promise} + */ + createNodeGroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.createNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteNodePool function of undefined - * @param {TypeReference} request - Data required for deleteNodePool - * @param {TypeReference} [options] - Data required for deleteNodePool - * @returns {Promise} - */ - deleteNodegroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .deleteNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteNodePool function of undefined + * @param {TypeReference} request - Data required for deleteNodePool + * @param {TypeReference} [options] - Data required for deleteNodePool + * @returns {Promise} + */ + deleteNodegroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.deleteNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getNodePool function of undefined - * @param {TypeReference} request - Data required for getNodePool - * @param {TypeReference} [options] - Data required for getNodePool - * @returns {Promise} - */ - describeNodeGroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .getNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getNodePool function of undefined + * @param {TypeReference} request - Data required for getNodePool + * @param {TypeReference} [options] - Data required for getNodePool + * @returns {Promise} + */ + describeNodeGroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.getNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the listNodePools function of undefined - * @param {TypeReference} request - Data required for listNodePools - * @param {TypeReference} [options] - Data required for listNodePools - * @returns {Promise} - */ - listNodegroups(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .listNodePools(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listNodePools function of undefined + * @param {TypeReference} request - Data required for listNodePools + * @param {TypeReference} [options] - Data required for listNodePools + * @returns {Promise} + */ + listNodegroups(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.listNodePools(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the setAddonsConfig function of undefined - * @param {TypeReference} request - Data required for setAddonsConfig - * @param {TypeReference} [options] - Data required for setAddonsConfig - * @returns {Promise} - */ - updateConfig(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient - .setAddonsConfig(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the setAddonsConfig function of undefined + * @param {TypeReference} request - Data required for setAddonsConfig + * @param {TypeReference} [options] - Data required for setAddonsConfig + * @returns {Promise} + */ + updateConfig(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient.setAddonsConfig(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_Kubernetes; diff --git a/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js b/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js index 46bbe942..a1364ad9 100644 --- a/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js +++ b/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js @@ -5,130 +5,124 @@ const { DatabaseAdminClient } = require("@google-cloud/spanner"); * @category Google Cloud */ class GCP_RDBMS { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._databaseAdminClient = new DatabaseAdminClient(config); - } - /** - * Trigers the createDatabase function of undefined - * @param {TypeReference} request - Data required for createDatabase - * @param {TypeReference} [options] - Data required for createDatabase - * @returns {Promise} - */ - createDatabse(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .createDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._databaseAdminClient = new DatabaseAdminClient(config); + } + /** + * Trigers the createDatabase function of undefined + * @param {TypeReference} request - Data required for createDatabase + * @param {TypeReference} [options] - Data required for createDatabase + * @returns {Promise} + */ + createDatabse(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.createDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the dropDatabase function of undefined - * @param {TypeReference} request - Data required for dropDatabase - * @param {TypeReference} [options] - Data required for dropDatabase - * @returns {Promise} - */ - deleteDatabase(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .dropDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the dropDatabase function of undefined + * @param {TypeReference} request - Data required for dropDatabase + * @param {TypeReference} [options] - Data required for dropDatabase + * @returns {Promise} + */ + deleteDatabase(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.dropDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createBackup function of undefined - * @param {TypeReference} request - Data required for createBackup - * @param {TypeReference} [options] - Data required for createBackup - * @returns {Promise} - */ - createSnapshots(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .createBackup(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createBackup function of undefined + * @param {TypeReference} request - Data required for createBackup + * @param {TypeReference} [options] - Data required for createBackup + * @returns {Promise} + */ + createSnapshots(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.createBackup(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the updateDatabaseDdl function of undefined - * @param {TypeReference} request - Data required for updateDatabaseDdl - * @param {TypeReference} [options] - Data required for updateDatabaseDdl - * @returns {Promise} - */ - modifyDB(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .updateDatabaseDdl(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the updateDatabaseDdl function of undefined + * @param {TypeReference} request - Data required for updateDatabaseDdl + * @param {TypeReference} [options] - Data required for updateDatabaseDdl + * @returns {Promise} + */ + modifyDB(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.updateDatabaseDdl(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the restoreDatabase function of undefined - * @param {TypeReference} request - Data required for restoreDatabase - * @param {TypeReference} [options] - Data required for restoreDatabase - * @returns {Promise} - */ - restoreDatabase(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .restoreDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the restoreDatabase function of undefined + * @param {TypeReference} request - Data required for restoreDatabase + * @param {TypeReference} [options] - Data required for restoreDatabase + * @returns {Promise} + */ + restoreDatabase(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.restoreDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteBackup function of undefined - * @param {TypeReference} request - Data required for deleteBackup - * @param {TypeReference} [options] - Data required for deleteBackup - * @returns {Promise} - */ - deleteDBSnapshot(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient - .deleteBackup(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteBackup function of undefined + * @param {TypeReference} request - Data required for deleteBackup + * @param {TypeReference} [options] - Data required for deleteBackup + * @returns {Promise} + */ + deleteDBSnapshot(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient.deleteBackup(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the databasePath function of undefined - * @param {StringKeyword} project - Data required for databasePath - * @param {StringKeyword} instance - Data required for databasePath - * @param {StringKeyword} database - Data required for databasePath - * @returns {Promise} - */ - databasePath(project, instance, database) { - return this._databaseAdminClient.databasePath(project, instance, database); - } + } + /** + * Trigers the databasePath function of undefined + * @param {StringKeyword} project - Data required for databasePath + * @param {StringKeyword} instance - Data required for databasePath + * @param {StringKeyword} database - Data required for databasePath + * @returns {Promise} + */ + databasePath(project, instance, database) { + return this._databaseAdminClient.databasePath(project, instance, database); + } } module.exports = GCP_RDBMS; diff --git a/generator/generatedClasses/googleCloud/database/gcp-noSql.js b/generator/generatedClasses/googleCloud/database/gcp-noSql.js index 7857a959..960ce486 100644 --- a/generator/generatedClasses/googleCloud/database/gcp-noSql.js +++ b/generator/generatedClasses/googleCloud/database/gcp-noSql.js @@ -5,75 +5,72 @@ const { FirestoreClient } = require("@google-cloud/firestore"); * @category Google Cloud */ class GCP_NoSql { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._firestoreClient = new FirestoreClient(config); - } - /** - * Trigers the createDocument function of undefined - * @param {TypeReference} request - Data required for createDocument - * @param {TypeReference} [options] - Data required for createDocument - * @returns {Promise} - */ - createItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient - .createDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._firestoreClient = new FirestoreClient(config); + } + /** + * Trigers the createDocument function of undefined + * @param {TypeReference} request - Data required for createDocument + * @param {TypeReference} [options] - Data required for createDocument + * @returns {Promise} + */ + createItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient.createDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteDocument function of undefined - * @param {TypeReference} request - Data required for deleteDocument - * @param {TypeReference} [options] - Data required for deleteDocument - * @returns {Promise} - */ - deleteItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient - .deleteDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteDocument function of undefined + * @param {TypeReference} request - Data required for deleteDocument + * @param {TypeReference} [options] - Data required for deleteDocument + * @returns {Promise} + */ + deleteItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient.deleteDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the updateDocument function of undefined - * @param {TypeReference} request - Data required for updateDocument - * @param {TypeReference} [options] - Data required for updateDocument - * @returns {Promise} - */ - updateItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient - .updateDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the updateDocument function of undefined + * @param {TypeReference} request - Data required for updateDocument + * @param {TypeReference} [options] - Data required for updateDocument + * @returns {Promise} + */ + updateItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient.updateDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the runQuery function of undefined - * @param {TypeReference} [request] - Data required for runQuery - * @param {TypeReference} [options] - Data required for runQuery - * @returns {Promise} - */ - query(request = undefined, options = undefined) { - return this._firestoreClient.runQuery(request, options); - } + } + /** + * Trigers the runQuery function of undefined + * @param {TypeReference} [request] - Data required for runQuery + * @param {TypeReference} [options] - Data required for runQuery + * @returns {Promise} + */ + query(request = undefined, options = undefined) { + return this._firestoreClient.runQuery(request, options); + } } module.exports = GCP_NoSql; diff --git a/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js b/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js index 8a106f5d..65c4ad71 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js +++ b/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js @@ -5,103 +5,98 @@ const { KeyManagementServiceClient } = require("@google-cloud/kms"); * @category Google Cloud */ class GCP_KeyManagement { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._keyManagementServiceClient = new KeyManagementServiceClient(config); - } - /** - * Trigers the createCryptoKey function of undefined - * @param {TypeReference} request - Data required for createCryptoKey - * @param {TypeReference} [options] - Data required for createCryptoKey - * @returns {Promise} - */ - createKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient - .createCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._keyManagementServiceClient = new KeyManagementServiceClient(config); + } + /** + * Trigers the createCryptoKey function of undefined + * @param {TypeReference} request - Data required for createCryptoKey + * @param {TypeReference} [options] - Data required for createCryptoKey + * @returns {Promise} + */ + createKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient.createCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the destroyCryptoKeyVersion function of undefined - * @param {TypeReference} request - Data required for destroyCryptoKeyVersion - * @param {TypeReference} [options] - Data required for destroyCryptoKeyVersion - * @returns {Promise} - */ - deleteKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient - .destroyCryptoKeyVersion(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the destroyCryptoKeyVersion function of undefined + * @param {TypeReference} request - Data required for destroyCryptoKeyVersion + * @param {TypeReference} [options] - Data required for destroyCryptoKeyVersion + * @returns {Promise} + */ + deleteKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient.destroyCryptoKeyVersion(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the updateCryptoKey function of undefined - * @param {TypeReference} request - Data required for updateCryptoKey - * @param {TypeReference} [options] - Data required for updateCryptoKey - * @returns {Promise} - */ - update(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient - .updateCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the updateCryptoKey function of undefined + * @param {TypeReference} request - Data required for updateCryptoKey + * @param {TypeReference} [options] - Data required for updateCryptoKey + * @returns {Promise} + */ + update(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient.updateCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getCryptoKey function of undefined - * @param {TypeReference} request - Data required for getCryptoKey - * @param {TypeReference} [options] - Data required for getCryptoKey - * @returns {Promise} - */ - describeKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient - .getCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getCryptoKey function of undefined + * @param {TypeReference} request - Data required for getCryptoKey + * @param {TypeReference} [options] - Data required for getCryptoKey + * @returns {Promise} + */ + describeKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient.getCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the setIamPolicy function of undefined - * @param {TypeReference} request - Data required for setIamPolicy - * @param {UnionType} [options] - Data required for setIamPolicy - * @param {TypeReference} [callback] - Data required for setIamPolicy - * @returns {Promise} - */ - putKeyPolicy(request, options = undefined, callback = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient - .setIamPolicy(request, options, callback) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the setIamPolicy function of undefined + * @param {TypeReference} request - Data required for setIamPolicy + * @param {UnionType} [options] - Data required for setIamPolicy + * @param {TypeReference} [callback] - Data required for setIamPolicy + * @returns {Promise} + */ + putKeyPolicy(request, options = undefined, callback = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient.setIamPolicy(request, options, callback) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_KeyManagement; diff --git a/generator/generatedClasses/googleCloud/management/gcp-monitoring.js b/generator/generatedClasses/googleCloud/management/gcp-monitoring.js index 8ea14029..4c2c2176 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-monitoring.js +++ b/generator/generatedClasses/googleCloud/management/gcp-monitoring.js @@ -6,111 +6,106 @@ const { MetricServiceClient } = require("@google-cloud/monitoring"); * @category Google Cloud */ class GCP_Monitoring { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._alertPolicyServiceClient = new AlertPolicyServiceClient(config); - this._metricServiceClient = new MetricServiceClient(config); - } - /** - * Trigers the createAlertPolicy function of undefined - * @param {TypeReference} request - Data required for createAlertPolicy - * @param {TypeReference} [options] - Data required for createAlertPolicy - * @returns {Promise} - */ - createAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient - .createAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._alertPolicyServiceClient = new AlertPolicyServiceClient(config); + this._metricServiceClient = new MetricServiceClient(config); + } + /** + * Trigers the createAlertPolicy function of undefined + * @param {TypeReference} request - Data required for createAlertPolicy + * @param {TypeReference} [options] - Data required for createAlertPolicy + * @returns {Promise} + */ + createAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient.createAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteAlertPolicy function of undefined - * @param {TypeReference} request - Data required for deleteAlertPolicy - * @param {TypeReference} [options] - Data required for deleteAlertPolicy - * @returns {Promise} - */ - deleteAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient - .deleteAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteAlertPolicy function of undefined + * @param {TypeReference} request - Data required for deleteAlertPolicy + * @param {TypeReference} [options] - Data required for deleteAlertPolicy + * @returns {Promise} + */ + deleteAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient.deleteAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the updateAlertPolicy function of undefined - * @param {TypeReference} request - Data required for updateAlertPolicy - * @param {TypeReference} [options] - Data required for updateAlertPolicy - * @returns {Promise} - */ - updateAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient - .updateAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the updateAlertPolicy function of undefined + * @param {TypeReference} request - Data required for updateAlertPolicy + * @param {TypeReference} [options] - Data required for updateAlertPolicy + * @returns {Promise} + */ + updateAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient.updateAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the listAlertPolicies function of undefined - * @param {TypeReference} request - Data required for listAlertPolicies - * @param {TypeReference} [options] - Data required for listAlertPolicies - * @returns {Promise} - */ - listAlarms(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient - .listAlertPolicies(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listAlertPolicies function of undefined + * @param {TypeReference} request - Data required for listAlertPolicies + * @param {TypeReference} [options] - Data required for listAlertPolicies + * @returns {Promise} + */ + listAlarms(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient.listAlertPolicies(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getMetricDescriptor function of undefined - * @param {TypeReference} request - Data required for getMetricDescriptor - * @param {TypeReference} [options] - Data required for getMetricDescriptor - * @returns {Promise} - */ - getMetricData(request, options = undefined) { - return new Promise((resolve, reject) => { - this._metricServiceClient - .getMetricDescriptor(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getMetricDescriptor function of undefined + * @param {TypeReference} request - Data required for getMetricDescriptor + * @param {TypeReference} [options] - Data required for getMetricDescriptor + * @returns {Promise} + */ + getMetricData(request, options = undefined) { + return new Promise((resolve, reject) => { + this._metricServiceClient.getMetricDescriptor(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the projectPath function of undefined - * @param {StringKeyword} project - Data required for projectPath - * @returns {Promise} - */ - projectPath(project) { - return this._alertPolicyServiceClient.projectPath(project); - } + } + /** + * Trigers the projectPath function of undefined + * @param {StringKeyword} project - Data required for projectPath + * @returns {Promise} + */ + projectPath(project) { + return this._alertPolicyServiceClient.projectPath(project); + } } module.exports = GCP_Monitoring; diff --git a/generator/generatedClasses/googleCloud/management/gcp-notificationService.js b/generator/generatedClasses/googleCloud/management/gcp-notificationService.js index ff4ee74f..fd9ab000 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-notificationService.js +++ b/generator/generatedClasses/googleCloud/management/gcp-notificationService.js @@ -6,157 +6,149 @@ const { SubscriberClient } = require("@google-cloud/pubsub"); * @category Google Cloud */ class GCP_NotificationService { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._publisherClient = new PublisherClient(config); - this._subscriberClient = new SubscriberClient(config); - } - /** - * Trigers the createTopic function of undefined - * @param {TypeReference} request - Data required for createTopic - * @param {TypeReference} [options] - Data required for createTopic - * @returns {Promise} - */ - createTopic(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .createTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._publisherClient = new PublisherClient(config); + this._subscriberClient = new SubscriberClient(config); + } + /** + * Trigers the createTopic function of undefined + * @param {TypeReference} request - Data required for createTopic + * @param {TypeReference} [options] - Data required for createTopic + * @returns {Promise} + */ + createTopic(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.createTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteTopic function of undefined - * @param {TypeReference} request - Data required for deleteTopic - * @param {TypeReference} [options] - Data required for deleteTopic - * @returns {Promise} - */ - deleteTopic(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .deleteTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteTopic function of undefined + * @param {TypeReference} request - Data required for deleteTopic + * @param {TypeReference} [options] - Data required for deleteTopic + * @returns {Promise} + */ + deleteTopic(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.deleteTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getTopic function of undefined - * @param {TypeReference} request - Data required for getTopic - * @param {TypeReference} [options] - Data required for getTopic - * @returns {Promise} - */ - getTopicAttributes(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .getTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getTopic function of undefined + * @param {TypeReference} request - Data required for getTopic + * @param {TypeReference} [options] - Data required for getTopic + * @returns {Promise} + */ + getTopicAttributes(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.getTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the listTopicSubscriptions function of undefined - * @param {TypeReference} request - Data required for listTopicSubscriptions - * @param {TypeReference} [options] - Data required for listTopicSubscriptions - * @returns {Promise} - */ - listSubscriptions(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .listTopicSubscriptions(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listTopicSubscriptions function of undefined + * @param {TypeReference} request - Data required for listTopicSubscriptions + * @param {TypeReference} [options] - Data required for listTopicSubscriptions + * @returns {Promise} + */ + listSubscriptions(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.listTopicSubscriptions(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createSubscription function of undefined - * @param {TypeReference} request - Data required for createSubscription - * @param {TypeReference} [options] - Data required for createSubscription - * @returns {Promise} - */ - subscribe(request, options = undefined) { - return new Promise((resolve, reject) => { - this._subscriberClient - .createSubscription(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createSubscription function of undefined + * @param {TypeReference} request - Data required for createSubscription + * @param {TypeReference} [options] - Data required for createSubscription + * @returns {Promise} + */ + subscribe(request, options = undefined) { + return new Promise((resolve, reject) => { + this._subscriberClient.createSubscription(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the publish function of undefined - * @param {TypeReference} request - Data required for publish - * @param {TypeReference} [options] - Data required for publish - * @returns {Promise} - */ - publish(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .publish(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the publish function of undefined + * @param {TypeReference} request - Data required for publish + * @param {TypeReference} [options] - Data required for publish + * @returns {Promise} + */ + publish(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.publish(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the listTopics function of undefined - * @param {TypeReference} request - Data required for listTopics - * @param {TypeReference} [options] - Data required for listTopics - * @returns {Promise} - */ - listTopics(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient - .listTopics(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the listTopics function of undefined + * @param {TypeReference} request - Data required for listTopics + * @param {TypeReference} [options] - Data required for listTopics + * @returns {Promise} + */ + listTopics(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient.listTopics(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the deleteSubscription function of undefined - * @param {TypeReference} request - Data required for deleteSubscription - * @param {TypeReference} [options] - Data required for deleteSubscription - * @returns {Promise} - */ - unsubscribe(request, options = undefined) { - return new Promise((resolve, reject) => { - this._subscriberClient - .deleteSubscription(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the deleteSubscription function of undefined + * @param {TypeReference} request - Data required for deleteSubscription + * @param {TypeReference} [options] - Data required for deleteSubscription + * @returns {Promise} + */ + unsubscribe(request, options = undefined) { + return new Promise((resolve, reject) => { + this._subscriberClient.deleteSubscription(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_NotificationService; diff --git a/generator/generatedClasses/googleCloud/network/gcp-DNS.js b/generator/generatedClasses/googleCloud/network/gcp-DNS.js index acb9acd3..b1ce2e6f 100644 --- a/generator/generatedClasses/googleCloud/network/gcp-DNS.js +++ b/generator/generatedClasses/googleCloud/network/gcp-DNS.js @@ -5,100 +5,93 @@ const { DNS } = require("@google-cloud/dns"); * @category Google Cloud */ class GCP_dns { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._dns = new DNS(config); - } - /** - * Trigers the getZones function of dns - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - listZones(query = undefined) { - return new Promise((resolve, reject) => { - this._dns - .getZones(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._dns = new DNS(config); + } + /** + * Trigers the getZones function of dns + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + listZones(query = undefined) { + return new Promise((resolve, reject) => { + this._dns.getZones(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the create function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} config - Mandatory parameter - * @returns {Promise} - */ - createZone(dns, config, identifier = undefined) { - return new Promise((resolve, reject) => { - dns - .zone(identifier) - .create(config) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the create function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} config - Mandatory parameter + * @returns {Promise} + */ + createZone(dns, config, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier).create(config) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createChange function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} config - Mandatory parameter - * @returns {Promise} - */ - changeRecordSets(dns, config, identifier = undefined) { - return new Promise((resolve, reject) => { - dns - .zone(identifier) - .createChange(config) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createChange function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} config - Mandatory parameter + * @returns {Promise} + */ + changeRecordSets(dns, config, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier).createChange(config) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the delete function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteZone(dns, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - dns - .zone(identifier) - .delete(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the delete function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteZone(dns, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier).delete(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the record function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {StringKeyword} type - Mandatory parameter - * @param {TypeReference} metadata - Mandatory parameter - * @returns {Promise} - */ - record(dns, type, metadata) { - return this.dns.record(type, metadata); - } + } + /** + * Trigers the record function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {StringKeyword} type - Mandatory parameter + * @param {TypeReference} metadata - Mandatory parameter + * @returns {Promise} + */ + record(dns, type, metadata) { + return this.dns.record(type, metadata); + } } module.exports = GCP_dns; diff --git a/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js b/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js index a51af327..d92787eb 100644 --- a/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js +++ b/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js @@ -5,107 +5,99 @@ const { Storage } = require("@google-cloud/storage"); * @category Google Cloud */ class GCP_storage { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._storage = new Storage(config); - } - /** - * Trigers the deleteFiles function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - deleteFiles(storage, query = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage - .bucket(identifier) - .deleteFiles(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._storage = new Storage(config); + } + /** + * Trigers the deleteFiles function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + deleteFiles(storage, query = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage.bucket(identifier).deleteFiles(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the upload function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {StringKeyword} pathString - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - upload(storage, pathString, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage - .bucket(identifier) - .upload(pathString, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the upload function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {StringKeyword} pathString - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + upload(storage, pathString, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage.bucket(identifier).upload(pathString, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the makePublic function of storage - * @param {string} [identifier] - Optional parameter - * @param {Bucket} bucket - Mandatory parameter - * @returns {Promise} - */ - makePublic(bucket, identifier = undefined) { - return new Promise((resolve, reject) => { - bucket - .file(identifier) - .makePublic() - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the makePublic function of storage + * @param {string} [identifier] - Optional parameter + * @param {Bucket} bucket - Mandatory parameter + * @returns {Promise} + */ + makePublic(bucket, identifier = undefined) { + return new Promise((resolve, reject) => { + bucket.file(identifier).makePublic() + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createBucket function of storage - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [metadata] - Optional parameter - * @returns {Promise} - */ - create(name, metadata = undefined) { - return new Promise((resolve, reject) => { - this._storage - .createBucket(name, metadata) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createBucket function of storage + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [metadata] - Optional parameter + * @returns {Promise} + */ + create(name, metadata = undefined) { + return new Promise((resolve, reject) => { + this._storage.createBucket(name, metadata) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getBuckets function of storage - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._storage - .getBuckets(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getBuckets function of storage + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._storage.getBuckets(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_storage; diff --git a/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js b/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js index a51af327..d92787eb 100644 --- a/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js +++ b/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js @@ -5,107 +5,99 @@ const { Storage } = require("@google-cloud/storage"); * @category Google Cloud */ class GCP_storage { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._storage = new Storage(config); - } - /** - * Trigers the deleteFiles function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - deleteFiles(storage, query = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage - .bucket(identifier) - .deleteFiles(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._storage = new Storage(config); + } + /** + * Trigers the deleteFiles function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + deleteFiles(storage, query = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage.bucket(identifier).deleteFiles(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the upload function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {StringKeyword} pathString - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - upload(storage, pathString, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage - .bucket(identifier) - .upload(pathString, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the upload function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {StringKeyword} pathString - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + upload(storage, pathString, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage.bucket(identifier).upload(pathString, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the makePublic function of storage - * @param {string} [identifier] - Optional parameter - * @param {Bucket} bucket - Mandatory parameter - * @returns {Promise} - */ - makePublic(bucket, identifier = undefined) { - return new Promise((resolve, reject) => { - bucket - .file(identifier) - .makePublic() - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the makePublic function of storage + * @param {string} [identifier] - Optional parameter + * @param {Bucket} bucket - Mandatory parameter + * @returns {Promise} + */ + makePublic(bucket, identifier = undefined) { + return new Promise((resolve, reject) => { + bucket.file(identifier).makePublic() + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the createBucket function of storage - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [metadata] - Optional parameter - * @returns {Promise} - */ - create(name, metadata = undefined) { - return new Promise((resolve, reject) => { - this._storage - .createBucket(name, metadata) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the createBucket function of storage + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [metadata] - Optional parameter + * @returns {Promise} + */ + create(name, metadata = undefined) { + return new Promise((resolve, reject) => { + this._storage.createBucket(name, metadata) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } - /** - * Trigers the getBuckets function of storage - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._storage - .getBuckets(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); + } + /** + * Trigers the getBuckets function of storage + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._storage.getBuckets(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); }); - }); - } + } } module.exports = GCP_storage; diff --git a/generator/generators/aws/generator.js b/generator/generators/aws/generator.js index 33d55ba9..61239627 100644 --- a/generator/generators/aws/generator.js +++ b/generator/generators/aws/generator.js @@ -1,137 +1,40 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.generateAWSClass = exports.extractSDKData = void 0; var fs = require("fs"); @@ -140,112 +43,103 @@ var parser_1 = require("../../parsers/aws/parser"); var transformer_1 = require("../../transformers/aws/transformer"); var helper_1 = require("../lib/helper"); var dummyFile = process.cwd() + "/dummyClasses/aws.js"; -var dummyAst = typescript_1.createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - typescript_1.ScriptTarget.Latest, - true -); +var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); function extractSDKData(sdkClassAst, serviceClass) { - var methods = []; - var functions = []; - Object.keys(serviceClass).map(function(key, index) { - functions.push(serviceClass[key].split(" ")[1]); - }); - sdkClassAst.members.map(function(method) { - if (method.name && functions.includes(method.name.text)) { - var name_1; - Object.keys(serviceClass).map(function(key, index) { - if (serviceClass[key].split(" ")[1] === method.name.text) { - name_1 = key; - } - }); - var parameters_1 = []; - method.parameters.map(function(param) { - if (param.name.text !== "callback") { - var parameter = { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeName: null - }; - if (parameter.type === "TypeReference" && param.type.typeName) { - parameter.typeName = param.type.typeName.right.text; - } - parameters_1.push(parameter); + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function (key, index) { + functions.push(serviceClass[key].split(" ")[1]); + }); + sdkClassAst.members.map(function (method) { + if (method.name && functions.includes(method.name.text)) { + var name_1; + Object.keys(serviceClass).map(function (key, index) { + if (serviceClass[key].split(" ")[1] === method.name.text) { + name_1 = key; + } + }); + var parameters_1 = []; + method.parameters.map(function (param) { + if (param.name.text !== "callback") { + var parameter = { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null + }; + if (parameter.type === "TypeReference" && param.type.typeName) { + parameter.typeName = param.type.typeName.right.text; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: method.name.text.toString(), + params: parameters_1 + }); } - }); - methods.push({ - functionName: name_1.toString(), - SDKFunctionName: method.name.text.toString(), - params: parameters_1 - }); - } - }); - var groupedMethods = helper_1.groupers.aws(methods); - methods = helper_1.filters.aws(groupedMethods); - var classData = { - className: sdkClassAst.name.text, - functions: methods, - serviceName: null - }; - return classData; + }); + var groupedMethods = helper_1.groupers.aws(methods); + methods = helper_1.filters.aws(groupedMethods); + var classData = { + className: sdkClassAst.name.text, + functions: methods, + serviceName: null + }; + return classData; } exports.extractSDKData = extractSDKData; function generateAWSClass(serviceClass, serviceName) { - var _this = this; - var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; - parser_1.getAST(sdkFile).then(function(result) { - return __awaiter(_this, void 0, void 0, function() { - var sdkClassAst, classData, output, filePath, dir, e_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - sdkClassAst = result; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - classData = extractSDKData(sdkClassAst, serviceClass); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - filePath = void 0; - dir = helper_1.getDir(serviceName); - if ( - !fs.existsSync(process.cwd() + "/generatedClasses/AWS/" + dir) - ) { - fs.mkdirSync(process.cwd() + "/generatedClasses/AWS/" + dir); + var _this = this; + var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; + parser_1.getAST(sdkFile).then(function (result) { return __awaiter(_this, void 0, void 0, function () { + var sdkClassAst, classData, output, filePath, dir, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + sdkClassAst = result; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + classData = extractSDKData(sdkClassAst, serviceClass); + classData.serviceName = serviceName; + return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; + case 2: + output = _a.sent(); + filePath = void 0; + dir = helper_1.getDir(serviceName); + if (!fs.existsSync(process.cwd() + "/generatedClasses/AWS/" + dir)) { + fs.mkdirSync(process.cwd() + "/generatedClasses/AWS/" + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + "/generatedClasses/AWS/" + + dir + + "/aws-" + + serviceName + + ".js"; + } + else { + filePath = + process.cwd() + + "/generatedClasses/AWS/" + + dir + + "/aws-" + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + ".js"; + } + helper_1.printFile(filePath, output); + return [3 /*break*/, 4]; + case 3: + e_1 = _a.sent(); + console.error(e_1); + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/AWS/" + - dir + - "/aws-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/AWS/" + - dir + - "/aws-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [3 /*break*/, 4]; - case 3: - e_1 = _a.sent(); - console.error(e_1); - return [3 /*break*/, 4]; - case 4: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.generateAWSClass = generateAWSClass; diff --git a/generator/generators/azure/generator.js b/generator/generators/azure/generator.js index cf75bcc8..e04def19 100644 --- a/generator/generators/azure/generator.js +++ b/generator/generators/azure/generator.js @@ -1,301 +1,178 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.generateAzureClass = exports.extractSDKData = void 0; var fs = require("fs"); var typescript_1 = require("typescript"); var parser_1 = require("../../parsers/azure/parser"); -var helper_1 = require("../lib/helper"); var transformer_1 = require("../../transformers/azure/transformer"); +var helper_1 = require("../lib/helper"); var dummyFile = process.cwd() + "/dummyClasses/azure.js"; -var dummyAst = typescript_1.createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - typescript_1.ScriptTarget.Latest, - true -); +var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); function extractSDKData(sdkFiles, methods) { - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - sdkFiles.map(function(sdkFile) { - sdkFile.ast.members.map(function(member) { - if (typescript_1.SyntaxKind[member.kind] === "Constructor") { - member.parameters.map(function(param) { - var tempStr = param.type.typeName.text.split(/(?=[A-Z])/); - tempStr.pop(); - sdkFile.client = tempStr.join(""); - }); - } - if ( - typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text) - ) { - var method = methods.find(function(methd) { - return ( - methd.SDKFunctionName === member.name.text && - methd.fileName === sdkFile.fileName - ); - }); - var parameters = member.parameters.map(function(param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + sdkFiles.map(function (sdkFile) { + sdkFile.ast.members.map(function (member) { + if (typescript_1.SyntaxKind[member.kind] === "Constructor") { + member.parameters.map(function (param) { + var tempStr = param.type.typeName.text.split(/(?=[A-Z])/); + tempStr.pop(); + sdkFile.client = tempStr.join(""); + }); + } + if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && + sdkFile.sdkFunctionNames.includes(member.name.text)) { + var method = methods.find(function (methd) { + return methd.SDKFunctionName === member.name.text && + methd.fileName === sdkFile.fileName; + }); + var parameters = member.parameters.map(function (param) { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind] + }; + }); + var returnType = typescript_1.SyntaxKind[member.type.kind]; + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } + else { + var clone = JSON.parse(JSON.stringify(method)); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } }); - var returnType = typescript_1.SyntaxKind[member.type.kind]; - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } else { - var clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); - } - } }); - }); - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - throw new Error("Data extraction unsuccessful"); - } - var groupedMethods = helper_1.groupers.azure(methods); - methods = helper_1.filters.azure(groupedMethods); - var classData = { - functions: methods - }; - return classData; + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + throw new Error("Data extraction unsuccessful"); + } + var groupedMethods = helper_1.groupers.azure(methods); + methods = helper_1.filters.azure(groupedMethods); + var classData = { + functions: methods + }; + return classData; } exports.extractSDKData = extractSDKData; function generateAzureClass(serviceClass, serviceName) { - return __awaiter(this, void 0, void 0, function() { - var methods, files, sdkFiles, classData, output, filePath, dir; - var _this = this; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - methods = []; - Object.keys(serviceClass).map(function(key, index) { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - client: null - }); - }); - files = Array.from( - new Set( - methods.map(function(method) { - return method.fileName; - }) - ) - ); - sdkFiles = files.map(function(file) { - return { - fileName: file, - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(function(method) { - return method.fileName === file; - }) - .map(function(method) { - return method.SDKFunctionName; - }) - }; - }); - return [ - 4 /*yield*/, - Promise.all( - sdkFiles.map(function(file) { - return __awaiter(_this, void 0, void 0, function() { - var _a; - return __generator(this, function(_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file)]; - case 1: - _a.ast = _b.sent(); - return [2 /*return*/]; + return __awaiter(this, void 0, void 0, function () { + var methods, files, sdkFiles, classData, output, filePath, dir; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + methods = []; + Object.keys(serviceClass).map(function (key, index) { + methods.push({ + pkgName: serviceClass[key].split(" ")[0], + fileName: serviceClass[key].split(" ")[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(" ")[2], + params: [], + returnType: null, + client: null + }); + }); + files = Array.from(new Set(methods.map(function (method) { return method.fileName; }))); + sdkFiles = files.map(function (file) { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function (method) { return method.fileName === file; }) + .map(function (method) { return method.SDKFunctionName; }) + }; + }); + return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = file; + return [4 /*yield*/, parser_1.getAST(file)]; + case 1: + _a.ast = _b.sent(); + return [2 /*return*/]; + } + }); + }); }))]; + case 1: + _a.sent(); + classData = extractSDKData(sdkFiles, methods); + classData.serviceName = serviceName; + return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; + case 2: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if (!fs.existsSync(process.cwd() + "/generatedClasses/Azure/" + dir)) { + fs.mkdirSync(process.cwd() + "/generatedClasses/Azure/" + dir); } - }); - }); - }) - ) - ]; - case 1: - _a.sent(); - classData = extractSDKData(sdkFiles, methods); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if ( - !fs.existsSync(process.cwd() + "/generatedClasses/Azure/" + dir) - ) { - fs.mkdirSync(process.cwd() + "/generatedClasses/Azure/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + "/generatedClasses/Azure/" + + dir + + "/azure-" + + serviceName + + ".js"; + } + else { + filePath = + process.cwd() + + "/generatedClasses/Azure/" + + dir + + "/azure-" + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + ".js"; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); }); - }); } exports.generateAzureClass = generateAzureClass; diff --git a/generator/generators/do/generator.js b/generator/generators/do/generator.js index 56ae7d57..9b59d7c2 100644 --- a/generator/generators/do/generator.js +++ b/generator/generators/do/generator.js @@ -1,137 +1,40 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.generateDOClass = exports.extractSDKData = void 0; var fs = require("fs"); @@ -140,108 +43,101 @@ var parser_1 = require("../../parsers/do/parser"); var transformer_1 = require("../../transformers/do/transformer"); var helper_1 = require("../lib/helper"); var dummyFile = process.cwd() + "/dummyClasses/do.js"; -var dummyAst = typescript_1.createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - typescript_1.ScriptTarget.Latest, - true -); +var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); function extractSDKData(sdkClassAst, serviceClass) { - var methods = []; - var functions = []; - Object.keys(serviceClass).map(function(key, index) { - functions.push(serviceClass[key].split(" ")[1]); - }); - sdkClassAst.members.map(function(method) { - if (method.name && functions.includes(method.name.text)) { - var name_1; - Object.keys(serviceClass).map(function(key, index) { - if (serviceClass[key].split(" ")[1] === method.name.text) { - name_1 = key; - } - }); - var parameters_1 = []; - method.parameters.map(function(param) { - if (param.name.text !== "callback") { - var parameter = { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeName: null - }; - if (parameter.type === "TypeReference" && param.type.typeName) { - parameter.typeName = param.type.typeName.text; - } - parameters_1.push(parameter); + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function (key, index) { + functions.push(serviceClass[key].split(" ")[1]); + }); + sdkClassAst.members.map(function (method) { + if (method.name && functions.includes(method.name.text)) { + var name_1; + Object.keys(serviceClass).map(function (key, index) { + if (serviceClass[key].split(" ")[1] === method.name.text) { + name_1 = key; + } + }); + var parameters_1 = []; + method.parameters.map(function (param) { + if (param.name.text !== "callback") { + var parameter = { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null + }; + if (parameter.type === "TypeReference" && param.type.typeName) { + parameter.typeName = param.type.typeName.text; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: method.name.text.toString(), + params: parameters_1 + }); } - }); - methods.push({ - functionName: name_1.toString(), - SDKFunctionName: method.name.text.toString(), - params: parameters_1 - }); - } - }); - var classData = { - className: sdkClassAst.name.text, - functions: methods, - serviceName: null - }; - return classData; + }); + var classData = { + className: sdkClassAst.name.text, + functions: methods, + serviceName: null + }; + return classData; } exports.extractSDKData = extractSDKData; function generateDOClass(serviceClass, serviceName) { - var _this = this; - var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; - parser_1.getAST(sdkFile).then(function(result) { - return __awaiter(_this, void 0, void 0, function() { - var sdkClassAst, classData, output, filePath, dir, e_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - sdkClassAst = result; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - classData = extractSDKData(sdkClassAst, serviceClass); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - filePath = void 0; - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/DO/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/DO/" + dir); + var _this = this; + var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; + parser_1.getAST(sdkFile).then(function (result) { return __awaiter(_this, void 0, void 0, function () { + var sdkClassAst, classData, output, filePath, dir, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + sdkClassAst = result; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + classData = extractSDKData(sdkClassAst, serviceClass); + classData.serviceName = serviceName; + return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; + case 2: + output = _a.sent(); + filePath = void 0; + dir = helper_1.getDir(serviceName); + if (!fs.existsSync(process.cwd() + "/generatedClasses/DO/" + dir)) { + fs.mkdirSync(process.cwd() + "/generatedClasses/DO/" + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + "/generatedClasses/DO/" + + dir + + "/do-" + + serviceName + + ".js"; + } + else { + filePath = + process.cwd() + + "/generatedClasses/DO/" + + dir + + "/do-" + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + ".js"; + } + helper_1.printFile(filePath, output); + return [3 /*break*/, 4]; + case 3: + e_1 = _a.sent(); + console.error(e_1); + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [3 /*break*/, 4]; - case 3: - e_1 = _a.sent(); - console.error(e_1); - return [3 /*break*/, 4]; - case 4: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.generateDOClass = generateDOClass; diff --git a/generator/generators/googleCloud/generator.js b/generator/generators/googleCloud/generator.js index 664103f9..a06ac192 100644 --- a/generator/generators/googleCloud/generator.js +++ b/generator/generators/googleCloud/generator.js @@ -1,594 +1,410 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.generateGCPClass = exports.extractClientBasedSDKdata = exports.extractClassBasedSDKData = void 0; var fs = require("fs"); var path = require("path"); var typescript_1 = require("typescript"); var parser_1 = require("../../parsers/googleCloud/parser"); -var helper_1 = require("../lib/helper"); -var clientBasedTransformer_1 = require("../../transformers/googleCloud/clientBasedTransformer"); var classBasedTransformer_1 = require("../../transformers/googleCloud/classBasedTransformer"); +var clientBasedTransformer_1 = require("../../transformers/googleCloud/clientBasedTransformer"); +var helper_1 = require("../lib/helper"); var dummyFile = process.cwd() + "/dummyClasses/gcp.js"; -var dummyAst = typescript_1.createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - typescript_1.ScriptTarget.Latest, - true -); +var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); function extractClassBasedSDKData(methods, sdkFiles) { - var _this = this; - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - var classes_1, extractedData; - return __generator(this, function(_a) { - try { - classes_1 = []; - sdkFiles.map(function(file) { - file.classes.map(function(classAst) { - var classInfo = { - name: classAst.name.text, - methods: [], - properties: [], - constructor: null - }; - classAst.members.map(function(member) { - if ( - typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" - ) { - var returnType = typescript_1.SyntaxKind[member.type.kind]; - var parameters = member.parameters.map(function(param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; - }); - var method_1 = { - pkgName: file.pkgName, - version: null, - fileName: file.fileName, - functionName: null, - SDKFunctionName: member.name.text, - params: parameters, - returnType: returnType, - returnTypeName: null, - client: classAst.name.text // Class name - }; - if (returnType === "TypeReference") { - method_1.returnTypeName = member.type.typeName.text; - } - var meth = methods.find(function(meth) { - return ( - meth.SDKFunctionName === method_1.SDKFunctionName && - meth.fileName === method_1.fileName - ); - }); - method_1.functionName = meth ? meth.functionName : null; - classInfo.methods.push(method_1); - } - if (typescript_1.SyntaxKind[member.kind] === "Constructor") { - var parameters = member.parameters.map(function(param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeRefName: param.type.typeName - ? param.type.typeName.text - : null - }; - }); - classInfo.constructor = { - parameters: parameters - }; - } - if ( - typescript_1.SyntaxKind[member.kind] === "PropertyDeclaration" - ) { - var isPrivateProp = - member.modifiers && - member.modifiers.some(function(modifier) { - return ( - typescript_1.SyntaxKind[modifier.kind] === - "PrivateKeyword" - ); + var _this = this; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var classes_1, extractedData; + return __generator(this, function (_a) { + try { + classes_1 = []; + sdkFiles.map(function (file) { + file.classes.map(function (classAst) { + var classInfo = { + name: classAst.name.text, + methods: [], + properties: [], + constructor: null + }; + classAst.members.map(function (member) { + if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration") { + var returnType = typescript_1.SyntaxKind[member.type.kind]; + var parameters = member.parameters.map(function (param) { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind] + }; + }); + var method_1 = { + pkgName: file.pkgName, + version: null, + fileName: file.fileName, + functionName: null, + SDKFunctionName: member.name.text, + params: parameters, + returnType: returnType, + returnTypeName: null, + client: classAst.name.text // Class name + }; + if (returnType === "TypeReference") { + method_1.returnTypeName = member.type.typeName.text; + } + var meth = methods.find(function (meth) { + return meth.SDKFunctionName === method_1.SDKFunctionName && + meth.fileName === method_1.fileName; + }); + method_1.functionName = meth ? meth.functionName : null; + classInfo.methods.push(method_1); + } + if (typescript_1.SyntaxKind[member.kind] === "Constructor") { + var parameters = member.parameters.map(function (param) { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeRefName: param.type.typeName + ? param.type.typeName.text + : null + }; + }); + classInfo.constructor = { + parameters: parameters + }; + } + if (typescript_1.SyntaxKind[member.kind] === "PropertyDeclaration") { + var isPrivateProp = member.modifiers && + member.modifiers.some(function (modifier) { return typescript_1.SyntaxKind[modifier.kind] === "PrivateKeyword"; }); + if (!isPrivateProp) { + var prop = { + name: member.name.text, + type: typescript_1.SyntaxKind[member.type.kind], + typeRefName: member.type.typeName + ? member.type.typeName.text + : null + }; + classInfo.properties.push(prop); + } + } + }); + classes_1.push(classInfo); }); - if (!isPrivateProp) { - var prop = { - name: member.name.text, - type: typescript_1.SyntaxKind[member.type.kind], - typeRefName: member.type.typeName - ? member.type.typeName.text - : null - }; - classInfo.properties.push(prop); - } + }); + methods = []; + classes_1.map(function (classData) { + var filteredMethods = classData.methods.filter(function (meth) { return meth.functionName !== null; }); + filteredMethods.map(function (filMeth) { + filMeth.classConstructorData = classData.constructor; + }); + methods = methods.concat(filteredMethods); + }); + extractedData = { + classes: classes_1, + methods: methods + }; + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + reject(new Error("Data extraction unsuccessful")); } - }); - classes_1.push(classInfo); - }); - }); - methods = []; - classes_1.map(function(classData) { - var filteredMethods = classData.methods.filter(function(meth) { - return meth.functionName !== null; - }); - filteredMethods.map(function(filMeth) { - filMeth.classConstructorData = classData.constructor; - }); - methods = methods.concat(filteredMethods); - }); - extractedData = { - classes: classes_1, - methods: methods - }; - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } else { - resolve(extractedData); - } - } catch (error) { - reject(error); - } - return [2 /*return*/]; - }); - }); - }); + else { + resolve(extractedData); + } + } + catch (error) { + reject(error); + } + return [2 /*return*/]; + }); + }); }); } exports.extractClassBasedSDKData = extractClassBasedSDKData; function extractClientBasedSDKdata(methods, sdkFiles) { - var _this = this; - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - return __generator(this, function(_a) { - try { - sdkFiles.map(function(sdkFile) { - sdkFile.client = sdkFile.ast.name.text; - sdkFile.ast.members.map(function(member) { - if ( - typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text) - ) { - var method = methods.find(function(methd) { - return methd.SDKFunctionName === member.name.text; - }); - var parameters = member.parameters.map(function(param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; + var _this = this; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + try { + sdkFiles.map(function (sdkFile) { + sdkFile.client = sdkFile.ast.name.text; + sdkFile.ast.members.map(function (member) { + if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && + sdkFile.sdkFunctionNames.includes(member.name.text)) { + var method = methods.find(function (methd) { return methd.SDKFunctionName === member.name.text; }); + var parameters = member.parameters.map(function (param) { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind] + }; + }); + var returnType = typescript_1.SyntaxKind[member.type.kind]; + if (returnType === "TypeReference") { + method.returnTypeName = member.type.typeName.text; + } + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } + else { + var clone = JSON.parse(JSON.stringify(method)); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } + }); }); - var returnType = typescript_1.SyntaxKind[member.type.kind]; - if (returnType === "TypeReference") { - method.returnTypeName = member.type.typeName.text; + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + reject(new Error("Data extraction unsuccessful")); } - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } else { - var clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); + else { + resolve(methods); } - } - }); - }); - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } else { - resolve(methods); - } - } catch (error) { - reject(error); - } - return [2 /*return*/]; - }); - }); - }); + } + catch (error) { + reject(error); + } + return [2 /*return*/]; + }); + }); }); } exports.extractClientBasedSDKdata = extractClientBasedSDKdata; function generateClassBasedCode(methods, data, serviceName) { - return __awaiter(this, void 0, void 0, function() { - var dirPath, - files, - sdkFiles, - extractedData, - groupedMethods, - output, - filePath, - dir; - var _this = this; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - dirPath = - "../../../node_modules/@google-cloud/" + - methods[0].pkgName + - "/build/src/"; - files = fs.readdirSync(path.join(__dirname, dirPath)); - files = files.filter(function(fileName) { - return ( - fileName.split(".")[1] === "d" && fileName.split(".")[2] === "ts" - ); - }); - sdkFiles = files.map(function(fileName) { - return { - fileName: fileName, - pkgName: methods[0].pkgName, - classes: null, - sdkFunctionNames: methods - .filter(function(method) { - return method.fileName === fileName; - }) - .map(function(method) { - return method.SDKFunctionName; - }) - }; - }); - return [ - 4 /*yield*/, - Promise.all( - sdkFiles.map(function(file) { - return __awaiter(_this, void 0, void 0, function() { - var _a; - return __generator(this, function(_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file, true)]; - case 1: - _a.classes = _b.sent(); - return [2 /*return*/]; + return __awaiter(this, void 0, void 0, function () { + var dirPath, files, sdkFiles, extractedData, groupedMethods, output, filePath, dir; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + dirPath = "../../../node_modules/@google-cloud/" + methods[0].pkgName + "/build/src/"; + files = fs.readdirSync(path.join(__dirname, dirPath)); + files = files.filter(function (fileName) { + return fileName.split(".")[1] === "d" && fileName.split(".")[2] === "ts"; + }); + sdkFiles = files.map(function (fileName) { + return { + fileName: fileName, + pkgName: methods[0].pkgName, + classes: null, + sdkFunctionNames: methods + .filter(function (method) { return method.fileName === fileName; }) + .map(function (method) { return method.SDKFunctionName; }) + }; + }); + return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = file; + return [4 /*yield*/, parser_1.getAST(file, true)]; + case 1: + _a.classes = _b.sent(); + return [2 /*return*/]; + } + }); + }); }))]; + case 1: + _a.sent(); + return [4 /*yield*/, extractClassBasedSDKData(methods, sdkFiles).then(function (result) { return result; })]; + case 2: + extractedData = _a.sent(); + groupedMethods = helper_1.groupers.gcp(extractedData.methods); + methods = helper_1.filters.gcp(groupedMethods); + data.functions = methods; + data.classData = extractedData.classes; + data.serviceName = serviceName; + return [4 /*yield*/, classBasedTransformer_1.classBasedTransform(dummyAst, data)]; + case 3: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { + fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); } - }); - }); - }) - ) - ]; - case 1: - _a.sent(); - return [ - 4 /*yield*/, - extractClassBasedSDKData(methods, sdkFiles).then(function(result) { - return result; - }) - ]; - case 2: - extractedData = _a.sent(); - groupedMethods = helper_1.groupers.gcp(extractedData.methods); - methods = helper_1.filters.gcp(groupedMethods); - data.functions = methods; - data.classData = extractedData.classes; - data.serviceName = serviceName; - return [ - 4 /*yield*/, - classBasedTransformer_1.classBasedTransform(dummyAst, data) - ]; - case 3: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if ( - !fs.existsSync( - process.cwd() + "/generatedClasses/googleCloud/" + dir - ) - ) { - fs.mkdirSync( - process.cwd() + "/generatedClasses/googleCloud/" + dir - ); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + "/generatedClasses/googleCloud/" + + dir + + "/gcp-" + + serviceName + + ".js"; + } + else { + filePath = + process.cwd() + + "/generatedClasses/googleCloud/" + + dir + + "/gcp-" + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + ".js"; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); }); - }); } function generateClientBasedCode(methods, serviceName) { - return __awaiter(this, void 0, void 0, function() { - var files, sdkFiles, groupedMethods, classData, output, filePath, dir; - var _this = this; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - files = Array.from( - new Set( - methods.map(function(method) { - return method.fileName + " " + method.version; - }) - ) - ); - sdkFiles = files.map(function(file) { - return { - fileName: file.split(" ")[0], - version: file.split(" ")[1], - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(function(method) { - return method.fileName === file.split(" ")[0]; - }) - .map(function(method) { - return method.SDKFunctionName; - }) - }; - }); - return [ - 4 /*yield*/, - Promise.all( - sdkFiles.map(function(file) { - return __awaiter(_this, void 0, void 0, function() { - var _a; - return __generator(this, function(_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file)]; - case 1: - _a.ast = _b.sent(); - return [2 /*return*/]; + return __awaiter(this, void 0, void 0, function () { + var files, sdkFiles, groupedMethods, classData, output, filePath, dir; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + files = Array.from(new Set(methods.map(function (method) { return method.fileName + " " + method.version; }))); + sdkFiles = files.map(function (file) { + return { + fileName: file.split(" ")[0], + version: file.split(" ")[1], + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function (method) { return method.fileName === file.split(" ")[0]; }) + .map(function (method) { return method.SDKFunctionName; }) + }; + }); + return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = file; + return [4 /*yield*/, parser_1.getAST(file)]; + case 1: + _a.ast = _b.sent(); + return [2 /*return*/]; + } + }); + }); }))]; + case 1: + _a.sent(); + return [4 /*yield*/, extractClientBasedSDKdata(methods, sdkFiles).then(function (result) { return result; })]; + case 2: + methods = _a.sent(); + groupedMethods = helper_1.groupers.gcp(methods); + methods = helper_1.filters.gcp(groupedMethods); + classData = { + functions: methods, + serviceName: serviceName + }; + return [4 /*yield*/, clientBasedTransformer_1.clientBasedTransform(dummyAst, classData)]; + case 3: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { + fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); } - }); - }); - }) - ) - ]; - case 1: - _a.sent(); - return [ - 4 /*yield*/, - extractClientBasedSDKdata(methods, sdkFiles).then(function(result) { - return result; - }) - ]; - case 2: - methods = _a.sent(); - groupedMethods = helper_1.groupers.gcp(methods); - methods = helper_1.filters.gcp(groupedMethods); - classData = { - functions: methods, - serviceName: serviceName - }; - return [ - 4 /*yield*/, - clientBasedTransformer_1.clientBasedTransform(dummyAst, classData) - ]; - case 3: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if ( - !fs.existsSync( - process.cwd() + "/generatedClasses/googleCloud/" + dir - ) - ) { - fs.mkdirSync( - process.cwd() + "/generatedClasses/googleCloud/" + dir - ); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + "/generatedClasses/googleCloud/" + + dir + + "/gcp-" + + serviceName + + ".js"; + } + else { + filePath = + process.cwd() + + "/generatedClasses/googleCloud/" + + dir + + "/gcp-" + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + ".js"; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); }); - }); } function generateGCPClass(serviceClass, serviceName) { - return __awaiter(this, void 0, void 0, function() { - var methods, data; - return __generator(this, function(_a) { - methods = []; - data = {}; - Object.keys(serviceClass).map(function(key, index) { - if (key === "mainClass") { - data.mainClass = serviceClass[key]; - } else if ( - serviceClass[key].split(" ")[1].length === 2 && - serviceClass[key].split(" ")[1].charAt(0) === "v" - ) { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: serviceClass[key].split(" ")[1], - fileName: serviceClass[key].split(" ")[2], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[3], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } else { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: null, - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } - }); - if (methods[0].version) { - generateClientBasedCode(methods, serviceName); - } else { - generateClassBasedCode(methods, data, serviceName); - } - return [2 /*return*/]; + return __awaiter(this, void 0, void 0, function () { + var methods, data; + return __generator(this, function (_a) { + methods = []; + data = {}; + Object.keys(serviceClass).map(function (key, index) { + if (key === "mainClass") { + data.mainClass = serviceClass[key]; + } + else if (serviceClass[key].split(" ")[1].length === 2 && + serviceClass[key].split(" ")[1].charAt(0) === "v") { + methods.push({ + pkgName: serviceClass[key].split(" ")[0], + version: serviceClass[key].split(" ")[1], + fileName: serviceClass[key].split(" ")[2], + functionName: key, + SDKFunctionName: serviceClass[key].split(" ")[3], + params: [], + returnType: null, + returnTypeName: null, + client: null + }); + } + else { + methods.push({ + pkgName: serviceClass[key].split(" ")[0], + version: null, + fileName: serviceClass[key].split(" ")[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(" ")[2], + params: [], + returnType: null, + returnTypeName: null, + client: null + }); + } + }); + if (methods[0].version) { + generateClientBasedCode(methods, serviceName); + } + else { + generateClassBasedCode(methods, data, serviceName); + } + return [2 /*return*/]; + }); }); - }); } exports.generateGCPClass = generateGCPClass; diff --git a/generator/generators/lib/aws/awsHelper.js b/generator/generators/lib/aws/awsHelper.js index e3a2f3fa..440e473f 100644 --- a/generator/generators/lib/aws/awsHelper.js +++ b/generator/generators/lib/aws/awsHelper.js @@ -2,37 +2,33 @@ exports.__esModule = true; exports.filterAWSMethods = exports.groupAWSMethods = void 0; function groupAWSMethods(methods) { - var methodArr = Object.values( - methods.reduce(function(result, _a) { - var functionName = _a.functionName, - SDKFunctionName = _a.SDKFunctionName, - params = _a.params; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params - }); - return result; - }, {}) - ); - return methodArr; + var methodArr = Object.values(methods.reduce(function (result, _a) { + var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [] + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params + }); + return result; + }, {})); + return methodArr; } exports.groupAWSMethods = groupAWSMethods; function filterAWSMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function(group) { - group.array.sort(function(a, b) { - return a.params.length - b.params.length; + var methods = []; + groupedMethods.map(function (group) { + group.array.sort(function (a, b) { + return a.params.length - b.params.length; + }); + methods.push(group.array.slice(-1)[0]); }); - methods.push(group.array.slice(-1)[0]); - }); - return methods; + return methods; } exports.filterAWSMethods = filterAWSMethods; diff --git a/generator/generators/lib/azure/azureHelper.js b/generator/generators/lib/azure/azureHelper.js index 3956a128..c0a0f595 100644 --- a/generator/generators/lib/azure/azureHelper.js +++ b/generator/generators/lib/azure/azureHelper.js @@ -2,59 +2,48 @@ exports.__esModule = true; exports.filterAzureMethods = exports.groupAzureMethods = void 0; function groupAzureMethods(methods) { - var methodArr = Object.values( - methods.reduce(function(result, _a) { - var functionName = _a.functionName, - SDKFunctionName = _a.SDKFunctionName, - params = _a.params, - pkgName = _a.pkgName, - fileName = _a.fileName, - client = _a.client, - returnType = _a.returnType; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params, - pkgName: pkgName, - fileName: fileName, - client: client, - returnType: returnType - }); - return result; - }, {}) - ); - return methodArr; + var methodArr = Object.values(methods.reduce(function (result, _a) { + var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params, pkgName = _a.pkgName, fileName = _a.fileName, client = _a.client, returnType = _a.returnType; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [] + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params, + pkgName: pkgName, + fileName: fileName, + client: client, + returnType: returnType + }); + return result; + }, {})); + return methodArr; } exports.groupAzureMethods = groupAzureMethods; function filterAzureMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function(group) { - if (group.array.length === 1) { - methods.push(group.array[0]); - } else { - var methodPushed_1 = false; - group.array.map(function(method) { - if ( - !method.params.find(function(param) { - return param.name === "callback"; - }) - ) { - methods.push(method); - methodPushed_1 = true; + var methods = []; + groupedMethods.map(function (group) { + if (group.array.length === 1) { + methods.push(group.array[0]); } - }); - if (!methodPushed_1) { - methods.push(group.array[0]); - } - } - }); - return methods; + else { + var methodPushed_1 = false; + group.array.map(function (method) { + if (!method.params.find(function (param) { return param.name === "callback"; })) { + methods.push(method); + methodPushed_1 = true; + } + }); + if (!methodPushed_1) { + methods.push(group.array[0]); + } + } + }); + return methods; } exports.filterAzureMethods = filterAzureMethods; diff --git a/generator/generators/lib/googleCloud/gcpHelper.js b/generator/generators/lib/googleCloud/gcpHelper.js index 90353fc4..7ec28cb2 100644 --- a/generator/generators/lib/googleCloud/gcpHelper.js +++ b/generator/generators/lib/googleCloud/gcpHelper.js @@ -2,63 +2,50 @@ exports.__esModule = true; exports.filterGCPMethods = exports.groupGCPMethods = void 0; function groupGCPMethods(methods) { - var methodArr = Object.values( - methods.reduce(function(result, _a) { - var functionName = _a.functionName, - SDKFunctionName = _a.SDKFunctionName, - params = _a.params, - pkgName = _a.pkgName, - fileName = _a.fileName, - client = _a.client, - returnType = _a.returnType, - returnTypeName = _a.returnTypeName, - classConstructorData = _a.classConstructorData; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params, - pkgName: pkgName, - fileName: fileName, - client: client, - returnType: returnType, - returnTypeName: returnTypeName, - classConstructorData: classConstructorData - }); - return result; - }, {}) - ); - return methodArr; + var methodArr = Object.values(methods.reduce(function (result, _a) { + var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params, pkgName = _a.pkgName, fileName = _a.fileName, client = _a.client, returnType = _a.returnType, returnTypeName = _a.returnTypeName, classConstructorData = _a.classConstructorData; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [] + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params, + pkgName: pkgName, + fileName: fileName, + client: client, + returnType: returnType, + returnTypeName: returnTypeName, + classConstructorData: classConstructorData + }); + return result; + }, {})); + return methodArr; } exports.groupGCPMethods = groupGCPMethods; function filterGCPMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function(group) { - if (group.array.length === 1) { - methods.push(group.array[0]); - } else { - var methodPushed_1 = false; - group.array.map(function(method) { - if ( - !method.params.find(function(param) { - return param.name === "callback"; - }) - ) { - methods.push(method); - methodPushed_1 = true; + var methods = []; + groupedMethods.map(function (group) { + if (group.array.length === 1) { + methods.push(group.array[0]); } - }); - if (!methodPushed_1) { - methods.push(group.array[0]); - } - } - }); - return methods; + else { + var methodPushed_1 = false; + group.array.map(function (method) { + if (!method.params.find(function (param) { return param.name === "callback"; })) { + methods.push(method); + methodPushed_1 = true; + } + }); + if (!methodPushed_1) { + methods.push(group.array[0]); + } + } + }); + return methods; } exports.filterGCPMethods = filterGCPMethods; diff --git a/generator/generators/lib/helper.js b/generator/generators/lib/helper.js index 5cdd24ce..6a79b2fd 100644 --- a/generator/generators/lib/helper.js +++ b/generator/generators/lib/helper.js @@ -1,47 +1,48 @@ "use strict"; exports.__esModule = true; -exports.getDir = exports.filters = exports.groupers = exports.printFile = void 0; +exports.groupers = exports.getDir = exports.filters = exports.printFile = void 0; var fs = require("fs"); var awsHelper_1 = require("../lib/aws/awsHelper"); -var gcpHelper_1 = require("../lib/googleCloud/gcpHelper"); -var azureHelper_1 = require("../lib/azure/azureHelper"); var awsHelper_2 = require("../lib/aws/awsHelper"); -var gcpHelper_2 = require("../lib/googleCloud/gcpHelper"); +var azureHelper_1 = require("../lib/azure/azureHelper"); var azureHelper_2 = require("../lib/azure/azureHelper"); +var gcpHelper_1 = require("../lib/googleCloud/gcpHelper"); +var gcpHelper_2 = require("../lib/googleCloud/gcpHelper"); var dirMap = { - appServices: ["PaaS"], - compute: ["ComputeInstance", "Kubernetes", "Container"], - database: ["NoSqlIndexed", "RDBMS", "NoSql"], - management: ["Monitoring", "KeyManagement", "NotificationService"], - network: ["DNS", "LoadBalancer"], - security: ["IAM"], - storage: ["StorageBucket", "BlockStorage", "ArchivalStorage"], - artificialinteligence: ["Translation"] + appServices: ["PaaS"], + compute: ["ComputeInstance", "Kubernetes", "Container"], + database: ["NoSqlIndexed", "RDBMS", "NoSql"], + management: ["Monitoring", "KeyManagement", "NotificationService"], + network: ["DNS", "LoadBalancer"], + security: ["IAM"], + storage: ["StorageBucket", "BlockStorage", "ArchivalStorage"], + artificialinteligence: ["Translation"] }; function printFile(fileName, data) { - fs.writeFile(fileName, data, function(err) { - if (err) throw err; - }); + fs.writeFile(fileName, data, function (err) { + if (err) + throw err; + }); } exports.printFile = printFile; var groupers = { - aws: awsHelper_1.groupAWSMethods, - gcp: gcpHelper_1.groupGCPMethods, - azure: azureHelper_1.groupAzureMethods + aws: awsHelper_1.groupAWSMethods, + gcp: gcpHelper_1.groupGCPMethods, + azure: azureHelper_1.groupAzureMethods }; exports.groupers = groupers; var filters = { - aws: awsHelper_2.filterAWSMethods, - gcp: gcpHelper_2.filterGCPMethods, - azure: azureHelper_2.filterAzureMethods + aws: awsHelper_2.filterAWSMethods, + gcp: gcpHelper_2.filterGCPMethods, + azure: azureHelper_2.filterAzureMethods }; exports.filters = filters; -var getDir = function(service) { - for (var dir in dirMap) { - if (dirMap[dir].includes(service)) { - return dir; +var getDir = function (service) { + for (var dir in dirMap) { + if (dirMap[dir].includes(service)) { + return dir; + } } - } - throw new Error("Not a valid service: " + service); + throw new Error("Not a valid service: " + service); }; exports.getDir = getDir; diff --git a/generator/generators/linode/generator.js b/generator/generators/linode/generator.js new file mode 100644 index 00000000..34bd95fc --- /dev/null +++ b/generator/generators/linode/generator.js @@ -0,0 +1,144 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.generateLinodeClass = exports.extractSDKData = void 0; +var typescript_1 = require("typescript"); +var parser_1 = require("../../parsers/linode/parser"); +function extractSDKData(sdkAst, serviceClass) { + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function (key, index) { + functions.push(serviceClass[key].split(' ')[2]); + }); + sdkAst.map(function (method) { + var methodName = method.name.escapedText; + if (methodName && functions.includes(methodName)) { + var name_1; + Object.keys(serviceClass).map(function (key, index) { + if (serviceClass[key].split(' ')[2] === methodName) { + name_1 = key; + } + }); + var parameters_1 = []; + var methodParameters = method.type.parameters; + methodParameters.map(function (param) { + if (param.name.excapedText !== 'callback') { + var parameter = { + name: param.name.escapedText, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null + }; + // common type + if (param.type.typeName) { + parameter.typeName = param.type.typeName.excapedText; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: methodName, + params: parameters_1 + }); + } + }); + var classData = { + className: '', + functions: methods, + serviceName: null + }; + return classData; +} +exports.extractSDKData = extractSDKData; +function generateLinodeClass(serviceClass, serviceName) { + return __awaiter(this, void 0, void 0, function () { + var methods, files, sdkFiles; + var _this = this; + return __generator(this, function (_a) { + methods = []; + if (serviceClass == null) + return [2 /*return*/]; + Object.keys(serviceClass).map(function (key, index) { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null + }); + }); + files = Array.from(new Set(methods.map(function (method) { return method.fileName; }))); + sdkFiles = files.map(function (file) { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function (method) { return method.fileName === file; }) + .map(function (method) { return method.SDKFunctionName; }) + }; + }); + sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { + var _this = this; + return __generator(this, function (_a) { + parser_1.getAST(file).then(function (result) { return __awaiter(_this, void 0, void 0, function () { + var sdkAst, classData; + return __generator(this, function (_a) { + sdkAst = result; + try { + classData = extractSDKData(sdkAst, serviceClass); + classData.serviceName = serviceName; + } + catch (e) { + console.error(e); + } + return [2 /*return*/]; + }); + }); }); + return [2 /*return*/]; + }); + }); }); + return [2 /*return*/]; + }); + }); +} +exports.generateLinodeClass = generateLinodeClass; diff --git a/generator/generators/linode/generator.ts b/generator/generators/linode/generator.ts index 5693489d..bf72be95 100644 --- a/generator/generators/linode/generator.ts +++ b/generator/generators/linode/generator.ts @@ -1,5 +1,5 @@ import { SyntaxKind } from 'typescript'; -// import { getAST } from '../../parsers/linode/parser'; +import { getAST } from '../../parsers/linode/parser'; interface SDKClassData { pkgName: string; @@ -43,7 +43,7 @@ export function extractSDKData(sdkAst, serviceClass) { if (methodName && functions.includes(methodName)) { let name; Object.keys(serviceClass).map((key, index) => { - if (serviceClass.split(' ')[2] === methodName) { + if (serviceClass[key].split(' ')[2] === methodName) { name = key; } }); @@ -75,13 +75,11 @@ export function extractSDKData(sdkAst, serviceClass) { }); } }); - const classData: ClassData = { className: '', functions: methods, serviceName: null, }; - return classData; } @@ -113,20 +111,20 @@ export async function generateLinodeClass(serviceClass, serviceName) { .map(method => method.SDKFunctionName), }; }); - console.log(sdkFiles); - + sdkFiles.map(async file => { - // getAST(file).then(async result => { - // const sdkAst = result; - // try { - // const classData: ClassData = extractSDKData( - // sdkAst, - // serviceClass - // ); - // classData.serviceName = serviceName; - // } catch (e) { - // console.error(e); - // } - // }); + getAST(file).then(async result => { + const sdkAst = result; + try { + const classData: ClassData = extractSDKData( + sdkAst, + serviceClass + ); + classData.serviceName = serviceName; + + } catch (e) { + console.error(e); + } + }); }); } diff --git a/generator/main.js b/generator/main.js index 4f556141..52fd2d17 100644 --- a/generator/main.js +++ b/generator/main.js @@ -1,26 +1,27 @@ "use strict"; exports.__esModule = true; -var yaml = require("js-yaml"); var fs = require("fs"); -var generator_1 = require("./generators/aws/generator"); -var generator_2 = require("./generators/azure/generator"); -var generator_3 = require("./generators/googleCloud/generator"); -var generator_4 = require("./generators/do/generator"); +var yaml = require("js-yaml"); +var generator_1 = require("./generators/linode/generator"); try { - var services_1 = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); - Object.keys(services_1).map(function(service, index) { - Object.keys(services_1[service]).map(function(provider, index1) { - if (provider === "Azure") { - generator_2.generateAzureClass(services_1[service][provider], service); - } else if (provider === "AWS") { - generator_1.generateAWSClass(services_1[service][provider], service); - } else if (provider === "GCP") { - generator_3.generateGCPClass(services_1[service][provider], service); - } else if (provider == "DO") { - generator_4.generateDOClass(services_1[service][provider], service); - } + var services_1 = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); + Object.keys(services_1).map(function (service, index) { + Object.keys(services_1[service]).map(function (provider, index1) { + // if (provider === "Azure") { + // generateAzureClass(services[service][provider], service); + // } else if (provider === "AWS") { + // generateAWSClass(services[service][provider], service); + // } else if (provider === "GCP") { + // generateGCPClass(services[service][provider], service); + // } else if (provider == "DO") { + // generateDOClass(services[service][provider], service); + // } + if (provider == "Linode") { + generator_1.generateLinodeClass(services_1[service][provider], service); + } + }); }); - }); -} catch (error) { - console.error("Error : ", error); +} +catch (error) { + console.error("Error : ", error); } diff --git a/generator/main.ts b/generator/main.ts index 5374718c..ed7148d4 100644 --- a/generator/main.ts +++ b/generator/main.ts @@ -5,19 +5,23 @@ import { generateAWSClass } from "./generators/aws/generator"; import { generateAzureClass } from "./generators/azure/generator"; import { generateDOClass } from "./generators/do/generator"; import { generateGCPClass } from "./generators/googleCloud/generator"; +import { generateLinodeClass } from "./generators/linode/generator"; try { const services = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); Object.keys(services).map((service, index) => { Object.keys(services[service]).map((provider, index1) => { - if (provider === "Azure") { - generateAzureClass(services[service][provider], service); - } else if (provider === "AWS") { - generateAWSClass(services[service][provider], service); - } else if (provider === "GCP") { - generateGCPClass(services[service][provider], service); - } else if (provider == "DO") { - generateDOClass(services[service][provider], service); + // if (provider === "Azure") { + // generateAzureClass(services[service][provider], service); + // } else if (provider === "AWS") { + // generateAWSClass(services[service][provider], service); + // } else if (provider === "GCP") { + // generateGCPClass(services[service][provider], service); + // } else if (provider == "DO") { + // generateDOClass(services[service][provider], service); + // } + if(provider == "Linode"){ + generateLinodeClass(services[service][provider],service); } }); }); diff --git a/generator/node-cloud.yml b/generator/node-cloud.yml index 88d97d24..67e4dbcf 100644 --- a/generator/node-cloud.yml +++ b/generator/node-cloud.yml @@ -1,365 +1,372 @@ -ComputeInstance: - AWS: - create: ec2.d.ts runInstances - list: ec2.d.ts describeInstances - start: ec2.d.ts startInstances - stop: ec2.d.ts stopInstances - reboot: ec2.d.ts rebootInstances - destroy: ec2.d.ts terminateInstances - monitor: ec2.d.ts monitorInstances - unmonitor: ec2.d.ts unmonitorInstances - addTags: ec2.d.ts createTags - Azure: - create: arm-compute virtualMachines.d.ts createOrUpdate - list: arm-compute virtualMachines.d.ts list - start: arm-compute virtualMachines.d.ts start - stop: arm-compute virtualMachines.d.ts powerOff - reboot: arm-compute virtualMachines.d.ts restart - destroy: arm-compute virtualMachines.d.ts deleteMethod - # GCP: This SDK currenlty doesn't contain type definition files - DO: - create: droplets.d.ts create - list: droplets.d.ts getAll - destroy: droplets.d.ts deleteById - start: droplets.d.ts requestAction - stop: droplets.d.ts requestAction +# ComputeInstance: +# AWS: +# create: ec2.d.ts runInstances +# list: ec2.d.ts describeInstances +# start: ec2.d.ts startInstances +# stop: ec2.d.ts stopInstances +# reboot: ec2.d.ts rebootInstances +# destroy: ec2.d.ts terminateInstances +# monitor: ec2.d.ts monitorInstances +# unmonitor: ec2.d.ts unmonitorInstances +# addTags: ec2.d.ts createTags +# Azure: +# create: arm-compute virtualMachines.d.ts createOrUpdate +# list: arm-compute virtualMachines.d.ts list +# start: arm-compute virtualMachines.d.ts start +# stop: arm-compute virtualMachines.d.ts powerOff +# reboot: arm-compute virtualMachines.d.ts restart +# destroy: arm-compute virtualMachines.d.ts deleteMethod +# # GCP: This SDK currenlty doesn't contain type definition files +# DO: +# create: droplets.d.ts create +# list: droplets.d.ts getAll +# destroy: droplets.d.ts deleteById +# start: droplets.d.ts requestAction +# stop: droplets.d.ts requestAction -StorageBucket: - AWS: - create: s3.d.ts createBucket - delete: s3.d.ts deleteBucket - list: s3.d.ts listBuckets - upload: s3.d.ts uploadPart - deleteFiles: s3.d.ts deleteObjects - Azure: - create: arm-storage blobContainers.d.ts create - delete: arm-storage blobContainers.d.ts deleteMethod - list: arm-storage blobContainers.d.ts list - GCP: - mainClass: Storage - create: storage storage.d.ts createBucket - deleteFiles: storage bucket.d.ts deleteFiles - delete: storage bucket.d.ts delete - list: storage storage.d.ts getBuckets - upload: storage bucket.d.ts upload - makePublic: storage file.d.ts makePublic +# StorageBucket: +# AWS: +# create: s3.d.ts createBucket +# delete: s3.d.ts deleteBucket +# list: s3.d.ts listBuckets +# upload: s3.d.ts uploadPart +# deleteFiles: s3.d.ts deleteObjects +# Azure: +# create: arm-storage blobContainers.d.ts create +# delete: arm-storage blobContainers.d.ts deleteMethod +# list: arm-storage blobContainers.d.ts list +# GCP: +# mainClass: Storage +# create: storage storage.d.ts createBucket +# deleteFiles: storage bucket.d.ts deleteFiles +# delete: storage bucket.d.ts delete +# list: storage storage.d.ts getBuckets +# upload: storage bucket.d.ts upload +# makePublic: storage file.d.ts makePublic -PaaS: - AWS: - create: elasticbeanstalk.d.ts createApplication - update: elasticbeanstalk.d.ts updateApplication - describe: elasticbeanstalk.d.ts describeApplications - delete: elasticbeanstalk.d.ts deleteApplication - restart: elasticbeanstalk.d.ts restartAppServer - createEnvironment: elasticbeanstalk.d.ts createEnvironment - updateEnvironment: elasticbeanstalk.d.ts updateEnvironment - createConfigTemplate: elasticbeanstalk.d.ts createConfigurationTemplate - describeConfigSettings: elasticbeanstalk.d.ts describeConfigurationSettings - listVersions: elasticbeanstalk.d.ts listPlatformVersions - deleteConfigTemplate: elasticbeanstalk.d.ts deleteConfigurationTemplate - describeAccountAttributes: elasticbeanstalk.d.ts describeAccountAttributes - composeEnvironments: elasticbeanstalk.d.ts composeEnvironments - checkDNSAvailability: elasticbeanstalk.d.ts checkDNSAvailability - terminateEnvironment: elasticbeanstalk.d.ts terminateEnvironment - createStorageLocation: elasticbeanstalk.d.ts createStorageLocation - Azure: - create: arm-appservice webApps.d.ts createOrUpdate - update: arm-appservice webApps.d.ts update - describe: arm-appservice webApps.d.ts get - delete: arm-appservice webApps.d.ts deleteMethod - restart: arm-appservice webApps.d.ts restart - createEnvironment: arm-appservice appServiceEnvironments.d.ts createOrUpdate - updateEnvironment: arm-appservice appServiceEnvironments.d.ts update - createConfigTemplate: arm-appservice webApps.d.ts createOrUpdateSlot - describeConfigSettings: arm-appservice webApps.d.ts getSlot - deleteConfigTemplate: arm-appservice webApps.d.ts deleteSlot - checkDNSAvailability: arm-appservice domains.d.ts checkAvailability - terminateEnvironment: arm-appservice appServiceEnvironments.d.ts deleteMethod +# PaaS: +# AWS: +# create: elasticbeanstalk.d.ts createApplication +# update: elasticbeanstalk.d.ts updateApplication +# describe: elasticbeanstalk.d.ts describeApplications +# delete: elasticbeanstalk.d.ts deleteApplication +# restart: elasticbeanstalk.d.ts restartAppServer +# createEnvironment: elasticbeanstalk.d.ts createEnvironment +# updateEnvironment: elasticbeanstalk.d.ts updateEnvironment +# createConfigTemplate: elasticbeanstalk.d.ts createConfigurationTemplate +# describeConfigSettings: elasticbeanstalk.d.ts describeConfigurationSettings +# listVersions: elasticbeanstalk.d.ts listPlatformVersions +# deleteConfigTemplate: elasticbeanstalk.d.ts deleteConfigurationTemplate +# describeAccountAttributes: elasticbeanstalk.d.ts describeAccountAttributes +# composeEnvironments: elasticbeanstalk.d.ts composeEnvironments +# checkDNSAvailability: elasticbeanstalk.d.ts checkDNSAvailability +# terminateEnvironment: elasticbeanstalk.d.ts terminateEnvironment +# createStorageLocation: elasticbeanstalk.d.ts createStorageLocation +# Azure: +# create: arm-appservice webApps.d.ts createOrUpdate +# update: arm-appservice webApps.d.ts update +# describe: arm-appservice webApps.d.ts get +# delete: arm-appservice webApps.d.ts deleteMethod +# restart: arm-appservice webApps.d.ts restart +# createEnvironment: arm-appservice appServiceEnvironments.d.ts createOrUpdate +# updateEnvironment: arm-appservice appServiceEnvironments.d.ts update +# createConfigTemplate: arm-appservice webApps.d.ts createOrUpdateSlot +# describeConfigSettings: arm-appservice webApps.d.ts getSlot +# deleteConfigTemplate: arm-appservice webApps.d.ts deleteSlot +# checkDNSAvailability: arm-appservice domains.d.ts checkAvailability +# terminateEnvironment: arm-appservice appServiceEnvironments.d.ts deleteMethod Kubernetes: - Azure: - create: arm-containerservice managedClusters.d.ts createOrUpdate - delete: arm-containerservice managedClusters.d.ts deleteMethod - updateTags: arm-containerservice managedClusters.d.ts updateTags - listClusters: arm-containerservice managedClusters.d.ts list - describeCluster: arm-containerservice managedClusters.d.ts get - createNodeGroup: arm-containerservice agentPools.d.ts createOrUpdate - deleteNodegroup: arm-containerservice agentPools.d.ts deleteMethod - describeNodeGroup: arm-containerservice agentPools.d.ts get - listNodegroups: arm-containerservice agentPools.d.ts list - updateConfig: arm-containerservice managedClusters.d.ts rotateClusterCertificates - GCP: - create: container v1 cluster_manager_client.d.ts createCluster - delete: container v1 cluster_manager_client.d.ts deleteCluster - listClusters: container v1 cluster_manager_client.d.ts listClusters - describeCluster: container v1 cluster_manager_client.d.ts getCluster - createNodeGroup: container v1 cluster_manager_client.d.ts createNodePool - deleteNodegroup: container v1 cluster_manager_client.d.ts deleteNodePool - describeNodeGroup: container v1 cluster_manager_client.d.ts getNodePool - listNodegroups: container v1 cluster_manager_client.d.ts listNodePools - updateConfig: container v1 cluster_manager_client.d.ts setAddonsConfig - AWS: - create: eks.d.ts createCluster - delete: eks.d.ts deleteCluster - listClusters: eks.d.ts listClusters - describeCluster: eks.d.ts describeCluster - updateTags: eks.d.ts tagResource - createNodeGroup: eks.d.ts createNodegroup - deleteNodegroup: eks.d.ts deleteNodegroup - describeNodeGroup: eks.d.ts describeNodegroup - listNodegroups: eks.d.ts listNodegroups - updateConfig: eks.d.ts updateClusterConfig - DO: - create: kubernetes.d.ts create - delete: kubernetes.d.ts delete - listClusters: kubernetes.d.ts getClusters - describeCluster: kubernetes.d.ts getById - createNodeGroup: kubernetes.d.ts addNodePool - deleteNodegroup: kubernetes.d.ts deleteNodePool - describeNodeGroup: kubernetes.d.ts getNodePoolById - listNodegroups: kubernetes.d.ts getNodePools +# Azure: +# create: arm-containerservice managedClusters.d.ts createOrUpdate +# delete: arm-containerservice managedClusters.d.ts deleteMethod +# updateTags: arm-containerservice managedClusters.d.ts updateTags +# listClusters: arm-containerservice managedClusters.d.ts list +# describeCluster: arm-containerservice managedClusters.d.ts get +# createNodeGroup: arm-containerservice agentPools.d.ts createOrUpdate +# deleteNodegroup: arm-containerservice agentPools.d.ts deleteMethod +# describeNodeGroup: arm-containerservice agentPools.d.ts get +# listNodegroups: arm-containerservice agentPools.d.ts list +# updateConfig: arm-containerservice managedClusters.d.ts rotateClusterCertificates +# GCP: +# create: container v1 cluster_manager_client.d.ts createCluster +# delete: container v1 cluster_manager_client.d.ts deleteCluster +# listClusters: container v1 cluster_manager_client.d.ts listClusters +# describeCluster: container v1 cluster_manager_client.d.ts getCluster +# createNodeGroup: container v1 cluster_manager_client.d.ts createNodePool +# deleteNodegroup: container v1 cluster_manager_client.d.ts deleteNodePool +# describeNodeGroup: container v1 cluster_manager_client.d.ts getNodePool +# listNodegroups: container v1 cluster_manager_client.d.ts listNodePools +# updateConfig: container v1 cluster_manager_client.d.ts setAddonsConfig +# AWS: +# create: eks.d.ts createCluster +# delete: eks.d.ts deleteCluster +# listClusters: eks.d.ts listClusters +# describeCluster: eks.d.ts describeCluster +# updateTags: eks.d.ts tagResource +# createNodeGroup: eks.d.ts createNodegroup +# deleteNodegroup: eks.d.ts deleteNodegroup +# describeNodeGroup: eks.d.ts describeNodegroup +# listNodegroups: eks.d.ts listNodegroups +# updateConfig: eks.d.ts updateClusterConfig +# DO: +# create: kubernetes.d.ts create +# delete: kubernetes.d.ts delete +# listClusters: kubernetes.d.ts getClusters +# describeCluster: kubernetes.d.ts getById +# createNodeGroup: kubernetes.d.ts addNodePool +# deleteNodegroup: kubernetes.d.ts deleteNodePool +# describeNodeGroup: kubernetes.d.ts getNodePoolById +# listNodegroups: kubernetes.d.ts getNodePools + Linode: + create: kubernetes kubernetes.d.ts createKubernetesCluster + delete: kubernetes kubernetes.d.ts deleteKubernetesCluster + getNodePool: kubernetes nodePools.d.ts getNodePool + createNodePool: kubernetes nodePools.d.ts createNodePool + updateNodePool: kubernetes nodePools.d.ts updateNodePool + deleteNodePool: kubernetes nodePools.d.ts deleteNodePool -Monitoring: - GCP: - createAlarm: monitoring v3 alert_policy_service_client.d.ts createAlertPolicy - deleteAlarm: monitoring v3 alert_policy_service_client.d.ts deleteAlertPolicy - updateAlarm: monitoring v3 alert_policy_service_client.d.ts updateAlertPolicy - listAlarms: monitoring v3 alert_policy_service_client.d.ts listAlertPolicies - getMetricData: monitoring v3 metric_service_client.d.ts getMetricDescriptor - projectPath: monitoring v3 alert_policy_service_client.d.ts projectPath - AWS: - createAlarm: cloudwatch.d.ts putMetricAlarm - deleteAlarm: cloudwatch.d.ts deleteAlarms - updateAlarm: cloudwatch.d.ts putMetricAlarm # same method for update - listAlarms: cloudwatch.d.ts listMetrics - getMetricData: cloudwatch.d.ts getMetricData - Azure: - createAlarm: arm-monitor alertRules.d.ts createOrUpdate - deleteAlarm: arm-monitor alertRules.d.ts deleteMethod - updateAlarm: arm-monitor alertRules.d.ts update - listAlarms: arm-monitor alertRules.d.ts listBySubscription - getMetricData: arm-monitor alertRules.d.ts get +# Monitoring: +# GCP: +# createAlarm: monitoring v3 alert_policy_service_client.d.ts createAlertPolicy +# deleteAlarm: monitoring v3 alert_policy_service_client.d.ts deleteAlertPolicy +# updateAlarm: monitoring v3 alert_policy_service_client.d.ts updateAlertPolicy +# listAlarms: monitoring v3 alert_policy_service_client.d.ts listAlertPolicies +# getMetricData: monitoring v3 metric_service_client.d.ts getMetricDescriptor +# projectPath: monitoring v3 alert_policy_service_client.d.ts projectPath +# AWS: +# createAlarm: cloudwatch.d.ts putMetricAlarm +# deleteAlarm: cloudwatch.d.ts deleteAlarms +# updateAlarm: cloudwatch.d.ts putMetricAlarm # same method for update +# listAlarms: cloudwatch.d.ts listMetrics +# getMetricData: cloudwatch.d.ts getMetricData +# Azure: +# createAlarm: arm-monitor alertRules.d.ts createOrUpdate +# deleteAlarm: arm-monitor alertRules.d.ts deleteMethod +# updateAlarm: arm-monitor alertRules.d.ts update +# listAlarms: arm-monitor alertRules.d.ts listBySubscription +# getMetricData: arm-monitor alertRules.d.ts get -Container: - AWS: - create: ecs.d.ts createCluster - delete: ecs.d.ts deleteCluster - describe: ecs.d.ts describeClusters - list: ecs.d.ts listClusters - Azure: - create: arm-containerservice containerServices.d.ts createOrUpdate - delete: arm-containerservice containerServices.d.ts deleteMethod - describe: arm-containerservice containerServices.d.ts get - list: arm-containerservice containerServices.d.ts list +# Container: +# AWS: +# create: ecs.d.ts createCluster +# delete: ecs.d.ts deleteCluster +# describe: ecs.d.ts describeClusters +# list: ecs.d.ts listClusters +# Azure: +# create: arm-containerservice containerServices.d.ts createOrUpdate +# delete: arm-containerservice containerServices.d.ts deleteMethod +# describe: arm-containerservice containerServices.d.ts get +# list: arm-containerservice containerServices.d.ts list -NoSqlIndexed: - AWS: - createCollection: SimpleDB.d.ts createDomain - deleteCollection: SimpleDB.d.ts deleteDomain - listCollections: SimpleDB.d.ts listDomains - batchDelete: SimpleDB.d.ts batchDeleteAttributes - batchWrite: SimpleDB.d.ts batchPutAttributes - query: SimpleDB.d.ts select - setAttribute: SimpleDB.d.ts putAttributes - deleteAttribute: SimpleDB.d.ts deleteAttributes - getAttributes: SimpleDB.d.ts getAttributes +# NoSqlIndexed: +# AWS: +# createCollection: SimpleDB.d.ts createDomain +# deleteCollection: SimpleDB.d.ts deleteDomain +# listCollections: SimpleDB.d.ts listDomains +# batchDelete: SimpleDB.d.ts batchDeleteAttributes +# batchWrite: SimpleDB.d.ts batchPutAttributes +# query: SimpleDB.d.ts select +# setAttribute: SimpleDB.d.ts putAttributes +# deleteAttribute: SimpleDB.d.ts deleteAttributes +# getAttributes: SimpleDB.d.ts getAttributes -RDBMS: - AWS: - createDatabse: rds.d.ts createDBCluster - deleteDatabase: rds.d.ts deleteDBCluster - createSnapshots: rds.d.ts createDBSnapshot - modifyDB: rds.d.ts modifyDBCluster - restoreDatabase: rds.d.ts rebootDBInstance - deleteDBSnapshot: rds.d.ts deleteDBSnapshot - Azure: - createDatabse: arm-sql databases.d.ts createOrUpdate - deleteDatabase: arm-sql databases.d.ts deleteMethod - createSnapshots: arm-sql databases.d.ts exportMethod - modifyDB: arm-sql databases.d.ts update - restoreDatabase: arm-sql managedDatabases.d.ts completeRestore - GCP: - createDatabse: spanner v1 database_admin_client.d.ts createDatabase - deleteDatabase: spanner v1 database_admin_client.d.ts dropDatabase - createSnapshots: spanner v1 database_admin_client.d.ts createBackup - modifyDB: spanner v1 database_admin_client.d.ts updateDatabaseDdl - restoreDatabase: spanner v1 database_admin_client.d.ts restoreDatabase - deleteDBSnapshot: spanner v1 database_admin_client.d.ts deleteBackup - databasePath: spanner v1 database_admin_client.d.ts databasePath - DO: - createCluster: databases.d.ts createCluster - getClusters: databases.d.ts getAllClusters - getCluster: databases.d.ts getClusterById - updateCluster: databases.d.ts resizeCluster +# RDBMS: +# AWS: +# createDatabse: rds.d.ts createDBCluster +# deleteDatabase: rds.d.ts deleteDBCluster +# createSnapshots: rds.d.ts createDBSnapshot +# modifyDB: rds.d.ts modifyDBCluster +# restoreDatabase: rds.d.ts rebootDBInstance +# deleteDBSnapshot: rds.d.ts deleteDBSnapshot +# Azure: +# createDatabse: arm-sql databases.d.ts createOrUpdate +# deleteDatabase: arm-sql databases.d.ts deleteMethod +# createSnapshots: arm-sql databases.d.ts exportMethod +# modifyDB: arm-sql databases.d.ts update +# restoreDatabase: arm-sql managedDatabases.d.ts completeRestore +# GCP: +# createDatabse: spanner v1 database_admin_client.d.ts createDatabase +# deleteDatabase: spanner v1 database_admin_client.d.ts dropDatabase +# createSnapshots: spanner v1 database_admin_client.d.ts createBackup +# modifyDB: spanner v1 database_admin_client.d.ts updateDatabaseDdl +# restoreDatabase: spanner v1 database_admin_client.d.ts restoreDatabase +# deleteDBSnapshot: spanner v1 database_admin_client.d.ts deleteBackup +# databasePath: spanner v1 database_admin_client.d.ts databasePath +# DO: +# createCluster: databases.d.ts createCluster +# getClusters: databases.d.ts getAllClusters +# getCluster: databases.d.ts getClusterById +# updateCluster: databases.d.ts resizeCluster -NoSql: - AWS: - createTable: dynamodb.d.ts createTable - createItem: dynamodb.d.ts putItem - deleteItem: dynamodb.d.ts deleteItem - updateItem: dynamodb.d.ts updateItem - query: dynamodb.d.ts query - deleteTable: dynamodb.d.ts deleteTable - Azure: - createCollection: arm-cosmosdb tableResources.d.ts createUpdateTable - deleteCollection: arm-cosmosdb tableResources.d.ts deleteTable - listCollections: arm-cosmosdb tableResources.d.ts listTables - setAttribute: arm-cosmosdb tableResources.d.ts updateTableThroughput - getAttributes: arm-cosmosdb tableResources.d.ts getTable - GCP: - createItem: firestore v1 firestore_client.d.ts createDocument - deleteItem: firestore v1 firestore_client.d.ts deleteDocument - updateItem: firestore v1 firestore_client.d.ts updateDocument - query: firestore v1 firestore_client.d.ts runQuery - DO: - createCluster: databases.d.ts createCluster - getClusters: databases.d.ts getAllClusters - getCluster: databases.d.ts getClusterById - updateCluster: databases.d.ts resizeCluster +# NoSql: +# AWS: +# createTable: dynamodb.d.ts createTable +# createItem: dynamodb.d.ts putItem +# deleteItem: dynamodb.d.ts deleteItem +# updateItem: dynamodb.d.ts updateItem +# query: dynamodb.d.ts query +# deleteTable: dynamodb.d.ts deleteTable +# Azure: +# createCollection: arm-cosmosdb tableResources.d.ts createUpdateTable +# deleteCollection: arm-cosmosdb tableResources.d.ts deleteTable +# listCollections: arm-cosmosdb tableResources.d.ts listTables +# setAttribute: arm-cosmosdb tableResources.d.ts updateTableThroughput +# getAttributes: arm-cosmosdb tableResources.d.ts getTable +# GCP: +# createItem: firestore v1 firestore_client.d.ts createDocument +# deleteItem: firestore v1 firestore_client.d.ts deleteDocument +# updateItem: firestore v1 firestore_client.d.ts updateDocument +# query: firestore v1 firestore_client.d.ts runQuery +# DO: +# createCluster: databases.d.ts createCluster +# getClusters: databases.d.ts getAllClusters +# getCluster: databases.d.ts getClusterById +# updateCluster: databases.d.ts resizeCluster -DNS: - AWS: - createZone: route53.d.ts createHostedZone - deleteZone: route53.d.ts deleteHostedZone - listZones: route53.d.ts listHostedZones - changeRecordSets: route53.d.ts changeResourceRecordSets - Azure: - createZone: arm-dns zones.d.ts createOrUpdate - deleteZone: arm-dns zones.d.ts deleteMethod - listZones: arm-dns zones.d.ts list - changeRecordSets: arm-dns recordSets.d.ts createOrUpdate - GCP: - mainClass: DNS - createZone: dns zone.d.ts create - deleteZone: dns zone.d.ts delete - listZones: dns index.d.ts getZones - changeRecordSets: dns zone.d.ts createChange - record: dns zone.d.ts record - DO: - createRecord: domains.d.ts createRecord - deleteRecord: domains.d.ts deleteRecord - getRecords: domains.d.ts getAllRecords - getRecord: domains.d.ts getRecord - changeRecordSets: domains.d.ts updateRecord +# DNS: +# AWS: +# createZone: route53.d.ts createHostedZone +# deleteZone: route53.d.ts deleteHostedZone +# listZones: route53.d.ts listHostedZones +# changeRecordSets: route53.d.ts changeResourceRecordSets +# Azure: +# createZone: arm-dns zones.d.ts createOrUpdate +# deleteZone: arm-dns zones.d.ts deleteMethod +# listZones: arm-dns zones.d.ts list +# changeRecordSets: arm-dns recordSets.d.ts createOrUpdate +# GCP: +# mainClass: DNS +# createZone: dns zone.d.ts create +# deleteZone: dns zone.d.ts delete +# listZones: dns index.d.ts getZones +# changeRecordSets: dns zone.d.ts createChange +# record: dns zone.d.ts record +# DO: +# createRecord: domains.d.ts createRecord +# deleteRecord: domains.d.ts deleteRecord +# getRecords: domains.d.ts getAllRecords +# getRecord: domains.d.ts getRecord +# changeRecordSets: domains.d.ts updateRecord -LoadBalancer: - AWS: - create: elb.d.ts createLoadBalancer - delete: elb.d.ts deleteLoadBalancer - list: elb.d.ts describeLoadBalancers - addTags: elb.d.ts addTags - describe: elb.d.ts describeLoadBalancerAttributes - Azure: - create: arm-network loadBalancers.d.ts createOrUpdate - delete: arm-network loadBalancers.d.ts deleteMethod - list: arm-network loadBalancers.d.ts list - addTags: arm-network loadBalancers.d.ts updateTags - describe: arm-network loadBalancers.d.ts get - DO: - create: load-balancers.d.ts create - delete: load-balancers.d.ts delete - list: load-balancers.d.ts getAll - update: load-balancers.d.ts update +# LoadBalancer: +# AWS: +# create: elb.d.ts createLoadBalancer +# delete: elb.d.ts deleteLoadBalancer +# list: elb.d.ts describeLoadBalancers +# addTags: elb.d.ts addTags +# describe: elb.d.ts describeLoadBalancerAttributes +# Azure: +# create: arm-network loadBalancers.d.ts createOrUpdate +# delete: arm-network loadBalancers.d.ts deleteMethod +# list: arm-network loadBalancers.d.ts list +# addTags: arm-network loadBalancers.d.ts updateTags +# describe: arm-network loadBalancers.d.ts get +# DO: +# create: load-balancers.d.ts create +# delete: load-balancers.d.ts delete +# list: load-balancers.d.ts getAll +# update: load-balancers.d.ts update -IAM: - AWS: - createGroup: iam.d.ts createGroup - deleteGroup: iam.d.ts deleteGroup - attachGroupPolicy: iam.d.ts attachGroupPolicy - detachGroupPolicy: iam.d.ts detachGroupPolicy - describe: iam.d.ts getGroup +# IAM: +# AWS: +# createGroup: iam.d.ts createGroup +# deleteGroup: iam.d.ts deleteGroup +# attachGroupPolicy: iam.d.ts attachGroupPolicy +# detachGroupPolicy: iam.d.ts detachGroupPolicy +# describe: iam.d.ts getGroup -ArchivalStorage: - AWS: - create: glacier.d.ts createVault - delete: glacier.d.ts deleteVault - list: glacier.d.ts listParts - upload: glacier.d.ts initiateMultipartUpload - deleteFiles: glacier.d.ts deleteArchive +# ArchivalStorage: +# AWS: +# create: glacier.d.ts createVault +# delete: glacier.d.ts deleteVault +# list: glacier.d.ts listParts +# upload: glacier.d.ts initiateMultipartUpload +# deleteFiles: glacier.d.ts deleteArchive - GCP: - # Use storage class as coldline - mainClass: Storage - create: storage storage.d.ts createBucket - deleteFiles: storage bucket.d.ts deleteFiles - delete: storage bucket.d.ts delete - list: storage storage.d.ts getBuckets - upload: storage bucket.d.ts upload - makePublic: storage file.d.ts makePublic +# GCP: +# # Use storage class as coldline +# mainClass: Storage +# create: storage storage.d.ts createBucket +# deleteFiles: storage bucket.d.ts deleteFiles +# delete: storage bucket.d.ts delete +# list: storage storage.d.ts getBuckets +# upload: storage bucket.d.ts upload +# makePublic: storage file.d.ts makePublic -Translation: - AWS: - translate: translate.d.ts translateText - batchTranslate: translate.d.ts startTextTranslationJob - getGlossary: translate.d.ts getTerminology - createGlossary: translate.d.ts importTerminology - deleteGlossary: translate.d.ts deleteTerminology - GCP: - translate: translate v3 translation_service_client.d.ts translateText - batchTranslate: translate v3 translation_service_client.d.ts batchTranslateText - getGlossary: translate v3 translation_service_client.d.ts getGlossary - createGlossary: translate v3 translation_service_client.d.ts createGlossary - detectLanguage: translate v3 translation_service_client.d.ts detectLanguage +# Translation: +# AWS: +# translate: translate.d.ts translateText +# batchTranslate: translate.d.ts startTextTranslationJob +# getGlossary: translate.d.ts getTerminology +# createGlossary: translate.d.ts importTerminology +# deleteGlossary: translate.d.ts deleteTerminology +# GCP: +# translate: translate v3 translation_service_client.d.ts translateText +# batchTranslate: translate v3 translation_service_client.d.ts batchTranslateText +# getGlossary: translate v3 translation_service_client.d.ts getGlossary +# createGlossary: translate v3 translation_service_client.d.ts createGlossary +# detectLanguage: translate v3 translation_service_client.d.ts detectLanguage -KeyManagement: - AWS: - createKey: kms.d.ts createKey - deleteKey: kms.d.ts deleteCustomKeyStore - update: kms.d.ts updateKeyDescription - describeKey: kms.d.ts describeKey - putKeyPolicy: kms.d.ts putKeyPolicy - Azure: - createKey: arm-keyvault vaults.d.ts createOrUpdate - deleteKey: arm-keyvault vaults.d.ts deleteMethod - update: arm-keyvault vaults.d.ts update - describeKey: arm-keyvault vaults.d.ts get - putKeyPolicy: arm-keyvault vaults.d.ts updateAccessPolicy - GCP: - createKey: kms v1 key_management_service_client.d.ts createCryptoKey - deleteKey: kms v1 key_management_service_client.d.ts destroyCryptoKeyVersion - update: kms v1 key_management_service_client.d.ts updateCryptoKey - describeKey: kms v1 key_management_service_client.d.ts getCryptoKey - putKeyPolicy: kms v1 key_management_service_client.d.ts setIamPolicy - DO: - createKey: keys.d.ts add - deleteKey: keys.d.ts delete - list: keys.d.ts getAll - describeKey: keys.d.ts getById +# KeyManagement: +# AWS: +# createKey: kms.d.ts createKey +# deleteKey: kms.d.ts deleteCustomKeyStore +# update: kms.d.ts updateKeyDescription +# describeKey: kms.d.ts describeKey +# putKeyPolicy: kms.d.ts putKeyPolicy +# Azure: +# createKey: arm-keyvault vaults.d.ts createOrUpdate +# deleteKey: arm-keyvault vaults.d.ts deleteMethod +# update: arm-keyvault vaults.d.ts update +# describeKey: arm-keyvault vaults.d.ts get +# putKeyPolicy: arm-keyvault vaults.d.ts updateAccessPolicy +# GCP: +# createKey: kms v1 key_management_service_client.d.ts createCryptoKey +# deleteKey: kms v1 key_management_service_client.d.ts destroyCryptoKeyVersion +# update: kms v1 key_management_service_client.d.ts updateCryptoKey +# describeKey: kms v1 key_management_service_client.d.ts getCryptoKey +# putKeyPolicy: kms v1 key_management_service_client.d.ts setIamPolicy +# DO: +# createKey: keys.d.ts add +# deleteKey: keys.d.ts delete +# list: keys.d.ts getAll +# describeKey: keys.d.ts getById -NotificationService: - AWS: - createTopic: sns.d.ts createTopic - deleteTopic: sns.d.ts deleteTopic - getTopicAttributes: sns.d.ts getTopicAttributes - listSubscriptions: sns.d.ts listSubscriptions - publish: sns.d.ts publish - subscribe: sns.d.ts subscribe - listTopics: sns.d.ts listTopics - unsubscribe: sns.d.ts unsubscribe - GCP: - createTopic: pubsub v1 publisher_client.d.ts createTopic - deleteTopic: pubsub v1 publisher_client.d.ts deleteTopic - getTopicAttributes: pubsub v1 publisher_client.d.ts getTopic - listSubscriptions: pubsub v1 publisher_client.d.ts listTopicSubscriptions - subscribe: pubsub v1 subscriber_client.d.ts createSubscription - publish: pubsub v1 publisher_client.d.ts publish - listTopics: pubsub v1 publisher_client.d.ts listTopics - unsubscribe: pubsub v1 subscriber_client.d.ts deleteSubscription +# NotificationService: +# AWS: +# createTopic: sns.d.ts createTopic +# deleteTopic: sns.d.ts deleteTopic +# getTopicAttributes: sns.d.ts getTopicAttributes +# listSubscriptions: sns.d.ts listSubscriptions +# publish: sns.d.ts publish +# subscribe: sns.d.ts subscribe +# listTopics: sns.d.ts listTopics +# unsubscribe: sns.d.ts unsubscribe +# GCP: +# createTopic: pubsub v1 publisher_client.d.ts createTopic +# deleteTopic: pubsub v1 publisher_client.d.ts deleteTopic +# getTopicAttributes: pubsub v1 publisher_client.d.ts getTopic +# listSubscriptions: pubsub v1 publisher_client.d.ts listTopicSubscriptions +# subscribe: pubsub v1 subscriber_client.d.ts createSubscription +# publish: pubsub v1 publisher_client.d.ts publish +# listTopics: pubsub v1 publisher_client.d.ts listTopics +# unsubscribe: pubsub v1 subscriber_client.d.ts deleteSubscription -BlockStorage: - AWS: - create: ec2.d.ts createVolume - delete: ec2.d.ts deleteVolume - describe: ec2.d.ts describeVolumeAttribute - list: ec2.d.ts describeVolumes - Azure: - create: arm-compute disks.d.ts createOrUpdate - delete: arm-compute disks.d.ts deleteMethod - describe: arm-compute disks.d.ts get - list: arm-compute disks.d.ts list - update: arm-compute disks.d.ts update - DO: - create: volumes.d.ts create - delete: volumes.d.ts deleteById - list: volumes.d.ts getAll - describe: volumes.d.ts getById +# BlockStorage: +# AWS: +# create: ec2.d.ts createVolume +# delete: ec2.d.ts deleteVolume +# describe: ec2.d.ts describeVolumeAttribute +# list: ec2.d.ts describeVolumes +# Azure: +# create: arm-compute disks.d.ts createOrUpdate +# delete: arm-compute disks.d.ts deleteMethod +# describe: arm-compute disks.d.ts get +# list: arm-compute disks.d.ts list +# update: arm-compute disks.d.ts update +# DO: +# create: volumes.d.ts create +# delete: volumes.d.ts deleteById +# list: volumes.d.ts getAll +# describe: volumes.d.ts getById diff --git a/generator/parsers/aws/parser.js b/generator/parsers/aws/parser.js index 8fd5e392..b285118e 100644 --- a/generator/parsers/aws/parser.js +++ b/generator/parsers/aws/parser.js @@ -1,194 +1,82 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.getAST = void 0; var fs = require("fs"); var path = require("path"); var typescript_1 = require("typescript"); function getAST(sdkFileName) { - var _this = this; - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - var file, ast, cloned_1, error_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join( - __dirname, - "../../../node_modules/aws-sdk/clients/" + - sdkFileName.toLowerCase() - ); - ast = typescript_1.createSourceFile( - file, - fs.readFileSync(file).toString(), - typescript_1.ScriptTarget.Latest, - true - ); - cloned_1 = null; - return [ - 4 /*yield*/, - ast.forEachChild(function(child) { - if ( - typescript_1.SyntaxKind[child.kind] === "ClassDeclaration" - ) { - cloned_1 = Object.assign({}, child); - } - }) - ]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } else { - resolve(cloned_1); + var _this = this; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var file, ast, cloned_1, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join(__dirname, "../../../node_modules/aws-sdk/clients/" + sdkFileName.toLowerCase()); + ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); + cloned_1 = null; + return [4 /*yield*/, ast.forEachChild(function (child) { + if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { + cloned_1 = Object.assign({}, child); + } + })]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error("Class not found!")); + } + else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === "ENOENT") { + reject(new Error("File not found!")); + } + else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.getAST = getAST; diff --git a/generator/parsers/azure/parser.js b/generator/parsers/azure/parser.js index 317dfc5f..96fafb87 100644 --- a/generator/parsers/azure/parser.js +++ b/generator/parsers/azure/parser.js @@ -1,196 +1,82 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.getAST = void 0; var fs = require("fs"); var path = require("path"); var typescript_1 = require("typescript"); function getAST(sdkFileInfo) { - var _this = this; - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - var file, ast, cloned_1, error_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join( - __dirname, - "../../../node_modules/@azure/" + - sdkFileInfo.pkgName + - "/esm/operations/" + - sdkFileInfo.fileName - ); - ast = typescript_1.createSourceFile( - file, - fs.readFileSync(file).toString(), - typescript_1.ScriptTarget.Latest, - true - ); - cloned_1 = null; - return [ - 4 /*yield*/, - ast.forEachChild(function(child) { - if ( - typescript_1.SyntaxKind[child.kind] === "ClassDeclaration" - ) { - cloned_1 = Object.assign({}, child); - } - }) - ]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } else { - resolve(cloned_1); + var _this = this; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var file, ast, cloned_1, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join(__dirname, "../../../node_modules/@azure/" + sdkFileInfo.pkgName + "/esm/operations/" + sdkFileInfo.fileName); + ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); + cloned_1 = null; + return [4 /*yield*/, ast.forEachChild(function (child) { + if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { + cloned_1 = Object.assign({}, child); + } + })]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error("Class not found!")); + } + else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === "ENOENT") { + reject(new Error("File not found!")); + } + else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.getAST = getAST; diff --git a/generator/parsers/do/parser.js b/generator/parsers/do/parser.js index 3e03d611..e861342d 100644 --- a/generator/parsers/do/parser.js +++ b/generator/parsers/do/parser.js @@ -1,194 +1,83 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.getAST = void 0; var fs = require("fs"); var path = require("path"); var typescript_1 = require("typescript"); function getAST(sdkFileName) { - var _this = this; - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - var file, ast, cloned_1, error_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join( - __dirname, - "../../../node_modules/do-wrapper/dist/modules/" + - sdkFileName.toLowerCase() - ); - ast = typescript_1.createSourceFile( - file, - fs.readFileSync(file).toString(), - typescript_1.ScriptTarget.Latest, - true - ); - cloned_1 = null; - return [ - 4 /*yield*/, - ast.forEachChild(function(child) { - if ( - typescript_1.SyntaxKind[child.kind] === "ClassDeclaration" - ) { - cloned_1 = Object.assign({}, child); - } - }) - ]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } else { - resolve(cloned_1); + var _this = this; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var file, ast, cloned_1, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join(__dirname, "../../../node_modules/do-wrapper/dist/modules/" + + sdkFileName.toLowerCase()); + ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); + cloned_1 = null; + return [4 /*yield*/, ast.forEachChild(function (child) { + if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { + cloned_1 = Object.assign({}, child); + } + })]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error("Class not found!")); + } + else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === "ENOENT") { + reject(new Error("File not found!")); + } + else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.getAST = getAST; diff --git a/generator/parsers/googleCloud/parser.js b/generator/parsers/googleCloud/parser.js index 4c9dc64c..cde5f858 100644 --- a/generator/parsers/googleCloud/parser.js +++ b/generator/parsers/googleCloud/parser.js @@ -1,220 +1,102 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.getAST = void 0; var fs = require("fs"); var path = require("path"); var typescript_1 = require("typescript"); function getAST(sdkFileInfo, multi) { - var _this = this; - var filePath; - if (sdkFileInfo.version) { - filePath = - "../../../node_modules/@google-cloud/" + - sdkFileInfo.pkgName + - "/build/src/" + - sdkFileInfo.version + - "/" + - sdkFileInfo.fileName; - } else { - filePath = - "../../../node_modules/@google-cloud/" + - sdkFileInfo.pkgName + - "/build/src/" + - sdkFileInfo.fileName; - } - return new Promise(function(resolve, reject) { - return __awaiter(_this, void 0, void 0, function() { - var file, ast, classes_1, cloned, error_1; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - file = path.join(__dirname, filePath); - ast = typescript_1.createSourceFile( - file, - fs.readFileSync(file).toString(), - typescript_1.ScriptTarget.Latest, - true - ); - if (!(multi === true)) return [3 /*break*/, 1]; - classes_1 = []; - ast.forEachChild(function(child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - var cloned = Object.assign({}, child); - classes_1.push(cloned); - } - }); - resolve(classes_1); - return [3 /*break*/, 3]; - case 1: - cloned = null; - return [ - 4 /*yield*/, - ast.forEachChild(function(child) { - if ( - typescript_1.SyntaxKind[child.kind] === "ClassDeclaration" - ) { - var cloned_1 = Object.assign({}, child); - return resolve(cloned_1); - } - }) - ]; - case 2: - _a.sent(); - if (!cloned) { - return [2 /*return*/, reject(new Error("Class not found!"))]; - } else { - return [2 /*return*/, resolve(cloned)]; - } - _a.label = 3; - case 3: - return [3 /*break*/, 5]; - case 4: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } else { - reject(error_1); + var _this = this; + var filePath; + if (sdkFileInfo.version) { + filePath = "../../../node_modules/@google-cloud/" + sdkFileInfo.pkgName + "/build/src/" + sdkFileInfo.version + "/" + sdkFileInfo.fileName; + } + else { + filePath = "../../../node_modules/@google-cloud/" + sdkFileInfo.pkgName + "/build/src/" + sdkFileInfo.fileName; + } + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var file, ast, classes_1, cloned, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 4, , 5]); + file = path.join(__dirname, filePath); + ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); + if (!(multi === true)) return [3 /*break*/, 1]; + classes_1 = []; + ast.forEachChild(function (child) { + if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { + var cloned = Object.assign({}, child); + classes_1.push(cloned); + } + }); + resolve(classes_1); + return [3 /*break*/, 3]; + case 1: + cloned = null; + return [4 /*yield*/, ast.forEachChild(function (child) { + if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { + var cloned_1 = Object.assign({}, child); + return resolve(cloned_1); + } + })]; + case 2: + _a.sent(); + if (!cloned) { + return [2 /*return*/, reject(new Error("Class not found!"))]; + } + else { + return [2 /*return*/, resolve(cloned)]; + } + _a.label = 3; + case 3: return [3 /*break*/, 5]; + case 4: + error_1 = _a.sent(); + if (error_1.code === "ENOENT") { + reject(new Error("File not found!")); + } + else { + reject(error_1); + } + return [3 /*break*/, 5]; + case 5: return [2 /*return*/]; } - return [3 /*break*/, 5]; - case 5: - return [2 /*return*/]; - } - }); - }); - }); + }); + }); }); } exports.getAST = getAST; diff --git a/generator/parsers/linode/parser.js b/generator/parsers/linode/parser.js new file mode 100644 index 00000000..4bf6bb89 --- /dev/null +++ b/generator/parsers/linode/parser.js @@ -0,0 +1,98 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +exports.getAST = void 0; +var fs = require("fs"); +var path = require("path"); +var typescript_1 = require("typescript"); +function getAST(sdkFileInfo) { + var _this = this; + return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { + var file, ast, cloned_1, tmp_1, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join(__dirname, '../../../node_modules/@linode/api-v4/lib/' + + sdkFileInfo.pkgName + + '/' + + sdkFileInfo.fileName); + ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); + cloned_1 = []; + tmp_1 = null; + return [4 /*yield*/, ast.forEachChild(function (child) { + // fs.writeFile('test.txt', SyntaxKind[child.kind], null); + // console.log(SyntaxKind[child.kind]); + // console.log('Linode', SyntaxKind[child.kind]); + // console.log("child",child); + if (typescript_1.SyntaxKind[child.kind] === 'FirstStatement') { + // console.log("child",child); + // resolve(false) + tmp_1 = Object.assign({}, child); + cloned_1.push(tmp_1.declarationList.declarations[0]); + // console.log( + // 'name', + // tmp.declarationList.declarations[0].type.parameters[0] + // ); + } + })]; + case 1: + _a.sent(); + // console.log('cloned', cloned); + if (!cloned_1) { + reject(new Error('Function not found!')); + } + else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } + else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; + } + }); + }); }); +} +exports.getAST = getAST; diff --git a/generator/parsers/linode/parser.ts b/generator/parsers/linode/parser.ts new file mode 100644 index 00000000..5c809b2e --- /dev/null +++ b/generator/parsers/linode/parser.ts @@ -0,0 +1,61 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; + +export function getAST(sdkFileInfo) { + return new Promise(async (resolve, reject) => { + try { + + const file = path.join( + __dirname, + '../../../node_modules/@linode/api-v4/lib/' + + sdkFileInfo.pkgName + + '/' + + sdkFileInfo.fileName + ); + + const ast = createSourceFile( + file, + fs.readFileSync(file).toString(), + ScriptTarget.Latest, + true + ); + + let cloned = []; + let tmp = null; + await ast.forEachChild(child => { + // fs.writeFile('test.txt', SyntaxKind[child.kind], null); + // console.log(SyntaxKind[child.kind]); + + // console.log('Linode', SyntaxKind[child.kind]); + // console.log("child",child); + + if (SyntaxKind[child.kind] === 'FirstStatement') { + // console.log("child",child); + // resolve(false) + tmp = Object.assign({}, child); + cloned.push(tmp.declarationList.declarations[0]); + + // console.log( + // 'name', + // tmp.declarationList.declarations[0].type.parameters[0] + // ); + } + + }); + // console.log('cloned', cloned); + + if (!cloned) { + reject(new Error('Function not found!')); + } else { + resolve(cloned); + } + } catch (error) { + if (error.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error); + } + } + }); +} diff --git a/generator/transformers/aws/transformer.js b/generator/transformers/aws/transformer.js index 90312335..683ff0a5 100644 --- a/generator/transformers/aws/transformer.js +++ b/generator/transformers/aws/transformer.js @@ -1,407 +1,200 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.transform = void 0; -var ts = require("typescript"); var lodash_1 = require("lodash"); +var ts = require("typescript"); var dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + "ClassName", + "_sdkClassName", + "SDKClassName", + "SDKFunctionName" ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function(resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise(function (resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); + resolve(output); + } + catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); } function transform(code, classData) { - return __awaiter(this, void 0, void 0, function() { - var addFunctions, - addIdentifiers, - addComments, - node, - result_1, - result_2, - result_3; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - addFunctions = function(context) { - return function(rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function(method) { - var clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions_1)) - ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addIdentifiers = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier( - "undefined" - ); - } - return paramNode; - } - ); - node.parameters = parameters; - } - if ( - ts.isIdentifier(node) && - dummyIdentifiers.includes(node.text) - ) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("AWS_" + classData.serviceName) - ); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.className) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].SDKFunctionName - ) - ); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function(childNode) { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - var args = classData.functions[count].params.map(function( - param - ) { - return ts.createIdentifier(param.name); - }); - node.arguments = args.concat(node.arguments); + return __awaiter(this, void 0, void 0, function () { + var addFunctions, addIdentifiers, addComments, node, result_1, result_2, result_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + addFunctions = function (context) { return function (rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function (method) { + var clonedNode = Object.assign({}, node.members[1]); + clonedNode.name = ts.createIdentifier(method.functionName); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addIdentifiers = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); + if (param.optional) { + paramNode.initializer = ts.createIdentifier("undefined"); + } + return paramNode; + }); + node.parameters = parameters; + } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + var updatedIdentifier = void 0; + switch (node.text) { + case "ClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("AWS_" + classData.serviceName)); + break; + case "_sdkClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + + classData.className.charAt(0).toLowerCase() + + classData.className.substr(1))); + break; + case "SDKClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.className)); + break; + case "SDKFunctionName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function (childNode) { + if (ts.isIdentifier(childNode) && + childNode.text === "SDKFunctionName") { + var args = classData.functions[count].params.map(function (param) { + return ts.createIdentifier(param.name); + }); + node.arguments = args.concat(node.arguments); + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addComments = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment(node, "This is an auto generated class, please do not change."); + var comment = "*\n * Class to create a " + classData.className + " object\n * @category AWS \n "; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var statment; + if (param.optional) { + statment = "* @param {" + param.typeName + "} [" + param.name + "] - Data required for " + classData.functions[count].SDKFunctionName; + } + else { + statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ""; + parameters.map(function (param) { + paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); + }); + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + else { + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); + if (!classData.className || !classData.functions) { + throw new Error("Input is invalid"); } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addComments = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - var comment = - "*\n * Class to create a " + - classData.className + - " object\n * @category AWS \n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var statment; - if (param.optional) { - statment = - "* @param {" + - param.typeName + - "} [" + - param.name + - "] - Data required for " + - classData.functions[count].SDKFunctionName; - } else { - statment = - "* @param {" + - param.typeName + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - } - return statment; + if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { + throw new Error("Code is invalid"); } - ); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function(param) { - paramStatments_1 = paramStatments_1.concat( - paramStatments_1 === "" ? "" + param : "\n " + param - ); - }); - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.className + - "\n " + - paramStatments_1 + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } else { - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.className + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - node = code.statements.find(function(stm) { - return ts.isClassDeclaration(stm); - }); - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - if ( - !node || - !node.members.some(function(member) { - return ts.isMethodDeclaration(member); - }) - ) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_1), addIdentifiers) - ]; - case 2: - result_2 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_2), addComments) - ]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } + code = lodash_1.cloneDeep(code); + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; + case 2: + result_2 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); }); - }); } exports.transform = transform; diff --git a/generator/transformers/azure/transformer.js b/generator/transformers/azure/transformer.js index 1ae0748d..c9f7f03c 100644 --- a/generator/transformers/azure/transformer.js +++ b/generator/transformers/azure/transformer.js @@ -1,428 +1,212 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.transform = void 0; -var ts = require("typescript"); var lodash_1 = require("lodash"); +var ts = require("typescript"); var dummyIdentifiers = [ - "ClassName", - "SDKClassName", - "SDKFunctionName", - "ClientName", - "functionClient" + "ClassName", + "SDKClassName", + "SDKFunctionName", + "ClientName", + "functionClient" ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function(resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise(function (resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); + resolve(output); + } + catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); } function transform(code, classData) { - return __awaiter(this, void 0, void 0, function() { - var node, - importStatments, - addFunctions, - addIdentifiers, - addComments, - result_1, - result_2, - result_3; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function(stm) { - return ts.isClassDeclaration(stm); - }); - if (!classData.functions) { - throw new Error("Input is invalid"); - } - if ( - !node || - !node.members.some(function(member) { - return ts.isMethodDeclaration(member); - }) - ) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - // import related - classData.clients = Array.from( - new Set( - classData.functions.map(function(method) { - return method.client; - }) - ) - ); - importStatments = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); - addFunctions = function(context) { - return function(rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function(method) { - var clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions_1)) - ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addIdentifiers = function(context) { - return function(rootNode) { - var count = 0; - var clientCount = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier( - "undefined" - ); - } - return paramNode; - } - ); - node.parameters = parameters; - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@azure/" + classData.functions[0].pkgName - ); - } - if ( - ts.isIdentifier(node) && - dummyIdentifiers.includes(node.text) - ) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("Azure_" + classData.serviceName) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].fileName.split(".")[0] - ) - ); - break; - case "functionClient": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].client) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientCount]) - ); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].SDKFunctionName - ) - ); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function(childNode) { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - var args = classData.functions[count].params.map(function( - param - ) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; + return __awaiter(this, void 0, void 0, function () { + var node, importStatments, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); + if (!classData.functions) { + throw new Error("Input is invalid"); } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addComments = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - var comment = - "*\n * Class to create a " + - classData.serviceName + - " object\n * @category Azure\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var statment; - if (param.optional) { - statment = - "* @param {" + - param.type + - "} [" + - param.name + - "] - Optional parameter"; - } else { - statment = - "* @param {" + - param.type + - "} " + - param.name + - " - Mandatory parameter"; - } - return statment; + if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { + throw new Error("Code is invalid"); } - ); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function(param) { - paramStatments_1 = paramStatments_1.concat( - paramStatments_1 === "" ? "" + param : "\n " + param - ); - }); - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.functions[0].pkgName.split("-")[1] + - "\n " + - paramStatments_1 + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } else { - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.functions[0].pkgName.split("-")[1] + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_1), addIdentifiers) - ]; - case 2: - result_2 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_2), addComments) - ]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } + code = lodash_1.cloneDeep(code); + // import related + classData.clients = Array.from(new Set(classData.functions.map(function (method) { return method.client; }))); + importStatments = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat(code.statements.slice(1)); + addFunctions = function (context) { return function (rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function (method) { + var clonedNode = Object.assign({}, node.members[1]); + clonedNode.name = ts.createIdentifier(method.functionName); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addIdentifiers = function (context) { return function (rootNode) { + var count = 0; + var clientCount = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); + if (param.optional) { + paramNode.initializer = ts.createIdentifier("undefined"); + } + return paramNode; + }); + node.parameters = parameters; + } + if (ts.isStringLiteral(node) && node.text === "pkgName") { + return ts.createStringLiteral("@azure/" + classData.functions[0].pkgName); + } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + var updatedIdentifier = void 0; + switch (node.text) { + case "ClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("Azure_" + classData.serviceName)); + break; + case "SDKClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].fileName.split(".")[0])); + break; + case "functionClient": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].client)); + break; + case "ClientName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientCount])); + clientCount++; + break; + case "SDKFunctionName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function (childNode) { + if (ts.isIdentifier(childNode) && + childNode.text === "SDKFunctionName") { + var args = classData.functions[count].params.map(function (param) { + return ts.createIdentifier(param.name); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addComments = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment(node, "This is an auto generated class, please do not change."); + var comment = "*\n * Class to create a " + classData.serviceName + " object\n * @category Azure\n "; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var statment; + if (param.optional) { + statment = "* @param {" + param.type + "} [" + param.name + "] - Optional parameter"; + } + else { + statment = "* @param {" + param.type + "} " + param.name + " - Mandatory parameter"; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ""; + parameters.map(function (param) { + paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); + }); + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + else { + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; + case 2: + result_2 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); }); - }); } exports.transform = transform; diff --git a/generator/transformers/do/transformer.js b/generator/transformers/do/transformer.js index 81a0bc68..973c8664 100644 --- a/generator/transformers/do/transformer.js +++ b/generator/transformers/do/transformer.js @@ -1,433 +1,212 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.transform = void 0; -var ts = require("typescript"); var lodash_1 = require("lodash"); +var ts = require("typescript"); var dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + "ClassName", + "_sdkClassName", + "SDKClassName", + "SDKFunctionName" ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function(resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise(function (resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); + resolve(output); + } + catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); } /* * The Transform function to be called from generator */ function transform(code, classData) { - return __awaiter(this, void 0, void 0, function() { - var addFunctions, - addIdentifiers, - addComments, - node, - result_1, - result_2, - result_3; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - addFunctions = function(context) { - return function(rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function(method) { - var clonedNode = Object.assign({}, node.members[1]); - // console.log("Cloned Node..........\n");//sdadas - // console.log(clonedNode);//asdasdasdasd - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions_1)) - ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addIdentifiers = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier( - "undefined" - ); - } - return paramNode; - } - ); - node.parameters = parameters; - } - if ( - ts.isIdentifier(node) && - dummyIdentifiers.includes(node.text) - ) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("DO_" + classData.serviceName) - ); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].SDKFunctionName - ) - ); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function(childNode) { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - var args = classData.functions[count].params.map(function( - param - ) { - return ts.createIdentifier(param.name); - }); - node.arguments = args.concat(node.arguments); + return __awaiter(this, void 0, void 0, function () { + var addFunctions, addIdentifiers, addComments, node, result_1, result_2, result_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + addFunctions = function (context) { return function (rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function (method) { + var clonedNode = Object.assign({}, node.members[1]); + // console.log("Cloned Node..........\n");//sdadas + // console.log(clonedNode);//asdasdasdasd + clonedNode.name = ts.createIdentifier(method.functionName); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addIdentifiers = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); + if (param.optional) { + paramNode.initializer = ts.createIdentifier("undefined"); + } + return paramNode; + }); + node.parameters = parameters; + } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + var updatedIdentifier = void 0; + switch (node.text) { + case "ClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("DO_" + classData.serviceName)); + break; + case "_sdkClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + + classData.className.charAt(0).toLowerCase() + + classData.className.substr(1))); + break; + case "SDKClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.className.charAt(0).toLowerCase() + + classData.className.substr(1))); + break; + case "SDKFunctionName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function (childNode) { + if (ts.isIdentifier(childNode) && + childNode.text === "SDKFunctionName") { + var args = classData.functions[count].params.map(function (param) { + return ts.createIdentifier(param.name); + }); + node.arguments = args.concat(node.arguments); + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addComments = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment(node, "This is an auto generated class, please do not change."); + var comment = "*\n* Class to create a " + classData.className + " object\n* @category Digital Ocean \n"; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var statment; + if (param.optional) { + if (param.type == "TypeReference") + statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + else + statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + } + else { + if (param.type == "TypeReference") + statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + else + statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ""; + parameters.map(function (param) { + paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n" + param); + }); + comment = "*\n* Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n" + paramStatments_1 + "\n* @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n"; + } + else { + comment = "*\n* Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n* @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n"; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); + if (!classData.className || !classData.functions) { + throw new Error("Input is invalid"); } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addComments = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - var comment = - "*\n* Class to create a " + - classData.className + - " object\n* @category Digital Ocean \n"; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var statment; - if (param.optional) { - if (param.type == "TypeReference") - statment = - "* @param {" + - param.typeName + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - else - statment = - "* @param {" + - param.type + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - } else { - if (param.type == "TypeReference") - statment = - "* @param {" + - param.typeName + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - else - statment = - "* @param {" + - param.type + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - } - return statment; + if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { + throw new Error("Code is invalid"); } - ); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function(param) { - paramStatments_1 = paramStatments_1.concat( - paramStatments_1 === "" ? "" + param : "\n" + param - ); - }); - comment = - "*\n* Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.className + - "\n" + - paramStatments_1 + - "\n* @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n"; - } else { - comment = - "*\n* Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.className + - "\n* @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n"; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - node = code.statements.find(function(stm) { - return ts.isClassDeclaration(stm); - }); - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - if ( - !node || - !node.members.some(function(member) { - return ts.isMethodDeclaration(member); - }) - ) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_1), addIdentifiers) - ]; - case 2: - result_2 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_2), addComments) - ]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } + code = lodash_1.cloneDeep(code); + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; + case 2: + result_2 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); }); - }); } exports.transform = transform; diff --git a/generator/transformers/googleCloud/classBasedTransformer.js b/generator/transformers/googleCloud/classBasedTransformer.js index a92ac78b..f9c776ae 100644 --- a/generator/transformers/googleCloud/classBasedTransformer.js +++ b/generator/transformers/googleCloud/classBasedTransformer.js @@ -1,477 +1,249 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.classBasedTransform = void 0; -var ts = require("typescript"); var lodash_1 = require("lodash"); +var ts = require("typescript"); var dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client", - "_className" + "ClassName", + "SDKFunctionName", + "ClientName", + "_client", + "_clientObj", + "Client", + "_className" ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function(resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise(function (resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); + resolve(output); + } + catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); } function classBasedTransform(code, data) { - return __awaiter(this, void 0, void 0, function() { - var node, - addFunctions, - addIdentifiers, - addComments, - result_1, - result_2, - result_3; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function(stm) { - return ts.isClassDeclaration(stm); - }); - if (!data.functions || !data.classData) { - throw new Error("Input is invalid"); - } - if ( - !node || - !node.members.some(function(member) { - return ts.isMethodDeclaration(member); - }) - ) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - addFunctions = function(context) { - return function(rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - data.functions.map(function(method) { - var clonedNode; - if (method.returnTypeName === "Promise") { - if ( - (method.classConstructorData.parameters[0].type = - "TypeReference" && - !method.classConstructorData.parameters[0].optional) - ) { - clonedNode = Object.assign({}, node.members[3]); - } else { - clonedNode = Object.assign({}, node.members[1]); - } - } else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions_1)) - ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addIdentifiers = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - data.functions[count].allParams = []; - var params = []; - if ( - (data.functions[ - count - ].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData.parameters[0] - .optional) - ) { - params.push( - data.functions[count].classConstructorData.parameters[0] - ); - data.functions[count].allParams.push({ - name: "identifier", - optional: true, - type: "string" - }); - } - params = params.concat(data.functions[count].params); - data.functions[count].allParams = data.functions[ - count - ].allParams.concat(params); - var parameters = params.map(function(param) { - var paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters.concat(node.parameters); - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@google-cloud/" + data.functions[0].pkgName - ); - } - if ( - ts.isIdentifier(node) && - dummyIdentifiers.includes(node.text) - ) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("GCP_" + data.functions[0].pkgName) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.mainClass) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - data.functions[count].SDKFunctionName - ) - ); - count++; - break; - case "_className": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - data.functions[count].client.toLowerCase() - ) - ); - break; - case "_client": - if ( - (data.functions[ - count - ].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData - .parameters[0].optional) - ) { - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - data.functions[count].classConstructorData - .parameters[0].name - ) - ); - } else { - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + data.mainClass.toLowerCase() - ) - ); - } - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("_" + data.mainClass.toLowerCase()) - ); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.mainClass) - ); - break; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function(childNode) { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - var args = data.functions[count].params.map(function( - param - ) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; + return __awaiter(this, void 0, void 0, function () { + var node, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); + if (!data.functions || !data.classData) { + throw new Error("Input is invalid"); } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addComments = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - var comment = - "*\n * Class to create a " + - data.functions[0].pkgName + - " object\n * @category Google Cloud\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = data.functions[count].allParams.map(function( - param - ) { - var statment; - if (param.optional) { - statment = - "* @param {" + - (param.typeRefName ? param.typeRefName : param.type) + - "} [" + - param.name + - "] - Optional parameter"; - } else { - statment = - "* @param {" + - (param.typeRefName ? param.typeRefName : param.type) + - "} " + - param.name + - " - Mandatory parameter"; + if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { + throw new Error("Code is invalid"); } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function(param) { - paramStatments_1 = paramStatments_1.concat( - paramStatments_1 === "" ? "" + param : "\n " + param - ); - }); - comment = - "*\n * Trigers the " + - data.functions[count].SDKFunctionName + - " function of " + - data.functions[0].pkgName + - "\n " + - paramStatments_1 + - "\n * @returns {Promise<" + - data.functions[count].SDKFunctionName + - "Response>}\n "; - } else { - comment = - "*\n * Trigers the " + - data.functions[count].SDKFunctionName + - " function of " + - data.functions[0].pkgName + - "\n * @returns {Promise<" + - data.functions[count].SDKFunctionName + - "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_1), addIdentifiers) - ]; - case 2: - result_2 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_2), addComments) - ]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } + code = lodash_1.cloneDeep(code); + addFunctions = function (context) { return function (rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + data.functions.map(function (method) { + var clonedNode; + if (method.returnTypeName === "Promise") { + if ((method.classConstructorData.parameters[0].type = + "TypeReference" && + !method.classConstructorData.parameters[0].optional)) { + clonedNode = Object.assign({}, node.members[3]); + } + else { + clonedNode = Object.assign({}, node.members[1]); + } + } + else { + clonedNode = Object.assign({}, node.members[2]); + } + clonedNode.name = ts.createIdentifier(method.functionName); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addIdentifiers = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + data.functions[count].allParams = []; + var params = []; + if ((data.functions[count].classConstructorData.parameters[0].type = + "TypeReference" && + !data.functions[count].classConstructorData.parameters[0].optional)) { + params.push(data.functions[count].classConstructorData.parameters[0]); + data.functions[count].allParams.push({ + name: "identifier", + optional: true, + type: "string" + }); + } + params = params.concat(data.functions[count].params); + data.functions[count].allParams = data.functions[count].allParams.concat(params); + var parameters = params.map(function (param) { + var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); + if (param.optional) { + paramNode.initializer = ts.createIdentifier("undefined"); + } + return paramNode; + }); + node.parameters = parameters.concat(node.parameters); + } + if (ts.isStringLiteral(node) && node.text === "pkgName") { + return ts.createStringLiteral("@google-cloud/" + data.functions[0].pkgName); + } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + var updatedIdentifier = void 0; + switch (node.text) { + case "ClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("GCP_" + data.functions[0].pkgName)); + break; + case "ClientName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.mainClass)); + break; + case "SDKFunctionName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].SDKFunctionName)); + count++; + break; + case "_className": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].client.toLowerCase())); + break; + case "_client": + if ((data.functions[count].classConstructorData.parameters[0].type = + "TypeReference" && + !data.functions[count].classConstructorData.parameters[0] + .optional)) { + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].classConstructorData.parameters[0].name)); + } + else { + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + data.mainClass.toLowerCase())); + } + break; + case "_clientObj": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + data.mainClass.toLowerCase())); + break; + case "Client": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.mainClass)); + break; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function (childNode) { + if (ts.isIdentifier(childNode) && + childNode.text === "SDKFunctionName") { + var args = data.functions[count].params.map(function (param) { + return ts.createIdentifier(param.name); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addComments = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment(node, "This is an auto generated class, please do not change."); + var comment = "*\n * Class to create a " + data.functions[0].pkgName + " object\n * @category Google Cloud\n "; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = data.functions[count].allParams.map(function (param) { + var statment; + if (param.optional) { + statment = "* @param {" + (param.typeRefName ? param.typeRefName : param.type) + "} [" + param.name + "] - Optional parameter"; + } + else { + statment = "* @param {" + (param.typeRefName ? param.typeRefName : param.type) + "} " + param.name + " - Mandatory parameter"; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ""; + parameters.map(function (param) { + paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); + }); + comment = "*\n * Trigers the " + data.functions[count].SDKFunctionName + " function of " + data.functions[0].pkgName + "\n " + paramStatments_1 + "\n * @returns {Promise<" + data.functions[count].SDKFunctionName + "Response>}\n "; + } + else { + comment = "*\n * Trigers the " + data.functions[count].SDKFunctionName + " function of " + data.functions[0].pkgName + "\n * @returns {Promise<" + data.functions[count].SDKFunctionName + "Response>}\n "; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; + case 2: + result_2 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); }); - }); } exports.classBasedTransform = classBasedTransform; diff --git a/generator/transformers/googleCloud/clientBasedTransformer.js b/generator/transformers/googleCloud/clientBasedTransformer.js index 509837e6..81956231 100644 --- a/generator/transformers/googleCloud/clientBasedTransformer.js +++ b/generator/transformers/googleCloud/clientBasedTransformer.js @@ -1,468 +1,236 @@ "use strict"; -var __awaiter = - (this && this.__awaiter) || - function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - }; -var __generator = - (this && this.__generator) || - function(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, - f, - y, - t, - g; - return ( - (g = { next: verb(0), throw: verb(1), return: verb(2) }), - typeof Symbol === "function" && - (g[Symbol.iterator] = function() { - return this; - }), - g - ); - function verb(n) { - return function(v) { - return step([n, v]); - }; - } +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) - try { - if ( - ((f = 1), - y && - (t = - op[0] & 2 - ? y["return"] - : op[0] - ? y["throw"] || ((t = y["return"]) && t.call(y), 0) - : y.next) && - !(t = t.call(y, op[1])).done) - ) - return t; - if (((y = 0), t)) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if ( - !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && - (op[0] === 6 || op[0] === 2) - ) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - }; +}; exports.__esModule = true; exports.clientBasedTransform = void 0; -var ts = require("typescript"); var lodash_1 = require("lodash"); +var ts = require("typescript"); var dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client" + "ClassName", + "SDKFunctionName", + "ClientName", + "_client", + "_clientObj", + "Client" ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function(resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise(function (resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); + resolve(output); + } + catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); } function clientBasedTransform(code, classData) { - return __awaiter(this, void 0, void 0, function() { - var node, - importStatments, - classDeclarationNode, - constructorNode, - clientObjects, - addFunctions, - addIdentifiers, - addComments, - result_1, - result_2, - result_3; - return __generator(this, function(_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function(stm) { - return ts.isClassDeclaration(stm); - }); - if (!classData.functions) { - throw new Error("Input is invalid"); - } - if ( - !node || - !node.members.some(function(member) { - return ts.isMethodDeclaration(member); - }) - ) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - // import related - classData.clients = Array.from( - new Set( - classData.functions.map(function(method) { - return method.client; - }) - ) - ); - importStatments = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); - classDeclarationNode = code.statements.find(function(node) { - return ts.isClassDeclaration(node); - }); - constructorNode = classDeclarationNode.members.find(function(node) { - return ts.SyntaxKind[node.kind] === "Constructor"; - }); - clientObjects = new Array(classData.clients.length); - clientObjects.fill( - Object.assign({}, constructorNode.body.statements[0]) - ); - constructorNode.body.statements = clientObjects; - addFunctions = function(context) { - return function(rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function(method) { - var clonedNode; - if (method.returnTypeName === "Promise") { - clonedNode = Object.assign({}, node.members[1]); - } else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions_1)) - ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addIdentifiers = function(context) { - return function(rootNode) { - var count = 0; - var clientCount = 0; - var clientObjCount = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier( - "undefined" - ); - } - return paramNode; - } - ); - node.parameters = parameters; - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@google-cloud/" + classData.functions[0].pkgName - ); - } - if ( - ts.isIdentifier(node) && - dummyIdentifiers.includes(node.text) - ) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("GCP_" + classData.serviceName) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientCount]) - ); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].SDKFunctionName - ) - ); - count++; - break; - case "_client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.functions[count].client - .toLowerCase() - .charAt(0) + - classData.functions[count].client.substr(1) - ) - ); - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.clients[clientObjCount] - .toLowerCase() - .charAt(0) + - classData.clients[clientObjCount].substr(1) - ) - ); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientObjCount]) - ); - clientObjCount++; - break; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function(childNode) { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - var args = classData.functions[count].params.map(function( - param - ) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; + return __awaiter(this, void 0, void 0, function () { + var node, importStatments, classDeclarationNode, constructorNode, clientObjects, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); + if (!classData.functions) { + throw new Error("Input is invalid"); } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - addComments = function(context) { - return function(rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - var comment = - "*\n * Class to create a " + - classData.serviceName + - " object\n * @category Google Cloud\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map( - function(param) { - var statment; - if (param.optional) { - statment = - "* @param {" + - param.type + - "} [" + - param.name + - "] - Data required for " + - classData.functions[count].SDKFunctionName; - } else { - statment = - "* @param {" + - param.type + - "} " + - param.name + - " - Data required for " + - classData.functions[count].SDKFunctionName; - } - return statment; + if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { + throw new Error("Code is invalid"); } - ); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function(param) { - paramStatments_1 = paramStatments_1.concat( - paramStatments_1 === "" ? "" + param : "\n " + param - ); + code = lodash_1.cloneDeep(code); + // import related + classData.clients = Array.from(new Set(classData.functions.map(function (method) { return method.client; }))); + importStatments = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat(code.statements.slice(1)); + classDeclarationNode = code.statements.find(function (node) { + return ts.isClassDeclaration(node); }); - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.functions[0].pkgName.split("-")[1] + - "\n " + - paramStatments_1 + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } else { - comment = - "*\n * Trigers the " + - classData.functions[count].SDKFunctionName + - " function of " + - classData.functions[0].pkgName.split("-")[1] + - "\n * @returns {Promise<" + - classData.functions[count].SDKFunctionName + - "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_1), addIdentifiers) - ]; - case 2: - result_2 = _a.sent(); - return [ - 4 /*yield*/, - runTransformation(toSourceFile(result_2), addComments) - ]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } + constructorNode = classDeclarationNode.members.find(function (node) { return ts.SyntaxKind[node.kind] === "Constructor"; }); + clientObjects = new Array(classData.clients.length); + clientObjects.fill(Object.assign({}, constructorNode.body.statements[0])); + constructorNode.body.statements = clientObjects; + addFunctions = function (context) { return function (rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function (method) { + var clonedNode; + if (method.returnTypeName === "Promise") { + clonedNode = Object.assign({}, node.members[1]); + } + else { + clonedNode = Object.assign({}, node.members[2]); + } + clonedNode.name = ts.createIdentifier(method.functionName); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addIdentifiers = function (context) { return function (rootNode) { + var count = 0; + var clientCount = 0; + var clientObjCount = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); + if (param.optional) { + paramNode.initializer = ts.createIdentifier("undefined"); + } + return paramNode; + }); + node.parameters = parameters; + } + if (ts.isStringLiteral(node) && node.text === "pkgName") { + return ts.createStringLiteral("@google-cloud/" + classData.functions[0].pkgName); + } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + var updatedIdentifier = void 0; + switch (node.text) { + case "ClassName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("GCP_" + classData.serviceName)); + break; + case "ClientName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientCount])); + clientCount++; + break; + case "SDKFunctionName": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); + count++; + break; + case "_client": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + + classData.functions[count].client.toLowerCase().charAt(0) + + classData.functions[count].client.substr(1))); + break; + case "_clientObj": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + + classData.clients[clientObjCount].toLowerCase().charAt(0) + + classData.clients[clientObjCount].substr(1))); + break; + case "Client": + updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientObjCount])); + clientObjCount++; + break; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function (childNode) { + if (ts.isIdentifier(childNode) && + childNode.text === "SDKFunctionName") { + var args = classData.functions[count].params.map(function (param) { + return ts.createIdentifier(param.name); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + addComments = function (context) { return function (rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment(node, "This is an auto generated class, please do not change."); + var comment = "*\n * Class to create a " + classData.serviceName + " object\n * @category Google Cloud\n "; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[count].params.map(function (param) { + var statment; + if (param.optional) { + statment = "* @param {" + param.type + "} [" + param.name + "] - Data required for " + classData.functions[count].SDKFunctionName; + } + else { + statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ""; + parameters.map(function (param) { + paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); + }); + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + else { + comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; + case 2: + result_2 = _a.sent(); + return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); }); - }); } exports.clientBasedTransform = clientBasedTransform; From 674350b5c83ff01a472256adfe919e09b01df0ed Mon Sep 17 00:00:00 2001 From: Partik SIngh Date: Fri, 23 Jun 2023 22:45:56 +0530 Subject: [PATCH 3/4] Changed Data Extractor Signed-off-by: Partik SIngh --- .../AWS/appServices/aws-paaS.js | 572 ++++----- .../artificialinteligence/aws-translation.js | 189 ++- .../AWS/compute/aws-computeInstance.js | 321 +++-- .../AWS/compute/aws-container.js | 156 ++- .../AWS/compute/aws-kubernetes.js | 354 +++--- .../AWS/database/aws-RDBMS.js | 222 ++-- .../AWS/database/aws-noSql.js | 222 ++-- .../AWS/database/aws-noSqlIndexed.js | 321 +++-- .../AWS/management/aws-keyManagement.js | 189 ++- .../AWS/management/aws-monitoring.js | 156 ++- .../AWS/management/aws-notificationService.js | 288 +++-- .../generatedClasses/AWS/network/aws-DNS.js | 156 ++- .../AWS/network/aws-loadBalancer.js | 189 ++- .../generatedClasses/AWS/security/aws-IAM.js | 189 ++- .../AWS/storage/aws-archivalStorage.js | 189 ++- .../AWS/storage/aws-blockStorage.js | 156 ++- .../AWS/storage/aws-storageBucket.js | 187 ++- .../Azure/appServices/azure-paaS.js | 699 ++++++----- .../Azure/compute/azure-computeInstance.js | 339 +++--- .../Azure/compute/azure-container.js | 238 ++-- .../Azure/compute/azure-kubernetes.js | 603 +++++---- .../Azure/database/azure-RDBMS.js | 357 ++++-- .../Azure/database/azure-noSql.js | 337 +++-- .../Azure/management/azure-keyManagement.js | 311 +++-- .../Azure/management/azure-monitoring.js | 296 +++-- .../Azure/network/azure-DNS.js | 249 ++-- .../Azure/network/azure-loadBalancer.js | 307 +++-- .../Azure/storage/azure-blockStorage.js | 284 +++-- .../Azure/storage/azure-storageBucket.js | 198 +-- .../DO/compute/do-computeInstance.js | 139 ++- .../DO/compute/do-kubernetes.js | 251 ++-- .../generatedClasses/DO/database/do-RDBMS.js | 139 ++- .../generatedClasses/DO/database/do-noSql.js | 139 ++- .../DO/management/do-keyManagement.js | 137 ++- .../generatedClasses/DO/network/do-DNS.js | 175 +-- .../DO/network/do-loadBalancer.js | 126 +- .../DO/storage/do-blockStorage.js | 126 +- .../artificialinteligence/gcp-translation.js | 191 +-- .../googleCloud/compute/gcp-kubernetes.js | 331 ++--- .../googleCloud/database/gcp-RDBMS.js | 250 ++-- .../googleCloud/database/gcp-noSql.js | 139 +-- .../management/gcp-keyManagement.js | 195 +-- .../googleCloud/management/gcp-monitoring.js | 211 ++-- .../management/gcp-notificationService.js | 300 ++--- .../googleCloud/network/gcp-DNS.js | 182 +-- .../storage/gcp-archivalStorage.js | 198 +-- .../googleCloud/storage/gcp-storageBucket.js | 198 +-- generator/generators/aws/generator.js | 397 +++--- generator/generators/azure/generator.js | 485 +++++--- generator/generators/azure/generator.ts | 272 ++--- generator/generators/do/generator.js | 393 ++++-- generator/generators/do/generator.ts | 212 ++-- generator/generators/googleCloud/generator.js | 1081 +++++++++++------ generator/generators/googleCloud/generator.ts | 725 +++++------ generator/generators/lib/aws/awsHelper.js | 56 +- generator/generators/lib/aws/awsHelper.ts | 52 +- generator/generators/lib/azure/azureHelper.js | 93 +- generator/generators/lib/azure/azureHelper.ts | 108 +- .../generators/lib/googleCloud/gcpHelper.js | 99 +- .../generators/lib/googleCloud/gcpHelper.ts | 116 +- generator/generators/lib/helper.js | 65 +- generator/generators/lib/helper.ts | 62 +- generator/generators/linode/generator.js | 391 +++--- generator/generators/linode/generator.ts | 8 +- generator/main.js | 50 +- generator/main.ts | 50 +- generator/node-cloud.yml | 83 +- generator/parsers/aws/parser.js | 274 +++-- generator/parsers/azure/parser.js | 276 +++-- generator/parsers/do/parser.js | 275 +++-- generator/parsers/googleCloud/parser.js | 326 +++-- generator/parsers/googleCloud/parser.ts | 98 +- generator/parsers/linode/parser.js | 307 +++-- generator/parsers/linode/parser.ts | 4 +- .../generators/googleCloud/generator.test.ts | 312 ++--- generator/transformers/aws/transformer.js | 620 +++++++--- generator/transformers/aws/transformer.ts | 433 +++---- generator/transformers/azure/transformer.js | 662 +++++++--- generator/transformers/azure/transformer.ts | 435 +++---- generator/transformers/do/transformer.js | 656 +++++++--- generator/transformers/do/transformer.ts | 481 ++++---- .../googleCloud/classBasedTransformer.js | 772 ++++++++---- .../googleCloud/classBasedTransformer.ts | 592 ++++----- .../googleCloud/clientBasedTransformer.js | 742 +++++++---- .../googleCloud/clientBasedTransformer.ts | 493 ++++---- 85 files changed, 14090 insertions(+), 10167 deletions(-) diff --git a/generator/generatedClasses/AWS/appServices/aws-paaS.js b/generator/generatedClasses/AWS/appServices/aws-paaS.js index b1acbd1e..f8e62ded 100644 --- a/generator/generatedClasses/AWS/appServices/aws-paaS.js +++ b/generator/generatedClasses/AWS/appServices/aws-paaS.js @@ -4,287 +4,295 @@ * @category AWS */ class AWS_PaaS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._elasticBeanstalk = new this._AWS.ElasticBeanstalk({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the checkDNSAvailability function of ElasticBeanstalk - * @param {CheckDNSAvailabilityMessage} params - Data required for checkDNSAvailability - * @returns {Promise} - */ - checkDNSAvailability(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.checkDNSAvailability(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the composeEnvironments function of ElasticBeanstalk - * @param {ComposeEnvironmentsMessage} params - Data required for composeEnvironments - * @returns {Promise} - */ - composeEnvironments(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.composeEnvironments(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createApplication function of ElasticBeanstalk - * @param {CreateApplicationMessage} params - Data required for createApplication - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createApplication(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createConfigurationTemplate function of ElasticBeanstalk - * @param {CreateConfigurationTemplateMessage} params - Data required for createConfigurationTemplate - * @returns {Promise} - */ - createConfigTemplate(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createConfigurationTemplate(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createEnvironment function of ElasticBeanstalk - * @param {CreateEnvironmentMessage} params - Data required for createEnvironment - * @returns {Promise} - */ - createEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createEnvironment(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createStorageLocation function of ElasticBeanstalk - * @returns {Promise} - */ - createStorageLocation() { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.createStorageLocation((error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteApplication function of ElasticBeanstalk - * @param {DeleteApplicationMessage} params - Data required for deleteApplication - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.deleteApplication(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteConfigurationTemplate function of ElasticBeanstalk - * @param {DeleteConfigurationTemplateMessage} params - Data required for deleteConfigurationTemplate - * @returns {Promise} - */ - deleteConfigTemplate(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.deleteConfigurationTemplate(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeAccountAttributes function of ElasticBeanstalk - * @returns {Promise} - */ - describeAccountAttributes() { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeAccountAttributes((error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeApplications function of ElasticBeanstalk - * @param {DescribeApplicationsMessage} params - Data required for describeApplications - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeApplications(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeConfigurationSettings function of ElasticBeanstalk - * @param {DescribeConfigurationSettingsMessage} params - Data required for describeConfigurationSettings - * @returns {Promise} - */ - describeConfigSettings(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.describeConfigurationSettings(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listPlatformVersions function of ElasticBeanstalk - * @param {ListPlatformVersionsRequest} params - Data required for listPlatformVersions - * @returns {Promise} - */ - listVersions(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.listPlatformVersions(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the restartAppServer function of ElasticBeanstalk - * @param {RestartAppServerMessage} params - Data required for restartAppServer - * @returns {Promise} - */ - restart(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.restartAppServer(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the terminateEnvironment function of ElasticBeanstalk - * @param {TerminateEnvironmentMessage} params - Data required for terminateEnvironment - * @returns {Promise} - */ - terminateEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.terminateEnvironment(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateApplication function of ElasticBeanstalk - * @param {UpdateApplicationMessage} params - Data required for updateApplication - * @returns {Promise} - */ - update(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.updateApplication(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateEnvironment function of ElasticBeanstalk - * @param {UpdateEnvironmentMessage} params - Data required for updateEnvironment - * @returns {Promise} - */ - updateEnvironment(params) { - return new Promise((resolve, reject) => { - this._elasticBeanstalk.updateEnvironment(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._elasticBeanstalk = new this._AWS.ElasticBeanstalk({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the checkDNSAvailability function of ElasticBeanstalk + * @param {CheckDNSAvailabilityMessage} params - Data required for checkDNSAvailability + * @returns {Promise} + */ + checkDNSAvailability(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.checkDNSAvailability( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the composeEnvironments function of ElasticBeanstalk + * @param {ComposeEnvironmentsMessage} params - Data required for composeEnvironments + * @returns {Promise} + */ + composeEnvironments(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.composeEnvironments( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the createApplication function of ElasticBeanstalk + * @param {CreateApplicationMessage} params - Data required for createApplication + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createApplication(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createConfigurationTemplate function of ElasticBeanstalk + * @param {CreateConfigurationTemplateMessage} params - Data required for createConfigurationTemplate + * @returns {Promise} + */ + createConfigTemplate(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createConfigurationTemplate( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the createEnvironment function of ElasticBeanstalk + * @param {CreateEnvironmentMessage} params - Data required for createEnvironment + * @returns {Promise} + */ + createEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createEnvironment(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createStorageLocation function of ElasticBeanstalk + * @returns {Promise} + */ + createStorageLocation() { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.createStorageLocation((error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteApplication function of ElasticBeanstalk + * @param {DeleteApplicationMessage} params - Data required for deleteApplication + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.deleteApplication(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteConfigurationTemplate function of ElasticBeanstalk + * @param {DeleteConfigurationTemplateMessage} params - Data required for deleteConfigurationTemplate + * @returns {Promise} + */ + deleteConfigTemplate(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.deleteConfigurationTemplate( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the describeAccountAttributes function of ElasticBeanstalk + * @returns {Promise} + */ + describeAccountAttributes() { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeAccountAttributes((error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeApplications function of ElasticBeanstalk + * @param {DescribeApplicationsMessage} params - Data required for describeApplications + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeApplications( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the describeConfigurationSettings function of ElasticBeanstalk + * @param {DescribeConfigurationSettingsMessage} params - Data required for describeConfigurationSettings + * @returns {Promise} + */ + describeConfigSettings(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.describeConfigurationSettings( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the listPlatformVersions function of ElasticBeanstalk + * @param {ListPlatformVersionsRequest} params - Data required for listPlatformVersions + * @returns {Promise} + */ + listVersions(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.listPlatformVersions( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the restartAppServer function of ElasticBeanstalk + * @param {RestartAppServerMessage} params - Data required for restartAppServer + * @returns {Promise} + */ + restart(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.restartAppServer(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the terminateEnvironment function of ElasticBeanstalk + * @param {TerminateEnvironmentMessage} params - Data required for terminateEnvironment + * @returns {Promise} + */ + terminateEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.terminateEnvironment( + params, + (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + } + ); + }); + } + /** + * Trigers the updateApplication function of ElasticBeanstalk + * @param {UpdateApplicationMessage} params - Data required for updateApplication + * @returns {Promise} + */ + update(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.updateApplication(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateEnvironment function of ElasticBeanstalk + * @param {UpdateEnvironmentMessage} params - Data required for updateEnvironment + * @returns {Promise} + */ + updateEnvironment(params) { + return new Promise((resolve, reject) => { + this._elasticBeanstalk.updateEnvironment(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_PaaS; diff --git a/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js b/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js index 0c4caf7b..c89ce192 100644 --- a/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js +++ b/generator/generatedClasses/AWS/artificialinteligence/aws-translation.js @@ -4,102 +4,97 @@ * @category AWS */ class AWS_Translation { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._translate = new this._AWS.Translate({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the deleteTerminology function of Translate - * @param {DeleteTerminologyRequest} params - Data required for deleteTerminology - * @returns {Promise} - */ - deleteGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.deleteTerminology(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getTerminology function of Translate - * @param {GetTerminologyRequest} params - Data required for getTerminology - * @returns {Promise} - */ - getGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.getTerminology(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the importTerminology function of Translate - * @param {ImportTerminologyRequest} params - Data required for importTerminology - * @returns {Promise} - */ - createGlossary(params) { - return new Promise((resolve, reject) => { - this._translate.importTerminology(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the startTextTranslationJob function of Translate - * @param {StartTextTranslationJobRequest} params - Data required for startTextTranslationJob - * @returns {Promise} - */ - batchTranslate(params) { - return new Promise((resolve, reject) => { - this._translate.startTextTranslationJob(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the translateText function of Translate - * @param {TranslateTextRequest} params - Data required for translateText - * @returns {Promise} - */ - translate(params) { - return new Promise((resolve, reject) => { - this._translate.translateText(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._translate = new this._AWS.Translate({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the deleteTerminology function of Translate + * @param {DeleteTerminologyRequest} params - Data required for deleteTerminology + * @returns {Promise} + */ + deleteGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.deleteTerminology(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getTerminology function of Translate + * @param {GetTerminologyRequest} params - Data required for getTerminology + * @returns {Promise} + */ + getGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.getTerminology(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the importTerminology function of Translate + * @param {ImportTerminologyRequest} params - Data required for importTerminology + * @returns {Promise} + */ + createGlossary(params) { + return new Promise((resolve, reject) => { + this._translate.importTerminology(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the startTextTranslationJob function of Translate + * @param {StartTextTranslationJobRequest} params - Data required for startTextTranslationJob + * @returns {Promise} + */ + batchTranslate(params) { + return new Promise((resolve, reject) => { + this._translate.startTextTranslationJob(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the translateText function of Translate + * @param {TranslateTextRequest} params - Data required for translateText + * @returns {Promise} + */ + translate(params) { + return new Promise((resolve, reject) => { + this._translate.translateText(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Translation; diff --git a/generator/generatedClasses/AWS/compute/aws-computeInstance.js b/generator/generatedClasses/AWS/compute/aws-computeInstance.js index 569ca6fe..7ac04a34 100644 --- a/generator/generatedClasses/AWS/compute/aws-computeInstance.js +++ b/generator/generatedClasses/AWS/compute/aws-computeInstance.js @@ -4,170 +4,161 @@ * @category AWS */ class AWS_ComputeInstance { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eC2 = new this._AWS.EC2({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTags function of EC2 - * @param {CreateTagsRequest} params - Data required for createTags - * @returns {Promise} - */ - addTags(params) { - return new Promise((resolve, reject) => { - this._eC2.createTags(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeInstances function of EC2 - * @param {DescribeInstancesRequest} params - Data required for describeInstances - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eC2.describeInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the monitorInstances function of EC2 - * @param {MonitorInstancesRequest} params - Data required for monitorInstances - * @returns {Promise} - */ - monitor(params) { - return new Promise((resolve, reject) => { - this._eC2.monitorInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the rebootInstances function of EC2 - * @param {RebootInstancesRequest} params - Data required for rebootInstances - * @returns {Promise} - */ - reboot(params) { - return new Promise((resolve, reject) => { - this._eC2.rebootInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the runInstances function of EC2 - * @param {RunInstancesRequest} params - Data required for runInstances - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eC2.runInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the startInstances function of EC2 - * @param {StartInstancesRequest} params - Data required for startInstances - * @returns {Promise} - */ - start(params) { - return new Promise((resolve, reject) => { - this._eC2.startInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the stopInstances function of EC2 - * @param {StopInstancesRequest} params - Data required for stopInstances - * @returns {Promise} - */ - stop(params) { - return new Promise((resolve, reject) => { - this._eC2.stopInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the terminateInstances function of EC2 - * @param {TerminateInstancesRequest} params - Data required for terminateInstances - * @returns {Promise} - */ - destroy(params) { - return new Promise((resolve, reject) => { - this._eC2.terminateInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the unmonitorInstances function of EC2 - * @param {UnmonitorInstancesRequest} params - Data required for unmonitorInstances - * @returns {Promise} - */ - unmonitor(params) { - return new Promise((resolve, reject) => { - this._eC2.unmonitorInstances(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eC2 = new this._AWS.EC2({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createTags function of EC2 + * @param {CreateTagsRequest} params - Data required for createTags + * @returns {Promise} + */ + addTags(params) { + return new Promise((resolve, reject) => { + this._eC2.createTags(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeInstances function of EC2 + * @param {DescribeInstancesRequest} params - Data required for describeInstances + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eC2.describeInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the monitorInstances function of EC2 + * @param {MonitorInstancesRequest} params - Data required for monitorInstances + * @returns {Promise} + */ + monitor(params) { + return new Promise((resolve, reject) => { + this._eC2.monitorInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the rebootInstances function of EC2 + * @param {RebootInstancesRequest} params - Data required for rebootInstances + * @returns {Promise} + */ + reboot(params) { + return new Promise((resolve, reject) => { + this._eC2.rebootInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the runInstances function of EC2 + * @param {RunInstancesRequest} params - Data required for runInstances + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eC2.runInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the startInstances function of EC2 + * @param {StartInstancesRequest} params - Data required for startInstances + * @returns {Promise} + */ + start(params) { + return new Promise((resolve, reject) => { + this._eC2.startInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the stopInstances function of EC2 + * @param {StopInstancesRequest} params - Data required for stopInstances + * @returns {Promise} + */ + stop(params) { + return new Promise((resolve, reject) => { + this._eC2.stopInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the terminateInstances function of EC2 + * @param {TerminateInstancesRequest} params - Data required for terminateInstances + * @returns {Promise} + */ + destroy(params) { + return new Promise((resolve, reject) => { + this._eC2.terminateInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the unmonitorInstances function of EC2 + * @param {UnmonitorInstancesRequest} params - Data required for unmonitorInstances + * @returns {Promise} + */ + unmonitor(params) { + return new Promise((resolve, reject) => { + this._eC2.unmonitorInstances(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_ComputeInstance; diff --git a/generator/generatedClasses/AWS/compute/aws-container.js b/generator/generatedClasses/AWS/compute/aws-container.js index 1b5ec5a5..44da8f96 100644 --- a/generator/generatedClasses/AWS/compute/aws-container.js +++ b/generator/generatedClasses/AWS/compute/aws-container.js @@ -4,85 +4,81 @@ * @category AWS */ class AWS_Container { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eCS = new this._AWS.ECS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createCluster function of ECS - * @param {CreateClusterRequest} params - Data required for createCluster - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eCS.createCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCluster function of ECS - * @param {DeleteClusterRequest} params - Data required for deleteCluster - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eCS.deleteCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeClusters function of ECS - * @param {DescribeClustersRequest} params - Data required for describeClusters - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eCS.describeClusters(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listClusters function of ECS - * @param {ListClustersRequest} params - Data required for listClusters - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eCS.listClusters(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eCS = new this._AWS.ECS({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createCluster function of ECS + * @param {CreateClusterRequest} params - Data required for createCluster + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eCS.createCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCluster function of ECS + * @param {DeleteClusterRequest} params - Data required for deleteCluster + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eCS.deleteCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeClusters function of ECS + * @param {DescribeClustersRequest} params - Data required for describeClusters + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eCS.describeClusters(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listClusters function of ECS + * @param {ListClustersRequest} params - Data required for listClusters + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eCS.listClusters(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Container; diff --git a/generator/generatedClasses/AWS/compute/aws-kubernetes.js b/generator/generatedClasses/AWS/compute/aws-kubernetes.js index bf31ba19..6381ac0f 100644 --- a/generator/generatedClasses/AWS/compute/aws-kubernetes.js +++ b/generator/generatedClasses/AWS/compute/aws-kubernetes.js @@ -4,187 +4,177 @@ * @category AWS */ class AWS_Kubernetes { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eKS = new this._AWS.EKS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createCluster function of EKS - * @param {CreateClusterRequest} params - Data required for createCluster - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eKS.createCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createNodegroup function of EKS - * @param {CreateNodegroupRequest} params - Data required for createNodegroup - * @returns {Promise} - */ - createNodeGroup(params) { - return new Promise((resolve, reject) => { - this._eKS.createNodegroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCluster function of EKS - * @param {DeleteClusterRequest} params - Data required for deleteCluster - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eKS.deleteCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteNodegroup function of EKS - * @param {DeleteNodegroupRequest} params - Data required for deleteNodegroup - * @returns {Promise} - */ - deleteNodegroup(params) { - return new Promise((resolve, reject) => { - this._eKS.deleteNodegroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeCluster function of EKS - * @param {DescribeClusterRequest} params - Data required for describeCluster - * @returns {Promise} - */ - describeCluster(params) { - return new Promise((resolve, reject) => { - this._eKS.describeCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeNodegroup function of EKS - * @param {DescribeNodegroupRequest} params - Data required for describeNodegroup - * @returns {Promise} - */ - describeNodeGroup(params) { - return new Promise((resolve, reject) => { - this._eKS.describeNodegroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listClusters function of EKS - * @param {ListClustersRequest} params - Data required for listClusters - * @returns {Promise} - */ - listClusters(params) { - return new Promise((resolve, reject) => { - this._eKS.listClusters(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listNodegroups function of EKS - * @param {ListNodegroupsRequest} params - Data required for listNodegroups - * @returns {Promise} - */ - listNodegroups(params) { - return new Promise((resolve, reject) => { - this._eKS.listNodegroups(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the tagResource function of EKS - * @param {TagResourceRequest} params - Data required for tagResource - * @returns {Promise} - */ - updateTags(params) { - return new Promise((resolve, reject) => { - this._eKS.tagResource(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateClusterConfig function of EKS - * @param {UpdateClusterConfigRequest} params - Data required for updateClusterConfig - * @returns {Promise} - */ - updateConfig(params) { - return new Promise((resolve, reject) => { - this._eKS.updateClusterConfig(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eKS = new this._AWS.EKS({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createCluster function of EKS + * @param {CreateClusterRequest} params - Data required for createCluster + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eKS.createCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createNodegroup function of EKS + * @param {CreateNodegroupRequest} params - Data required for createNodegroup + * @returns {Promise} + */ + createNodeGroup(params) { + return new Promise((resolve, reject) => { + this._eKS.createNodegroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCluster function of EKS + * @param {DeleteClusterRequest} params - Data required for deleteCluster + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eKS.deleteCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteNodegroup function of EKS + * @param {DeleteNodegroupRequest} params - Data required for deleteNodegroup + * @returns {Promise} + */ + deleteNodegroup(params) { + return new Promise((resolve, reject) => { + this._eKS.deleteNodegroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeCluster function of EKS + * @param {DescribeClusterRequest} params - Data required for describeCluster + * @returns {Promise} + */ + describeCluster(params) { + return new Promise((resolve, reject) => { + this._eKS.describeCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeNodegroup function of EKS + * @param {DescribeNodegroupRequest} params - Data required for describeNodegroup + * @returns {Promise} + */ + describeNodeGroup(params) { + return new Promise((resolve, reject) => { + this._eKS.describeNodegroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listClusters function of EKS + * @param {ListClustersRequest} params - Data required for listClusters + * @returns {Promise} + */ + listClusters(params) { + return new Promise((resolve, reject) => { + this._eKS.listClusters(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listNodegroups function of EKS + * @param {ListNodegroupsRequest} params - Data required for listNodegroups + * @returns {Promise} + */ + listNodegroups(params) { + return new Promise((resolve, reject) => { + this._eKS.listNodegroups(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the tagResource function of EKS + * @param {TagResourceRequest} params - Data required for tagResource + * @returns {Promise} + */ + updateTags(params) { + return new Promise((resolve, reject) => { + this._eKS.tagResource(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateClusterConfig function of EKS + * @param {UpdateClusterConfigRequest} params - Data required for updateClusterConfig + * @returns {Promise} + */ + updateConfig(params) { + return new Promise((resolve, reject) => { + this._eKS.updateClusterConfig(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Kubernetes; diff --git a/generator/generatedClasses/AWS/database/aws-RDBMS.js b/generator/generatedClasses/AWS/database/aws-RDBMS.js index 7983b58e..b53f2bcb 100644 --- a/generator/generatedClasses/AWS/database/aws-RDBMS.js +++ b/generator/generatedClasses/AWS/database/aws-RDBMS.js @@ -4,119 +4,113 @@ * @category AWS */ class AWS_RDBMS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._rDS = new this._AWS.RDS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createDBCluster function of RDS - * @param {CreateDBClusterMessage} params - Data required for createDBCluster - * @returns {Promise} - */ - createDatabse(params) { - return new Promise((resolve, reject) => { - this._rDS.createDBCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createDBSnapshot function of RDS - * @param {CreateDBSnapshotMessage} params - Data required for createDBSnapshot - * @returns {Promise} - */ - createSnapshots(params) { - return new Promise((resolve, reject) => { - this._rDS.createDBSnapshot(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDBCluster function of RDS - * @param {DeleteDBClusterMessage} params - Data required for deleteDBCluster - * @returns {Promise} - */ - deleteDatabase(params) { - return new Promise((resolve, reject) => { - this._rDS.deleteDBCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDBSnapshot function of RDS - * @param {DeleteDBSnapshotMessage} params - Data required for deleteDBSnapshot - * @returns {Promise} - */ - deleteDBSnapshot(params) { - return new Promise((resolve, reject) => { - this._rDS.deleteDBSnapshot(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the modifyDBCluster function of RDS - * @param {ModifyDBClusterMessage} params - Data required for modifyDBCluster - * @returns {Promise} - */ - modifyDB(params) { - return new Promise((resolve, reject) => { - this._rDS.modifyDBCluster(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the rebootDBInstance function of RDS - * @param {RebootDBInstanceMessage} params - Data required for rebootDBInstance - * @returns {Promise} - */ - restoreDatabase(params) { - return new Promise((resolve, reject) => { - this._rDS.rebootDBInstance(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._rDS = new this._AWS.RDS({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createDBCluster function of RDS + * @param {CreateDBClusterMessage} params - Data required for createDBCluster + * @returns {Promise} + */ + createDatabse(params) { + return new Promise((resolve, reject) => { + this._rDS.createDBCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createDBSnapshot function of RDS + * @param {CreateDBSnapshotMessage} params - Data required for createDBSnapshot + * @returns {Promise} + */ + createSnapshots(params) { + return new Promise((resolve, reject) => { + this._rDS.createDBSnapshot(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDBCluster function of RDS + * @param {DeleteDBClusterMessage} params - Data required for deleteDBCluster + * @returns {Promise} + */ + deleteDatabase(params) { + return new Promise((resolve, reject) => { + this._rDS.deleteDBCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDBSnapshot function of RDS + * @param {DeleteDBSnapshotMessage} params - Data required for deleteDBSnapshot + * @returns {Promise} + */ + deleteDBSnapshot(params) { + return new Promise((resolve, reject) => { + this._rDS.deleteDBSnapshot(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the modifyDBCluster function of RDS + * @param {ModifyDBClusterMessage} params - Data required for modifyDBCluster + * @returns {Promise} + */ + modifyDB(params) { + return new Promise((resolve, reject) => { + this._rDS.modifyDBCluster(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the rebootDBInstance function of RDS + * @param {RebootDBInstanceMessage} params - Data required for rebootDBInstance + * @returns {Promise} + */ + restoreDatabase(params) { + return new Promise((resolve, reject) => { + this._rDS.rebootDBInstance(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_RDBMS; diff --git a/generator/generatedClasses/AWS/database/aws-noSql.js b/generator/generatedClasses/AWS/database/aws-noSql.js index 3af86a16..3eebfbbd 100644 --- a/generator/generatedClasses/AWS/database/aws-noSql.js +++ b/generator/generatedClasses/AWS/database/aws-noSql.js @@ -4,119 +4,113 @@ * @category AWS */ class AWS_NoSql { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._dynamoDB = new this._AWS.DynamoDB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTable function of DynamoDB - * @param {CreateTableInput} params - Data required for createTable - * @returns {Promise} - */ - createTable(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.createTable(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteItem function of DynamoDB - * @param {DeleteItemInput} params - Data required for deleteItem - * @returns {Promise} - */ - deleteItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.deleteItem(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteTable function of DynamoDB - * @param {DeleteTableInput} params - Data required for deleteTable - * @returns {Promise} - */ - deleteTable(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.deleteTable(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putItem function of DynamoDB - * @param {PutItemInput} params - Data required for putItem - * @returns {Promise} - */ - createItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.putItem(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the query function of DynamoDB - * @param {QueryInput} params - Data required for query - * @returns {Promise} - */ - query(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.query(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateItem function of DynamoDB - * @param {UpdateItemInput} params - Data required for updateItem - * @returns {Promise} - */ - updateItem(params) { - return new Promise((resolve, reject) => { - this._dynamoDB.updateItem(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._dynamoDB = new this._AWS.DynamoDB({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createTable function of DynamoDB + * @param {CreateTableInput} params - Data required for createTable + * @returns {Promise} + */ + createTable(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.createTable(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteItem function of DynamoDB + * @param {DeleteItemInput} params - Data required for deleteItem + * @returns {Promise} + */ + deleteItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.deleteItem(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteTable function of DynamoDB + * @param {DeleteTableInput} params - Data required for deleteTable + * @returns {Promise} + */ + deleteTable(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.deleteTable(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putItem function of DynamoDB + * @param {PutItemInput} params - Data required for putItem + * @returns {Promise} + */ + createItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.putItem(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the query function of DynamoDB + * @param {QueryInput} params - Data required for query + * @returns {Promise} + */ + query(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.query(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateItem function of DynamoDB + * @param {UpdateItemInput} params - Data required for updateItem + * @returns {Promise} + */ + updateItem(params) { + return new Promise((resolve, reject) => { + this._dynamoDB.updateItem(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NoSql; diff --git a/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js b/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js index d55afca0..82128eef 100644 --- a/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js +++ b/generator/generatedClasses/AWS/database/aws-noSqlIndexed.js @@ -4,170 +4,161 @@ * @category AWS */ class AWS_NoSqlIndexed { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._simpleDB = new this._AWS.SimpleDB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the batchDeleteAttributes function of SimpleDB - * @param {BatchDeleteAttributesRequest} params - Data required for batchDeleteAttributes - * @returns {Promise} - */ - batchDelete(params) { - return new Promise((resolve, reject) => { - this._simpleDB.batchDeleteAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the batchPutAttributes function of SimpleDB - * @param {BatchPutAttributesRequest} params - Data required for batchPutAttributes - * @returns {Promise} - */ - batchWrite(params) { - return new Promise((resolve, reject) => { - this._simpleDB.batchPutAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createDomain function of SimpleDB - * @param {CreateDomainRequest} params - Data required for createDomain - * @returns {Promise} - */ - createCollection(params) { - return new Promise((resolve, reject) => { - this._simpleDB.createDomain(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteAttributes function of SimpleDB - * @param {DeleteAttributesRequest} params - Data required for deleteAttributes - * @returns {Promise} - */ - deleteAttribute(params) { - return new Promise((resolve, reject) => { - this._simpleDB.deleteAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteDomain function of SimpleDB - * @param {DeleteDomainRequest} params - Data required for deleteDomain - * @returns {Promise} - */ - deleteCollection(params) { - return new Promise((resolve, reject) => { - this._simpleDB.deleteDomain(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getAttributes function of SimpleDB - * @param {GetAttributesRequest} params - Data required for getAttributes - * @returns {Promise} - */ - getAttributes(params) { - return new Promise((resolve, reject) => { - this._simpleDB.getAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listDomains function of SimpleDB - * @param {ListDomainsRequest} params - Data required for listDomains - * @returns {Promise} - */ - listCollections(params) { - return new Promise((resolve, reject) => { - this._simpleDB.listDomains(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putAttributes function of SimpleDB - * @param {PutAttributesRequest} params - Data required for putAttributes - * @returns {Promise} - */ - setAttribute(params) { - return new Promise((resolve, reject) => { - this._simpleDB.putAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the select function of SimpleDB - * @param {SelectRequest} params - Data required for select - * @returns {Promise} - */ - query(params) { - return new Promise((resolve, reject) => { - this._simpleDB.select(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._simpleDB = new this._AWS.SimpleDB({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the batchDeleteAttributes function of SimpleDB + * @param {BatchDeleteAttributesRequest} params - Data required for batchDeleteAttributes + * @returns {Promise} + */ + batchDelete(params) { + return new Promise((resolve, reject) => { + this._simpleDB.batchDeleteAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the batchPutAttributes function of SimpleDB + * @param {BatchPutAttributesRequest} params - Data required for batchPutAttributes + * @returns {Promise} + */ + batchWrite(params) { + return new Promise((resolve, reject) => { + this._simpleDB.batchPutAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createDomain function of SimpleDB + * @param {CreateDomainRequest} params - Data required for createDomain + * @returns {Promise} + */ + createCollection(params) { + return new Promise((resolve, reject) => { + this._simpleDB.createDomain(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteAttributes function of SimpleDB + * @param {DeleteAttributesRequest} params - Data required for deleteAttributes + * @returns {Promise} + */ + deleteAttribute(params) { + return new Promise((resolve, reject) => { + this._simpleDB.deleteAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteDomain function of SimpleDB + * @param {DeleteDomainRequest} params - Data required for deleteDomain + * @returns {Promise} + */ + deleteCollection(params) { + return new Promise((resolve, reject) => { + this._simpleDB.deleteDomain(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getAttributes function of SimpleDB + * @param {GetAttributesRequest} params - Data required for getAttributes + * @returns {Promise} + */ + getAttributes(params) { + return new Promise((resolve, reject) => { + this._simpleDB.getAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listDomains function of SimpleDB + * @param {ListDomainsRequest} params - Data required for listDomains + * @returns {Promise} + */ + listCollections(params) { + return new Promise((resolve, reject) => { + this._simpleDB.listDomains(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putAttributes function of SimpleDB + * @param {PutAttributesRequest} params - Data required for putAttributes + * @returns {Promise} + */ + setAttribute(params) { + return new Promise((resolve, reject) => { + this._simpleDB.putAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the select function of SimpleDB + * @param {SelectRequest} params - Data required for select + * @returns {Promise} + */ + query(params) { + return new Promise((resolve, reject) => { + this._simpleDB.select(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NoSqlIndexed; diff --git a/generator/generatedClasses/AWS/management/aws-keyManagement.js b/generator/generatedClasses/AWS/management/aws-keyManagement.js index 225039c8..c311e123 100644 --- a/generator/generatedClasses/AWS/management/aws-keyManagement.js +++ b/generator/generatedClasses/AWS/management/aws-keyManagement.js @@ -4,102 +4,97 @@ * @category AWS */ class AWS_KeyManagement { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._kMS = new this._AWS.KMS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createKey function of KMS - * @param {CreateKeyRequest} params - Data required for createKey - * @returns {Promise} - */ - createKey(params) { - return new Promise((resolve, reject) => { - this._kMS.createKey(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteCustomKeyStore function of KMS - * @param {DeleteCustomKeyStoreRequest} params - Data required for deleteCustomKeyStore - * @returns {Promise} - */ - deleteKey(params) { - return new Promise((resolve, reject) => { - this._kMS.deleteCustomKeyStore(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeKey function of KMS - * @param {DescribeKeyRequest} params - Data required for describeKey - * @returns {Promise} - */ - describeKey(params) { - return new Promise((resolve, reject) => { - this._kMS.describeKey(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putKeyPolicy function of KMS - * @param {PutKeyPolicyRequest} params - Data required for putKeyPolicy - * @returns {Promise} - */ - putKeyPolicy(params) { - return new Promise((resolve, reject) => { - this._kMS.putKeyPolicy(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the updateKeyDescription function of KMS - * @param {UpdateKeyDescriptionRequest} params - Data required for updateKeyDescription - * @returns {Promise} - */ - update(params) { - return new Promise((resolve, reject) => { - this._kMS.updateKeyDescription(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._kMS = new this._AWS.KMS({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createKey function of KMS + * @param {CreateKeyRequest} params - Data required for createKey + * @returns {Promise} + */ + createKey(params) { + return new Promise((resolve, reject) => { + this._kMS.createKey(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteCustomKeyStore function of KMS + * @param {DeleteCustomKeyStoreRequest} params - Data required for deleteCustomKeyStore + * @returns {Promise} + */ + deleteKey(params) { + return new Promise((resolve, reject) => { + this._kMS.deleteCustomKeyStore(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeKey function of KMS + * @param {DescribeKeyRequest} params - Data required for describeKey + * @returns {Promise} + */ + describeKey(params) { + return new Promise((resolve, reject) => { + this._kMS.describeKey(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putKeyPolicy function of KMS + * @param {PutKeyPolicyRequest} params - Data required for putKeyPolicy + * @returns {Promise} + */ + putKeyPolicy(params) { + return new Promise((resolve, reject) => { + this._kMS.putKeyPolicy(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the updateKeyDescription function of KMS + * @param {UpdateKeyDescriptionRequest} params - Data required for updateKeyDescription + * @returns {Promise} + */ + update(params) { + return new Promise((resolve, reject) => { + this._kMS.updateKeyDescription(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_KeyManagement; diff --git a/generator/generatedClasses/AWS/management/aws-monitoring.js b/generator/generatedClasses/AWS/management/aws-monitoring.js index aa89282a..24c83246 100644 --- a/generator/generatedClasses/AWS/management/aws-monitoring.js +++ b/generator/generatedClasses/AWS/management/aws-monitoring.js @@ -4,85 +4,81 @@ * @category AWS */ class AWS_Monitoring { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._cloudWatch = new this._AWS.CloudWatch({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the deleteAlarms function of CloudWatch - * @param {DeleteAlarmsInput} params - Data required for deleteAlarms - * @returns {Promise} - */ - deleteAlarm(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.deleteAlarms(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getMetricData function of CloudWatch - * @param {GetMetricDataInput} params - Data required for getMetricData - * @returns {Promise} - */ - getMetricData(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.getMetricData(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listMetrics function of CloudWatch - * @param {ListMetricsInput} params - Data required for listMetrics - * @returns {Promise} - */ - listAlarms(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.listMetrics(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the putMetricAlarm function of CloudWatch - * @param {PutMetricAlarmInput} params - Data required for putMetricAlarm - * @returns {Promise} - */ - updateAlarm(params) { - return new Promise((resolve, reject) => { - this._cloudWatch.putMetricAlarm(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._cloudWatch = new this._AWS.CloudWatch({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the deleteAlarms function of CloudWatch + * @param {DeleteAlarmsInput} params - Data required for deleteAlarms + * @returns {Promise} + */ + deleteAlarm(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.deleteAlarms(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getMetricData function of CloudWatch + * @param {GetMetricDataInput} params - Data required for getMetricData + * @returns {Promise} + */ + getMetricData(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.getMetricData(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listMetrics function of CloudWatch + * @param {ListMetricsInput} params - Data required for listMetrics + * @returns {Promise} + */ + listAlarms(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.listMetrics(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the putMetricAlarm function of CloudWatch + * @param {PutMetricAlarmInput} params - Data required for putMetricAlarm + * @returns {Promise} + */ + updateAlarm(params) { + return new Promise((resolve, reject) => { + this._cloudWatch.putMetricAlarm(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_Monitoring; diff --git a/generator/generatedClasses/AWS/management/aws-notificationService.js b/generator/generatedClasses/AWS/management/aws-notificationService.js index fb80c822..50efb35e 100644 --- a/generator/generatedClasses/AWS/management/aws-notificationService.js +++ b/generator/generatedClasses/AWS/management/aws-notificationService.js @@ -4,153 +4,145 @@ * @category AWS */ class AWS_NotificationService { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._sNS = new this._AWS.SNS({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createTopic function of SNS - * @param {CreateTopicInput} params - Data required for createTopic - * @returns {Promise} - */ - createTopic(params) { - return new Promise((resolve, reject) => { - this._sNS.createTopic(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteTopic function of SNS - * @param {DeleteTopicInput} params - Data required for deleteTopic - * @returns {Promise} - */ - deleteTopic(params) { - return new Promise((resolve, reject) => { - this._sNS.deleteTopic(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getTopicAttributes function of SNS - * @param {GetTopicAttributesInput} params - Data required for getTopicAttributes - * @returns {Promise} - */ - getTopicAttributes(params) { - return new Promise((resolve, reject) => { - this._sNS.getTopicAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listSubscriptions function of SNS - * @param {ListSubscriptionsInput} params - Data required for listSubscriptions - * @returns {Promise} - */ - listSubscriptions(params) { - return new Promise((resolve, reject) => { - this._sNS.listSubscriptions(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listTopics function of SNS - * @param {ListTopicsInput} params - Data required for listTopics - * @returns {Promise} - */ - listTopics(params) { - return new Promise((resolve, reject) => { - this._sNS.listTopics(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the publish function of SNS - * @param {PublishInput} params - Data required for publish - * @returns {Promise} - */ - publish(params) { - return new Promise((resolve, reject) => { - this._sNS.publish(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the subscribe function of SNS - * @param {SubscribeInput} params - Data required for subscribe - * @returns {Promise} - */ - subscribe(params) { - return new Promise((resolve, reject) => { - this._sNS.subscribe(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the unsubscribe function of SNS - * @param {UnsubscribeInput} params - Data required for unsubscribe - * @returns {Promise} - */ - unsubscribe(params) { - return new Promise((resolve, reject) => { - this._sNS.unsubscribe(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._sNS = new this._AWS.SNS({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createTopic function of SNS + * @param {CreateTopicInput} params - Data required for createTopic + * @returns {Promise} + */ + createTopic(params) { + return new Promise((resolve, reject) => { + this._sNS.createTopic(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteTopic function of SNS + * @param {DeleteTopicInput} params - Data required for deleteTopic + * @returns {Promise} + */ + deleteTopic(params) { + return new Promise((resolve, reject) => { + this._sNS.deleteTopic(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getTopicAttributes function of SNS + * @param {GetTopicAttributesInput} params - Data required for getTopicAttributes + * @returns {Promise} + */ + getTopicAttributes(params) { + return new Promise((resolve, reject) => { + this._sNS.getTopicAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listSubscriptions function of SNS + * @param {ListSubscriptionsInput} params - Data required for listSubscriptions + * @returns {Promise} + */ + listSubscriptions(params) { + return new Promise((resolve, reject) => { + this._sNS.listSubscriptions(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listTopics function of SNS + * @param {ListTopicsInput} params - Data required for listTopics + * @returns {Promise} + */ + listTopics(params) { + return new Promise((resolve, reject) => { + this._sNS.listTopics(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the publish function of SNS + * @param {PublishInput} params - Data required for publish + * @returns {Promise} + */ + publish(params) { + return new Promise((resolve, reject) => { + this._sNS.publish(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the subscribe function of SNS + * @param {SubscribeInput} params - Data required for subscribe + * @returns {Promise} + */ + subscribe(params) { + return new Promise((resolve, reject) => { + this._sNS.subscribe(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the unsubscribe function of SNS + * @param {UnsubscribeInput} params - Data required for unsubscribe + * @returns {Promise} + */ + unsubscribe(params) { + return new Promise((resolve, reject) => { + this._sNS.unsubscribe(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_NotificationService; diff --git a/generator/generatedClasses/AWS/network/aws-DNS.js b/generator/generatedClasses/AWS/network/aws-DNS.js index 2a9330da..7a62602f 100644 --- a/generator/generatedClasses/AWS/network/aws-DNS.js +++ b/generator/generatedClasses/AWS/network/aws-DNS.js @@ -4,85 +4,81 @@ * @category AWS */ class AWS_DNS { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._route53 = new this._AWS.Route53({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the changeResourceRecordSets function of Route53 - * @param {ChangeResourceRecordSetsRequest} params - Data required for changeResourceRecordSets - * @returns {Promise} - */ - changeRecordSets(params) { - return new Promise((resolve, reject) => { - this._route53.changeResourceRecordSets(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createHostedZone function of Route53 - * @param {CreateHostedZoneRequest} params - Data required for createHostedZone - * @returns {Promise} - */ - createZone(params) { - return new Promise((resolve, reject) => { - this._route53.createHostedZone(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteHostedZone function of Route53 - * @param {DeleteHostedZoneRequest} params - Data required for deleteHostedZone - * @returns {Promise} - */ - deleteZone(params) { - return new Promise((resolve, reject) => { - this._route53.deleteHostedZone(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listHostedZones function of Route53 - * @param {ListHostedZonesRequest} params - Data required for listHostedZones - * @returns {Promise} - */ - listZones(params) { - return new Promise((resolve, reject) => { - this._route53.listHostedZones(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._route53 = new this._AWS.Route53({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the changeResourceRecordSets function of Route53 + * @param {ChangeResourceRecordSetsRequest} params - Data required for changeResourceRecordSets + * @returns {Promise} + */ + changeRecordSets(params) { + return new Promise((resolve, reject) => { + this._route53.changeResourceRecordSets(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createHostedZone function of Route53 + * @param {CreateHostedZoneRequest} params - Data required for createHostedZone + * @returns {Promise} + */ + createZone(params) { + return new Promise((resolve, reject) => { + this._route53.createHostedZone(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteHostedZone function of Route53 + * @param {DeleteHostedZoneRequest} params - Data required for deleteHostedZone + * @returns {Promise} + */ + deleteZone(params) { + return new Promise((resolve, reject) => { + this._route53.deleteHostedZone(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listHostedZones function of Route53 + * @param {ListHostedZonesRequest} params - Data required for listHostedZones + * @returns {Promise} + */ + listZones(params) { + return new Promise((resolve, reject) => { + this._route53.listHostedZones(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_DNS; diff --git a/generator/generatedClasses/AWS/network/aws-loadBalancer.js b/generator/generatedClasses/AWS/network/aws-loadBalancer.js index 7731152c..d9eba23b 100644 --- a/generator/generatedClasses/AWS/network/aws-loadBalancer.js +++ b/generator/generatedClasses/AWS/network/aws-loadBalancer.js @@ -4,102 +4,97 @@ * @category AWS */ class AWS_LoadBalancer { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eLB = new this._AWS.ELB({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the addTags function of ELB - * @param {AddTagsInput} params - Data required for addTags - * @returns {Promise} - */ - addTags(params) { - return new Promise((resolve, reject) => { - this._eLB.addTags(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createLoadBalancer function of ELB - * @param {CreateAccessPointInput} params - Data required for createLoadBalancer - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eLB.createLoadBalancer(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteLoadBalancer function of ELB - * @param {DeleteAccessPointInput} params - Data required for deleteLoadBalancer - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eLB.deleteLoadBalancer(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeLoadBalancerAttributes function of ELB - * @param {DescribeLoadBalancerAttributesInput} params - Data required for describeLoadBalancerAttributes - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eLB.describeLoadBalancerAttributes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeLoadBalancers function of ELB - * @param {DescribeAccessPointsInput} params - Data required for describeLoadBalancers - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eLB.describeLoadBalancers(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eLB = new this._AWS.ELB({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the addTags function of ELB + * @param {AddTagsInput} params - Data required for addTags + * @returns {Promise} + */ + addTags(params) { + return new Promise((resolve, reject) => { + this._eLB.addTags(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createLoadBalancer function of ELB + * @param {CreateAccessPointInput} params - Data required for createLoadBalancer + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eLB.createLoadBalancer(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteLoadBalancer function of ELB + * @param {DeleteAccessPointInput} params - Data required for deleteLoadBalancer + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eLB.deleteLoadBalancer(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeLoadBalancerAttributes function of ELB + * @param {DescribeLoadBalancerAttributesInput} params - Data required for describeLoadBalancerAttributes + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eLB.describeLoadBalancerAttributes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeLoadBalancers function of ELB + * @param {DescribeAccessPointsInput} params - Data required for describeLoadBalancers + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eLB.describeLoadBalancers(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_LoadBalancer; diff --git a/generator/generatedClasses/AWS/security/aws-IAM.js b/generator/generatedClasses/AWS/security/aws-IAM.js index b643c521..9191ab3d 100644 --- a/generator/generatedClasses/AWS/security/aws-IAM.js +++ b/generator/generatedClasses/AWS/security/aws-IAM.js @@ -4,102 +4,97 @@ * @category AWS */ class AWS_IAM { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._iAM = new this._AWS.IAM({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the attachGroupPolicy function of IAM - * @param {AttachGroupPolicyRequest} params - Data required for attachGroupPolicy - * @returns {Promise} - */ - attachGroupPolicy(params) { - return new Promise((resolve, reject) => { - this._iAM.attachGroupPolicy(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the createGroup function of IAM - * @param {CreateGroupRequest} params - Data required for createGroup - * @returns {Promise} - */ - createGroup(params) { - return new Promise((resolve, reject) => { - this._iAM.createGroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteGroup function of IAM - * @param {DeleteGroupRequest} params - Data required for deleteGroup - * @returns {Promise} - */ - deleteGroup(params) { - return new Promise((resolve, reject) => { - this._iAM.deleteGroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the detachGroupPolicy function of IAM - * @param {DetachGroupPolicyRequest} params - Data required for detachGroupPolicy - * @returns {Promise} - */ - detachGroupPolicy(params) { - return new Promise((resolve, reject) => { - this._iAM.detachGroupPolicy(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the getGroup function of IAM - * @param {GetGroupRequest} params - Data required for getGroup - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._iAM.getGroup(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._iAM = new this._AWS.IAM({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the attachGroupPolicy function of IAM + * @param {AttachGroupPolicyRequest} params - Data required for attachGroupPolicy + * @returns {Promise} + */ + attachGroupPolicy(params) { + return new Promise((resolve, reject) => { + this._iAM.attachGroupPolicy(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the createGroup function of IAM + * @param {CreateGroupRequest} params - Data required for createGroup + * @returns {Promise} + */ + createGroup(params) { + return new Promise((resolve, reject) => { + this._iAM.createGroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteGroup function of IAM + * @param {DeleteGroupRequest} params - Data required for deleteGroup + * @returns {Promise} + */ + deleteGroup(params) { + return new Promise((resolve, reject) => { + this._iAM.deleteGroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the detachGroupPolicy function of IAM + * @param {DetachGroupPolicyRequest} params - Data required for detachGroupPolicy + * @returns {Promise} + */ + detachGroupPolicy(params) { + return new Promise((resolve, reject) => { + this._iAM.detachGroupPolicy(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the getGroup function of IAM + * @param {GetGroupRequest} params - Data required for getGroup + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._iAM.getGroup(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_IAM; diff --git a/generator/generatedClasses/AWS/storage/aws-archivalStorage.js b/generator/generatedClasses/AWS/storage/aws-archivalStorage.js index 44aa797f..a5189f99 100644 --- a/generator/generatedClasses/AWS/storage/aws-archivalStorage.js +++ b/generator/generatedClasses/AWS/storage/aws-archivalStorage.js @@ -4,102 +4,97 @@ * @category AWS */ class AWS_ArchivalStorage { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._glacier = new this._AWS.Glacier({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createVault function of Glacier - * @param {CreateVaultInput} params - Data required for createVault - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._glacier.createVault(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteArchive function of Glacier - * @param {DeleteArchiveInput} params - Data required for deleteArchive - * @returns {Promise} - */ - deleteFiles(params) { - return new Promise((resolve, reject) => { - this._glacier.deleteArchive(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteVault function of Glacier - * @param {DeleteVaultInput} params - Data required for deleteVault - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._glacier.deleteVault(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the initiateMultipartUpload function of Glacier - * @param {InitiateMultipartUploadInput} params - Data required for initiateMultipartUpload - * @returns {Promise} - */ - upload(params) { - return new Promise((resolve, reject) => { - this._glacier.initiateMultipartUpload(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listParts function of Glacier - * @param {ListPartsInput} params - Data required for listParts - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._glacier.listParts(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._glacier = new this._AWS.Glacier({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createVault function of Glacier + * @param {CreateVaultInput} params - Data required for createVault + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._glacier.createVault(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteArchive function of Glacier + * @param {DeleteArchiveInput} params - Data required for deleteArchive + * @returns {Promise} + */ + deleteFiles(params) { + return new Promise((resolve, reject) => { + this._glacier.deleteArchive(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteVault function of Glacier + * @param {DeleteVaultInput} params - Data required for deleteVault + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._glacier.deleteVault(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the initiateMultipartUpload function of Glacier + * @param {InitiateMultipartUploadInput} params - Data required for initiateMultipartUpload + * @returns {Promise} + */ + upload(params) { + return new Promise((resolve, reject) => { + this._glacier.initiateMultipartUpload(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listParts function of Glacier + * @param {ListPartsInput} params - Data required for listParts + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._glacier.listParts(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_ArchivalStorage; diff --git a/generator/generatedClasses/AWS/storage/aws-blockStorage.js b/generator/generatedClasses/AWS/storage/aws-blockStorage.js index d1c77717..b362afec 100644 --- a/generator/generatedClasses/AWS/storage/aws-blockStorage.js +++ b/generator/generatedClasses/AWS/storage/aws-blockStorage.js @@ -4,85 +4,81 @@ * @category AWS */ class AWS_BlockStorage { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._eC2 = new this._AWS.EC2({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createVolume function of EC2 - * @param {CreateVolumeRequest} params - Data required for createVolume - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._eC2.createVolume(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteVolume function of EC2 - * @param {DeleteVolumeRequest} params - Data required for deleteVolume - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._eC2.deleteVolume(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeVolumeAttribute function of EC2 - * @param {DescribeVolumeAttributeRequest} params - Data required for describeVolumeAttribute - * @returns {Promise} - */ - describe(params) { - return new Promise((resolve, reject) => { - this._eC2.describeVolumeAttribute(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the describeVolumes function of EC2 - * @param {DescribeVolumesRequest} params - Data required for describeVolumes - * @returns {Promise} - */ - list(params) { - return new Promise((resolve, reject) => { - this._eC2.describeVolumes(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._eC2 = new this._AWS.EC2({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createVolume function of EC2 + * @param {CreateVolumeRequest} params - Data required for createVolume + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._eC2.createVolume(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteVolume function of EC2 + * @param {DeleteVolumeRequest} params - Data required for deleteVolume + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._eC2.deleteVolume(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeVolumeAttribute function of EC2 + * @param {DescribeVolumeAttributeRequest} params - Data required for describeVolumeAttribute + * @returns {Promise} + */ + describe(params) { + return new Promise((resolve, reject) => { + this._eC2.describeVolumeAttribute(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the describeVolumes function of EC2 + * @param {DescribeVolumesRequest} params - Data required for describeVolumes + * @returns {Promise} + */ + list(params) { + return new Promise((resolve, reject) => { + this._eC2.describeVolumes(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_BlockStorage; diff --git a/generator/generatedClasses/AWS/storage/aws-storageBucket.js b/generator/generatedClasses/AWS/storage/aws-storageBucket.js index eb483a51..f738acfc 100644 --- a/generator/generatedClasses/AWS/storage/aws-storageBucket.js +++ b/generator/generatedClasses/AWS/storage/aws-storageBucket.js @@ -4,101 +4,96 @@ * @category AWS */ class AWS_StorageBucket { - /** - * - * @param {module} aws AWS SDK - * @param {object} options SDK options - */ - constructor(aws, options) { - this._AWS = aws; - this._apiVersion = options.apiVersion; - this._s3 = new this._AWS.S3({ - apiVersion: this._apiVersion - }); - } - /** - * Trigers the createBucket function of S3 - * @param {CreateBucketRequest} params - Data required for createBucket - * @returns {Promise} - */ - create(params) { - return new Promise((resolve, reject) => { - this._s3.createBucket(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteBucket function of S3 - * @param {DeleteBucketRequest} params - Data required for deleteBucket - * @returns {Promise} - */ - delete(params) { - return new Promise((resolve, reject) => { - this._s3.deleteBucket(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the deleteObjects function of S3 - * @param {DeleteObjectsRequest} params - Data required for deleteObjects - * @returns {Promise} - */ - deleteFiles(params) { - return new Promise((resolve, reject) => { - this._s3.deleteObjects(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the listBuckets function of S3 - * @returns {Promise} - */ - list() { - return new Promise((resolve, reject) => { - this._s3.listBuckets((error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } - /** - * Trigers the uploadPart function of S3 - * @param {UploadPartRequest} params - Data required for uploadPart - * @returns {Promise} - */ - upload(params) { - return new Promise((resolve, reject) => { - this._s3.uploadPart(params, (error, data) => { - if (error) { - reject(error); - } - else { - resolve(data); - } - }); - }); - } + /** + * + * @param {module} aws AWS SDK + * @param {object} options SDK options + */ + constructor(aws, options) { + this._AWS = aws; + this._apiVersion = options.apiVersion; + this._s3 = new this._AWS.S3({ + apiVersion: this._apiVersion, + }); + } + /** + * Trigers the createBucket function of S3 + * @param {CreateBucketRequest} params - Data required for createBucket + * @returns {Promise} + */ + create(params) { + return new Promise((resolve, reject) => { + this._s3.createBucket(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteBucket function of S3 + * @param {DeleteBucketRequest} params - Data required for deleteBucket + * @returns {Promise} + */ + delete(params) { + return new Promise((resolve, reject) => { + this._s3.deleteBucket(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the deleteObjects function of S3 + * @param {DeleteObjectsRequest} params - Data required for deleteObjects + * @returns {Promise} + */ + deleteFiles(params) { + return new Promise((resolve, reject) => { + this._s3.deleteObjects(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the listBuckets function of S3 + * @returns {Promise} + */ + list() { + return new Promise((resolve, reject) => { + this._s3.listBuckets((error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } + /** + * Trigers the uploadPart function of S3 + * @param {UploadPartRequest} params - Data required for uploadPart + * @returns {Promise} + */ + upload(params) { + return new Promise((resolve, reject) => { + this._s3.uploadPart(params, (error, data) => { + if (error) { + reject(error); + } else { + resolve(data); + } + }); + }); + } } module.exports = AWS_StorageBucket; diff --git a/generator/generatedClasses/Azure/appServices/azure-paaS.js b/generator/generatedClasses/Azure/appServices/azure-paaS.js index 226bbc2a..db0d3ff8 100644 --- a/generator/generatedClasses/Azure/appServices/azure-paaS.js +++ b/generator/generatedClasses/Azure/appServices/azure-paaS.js @@ -1,286 +1,429 @@ -const { WebSiteManagementClient } = require("@azure/arm-appservice"); +const { WebSiteManagementClient } = require('@azure/arm-appservice'); /*This is an auto generated class, please do not change.*/ /** * Class to create a PaaS object * @category Azure */ class Azure_PaaS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, name, siteEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.createOrUpdate(resourceGroupName, name, siteEnvelope, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, name, siteEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.update(resourceGroupName, name, siteEnvelope, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.get(resourceGroupName, name, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.deleteMethod(resourceGroupName, name, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the restart function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - restart(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.restart(resourceGroupName, name, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createOrUpdate function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createEnvironment(resourceGroupName, name, hostingEnvironmentEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.appServiceEnvironments.createOrUpdate(resourceGroupName, name, hostingEnvironmentEnvelope, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateEnvironment(resourceGroupName, name, hostingEnvironmentEnvelope, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.appServiceEnvironments.update(resourceGroupName, name, hostingEnvironmentEnvelope, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createOrUpdateSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} siteEnvelope - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createConfigTemplate(resourceGroupName, name, siteEnvelope, slot, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.createOrUpdateSlot(resourceGroupName, name, siteEnvelope, slot, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeConfigSettings(resourceGroupName, name, slot, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.getSlot(resourceGroupName, name, slot, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteSlot function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {StringKeyword} slot - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteConfigTemplate(resourceGroupName, name, slot, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.webApps.deleteSlot(resourceGroupName, name, slot, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the checkAvailability function of appservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - checkDNSAvailability(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.domains.checkAvailability(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of appservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - terminateEnvironment(resourceGroupName, name, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new WebSiteManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.appServiceEnvironments.deleteMethod(resourceGroupName, name, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, name, siteEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .createOrUpdate( + resourceGroupName, + name, + siteEnvelope, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, name, siteEnvelope, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .update(resourceGroupName, name, siteEnvelope, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .get(resourceGroupName, name, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .deleteMethod(resourceGroupName, name, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the restart function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + restart(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .restart(resourceGroupName, name, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createOrUpdate function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createEnvironment( + resourceGroupName, + name, + hostingEnvironmentEnvelope, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.appServiceEnvironments + .createOrUpdate( + resourceGroupName, + name, + hostingEnvironmentEnvelope, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} hostingEnvironmentEnvelope - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateEnvironment( + resourceGroupName, + name, + hostingEnvironmentEnvelope, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.appServiceEnvironments + .update( + resourceGroupName, + name, + hostingEnvironmentEnvelope, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createOrUpdateSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} siteEnvelope - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createConfigTemplate( + resourceGroupName, + name, + siteEnvelope, + slot, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .createOrUpdateSlot( + resourceGroupName, + name, + siteEnvelope, + slot, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeConfigSettings(resourceGroupName, name, slot, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .getSlot(resourceGroupName, name, slot, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteSlot function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {StringKeyword} slot - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteConfigTemplate(resourceGroupName, name, slot, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.webApps + .deleteSlot(resourceGroupName, name, slot, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the checkAvailability function of appservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + checkDNSAvailability(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.domains.checkAvailability(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of appservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + terminateEnvironment(resourceGroupName, name, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new WebSiteManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.appServiceEnvironments + .deleteMethod(resourceGroupName, name, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_PaaS; diff --git a/generator/generatedClasses/Azure/compute/azure-computeInstance.js b/generator/generatedClasses/Azure/compute/azure-computeInstance.js index 1ff4472f..d793562a 100644 --- a/generator/generatedClasses/Azure/compute/azure-computeInstance.js +++ b/generator/generatedClasses/Azure/compute/azure-computeInstance.js @@ -1,148 +1,207 @@ -const { ComputeManagementClient } = require("@azure/arm-compute"); +const { ComputeManagementClient } = require('@azure/arm-compute'); /*This is an auto generated class, please do not change.*/ /** * Class to create a ComputeInstance object * @category Azure */ class Azure_ComputeInstance { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, vmName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.createOrUpdate(resourceGroupName, vmName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.list(resourceGroupName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the start function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - start(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.start(resourceGroupName, vmName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the powerOff function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - stop(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.powerOff(resourceGroupName, vmName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the restart function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - reboot(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.restart(resourceGroupName, vmName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vmName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - destroy(resourceGroupName, vmName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.virtualMachines.deleteMethod(resourceGroupName, vmName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, vmName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .createOrUpdate( + resourceGroupName, + vmName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .list(resourceGroupName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the start function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + start(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .start(resourceGroupName, vmName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the powerOff function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + stop(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .powerOff(resourceGroupName, vmName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the restart function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + reboot(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .restart(resourceGroupName, vmName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vmName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + destroy(resourceGroupName, vmName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.virtualMachines + .deleteMethod(resourceGroupName, vmName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_ComputeInstance; diff --git a/generator/generatedClasses/Azure/compute/azure-container.js b/generator/generatedClasses/Azure/compute/azure-container.js index 7ae30f1e..f27e4286 100644 --- a/generator/generatedClasses/Azure/compute/azure-container.js +++ b/generator/generatedClasses/Azure/compute/azure-container.js @@ -1,103 +1,151 @@ -const { ContainerServiceClient } = require("@azure/arm-containerservice"); +const { ContainerServiceClient } = require('@azure/arm-containerservice'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Container object * @category Azure */ class Azure_Container { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, containerServiceName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.containerServices.createOrUpdate(resourceGroupName, containerServiceName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, containerServiceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.containerServices.deleteMethod(resourceGroupName, containerServiceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} containerServiceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, containerServiceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.containerServices.get(resourceGroupName, containerServiceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of containerservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.containerServices.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create( + resourceGroupName, + containerServiceName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.containerServices + .createOrUpdate( + resourceGroupName, + containerServiceName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, containerServiceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.containerServices + .deleteMethod( + resourceGroupName, + containerServiceName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} containerServiceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, containerServiceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.containerServices + .get(resourceGroupName, containerServiceName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of containerservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.containerServices.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_Container; diff --git a/generator/generatedClasses/Azure/compute/azure-kubernetes.js b/generator/generatedClasses/Azure/compute/azure-kubernetes.js index 8f01c7c1..9ce5157f 100644 --- a/generator/generatedClasses/Azure/compute/azure-kubernetes.js +++ b/generator/generatedClasses/Azure/compute/azure-kubernetes.js @@ -1,240 +1,379 @@ -const { ContainerServiceClient } = require("@azure/arm-containerservice"); +const { ContainerServiceClient } = require('@azure/arm-containerservice'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Kubernetes object * @category Azure */ class Azure_Kubernetes { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, resourceName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.createOrUpdate(resourceGroupName, resourceName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.deleteMethod(resourceGroupName, resourceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateTags function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateTags(resourceGroupName, resourceName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.updateTags(resourceGroupName, resourceName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of containerservice - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listClusters(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeCluster(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.get(resourceGroupName, resourceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createOrUpdate function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createNodeGroup(resourceGroupName, resourceName, agentPoolName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.agentPools.createOrUpdate(resourceGroupName, resourceName, agentPoolName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteNodegroup(resourceGroupName, resourceName, agentPoolName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.agentPools.deleteMethod(resourceGroupName, resourceName, agentPoolName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {StringKeyword} agentPoolName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeNodeGroup(resourceGroupName, resourceName, agentPoolName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.agentPools.get(resourceGroupName, resourceName, agentPoolName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listNodegroups(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.agentPools.list(resourceGroupName, resourceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the rotateClusterCertificates function of containerservice - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} resourceName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateConfig(resourceGroupName, resourceName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ContainerServiceClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedClusters.rotateClusterCertificates(resourceGroupName, resourceName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, resourceName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters + .createOrUpdate( + resourceGroupName, + resourceName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters + .deleteMethod(resourceGroupName, resourceName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateTags function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateTags( + resourceGroupName, + resourceName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters + .updateTags( + resourceGroupName, + resourceName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of containerservice + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listClusters(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeCluster(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters + .get(resourceGroupName, resourceName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createOrUpdate function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createNodeGroup( + resourceGroupName, + resourceName, + agentPoolName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.agentPools + .createOrUpdate( + resourceGroupName, + resourceName, + agentPoolName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteNodegroup( + resourceGroupName, + resourceName, + agentPoolName, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.agentPools + .deleteMethod( + resourceGroupName, + resourceName, + agentPoolName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {StringKeyword} agentPoolName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeNodeGroup( + resourceGroupName, + resourceName, + agentPoolName, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.agentPools + .get( + resourceGroupName, + resourceName, + agentPoolName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listNodegroups(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.agentPools + .list(resourceGroupName, resourceName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the rotateClusterCertificates function of containerservice + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} resourceName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateConfig(resourceGroupName, resourceName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ContainerServiceClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedClusters + .rotateClusterCertificates( + resourceGroupName, + resourceName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_Kubernetes; diff --git a/generator/generatedClasses/Azure/database/azure-RDBMS.js b/generator/generatedClasses/Azure/database/azure-RDBMS.js index f2665dd0..d4d7d062 100644 --- a/generator/generatedClasses/Azure/database/azure-RDBMS.js +++ b/generator/generatedClasses/Azure/database/azure-RDBMS.js @@ -1,135 +1,238 @@ -const { SqlManagementClient } = require("@azure/arm-sql"); +const { SqlManagementClient } = require('@azure/arm-sql'); /*This is an auto generated class, please do not change.*/ /** * Class to create a RDBMS object * @category Azure */ class Azure_RDBMS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createDatabse(resourceGroupName, serverName, databaseName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.databases.createOrUpdate(resourceGroupName, serverName, databaseName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteDatabase(resourceGroupName, serverName, databaseName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.databases.deleteMethod(resourceGroupName, serverName, databaseName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the exportMethod function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createSnapshots(resourceGroupName, serverName, databaseName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.databases.exportMethod(resourceGroupName, serverName, databaseName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} serverName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - modifyDB(resourceGroupName, serverName, databaseName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.databases.update(resourceGroupName, serverName, databaseName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the completeRestore function of sql - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} managedInstanceName - Mandatory parameter - * @param {StringKeyword} databaseName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - restoreDatabase(resourceGroupName, managedInstanceName, databaseName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new SqlManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.managedDatabases.completeRestore(resourceGroupName, managedInstanceName, databaseName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createDatabse( + resourceGroupName, + serverName, + databaseName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new SqlManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.databases + .createOrUpdate( + resourceGroupName, + serverName, + databaseName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteDatabase( + resourceGroupName, + serverName, + databaseName, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new SqlManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.databases + .deleteMethod( + resourceGroupName, + serverName, + databaseName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the exportMethod function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createSnapshots( + resourceGroupName, + serverName, + databaseName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new SqlManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.databases + .exportMethod( + resourceGroupName, + serverName, + databaseName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} serverName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + modifyDB( + resourceGroupName, + serverName, + databaseName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new SqlManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.databases + .update( + resourceGroupName, + serverName, + databaseName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the completeRestore function of sql + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} managedInstanceName - Mandatory parameter + * @param {StringKeyword} databaseName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + restoreDatabase( + resourceGroupName, + managedInstanceName, + databaseName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new SqlManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.managedDatabases + .completeRestore( + resourceGroupName, + managedInstanceName, + databaseName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_RDBMS; diff --git a/generator/generatedClasses/Azure/database/azure-noSql.js b/generator/generatedClasses/Azure/database/azure-noSql.js index 190ed4f2..70b2d295 100644 --- a/generator/generatedClasses/Azure/database/azure-noSql.js +++ b/generator/generatedClasses/Azure/database/azure-noSql.js @@ -1,132 +1,221 @@ -const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb"); +const { CosmosDBManagementClient } = require('@azure/arm-cosmosdb'); /*This is an auto generated class, please do not change.*/ /** * Class to create a NoSql object * @category Azure */ class Azure_NoSql { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createUpdateTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} createUpdateTableParameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createCollection(resourceGroupName, accountName, tableName, createUpdateTableParameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.tableResources.createUpdateTable(resourceGroupName, accountName, tableName, createUpdateTableParameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteCollection(resourceGroupName, accountName, tableName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.tableResources.deleteTable(resourceGroupName, accountName, tableName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listTables function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listCollections(resourceGroupName, accountName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.tableResources.listTables(resourceGroupName, accountName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateTableThroughput function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} updateThroughputParameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - setAttribute(resourceGroupName, accountName, tableName, updateThroughputParameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.tableResources.updateTableThroughput(resourceGroupName, accountName, tableName, updateThroughputParameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getTable function of cosmosdb - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} tableName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - getAttributes(resourceGroupName, accountName, tableName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new CosmosDBManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.tableResources.getTable(resourceGroupName, accountName, tableName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createUpdateTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} createUpdateTableParameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createCollection( + resourceGroupName, + accountName, + tableName, + createUpdateTableParameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new CosmosDBManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.tableResources + .createUpdateTable( + resourceGroupName, + accountName, + tableName, + createUpdateTableParameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteCollection( + resourceGroupName, + accountName, + tableName, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new CosmosDBManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.tableResources + .deleteTable( + resourceGroupName, + accountName, + tableName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listTables function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listCollections(resourceGroupName, accountName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new CosmosDBManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.tableResources + .listTables(resourceGroupName, accountName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateTableThroughput function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} updateThroughputParameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + setAttribute( + resourceGroupName, + accountName, + tableName, + updateThroughputParameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new CosmosDBManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.tableResources + .updateTableThroughput( + resourceGroupName, + accountName, + tableName, + updateThroughputParameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getTable function of cosmosdb + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} tableName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + getAttributes( + resourceGroupName, + accountName, + tableName, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new CosmosDBManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.tableResources + .getTable( + resourceGroupName, + accountName, + tableName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_NoSql; diff --git a/generator/generatedClasses/Azure/management/azure-keyManagement.js b/generator/generatedClasses/Azure/management/azure-keyManagement.js index 2d594150..ef080569 100644 --- a/generator/generatedClasses/Azure/management/azure-keyManagement.js +++ b/generator/generatedClasses/Azure/management/azure-keyManagement.js @@ -1,130 +1,197 @@ -const { KeyVaultManagementClient } = require("@azure/arm-keyvault"); +const { KeyVaultManagementClient } = require('@azure/arm-keyvault'); /*This is an auto generated class, please do not change.*/ /** * Class to create a KeyManagement object * @category Azure */ class Azure_KeyManagement { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createKey(resourceGroupName, vaultName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.vaults.createOrUpdate(resourceGroupName, vaultName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteKey(resourceGroupName, vaultName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.vaults.deleteMethod(resourceGroupName, vaultName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, vaultName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.vaults.update(resourceGroupName, vaultName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describeKey(resourceGroupName, vaultName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.vaults.get(resourceGroupName, vaultName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateAccessPolicy function of keyvault - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} vaultName - Mandatory parameter - * @param {TypeReference} operationKind - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - putKeyPolicy(resourceGroupName, vaultName, operationKind, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new KeyVaultManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.vaults.updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createKey(resourceGroupName, vaultName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new KeyVaultManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.vaults + .createOrUpdate( + resourceGroupName, + vaultName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteKey(resourceGroupName, vaultName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new KeyVaultManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.vaults + .deleteMethod(resourceGroupName, vaultName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, vaultName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new KeyVaultManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.vaults + .update( + resourceGroupName, + vaultName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describeKey(resourceGroupName, vaultName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new KeyVaultManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.vaults + .get(resourceGroupName, vaultName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateAccessPolicy function of keyvault + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} vaultName - Mandatory parameter + * @param {TypeReference} operationKind - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + putKeyPolicy( + resourceGroupName, + vaultName, + operationKind, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new KeyVaultManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.vaults + .updateAccessPolicy( + resourceGroupName, + vaultName, + operationKind, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_KeyManagement; diff --git a/generator/generatedClasses/Azure/management/azure-monitoring.js b/generator/generatedClasses/Azure/management/azure-monitoring.js index e7b373c0..efb43c1f 100644 --- a/generator/generatedClasses/Azure/management/azure-monitoring.js +++ b/generator/generatedClasses/Azure/management/azure-monitoring.js @@ -1,126 +1,186 @@ -const { MonitorManagementClient } = require("@azure/arm-monitor"); +const { MonitorManagementClient } = require('@azure/arm-monitor'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Monitoring object * @category Azure */ class Azure_Monitoring { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createAlarm(resourceGroupName, ruleName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.alertRules.createOrUpdate(resourceGroupName, ruleName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteAlarm(resourceGroupName, ruleName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.alertRules.deleteMethod(resourceGroupName, ruleName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} alertRulesResource - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - updateAlarm(resourceGroupName, ruleName, alertRulesResource, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.alertRules.update(resourceGroupName, ruleName, alertRulesResource, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listBySubscription function of monitor - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listAlarms(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.alertRules.listBySubscription(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of monitor - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} ruleName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - getMetricData(resourceGroupName, ruleName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new MonitorManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.alertRules.get(resourceGroupName, ruleName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createAlarm(resourceGroupName, ruleName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new MonitorManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.alertRules + .createOrUpdate( + resourceGroupName, + ruleName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteAlarm(resourceGroupName, ruleName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new MonitorManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.alertRules + .deleteMethod(resourceGroupName, ruleName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} alertRulesResource - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + updateAlarm( + resourceGroupName, + ruleName, + alertRulesResource, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new MonitorManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.alertRules + .update( + resourceGroupName, + ruleName, + alertRulesResource, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listBySubscription function of monitor + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listAlarms(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new MonitorManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.alertRules + .listBySubscription(options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of monitor + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} ruleName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + getMetricData(resourceGroupName, ruleName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new MonitorManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.alertRules + .get(resourceGroupName, ruleName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_Monitoring; diff --git a/generator/generatedClasses/Azure/network/azure-DNS.js b/generator/generatedClasses/Azure/network/azure-DNS.js index 17a86c4b..38ae476b 100644 --- a/generator/generatedClasses/Azure/network/azure-DNS.js +++ b/generator/generatedClasses/Azure/network/azure-DNS.js @@ -1,106 +1,159 @@ -const { DnsManagementClient } = require("@azure/arm-dns"); +const { DnsManagementClient } = require('@azure/arm-dns'); /*This is an auto generated class, please do not change.*/ /** * Class to create a DNS object * @category Azure */ class Azure_DNS { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - createZone(resourceGroupName, zoneName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.zones.createOrUpdate(resourceGroupName, zoneName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteZone(resourceGroupName, zoneName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.zones.deleteMethod(resourceGroupName, zoneName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of dns - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - listZones(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.zones.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createOrUpdate function of dns - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} zoneName - Mandatory parameter - * @param {StringKeyword} relativeRecordSetName - Mandatory parameter - * @param {TypeReference} recordType - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - changeRecordSets(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new DnsManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.recordSets.createOrUpdate(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + createZone(resourceGroupName, zoneName, parameters, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new DnsManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.zones + .createOrUpdate( + resourceGroupName, + zoneName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteZone(resourceGroupName, zoneName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new DnsManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.zones + .deleteMethod(resourceGroupName, zoneName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of dns + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + listZones(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new DnsManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.zones.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createOrUpdate function of dns + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} zoneName - Mandatory parameter + * @param {StringKeyword} relativeRecordSetName - Mandatory parameter + * @param {TypeReference} recordType - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + changeRecordSets( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new DnsManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.recordSets + .createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_DNS; diff --git a/generator/generatedClasses/Azure/network/azure-loadBalancer.js b/generator/generatedClasses/Azure/network/azure-loadBalancer.js index 0d7ea4bc..db3ae534 100644 --- a/generator/generatedClasses/Azure/network/azure-loadBalancer.js +++ b/generator/generatedClasses/Azure/network/azure-loadBalancer.js @@ -1,127 +1,196 @@ -const { NetworkManagementClient } = require("@azure/arm-network"); +const { NetworkManagementClient } = require('@azure/arm-network'); /*This is an auto generated class, please do not change.*/ /** * Class to create a LoadBalancer object * @category Azure */ class Azure_LoadBalancer { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, loadBalancerName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.loadBalancers.createOrUpdate(resourceGroupName, loadBalancerName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, loadBalancerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.loadBalancers.deleteMethod(resourceGroupName, loadBalancerName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.loadBalancers.list(resourceGroupName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateTags function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} parameters - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - addTags(resourceGroupName, loadBalancerName, parameters, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.loadBalancers.updateTags(resourceGroupName, loadBalancerName, parameters, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of network - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} loadBalancerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, loadBalancerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new NetworkManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.loadBalancers.get(resourceGroupName, loadBalancerName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create( + resourceGroupName, + loadBalancerName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new NetworkManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.loadBalancers + .createOrUpdate( + resourceGroupName, + loadBalancerName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, loadBalancerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new NetworkManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.loadBalancers + .deleteMethod( + resourceGroupName, + loadBalancerName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new NetworkManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.loadBalancers + .list(resourceGroupName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateTags function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} parameters - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + addTags( + resourceGroupName, + loadBalancerName, + parameters, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new NetworkManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.loadBalancers + .updateTags( + resourceGroupName, + loadBalancerName, + parameters, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of network + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} loadBalancerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, loadBalancerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new NetworkManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.loadBalancers + .get(resourceGroupName, loadBalancerName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_LoadBalancer; diff --git a/generator/generatedClasses/Azure/storage/azure-blockStorage.js b/generator/generatedClasses/Azure/storage/azure-blockStorage.js index 13ea3e7d..a792ee41 100644 --- a/generator/generatedClasses/Azure/storage/azure-blockStorage.js +++ b/generator/generatedClasses/Azure/storage/azure-blockStorage.js @@ -1,126 +1,174 @@ -const { ComputeManagementClient } = require("@azure/arm-compute"); +const { ComputeManagementClient } = require('@azure/arm-compute'); /*This is an auto generated class, please do not change.*/ /** * Class to create a BlockStorage object * @category Azure */ class Azure_BlockStorage { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the createOrUpdate function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} disk - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, diskName, disk, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.disks.createOrUpdate(resourceGroupName, diskName, disk, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, diskName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.disks.deleteMethod(resourceGroupName, diskName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the get function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - describe(resourceGroupName, diskName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.disks.get(resourceGroupName, diskName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of compute - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.disks.list(options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the update function of compute - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} diskName - Mandatory parameter - * @param {TypeReference} disk - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - update(resourceGroupName, diskName, disk, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new ComputeManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.disks.update(resourceGroupName, diskName, disk, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the createOrUpdate function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} disk - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create(resourceGroupName, diskName, disk, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.disks + .createOrUpdate( + resourceGroupName, + diskName, + disk, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, diskName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.disks + .deleteMethod(resourceGroupName, diskName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the get function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + describe(resourceGroupName, diskName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.disks + .get(resourceGroupName, diskName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of compute + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.disks.list(options).then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the update function of compute + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} diskName - Mandatory parameter + * @param {TypeReference} disk - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + update(resourceGroupName, diskName, disk, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new ComputeManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.disks + .update(resourceGroupName, diskName, disk, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_BlockStorage; diff --git a/generator/generatedClasses/Azure/storage/azure-storageBucket.js b/generator/generatedClasses/Azure/storage/azure-storageBucket.js index f2e9e22c..fd7c99ec 100644 --- a/generator/generatedClasses/Azure/storage/azure-storageBucket.js +++ b/generator/generatedClasses/Azure/storage/azure-storageBucket.js @@ -1,85 +1,129 @@ -const { StorageManagementClient } = require("@azure/arm-storage"); +const { StorageManagementClient } = require('@azure/arm-storage'); /*This is an auto generated class, please do not change.*/ /** * Class to create a StorageBucket object * @category Azure */ class Azure_StorageBucket { - /** - * - * @param {module} azureRestSdk Azure Rest SDK - */ - constructor(azureRestSdk) { - this._azureRestSdk = azureRestSdk; - } - /** - * Trigers the create function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} containerName - Mandatory parameter - * @param {TypeReference} blobContainer - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - create(resourceGroupName, accountName, containerName, blobContainer, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.blobContainers.create(resourceGroupName, accountName, containerName, blobContainer, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteMethod function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {StringKeyword} containerName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - delete(resourceGroupName, accountName, containerName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.blobContainers.deleteMethod(resourceGroupName, accountName, containerName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the list function of storage - * @param {StringKeyword} resourceGroupName - Mandatory parameter - * @param {StringKeyword} accountName - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(resourceGroupName, accountName, options = undefined) { - return new Promise((resolve, reject) => { - this._azureRestSdk - .loginWithServicePrincipalSecretWithAuthResponse(process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET, process.env.AZURE_TENANT_ID) - .then(authres => { - const client = new StorageManagementClient(authres.credentials, process.env.AZURE_SUBSCRIPTION_ID); - client.blobContainers.list(resourceGroupName, accountName, options).then(result => { - resolve(result); - }); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {module} azureRestSdk Azure Rest SDK + */ + constructor(azureRestSdk) { + this._azureRestSdk = azureRestSdk; + } + /** + * Trigers the create function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} containerName - Mandatory parameter + * @param {TypeReference} blobContainer - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + create( + resourceGroupName, + accountName, + containerName, + blobContainer, + options = undefined + ) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new StorageManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.blobContainers + .create( + resourceGroupName, + accountName, + containerName, + blobContainer, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteMethod function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {StringKeyword} containerName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + delete(resourceGroupName, accountName, containerName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new StorageManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.blobContainers + .deleteMethod( + resourceGroupName, + accountName, + containerName, + options + ) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the list function of storage + * @param {StringKeyword} resourceGroupName - Mandatory parameter + * @param {StringKeyword} accountName - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(resourceGroupName, accountName, options = undefined) { + return new Promise((resolve, reject) => { + this._azureRestSdk + .loginWithServicePrincipalSecretWithAuthResponse( + process.env.AZURE_CLIENT_ID, + process.env.AZURE_CLIENT_SECRET, + process.env.AZURE_TENANT_ID + ) + .then(authres => { + const client = new StorageManagementClient( + authres.credentials, + process.env.AZURE_SUBSCRIPTION_ID + ); + client.blobContainers + .list(resourceGroupName, accountName, options) + .then(result => { + resolve(result); + }); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = Azure_StorageBucket; diff --git a/generator/generatedClasses/DO/compute/do-computeInstance.js b/generator/generatedClasses/DO/compute/do-computeInstance.js index 70594a63..593c3b85 100644 --- a/generator/generatedClasses/DO/compute/do-computeInstance.js +++ b/generator/generatedClasses/DO/compute/do-computeInstance.js @@ -1,70 +1,79 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Droplets object -* @category Digital Ocean -*/ + * Class to create a Droplets object + * @category Digital Ocean + */ class DO_ComputeInstance { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._droplets = this._instance.droplets; - } - /** - * Trigers the getAll function of Droplets - * @param {StringKeyword} tagName - Data required for getAll - * @param {BooleanKeyword} includeAll - Data required for getAll - * @param {NumberKeyword} page - Data required for getAll - * @param {NumberKeyword} pageSize - Data required for getAll - * @returns {Promise} - */ - list(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._droplets.getAll(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Droplets - * @param {DropletCreationRequest} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._droplets.create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteById function of Droplets - * @param {StringKeyword} dropletId - Data required for deleteById - * @returns {Promise} - */ - destroy(dropletId) { - return new Promise((resolve, reject) => { - this._droplets.deleteById(dropletId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the requestAction function of Droplets - * @param {StringKeyword} dropletId - Data required for requestAction - * @param {AnyKeyword} action - Data required for requestAction - * @returns {Promise} - */ - stop(dropletId, action) { - return new Promise((resolve, reject) => { - this._droplets.requestAction(dropletId, action) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._droplets = this._instance.droplets; + } + /** + * Trigers the getAll function of Droplets + * @param {StringKeyword} tagName - Data required for getAll + * @param {BooleanKeyword} includeAll - Data required for getAll + * @param {NumberKeyword} page - Data required for getAll + * @param {NumberKeyword} pageSize - Data required for getAll + * @returns {Promise} + */ + list( + tagName, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._droplets + .getAll(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Droplets + * @param {DropletCreationRequest} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._droplets + .create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteById function of Droplets + * @param {StringKeyword} dropletId - Data required for deleteById + * @returns {Promise} + */ + destroy(dropletId) { + return new Promise((resolve, reject) => { + this._droplets + .deleteById(dropletId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the requestAction function of Droplets + * @param {StringKeyword} dropletId - Data required for requestAction + * @param {AnyKeyword} action - Data required for requestAction + * @returns {Promise} + */ + stop(dropletId, action) { + return new Promise((resolve, reject) => { + this._droplets + .requestAction(dropletId, action) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_ComputeInstance; diff --git a/generator/generatedClasses/DO/compute/do-kubernetes.js b/generator/generatedClasses/DO/compute/do-kubernetes.js index e5bacb21..bcf976ed 100644 --- a/generator/generatedClasses/DO/compute/do-kubernetes.js +++ b/generator/generatedClasses/DO/compute/do-kubernetes.js @@ -1,122 +1,139 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Kubernetes object -* @category Digital Ocean -*/ + * Class to create a Kubernetes object + * @category Digital Ocean + */ class DO_Kubernetes { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._kubernetes = this._instance.kubernetes; - } - /** - * Trigers the getClusters function of Kubernetes - * @param {BooleanKeyword} includeAll - Data required for getClusters - * @param {NumberKeyword} page - Data required for getClusters - * @param {NumberKeyword} pageSize - Data required for getClusters - * @returns {Promise} - */ - listClusters(includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._kubernetes.getClusters(includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Kubernetes - * @param {NewClusterRequest} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._kubernetes.create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getById - * @returns {Promise} - */ - describeCluster(clusterId) { - return new Promise((resolve, reject) => { - this._kubernetes.getById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of Kubernetes - * @param {StringKeyword} clusterId - Data required for delete - * @returns {Promise} - */ - delete(clusterId) { - return new Promise((resolve, reject) => { - this._kubernetes.delete(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getNodePools function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getNodePools - * @param {BooleanKeyword} includeAll - Data required for getNodePools - * @param {NumberKeyword} page - Data required for getNodePools - * @param {NumberKeyword} pageSize - Data required for getNodePools - * @returns {Promise} - */ - listNodegroups(clusterId, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._kubernetes.getNodePools(clusterId, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getNodePoolById function of Kubernetes - * @param {StringKeyword} clusterId - Data required for getNodePoolById - * @param {StringKeyword} nodePoolId - Data required for getNodePoolById - * @returns {Promise} - */ - describeNodeGroup(clusterId, nodePoolId) { - return new Promise((resolve, reject) => { - this._kubernetes.getNodePoolById(clusterId, nodePoolId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the addNodePool function of Kubernetes - * @param {StringKeyword} clusterId - Data required for addNodePool - * @param {ClusterNodePool} nodePool - Data required for addNodePool - * @returns {Promise} - */ - createNodeGroup(clusterId, nodePool) { - return new Promise((resolve, reject) => { - this._kubernetes.addNodePool(clusterId, nodePool) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteNodePool function of Kubernetes - * @param {StringKeyword} clusterId - Data required for deleteNodePool - * @param {StringKeyword} nodePoolId - Data required for deleteNodePool - * @returns {Promise} - */ - deleteNodegroup(clusterId, nodePoolId) { - return new Promise((resolve, reject) => { - this._kubernetes.deleteNodePool(clusterId, nodePoolId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._kubernetes = this._instance.kubernetes; + } + /** + * Trigers the getClusters function of Kubernetes + * @param {BooleanKeyword} includeAll - Data required for getClusters + * @param {NumberKeyword} page - Data required for getClusters + * @param {NumberKeyword} pageSize - Data required for getClusters + * @returns {Promise} + */ + listClusters( + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._kubernetes + .getClusters(includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Kubernetes + * @param {NewClusterRequest} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._kubernetes + .create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getById + * @returns {Promise} + */ + describeCluster(clusterId) { + return new Promise((resolve, reject) => { + this._kubernetes + .getById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of Kubernetes + * @param {StringKeyword} clusterId - Data required for delete + * @returns {Promise} + */ + delete(clusterId) { + return new Promise((resolve, reject) => { + this._kubernetes + .delete(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getNodePools function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getNodePools + * @param {BooleanKeyword} includeAll - Data required for getNodePools + * @param {NumberKeyword} page - Data required for getNodePools + * @param {NumberKeyword} pageSize - Data required for getNodePools + * @returns {Promise} + */ + listNodegroups( + clusterId, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._kubernetes + .getNodePools(clusterId, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getNodePoolById function of Kubernetes + * @param {StringKeyword} clusterId - Data required for getNodePoolById + * @param {StringKeyword} nodePoolId - Data required for getNodePoolById + * @returns {Promise} + */ + describeNodeGroup(clusterId, nodePoolId) { + return new Promise((resolve, reject) => { + this._kubernetes + .getNodePoolById(clusterId, nodePoolId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the addNodePool function of Kubernetes + * @param {StringKeyword} clusterId - Data required for addNodePool + * @param {ClusterNodePool} nodePool - Data required for addNodePool + * @returns {Promise} + */ + createNodeGroup(clusterId, nodePool) { + return new Promise((resolve, reject) => { + this._kubernetes + .addNodePool(clusterId, nodePool) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteNodePool function of Kubernetes + * @param {StringKeyword} clusterId - Data required for deleteNodePool + * @param {StringKeyword} nodePoolId - Data required for deleteNodePool + * @returns {Promise} + */ + deleteNodegroup(clusterId, nodePoolId) { + return new Promise((resolve, reject) => { + this._kubernetes + .deleteNodePool(clusterId, nodePoolId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_Kubernetes; diff --git a/generator/generatedClasses/DO/database/do-RDBMS.js b/generator/generatedClasses/DO/database/do-RDBMS.js index fa59255a..216c49fd 100644 --- a/generator/generatedClasses/DO/database/do-RDBMS.js +++ b/generator/generatedClasses/DO/database/do-RDBMS.js @@ -1,70 +1,79 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Databases object -* @category Digital Ocean -*/ + * Class to create a Databases object + * @category Digital Ocean + */ class DO_RDBMS { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._databases = this._instance.databases; - } - /** - * Trigers the getAllClusters function of Databases - * @param {StringKeyword} tagName - Data required for getAllClusters - * @param {BooleanKeyword} includeAll - Data required for getAllClusters - * @param {NumberKeyword} page - Data required for getAllClusters - * @param {NumberKeyword} pageSize - Data required for getAllClusters - * @returns {Promise} - */ - getClusters(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._databases.getAllClusters(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createCluster function of Databases - * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster - * @returns {Promise} - */ - createCluster(clusterOptions) { - return new Promise((resolve, reject) => { - this._databases.createCluster(clusterOptions) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getClusterById function of Databases - * @param {StringKeyword} clusterId - Data required for getClusterById - * @returns {Promise} - */ - getCluster(clusterId) { - return new Promise((resolve, reject) => { - this._databases.getClusterById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the resizeCluster function of Databases - * @param {StringKeyword} clusterId - Data required for resizeCluster - * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster - * @returns {Promise} - */ - updateCluster(clusterId, configuration) { - return new Promise((resolve, reject) => { - this._databases.resizeCluster(clusterId, configuration) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._databases = this._instance.databases; + } + /** + * Trigers the getAllClusters function of Databases + * @param {StringKeyword} tagName - Data required for getAllClusters + * @param {BooleanKeyword} includeAll - Data required for getAllClusters + * @param {NumberKeyword} page - Data required for getAllClusters + * @param {NumberKeyword} pageSize - Data required for getAllClusters + * @returns {Promise} + */ + getClusters( + tagName, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._databases + .getAllClusters(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createCluster function of Databases + * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster + * @returns {Promise} + */ + createCluster(clusterOptions) { + return new Promise((resolve, reject) => { + this._databases + .createCluster(clusterOptions) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getClusterById function of Databases + * @param {StringKeyword} clusterId - Data required for getClusterById + * @returns {Promise} + */ + getCluster(clusterId) { + return new Promise((resolve, reject) => { + this._databases + .getClusterById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the resizeCluster function of Databases + * @param {StringKeyword} clusterId - Data required for resizeCluster + * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster + * @returns {Promise} + */ + updateCluster(clusterId, configuration) { + return new Promise((resolve, reject) => { + this._databases + .resizeCluster(clusterId, configuration) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_RDBMS; diff --git a/generator/generatedClasses/DO/database/do-noSql.js b/generator/generatedClasses/DO/database/do-noSql.js index 7d7650f5..1fcbbe5e 100644 --- a/generator/generatedClasses/DO/database/do-noSql.js +++ b/generator/generatedClasses/DO/database/do-noSql.js @@ -1,70 +1,79 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Databases object -* @category Digital Ocean -*/ + * Class to create a Databases object + * @category Digital Ocean + */ class DO_NoSql { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._databases = this._instance.databases; - } - /** - * Trigers the getAllClusters function of Databases - * @param {StringKeyword} tagName - Data required for getAllClusters - * @param {BooleanKeyword} includeAll - Data required for getAllClusters - * @param {NumberKeyword} page - Data required for getAllClusters - * @param {NumberKeyword} pageSize - Data required for getAllClusters - * @returns {Promise} - */ - getClusters(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._databases.getAllClusters(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createCluster function of Databases - * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster - * @returns {Promise} - */ - createCluster(clusterOptions) { - return new Promise((resolve, reject) => { - this._databases.createCluster(clusterOptions) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getClusterById function of Databases - * @param {StringKeyword} clusterId - Data required for getClusterById - * @returns {Promise} - */ - getCluster(clusterId) { - return new Promise((resolve, reject) => { - this._databases.getClusterById(clusterId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the resizeCluster function of Databases - * @param {StringKeyword} clusterId - Data required for resizeCluster - * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster - * @returns {Promise} - */ - updateCluster(clusterId, configuration) { - return new Promise((resolve, reject) => { - this._databases.resizeCluster(clusterId, configuration) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._databases = this._instance.databases; + } + /** + * Trigers the getAllClusters function of Databases + * @param {StringKeyword} tagName - Data required for getAllClusters + * @param {BooleanKeyword} includeAll - Data required for getAllClusters + * @param {NumberKeyword} page - Data required for getAllClusters + * @param {NumberKeyword} pageSize - Data required for getAllClusters + * @returns {Promise} + */ + getClusters( + tagName, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._databases + .getAllClusters(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createCluster function of Databases + * @param {DatabaseCreateClusterRequest} clusterOptions - Data required for createCluster + * @returns {Promise} + */ + createCluster(clusterOptions) { + return new Promise((resolve, reject) => { + this._databases + .createCluster(clusterOptions) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getClusterById function of Databases + * @param {StringKeyword} clusterId - Data required for getClusterById + * @returns {Promise} + */ + getCluster(clusterId) { + return new Promise((resolve, reject) => { + this._databases + .getClusterById(clusterId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the resizeCluster function of Databases + * @param {StringKeyword} clusterId - Data required for resizeCluster + * @param {DatabaseResizeClusterRequest} configuration - Data required for resizeCluster + * @returns {Promise} + */ + updateCluster(clusterId, configuration) { + return new Promise((resolve, reject) => { + this._databases + .resizeCluster(clusterId, configuration) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_NoSql; diff --git a/generator/generatedClasses/DO/management/do-keyManagement.js b/generator/generatedClasses/DO/management/do-keyManagement.js index d4e8f11a..5af44abb 100644 --- a/generator/generatedClasses/DO/management/do-keyManagement.js +++ b/generator/generatedClasses/DO/management/do-keyManagement.js @@ -1,69 +1,78 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Keys object -* @category Digital Ocean -*/ + * Class to create a Keys object + * @category Digital Ocean + */ class DO_KeyManagement { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._keys = this._instance.keys; - } - /** - * Trigers the getAll function of Keys - * @param {StringKeyword} tagName - Data required for getAll - * @param {BooleanKeyword} includeAll - Data required for getAll - * @param {NumberKeyword} page - Data required for getAll - * @param {NumberKeyword} pageSize - Data required for getAll - * @returns {Promise} - */ - list(tagName, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._keys.getAll(tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Keys - * @param {NumberKeyword} keyId - Data required for getById - * @returns {Promise} - */ - describeKey(keyId) { - return new Promise((resolve, reject) => { - this._keys.getById(keyId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the add function of Keys - * @param {AddKeyRequest} addKeyRequest - Data required for add - * @returns {Promise} - */ - createKey(addKeyRequest) { - return new Promise((resolve, reject) => { - this._keys.add(addKeyRequest) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of Keys - * @param {StringKeyword} identifier - Data required for delete - * @returns {Promise} - */ - deleteKey(identifier) { - return new Promise((resolve, reject) => { - this._keys.delete(identifier) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._keys = this._instance.keys; + } + /** + * Trigers the getAll function of Keys + * @param {StringKeyword} tagName - Data required for getAll + * @param {BooleanKeyword} includeAll - Data required for getAll + * @param {NumberKeyword} page - Data required for getAll + * @param {NumberKeyword} pageSize - Data required for getAll + * @returns {Promise} + */ + list( + tagName, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._keys + .getAll(tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Keys + * @param {NumberKeyword} keyId - Data required for getById + * @returns {Promise} + */ + describeKey(keyId) { + return new Promise((resolve, reject) => { + this._keys + .getById(keyId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the add function of Keys + * @param {AddKeyRequest} addKeyRequest - Data required for add + * @returns {Promise} + */ + createKey(addKeyRequest) { + return new Promise((resolve, reject) => { + this._keys + .add(addKeyRequest) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of Keys + * @param {StringKeyword} identifier - Data required for delete + * @returns {Promise} + */ + deleteKey(identifier) { + return new Promise((resolve, reject) => { + this._keys + .delete(identifier) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_KeyManagement; diff --git a/generator/generatedClasses/DO/network/do-DNS.js b/generator/generatedClasses/DO/network/do-DNS.js index ced40bd0..39ffe53e 100644 --- a/generator/generatedClasses/DO/network/do-DNS.js +++ b/generator/generatedClasses/DO/network/do-DNS.js @@ -1,87 +1,98 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Domains object -* @category Digital Ocean -*/ + * Class to create a Domains object + * @category Digital Ocean + */ class DO_DNS { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._domains = this._instance.domains; - } - /** - * Trigers the getAllRecords function of Domains - * @param {StringKeyword} domainName - Data required for getAllRecords - * @param {StringKeyword} tagName - Data required for getAllRecords - * @param {BooleanKeyword} includeAll - Data required for getAllRecords - * @param {NumberKeyword} page - Data required for getAllRecords - * @param {NumberKeyword} pageSize - Data required for getAllRecords - * @returns {Promise} - */ - getRecords(domainName, tagName, includeAll = undefined, page = undefined, pageSize = undefined) { - return new Promise((resolve, reject) => { - this._domains.getAllRecords(domainName, tagName, includeAll, page, pageSize) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the createRecord function of Domains - * @param {StringKeyword} domainName - Data required for createRecord - * @param {DomainRecordRequestOptions} options - Data required for createRecord - * @returns {Promise} - */ - createRecord(domainName, options) { - return new Promise((resolve, reject) => { - this._domains.createRecord(domainName, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getRecord function of Domains - * @param {StringKeyword} domainName - Data required for getRecord - * @param {StringKeyword} recordId - Data required for getRecord - * @returns {Promise} - */ - getRecord(domainName, recordId) { - return new Promise((resolve, reject) => { - this._domains.getRecord(domainName, recordId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteRecord function of Domains - * @param {StringKeyword} domainName - Data required for deleteRecord - * @param {StringKeyword} recordId - Data required for deleteRecord - * @returns {Promise} - */ - deleteRecord(domainName, recordId) { - return new Promise((resolve, reject) => { - this._domains.deleteRecord(domainName, recordId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the updateRecord function of Domains - * @param {StringKeyword} domainName - Data required for updateRecord - * @param {StringKeyword} recordId - Data required for updateRecord - * @param {DomainRecordRequestOptions} options - Data required for updateRecord - * @returns {Promise} - */ - changeRecordSets(domainName, recordId, options) { - return new Promise((resolve, reject) => { - this._domains.updateRecord(domainName, recordId, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._domains = this._instance.domains; + } + /** + * Trigers the getAllRecords function of Domains + * @param {StringKeyword} domainName - Data required for getAllRecords + * @param {StringKeyword} tagName - Data required for getAllRecords + * @param {BooleanKeyword} includeAll - Data required for getAllRecords + * @param {NumberKeyword} page - Data required for getAllRecords + * @param {NumberKeyword} pageSize - Data required for getAllRecords + * @returns {Promise} + */ + getRecords( + domainName, + tagName, + includeAll = undefined, + page = undefined, + pageSize = undefined + ) { + return new Promise((resolve, reject) => { + this._domains + .getAllRecords(domainName, tagName, includeAll, page, pageSize) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the createRecord function of Domains + * @param {StringKeyword} domainName - Data required for createRecord + * @param {DomainRecordRequestOptions} options - Data required for createRecord + * @returns {Promise} + */ + createRecord(domainName, options) { + return new Promise((resolve, reject) => { + this._domains + .createRecord(domainName, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getRecord function of Domains + * @param {StringKeyword} domainName - Data required for getRecord + * @param {StringKeyword} recordId - Data required for getRecord + * @returns {Promise} + */ + getRecord(domainName, recordId) { + return new Promise((resolve, reject) => { + this._domains + .getRecord(domainName, recordId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteRecord function of Domains + * @param {StringKeyword} domainName - Data required for deleteRecord + * @param {StringKeyword} recordId - Data required for deleteRecord + * @returns {Promise} + */ + deleteRecord(domainName, recordId) { + return new Promise((resolve, reject) => { + this._domains + .deleteRecord(domainName, recordId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the updateRecord function of Domains + * @param {StringKeyword} domainName - Data required for updateRecord + * @param {StringKeyword} recordId - Data required for updateRecord + * @param {DomainRecordRequestOptions} options - Data required for updateRecord + * @returns {Promise} + */ + changeRecordSets(domainName, recordId, options) { + return new Promise((resolve, reject) => { + this._domains + .updateRecord(domainName, recordId, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_DNS; diff --git a/generator/generatedClasses/DO/network/do-loadBalancer.js b/generator/generatedClasses/DO/network/do-loadBalancer.js index cd02d3c1..665ebb2f 100644 --- a/generator/generatedClasses/DO/network/do-loadBalancer.js +++ b/generator/generatedClasses/DO/network/do-loadBalancer.js @@ -1,66 +1,70 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a LoadBalancers object -* @category Digital Ocean -*/ + * Class to create a LoadBalancers object + * @category Digital Ocean + */ class DO_LoadBalancer { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._loadBalancers = this._instance.loadBalancers; - } - /** - * Trigers the create function of LoadBalancers - * @param {LoadBalancerCreationOptions} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._loadBalancers.create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getAll function of LoadBalancers - * @returns {Promise} - */ - list() { - return new Promise((resolve, reject) => { - this._loadBalancers.getAll() - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the update function of LoadBalancers - * @param {StringKeyword} loadBalancerId - Data required for update - * @param {AnyKeyword} options - Data required for update - * @returns {Promise} - */ - update(loadBalancerId, options) { - return new Promise((resolve, reject) => { - this._loadBalancers.update(loadBalancerId, options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the delete function of LoadBalancers - * @param {StringKeyword} loadBalancerId - Data required for delete - * @returns {Promise} - */ - delete(loadBalancerId) { - return new Promise((resolve, reject) => { - this._loadBalancers.delete(loadBalancerId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._loadBalancers = this._instance.loadBalancers; + } + /** + * Trigers the create function of LoadBalancers + * @param {LoadBalancerCreationOptions} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._loadBalancers + .create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getAll function of LoadBalancers + * @returns {Promise} + */ + list() { + return new Promise((resolve, reject) => { + this._loadBalancers + .getAll() + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the update function of LoadBalancers + * @param {StringKeyword} loadBalancerId - Data required for update + * @param {AnyKeyword} options - Data required for update + * @returns {Promise} + */ + update(loadBalancerId, options) { + return new Promise((resolve, reject) => { + this._loadBalancers + .update(loadBalancerId, options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the delete function of LoadBalancers + * @param {StringKeyword} loadBalancerId - Data required for delete + * @returns {Promise} + */ + delete(loadBalancerId) { + return new Promise((resolve, reject) => { + this._loadBalancers + .delete(loadBalancerId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_LoadBalancer; diff --git a/generator/generatedClasses/DO/storage/do-blockStorage.js b/generator/generatedClasses/DO/storage/do-blockStorage.js index 5724610c..ce6bc60e 100644 --- a/generator/generatedClasses/DO/storage/do-blockStorage.js +++ b/generator/generatedClasses/DO/storage/do-blockStorage.js @@ -1,66 +1,70 @@ /*This is an auto generated class, please do not change.*/ /** -* Class to create a Volumes object -* @category Digital Ocean -*/ + * Class to create a Volumes object + * @category Digital Ocean + */ class DO_BlockStorage { - /** - * - * @param {module} do DO SDK - * @param {object} options SDK options - */ - constructor(dosdk, dotoken) { - this._DO = dosdk; - this._instance = new this._DO(dotoken); - this._volumes = this._instance.volumes; - } - /** - * Trigers the getAll function of Volumes - * @param {StringKeyword} region - Data required for getAll - * @returns {Promise} - */ - list(region) { - return new Promise((resolve, reject) => { - this._volumes.getAll(region) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the create function of Volumes - * @param {VolumeCreationOptions} options - Data required for create - * @returns {Promise} - */ - create(options) { - return new Promise((resolve, reject) => { - this._volumes.create(options) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the getById function of Volumes - * @param {StringKeyword} volumeId - Data required for getById - * @returns {Promise} - */ - describe(volumeId) { - return new Promise((resolve, reject) => { - this._volumes.getById(volumeId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } - /** - * Trigers the deleteById function of Volumes - * @param {StringKeyword} volumeId - Data required for deleteById - * @returns {Promise} - */ - delete(volumeId) { - return new Promise((resolve, reject) => { - this._volumes.deleteById(volumeId) - .then(data => resolve(data)) - .catch(err => reject(err)); - }); - } + /** + * + * @param {module} do DO SDK + * @param {object} options SDK options + */ + constructor(dosdk, dotoken) { + this._DO = dosdk; + this._instance = new this._DO(dotoken); + this._volumes = this._instance.volumes; + } + /** + * Trigers the getAll function of Volumes + * @param {StringKeyword} region - Data required for getAll + * @returns {Promise} + */ + list(region) { + return new Promise((resolve, reject) => { + this._volumes + .getAll(region) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the create function of Volumes + * @param {VolumeCreationOptions} options - Data required for create + * @returns {Promise} + */ + create(options) { + return new Promise((resolve, reject) => { + this._volumes + .create(options) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the getById function of Volumes + * @param {StringKeyword} volumeId - Data required for getById + * @returns {Promise} + */ + describe(volumeId) { + return new Promise((resolve, reject) => { + this._volumes + .getById(volumeId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } + /** + * Trigers the deleteById function of Volumes + * @param {StringKeyword} volumeId - Data required for deleteById + * @returns {Promise} + */ + delete(volumeId) { + return new Promise((resolve, reject) => { + this._volumes + .deleteById(volumeId) + .then(data => resolve(data)) + .catch(err => reject(err)); + }); + } } module.exports = DO_BlockStorage; diff --git a/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js b/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js index dd66d85f..5ff02a87 100644 --- a/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js +++ b/generator/generatedClasses/googleCloud/artificialinteligence/gcp-translation.js @@ -1,101 +1,106 @@ -const { TranslationServiceClient } = require("@google-cloud/translate"); +const { TranslationServiceClient } = require('@google-cloud/translate'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Translation object * @category Google Cloud */ class GCP_Translation { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._translationServiceClient = new TranslationServiceClient(config); - } - /** - * Trigers the translateText function of undefined - * @param {TypeReference} request - Data required for translateText - * @param {TypeReference} [options] - Data required for translateText - * @returns {Promise} - */ - translate(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient.translateText(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the batchTranslateText function of undefined - * @param {TypeReference} request - Data required for batchTranslateText - * @param {TypeReference} [options] - Data required for batchTranslateText - * @returns {Promise} - */ - batchTranslate(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient.batchTranslateText(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getGlossary function of undefined - * @param {TypeReference} request - Data required for getGlossary - * @param {TypeReference} [options] - Data required for getGlossary - * @returns {Promise} - */ - getGlossary(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient.getGlossary(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createGlossary function of undefined - * @param {TypeReference} request - Data required for createGlossary - * @param {TypeReference} [options] - Data required for createGlossary - * @returns {Promise} - */ - createGlossary(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient.createGlossary(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the detectLanguage function of undefined - * @param {TypeReference} request - Data required for detectLanguage - * @param {TypeReference} [options] - Data required for detectLanguage - * @returns {Promise} - */ - detectLanguage(request, options = undefined) { - return new Promise((resolve, reject) => { - this._translationServiceClient.detectLanguage(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._translationServiceClient = new TranslationServiceClient(config); + } + /** + * Trigers the translateText function of undefined + * @param {TypeReference} request - Data required for translateText + * @param {TypeReference} [options] - Data required for translateText + * @returns {Promise} + */ + translate(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient + .translateText(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the batchTranslateText function of undefined + * @param {TypeReference} request - Data required for batchTranslateText + * @param {TypeReference} [options] - Data required for batchTranslateText + * @returns {Promise} + */ + batchTranslate(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient + .batchTranslateText(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getGlossary function of undefined + * @param {TypeReference} request - Data required for getGlossary + * @param {TypeReference} [options] - Data required for getGlossary + * @returns {Promise} + */ + getGlossary(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient + .getGlossary(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createGlossary function of undefined + * @param {TypeReference} request - Data required for createGlossary + * @param {TypeReference} [options] - Data required for createGlossary + * @returns {Promise} + */ + createGlossary(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient + .createGlossary(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the detectLanguage function of undefined + * @param {TypeReference} request - Data required for detectLanguage + * @param {TypeReference} [options] - Data required for detectLanguage + * @returns {Promise} + */ + detectLanguage(request, options = undefined) { + return new Promise((resolve, reject) => { + this._translationServiceClient + .detectLanguage(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_Translation; diff --git a/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js b/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js index 340e295b..8b2d00e5 100644 --- a/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js +++ b/generator/generatedClasses/googleCloud/compute/gcp-kubernetes.js @@ -1,169 +1,178 @@ -const { ClusterManagerClient } = require("@google-cloud/container"); +const { ClusterManagerClient } = require('@google-cloud/container'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Kubernetes object * @category Google Cloud */ class GCP_Kubernetes { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._clusterManagerClient = new ClusterManagerClient(config); - } - /** - * Trigers the createCluster function of undefined - * @param {TypeReference} request - Data required for createCluster - * @param {TypeReference} [options] - Data required for createCluster - * @returns {Promise} - */ - create(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.createCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteCluster function of undefined - * @param {TypeReference} request - Data required for deleteCluster - * @param {TypeReference} [options] - Data required for deleteCluster - * @returns {Promise} - */ - delete(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.deleteCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listClusters function of undefined - * @param {TypeReference} request - Data required for listClusters - * @param {TypeReference} [options] - Data required for listClusters - * @returns {Promise} - */ - listClusters(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.listClusters(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getCluster function of undefined - * @param {TypeReference} request - Data required for getCluster - * @param {TypeReference} [options] - Data required for getCluster - * @returns {Promise} - */ - describeCluster(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.getCluster(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createNodePool function of undefined - * @param {TypeReference} request - Data required for createNodePool - * @param {TypeReference} [options] - Data required for createNodePool - * @returns {Promise} - */ - createNodeGroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.createNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteNodePool function of undefined - * @param {TypeReference} request - Data required for deleteNodePool - * @param {TypeReference} [options] - Data required for deleteNodePool - * @returns {Promise} - */ - deleteNodegroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.deleteNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getNodePool function of undefined - * @param {TypeReference} request - Data required for getNodePool - * @param {TypeReference} [options] - Data required for getNodePool - * @returns {Promise} - */ - describeNodeGroup(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.getNodePool(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listNodePools function of undefined - * @param {TypeReference} request - Data required for listNodePools - * @param {TypeReference} [options] - Data required for listNodePools - * @returns {Promise} - */ - listNodegroups(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.listNodePools(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the setAddonsConfig function of undefined - * @param {TypeReference} request - Data required for setAddonsConfig - * @param {TypeReference} [options] - Data required for setAddonsConfig - * @returns {Promise} - */ - updateConfig(request, options = undefined) { - return new Promise((resolve, reject) => { - this._clusterManagerClient.setAddonsConfig(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._clusterManagerClient = new ClusterManagerClient(config); + } + /** + * Trigers the createCluster function of undefined + * @param {TypeReference} request - Data required for createCluster + * @param {TypeReference} [options] - Data required for createCluster + * @returns {Promise} + */ + create(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .createCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteCluster function of undefined + * @param {TypeReference} request - Data required for deleteCluster + * @param {TypeReference} [options] - Data required for deleteCluster + * @returns {Promise} + */ + delete(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .deleteCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listClusters function of undefined + * @param {TypeReference} request - Data required for listClusters + * @param {TypeReference} [options] - Data required for listClusters + * @returns {Promise} + */ + listClusters(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .listClusters(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getCluster function of undefined + * @param {TypeReference} request - Data required for getCluster + * @param {TypeReference} [options] - Data required for getCluster + * @returns {Promise} + */ + describeCluster(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .getCluster(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createNodePool function of undefined + * @param {TypeReference} request - Data required for createNodePool + * @param {TypeReference} [options] - Data required for createNodePool + * @returns {Promise} + */ + createNodeGroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .createNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteNodePool function of undefined + * @param {TypeReference} request - Data required for deleteNodePool + * @param {TypeReference} [options] - Data required for deleteNodePool + * @returns {Promise} + */ + deleteNodegroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .deleteNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getNodePool function of undefined + * @param {TypeReference} request - Data required for getNodePool + * @param {TypeReference} [options] - Data required for getNodePool + * @returns {Promise} + */ + describeNodeGroup(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .getNodePool(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listNodePools function of undefined + * @param {TypeReference} request - Data required for listNodePools + * @param {TypeReference} [options] - Data required for listNodePools + * @returns {Promise} + */ + listNodegroups(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .listNodePools(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the setAddonsConfig function of undefined + * @param {TypeReference} request - Data required for setAddonsConfig + * @param {TypeReference} [options] - Data required for setAddonsConfig + * @returns {Promise} + */ + updateConfig(request, options = undefined) { + return new Promise((resolve, reject) => { + this._clusterManagerClient + .setAddonsConfig(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_Kubernetes; diff --git a/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js b/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js index a1364ad9..e783c97f 100644 --- a/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js +++ b/generator/generatedClasses/googleCloud/database/gcp-RDBMS.js @@ -1,128 +1,138 @@ -const { DatabaseAdminClient } = require("@google-cloud/spanner"); +const { DatabaseAdminClient } = require('@google-cloud/spanner'); /*This is an auto generated class, please do not change.*/ /** * Class to create a RDBMS object * @category Google Cloud */ class GCP_RDBMS { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._databaseAdminClient = new DatabaseAdminClient(config); - } - /** - * Trigers the createDatabase function of undefined - * @param {TypeReference} request - Data required for createDatabase - * @param {TypeReference} [options] - Data required for createDatabase - * @returns {Promise} - */ - createDatabse(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.createDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the dropDatabase function of undefined - * @param {TypeReference} request - Data required for dropDatabase - * @param {TypeReference} [options] - Data required for dropDatabase - * @returns {Promise} - */ - deleteDatabase(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.dropDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createBackup function of undefined - * @param {TypeReference} request - Data required for createBackup - * @param {TypeReference} [options] - Data required for createBackup - * @returns {Promise} - */ - createSnapshots(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.createBackup(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateDatabaseDdl function of undefined - * @param {TypeReference} request - Data required for updateDatabaseDdl - * @param {TypeReference} [options] - Data required for updateDatabaseDdl - * @returns {Promise} - */ - modifyDB(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.updateDatabaseDdl(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the restoreDatabase function of undefined - * @param {TypeReference} request - Data required for restoreDatabase - * @param {TypeReference} [options] - Data required for restoreDatabase - * @returns {Promise} - */ - restoreDatabase(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.restoreDatabase(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteBackup function of undefined - * @param {TypeReference} request - Data required for deleteBackup - * @param {TypeReference} [options] - Data required for deleteBackup - * @returns {Promise} - */ - deleteDBSnapshot(request, options = undefined) { - return new Promise((resolve, reject) => { - this._databaseAdminClient.deleteBackup(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the databasePath function of undefined - * @param {StringKeyword} project - Data required for databasePath - * @param {StringKeyword} instance - Data required for databasePath - * @param {StringKeyword} database - Data required for databasePath - * @returns {Promise} - */ - databasePath(project, instance, database) { - return this._databaseAdminClient.databasePath(project, instance, database); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._databaseAdminClient = new DatabaseAdminClient(config); + } + /** + * Trigers the createDatabase function of undefined + * @param {TypeReference} request - Data required for createDatabase + * @param {TypeReference} [options] - Data required for createDatabase + * @returns {Promise} + */ + createDatabse(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .createDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the dropDatabase function of undefined + * @param {TypeReference} request - Data required for dropDatabase + * @param {TypeReference} [options] - Data required for dropDatabase + * @returns {Promise} + */ + deleteDatabase(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .dropDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createBackup function of undefined + * @param {TypeReference} request - Data required for createBackup + * @param {TypeReference} [options] - Data required for createBackup + * @returns {Promise} + */ + createSnapshots(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .createBackup(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateDatabaseDdl function of undefined + * @param {TypeReference} request - Data required for updateDatabaseDdl + * @param {TypeReference} [options] - Data required for updateDatabaseDdl + * @returns {Promise} + */ + modifyDB(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .updateDatabaseDdl(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the restoreDatabase function of undefined + * @param {TypeReference} request - Data required for restoreDatabase + * @param {TypeReference} [options] - Data required for restoreDatabase + * @returns {Promise} + */ + restoreDatabase(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .restoreDatabase(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteBackup function of undefined + * @param {TypeReference} request - Data required for deleteBackup + * @param {TypeReference} [options] - Data required for deleteBackup + * @returns {Promise} + */ + deleteDBSnapshot(request, options = undefined) { + return new Promise((resolve, reject) => { + this._databaseAdminClient + .deleteBackup(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the databasePath function of undefined + * @param {StringKeyword} project - Data required for databasePath + * @param {StringKeyword} instance - Data required for databasePath + * @param {StringKeyword} database - Data required for databasePath + * @returns {Promise} + */ + databasePath(project, instance, database) { + return this._databaseAdminClient.databasePath( + project, + instance, + database + ); + } } module.exports = GCP_RDBMS; diff --git a/generator/generatedClasses/googleCloud/database/gcp-noSql.js b/generator/generatedClasses/googleCloud/database/gcp-noSql.js index 960ce486..626a8256 100644 --- a/generator/generatedClasses/googleCloud/database/gcp-noSql.js +++ b/generator/generatedClasses/googleCloud/database/gcp-noSql.js @@ -1,76 +1,79 @@ -const { FirestoreClient } = require("@google-cloud/firestore"); +const { FirestoreClient } = require('@google-cloud/firestore'); /*This is an auto generated class, please do not change.*/ /** * Class to create a NoSql object * @category Google Cloud */ class GCP_NoSql { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._firestoreClient = new FirestoreClient(config); - } - /** - * Trigers the createDocument function of undefined - * @param {TypeReference} request - Data required for createDocument - * @param {TypeReference} [options] - Data required for createDocument - * @returns {Promise} - */ - createItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient.createDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteDocument function of undefined - * @param {TypeReference} request - Data required for deleteDocument - * @param {TypeReference} [options] - Data required for deleteDocument - * @returns {Promise} - */ - deleteItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient.deleteDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateDocument function of undefined - * @param {TypeReference} request - Data required for updateDocument - * @param {TypeReference} [options] - Data required for updateDocument - * @returns {Promise} - */ - updateItem(request, options = undefined) { - return new Promise((resolve, reject) => { - this._firestoreClient.updateDocument(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the runQuery function of undefined - * @param {TypeReference} [request] - Data required for runQuery - * @param {TypeReference} [options] - Data required for runQuery - * @returns {Promise} - */ - query(request = undefined, options = undefined) { - return this._firestoreClient.runQuery(request, options); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._firestoreClient = new FirestoreClient(config); + } + /** + * Trigers the createDocument function of undefined + * @param {TypeReference} request - Data required for createDocument + * @param {TypeReference} [options] - Data required for createDocument + * @returns {Promise} + */ + createItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient + .createDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteDocument function of undefined + * @param {TypeReference} request - Data required for deleteDocument + * @param {TypeReference} [options] - Data required for deleteDocument + * @returns {Promise} + */ + deleteItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient + .deleteDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateDocument function of undefined + * @param {TypeReference} request - Data required for updateDocument + * @param {TypeReference} [options] - Data required for updateDocument + * @returns {Promise} + */ + updateItem(request, options = undefined) { + return new Promise((resolve, reject) => { + this._firestoreClient + .updateDocument(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the runQuery function of undefined + * @param {TypeReference} [request] - Data required for runQuery + * @param {TypeReference} [options] - Data required for runQuery + * @returns {Promise} + */ + query(request = undefined, options = undefined) { + return this._firestoreClient.runQuery(request, options); + } } module.exports = GCP_NoSql; diff --git a/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js b/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js index 65c4ad71..e90fee97 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js +++ b/generator/generatedClasses/googleCloud/management/gcp-keyManagement.js @@ -1,102 +1,109 @@ -const { KeyManagementServiceClient } = require("@google-cloud/kms"); +const { KeyManagementServiceClient } = require('@google-cloud/kms'); /*This is an auto generated class, please do not change.*/ /** * Class to create a KeyManagement object * @category Google Cloud */ class GCP_KeyManagement { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._keyManagementServiceClient = new KeyManagementServiceClient(config); - } - /** - * Trigers the createCryptoKey function of undefined - * @param {TypeReference} request - Data required for createCryptoKey - * @param {TypeReference} [options] - Data required for createCryptoKey - * @returns {Promise} - */ - createKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient.createCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the destroyCryptoKeyVersion function of undefined - * @param {TypeReference} request - Data required for destroyCryptoKeyVersion - * @param {TypeReference} [options] - Data required for destroyCryptoKeyVersion - * @returns {Promise} - */ - deleteKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient.destroyCryptoKeyVersion(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateCryptoKey function of undefined - * @param {TypeReference} request - Data required for updateCryptoKey - * @param {TypeReference} [options] - Data required for updateCryptoKey - * @returns {Promise} - */ - update(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient.updateCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getCryptoKey function of undefined - * @param {TypeReference} request - Data required for getCryptoKey - * @param {TypeReference} [options] - Data required for getCryptoKey - * @returns {Promise} - */ - describeKey(request, options = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient.getCryptoKey(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the setIamPolicy function of undefined - * @param {TypeReference} request - Data required for setIamPolicy - * @param {UnionType} [options] - Data required for setIamPolicy - * @param {TypeReference} [callback] - Data required for setIamPolicy - * @returns {Promise} - */ - putKeyPolicy(request, options = undefined, callback = undefined) { - return new Promise((resolve, reject) => { - this._keyManagementServiceClient.setIamPolicy(request, options, callback) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._keyManagementServiceClient = new KeyManagementServiceClient( + config + ); + } + /** + * Trigers the createCryptoKey function of undefined + * @param {TypeReference} request - Data required for createCryptoKey + * @param {TypeReference} [options] - Data required for createCryptoKey + * @returns {Promise} + */ + createKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient + .createCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the destroyCryptoKeyVersion function of undefined + * @param {TypeReference} request - Data required for destroyCryptoKeyVersion + * @param {TypeReference} [options] - Data required for destroyCryptoKeyVersion + * @returns {Promise} + */ + deleteKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient + .destroyCryptoKeyVersion(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateCryptoKey function of undefined + * @param {TypeReference} request - Data required for updateCryptoKey + * @param {TypeReference} [options] - Data required for updateCryptoKey + * @returns {Promise} + */ + update(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient + .updateCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getCryptoKey function of undefined + * @param {TypeReference} request - Data required for getCryptoKey + * @param {TypeReference} [options] - Data required for getCryptoKey + * @returns {Promise} + */ + describeKey(request, options = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient + .getCryptoKey(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the setIamPolicy function of undefined + * @param {TypeReference} request - Data required for setIamPolicy + * @param {UnionType} [options] - Data required for setIamPolicy + * @param {TypeReference} [callback] - Data required for setIamPolicy + * @returns {Promise} + */ + putKeyPolicy(request, options = undefined, callback = undefined) { + return new Promise((resolve, reject) => { + this._keyManagementServiceClient + .setIamPolicy(request, options, callback) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_KeyManagement; diff --git a/generator/generatedClasses/googleCloud/management/gcp-monitoring.js b/generator/generatedClasses/googleCloud/management/gcp-monitoring.js index 4c2c2176..4c03f5d1 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-monitoring.js +++ b/generator/generatedClasses/googleCloud/management/gcp-monitoring.js @@ -1,111 +1,116 @@ -const { AlertPolicyServiceClient } = require("@google-cloud/monitoring"); -const { MetricServiceClient } = require("@google-cloud/monitoring"); +const { AlertPolicyServiceClient } = require('@google-cloud/monitoring'); +const { MetricServiceClient } = require('@google-cloud/monitoring'); /*This is an auto generated class, please do not change.*/ /** * Class to create a Monitoring object * @category Google Cloud */ class GCP_Monitoring { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._alertPolicyServiceClient = new AlertPolicyServiceClient(config); - this._metricServiceClient = new MetricServiceClient(config); - } - /** - * Trigers the createAlertPolicy function of undefined - * @param {TypeReference} request - Data required for createAlertPolicy - * @param {TypeReference} [options] - Data required for createAlertPolicy - * @returns {Promise} - */ - createAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient.createAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteAlertPolicy function of undefined - * @param {TypeReference} request - Data required for deleteAlertPolicy - * @param {TypeReference} [options] - Data required for deleteAlertPolicy - * @returns {Promise} - */ - deleteAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient.deleteAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the updateAlertPolicy function of undefined - * @param {TypeReference} request - Data required for updateAlertPolicy - * @param {TypeReference} [options] - Data required for updateAlertPolicy - * @returns {Promise} - */ - updateAlarm(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient.updateAlertPolicy(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listAlertPolicies function of undefined - * @param {TypeReference} request - Data required for listAlertPolicies - * @param {TypeReference} [options] - Data required for listAlertPolicies - * @returns {Promise} - */ - listAlarms(request, options = undefined) { - return new Promise((resolve, reject) => { - this._alertPolicyServiceClient.listAlertPolicies(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getMetricDescriptor function of undefined - * @param {TypeReference} request - Data required for getMetricDescriptor - * @param {TypeReference} [options] - Data required for getMetricDescriptor - * @returns {Promise} - */ - getMetricData(request, options = undefined) { - return new Promise((resolve, reject) => { - this._metricServiceClient.getMetricDescriptor(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the projectPath function of undefined - * @param {StringKeyword} project - Data required for projectPath - * @returns {Promise} - */ - projectPath(project) { - return this._alertPolicyServiceClient.projectPath(project); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._alertPolicyServiceClient = new AlertPolicyServiceClient(config); + this._metricServiceClient = new MetricServiceClient(config); + } + /** + * Trigers the createAlertPolicy function of undefined + * @param {TypeReference} request - Data required for createAlertPolicy + * @param {TypeReference} [options] - Data required for createAlertPolicy + * @returns {Promise} + */ + createAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient + .createAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteAlertPolicy function of undefined + * @param {TypeReference} request - Data required for deleteAlertPolicy + * @param {TypeReference} [options] - Data required for deleteAlertPolicy + * @returns {Promise} + */ + deleteAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient + .deleteAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the updateAlertPolicy function of undefined + * @param {TypeReference} request - Data required for updateAlertPolicy + * @param {TypeReference} [options] - Data required for updateAlertPolicy + * @returns {Promise} + */ + updateAlarm(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient + .updateAlertPolicy(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listAlertPolicies function of undefined + * @param {TypeReference} request - Data required for listAlertPolicies + * @param {TypeReference} [options] - Data required for listAlertPolicies + * @returns {Promise} + */ + listAlarms(request, options = undefined) { + return new Promise((resolve, reject) => { + this._alertPolicyServiceClient + .listAlertPolicies(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getMetricDescriptor function of undefined + * @param {TypeReference} request - Data required for getMetricDescriptor + * @param {TypeReference} [options] - Data required for getMetricDescriptor + * @returns {Promise} + */ + getMetricData(request, options = undefined) { + return new Promise((resolve, reject) => { + this._metricServiceClient + .getMetricDescriptor(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the projectPath function of undefined + * @param {StringKeyword} project - Data required for projectPath + * @returns {Promise} + */ + projectPath(project) { + return this._alertPolicyServiceClient.projectPath(project); + } } module.exports = GCP_Monitoring; diff --git a/generator/generatedClasses/googleCloud/management/gcp-notificationService.js b/generator/generatedClasses/googleCloud/management/gcp-notificationService.js index fd9ab000..447558f5 100644 --- a/generator/generatedClasses/googleCloud/management/gcp-notificationService.js +++ b/generator/generatedClasses/googleCloud/management/gcp-notificationService.js @@ -1,154 +1,162 @@ -const { PublisherClient } = require("@google-cloud/pubsub"); -const { SubscriberClient } = require("@google-cloud/pubsub"); +const { PublisherClient } = require('@google-cloud/pubsub'); +const { SubscriberClient } = require('@google-cloud/pubsub'); /*This is an auto generated class, please do not change.*/ /** * Class to create a NotificationService object * @category Google Cloud */ class GCP_NotificationService { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._publisherClient = new PublisherClient(config); - this._subscriberClient = new SubscriberClient(config); - } - /** - * Trigers the createTopic function of undefined - * @param {TypeReference} request - Data required for createTopic - * @param {TypeReference} [options] - Data required for createTopic - * @returns {Promise} - */ - createTopic(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.createTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteTopic function of undefined - * @param {TypeReference} request - Data required for deleteTopic - * @param {TypeReference} [options] - Data required for deleteTopic - * @returns {Promise} - */ - deleteTopic(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.deleteTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getTopic function of undefined - * @param {TypeReference} request - Data required for getTopic - * @param {TypeReference} [options] - Data required for getTopic - * @returns {Promise} - */ - getTopicAttributes(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.getTopic(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listTopicSubscriptions function of undefined - * @param {TypeReference} request - Data required for listTopicSubscriptions - * @param {TypeReference} [options] - Data required for listTopicSubscriptions - * @returns {Promise} - */ - listSubscriptions(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.listTopicSubscriptions(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createSubscription function of undefined - * @param {TypeReference} request - Data required for createSubscription - * @param {TypeReference} [options] - Data required for createSubscription - * @returns {Promise} - */ - subscribe(request, options = undefined) { - return new Promise((resolve, reject) => { - this._subscriberClient.createSubscription(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the publish function of undefined - * @param {TypeReference} request - Data required for publish - * @param {TypeReference} [options] - Data required for publish - * @returns {Promise} - */ - publish(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.publish(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the listTopics function of undefined - * @param {TypeReference} request - Data required for listTopics - * @param {TypeReference} [options] - Data required for listTopics - * @returns {Promise} - */ - listTopics(request, options = undefined) { - return new Promise((resolve, reject) => { - this._publisherClient.listTopics(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the deleteSubscription function of undefined - * @param {TypeReference} request - Data required for deleteSubscription - * @param {TypeReference} [options] - Data required for deleteSubscription - * @returns {Promise} - */ - unsubscribe(request, options = undefined) { - return new Promise((resolve, reject) => { - this._subscriberClient.deleteSubscription(request, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._publisherClient = new PublisherClient(config); + this._subscriberClient = new SubscriberClient(config); + } + /** + * Trigers the createTopic function of undefined + * @param {TypeReference} request - Data required for createTopic + * @param {TypeReference} [options] - Data required for createTopic + * @returns {Promise} + */ + createTopic(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .createTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteTopic function of undefined + * @param {TypeReference} request - Data required for deleteTopic + * @param {TypeReference} [options] - Data required for deleteTopic + * @returns {Promise} + */ + deleteTopic(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .deleteTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getTopic function of undefined + * @param {TypeReference} request - Data required for getTopic + * @param {TypeReference} [options] - Data required for getTopic + * @returns {Promise} + */ + getTopicAttributes(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .getTopic(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listTopicSubscriptions function of undefined + * @param {TypeReference} request - Data required for listTopicSubscriptions + * @param {TypeReference} [options] - Data required for listTopicSubscriptions + * @returns {Promise} + */ + listSubscriptions(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .listTopicSubscriptions(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createSubscription function of undefined + * @param {TypeReference} request - Data required for createSubscription + * @param {TypeReference} [options] - Data required for createSubscription + * @returns {Promise} + */ + subscribe(request, options = undefined) { + return new Promise((resolve, reject) => { + this._subscriberClient + .createSubscription(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the publish function of undefined + * @param {TypeReference} request - Data required for publish + * @param {TypeReference} [options] - Data required for publish + * @returns {Promise} + */ + publish(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .publish(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the listTopics function of undefined + * @param {TypeReference} request - Data required for listTopics + * @param {TypeReference} [options] - Data required for listTopics + * @returns {Promise} + */ + listTopics(request, options = undefined) { + return new Promise((resolve, reject) => { + this._publisherClient + .listTopics(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the deleteSubscription function of undefined + * @param {TypeReference} request - Data required for deleteSubscription + * @param {TypeReference} [options] - Data required for deleteSubscription + * @returns {Promise} + */ + unsubscribe(request, options = undefined) { + return new Promise((resolve, reject) => { + this._subscriberClient + .deleteSubscription(request, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_NotificationService; diff --git a/generator/generatedClasses/googleCloud/network/gcp-DNS.js b/generator/generatedClasses/googleCloud/network/gcp-DNS.js index b1ce2e6f..eadb0c8a 100644 --- a/generator/generatedClasses/googleCloud/network/gcp-DNS.js +++ b/generator/generatedClasses/googleCloud/network/gcp-DNS.js @@ -1,97 +1,101 @@ -const { DNS } = require("@google-cloud/dns"); +const { DNS } = require('@google-cloud/dns'); /*This is an auto generated class, please do not change.*/ /** * Class to create a dns object * @category Google Cloud */ class GCP_dns { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._dns = new DNS(config); - } - /** - * Trigers the getZones function of dns - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - listZones(query = undefined) { - return new Promise((resolve, reject) => { - this._dns.getZones(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the create function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} config - Mandatory parameter - * @returns {Promise} - */ - createZone(dns, config, identifier = undefined) { - return new Promise((resolve, reject) => { - dns.zone(identifier).create(config) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createChange function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} config - Mandatory parameter - * @returns {Promise} - */ - changeRecordSets(dns, config, identifier = undefined) { - return new Promise((resolve, reject) => { - dns.zone(identifier).createChange(config) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the delete function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - deleteZone(dns, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - dns.zone(identifier).delete(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the record function of dns - * @param {string} [identifier] - Optional parameter - * @param {DNS} dns - Mandatory parameter - * @param {StringKeyword} type - Mandatory parameter - * @param {TypeReference} metadata - Mandatory parameter - * @returns {Promise} - */ - record(dns, type, metadata) { - return this.dns.record(type, metadata); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._dns = new DNS(config); + } + /** + * Trigers the getZones function of dns + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + listZones(query = undefined) { + return new Promise((resolve, reject) => { + this._dns + .getZones(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the create function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} config - Mandatory parameter + * @returns {Promise} + */ + createZone(dns, config, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier) + .create(config) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createChange function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} config - Mandatory parameter + * @returns {Promise} + */ + changeRecordSets(dns, config, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier) + .createChange(config) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the delete function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + deleteZone(dns, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + dns.zone(identifier) + .delete(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the record function of dns + * @param {string} [identifier] - Optional parameter + * @param {DNS} dns - Mandatory parameter + * @param {StringKeyword} type - Mandatory parameter + * @param {TypeReference} metadata - Mandatory parameter + * @returns {Promise} + */ + record(dns, type, metadata) { + return this.dns.record(type, metadata); + } } module.exports = GCP_dns; diff --git a/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js b/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js index d92787eb..75ab8af4 100644 --- a/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js +++ b/generator/generatedClasses/googleCloud/storage/gcp-archivalStorage.js @@ -1,103 +1,111 @@ -const { Storage } = require("@google-cloud/storage"); +const { Storage } = require('@google-cloud/storage'); /*This is an auto generated class, please do not change.*/ /** * Class to create a storage object * @category Google Cloud */ class GCP_storage { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._storage = new Storage(config); - } - /** - * Trigers the deleteFiles function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - deleteFiles(storage, query = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage.bucket(identifier).deleteFiles(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the upload function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {StringKeyword} pathString - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - upload(storage, pathString, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage.bucket(identifier).upload(pathString, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the makePublic function of storage - * @param {string} [identifier] - Optional parameter - * @param {Bucket} bucket - Mandatory parameter - * @returns {Promise} - */ - makePublic(bucket, identifier = undefined) { - return new Promise((resolve, reject) => { - bucket.file(identifier).makePublic() - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createBucket function of storage - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [metadata] - Optional parameter - * @returns {Promise} - */ - create(name, metadata = undefined) { - return new Promise((resolve, reject) => { - this._storage.createBucket(name, metadata) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getBuckets function of storage - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._storage.getBuckets(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._storage = new Storage(config); + } + /** + * Trigers the deleteFiles function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + deleteFiles(storage, query = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage + .bucket(identifier) + .deleteFiles(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the upload function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {StringKeyword} pathString - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + upload(storage, pathString, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage + .bucket(identifier) + .upload(pathString, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the makePublic function of storage + * @param {string} [identifier] - Optional parameter + * @param {Bucket} bucket - Mandatory parameter + * @returns {Promise} + */ + makePublic(bucket, identifier = undefined) { + return new Promise((resolve, reject) => { + bucket + .file(identifier) + .makePublic() + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createBucket function of storage + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [metadata] - Optional parameter + * @returns {Promise} + */ + create(name, metadata = undefined) { + return new Promise((resolve, reject) => { + this._storage + .createBucket(name, metadata) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getBuckets function of storage + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._storage + .getBuckets(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_storage; diff --git a/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js b/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js index d92787eb..75ab8af4 100644 --- a/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js +++ b/generator/generatedClasses/googleCloud/storage/gcp-storageBucket.js @@ -1,103 +1,111 @@ -const { Storage } = require("@google-cloud/storage"); +const { Storage } = require('@google-cloud/storage'); /*This is an auto generated class, please do not change.*/ /** * Class to create a storage object * @category Google Cloud */ class GCP_storage { - /** - * - * @param {object} config Configuration object - */ - constructor(config) { - this._storage = new Storage(config); - } - /** - * Trigers the deleteFiles function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {TypeReference} [query] - Optional parameter - * @returns {Promise} - */ - deleteFiles(storage, query = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage.bucket(identifier).deleteFiles(query) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the upload function of storage - * @param {string} [identifier] - Optional parameter - * @param {Storage} storage - Mandatory parameter - * @param {StringKeyword} pathString - Mandatory parameter - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - upload(storage, pathString, options = undefined, identifier = undefined) { - return new Promise((resolve, reject) => { - storage.bucket(identifier).upload(pathString, options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the makePublic function of storage - * @param {string} [identifier] - Optional parameter - * @param {Bucket} bucket - Mandatory parameter - * @returns {Promise} - */ - makePublic(bucket, identifier = undefined) { - return new Promise((resolve, reject) => { - bucket.file(identifier).makePublic() - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the createBucket function of storage - * @param {StringKeyword} name - Mandatory parameter - * @param {TypeReference} [metadata] - Optional parameter - * @returns {Promise} - */ - create(name, metadata = undefined) { - return new Promise((resolve, reject) => { - this._storage.createBucket(name, metadata) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } - /** - * Trigers the getBuckets function of storage - * @param {TypeReference} [options] - Optional parameter - * @returns {Promise} - */ - list(options = undefined) { - return new Promise((resolve, reject) => { - this._storage.getBuckets(options) - .then(result => { - resolve(result); - }) - .catch(err => { - reject(err); - }); - }); - } + /** + * + * @param {object} config Configuration object + */ + constructor(config) { + this._storage = new Storage(config); + } + /** + * Trigers the deleteFiles function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {TypeReference} [query] - Optional parameter + * @returns {Promise} + */ + deleteFiles(storage, query = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage + .bucket(identifier) + .deleteFiles(query) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the upload function of storage + * @param {string} [identifier] - Optional parameter + * @param {Storage} storage - Mandatory parameter + * @param {StringKeyword} pathString - Mandatory parameter + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + upload(storage, pathString, options = undefined, identifier = undefined) { + return new Promise((resolve, reject) => { + storage + .bucket(identifier) + .upload(pathString, options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the makePublic function of storage + * @param {string} [identifier] - Optional parameter + * @param {Bucket} bucket - Mandatory parameter + * @returns {Promise} + */ + makePublic(bucket, identifier = undefined) { + return new Promise((resolve, reject) => { + bucket + .file(identifier) + .makePublic() + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the createBucket function of storage + * @param {StringKeyword} name - Mandatory parameter + * @param {TypeReference} [metadata] - Optional parameter + * @returns {Promise} + */ + create(name, metadata = undefined) { + return new Promise((resolve, reject) => { + this._storage + .createBucket(name, metadata) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } + /** + * Trigers the getBuckets function of storage + * @param {TypeReference} [options] - Optional parameter + * @returns {Promise} + */ + list(options = undefined) { + return new Promise((resolve, reject) => { + this._storage + .getBuckets(options) + .then(result => { + resolve(result); + }) + .catch(err => { + reject(err); + }); + }); + } } module.exports = GCP_storage; diff --git a/generator/generators/aws/generator.js b/generator/generators/aws/generator.js index 61239627..508d06c2 100644 --- a/generator/generators/aws/generator.js +++ b/generator/generators/aws/generator.js @@ -1,145 +1,268 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.generateAWSClass = exports.extractSDKData = void 0; -var fs = require("fs"); -var typescript_1 = require("typescript"); -var parser_1 = require("../../parsers/aws/parser"); -var transformer_1 = require("../../transformers/aws/transformer"); -var helper_1 = require("../lib/helper"); -var dummyFile = process.cwd() + "/dummyClasses/aws.js"; -var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); +var fs = require('fs'); +var typescript_1 = require('typescript'); +var parser_1 = require('../../parsers/aws/parser'); +var transformer_1 = require('../../transformers/aws/transformer'); +var helper_1 = require('../lib/helper'); +var dummyFile = process.cwd() + '/dummyClasses/aws.js'; +var dummyAst = typescript_1.createSourceFile( + dummyFile, + fs.readFileSync(dummyFile).toString(), + typescript_1.ScriptTarget.Latest, + true +); function extractSDKData(sdkClassAst, serviceClass) { - var methods = []; - var functions = []; - Object.keys(serviceClass).map(function (key, index) { - functions.push(serviceClass[key].split(" ")[1]); - }); - sdkClassAst.members.map(function (method) { - if (method.name && functions.includes(method.name.text)) { - var name_1; - Object.keys(serviceClass).map(function (key, index) { - if (serviceClass[key].split(" ")[1] === method.name.text) { - name_1 = key; - } - }); - var parameters_1 = []; - method.parameters.map(function (param) { - if (param.name.text !== "callback") { - var parameter = { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeName: null - }; - if (parameter.type === "TypeReference" && param.type.typeName) { - parameter.typeName = param.type.typeName.right.text; - } - parameters_1.push(parameter); - } - }); - methods.push({ - functionName: name_1.toString(), - SDKFunctionName: method.name.text.toString(), - params: parameters_1 - }); - } - }); - var groupedMethods = helper_1.groupers.aws(methods); - methods = helper_1.filters.aws(groupedMethods); - var classData = { - className: sdkClassAst.name.text, - functions: methods, - serviceName: null - }; - return classData; + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function(key, index) { + functions.push(serviceClass[key].split(' ')[1]); + }); + sdkClassAst.members.map(function(method) { + if (method.name && functions.includes(method.name.text)) { + var name_1; + Object.keys(serviceClass).map(function(key, index) { + if (serviceClass[key].split(' ')[1] === method.name.text) { + name_1 = key; + } + }); + var parameters_1 = []; + method.parameters.map(function(param) { + if (param.name.text !== 'callback') { + var parameter = { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null, + }; + if ( + parameter.type === 'TypeReference' && + param.type.typeName + ) { + parameter.typeName = param.type.typeName.right.text; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: method.name.text.toString(), + params: parameters_1, + }); + } + }); + var groupedMethods = helper_1.groupers.aws(methods); + methods = helper_1.filters.aws(groupedMethods); + var classData = { + className: sdkClassAst.name.text, + functions: methods, + serviceName: null, + }; + return classData; } exports.extractSDKData = extractSDKData; function generateAWSClass(serviceClass, serviceName) { - var _this = this; - var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; - parser_1.getAST(sdkFile).then(function (result) { return __awaiter(_this, void 0, void 0, function () { - var sdkClassAst, classData, output, filePath, dir, e_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - sdkClassAst = result; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - classData = extractSDKData(sdkClassAst, serviceClass); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - filePath = void 0; - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/AWS/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/AWS/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/AWS/" + - dir + - "/aws-" + - serviceName + - ".js"; - } - else { - filePath = - process.cwd() + - "/generatedClasses/AWS/" + - dir + - "/aws-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [3 /*break*/, 4]; - case 3: - e_1 = _a.sent(); - console.error(e_1); - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(' ')[0]; + parser_1.getAST(sdkFile).then(function(result) { + return __awaiter(_this, void 0, void 0, function() { + var sdkClassAst, classData, output, filePath, dir, e_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + sdkClassAst = result; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + classData = extractSDKData(sdkClassAst, serviceClass); + classData.serviceName = serviceName; + return [ + 4 /*yield*/, + transformer_1.transform(dummyAst, classData), + ]; + case 2: + output = _a.sent(); + filePath = void 0; + dir = helper_1.getDir(serviceName); + if ( + !fs.existsSync( + process.cwd() + '/generatedClasses/AWS/' + dir + ) + ) { + fs.mkdirSync( + process.cwd() + '/generatedClasses/AWS/' + dir + ); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/AWS/' + + dir + + '/aws-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/AWS/' + + dir + + '/aws-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + helper_1.printFile(filePath, output); + return [3 /*break*/, 4]; + case 3: + e_1 = _a.sent(); + console.error(e_1); + return [3 /*break*/, 4]; + case 4: + return [2 /*return*/]; + } + }); + }); + }); } exports.generateAWSClass = generateAWSClass; diff --git a/generator/generators/azure/generator.js b/generator/generators/azure/generator.js index e04def19..9fecc505 100644 --- a/generator/generators/azure/generator.js +++ b/generator/generators/azure/generator.js @@ -1,178 +1,323 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.generateAzureClass = exports.extractSDKData = void 0; -var fs = require("fs"); -var typescript_1 = require("typescript"); -var parser_1 = require("../../parsers/azure/parser"); -var transformer_1 = require("../../transformers/azure/transformer"); -var helper_1 = require("../lib/helper"); -var dummyFile = process.cwd() + "/dummyClasses/azure.js"; -var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); +var fs = require('fs'); +var typescript_1 = require('typescript'); +var parser_1 = require('../../parsers/azure/parser'); +var transformer_1 = require('../../transformers/azure/transformer'); +var helper_1 = require('../lib/helper'); +var dummyFile = process.cwd() + '/dummyClasses/azure.js'; +var dummyAst = typescript_1.createSourceFile( + dummyFile, + fs.readFileSync(dummyFile).toString(), + typescript_1.ScriptTarget.Latest, + true +); function extractSDKData(sdkFiles, methods) { - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - sdkFiles.map(function (sdkFile) { - sdkFile.ast.members.map(function (member) { - if (typescript_1.SyntaxKind[member.kind] === "Constructor") { - member.parameters.map(function (param) { - var tempStr = param.type.typeName.text.split(/(?=[A-Z])/); - tempStr.pop(); - sdkFile.client = tempStr.join(""); - }); - } - if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text)) { - var method = methods.find(function (methd) { - return methd.SDKFunctionName === member.name.text && - methd.fileName === sdkFile.fileName; - }); - var parameters = member.parameters.map(function (param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; - }); - var returnType = typescript_1.SyntaxKind[member.type.kind]; - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } - else { - var clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); - } - } - }); - }); - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - throw new Error("Data extraction unsuccessful"); - } - var groupedMethods = helper_1.groupers.azure(methods); - methods = helper_1.filters.azure(groupedMethods); - var classData = { - functions: methods - }; - return classData; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + sdkFiles.map(function(sdkFile) { + sdkFile.ast.members.map(function(member) { + if (typescript_1.SyntaxKind[member.kind] === 'Constructor') { + member.parameters.map(function(param) { + var tempStr = param.type.typeName.text.split(/(?=[A-Z])/); + tempStr.pop(); + sdkFile.client = tempStr.join(''); + }); + } + if ( + typescript_1.SyntaxKind[member.kind] === 'MethodDeclaration' && + sdkFile.sdkFunctionNames.includes(member.name.text) + ) { + var method = methods.find(function(methd) { + return ( + methd.SDKFunctionName === member.name.text && + methd.fileName === sdkFile.fileName + ); + }); + var parameters = member.parameters.map(function(param) { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + }; + }); + var returnType = typescript_1.SyntaxKind[member.type.kind]; + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } else { + var clone = JSON.parse(JSON.stringify(method)); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } + }); + }); + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + throw new Error('Data extraction unsuccessful'); + } + var groupedMethods = helper_1.groupers.azure(methods); + methods = helper_1.filters.azure(groupedMethods); + var classData = { + functions: methods, + }; + return classData; } exports.extractSDKData = extractSDKData; function generateAzureClass(serviceClass, serviceName) { - return __awaiter(this, void 0, void 0, function () { - var methods, files, sdkFiles, classData, output, filePath, dir; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - methods = []; - Object.keys(serviceClass).map(function (key, index) { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - client: null - }); - }); - files = Array.from(new Set(methods.map(function (method) { return method.fileName; }))); - sdkFiles = files.map(function (file) { - return { - fileName: file, - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(function (method) { return method.fileName === file; }) - .map(function (method) { return method.SDKFunctionName; }) - }; - }); - return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file)]; - case 1: - _a.ast = _b.sent(); - return [2 /*return*/]; - } - }); - }); }))]; - case 1: - _a.sent(); - classData = extractSDKData(sdkFiles, methods); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/Azure/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/Azure/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName + - ".js"; - } - else { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var methods, files, sdkFiles, classData, output, filePath, dir; + var _this = this; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + methods = []; + Object.keys(serviceClass).map(function(key, index) { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null, + }); + }); + files = Array.from( + new Set( + methods.map(function(method) { + return method.fileName; + }) + ) + ); + sdkFiles = files.map(function(file) { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function(method) { + return method.fileName === file; + }) + .map(function(method) { + return method.SDKFunctionName; + }), + }; + }); + return [ + 4 /*yield*/, + Promise.all( + sdkFiles.map(function(file) { + return __awaiter( + _this, + void 0, + void 0, + function() { + var _a; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + _a = file; + return [ + 4 /*yield*/, + parser_1.getAST(file), + ]; + case 1: + _a.ast = _b.sent(); + return [2 /*return*/]; + } + }); + } + ); + }) + ), + ]; + case 1: + _a.sent(); + classData = extractSDKData(sdkFiles, methods); + classData.serviceName = serviceName; + return [ + 4 /*yield*/, + transformer_1.transform(dummyAst, classData), + ]; + case 2: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if ( + !fs.existsSync( + process.cwd() + '/generatedClasses/Azure/' + dir + ) + ) { + fs.mkdirSync( + process.cwd() + '/generatedClasses/Azure/' + dir + ); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/Azure/' + + dir + + '/azure-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/Azure/' + + dir + + '/azure-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); + }); } exports.generateAzureClass = generateAzureClass; diff --git a/generator/generators/azure/generator.ts b/generator/generators/azure/generator.ts index 2aa27b60..38839d33 100644 --- a/generator/generators/azure/generator.ts +++ b/generator/generators/azure/generator.ts @@ -1,152 +1,152 @@ -import * as fs from "fs"; -import { createSourceFile, ScriptTarget,SyntaxKind } from "typescript"; +import * as fs from 'fs'; +import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; -import { getAST } from "../../parsers/azure/parser"; -import { transform } from "../../transformers/azure/transformer"; -import { filters, getDir,groupers, printFile } from "../lib/helper"; +import { getAST } from '../../parsers/azure/parser'; +import { transform } from '../../transformers/azure/transformer'; +import { filters, getDir, groupers, printFile } from '../lib/helper'; interface FunctionData { - pkgName: string; - fileName: string; - functionName: string; - SDKFunctionName: string; - params: param[]; - returnType: string; - client: string; + pkgName: string; + fileName: string; + functionName: string; + SDKFunctionName: string; + params: param[]; + returnType: string; + client: string; } interface param { - name: string; - type: string; + name: string; + type: string; } -const dummyFile = process.cwd() + "/dummyClasses/azure.js"; +const dummyFile = process.cwd() + '/dummyClasses/azure.js'; const dummyAst = createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - ScriptTarget.Latest, - true + dummyFile, + fs.readFileSync(dummyFile).toString(), + ScriptTarget.Latest, + true ); export function extractSDKData(sdkFiles, methods) { - const specifiedMethods = JSON.parse(JSON.stringify(methods)); - sdkFiles.map(sdkFile => { - sdkFile.ast.members.map(member => { - if (SyntaxKind[member.kind] === "Constructor") { - member.parameters.map(param => { - const tempStr = param.type.typeName.text.split(/(?=[A-Z])/); - tempStr.pop(); - sdkFile.client = tempStr.join(""); - }); - } - - if ( - SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text) - ) { - const method = methods.find( - methd => - methd.SDKFunctionName === member.name.text && - methd.fileName === sdkFile.fileName - ); - const parameters = member.parameters.map(param => { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: SyntaxKind[param.type.kind] - }; - }); - - const returnType = SyntaxKind[member.type.kind]; - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } else { - const clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); - } - } - }); - }); - - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - throw new Error("Data extraction unsuccessful"); - } - - const groupedMethods = groupers.azure(methods); - methods = filters.azure(groupedMethods); - - const classData = { - functions: methods - }; - - return classData; + const specifiedMethods = JSON.parse(JSON.stringify(methods)); + sdkFiles.map(sdkFile => { + sdkFile.ast.members.map(member => { + if (SyntaxKind[member.kind] === 'Constructor') { + member.parameters.map(param => { + const tempStr = param.type.typeName.text.split(/(?=[A-Z])/); + tempStr.pop(); + sdkFile.client = tempStr.join(''); + }); + } + + if ( + SyntaxKind[member.kind] === 'MethodDeclaration' && + sdkFile.sdkFunctionNames.includes(member.name.text) + ) { + const method = methods.find( + methd => + methd.SDKFunctionName === member.name.text && + methd.fileName === sdkFile.fileName + ); + const parameters = member.parameters.map(param => { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: SyntaxKind[param.type.kind], + }; + }); + + const returnType = SyntaxKind[member.type.kind]; + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } else { + const clone = JSON.parse(JSON.stringify(method)); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } + }); + }); + + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + throw new Error('Data extraction unsuccessful'); + } + + const groupedMethods = groupers.azure(methods); + methods = filters.azure(groupedMethods); + + const classData = { + functions: methods, + }; + + return classData; } export async function generateAzureClass(serviceClass, serviceName) { - let methods: FunctionData[] = []; - - Object.keys(serviceClass).map((key, index) => { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - client: null - }); - }); - - const files = Array.from(new Set(methods.map(method => method.fileName))); - - const sdkFiles = files.map(file => { - return { - fileName: file, - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(method => method.fileName === file) - .map(method => method.SDKFunctionName) - }; - }); - - await Promise.all( - sdkFiles.map(async file => { - file.ast = await getAST(file); - }) - ); - - const classData: any = extractSDKData(sdkFiles, methods); - classData.serviceName = serviceName; - const output = await transform(dummyAst, classData); - let filePath; - const dir = getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/Azure/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/Azure/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/Azure/" + - dir + - "/azure-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - printFile(filePath, output); + const methods: FunctionData[] = []; + + Object.keys(serviceClass).map((key, index) => { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null, + }); + }); + + const files = Array.from(new Set(methods.map(method => method.fileName))); + + const sdkFiles = files.map(file => { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(method => method.fileName === file) + .map(method => method.SDKFunctionName), + }; + }); + + await Promise.all( + sdkFiles.map(async file => { + file.ast = await getAST(file); + }) + ); + + const classData: any = extractSDKData(sdkFiles, methods); + classData.serviceName = serviceName; + const output = await transform(dummyAst, classData); + let filePath; + const dir = getDir(serviceName); + if (!fs.existsSync(process.cwd() + '/generatedClasses/Azure/' + dir)) { + fs.mkdirSync(process.cwd() + '/generatedClasses/Azure/' + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/Azure/' + + dir + + '/azure-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/Azure/' + + dir + + '/azure-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + printFile(filePath, output); } diff --git a/generator/generators/do/generator.js b/generator/generators/do/generator.js index 9b59d7c2..f6c11156 100644 --- a/generator/generators/do/generator.js +++ b/generator/generators/do/generator.js @@ -1,143 +1,266 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.generateDOClass = exports.extractSDKData = void 0; -var fs = require("fs"); -var typescript_1 = require("typescript"); -var parser_1 = require("../../parsers/do/parser"); -var transformer_1 = require("../../transformers/do/transformer"); -var helper_1 = require("../lib/helper"); -var dummyFile = process.cwd() + "/dummyClasses/do.js"; -var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); +var fs = require('fs'); +var typescript_1 = require('typescript'); +var parser_1 = require('../../parsers/do/parser'); +var transformer_1 = require('../../transformers/do/transformer'); +var helper_1 = require('../lib/helper'); +var dummyFile = process.cwd() + '/dummyClasses/do.js'; +var dummyAst = typescript_1.createSourceFile( + dummyFile, + fs.readFileSync(dummyFile).toString(), + typescript_1.ScriptTarget.Latest, + true +); function extractSDKData(sdkClassAst, serviceClass) { - var methods = []; - var functions = []; - Object.keys(serviceClass).map(function (key, index) { - functions.push(serviceClass[key].split(" ")[1]); - }); - sdkClassAst.members.map(function (method) { - if (method.name && functions.includes(method.name.text)) { - var name_1; - Object.keys(serviceClass).map(function (key, index) { - if (serviceClass[key].split(" ")[1] === method.name.text) { - name_1 = key; - } - }); - var parameters_1 = []; - method.parameters.map(function (param) { - if (param.name.text !== "callback") { - var parameter = { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeName: null - }; - if (parameter.type === "TypeReference" && param.type.typeName) { - parameter.typeName = param.type.typeName.text; - } - parameters_1.push(parameter); - } - }); - methods.push({ - functionName: name_1.toString(), - SDKFunctionName: method.name.text.toString(), - params: parameters_1 - }); - } - }); - var classData = { - className: sdkClassAst.name.text, - functions: methods, - serviceName: null - }; - return classData; + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function(key, index) { + functions.push(serviceClass[key].split(' ')[1]); + }); + sdkClassAst.members.map(function(method) { + if (method.name && functions.includes(method.name.text)) { + var name_1; + Object.keys(serviceClass).map(function(key, index) { + if (serviceClass[key].split(' ')[1] === method.name.text) { + name_1 = key; + } + }); + var parameters_1 = []; + method.parameters.map(function(param) { + if (param.name.text !== 'callback') { + var parameter = { + name: param.name.text, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null, + }; + if ( + parameter.type === 'TypeReference' && + param.type.typeName + ) { + parameter.typeName = param.type.typeName.text; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: method.name.text.toString(), + params: parameters_1, + }); + } + }); + var classData = { + className: sdkClassAst.name.text, + functions: methods, + serviceName: null, + }; + return classData; } exports.extractSDKData = extractSDKData; function generateDOClass(serviceClass, serviceName) { - var _this = this; - var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; - parser_1.getAST(sdkFile).then(function (result) { return __awaiter(_this, void 0, void 0, function () { - var sdkClassAst, classData, output, filePath, dir, e_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - sdkClassAst = result; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - classData = extractSDKData(sdkClassAst, serviceClass); - classData.serviceName = serviceName; - return [4 /*yield*/, transformer_1.transform(dummyAst, classData)]; - case 2: - output = _a.sent(); - filePath = void 0; - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/DO/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/DO/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName + - ".js"; - } - else { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [3 /*break*/, 4]; - case 3: - e_1 = _a.sent(); - console.error(e_1); - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + var sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(' ')[0]; + parser_1.getAST(sdkFile).then(function(result) { + return __awaiter(_this, void 0, void 0, function() { + var sdkClassAst, classData, output, filePath, dir, e_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + sdkClassAst = result; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + classData = extractSDKData(sdkClassAst, serviceClass); + classData.serviceName = serviceName; + return [ + 4 /*yield*/, + transformer_1.transform(dummyAst, classData), + ]; + case 2: + output = _a.sent(); + filePath = void 0; + dir = helper_1.getDir(serviceName); + if ( + !fs.existsSync( + process.cwd() + '/generatedClasses/DO/' + dir + ) + ) { + fs.mkdirSync( + process.cwd() + '/generatedClasses/DO/' + dir + ); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/DO/' + + dir + + '/do-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/DO/' + + dir + + '/do-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + helper_1.printFile(filePath, output); + return [3 /*break*/, 4]; + case 3: + e_1 = _a.sent(); + console.error(e_1); + return [3 /*break*/, 4]; + case 4: + return [2 /*return*/]; + } + }); + }); + }); } exports.generateDOClass = generateDOClass; diff --git a/generator/generators/do/generator.ts b/generator/generators/do/generator.ts index 052b13e0..7a97277d 100644 --- a/generator/generators/do/generator.ts +++ b/generator/generators/do/generator.ts @@ -1,123 +1,129 @@ -import * as fs from "fs"; -import { createSourceFile, ScriptTarget, SyntaxKind } from "typescript"; +import * as fs from 'fs'; +import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; -import { getAST } from "../../parsers/do/parser"; -import { transform } from "../../transformers/do/transformer"; -import { getDir,printFile } from "../lib/helper"; +import { getAST } from '../../parsers/do/parser'; +import { transform } from '../../transformers/do/transformer'; +import { getDir, printFile } from '../lib/helper'; interface FunctionData { - functionName: string; - SDKFunctionName: string; - params: param[]; + functionName: string; + SDKFunctionName: string; + params: param[]; } interface param { - name: string; - type: string; - typeName: string; + name: string; + type: string; + typeName: string; } interface ClassData { - className: string; - functions: FunctionData[]; - serviceName: string; + className: string; + functions: FunctionData[]; + serviceName: string; } -const dummyFile = process.cwd() + "/dummyClasses/do.js"; +const dummyFile = process.cwd() + '/dummyClasses/do.js'; const dummyAst = createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - ScriptTarget.Latest, - true + dummyFile, + fs.readFileSync(dummyFile).toString(), + ScriptTarget.Latest, + true ); export function extractSDKData(sdkClassAst, serviceClass) { - let methods: FunctionData[] = []; - const functions = []; - - Object.keys(serviceClass).map((key, index) => { - functions.push(serviceClass[key].split(" ")[1]); - }); - - sdkClassAst.members.map(method => { - if (method.name && functions.includes(method.name.text)) { - let name; - Object.keys(serviceClass).map((key, index) => { - if (serviceClass[key].split(" ")[1] === method.name.text) { - name = key; - } - }); - - const parameters = []; - method.parameters.map(param => { - if (param.name.text !== "callback") { - const parameter = { - name: param.name.text, - optional: param.questionToken ? true : false, - type: SyntaxKind[param.type.kind], - typeName: null - }; - - if (parameter.type === "TypeReference" && param.type.typeName) { - parameter.typeName = param.type.typeName.text; - } - - parameters.push(parameter); - } - }); - - methods.push({ - functionName: name.toString(), - SDKFunctionName: method.name.text.toString(), - params: parameters - }); - } - }); - - const classData: ClassData = { - className: sdkClassAst.name.text, - functions: methods, - serviceName: null - }; - - return classData; + const methods: FunctionData[] = []; + const functions = []; + + Object.keys(serviceClass).map((key, index) => { + functions.push(serviceClass[key].split(' ')[1]); + }); + + sdkClassAst.members.map(method => { + if (method.name && functions.includes(method.name.text)) { + let name; + Object.keys(serviceClass).map((key, index) => { + if (serviceClass[key].split(' ')[1] === method.name.text) { + name = key; + } + }); + + const parameters = []; + method.parameters.map(param => { + if (param.name.text !== 'callback') { + const parameter = { + name: param.name.text, + optional: param.questionToken ? true : false, + type: SyntaxKind[param.type.kind], + typeName: null, + }; + + if ( + parameter.type === 'TypeReference' && + param.type.typeName + ) { + parameter.typeName = param.type.typeName.text; + } + + parameters.push(parameter); + } + }); + + methods.push({ + functionName: name.toString(), + SDKFunctionName: method.name.text.toString(), + params: parameters, + }); + } + }); + + const classData: ClassData = { + className: sdkClassAst.name.text, + functions: methods, + serviceName: null, + }; + + return classData; } export function generateDOClass(serviceClass, serviceName) { - const sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(" ")[0]; - getAST(sdkFile).then(async result => { - const sdkClassAst = result; - try { - const classData: ClassData = extractSDKData(sdkClassAst, serviceClass); - classData.serviceName = serviceName; - const output = await transform(dummyAst, classData); - let filePath; - const dir = getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/DO/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/DO/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/DO/" + - dir + - "/do-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - printFile(filePath, output); - } catch (e) { - console.error(e); - } - }); + const sdkFile = serviceClass[Object.keys(serviceClass)[0]].split(' ')[0]; + getAST(sdkFile).then(async result => { + const sdkClassAst = result; + try { + const classData: ClassData = extractSDKData( + sdkClassAst, + serviceClass + ); + classData.serviceName = serviceName; + const output = await transform(dummyAst, classData); + let filePath; + const dir = getDir(serviceName); + if (!fs.existsSync(process.cwd() + '/generatedClasses/DO/' + dir)) { + fs.mkdirSync(process.cwd() + '/generatedClasses/DO/' + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/DO/' + + dir + + '/do-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/DO/' + + dir + + '/do-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + printFile(filePath, output); + } catch (e) { + console.error(e); + } + }); } diff --git a/generator/generators/googleCloud/generator.js b/generator/generators/googleCloud/generator.js index a06ac192..ea5d502a 100644 --- a/generator/generators/googleCloud/generator.js +++ b/generator/generators/googleCloud/generator.js @@ -1,410 +1,701 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.generateGCPClass = exports.extractClientBasedSDKdata = exports.extractClassBasedSDKData = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); -var parser_1 = require("../../parsers/googleCloud/parser"); -var classBasedTransformer_1 = require("../../transformers/googleCloud/classBasedTransformer"); -var clientBasedTransformer_1 = require("../../transformers/googleCloud/clientBasedTransformer"); -var helper_1 = require("../lib/helper"); -var dummyFile = process.cwd() + "/dummyClasses/gcp.js"; -var dummyAst = typescript_1.createSourceFile(dummyFile, fs.readFileSync(dummyFile).toString(), typescript_1.ScriptTarget.Latest, true); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); +var parser_1 = require('../../parsers/googleCloud/parser'); +var classBasedTransformer_1 = require('../../transformers/googleCloud/classBasedTransformer'); +var clientBasedTransformer_1 = require('../../transformers/googleCloud/clientBasedTransformer'); +var helper_1 = require('../lib/helper'); +var dummyFile = process.cwd() + '/dummyClasses/gcp.js'; +var dummyAst = typescript_1.createSourceFile( + dummyFile, + fs.readFileSync(dummyFile).toString(), + typescript_1.ScriptTarget.Latest, + true +); function extractClassBasedSDKData(methods, sdkFiles) { - var _this = this; - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var classes_1, extractedData; - return __generator(this, function (_a) { - try { - classes_1 = []; - sdkFiles.map(function (file) { - file.classes.map(function (classAst) { - var classInfo = { - name: classAst.name.text, - methods: [], - properties: [], - constructor: null - }; - classAst.members.map(function (member) { - if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration") { - var returnType = typescript_1.SyntaxKind[member.type.kind]; - var parameters = member.parameters.map(function (param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; - }); - var method_1 = { - pkgName: file.pkgName, - version: null, - fileName: file.fileName, - functionName: null, - SDKFunctionName: member.name.text, - params: parameters, - returnType: returnType, - returnTypeName: null, - client: classAst.name.text // Class name - }; - if (returnType === "TypeReference") { - method_1.returnTypeName = member.type.typeName.text; - } - var meth = methods.find(function (meth) { - return meth.SDKFunctionName === method_1.SDKFunctionName && - meth.fileName === method_1.fileName; - }); - method_1.functionName = meth ? meth.functionName : null; - classInfo.methods.push(method_1); - } - if (typescript_1.SyntaxKind[member.kind] === "Constructor") { - var parameters = member.parameters.map(function (param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeRefName: param.type.typeName - ? param.type.typeName.text - : null - }; - }); - classInfo.constructor = { - parameters: parameters - }; - } - if (typescript_1.SyntaxKind[member.kind] === "PropertyDeclaration") { - var isPrivateProp = member.modifiers && - member.modifiers.some(function (modifier) { return typescript_1.SyntaxKind[modifier.kind] === "PrivateKeyword"; }); - if (!isPrivateProp) { - var prop = { - name: member.name.text, - type: typescript_1.SyntaxKind[member.type.kind], - typeRefName: member.type.typeName - ? member.type.typeName.text - : null - }; - classInfo.properties.push(prop); - } - } - }); - classes_1.push(classInfo); - }); - }); - methods = []; - classes_1.map(function (classData) { - var filteredMethods = classData.methods.filter(function (meth) { return meth.functionName !== null; }); - filteredMethods.map(function (filMeth) { - filMeth.classConstructorData = classData.constructor; - }); - methods = methods.concat(filteredMethods); - }); - extractedData = { - classes: classes_1, - methods: methods - }; - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } - else { - resolve(extractedData); - } - } - catch (error) { - reject(error); - } - return [2 /*return*/]; - }); - }); }); + var _this = this; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var classes_1, extractedData; + return __generator(this, function(_a) { + try { + classes_1 = []; + sdkFiles.map(function(file) { + file.classes.map(function(classAst) { + var classInfo = { + name: classAst.name.text, + methods: [], + properties: [], + constructor: null, + }; + classAst.members.map(function(member) { + if ( + typescript_1.SyntaxKind[member.kind] === + 'MethodDeclaration' + ) { + var returnType = + typescript_1.SyntaxKind[ + member.type.kind + ]; + var parameters = member.parameters.map( + function(param) { + return { + name: param.name.text, + optional: param.questionToken + ? true + : false, + type: + typescript_1.SyntaxKind[ + param.type.kind + ], + }; + } + ); + var method_1 = { + pkgName: file.pkgName, + version: null, + fileName: file.fileName, + functionName: null, + SDKFunctionName: member.name.text, + params: parameters, + returnType: returnType, + returnTypeName: null, + client: classAst.name.text, // Class name + }; + if (returnType === 'TypeReference') { + method_1.returnTypeName = + member.type.typeName.text; + } + var meth = methods.find(function(meth) { + return ( + meth.SDKFunctionName === + method_1.SDKFunctionName && + meth.fileName === method_1.fileName + ); + }); + method_1.functionName = meth + ? meth.functionName + : null; + classInfo.methods.push(method_1); + } + if ( + typescript_1.SyntaxKind[member.kind] === + 'Constructor' + ) { + var parameters = member.parameters.map( + function(param) { + return { + name: param.name.text, + optional: param.questionToken + ? true + : false, + type: + typescript_1.SyntaxKind[ + param.type.kind + ], + typeRefName: param.type.typeName + ? param.type.typeName.text + : null, + }; + } + ); + classInfo.constructor = { + parameters: parameters, + }; + } + if ( + typescript_1.SyntaxKind[member.kind] === + 'PropertyDeclaration' + ) { + var isPrivateProp = + member.modifiers && + member.modifiers.some(function( + modifier + ) { + return ( + typescript_1.SyntaxKind[ + modifier.kind + ] === 'PrivateKeyword' + ); + }); + if (!isPrivateProp) { + var prop = { + name: member.name.text, + type: + typescript_1.SyntaxKind[ + member.type.kind + ], + typeRefName: member.type.typeName + ? member.type.typeName.text + : null, + }; + classInfo.properties.push(prop); + } + } + }); + classes_1.push(classInfo); + }); + }); + methods = []; + classes_1.map(function(classData) { + var filteredMethods = classData.methods.filter(function( + meth + ) { + return meth.functionName !== null; + }); + filteredMethods.map(function(filMeth) { + filMeth.classConstructorData = + classData.constructor; + }); + methods = methods.concat(filteredMethods); + }); + extractedData = { + classes: classes_1, + methods: methods, + }; + if ( + JSON.stringify(methods) === + JSON.stringify(specifiedMethods) + ) { + reject(new Error('Data extraction unsuccessful')); + } else { + resolve(extractedData); + } + } catch (error) { + reject(error); + } + return [2 /*return*/]; + }); + }); + }); } exports.extractClassBasedSDKData = extractClassBasedSDKData; function extractClientBasedSDKdata(methods, sdkFiles) { - var _this = this; - var specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - try { - sdkFiles.map(function (sdkFile) { - sdkFile.client = sdkFile.ast.name.text; - sdkFile.ast.members.map(function (member) { - if (typescript_1.SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text)) { - var method = methods.find(function (methd) { return methd.SDKFunctionName === member.name.text; }); - var parameters = member.parameters.map(function (param) { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind] - }; - }); - var returnType = typescript_1.SyntaxKind[member.type.kind]; - if (returnType === "TypeReference") { - method.returnTypeName = member.type.typeName.text; - } - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } - else { - var clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); - } - } - }); - }); - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } - else { - resolve(methods); - } - } - catch (error) { - reject(error); - } - return [2 /*return*/]; - }); - }); }); + var _this = this; + var specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + return __generator(this, function(_a) { + try { + sdkFiles.map(function(sdkFile) { + sdkFile.client = sdkFile.ast.name.text; + sdkFile.ast.members.map(function(member) { + if ( + typescript_1.SyntaxKind[member.kind] === + 'MethodDeclaration' && + sdkFile.sdkFunctionNames.includes( + member.name.text + ) + ) { + var method = methods.find(function(methd) { + return ( + methd.SDKFunctionName === + member.name.text + ); + }); + var parameters = member.parameters.map(function( + param + ) { + return { + name: param.name.text, + optional: param.questionToken + ? true + : false, + type: + typescript_1.SyntaxKind[ + param.type.kind + ], + }; + }); + var returnType = + typescript_1.SyntaxKind[member.type.kind]; + if (returnType === 'TypeReference') { + method.returnTypeName = + member.type.typeName.text; + } + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } else { + var clone = JSON.parse( + JSON.stringify(method) + ); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } + }); + }); + if ( + JSON.stringify(methods) === + JSON.stringify(specifiedMethods) + ) { + reject(new Error('Data extraction unsuccessful')); + } else { + resolve(methods); + } + } catch (error) { + reject(error); + } + return [2 /*return*/]; + }); + }); + }); } exports.extractClientBasedSDKdata = extractClientBasedSDKdata; function generateClassBasedCode(methods, data, serviceName) { - return __awaiter(this, void 0, void 0, function () { - var dirPath, files, sdkFiles, extractedData, groupedMethods, output, filePath, dir; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - dirPath = "../../../node_modules/@google-cloud/" + methods[0].pkgName + "/build/src/"; - files = fs.readdirSync(path.join(__dirname, dirPath)); - files = files.filter(function (fileName) { - return fileName.split(".")[1] === "d" && fileName.split(".")[2] === "ts"; - }); - sdkFiles = files.map(function (fileName) { - return { - fileName: fileName, - pkgName: methods[0].pkgName, - classes: null, - sdkFunctionNames: methods - .filter(function (method) { return method.fileName === fileName; }) - .map(function (method) { return method.SDKFunctionName; }) - }; - }); - return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file, true)]; - case 1: - _a.classes = _b.sent(); - return [2 /*return*/]; - } - }); - }); }))]; - case 1: - _a.sent(); - return [4 /*yield*/, extractClassBasedSDKData(methods, sdkFiles).then(function (result) { return result; })]; - case 2: - extractedData = _a.sent(); - groupedMethods = helper_1.groupers.gcp(extractedData.methods); - methods = helper_1.filters.gcp(groupedMethods); - data.functions = methods; - data.classData = extractedData.classes; - data.serviceName = serviceName; - return [4 /*yield*/, classBasedTransformer_1.classBasedTransform(dummyAst, data)]; - case 3: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } - else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var dirPath, + files, + sdkFiles, + extractedData, + groupedMethods, + output, + filePath, + dir; + var _this = this; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + dirPath = + '../../../node_modules/@google-cloud/' + + methods[0].pkgName + + '/build/src/'; + files = fs.readdirSync(path.join(__dirname, dirPath)); + files = files.filter(function(fileName) { + return ( + fileName.split('.')[1] === 'd' && + fileName.split('.')[2] === 'ts' + ); + }); + sdkFiles = files.map(function(fileName) { + return { + fileName: fileName, + pkgName: methods[0].pkgName, + classes: null, + sdkFunctionNames: methods + .filter(function(method) { + return method.fileName === fileName; + }) + .map(function(method) { + return method.SDKFunctionName; + }), + }; + }); + return [ + 4 /*yield*/, + Promise.all( + sdkFiles.map(function(file) { + return __awaiter( + _this, + void 0, + void 0, + function() { + var _a; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + _a = file; + return [ + 4 /*yield*/, + parser_1.getAST( + file, + true + ), + ]; + case 1: + _a.classes = _b.sent(); + return [2 /*return*/]; + } + }); + } + ); + }) + ), + ]; + case 1: + _a.sent(); + return [ + 4 /*yield*/, + extractClassBasedSDKData(methods, sdkFiles).then( + function(result) { + return result; + } + ), + ]; + case 2: + extractedData = _a.sent(); + groupedMethods = helper_1.groupers.gcp( + extractedData.methods + ); + methods = helper_1.filters.gcp(groupedMethods); + data.functions = methods; + data.classData = extractedData.classes; + data.serviceName = serviceName; + return [ + 4 /*yield*/, + classBasedTransformer_1.classBasedTransform( + dummyAst, + data + ), + ]; + case 3: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if ( + !fs.existsSync( + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + ) + ) { + fs.mkdirSync( + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + ); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); + }); } function generateClientBasedCode(methods, serviceName) { - return __awaiter(this, void 0, void 0, function () { - var files, sdkFiles, groupedMethods, classData, output, filePath, dir; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - files = Array.from(new Set(methods.map(function (method) { return method.fileName + " " + method.version; }))); - sdkFiles = files.map(function (file) { - return { - fileName: file.split(" ")[0], - version: file.split(" ")[1], - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(function (method) { return method.fileName === file.split(" ")[0]; }) - .map(function (method) { return method.SDKFunctionName; }) - }; - }); - return [4 /*yield*/, Promise.all(sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = file; - return [4 /*yield*/, parser_1.getAST(file)]; - case 1: - _a.ast = _b.sent(); - return [2 /*return*/]; - } - }); - }); }))]; - case 1: - _a.sent(); - return [4 /*yield*/, extractClientBasedSDKdata(methods, sdkFiles).then(function (result) { return result; })]; - case 2: - methods = _a.sent(); - groupedMethods = helper_1.groupers.gcp(methods); - methods = helper_1.filters.gcp(groupedMethods); - classData = { - functions: methods, - serviceName: serviceName - }; - return [4 /*yield*/, clientBasedTransformer_1.clientBasedTransform(dummyAst, classData)]; - case 3: - output = _a.sent(); - dir = helper_1.getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } - else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - helper_1.printFile(filePath, output); - return [2 /*return*/]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var files, sdkFiles, groupedMethods, classData, output, filePath, dir; + var _this = this; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + files = Array.from( + new Set( + methods.map(function(method) { + return method.fileName + ' ' + method.version; + }) + ) + ); + sdkFiles = files.map(function(file) { + return { + fileName: file.split(' ')[0], + version: file.split(' ')[1], + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function(method) { + return ( + method.fileName === file.split(' ')[0] + ); + }) + .map(function(method) { + return method.SDKFunctionName; + }), + }; + }); + return [ + 4 /*yield*/, + Promise.all( + sdkFiles.map(function(file) { + return __awaiter( + _this, + void 0, + void 0, + function() { + var _a; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + _a = file; + return [ + 4 /*yield*/, + parser_1.getAST(file), + ]; + case 1: + _a.ast = _b.sent(); + return [2 /*return*/]; + } + }); + } + ); + }) + ), + ]; + case 1: + _a.sent(); + return [ + 4 /*yield*/, + extractClientBasedSDKdata(methods, sdkFiles).then( + function(result) { + return result; + } + ), + ]; + case 2: + methods = _a.sent(); + groupedMethods = helper_1.groupers.gcp(methods); + methods = helper_1.filters.gcp(groupedMethods); + classData = { + functions: methods, + serviceName: serviceName, + }; + return [ + 4 /*yield*/, + clientBasedTransformer_1.clientBasedTransform( + dummyAst, + classData + ), + ]; + case 3: + output = _a.sent(); + dir = helper_1.getDir(serviceName); + if ( + !fs.existsSync( + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + ) + ) { + fs.mkdirSync( + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + ); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + helper_1.printFile(filePath, output); + return [2 /*return*/]; + } + }); + }); } function generateGCPClass(serviceClass, serviceName) { - return __awaiter(this, void 0, void 0, function () { - var methods, data; - return __generator(this, function (_a) { - methods = []; - data = {}; - Object.keys(serviceClass).map(function (key, index) { - if (key === "mainClass") { - data.mainClass = serviceClass[key]; - } - else if (serviceClass[key].split(" ")[1].length === 2 && - serviceClass[key].split(" ")[1].charAt(0) === "v") { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: serviceClass[key].split(" ")[1], - fileName: serviceClass[key].split(" ")[2], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[3], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } - else { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: null, - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } - }); - if (methods[0].version) { - generateClientBasedCode(methods, serviceName); - } - else { - generateClassBasedCode(methods, data, serviceName); - } - return [2 /*return*/]; - }); - }); + return __awaiter(this, void 0, void 0, function() { + var methods, data; + return __generator(this, function(_a) { + methods = []; + data = {}; + Object.keys(serviceClass).map(function(key, index) { + if (key === 'mainClass') { + data.mainClass = serviceClass[key]; + } else if ( + serviceClass[key].split(' ')[1].length === 2 && + serviceClass[key].split(' ')[1].charAt(0) === 'v' + ) { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + version: serviceClass[key].split(' ')[1], + fileName: serviceClass[key].split(' ')[2], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[3], + params: [], + returnType: null, + returnTypeName: null, + client: null, + }); + } else { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + version: null, + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + returnTypeName: null, + client: null, + }); + } + }); + if (methods[0].version) { + generateClientBasedCode(methods, serviceName); + } else { + generateClassBasedCode(methods, data, serviceName); + } + return [2 /*return*/]; + }); + }); } exports.generateGCPClass = generateGCPClass; diff --git a/generator/generators/googleCloud/generator.ts b/generator/generators/googleCloud/generator.ts index 9a2702cf..c3996431 100644 --- a/generator/generators/googleCloud/generator.ts +++ b/generator/generators/googleCloud/generator.ts @@ -1,388 +1,405 @@ -import * as fs from "fs"; -import * as path from "path"; -import { createSourceFile, ScriptTarget,SyntaxKind } from "typescript"; +import * as fs from 'fs'; +import * as path from 'path'; +import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; -import { getAST } from "../../parsers/googleCloud/parser"; -import { classBasedTransform } from "../../transformers/googleCloud/classBasedTransformer"; -import { clientBasedTransform } from "../../transformers/googleCloud/clientBasedTransformer"; -import { filters, getDir,groupers, printFile } from "../lib/helper"; +import { getAST } from '../../parsers/googleCloud/parser'; +import { classBasedTransform } from '../../transformers/googleCloud/classBasedTransformer'; +import { clientBasedTransform } from '../../transformers/googleCloud/clientBasedTransformer'; +import { filters, getDir, groupers, printFile } from '../lib/helper'; interface ClassData { - name: string; - methods: FunctionData[]; - constructor: constructorData; - properties: propertyData[]; + name: string; + methods: FunctionData[]; + constructor: constructorData; + properties: propertyData[]; } interface FunctionData { - pkgName: string; - version: string; - fileName: string; - functionName: string; - SDKFunctionName: string; - params: param[]; - returnType: string; - returnTypeName: string; - client: string; + pkgName: string; + version: string; + fileName: string; + functionName: string; + SDKFunctionName: string; + params: param[]; + returnType: string; + returnTypeName: string; + client: string; } interface propertyData { - name: string; - type: string; + name: string; + type: string; } interface constructorData { - parameters: param[]; + parameters: param[]; } interface param { - name: string; - type: string; - optional: boolean; + name: string; + type: string; + optional: boolean; } -const dummyFile = process.cwd() + "/dummyClasses/gcp.js"; +const dummyFile = process.cwd() + '/dummyClasses/gcp.js'; const dummyAst = createSourceFile( - dummyFile, - fs.readFileSync(dummyFile).toString(), - ScriptTarget.Latest, - true + dummyFile, + fs.readFileSync(dummyFile).toString(), + ScriptTarget.Latest, + true ); export function extractClassBasedSDKData(methods, sdkFiles): any { - const specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(async (resolve, reject) => { - try { - let classes: ClassData[] = []; - - sdkFiles.map(file => { - file.classes.map(classAst => { - const classInfo: ClassData = { - name: classAst.name.text, - methods: [], - properties: [], - constructor: null - }; - - classAst.members.map(member => { - if (SyntaxKind[member.kind] === "MethodDeclaration") { - const returnType = SyntaxKind[member.type.kind]; - - const parameters = member.parameters.map(param => { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: SyntaxKind[param.type.kind] - }; - }); - const method: FunctionData = { - pkgName: file.pkgName, - version: null, - fileName: file.fileName, - functionName: null, - SDKFunctionName: member.name.text, - params: parameters, - returnType: returnType, - returnTypeName: null, - client: classAst.name.text // Class name - }; - - if (returnType === "TypeReference") { - method.returnTypeName = member.type.typeName.text; - } - - const meth = methods.find( - meth => - meth.SDKFunctionName === method.SDKFunctionName && - meth.fileName === method.fileName - ); - method.functionName = meth ? meth.functionName : null; - classInfo.methods.push(method); - } - - if (SyntaxKind[member.kind] === "Constructor") { - const parameters = member.parameters.map(param => { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: SyntaxKind[param.type.kind], - typeRefName: param.type.typeName - ? param.type.typeName.text - : null - }; - }); - - classInfo.constructor = { - parameters - }; - } - - if (SyntaxKind[member.kind] === "PropertyDeclaration") { - const isPrivateProp = - member.modifiers && - member.modifiers.some( - modifier => SyntaxKind[modifier.kind] === "PrivateKeyword" - ); - if (!isPrivateProp) { - const prop = { - name: member.name.text, - type: SyntaxKind[member.type.kind], - typeRefName: member.type.typeName - ? member.type.typeName.text - : null - }; - classInfo.properties.push(prop); - } - } - }); - classes.push(classInfo); - }); - }); - - methods = []; - - classes.map(classData => { - let filteredMethods: any = classData.methods.filter( - meth => meth.functionName !== null - ); - filteredMethods.map(filMeth => { - filMeth.classConstructorData = classData.constructor; - }); - - methods = methods.concat(filteredMethods); - }); - - const extractedData = { - classes, - methods - }; - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } else { - resolve(extractedData); - } - } catch (error) { - reject(error); - } - }); + const specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(async (resolve, reject) => { + try { + const classes: ClassData[] = []; + + sdkFiles.map(file => { + file.classes.map(classAst => { + const classInfo: ClassData = { + name: classAst.name.text, + methods: [], + properties: [], + constructor: null, + }; + + classAst.members.map(member => { + if (SyntaxKind[member.kind] === 'MethodDeclaration') { + const returnType = SyntaxKind[member.type.kind]; + + const parameters = member.parameters.map(param => { + return { + name: param.name.text, + optional: param.questionToken + ? true + : false, + type: SyntaxKind[param.type.kind], + }; + }); + const method: FunctionData = { + pkgName: file.pkgName, + version: null, + fileName: file.fileName, + functionName: null, + SDKFunctionName: member.name.text, + params: parameters, + returnType: returnType, + returnTypeName: null, + client: classAst.name.text, // Class name + }; + + if (returnType === 'TypeReference') { + method.returnTypeName = + member.type.typeName.text; + } + + const meth = methods.find( + meth => + meth.SDKFunctionName === + method.SDKFunctionName && + meth.fileName === method.fileName + ); + method.functionName = meth + ? meth.functionName + : null; + classInfo.methods.push(method); + } + + if (SyntaxKind[member.kind] === 'Constructor') { + const parameters = member.parameters.map(param => { + return { + name: param.name.text, + optional: param.questionToken + ? true + : false, + type: SyntaxKind[param.type.kind], + typeRefName: param.type.typeName + ? param.type.typeName.text + : null, + }; + }); + + classInfo.constructor = { + parameters, + }; + } + + if (SyntaxKind[member.kind] === 'PropertyDeclaration') { + const isPrivateProp = + member.modifiers && + member.modifiers.some( + modifier => + SyntaxKind[modifier.kind] === + 'PrivateKeyword' + ); + if (!isPrivateProp) { + const prop = { + name: member.name.text, + type: SyntaxKind[member.type.kind], + typeRefName: member.type.typeName + ? member.type.typeName.text + : null, + }; + classInfo.properties.push(prop); + } + } + }); + classes.push(classInfo); + }); + }); + + methods = []; + + classes.map(classData => { + const filteredMethods: any = classData.methods.filter( + meth => meth.functionName !== null + ); + filteredMethods.map(filMeth => { + filMeth.classConstructorData = classData.constructor; + }); + + methods = methods.concat(filteredMethods); + }); + + const extractedData = { + classes, + methods, + }; + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + reject(new Error('Data extraction unsuccessful')); + } else { + resolve(extractedData); + } + } catch (error) { + reject(error); + } + }); } export function extractClientBasedSDKdata(methods, sdkFiles): any { - const specifiedMethods = JSON.parse(JSON.stringify(methods)); - return new Promise(async (resolve, reject) => { - try { - sdkFiles.map(sdkFile => { - sdkFile.client = sdkFile.ast.name.text; - sdkFile.ast.members.map(member => { - if ( - SyntaxKind[member.kind] === "MethodDeclaration" && - sdkFile.sdkFunctionNames.includes(member.name.text) - ) { - const method = methods.find( - methd => methd.SDKFunctionName === member.name.text - ); - - const parameters = member.parameters.map(param => { - return { - name: param.name.text, - optional: param.questionToken ? true : false, - type: SyntaxKind[param.type.kind] - }; - }); - - const returnType = SyntaxKind[member.type.kind]; - if (returnType === "TypeReference") { - method.returnTypeName = member.type.typeName.text; - } - - if (!method.returnType) { - method.params = parameters; - method.returnType = returnType; - method.client = sdkFile.client; - } else { - const clone = JSON.parse(JSON.stringify(method)); - clone.params = parameters; - clone.returnType = returnType; - clone.client = sdkFile.client; - methods.push(clone); - } - } - }); - }); - - if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { - reject(new Error("Data extraction unsuccessful")); - } else { - resolve(methods); - } - } catch (error) { - reject(error); - } - }); + const specifiedMethods = JSON.parse(JSON.stringify(methods)); + return new Promise(async (resolve, reject) => { + try { + sdkFiles.map(sdkFile => { + sdkFile.client = sdkFile.ast.name.text; + sdkFile.ast.members.map(member => { + if ( + SyntaxKind[member.kind] === 'MethodDeclaration' && + sdkFile.sdkFunctionNames.includes(member.name.text) + ) { + const method = methods.find( + methd => methd.SDKFunctionName === member.name.text + ); + + const parameters = member.parameters.map(param => { + return { + name: param.name.text, + optional: param.questionToken ? true : false, + type: SyntaxKind[param.type.kind], + }; + }); + + const returnType = SyntaxKind[member.type.kind]; + if (returnType === 'TypeReference') { + method.returnTypeName = member.type.typeName.text; + } + + if (!method.returnType) { + method.params = parameters; + method.returnType = returnType; + method.client = sdkFile.client; + } else { + const clone = JSON.parse(JSON.stringify(method)); + clone.params = parameters; + clone.returnType = returnType; + clone.client = sdkFile.client; + methods.push(clone); + } + } + }); + }); + + if (JSON.stringify(methods) === JSON.stringify(specifiedMethods)) { + reject(new Error('Data extraction unsuccessful')); + } else { + resolve(methods); + } + } catch (error) { + reject(error); + } + }); } async function generateClassBasedCode(methods, data, serviceName) { - const dirPath = `../../../node_modules/@google-cloud/${methods[0].pkgName}/build/src/`; - let files = fs.readdirSync(path.join(__dirname, dirPath)); - files = files.filter( - fileName => - fileName.split(".")[1] === "d" && fileName.split(".")[2] === "ts" - ); - - const sdkFiles = files.map(fileName => { - return { - fileName: fileName, - pkgName: methods[0].pkgName, - classes: null, - sdkFunctionNames: methods - .filter(method => method.fileName === fileName) - .map(method => method.SDKFunctionName) - }; - }); - - await Promise.all( - sdkFiles.map(async file => { - file.classes = await getAST(file, true); - }) - ); - - const extractedData = await extractClassBasedSDKData(methods, sdkFiles).then( - result => result - ); - const groupedMethods = groupers.gcp(extractedData.methods); - methods = filters.gcp(groupedMethods); - data.functions = methods; - data.classData = extractedData.classes; - data.serviceName = serviceName; - - const output = await classBasedTransform(dummyAst, data); - let filePath; - const dir = getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - printFile(filePath, output); + const dirPath = `../../../node_modules/@google-cloud/${methods[0].pkgName}/build/src/`; + let files = fs.readdirSync(path.join(__dirname, dirPath)); + files = files.filter( + fileName => + fileName.split('.')[1] === 'd' && fileName.split('.')[2] === 'ts' + ); + + const sdkFiles = files.map(fileName => { + return { + fileName: fileName, + pkgName: methods[0].pkgName, + classes: null, + sdkFunctionNames: methods + .filter(method => method.fileName === fileName) + .map(method => method.SDKFunctionName), + }; + }); + + await Promise.all( + sdkFiles.map(async file => { + file.classes = await getAST(file, true); + }) + ); + + const extractedData = await extractClassBasedSDKData( + methods, + sdkFiles + ).then(result => result); + const groupedMethods = groupers.gcp(extractedData.methods); + methods = filters.gcp(groupedMethods); + data.functions = methods; + data.classData = extractedData.classes; + data.serviceName = serviceName; + + const output = await classBasedTransform(dummyAst, data); + let filePath; + const dir = getDir(serviceName); + if ( + !fs.existsSync(process.cwd() + '/generatedClasses/googleCloud/' + dir) + ) { + fs.mkdirSync(process.cwd() + '/generatedClasses/googleCloud/' + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + printFile(filePath, output); } async function generateClientBasedCode(methods, serviceName) { - const files = Array.from( - new Set(methods.map(method => method.fileName + " " + method.version)) - ); - const sdkFiles = files.map(file => { - return { - fileName: (file).split(" ")[0], - version: (file).split(" ")[1], - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(method => method.fileName === (file).split(" ")[0]) - .map(method => method.SDKFunctionName) - }; - }); - - await Promise.all( - sdkFiles.map(async file => { - file.ast = await getAST(file); - }) - ); - - methods = await extractClientBasedSDKdata(methods, sdkFiles).then( - result => result - ); - const groupedMethods = groupers.gcp(methods); - methods = filters.gcp(groupedMethods); - - const classData = { - functions: methods, - serviceName - }; - - const output = await clientBasedTransform(dummyAst, classData); - let filePath; - const dir = getDir(serviceName); - if (!fs.existsSync(process.cwd() + "/generatedClasses/googleCloud/" + dir)) { - fs.mkdirSync(process.cwd() + "/generatedClasses/googleCloud/" + dir); - } - if (/^[A-Z]*$/.test(serviceName)) { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName + - ".js"; - } else { - filePath = - process.cwd() + - "/generatedClasses/googleCloud/" + - dir + - "/gcp-" + - serviceName.charAt(0).toLowerCase() + - serviceName.slice(1) + - ".js"; - } - printFile(filePath, output); + const files = Array.from( + new Set(methods.map(method => method.fileName + ' ' + method.version)) + ); + const sdkFiles = files.map(file => { + return { + fileName: (file).split(' ')[0], + version: (file).split(' ')[1], + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter( + method => method.fileName === (file).split(' ')[0] + ) + .map(method => method.SDKFunctionName), + }; + }); + + await Promise.all( + sdkFiles.map(async file => { + file.ast = await getAST(file); + }) + ); + + methods = await extractClientBasedSDKdata(methods, sdkFiles).then( + result => result + ); + const groupedMethods = groupers.gcp(methods); + methods = filters.gcp(groupedMethods); + + const classData = { + functions: methods, + serviceName, + }; + + const output = await clientBasedTransform(dummyAst, classData); + let filePath; + const dir = getDir(serviceName); + if ( + !fs.existsSync(process.cwd() + '/generatedClasses/googleCloud/' + dir) + ) { + fs.mkdirSync(process.cwd() + '/generatedClasses/googleCloud/' + dir); + } + if (/^[A-Z]*$/.test(serviceName)) { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName + + '.js'; + } else { + filePath = + process.cwd() + + '/generatedClasses/googleCloud/' + + dir + + '/gcp-' + + serviceName.charAt(0).toLowerCase() + + serviceName.slice(1) + + '.js'; + } + printFile(filePath, output); } export async function generateGCPClass(serviceClass, serviceName) { - let methods: FunctionData[] = []; - const data: any = {}; - - Object.keys(serviceClass).map((key, index) => { - if (key === "mainClass") { - data.mainClass = serviceClass[key]; - } else if ( - serviceClass[key].split(" ")[1].length === 2 && - serviceClass[key].split(" ")[1].charAt(0) === "v" - ) { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: serviceClass[key].split(" ")[1], - fileName: serviceClass[key].split(" ")[2], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[3], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } else { - methods.push({ - pkgName: serviceClass[key].split(" ")[0], - version: null, - fileName: serviceClass[key].split(" ")[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(" ")[2], - params: [], - returnType: null, - returnTypeName: null, - client: null - }); - } - }); - - if (methods[0].version) { - generateClientBasedCode(methods, serviceName); - } else { - generateClassBasedCode(methods, data, serviceName); - } + const methods: FunctionData[] = []; + const data: any = {}; + + Object.keys(serviceClass).map((key, index) => { + if (key === 'mainClass') { + data.mainClass = serviceClass[key]; + } else if ( + serviceClass[key].split(' ')[1].length === 2 && + serviceClass[key].split(' ')[1].charAt(0) === 'v' + ) { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + version: serviceClass[key].split(' ')[1], + fileName: serviceClass[key].split(' ')[2], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[3], + params: [], + returnType: null, + returnTypeName: null, + client: null, + }); + } else { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + version: null, + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + returnTypeName: null, + client: null, + }); + } + }); + + if (methods[0].version) { + generateClientBasedCode(methods, serviceName); + } else { + generateClassBasedCode(methods, data, serviceName); + } } diff --git a/generator/generators/lib/aws/awsHelper.js b/generator/generators/lib/aws/awsHelper.js index 440e473f..b43d982f 100644 --- a/generator/generators/lib/aws/awsHelper.js +++ b/generator/generators/lib/aws/awsHelper.js @@ -1,34 +1,38 @@ -"use strict"; +'use strict'; exports.__esModule = true; exports.filterAWSMethods = exports.groupAWSMethods = void 0; function groupAWSMethods(methods) { - var methodArr = Object.values(methods.reduce(function (result, _a) { - var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params - }); - return result; - }, {})); - return methodArr; + var methodArr = Object.values( + methods.reduce(function(result, _a) { + var functionName = _a.functionName, + SDKFunctionName = _a.SDKFunctionName, + params = _a.params; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params, + }); + return result; + }, {}) + ); + return methodArr; } exports.groupAWSMethods = groupAWSMethods; function filterAWSMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function (group) { - group.array.sort(function (a, b) { - return a.params.length - b.params.length; - }); - methods.push(group.array.slice(-1)[0]); - }); - return methods; + var methods = []; + groupedMethods.map(function(group) { + group.array.sort(function(a, b) { + return a.params.length - b.params.length; + }); + methods.push(group.array.slice(-1)[0]); + }); + return methods; } exports.filterAWSMethods = filterAWSMethods; diff --git a/generator/generators/lib/aws/awsHelper.ts b/generator/generators/lib/aws/awsHelper.ts index 7cfe04de..13ddcd09 100644 --- a/generator/generators/lib/aws/awsHelper.ts +++ b/generator/generators/lib/aws/awsHelper.ts @@ -1,32 +1,32 @@ export function groupAWSMethods(methods): any { - const methodArr = Object.values( - methods.reduce((result, { functionName, SDKFunctionName, params }) => { - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName, - SDKFunctionName, - params - }); - return result; - }, {}) - ); + const methodArr = Object.values( + methods.reduce((result, { functionName, SDKFunctionName, params }) => { + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName, + SDKFunctionName, + params, + }); + return result; + }, {}) + ); - return methodArr; + return methodArr; } export function filterAWSMethods(groupedMethods): any { - let methods = []; - groupedMethods.map(group => { - group.array.sort(function(a, b) { - return a.params.length - b.params.length; - }); - methods.push(group.array.slice(-1)[0]); - }); - return methods; + const methods = []; + groupedMethods.map(group => { + group.array.sort(function(a, b) { + return a.params.length - b.params.length; + }); + methods.push(group.array.slice(-1)[0]); + }); + return methods; } diff --git a/generator/generators/lib/azure/azureHelper.js b/generator/generators/lib/azure/azureHelper.js index c0a0f595..38e14b07 100644 --- a/generator/generators/lib/azure/azureHelper.js +++ b/generator/generators/lib/azure/azureHelper.js @@ -1,49 +1,60 @@ -"use strict"; +'use strict'; exports.__esModule = true; exports.filterAzureMethods = exports.groupAzureMethods = void 0; function groupAzureMethods(methods) { - var methodArr = Object.values(methods.reduce(function (result, _a) { - var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params, pkgName = _a.pkgName, fileName = _a.fileName, client = _a.client, returnType = _a.returnType; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params, - pkgName: pkgName, - fileName: fileName, - client: client, - returnType: returnType - }); - return result; - }, {})); - return methodArr; + var methodArr = Object.values( + methods.reduce(function(result, _a) { + var functionName = _a.functionName, + SDKFunctionName = _a.SDKFunctionName, + params = _a.params, + pkgName = _a.pkgName, + fileName = _a.fileName, + client = _a.client, + returnType = _a.returnType; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params, + pkgName: pkgName, + fileName: fileName, + client: client, + returnType: returnType, + }); + return result; + }, {}) + ); + return methodArr; } exports.groupAzureMethods = groupAzureMethods; function filterAzureMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function (group) { - if (group.array.length === 1) { - methods.push(group.array[0]); - } - else { - var methodPushed_1 = false; - group.array.map(function (method) { - if (!method.params.find(function (param) { return param.name === "callback"; })) { - methods.push(method); - methodPushed_1 = true; - } - }); - if (!methodPushed_1) { - methods.push(group.array[0]); - } - } - }); - return methods; + var methods = []; + groupedMethods.map(function(group) { + if (group.array.length === 1) { + methods.push(group.array[0]); + } else { + var methodPushed_1 = false; + group.array.map(function(method) { + if ( + !method.params.find(function(param) { + return param.name === 'callback'; + }) + ) { + methods.push(method); + methodPushed_1 = true; + } + }); + if (!methodPushed_1) { + methods.push(group.array[0]); + } + } + }); + return methods; } exports.filterAzureMethods = filterAzureMethods; diff --git a/generator/generators/lib/azure/azureHelper.ts b/generator/generators/lib/azure/azureHelper.ts index dc066724..d9d752db 100644 --- a/generator/generators/lib/azure/azureHelper.ts +++ b/generator/generators/lib/azure/azureHelper.ts @@ -1,60 +1,60 @@ export function groupAzureMethods(methods): any { - const methodArr = Object.values( - methods.reduce( - ( - result, - { - functionName, - SDKFunctionName, - params, - pkgName, - fileName, - client, - returnType - } - ) => { - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName, - SDKFunctionName, - params, - pkgName, - fileName, - client, - returnType - }); - return result; - }, - {} - ) - ); + const methodArr = Object.values( + methods.reduce( + ( + result, + { + functionName, + SDKFunctionName, + params, + pkgName, + fileName, + client, + returnType, + } + ) => { + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName, + SDKFunctionName, + params, + pkgName, + fileName, + client, + returnType, + }); + return result; + }, + {} + ) + ); - return methodArr; + return methodArr; } export function filterAzureMethods(groupedMethods): any { - let methods = []; - groupedMethods.map(group => { - if (group.array.length === 1) { - methods.push(group.array[0]); - } else { - let methodPushed = false; - group.array.map(method => { - if (!method.params.find(param => param.name === "callback")) { - methods.push(method); - methodPushed = true; - } - }); - if (!methodPushed) { - methods.push(group.array[0]); - } - } - }); - return methods; + const methods = []; + groupedMethods.map(group => { + if (group.array.length === 1) { + methods.push(group.array[0]); + } else { + let methodPushed = false; + group.array.map(method => { + if (!method.params.find(param => param.name === 'callback')) { + methods.push(method); + methodPushed = true; + } + }); + if (!methodPushed) { + methods.push(group.array[0]); + } + } + }); + return methods; } diff --git a/generator/generators/lib/googleCloud/gcpHelper.js b/generator/generators/lib/googleCloud/gcpHelper.js index 7ec28cb2..3a8caddd 100644 --- a/generator/generators/lib/googleCloud/gcpHelper.js +++ b/generator/generators/lib/googleCloud/gcpHelper.js @@ -1,51 +1,64 @@ -"use strict"; +'use strict'; exports.__esModule = true; exports.filterGCPMethods = exports.groupGCPMethods = void 0; function groupGCPMethods(methods) { - var methodArr = Object.values(methods.reduce(function (result, _a) { - var functionName = _a.functionName, SDKFunctionName = _a.SDKFunctionName, params = _a.params, pkgName = _a.pkgName, fileName = _a.fileName, client = _a.client, returnType = _a.returnType, returnTypeName = _a.returnTypeName, classConstructorData = _a.classConstructorData; - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName: functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName: functionName, - SDKFunctionName: SDKFunctionName, - params: params, - pkgName: pkgName, - fileName: fileName, - client: client, - returnType: returnType, - returnTypeName: returnTypeName, - classConstructorData: classConstructorData - }); - return result; - }, {})); - return methodArr; + var methodArr = Object.values( + methods.reduce(function(result, _a) { + var functionName = _a.functionName, + SDKFunctionName = _a.SDKFunctionName, + params = _a.params, + pkgName = _a.pkgName, + fileName = _a.fileName, + client = _a.client, + returnType = _a.returnType, + returnTypeName = _a.returnTypeName, + classConstructorData = _a.classConstructorData; + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName: functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName: functionName, + SDKFunctionName: SDKFunctionName, + params: params, + pkgName: pkgName, + fileName: fileName, + client: client, + returnType: returnType, + returnTypeName: returnTypeName, + classConstructorData: classConstructorData, + }); + return result; + }, {}) + ); + return methodArr; } exports.groupGCPMethods = groupGCPMethods; function filterGCPMethods(groupedMethods) { - var methods = []; - groupedMethods.map(function (group) { - if (group.array.length === 1) { - methods.push(group.array[0]); - } - else { - var methodPushed_1 = false; - group.array.map(function (method) { - if (!method.params.find(function (param) { return param.name === "callback"; })) { - methods.push(method); - methodPushed_1 = true; - } - }); - if (!methodPushed_1) { - methods.push(group.array[0]); - } - } - }); - return methods; + var methods = []; + groupedMethods.map(function(group) { + if (group.array.length === 1) { + methods.push(group.array[0]); + } else { + var methodPushed_1 = false; + group.array.map(function(method) { + if ( + !method.params.find(function(param) { + return param.name === 'callback'; + }) + ) { + methods.push(method); + methodPushed_1 = true; + } + }); + if (!methodPushed_1) { + methods.push(group.array[0]); + } + } + }); + return methods; } exports.filterGCPMethods = filterGCPMethods; diff --git a/generator/generators/lib/googleCloud/gcpHelper.ts b/generator/generators/lib/googleCloud/gcpHelper.ts index 2b93f726..ee196b45 100644 --- a/generator/generators/lib/googleCloud/gcpHelper.ts +++ b/generator/generators/lib/googleCloud/gcpHelper.ts @@ -1,64 +1,64 @@ export function groupGCPMethods(methods): any { - const methodArr = Object.values( - methods.reduce( - ( - result, - { - functionName, - SDKFunctionName, - params, - pkgName, - fileName, - client, - returnType, - returnTypeName, - classConstructorData - } - ) => { - // Create new group - if (!result[functionName]) - result[functionName] = { - functionName, - array: [] - }; - // Append to group - result[functionName].array.push({ - functionName, - SDKFunctionName, - params, - pkgName, - fileName, - client, - returnType, - returnTypeName, - classConstructorData - }); - return result; - }, - {} - ) - ); + const methodArr = Object.values( + methods.reduce( + ( + result, + { + functionName, + SDKFunctionName, + params, + pkgName, + fileName, + client, + returnType, + returnTypeName, + classConstructorData, + } + ) => { + // Create new group + if (!result[functionName]) + result[functionName] = { + functionName, + array: [], + }; + // Append to group + result[functionName].array.push({ + functionName, + SDKFunctionName, + params, + pkgName, + fileName, + client, + returnType, + returnTypeName, + classConstructorData, + }); + return result; + }, + {} + ) + ); - return methodArr; + return methodArr; } export function filterGCPMethods(groupedMethods): any { - let methods = []; - groupedMethods.map(group => { - if (group.array.length === 1) { - methods.push(group.array[0]); - } else { - let methodPushed = false; - group.array.map(method => { - if (!method.params.find(param => param.name === "callback")) { - methods.push(method); - methodPushed = true; - } - }); - if (!methodPushed) { - methods.push(group.array[0]); - } - } - }); - return methods; + const methods = []; + groupedMethods.map(group => { + if (group.array.length === 1) { + methods.push(group.array[0]); + } else { + let methodPushed = false; + group.array.map(method => { + if (!method.params.find(param => param.name === 'callback')) { + methods.push(method); + methodPushed = true; + } + }); + if (!methodPushed) { + methods.push(group.array[0]); + } + } + }); + return methods; } diff --git a/generator/generators/lib/helper.js b/generator/generators/lib/helper.js index 6a79b2fd..4fbdb30a 100644 --- a/generator/generators/lib/helper.js +++ b/generator/generators/lib/helper.js @@ -1,48 +1,47 @@ -"use strict"; +'use strict'; exports.__esModule = true; exports.groupers = exports.getDir = exports.filters = exports.printFile = void 0; -var fs = require("fs"); -var awsHelper_1 = require("../lib/aws/awsHelper"); -var awsHelper_2 = require("../lib/aws/awsHelper"); -var azureHelper_1 = require("../lib/azure/azureHelper"); -var azureHelper_2 = require("../lib/azure/azureHelper"); -var gcpHelper_1 = require("../lib/googleCloud/gcpHelper"); -var gcpHelper_2 = require("../lib/googleCloud/gcpHelper"); +var fs = require('fs'); +var awsHelper_1 = require('../lib/aws/awsHelper'); +var awsHelper_2 = require('../lib/aws/awsHelper'); +var azureHelper_1 = require('../lib/azure/azureHelper'); +var azureHelper_2 = require('../lib/azure/azureHelper'); +var gcpHelper_1 = require('../lib/googleCloud/gcpHelper'); +var gcpHelper_2 = require('../lib/googleCloud/gcpHelper'); var dirMap = { - appServices: ["PaaS"], - compute: ["ComputeInstance", "Kubernetes", "Container"], - database: ["NoSqlIndexed", "RDBMS", "NoSql"], - management: ["Monitoring", "KeyManagement", "NotificationService"], - network: ["DNS", "LoadBalancer"], - security: ["IAM"], - storage: ["StorageBucket", "BlockStorage", "ArchivalStorage"], - artificialinteligence: ["Translation"] + appServices: ['PaaS'], + compute: ['ComputeInstance', 'Kubernetes', 'Container'], + database: ['NoSqlIndexed', 'RDBMS', 'NoSql'], + management: ['Monitoring', 'KeyManagement', 'NotificationService'], + network: ['DNS', 'LoadBalancer'], + security: ['IAM'], + storage: ['StorageBucket', 'BlockStorage', 'ArchivalStorage'], + artificialinteligence: ['Translation'], }; function printFile(fileName, data) { - fs.writeFile(fileName, data, function (err) { - if (err) - throw err; - }); + fs.writeFile(fileName, data, function(err) { + if (err) throw err; + }); } exports.printFile = printFile; var groupers = { - aws: awsHelper_1.groupAWSMethods, - gcp: gcpHelper_1.groupGCPMethods, - azure: azureHelper_1.groupAzureMethods + aws: awsHelper_1.groupAWSMethods, + gcp: gcpHelper_1.groupGCPMethods, + azure: azureHelper_1.groupAzureMethods, }; exports.groupers = groupers; var filters = { - aws: awsHelper_2.filterAWSMethods, - gcp: gcpHelper_2.filterGCPMethods, - azure: azureHelper_2.filterAzureMethods + aws: awsHelper_2.filterAWSMethods, + gcp: gcpHelper_2.filterGCPMethods, + azure: azureHelper_2.filterAzureMethods, }; exports.filters = filters; -var getDir = function (service) { - for (var dir in dirMap) { - if (dirMap[dir].includes(service)) { - return dir; - } - } - throw new Error("Not a valid service: " + service); +var getDir = function(service) { + for (var dir in dirMap) { + if (dirMap[dir].includes(service)) { + return dir; + } + } + throw new Error('Not a valid service: ' + service); }; exports.getDir = getDir; diff --git a/generator/generators/lib/helper.ts b/generator/generators/lib/helper.ts index 31c67b7c..883aebc9 100644 --- a/generator/generators/lib/helper.ts +++ b/generator/generators/lib/helper.ts @@ -1,48 +1,48 @@ -import * as fs from "fs"; +import * as fs from 'fs'; -import { groupAWSMethods } from "../lib/aws/awsHelper"; -import { filterAWSMethods } from "../lib/aws/awsHelper"; -import { groupAzureMethods } from "../lib/azure/azureHelper"; -import { filterAzureMethods } from "../lib/azure/azureHelper"; -import { groupGCPMethods } from "../lib/googleCloud/gcpHelper"; -import { filterGCPMethods } from "../lib/googleCloud/gcpHelper"; +import { groupAWSMethods } from '../lib/aws/awsHelper'; +import { filterAWSMethods } from '../lib/aws/awsHelper'; +import { groupAzureMethods } from '../lib/azure/azureHelper'; +import { filterAzureMethods } from '../lib/azure/azureHelper'; +import { groupGCPMethods } from '../lib/googleCloud/gcpHelper'; +import { filterGCPMethods } from '../lib/googleCloud/gcpHelper'; const dirMap = { - appServices: ["PaaS"], - compute: ["ComputeInstance", "Kubernetes", "Container"], - database: ["NoSqlIndexed", "RDBMS", "NoSql"], - management: ["Monitoring", "KeyManagement", "NotificationService"], - network: ["DNS", "LoadBalancer"], - security: ["IAM"], - storage: ["StorageBucket", "BlockStorage", "ArchivalStorage"], - artificialinteligence: ["Translation"] + appServices: ['PaaS'], + compute: ['ComputeInstance', 'Kubernetes', 'Container'], + database: ['NoSqlIndexed', 'RDBMS', 'NoSql'], + management: ['Monitoring', 'KeyManagement', 'NotificationService'], + network: ['DNS', 'LoadBalancer'], + security: ['IAM'], + storage: ['StorageBucket', 'BlockStorage', 'ArchivalStorage'], + artificialinteligence: ['Translation'], }; export function printFile(fileName, data) { - fs.writeFile(fileName, data, function(err) { - if (err) throw err; - }); + fs.writeFile(fileName, data, function(err) { + if (err) throw err; + }); } const groupers = { - aws: groupAWSMethods, - gcp: groupGCPMethods, - azure: groupAzureMethods + aws: groupAWSMethods, + gcp: groupGCPMethods, + azure: groupAzureMethods, }; const filters = { - aws: filterAWSMethods, - gcp: filterGCPMethods, - azure: filterAzureMethods + aws: filterAWSMethods, + gcp: filterGCPMethods, + azure: filterAzureMethods, }; const getDir = (service: string): string => { - for (let dir in dirMap) { - if (dirMap[dir].includes(service)) { - return dir; - } - } - throw new Error("Not a valid service: " + service); + for (const dir in dirMap) { + if (dirMap[dir].includes(service)) { + return dir; + } + } + throw new Error('Not a valid service: ' + service); }; -export { filters, getDir,groupers }; +export { filters, getDir, groupers }; diff --git a/generator/generators/linode/generator.js b/generator/generators/linode/generator.js index 34bd95fc..16932040 100644 --- a/generator/generators/linode/generator.js +++ b/generator/generators/linode/generator.js @@ -1,144 +1,263 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.generateLinodeClass = exports.extractSDKData = void 0; -var typescript_1 = require("typescript"); -var parser_1 = require("../../parsers/linode/parser"); +var typescript_1 = require('typescript'); +var parser_1 = require('../../parsers/linode/parser'); function extractSDKData(sdkAst, serviceClass) { - var methods = []; - var functions = []; - Object.keys(serviceClass).map(function (key, index) { - functions.push(serviceClass[key].split(' ')[2]); - }); - sdkAst.map(function (method) { - var methodName = method.name.escapedText; - if (methodName && functions.includes(methodName)) { - var name_1; - Object.keys(serviceClass).map(function (key, index) { - if (serviceClass[key].split(' ')[2] === methodName) { - name_1 = key; - } - }); - var parameters_1 = []; - var methodParameters = method.type.parameters; - methodParameters.map(function (param) { - if (param.name.excapedText !== 'callback') { - var parameter = { - name: param.name.escapedText, - optional: param.questionToken ? true : false, - type: typescript_1.SyntaxKind[param.type.kind], - typeName: null - }; - // common type - if (param.type.typeName) { - parameter.typeName = param.type.typeName.excapedText; - } - parameters_1.push(parameter); - } - }); - methods.push({ - functionName: name_1.toString(), - SDKFunctionName: methodName, - params: parameters_1 - }); - } - }); - var classData = { - className: '', - functions: methods, - serviceName: null - }; - return classData; + var methods = []; + var functions = []; + Object.keys(serviceClass).map(function(key, index) { + functions.push(serviceClass[key].split(' ')[2]); + }); + sdkAst.map(function(method) { + var methodName = method.name.escapedText; + if (methodName && functions.includes(methodName)) { + var name_1; + Object.keys(serviceClass).map(function(key, index) { + if (serviceClass[key].split(' ')[2] === methodName) { + name_1 = key; + } + }); + var parameters_1 = []; + var methodParameters = method.type.parameters; + methodParameters.map(function(param) { + if (param.name.excapedText !== 'callback') { + var parameter = { + name: param.name.escapedText, + optional: param.questionToken ? true : false, + type: typescript_1.SyntaxKind[param.type.kind], + typeName: null, + }; + // common type + if (param.type.typeName) { + parameter.typeName = param.type.typeName.excapedText; + } + parameters_1.push(parameter); + } + }); + methods.push({ + functionName: name_1.toString(), + SDKFunctionName: methodName, + params: parameters_1, + }); + } + }); + var classData = { + className: '', + functions: methods, + serviceName: null, + }; + return classData; } exports.extractSDKData = extractSDKData; function generateLinodeClass(serviceClass, serviceName) { - return __awaiter(this, void 0, void 0, function () { - var methods, files, sdkFiles; - var _this = this; - return __generator(this, function (_a) { - methods = []; - if (serviceClass == null) - return [2 /*return*/]; - Object.keys(serviceClass).map(function (key, index) { - methods.push({ - pkgName: serviceClass[key].split(' ')[0], - fileName: serviceClass[key].split(' ')[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(' ')[2], - params: [], - returnType: null, - client: null - }); - }); - files = Array.from(new Set(methods.map(function (method) { return method.fileName; }))); - sdkFiles = files.map(function (file) { - return { - fileName: file, - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(function (method) { return method.fileName === file; }) - .map(function (method) { return method.SDKFunctionName; }) - }; - }); - sdkFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - parser_1.getAST(file).then(function (result) { return __awaiter(_this, void 0, void 0, function () { - var sdkAst, classData; - return __generator(this, function (_a) { - sdkAst = result; - try { - classData = extractSDKData(sdkAst, serviceClass); - classData.serviceName = serviceName; - } - catch (e) { - console.error(e); - } - return [2 /*return*/]; - }); - }); }); - return [2 /*return*/]; - }); - }); }); - return [2 /*return*/]; - }); - }); + return __awaiter(this, void 0, void 0, function() { + var methods, files, sdkFiles; + var _this = this; + return __generator(this, function(_a) { + methods = []; + if (serviceClass == null) return [2 /*return*/]; + Object.keys(serviceClass).map(function(key, index) { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null, + }); + }); + files = Array.from( + new Set( + methods.map(function(method) { + return method.fileName; + }) + ) + ); + sdkFiles = files.map(function(file) { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(function(method) { + return method.fileName === file; + }) + .map(function(method) { + return method.SDKFunctionName; + }), + }; + }); + sdkFiles.map(function(file) { + return __awaiter(_this, void 0, void 0, function() { + var _this = this; + return __generator(this, function(_a) { + parser_1.getAST(file).then(function(result) { + return __awaiter(_this, void 0, void 0, function() { + var sdkAst, classData; + return __generator(this, function(_a) { + sdkAst = result; + try { + classData = extractSDKData( + sdkAst, + serviceClass + ); + classData.serviceName = serviceName; + } catch (e) { + console.error(e); + } + return [2 /*return*/]; + }); + }); + }); + return [2 /*return*/]; + }); + }); + }); + return [2 /*return*/]; + }); + }); } exports.generateLinodeClass = generateLinodeClass; diff --git a/generator/generators/linode/generator.ts b/generator/generators/linode/generator.ts index bf72be95..2c71772c 100644 --- a/generator/generators/linode/generator.ts +++ b/generator/generators/linode/generator.ts @@ -1,4 +1,5 @@ import { SyntaxKind } from 'typescript'; + import { getAST } from '../../parsers/linode/parser'; interface SDKClassData { @@ -31,7 +32,7 @@ interface param { } export function extractSDKData(sdkAst, serviceClass) { - let methods: FunctionData[] = []; + const methods: FunctionData[] = []; const functions = []; Object.keys(serviceClass).map((key, index) => { @@ -84,7 +85,7 @@ export function extractSDKData(sdkAst, serviceClass) { } export async function generateLinodeClass(serviceClass, serviceName) { - let methods: SDKClassData[] = []; + const methods: SDKClassData[] = []; if (serviceClass == null) return; Object.keys(serviceClass).map((key, index) => { methods.push({ @@ -111,7 +112,7 @@ export async function generateLinodeClass(serviceClass, serviceName) { .map(method => method.SDKFunctionName), }; }); - + sdkFiles.map(async file => { getAST(file).then(async result => { const sdkAst = result; @@ -121,7 +122,6 @@ export async function generateLinodeClass(serviceClass, serviceName) { serviceClass ); classData.serviceName = serviceName; - } catch (e) { console.error(e); } diff --git a/generator/main.js b/generator/main.js index 52fd2d17..fed351f3 100644 --- a/generator/main.js +++ b/generator/main.js @@ -1,27 +1,29 @@ -"use strict"; +'use strict'; exports.__esModule = true; -var fs = require("fs"); -var yaml = require("js-yaml"); -var generator_1 = require("./generators/linode/generator"); +var fs = require('fs'); +var yaml = require('js-yaml'); +var generator_1 = require('./generators/linode/generator'); try { - var services_1 = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); - Object.keys(services_1).map(function (service, index) { - Object.keys(services_1[service]).map(function (provider, index1) { - // if (provider === "Azure") { - // generateAzureClass(services[service][provider], service); - // } else if (provider === "AWS") { - // generateAWSClass(services[service][provider], service); - // } else if (provider === "GCP") { - // generateGCPClass(services[service][provider], service); - // } else if (provider == "DO") { - // generateDOClass(services[service][provider], service); - // } - if (provider == "Linode") { - generator_1.generateLinodeClass(services_1[service][provider], service); - } - }); - }); -} -catch (error) { - console.error("Error : ", error); + var services_1 = yaml.safeLoad(fs.readFileSync('node-cloud.yml', 'utf8')); + Object.keys(services_1).map(function(service, index) { + Object.keys(services_1[service]).map(function(provider, index1) { + // if (provider === "Azure") { + // generateAzureClass(services[service][provider], service); + // } else if (provider === "AWS") { + // generateAWSClass(services[service][provider], service); + // } else if (provider === "GCP") { + // generateGCPClass(services[service][provider], service); + // } else if (provider == "DO") { + // generateDOClass(services[service][provider], service); + // } + if (provider == 'Linode') { + generator_1.generateLinodeClass( + services_1[service][provider], + service + ); + } + }); + }); +} catch (error) { + console.error('Error : ', error); } diff --git a/generator/main.ts b/generator/main.ts index ed7148d4..a2bffd1f 100644 --- a/generator/main.ts +++ b/generator/main.ts @@ -1,30 +1,30 @@ -import * as fs from "fs"; -import * as yaml from "js-yaml"; +import * as fs from 'fs'; +import * as yaml from 'js-yaml'; -import { generateAWSClass } from "./generators/aws/generator"; -import { generateAzureClass } from "./generators/azure/generator"; -import { generateDOClass } from "./generators/do/generator"; -import { generateGCPClass } from "./generators/googleCloud/generator"; -import { generateLinodeClass } from "./generators/linode/generator"; +import { generateAWSClass } from './generators/aws/generator'; +import { generateAzureClass } from './generators/azure/generator'; +import { generateDOClass } from './generators/do/generator'; +import { generateGCPClass } from './generators/googleCloud/generator'; +import { generateLinodeClass } from './generators/linode/generator'; try { - const services = yaml.safeLoad(fs.readFileSync("node-cloud.yml", "utf8")); - Object.keys(services).map((service, index) => { - Object.keys(services[service]).map((provider, index1) => { - // if (provider === "Azure") { - // generateAzureClass(services[service][provider], service); - // } else if (provider === "AWS") { - // generateAWSClass(services[service][provider], service); - // } else if (provider === "GCP") { - // generateGCPClass(services[service][provider], service); - // } else if (provider == "DO") { - // generateDOClass(services[service][provider], service); - // } - if(provider == "Linode"){ - generateLinodeClass(services[service][provider],service); - } - }); - }); + const services = yaml.safeLoad(fs.readFileSync('node-cloud.yml', 'utf8')); + Object.keys(services).map((service, index) => { + Object.keys(services[service]).map((provider, index1) => { + // if (provider === "Azure") { + // generateAzureClass(services[service][provider], service); + // } else if (provider === "AWS") { + // generateAWSClass(services[service][provider], service); + // } else if (provider === "GCP") { + // generateGCPClass(services[service][provider], service); + // } else if (provider == "DO") { + // generateDOClass(services[service][provider], service); + // } + if (provider == 'Linode') { + generateLinodeClass(services[service][provider], service); + } + }); + }); } catch (error) { - console.error("Error : ", error); + console.error('Error : ', error); } diff --git a/generator/node-cloud.yml b/generator/node-cloud.yml index 67e4dbcf..4f864649 100644 --- a/generator/node-cloud.yml +++ b/generator/node-cloud.yml @@ -77,47 +77,47 @@ # terminateEnvironment: arm-appservice appServiceEnvironments.d.ts deleteMethod Kubernetes: -# Azure: -# create: arm-containerservice managedClusters.d.ts createOrUpdate -# delete: arm-containerservice managedClusters.d.ts deleteMethod -# updateTags: arm-containerservice managedClusters.d.ts updateTags -# listClusters: arm-containerservice managedClusters.d.ts list -# describeCluster: arm-containerservice managedClusters.d.ts get -# createNodeGroup: arm-containerservice agentPools.d.ts createOrUpdate -# deleteNodegroup: arm-containerservice agentPools.d.ts deleteMethod -# describeNodeGroup: arm-containerservice agentPools.d.ts get -# listNodegroups: arm-containerservice agentPools.d.ts list -# updateConfig: arm-containerservice managedClusters.d.ts rotateClusterCertificates -# GCP: -# create: container v1 cluster_manager_client.d.ts createCluster -# delete: container v1 cluster_manager_client.d.ts deleteCluster -# listClusters: container v1 cluster_manager_client.d.ts listClusters -# describeCluster: container v1 cluster_manager_client.d.ts getCluster -# createNodeGroup: container v1 cluster_manager_client.d.ts createNodePool -# deleteNodegroup: container v1 cluster_manager_client.d.ts deleteNodePool -# describeNodeGroup: container v1 cluster_manager_client.d.ts getNodePool -# listNodegroups: container v1 cluster_manager_client.d.ts listNodePools -# updateConfig: container v1 cluster_manager_client.d.ts setAddonsConfig -# AWS: -# create: eks.d.ts createCluster -# delete: eks.d.ts deleteCluster -# listClusters: eks.d.ts listClusters -# describeCluster: eks.d.ts describeCluster -# updateTags: eks.d.ts tagResource -# createNodeGroup: eks.d.ts createNodegroup -# deleteNodegroup: eks.d.ts deleteNodegroup -# describeNodeGroup: eks.d.ts describeNodegroup -# listNodegroups: eks.d.ts listNodegroups -# updateConfig: eks.d.ts updateClusterConfig -# DO: -# create: kubernetes.d.ts create -# delete: kubernetes.d.ts delete -# listClusters: kubernetes.d.ts getClusters -# describeCluster: kubernetes.d.ts getById -# createNodeGroup: kubernetes.d.ts addNodePool -# deleteNodegroup: kubernetes.d.ts deleteNodePool -# describeNodeGroup: kubernetes.d.ts getNodePoolById -# listNodegroups: kubernetes.d.ts getNodePools + # Azure: + # create: arm-containerservice managedClusters.d.ts createOrUpdate + # delete: arm-containerservice managedClusters.d.ts deleteMethod + # updateTags: arm-containerservice managedClusters.d.ts updateTags + # listClusters: arm-containerservice managedClusters.d.ts list + # describeCluster: arm-containerservice managedClusters.d.ts get + # createNodeGroup: arm-containerservice agentPools.d.ts createOrUpdate + # deleteNodegroup: arm-containerservice agentPools.d.ts deleteMethod + # describeNodeGroup: arm-containerservice agentPools.d.ts get + # listNodegroups: arm-containerservice agentPools.d.ts list + # updateConfig: arm-containerservice managedClusters.d.ts rotateClusterCertificates + # GCP: + # create: container v1 cluster_manager_client.d.ts createCluster + # delete: container v1 cluster_manager_client.d.ts deleteCluster + # listClusters: container v1 cluster_manager_client.d.ts listClusters + # describeCluster: container v1 cluster_manager_client.d.ts getCluster + # createNodeGroup: container v1 cluster_manager_client.d.ts createNodePool + # deleteNodegroup: container v1 cluster_manager_client.d.ts deleteNodePool + # describeNodeGroup: container v1 cluster_manager_client.d.ts getNodePool + # listNodegroups: container v1 cluster_manager_client.d.ts listNodePools + # updateConfig: container v1 cluster_manager_client.d.ts setAddonsConfig + # AWS: + # create: eks.d.ts createCluster + # delete: eks.d.ts deleteCluster + # listClusters: eks.d.ts listClusters + # describeCluster: eks.d.ts describeCluster + # updateTags: eks.d.ts tagResource + # createNodeGroup: eks.d.ts createNodegroup + # deleteNodegroup: eks.d.ts deleteNodegroup + # describeNodeGroup: eks.d.ts describeNodegroup + # listNodegroups: eks.d.ts listNodegroups + # updateConfig: eks.d.ts updateClusterConfig + # DO: + # create: kubernetes.d.ts create + # delete: kubernetes.d.ts delete + # listClusters: kubernetes.d.ts getClusters + # describeCluster: kubernetes.d.ts getById + # createNodeGroup: kubernetes.d.ts addNodePool + # deleteNodegroup: kubernetes.d.ts deleteNodePool + # describeNodeGroup: kubernetes.d.ts getNodePoolById + # listNodegroups: kubernetes.d.ts getNodePools Linode: create: kubernetes kubernetes.d.ts createKubernetesCluster delete: kubernetes kubernetes.d.ts deleteKubernetesCluster @@ -125,7 +125,6 @@ Kubernetes: createNodePool: kubernetes nodePools.d.ts createNodePool updateNodePool: kubernetes nodePools.d.ts updateNodePool deleteNodePool: kubernetes nodePools.d.ts deleteNodePool - # Monitoring: # GCP: # createAlarm: monitoring v3 alert_policy_service_client.d.ts createAlertPolicy diff --git a/generator/parsers/aws/parser.js b/generator/parsers/aws/parser.js index b285118e..7e661687 100644 --- a/generator/parsers/aws/parser.js +++ b/generator/parsers/aws/parser.js @@ -1,82 +1,202 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.getAST = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); function getAST(sdkFileName) { - var _this = this; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var file, ast, cloned_1, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join(__dirname, "../../../node_modules/aws-sdk/clients/" + sdkFileName.toLowerCase()); - ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); - cloned_1 = null; - return [4 /*yield*/, ast.forEachChild(function (child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - cloned_1 = Object.assign({}, child); - } - })]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } - else { - resolve(cloned_1); - } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } - else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var file, ast, cloned_1, error_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join( + __dirname, + '../../../node_modules/aws-sdk/clients/' + + sdkFileName.toLowerCase() + ); + ast = typescript_1.createSourceFile( + file, + fs.readFileSync(file).toString(), + typescript_1.ScriptTarget.Latest, + true + ); + cloned_1 = null; + return [ + 4 /*yield*/, + ast.forEachChild(function(child) { + if ( + typescript_1.SyntaxKind[child.kind] === + 'ClassDeclaration' + ) { + cloned_1 = Object.assign({}, child); + } + }), + ]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error('Class not found!')); + } else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); + }); } exports.getAST = getAST; diff --git a/generator/parsers/azure/parser.js b/generator/parsers/azure/parser.js index 96fafb87..d88c5450 100644 --- a/generator/parsers/azure/parser.js +++ b/generator/parsers/azure/parser.js @@ -1,82 +1,204 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.getAST = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); function getAST(sdkFileInfo) { - var _this = this; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var file, ast, cloned_1, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join(__dirname, "../../../node_modules/@azure/" + sdkFileInfo.pkgName + "/esm/operations/" + sdkFileInfo.fileName); - ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); - cloned_1 = null; - return [4 /*yield*/, ast.forEachChild(function (child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - cloned_1 = Object.assign({}, child); - } - })]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } - else { - resolve(cloned_1); - } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } - else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var file, ast, cloned_1, error_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join( + __dirname, + '../../../node_modules/@azure/' + + sdkFileInfo.pkgName + + '/esm/operations/' + + sdkFileInfo.fileName + ); + ast = typescript_1.createSourceFile( + file, + fs.readFileSync(file).toString(), + typescript_1.ScriptTarget.Latest, + true + ); + cloned_1 = null; + return [ + 4 /*yield*/, + ast.forEachChild(function(child) { + if ( + typescript_1.SyntaxKind[child.kind] === + 'ClassDeclaration' + ) { + cloned_1 = Object.assign({}, child); + } + }), + ]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error('Class not found!')); + } else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); + }); } exports.getAST = getAST; diff --git a/generator/parsers/do/parser.js b/generator/parsers/do/parser.js index e861342d..e1fb57ec 100644 --- a/generator/parsers/do/parser.js +++ b/generator/parsers/do/parser.js @@ -1,83 +1,202 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.getAST = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); function getAST(sdkFileName) { - var _this = this; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var file, ast, cloned_1, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join(__dirname, "../../../node_modules/do-wrapper/dist/modules/" + - sdkFileName.toLowerCase()); - ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); - cloned_1 = null; - return [4 /*yield*/, ast.forEachChild(function (child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - cloned_1 = Object.assign({}, child); - } - })]; - case 1: - _a.sent(); - if (!cloned_1) { - reject(new Error("Class not found!")); - } - else { - resolve(cloned_1); - } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } - else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var file, ast, cloned_1, error_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join( + __dirname, + '../../../node_modules/do-wrapper/dist/modules/' + + sdkFileName.toLowerCase() + ); + ast = typescript_1.createSourceFile( + file, + fs.readFileSync(file).toString(), + typescript_1.ScriptTarget.Latest, + true + ); + cloned_1 = null; + return [ + 4 /*yield*/, + ast.forEachChild(function(child) { + if ( + typescript_1.SyntaxKind[child.kind] === + 'ClassDeclaration' + ) { + cloned_1 = Object.assign({}, child); + } + }), + ]; + case 1: + _a.sent(); + if (!cloned_1) { + reject(new Error('Class not found!')); + } else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); + }); } exports.getAST = getAST; diff --git a/generator/parsers/googleCloud/parser.js b/generator/parsers/googleCloud/parser.js index cde5f858..1fcf3819 100644 --- a/generator/parsers/googleCloud/parser.js +++ b/generator/parsers/googleCloud/parser.js @@ -1,102 +1,234 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.getAST = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); function getAST(sdkFileInfo, multi) { - var _this = this; - var filePath; - if (sdkFileInfo.version) { - filePath = "../../../node_modules/@google-cloud/" + sdkFileInfo.pkgName + "/build/src/" + sdkFileInfo.version + "/" + sdkFileInfo.fileName; - } - else { - filePath = "../../../node_modules/@google-cloud/" + sdkFileInfo.pkgName + "/build/src/" + sdkFileInfo.fileName; - } - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var file, ast, classes_1, cloned, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - file = path.join(__dirname, filePath); - ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); - if (!(multi === true)) return [3 /*break*/, 1]; - classes_1 = []; - ast.forEachChild(function (child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - var cloned = Object.assign({}, child); - classes_1.push(cloned); - } - }); - resolve(classes_1); - return [3 /*break*/, 3]; - case 1: - cloned = null; - return [4 /*yield*/, ast.forEachChild(function (child) { - if (typescript_1.SyntaxKind[child.kind] === "ClassDeclaration") { - var cloned_1 = Object.assign({}, child); - return resolve(cloned_1); - } - })]; - case 2: - _a.sent(); - if (!cloned) { - return [2 /*return*/, reject(new Error("Class not found!"))]; - } - else { - return [2 /*return*/, resolve(cloned)]; - } - _a.label = 3; - case 3: return [3 /*break*/, 5]; - case 4: - error_1 = _a.sent(); - if (error_1.code === "ENOENT") { - reject(new Error("File not found!")); - } - else { - reject(error_1); - } - return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + var filePath; + if (sdkFileInfo.version) { + filePath = + '../../../node_modules/@google-cloud/' + + sdkFileInfo.pkgName + + '/build/src/' + + sdkFileInfo.version + + '/' + + sdkFileInfo.fileName; + } else { + filePath = + '../../../node_modules/@google-cloud/' + + sdkFileInfo.pkgName + + '/build/src/' + + sdkFileInfo.fileName; + } + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var file, ast, classes_1, cloned, error_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 4, , 5]); + file = path.join(__dirname, filePath); + ast = typescript_1.createSourceFile( + file, + fs.readFileSync(file).toString(), + typescript_1.ScriptTarget.Latest, + true + ); + if (!(multi === true)) return [3 /*break*/, 1]; + classes_1 = []; + ast.forEachChild(function(child) { + if ( + typescript_1.SyntaxKind[child.kind] === + 'ClassDeclaration' + ) { + var cloned = Object.assign({}, child); + classes_1.push(cloned); + } + }); + resolve(classes_1); + return [3 /*break*/, 3]; + case 1: + cloned = null; + return [ + 4 /*yield*/, + ast.forEachChild(function(child) { + if ( + typescript_1.SyntaxKind[child.kind] === + 'ClassDeclaration' + ) { + var cloned_1 = Object.assign({}, child); + return resolve(cloned_1); + } + }), + ]; + case 2: + _a.sent(); + if (!cloned) { + return [ + 2 /*return*/, + reject(new Error('Class not found!')), + ]; + } else { + return [2 /*return*/, resolve(cloned)]; + } + _a.label = 3; + case 3: + return [3 /*break*/, 5]; + case 4: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error_1); + } + return [3 /*break*/, 5]; + case 5: + return [2 /*return*/]; + } + }); + }); + }); } exports.getAST = getAST; diff --git a/generator/parsers/googleCloud/parser.ts b/generator/parsers/googleCloud/parser.ts index b8701074..1cf53b17 100644 --- a/generator/parsers/googleCloud/parser.ts +++ b/generator/parsers/googleCloud/parser.ts @@ -1,55 +1,55 @@ -import * as fs from "fs"; -import * as path from "path"; -import { createSourceFile, ScriptTarget, SyntaxKind } from "typescript"; +import * as fs from 'fs'; +import * as path from 'path'; +import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; export function getAST(sdkFileInfo, multi?: boolean) { - let filePath; - if (sdkFileInfo.version) { - filePath = `../../../node_modules/@google-cloud/${sdkFileInfo.pkgName}/build/src/${sdkFileInfo.version}/${sdkFileInfo.fileName}`; - } else { - filePath = `../../../node_modules/@google-cloud/${sdkFileInfo.pkgName}/build/src/${sdkFileInfo.fileName}`; - } + let filePath; + if (sdkFileInfo.version) { + filePath = `../../../node_modules/@google-cloud/${sdkFileInfo.pkgName}/build/src/${sdkFileInfo.version}/${sdkFileInfo.fileName}`; + } else { + filePath = `../../../node_modules/@google-cloud/${sdkFileInfo.pkgName}/build/src/${sdkFileInfo.fileName}`; + } - return new Promise(async (resolve, reject) => { - try { - const file = path.join(__dirname, filePath); - const ast = createSourceFile( - file, - fs.readFileSync(file).toString(), - ScriptTarget.Latest, - true - ); + return new Promise(async (resolve, reject) => { + try { + const file = path.join(__dirname, filePath); + const ast = createSourceFile( + file, + fs.readFileSync(file).toString(), + ScriptTarget.Latest, + true + ); - if (multi === true) { - let classes = []; - ast.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - let cloned = Object.assign({}, child); - classes.push(cloned); - } - }); - resolve(classes); - } else { - let cloned = null; - await ast.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - let cloned = Object.assign({}, child); - return resolve(cloned); - } - }); + if (multi === true) { + const classes = []; + ast.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + const cloned = Object.assign({}, child); + classes.push(cloned); + } + }); + resolve(classes); + } else { + const cloned = null; + await ast.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + const cloned = Object.assign({}, child); + return resolve(cloned); + } + }); - if (!cloned) { - return reject(new Error("Class not found!")); - } else { - return resolve(cloned); - } - } - } catch (error) { - if (error.code === "ENOENT") { - reject(new Error("File not found!")); - } else { - reject(error); - } - } - }); + if (!cloned) { + return reject(new Error('Class not found!')); + } else { + return resolve(cloned); + } + } + } catch (error) { + if (error.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error); + } + } + }); } diff --git a/generator/parsers/linode/parser.js b/generator/parsers/linode/parser.js index 4bf6bb89..7958cca4 100644 --- a/generator/parsers/linode/parser.js +++ b/generator/parsers/linode/parser.js @@ -1,98 +1,219 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.getAST = void 0; -var fs = require("fs"); -var path = require("path"); -var typescript_1 = require("typescript"); +var fs = require('fs'); +var path = require('path'); +var typescript_1 = require('typescript'); function getAST(sdkFileInfo) { - var _this = this; - return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { - var file, ast, cloned_1, tmp_1, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - file = path.join(__dirname, '../../../node_modules/@linode/api-v4/lib/' + - sdkFileInfo.pkgName + - '/' + - sdkFileInfo.fileName); - ast = typescript_1.createSourceFile(file, fs.readFileSync(file).toString(), typescript_1.ScriptTarget.Latest, true); - cloned_1 = []; - tmp_1 = null; - return [4 /*yield*/, ast.forEachChild(function (child) { - // fs.writeFile('test.txt', SyntaxKind[child.kind], null); - // console.log(SyntaxKind[child.kind]); - // console.log('Linode', SyntaxKind[child.kind]); - // console.log("child",child); - if (typescript_1.SyntaxKind[child.kind] === 'FirstStatement') { - // console.log("child",child); - // resolve(false) - tmp_1 = Object.assign({}, child); - cloned_1.push(tmp_1.declarationList.declarations[0]); - // console.log( - // 'name', - // tmp.declarationList.declarations[0].type.parameters[0] - // ); - } - })]; - case 1: - _a.sent(); - // console.log('cloned', cloned); - if (!cloned_1) { - reject(new Error('Function not found!')); - } - else { - resolve(cloned_1); - } - return [3 /*break*/, 3]; - case 2: - error_1 = _a.sent(); - if (error_1.code === 'ENOENT') { - reject(new Error('File not found!')); - } - else { - reject(error_1); - } - return [3 /*break*/, 3]; - case 3: return [2 /*return*/]; - } - }); - }); }); + var _this = this; + return new Promise(function(resolve, reject) { + return __awaiter(_this, void 0, void 0, function() { + var file, ast, cloned_1, tmp_1, error_1; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 2, , 3]); + file = path.join( + __dirname, + '../../../node_modules/@linode/api-v4/lib/' + + sdkFileInfo.pkgName + + '/' + + sdkFileInfo.fileName + ); + ast = typescript_1.createSourceFile( + file, + fs.readFileSync(file).toString(), + typescript_1.ScriptTarget.Latest, + true + ); + cloned_1 = []; + tmp_1 = null; + return [ + 4 /*yield*/, + ast.forEachChild(function(child) { + // fs.writeFile('test.txt', SyntaxKind[child.kind], null); + // console.log(SyntaxKind[child.kind]); + // console.log('Linode', SyntaxKind[child.kind]); + // console.log("child",child); + if ( + typescript_1.SyntaxKind[child.kind] === + 'FirstStatement' + ) { + // console.log("child",child); + // resolve(false) + tmp_1 = Object.assign({}, child); + cloned_1.push( + tmp_1.declarationList.declarations[0] + ); + // console.log( + // 'name', + // tmp.declarationList.declarations[0].type.parameters[0] + // ); + } + }), + ]; + case 1: + _a.sent(); + // console.log('cloned', cloned); + if (!cloned_1) { + reject(new Error('Function not found!')); + } else { + resolve(cloned_1); + } + return [3 /*break*/, 3]; + case 2: + error_1 = _a.sent(); + if (error_1.code === 'ENOENT') { + reject(new Error('File not found!')); + } else { + reject(error_1); + } + return [3 /*break*/, 3]; + case 3: + return [2 /*return*/]; + } + }); + }); + }); } exports.getAST = getAST; diff --git a/generator/parsers/linode/parser.ts b/generator/parsers/linode/parser.ts index 5c809b2e..7308ea0f 100644 --- a/generator/parsers/linode/parser.ts +++ b/generator/parsers/linode/parser.ts @@ -5,7 +5,6 @@ import { createSourceFile, ScriptTarget, SyntaxKind } from 'typescript'; export function getAST(sdkFileInfo) { return new Promise(async (resolve, reject) => { try { - const file = path.join( __dirname, '../../../node_modules/@linode/api-v4/lib/' + @@ -21,7 +20,7 @@ export function getAST(sdkFileInfo) { true ); - let cloned = []; + const cloned = []; let tmp = null; await ast.forEachChild(child => { // fs.writeFile('test.txt', SyntaxKind[child.kind], null); @@ -41,7 +40,6 @@ export function getAST(sdkFileInfo) { // tmp.declarationList.declarations[0].type.parameters[0] // ); } - }); // console.log('cloned', cloned); diff --git a/generator/test/generators/googleCloud/generator.test.ts b/generator/test/generators/googleCloud/generator.test.ts index 3b339d3c..0702d965 100644 --- a/generator/test/generators/googleCloud/generator.test.ts +++ b/generator/test/generators/googleCloud/generator.test.ts @@ -1,159 +1,163 @@ -import { expect } from "chai"; -import { SyntaxKind } from "typescript"; +import { expect } from 'chai'; +import { SyntaxKind } from 'typescript'; import { - extractClassBasedSDKData, - extractClientBasedSDKdata -} from "../../../generators/googleCloud/generator"; -import { readJsonData, readSourceFile } from "../lib/helper"; - -describe("GCP generator extractClassBasedSDKData", () => { - context("with valid methods and valid AST", () => { - it("should return class data", async () => { - const methods: any = await readJsonData( - "validDataset_1", - "googleCloud", - "methods" - ); - - const sdkFiles: any = await readJsonData( - "validDataset_1", - "googleCloud", - "files" - ); - - await Promise.all( - sdkFiles.map(async file => { - file.classes = []; - const sdkFile: any = await readSourceFile( - "validDataset_1", - "googleCloud" - ); - sdkFile.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - let cloned = Object.assign({}, child); - file.classes.push(cloned); - } - }); - }) - ); - - extractClassBasedSDKData(methods, sdkFiles).then(result => { - expect(result).to.be.an("object"); - expect(result.methods).to.be.an("array"); - }); - }); - }); - - context("with invalid AST", () => { - it("should return Error", async () => { - const methods: any = await readJsonData( - "invalidDataset_1", - "googleCloud", - "methods" - ); - - const sdkFiles: any = await readJsonData( - "invalidDataset_1", - "googleCloud", - "files" - ); - - await Promise.all( - sdkFiles.map(async file => { - file.classes = []; - const sdkFile: any = await readSourceFile( - "invalidDataset_1", - "googleCloud" - ); - sdkFile.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - let cloned = Object.assign({}, child); - file.classes.push(cloned); - } - }); - }) - ); - - extractClassBasedSDKData(methods, sdkFiles).then( - result => {}, - error => { - expect(error.message).to.eql("Data extraction unsuccessful"); - } - ); - }); - }); + extractClassBasedSDKData, + extractClientBasedSDKdata, +} from '../../../generators/googleCloud/generator'; +import { readJsonData, readSourceFile } from '../lib/helper'; + +describe('GCP generator extractClassBasedSDKData', () => { + context('with valid methods and valid AST', () => { + it('should return class data', async () => { + const methods: any = await readJsonData( + 'validDataset_1', + 'googleCloud', + 'methods' + ); + + const sdkFiles: any = await readJsonData( + 'validDataset_1', + 'googleCloud', + 'files' + ); + + await Promise.all( + sdkFiles.map(async file => { + file.classes = []; + const sdkFile: any = await readSourceFile( + 'validDataset_1', + 'googleCloud' + ); + sdkFile.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + const cloned = Object.assign({}, child); + file.classes.push(cloned); + } + }); + }) + ); + + extractClassBasedSDKData(methods, sdkFiles).then(result => { + expect(result).to.be.an('object'); + expect(result.methods).to.be.an('array'); + }); + }); + }); + + context('with invalid AST', () => { + it('should return Error', async () => { + const methods: any = await readJsonData( + 'invalidDataset_1', + 'googleCloud', + 'methods' + ); + + const sdkFiles: any = await readJsonData( + 'invalidDataset_1', + 'googleCloud', + 'files' + ); + + await Promise.all( + sdkFiles.map(async file => { + file.classes = []; + const sdkFile: any = await readSourceFile( + 'invalidDataset_1', + 'googleCloud' + ); + sdkFile.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + const cloned = Object.assign({}, child); + file.classes.push(cloned); + } + }); + }) + ); + + extractClassBasedSDKData(methods, sdkFiles).then( + result => {}, + error => { + expect(error.message).to.eql( + 'Data extraction unsuccessful' + ); + } + ); + }); + }); }); -describe("GCP generator extractClientBasedSDKdata", () => { - context("with valid methods and valid AST", () => { - it("should return class data", async () => { - const methods: any = await readJsonData( - "validDataset_2", - "googleCloud", - "methods" - ); - - const sdkFiles: any = await readJsonData( - "validDataset_2", - "googleCloud", - "files" - ); - - await Promise.all( - sdkFiles.map(async file => { - const sdkFile: any = await readSourceFile( - "validDataset_2", - "googleCloud" - ); - sdkFile.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - file.ast = Object.assign({}, child); - } - }); - }) - ); - - extractClientBasedSDKdata(methods, sdkFiles).then(result => { - expect(result).to.be.an("array"); - }); - }); - }); - - context("with invalid AST", () => { - it("should return Error", async () => { - const methods: any = await readJsonData( - "invalidDataset_2", - "googleCloud", - "methods" - ); - - const sdkFiles: any = await readJsonData( - "invalidDataset_2", - "googleCloud", - "files" - ); - - await Promise.all( - sdkFiles.map(async file => { - const sdkFile: any = await readSourceFile( - "invalidDataset_2", - "googleCloud" - ); - sdkFile.forEachChild(child => { - if (SyntaxKind[child.kind] === "ClassDeclaration") { - file.ast = Object.assign({}, child); - } - }); - }) - ); - - extractClientBasedSDKdata(methods, sdkFiles).then( - result => {}, - error => { - expect(error.message).to.eql("Data extraction unsuccessful"); - } - ); - }); - }); +describe('GCP generator extractClientBasedSDKdata', () => { + context('with valid methods and valid AST', () => { + it('should return class data', async () => { + const methods: any = await readJsonData( + 'validDataset_2', + 'googleCloud', + 'methods' + ); + + const sdkFiles: any = await readJsonData( + 'validDataset_2', + 'googleCloud', + 'files' + ); + + await Promise.all( + sdkFiles.map(async file => { + const sdkFile: any = await readSourceFile( + 'validDataset_2', + 'googleCloud' + ); + sdkFile.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + file.ast = Object.assign({}, child); + } + }); + }) + ); + + extractClientBasedSDKdata(methods, sdkFiles).then(result => { + expect(result).to.be.an('array'); + }); + }); + }); + + context('with invalid AST', () => { + it('should return Error', async () => { + const methods: any = await readJsonData( + 'invalidDataset_2', + 'googleCloud', + 'methods' + ); + + const sdkFiles: any = await readJsonData( + 'invalidDataset_2', + 'googleCloud', + 'files' + ); + + await Promise.all( + sdkFiles.map(async file => { + const sdkFile: any = await readSourceFile( + 'invalidDataset_2', + 'googleCloud' + ); + sdkFile.forEachChild(child => { + if (SyntaxKind[child.kind] === 'ClassDeclaration') { + file.ast = Object.assign({}, child); + } + }); + }) + ); + + extractClientBasedSDKdata(methods, sdkFiles).then( + result => {}, + error => { + expect(error.message).to.eql( + 'Data extraction unsuccessful' + ); + } + ); + }); + }); }); diff --git a/generator/transformers/aws/transformer.js b/generator/transformers/aws/transformer.js index 683ff0a5..da809d1a 100644 --- a/generator/transformers/aws/transformer.js +++ b/generator/transformers/aws/transformer.js @@ -1,200 +1,450 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.transform = void 0; -var lodash_1 = require("lodash"); -var ts = require("typescript"); +var lodash_1 = require('lodash'); +var ts = require('typescript'); var dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + 'ClassName', + '_sdkClassName', + 'SDKClassName', + 'SDKFunctionName', ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function (resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); - resolve(output); - } - catch (error) { - reject(error); - } - }); + return new Promise(function(resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } function transform(code, classData) { - return __awaiter(this, void 0, void 0, function () { - var addFunctions, addIdentifiers, addComments, node, result_1, result_2, result_3; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - addFunctions = function (context) { return function (rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function (method) { - var clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addIdentifiers = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters; - } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("AWS_" + classData.serviceName)); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1))); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.className)); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function (childNode) { - if (ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName") { - var args = classData.functions[count].params.map(function (param) { - return ts.createIdentifier(param.name); - }); - node.arguments = args.concat(node.arguments); - } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addComments = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment(node, "This is an auto generated class, please do not change."); - var comment = "*\n * Class to create a " + classData.className + " object\n * @category AWS \n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var statment; - if (param.optional) { - statment = "* @param {" + param.typeName + "} [" + param.name + "] - Data required for " + classData.functions[count].SDKFunctionName; - } - else { - statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function (param) { - paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); - }); - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - else { - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; - case 2: - result_2 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var addFunctions, + addIdentifiers, + addComments, + node, + result_1, + result_2, + result_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + addFunctions = function(context) { + return function(rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function(method) { + var clonedNode = Object.assign( + {}, + node.members[1] + ); + clonedNode.name = ts.createIdentifier( + method.functionName + ); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray( + [node.members[0]].concat( + functions_1 + ) + ) + ); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addIdentifiers = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + return paramNode; + }); + node.parameters = parameters; + } + if ( + ts.isIdentifier(node) && + dummyIdentifiers.includes(node.text) + ) { + var updatedIdentifier = void 0; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'AWS_' + + classData.serviceName + ) + ); + break; + case '_sdkClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.className + .charAt(0) + .toLowerCase() + + classData.className.substr( + 1 + ) + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.className + ) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count] + .SDKFunctionName + ) + ); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function( + childNode + ) { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + var args = classData.functions[ + count + ].params.map(function(param) { + return ts.createIdentifier( + param.name + ); + }); + node.arguments = args.concat( + node.arguments + ); + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addComments = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + var comment = + '*\n * Class to create a ' + + classData.className + + ' object\n * @category AWS \n '; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var statment; + if (param.optional) { + statment = + '* @param {' + + param.typeName + + '} [' + + param.name + + '] - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } else { + statment = + '* @param {' + + param.typeName + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ''; + parameters.map(function(param) { + paramStatments_1 = paramStatments_1.concat( + paramStatments_1 === '' + ? '' + param + : '\n ' + param + ); + }); + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.className + + '\n ' + + paramStatments_1 + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } else { + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.className + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + node = code.statements.find(function(stm) { + return ts.isClassDeclaration(stm); + }); + if (!classData.className || !classData.functions) { + throw new Error('Input is invalid'); + } + if ( + !node || + !node.members.some(function(member) { + return ts.isMethodDeclaration(member); + }) + ) { + throw new Error('Code is invalid'); + } + code = lodash_1.cloneDeep(code); + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation( + toSourceFile(result_1), + addIdentifiers + ), + ]; + case 2: + result_2 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation(toSourceFile(result_2), addComments), + ]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); + }); } exports.transform = transform; diff --git a/generator/transformers/aws/transformer.ts b/generator/transformers/aws/transformer.ts index 31230633..ed063fe9 100644 --- a/generator/transformers/aws/transformer.ts +++ b/generator/transformers/aws/transformer.ts @@ -1,239 +1,252 @@ -import { cloneDeep } from "lodash"; -import * as ts from "typescript"; +import { cloneDeep } from 'lodash'; +import * as ts from 'typescript'; const dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + 'ClassName', + '_sdkClassName', + 'SDKClassName', + 'SDKFunctionName', ]; const printer: ts.Printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment: string) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod): Promise { - return new Promise((resolve, reject) => { - try { - const result = ts.transform(sourceCode, [transformMethod]); - const transformedNodes = result.transformed[0]; - const output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise((resolve, reject) => { + try { + const result = ts.transform(sourceCode, [transformMethod]); + const transformedNodes = result.transformed[0]; + const output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode: string): ts.SourceFile { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } export async function transform( - code: ts.SourceFile, - classData: any + code: ts.SourceFile, + classData: any ): Promise { - const addFunctions = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - let functions: any = []; - classData.functions.map(method => { - const clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions.push(clonedNode); - }); - - const updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions)) - ); - - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const addIdentifiers = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isMethodDeclaration(node)) { - const parameters = classData.functions[count].params.map(param => { - const paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - - return paramNode; - }); - - node.parameters = parameters; - } - - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - let updatedIdentifier; - - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("AWS_" + classData.serviceName) - ); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.className) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].SDKFunctionName) - ); - count++; - } - - return updatedIdentifier; - } - - if (ts.isCallExpression(node)) { - node.expression.forEachChild(childNode => { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - const args = classData.functions[count].params.map(param => - ts.createIdentifier(param.name) - ); - node.arguments = args.concat(node.arguments); - } - }); - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const addComments = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - const comment = `* + const addFunctions = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + const functions: any = []; + classData.functions.map(method => { + const clonedNode = Object.assign({}, node.members[1]); + clonedNode.name = ts.createIdentifier(method.functionName); + functions.push(clonedNode); + }); + + const updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray([node.members[0]].concat(functions)) + ); + + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const addIdentifiers = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + function visit(node: ts.Node): ts.Node { + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + const paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + + return paramNode; + } + ); + + node.parameters = parameters; + } + + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + let updatedIdentifier; + + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier('AWS_' + classData.serviceName) + ); + break; + case '_sdkClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.className + .charAt(0) + .toLowerCase() + + classData.className.substr(1) + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier(classData.className) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].SDKFunctionName + ) + ); + count++; + } + + return updatedIdentifier; + } + + if (ts.isCallExpression(node)) { + node.expression.forEachChild(childNode => { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + const args = classData.functions[count].params.map( + param => ts.createIdentifier(param.name) + ); + node.arguments = args.concat(node.arguments); + } + }); + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const addComments = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + const comment = `* * Class to create a ${classData.className} object * @category AWS `; - addMultiLineComment(node, comment); - } - - if (ts.isMethodDeclaration(node)) { - let parameters = classData.functions[count].params.map(param => { - let statment; - - if (param.optional) { - statment = `* @param {${param.typeName}} [${param.name}] - Data required for ${classData.functions[count].SDKFunctionName}`; - } else { - statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - } - return statment; - }); - - let comment; - if (parameters.length > 0) { - let paramStatments: string = ""; - parameters.map(param => { - paramStatments = paramStatments.concat( - paramStatments === "" ? `${param}` : `\n ${param}` - ); - }); - - comment = `* + addMultiLineComment(node, comment); + } + + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + let statment; + + if (param.optional) { + statment = `* @param {${param.typeName}} [${param.name}] - Data required for ${classData.functions[count].SDKFunctionName}`; + } else { + statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + } + return statment; + } + ); + + let comment; + if (parameters.length > 0) { + let paramStatments: string = ''; + parameters.map(param => { + paramStatments = paramStatments.concat( + paramStatments === '' ? `${param}` : `\n ${param}` + ); + }); + + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${classData.className} ${paramStatments} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } else { - comment = `* + } else { + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${classData.className} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } - - addMultiLineComment(node, comment); - count++; - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); - - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - - if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { - throw new Error("Code is invalid"); - } - - code = cloneDeep(code); - - const result_1 = await runTransformation(code, addFunctions); - const result_2 = await runTransformation( - toSourceFile(result_1), - addIdentifiers - ); - const result_3 = await runTransformation(toSourceFile(result_2), addComments); - return result_3; + } + + addMultiLineComment(node, comment); + count++; + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); + + if (!classData.className || !classData.functions) { + throw new Error('Input is invalid'); + } + + if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { + throw new Error('Code is invalid'); + } + + code = cloneDeep(code); + + const result_1 = await runTransformation(code, addFunctions); + const result_2 = await runTransformation( + toSourceFile(result_1), + addIdentifiers + ); + const result_3 = await runTransformation( + toSourceFile(result_2), + addComments + ); + return result_3; } diff --git a/generator/transformers/azure/transformer.js b/generator/transformers/azure/transformer.js index c9f7f03c..069cea3a 100644 --- a/generator/transformers/azure/transformer.js +++ b/generator/transformers/azure/transformer.js @@ -1,212 +1,480 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.transform = void 0; -var lodash_1 = require("lodash"); -var ts = require("typescript"); +var lodash_1 = require('lodash'); +var ts = require('typescript'); var dummyIdentifiers = [ - "ClassName", - "SDKClassName", - "SDKFunctionName", - "ClientName", - "functionClient" + 'ClassName', + 'SDKClassName', + 'SDKFunctionName', + 'ClientName', + 'functionClient', ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function (resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); - resolve(output); - } - catch (error) { - reject(error); - } - }); + return new Promise(function(resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } function transform(code, classData) { - return __awaiter(this, void 0, void 0, function () { - var node, importStatments, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); - if (!classData.functions) { - throw new Error("Input is invalid"); - } - if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - // import related - classData.clients = Array.from(new Set(classData.functions.map(function (method) { return method.client; }))); - importStatments = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); - addFunctions = function (context) { return function (rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function (method) { - var clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addIdentifiers = function (context) { return function (rootNode) { - var count = 0; - var clientCount = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters; - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral("@azure/" + classData.functions[0].pkgName); - } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("Azure_" + classData.serviceName)); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].fileName.split(".")[0])); - break; - case "functionClient": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].client)); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientCount])); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function (childNode) { - if (ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName") { - var args = classData.functions[count].params.map(function (param) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; - } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addComments = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment(node, "This is an auto generated class, please do not change."); - var comment = "*\n * Class to create a " + classData.serviceName + " object\n * @category Azure\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var statment; - if (param.optional) { - statment = "* @param {" + param.type + "} [" + param.name + "] - Optional parameter"; - } - else { - statment = "* @param {" + param.type + "} " + param.name + " - Mandatory parameter"; - } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function (param) { - paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); - }); - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - else { - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; - case 2: - result_2 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var node, + importStatments, + addFunctions, + addIdentifiers, + addComments, + result_1, + result_2, + result_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function(stm) { + return ts.isClassDeclaration(stm); + }); + if (!classData.functions) { + throw new Error('Input is invalid'); + } + if ( + !node || + !node.members.some(function(member) { + return ts.isMethodDeclaration(member); + }) + ) { + throw new Error('Code is invalid'); + } + code = lodash_1.cloneDeep(code); + // import related + classData.clients = Array.from( + new Set( + classData.functions.map(function(method) { + return method.client; + }) + ) + ); + importStatments = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat( + code.statements.slice(1) + ); + addFunctions = function(context) { + return function(rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function(method) { + var clonedNode = Object.assign( + {}, + node.members[1] + ); + clonedNode.name = ts.createIdentifier( + method.functionName + ); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray( + [node.members[0]].concat( + functions_1 + ) + ) + ); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addIdentifiers = function(context) { + return function(rootNode) { + var count = 0; + var clientCount = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + return paramNode; + }); + node.parameters = parameters; + } + if ( + ts.isStringLiteral(node) && + node.text === 'pkgName' + ) { + return ts.createStringLiteral( + '@azure/' + + classData.functions[0].pkgName + ); + } + if ( + ts.isIdentifier(node) && + dummyIdentifiers.includes(node.text) + ) { + var updatedIdentifier = void 0; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'Azure_' + + classData.serviceName + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[ + count + ].fileName.split('.')[0] + ) + ); + break; + case 'functionClient': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count] + .client + ) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.clients[ + clientCount + ] + ) + ); + clientCount++; + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count] + .SDKFunctionName + ) + ); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function( + childNode + ) { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + var args = classData.functions[ + count + ].params.map(function(param) { + return ts.createIdentifier( + param.name + ); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addComments = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + var comment = + '*\n * Class to create a ' + + classData.serviceName + + ' object\n * @category Azure\n '; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var statment; + if (param.optional) { + statment = + '* @param {' + + param.type + + '} [' + + param.name + + '] - Optional parameter'; + } else { + statment = + '* @param {' + + param.type + + '} ' + + param.name + + ' - Mandatory parameter'; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ''; + parameters.map(function(param) { + paramStatments_1 = paramStatments_1.concat( + paramStatments_1 === '' + ? '' + param + : '\n ' + param + ); + }); + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.functions[0].pkgName.split( + '-' + )[1] + + '\n ' + + paramStatments_1 + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } else { + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.functions[0].pkgName.split( + '-' + )[1] + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation( + toSourceFile(result_1), + addIdentifiers + ), + ]; + case 2: + result_2 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation(toSourceFile(result_2), addComments), + ]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); + }); } exports.transform = transform; diff --git a/generator/transformers/azure/transformer.ts b/generator/transformers/azure/transformer.ts index 1c9fd106..e27a4ef6 100644 --- a/generator/transformers/azure/transformer.ts +++ b/generator/transformers/azure/transformer.ts @@ -1,262 +1,279 @@ -import { cloneDeep } from "lodash"; -import * as ts from "typescript"; +import { cloneDeep } from 'lodash'; +import * as ts from 'typescript'; const dummyIdentifiers = [ - "ClassName", - "SDKClassName", - "SDKFunctionName", - "ClientName", - "functionClient" + 'ClassName', + 'SDKClassName', + 'SDKFunctionName', + 'ClientName', + 'functionClient', ]; const printer: ts.Printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment: string) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod): Promise { - return new Promise((resolve, reject) => { - try { - const result = ts.transform(sourceCode, [transformMethod]); - const transformedNodes = result.transformed[0]; - const output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise((resolve, reject) => { + try { + const result = ts.transform(sourceCode, [transformMethod]); + const transformedNodes = result.transformed[0]; + const output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode: string): ts.SourceFile { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } export async function transform( - code: ts.SourceFile, - classData: any + code: ts.SourceFile, + classData: any ): Promise { - const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); + const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); - if (!classData.functions) { - throw new Error("Input is invalid"); - } + if (!classData.functions) { + throw new Error('Input is invalid'); + } - if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { - throw new Error("Code is invalid"); - } + if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { + throw new Error('Code is invalid'); + } - code = cloneDeep(code); + code = cloneDeep(code); - // import related - classData.clients = Array.from( - new Set(classData.functions.map(method => method.client)) - ); - const importStatments: any = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); - // import related + // import related + classData.clients = Array.from( + new Set(classData.functions.map(method => method.client)) + ); + const importStatments: any = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat(code.statements.slice(1)); + // import related - const addFunctions = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - let functions: any = []; - classData.functions.map(method => { - const clonedNode = Object.assign({}, node.members[1]); - clonedNode.name = ts.createIdentifier(method.functionName); - functions.push(clonedNode); - }); + const addFunctions = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + const functions: any = []; + classData.functions.map(method => { + const clonedNode = Object.assign({}, node.members[1]); + clonedNode.name = ts.createIdentifier(method.functionName); + functions.push(clonedNode); + }); - const updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions)) - ); + const updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray([node.members[0]].concat(functions)) + ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const addIdentifiers = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - let clientCount = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isMethodDeclaration(node)) { - const parameters = classData.functions[count].params.map(param => { - const paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); + const addIdentifiers = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + let clientCount = 0; + function visit(node: ts.Node): ts.Node { + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + const paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } - return paramNode; - }); + return paramNode; + } + ); - node.parameters = parameters; - } + node.parameters = parameters; + } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@azure/" + classData.functions[0].pkgName - ); - } + if (ts.isStringLiteral(node) && node.text === 'pkgName') { + return ts.createStringLiteral( + '@azure/' + classData.functions[0].pkgName + ); + } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - let updatedIdentifier; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("Azure_" + classData.serviceName) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.functions[count].fileName.split(".")[0] - ) - ); - break; - case "functionClient": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].client) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientCount]) - ); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].SDKFunctionName) - ); - count++; - } - return updatedIdentifier; - } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + let updatedIdentifier; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'Azure_' + classData.serviceName + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].fileName.split( + '.' + )[0] + ) + ); + break; + case 'functionClient': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].client + ) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier(classData.clients[clientCount]) + ); + clientCount++; + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].SDKFunctionName + ) + ); + count++; + } + return updatedIdentifier; + } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(childNode => { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - const args = classData.functions[count].params.map(param => - ts.createIdentifier(param.name) - ); - node.arguments = args; - } - }); - } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(childNode => { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + const args = classData.functions[count].params.map( + param => ts.createIdentifier(param.name) + ); + node.arguments = args; + } + }); + } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const addComments = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; + const addComments = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - const comment = `* + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + const comment = `* * Class to create a ${classData.serviceName} object * @category Azure `; - addMultiLineComment(node, comment); - } + addMultiLineComment(node, comment); + } - if (ts.isMethodDeclaration(node)) { - let parameters = classData.functions[count].params.map(param => { - let statment; + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + let statment; - if (param.optional) { - statment = `* @param {${param.type}} [${param.name}] - Optional parameter`; - } else { - statment = `* @param {${param.type}} ${param.name} - Mandatory parameter`; - } - return statment; - }); + if (param.optional) { + statment = `* @param {${param.type}} [${param.name}] - Optional parameter`; + } else { + statment = `* @param {${param.type}} ${param.name} - Mandatory parameter`; + } + return statment; + } + ); - let comment; - if (parameters.length > 0) { - let paramStatments: string = ""; - parameters.map(param => { - paramStatments = paramStatments.concat( - paramStatments === "" ? `${param}` : `\n ${param}` - ); - }); + let comment; + if (parameters.length > 0) { + let paramStatments: string = ''; + parameters.map(param => { + paramStatments = paramStatments.concat( + paramStatments === '' ? `${param}` : `\n ${param}` + ); + }); - comment = `* + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${ - classData.functions[0].pkgName.split("-")[1] - } + classData.functions[0].pkgName.split('-')[1] + } ${paramStatments} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } else { - comment = `* + } else { + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${ - classData.functions[0].pkgName.split("-")[1] - } + classData.functions[0].pkgName.split('-')[1] + } * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } + } - addMultiLineComment(node, comment); - count++; - } + addMultiLineComment(node, comment); + count++; + } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const result_1 = await runTransformation(code, addFunctions); - const result_2 = await runTransformation( - toSourceFile(result_1), - addIdentifiers - ); - const result_3 = await runTransformation(toSourceFile(result_2), addComments); - return result_3; + const result_1 = await runTransformation(code, addFunctions); + const result_2 = await runTransformation( + toSourceFile(result_1), + addIdentifiers + ); + const result_3 = await runTransformation( + toSourceFile(result_2), + addComments + ); + return result_3; } diff --git a/generator/transformers/do/transformer.js b/generator/transformers/do/transformer.js index 973c8664..30e4c2fb 100644 --- a/generator/transformers/do/transformer.js +++ b/generator/transformers/do/transformer.js @@ -1,212 +1,480 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.transform = void 0; -var lodash_1 = require("lodash"); -var ts = require("typescript"); +var lodash_1 = require('lodash'); +var ts = require('typescript'); var dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + 'ClassName', + '_sdkClassName', + 'SDKClassName', + 'SDKFunctionName', ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function (resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); - resolve(output); - } - catch (error) { - reject(error); - } - }); + return new Promise(function(resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } /* * The Transform function to be called from generator */ function transform(code, classData) { - return __awaiter(this, void 0, void 0, function () { - var addFunctions, addIdentifiers, addComments, node, result_1, result_2, result_3; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - addFunctions = function (context) { return function (rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function (method) { - var clonedNode = Object.assign({}, node.members[1]); - // console.log("Cloned Node..........\n");//sdadas - // console.log(clonedNode);//asdasdasdasd - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addIdentifiers = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters; - } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("DO_" + classData.serviceName)); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1))); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.className.charAt(0).toLowerCase() + - classData.className.substr(1))); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); - count++; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function (childNode) { - if (ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName") { - var args = classData.functions[count].params.map(function (param) { - return ts.createIdentifier(param.name); - }); - node.arguments = args.concat(node.arguments); - } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addComments = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment(node, "This is an auto generated class, please do not change."); - var comment = "*\n* Class to create a " + classData.className + " object\n* @category Digital Ocean \n"; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var statment; - if (param.optional) { - if (param.type == "TypeReference") - statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - else - statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - } - else { - if (param.type == "TypeReference") - statment = "* @param {" + param.typeName + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - else - statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function (param) { - paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n" + param); - }); - comment = "*\n* Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n" + paramStatments_1 + "\n* @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n"; - } - else { - comment = "*\n* Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.className + "\n* @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n"; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; - case 2: - result_2 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var addFunctions, + addIdentifiers, + addComments, + node, + result_1, + result_2, + result_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + addFunctions = function(context) { + return function(rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function(method) { + var clonedNode = Object.assign( + {}, + node.members[1] + ); + // console.log("Cloned Node..........\n");//sdadas + // console.log(clonedNode);//asdasdasdasd + clonedNode.name = ts.createIdentifier( + method.functionName + ); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray( + [node.members[0]].concat( + functions_1 + ) + ) + ); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addIdentifiers = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + return paramNode; + }); + node.parameters = parameters; + } + if ( + ts.isIdentifier(node) && + dummyIdentifiers.includes(node.text) + ) { + var updatedIdentifier = void 0; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'DO_' + + classData.serviceName + ) + ); + break; + case '_sdkClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.className + .charAt(0) + .toLowerCase() + + classData.className.substr( + 1 + ) + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.className + .charAt(0) + .toLowerCase() + + classData.className.substr( + 1 + ) + ) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count] + .SDKFunctionName + ) + ); + count++; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function( + childNode + ) { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + var args = classData.functions[ + count + ].params.map(function(param) { + return ts.createIdentifier( + param.name + ); + }); + node.arguments = args.concat( + node.arguments + ); + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addComments = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + var comment = + '*\n* Class to create a ' + + classData.className + + ' object\n* @category Digital Ocean \n'; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var statment; + if (param.optional) { + if (param.type == 'TypeReference') + statment = + '* @param {' + + param.typeName + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + else + statment = + '* @param {' + + param.type + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } else { + if (param.type == 'TypeReference') + statment = + '* @param {' + + param.typeName + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + else + statment = + '* @param {' + + param.type + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ''; + parameters.map(function(param) { + paramStatments_1 = paramStatments_1.concat( + paramStatments_1 === '' + ? '' + param + : '\n' + param + ); + }); + comment = + '*\n* Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.className + + '\n' + + paramStatments_1 + + '\n* @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n'; + } else { + comment = + '*\n* Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.className + + '\n* @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n'; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + node = code.statements.find(function(stm) { + return ts.isClassDeclaration(stm); + }); + if (!classData.className || !classData.functions) { + throw new Error('Input is invalid'); + } + if ( + !node || + !node.members.some(function(member) { + return ts.isMethodDeclaration(member); + }) + ) { + throw new Error('Code is invalid'); + } + code = lodash_1.cloneDeep(code); + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation( + toSourceFile(result_1), + addIdentifiers + ), + ]; + case 2: + result_2 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation(toSourceFile(result_2), addComments), + ]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); + }); } exports.transform = transform; diff --git a/generator/transformers/do/transformer.ts b/generator/transformers/do/transformer.ts index 3f063962..115ed946 100644 --- a/generator/transformers/do/transformer.ts +++ b/generator/transformers/do/transformer.ts @@ -1,51 +1,51 @@ -import { cloneDeep } from "lodash"; -import * as ts from "typescript"; +import { cloneDeep } from 'lodash'; +import * as ts from 'typescript'; const dummyIdentifiers = [ - "ClassName", - "_sdkClassName", - "SDKClassName", - "SDKFunctionName" + 'ClassName', + '_sdkClassName', + 'SDKClassName', + 'SDKFunctionName', ]; const printer: ts.Printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment: string) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod): Promise { - return new Promise((resolve, reject) => { - try { - const result = ts.transform(sourceCode, [transformMethod]); - const transformedNodes = result.transformed[0]; - const output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise((resolve, reject) => { + try { + const result = ts.transform(sourceCode, [transformMethod]); + const transformedNodes = result.transformed[0]; + const output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode: string): ts.SourceFile { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } /* @@ -53,215 +53,228 @@ function toSourceFile(sourceCode: string): ts.SourceFile { */ export async function transform( - code: ts.SourceFile, - classData: any + code: ts.SourceFile, + classData: any ): Promise { - /* - * Transformation function for adding Functions - */ - const addFunctions = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - let functions: any = []; - classData.functions.map(method => { - const clonedNode = Object.assign({}, node.members[1]); - // console.log("Cloned Node..........\n");//sdadas - // console.log(clonedNode);//asdasdasdasd - clonedNode.name = ts.createIdentifier(method.functionName); - functions.push(clonedNode); - }); - - const updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions)) - ); - - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - /* - * Transformation function for adding Identifiers/Parameters - */ - const addIdentifiers = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isMethodDeclaration(node)) { - const parameters = classData.functions[count].params.map(param => { - const paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - - return paramNode; - }); - - node.parameters = parameters; - } - - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - let updatedIdentifier; - - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("DO_" + classData.serviceName) - ); - break; - case "_sdkClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - classData.className.charAt(0).toLowerCase() + - classData.className.substr(1) - ) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].SDKFunctionName) - ); - count++; - } - - return updatedIdentifier; - } - - if (ts.isCallExpression(node)) { - node.expression.forEachChild(childNode => { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - const args = classData.functions[count].params.map(param => - ts.createIdentifier(param.name) - ); - node.arguments = args.concat(node.arguments); - } - }); - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - /* - *Transformation function for adding comments - */ - - const addComments = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - const comment = `* + /* + * Transformation function for adding Functions + */ + const addFunctions = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + const functions: any = []; + classData.functions.map(method => { + const clonedNode = Object.assign({}, node.members[1]); + // console.log("Cloned Node..........\n");//sdadas + // console.log(clonedNode);//asdasdasdasd + clonedNode.name = ts.createIdentifier(method.functionName); + functions.push(clonedNode); + }); + + const updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray([node.members[0]].concat(functions)) + ); + + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + /* + * Transformation function for adding Identifiers/Parameters + */ + const addIdentifiers = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + function visit(node: ts.Node): ts.Node { + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + const paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + + return paramNode; + } + ); + + node.parameters = parameters; + } + + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + let updatedIdentifier; + + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier('DO_' + classData.serviceName) + ); + break; + case '_sdkClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.className + .charAt(0) + .toLowerCase() + + classData.className.substr(1) + ) + ); + break; + case 'SDKClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.className.charAt(0).toLowerCase() + + classData.className.substr(1) + ) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].SDKFunctionName + ) + ); + count++; + } + + return updatedIdentifier; + } + + if (ts.isCallExpression(node)) { + node.expression.forEachChild(childNode => { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + const args = classData.functions[count].params.map( + param => ts.createIdentifier(param.name) + ); + node.arguments = args.concat(node.arguments); + } + }); + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + /* + *Transformation function for adding comments + */ + + const addComments = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + const comment = `* * Class to create a ${classData.className} object * @category Digital Ocean `; - addMultiLineComment(node, comment); - } - - if (ts.isMethodDeclaration(node)) { - let parameters = classData.functions[count].params.map(param => { - let statment; - - if (param.optional) { - if (param.type == "TypeReference") - statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - else - statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - } else { - if (param.type == "TypeReference") - statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - else - statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - } - return statment; - }); - - let comment; - if (parameters.length > 0) { - let paramStatments: string = ""; - parameters.map(param => { - paramStatments = paramStatments.concat( - paramStatments === "" ? `${param}` : `\n${param}` - ); - }); - - comment = `* + addMultiLineComment(node, comment); + } + + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + let statment; + + if (param.optional) { + if (param.type == 'TypeReference') + statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + else + statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + } else { + if (param.type == 'TypeReference') + statment = `* @param {${param.typeName}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + else + statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + } + return statment; + } + ); + + let comment; + if (parameters.length > 0) { + let paramStatments: string = ''; + parameters.map(param => { + paramStatments = paramStatments.concat( + paramStatments === '' ? `${param}` : `\n${param}` + ); + }); + + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${classData.className} ${paramStatments} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } else { - comment = `* + } else { + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${classData.className} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } - - addMultiLineComment(node, comment); - count++; - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - /* - * Code to get node and run tranformations - */ - const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); - - if (!classData.className || !classData.functions) { - throw new Error("Input is invalid"); - } - - if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { - throw new Error("Code is invalid"); - } - - code = cloneDeep(code); - - const result_1 = await runTransformation(code, addFunctions); - const result_2 = await runTransformation( - toSourceFile(result_1), - addIdentifiers - ); - const result_3 = await runTransformation(toSourceFile(result_2), addComments); - return result_3; + } + + addMultiLineComment(node, comment); + count++; + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + /* + * Code to get node and run tranformations + */ + const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); + + if (!classData.className || !classData.functions) { + throw new Error('Input is invalid'); + } + + if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { + throw new Error('Code is invalid'); + } + + code = cloneDeep(code); + + const result_1 = await runTransformation(code, addFunctions); + const result_2 = await runTransformation( + toSourceFile(result_1), + addIdentifiers + ); + const result_3 = await runTransformation( + toSourceFile(result_2), + addComments + ); + return result_3; } diff --git a/generator/transformers/googleCloud/classBasedTransformer.js b/generator/transformers/googleCloud/classBasedTransformer.js index f9c776ae..48c30b18 100644 --- a/generator/transformers/googleCloud/classBasedTransformer.js +++ b/generator/transformers/googleCloud/classBasedTransformer.js @@ -1,249 +1,553 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.classBasedTransform = void 0; -var lodash_1 = require("lodash"); -var ts = require("typescript"); +var lodash_1 = require('lodash'); +var ts = require('typescript'); var dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client", - "_className" + 'ClassName', + 'SDKFunctionName', + 'ClientName', + '_client', + '_clientObj', + 'Client', + '_className', ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function (resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); - resolve(output); - } - catch (error) { - reject(error); - } - }); + return new Promise(function(resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } function classBasedTransform(code, data) { - return __awaiter(this, void 0, void 0, function () { - var node, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); - if (!data.functions || !data.classData) { - throw new Error("Input is invalid"); - } - if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - addFunctions = function (context) { return function (rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - data.functions.map(function (method) { - var clonedNode; - if (method.returnTypeName === "Promise") { - if ((method.classConstructorData.parameters[0].type = - "TypeReference" && - !method.classConstructorData.parameters[0].optional)) { - clonedNode = Object.assign({}, node.members[3]); - } - else { - clonedNode = Object.assign({}, node.members[1]); - } - } - else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addIdentifiers = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - data.functions[count].allParams = []; - var params = []; - if ((data.functions[count].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData.parameters[0].optional)) { - params.push(data.functions[count].classConstructorData.parameters[0]); - data.functions[count].allParams.push({ - name: "identifier", - optional: true, - type: "string" - }); - } - params = params.concat(data.functions[count].params); - data.functions[count].allParams = data.functions[count].allParams.concat(params); - var parameters = params.map(function (param) { - var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters.concat(node.parameters); - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral("@google-cloud/" + data.functions[0].pkgName); - } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("GCP_" + data.functions[0].pkgName)); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.mainClass)); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].SDKFunctionName)); - count++; - break; - case "_className": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].client.toLowerCase())); - break; - case "_client": - if ((data.functions[count].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData.parameters[0] - .optional)) { - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.functions[count].classConstructorData.parameters[0].name)); - } - else { - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + data.mainClass.toLowerCase())); - } - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + data.mainClass.toLowerCase())); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(data.mainClass)); - break; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function (childNode) { - if (ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName") { - var args = data.functions[count].params.map(function (param) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; - } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addComments = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment(node, "This is an auto generated class, please do not change."); - var comment = "*\n * Class to create a " + data.functions[0].pkgName + " object\n * @category Google Cloud\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = data.functions[count].allParams.map(function (param) { - var statment; - if (param.optional) { - statment = "* @param {" + (param.typeRefName ? param.typeRefName : param.type) + "} [" + param.name + "] - Optional parameter"; - } - else { - statment = "* @param {" + (param.typeRefName ? param.typeRefName : param.type) + "} " + param.name + " - Mandatory parameter"; - } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function (param) { - paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); - }); - comment = "*\n * Trigers the " + data.functions[count].SDKFunctionName + " function of " + data.functions[0].pkgName + "\n " + paramStatments_1 + "\n * @returns {Promise<" + data.functions[count].SDKFunctionName + "Response>}\n "; - } - else { - comment = "*\n * Trigers the " + data.functions[count].SDKFunctionName + " function of " + data.functions[0].pkgName + "\n * @returns {Promise<" + data.functions[count].SDKFunctionName + "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; - case 2: - result_2 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var node, + addFunctions, + addIdentifiers, + addComments, + result_1, + result_2, + result_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function(stm) { + return ts.isClassDeclaration(stm); + }); + if (!data.functions || !data.classData) { + throw new Error('Input is invalid'); + } + if ( + !node || + !node.members.some(function(member) { + return ts.isMethodDeclaration(member); + }) + ) { + throw new Error('Code is invalid'); + } + code = lodash_1.cloneDeep(code); + addFunctions = function(context) { + return function(rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + data.functions.map(function(method) { + var clonedNode; + if ( + method.returnTypeName === 'Promise' + ) { + if ( + (method.classConstructorData.parameters[0].type = + 'TypeReference' && + !method.classConstructorData + .parameters[0].optional) + ) { + clonedNode = Object.assign( + {}, + node.members[3] + ); + } else { + clonedNode = Object.assign( + {}, + node.members[1] + ); + } + } else { + clonedNode = Object.assign( + {}, + node.members[2] + ); + } + clonedNode.name = ts.createIdentifier( + method.functionName + ); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray( + [node.members[0]].concat( + functions_1 + ) + ) + ); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addIdentifiers = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + data.functions[count].allParams = []; + var params = []; + if ( + (data.functions[ + count + ].classConstructorData.parameters[0].type = + 'TypeReference' && + !data.functions[count] + .classConstructorData + .parameters[0].optional) + ) { + params.push( + data.functions[count] + .classConstructorData + .parameters[0] + ); + data.functions[count].allParams.push({ + name: 'identifier', + optional: true, + type: 'string', + }); + } + params = params.concat( + data.functions[count].params + ); + data.functions[ + count + ].allParams = data.functions[ + count + ].allParams.concat(params); + var parameters = params.map(function( + param + ) { + var paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + return paramNode; + }); + node.parameters = parameters.concat( + node.parameters + ); + } + if ( + ts.isStringLiteral(node) && + node.text === 'pkgName' + ) { + return ts.createStringLiteral( + '@google-cloud/' + + data.functions[0].pkgName + ); + } + if ( + ts.isIdentifier(node) && + dummyIdentifiers.includes(node.text) + ) { + var updatedIdentifier = void 0; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'GCP_' + + data.functions[0] + .pkgName + ) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.mainClass + ) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[count] + .SDKFunctionName + ) + ); + count++; + break; + case '_className': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[ + count + ].client.toLowerCase() + ) + ); + break; + case '_client': + if ( + (data.functions[ + count + ].classConstructorData.parameters[0].type = + 'TypeReference' && + !data.functions[count] + .classConstructorData + .parameters[0].optional) + ) { + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[count] + .classConstructorData + .parameters[0].name + ) + ); + } else { + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + data.mainClass.toLowerCase() + ) + ); + } + break; + case '_clientObj': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + data.mainClass.toLowerCase() + ) + ); + break; + case 'Client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.mainClass + ) + ); + break; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function( + childNode + ) { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + var args = data.functions[ + count + ].params.map(function(param) { + return ts.createIdentifier( + param.name + ); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addComments = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + var comment = + '*\n * Class to create a ' + + data.functions[0].pkgName + + ' object\n * @category Google Cloud\n '; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = data.functions[ + count + ].allParams.map(function(param) { + var statment; + if (param.optional) { + statment = + '* @param {' + + (param.typeRefName + ? param.typeRefName + : param.type) + + '} [' + + param.name + + '] - Optional parameter'; + } else { + statment = + '* @param {' + + (param.typeRefName + ? param.typeRefName + : param.type) + + '} ' + + param.name + + ' - Mandatory parameter'; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ''; + parameters.map(function(param) { + paramStatments_1 = paramStatments_1.concat( + paramStatments_1 === '' + ? '' + param + : '\n ' + param + ); + }); + comment = + '*\n * Trigers the ' + + data.functions[count] + .SDKFunctionName + + ' function of ' + + data.functions[0].pkgName + + '\n ' + + paramStatments_1 + + '\n * @returns {Promise<' + + data.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } else { + comment = + '*\n * Trigers the ' + + data.functions[count] + .SDKFunctionName + + ' function of ' + + data.functions[0].pkgName + + '\n * @returns {Promise<' + + data.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation( + toSourceFile(result_1), + addIdentifiers + ), + ]; + case 2: + result_2 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation(toSourceFile(result_2), addComments), + ]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); + }); } exports.classBasedTransform = classBasedTransform; diff --git a/generator/transformers/googleCloud/classBasedTransformer.ts b/generator/transformers/googleCloud/classBasedTransformer.ts index a68f9365..06f0f729 100644 --- a/generator/transformers/googleCloud/classBasedTransformer.ts +++ b/generator/transformers/googleCloud/classBasedTransformer.ts @@ -1,310 +1,340 @@ -import { cloneDeep } from "lodash"; -import * as ts from "typescript"; +import { cloneDeep } from 'lodash'; +import * as ts from 'typescript'; const dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client", - "_className" + 'ClassName', + 'SDKFunctionName', + 'ClientName', + '_client', + '_clientObj', + 'Client', + '_className', ]; const printer: ts.Printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment: string) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod): Promise { - return new Promise((resolve, reject) => { - try { - const result = ts.transform(sourceCode, [transformMethod]); - const transformedNodes = result.transformed[0]; - const output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise((resolve, reject) => { + try { + const result = ts.transform(sourceCode, [transformMethod]); + const transformedNodes = result.transformed[0]; + const output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode: string): ts.SourceFile { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } export async function classBasedTransform( - code: ts.SourceFile, - data: any + code: ts.SourceFile, + data: any ): Promise { - const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); - - if (!data.functions || !data.classData) { - throw new Error("Input is invalid"); - } - - if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { - throw new Error("Code is invalid"); - } - - code = cloneDeep(code); - - const addFunctions = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - let functions: any = []; - data.functions.map(method => { - let clonedNode; - if (method.returnTypeName === "Promise") { - if ( - (method.classConstructorData.parameters[0].type = - "TypeReference" && - !method.classConstructorData.parameters[0].optional) - ) { - clonedNode = Object.assign({}, node.members[3]); - } else { - clonedNode = Object.assign({}, node.members[1]); - } - } else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions.push(clonedNode); - }); - - const updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions)) - ); - - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const addIdentifiers = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isMethodDeclaration(node)) { - data.functions[count].allParams = []; - - let params = []; - if ( - (data.functions[count].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData.parameters[0].optional) - ) { - params.push(data.functions[count].classConstructorData.parameters[0]); - - data.functions[count].allParams.push({ - name: "identifier", - optional: true, - type: "string" - }); - } - - params = params.concat(data.functions[count].params); - data.functions[count].allParams = data.functions[ - count - ].allParams.concat(params); - - const parameters: any = params.map(param => { - const paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); - - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - - return paramNode; - }); - - node.parameters = parameters.concat(node.parameters); - } - - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@google-cloud/" + data.functions[0].pkgName - ); - } - - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - let updatedIdentifier; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("GCP_" + data.functions[0].pkgName) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.mainClass) - ); - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.functions[count].SDKFunctionName) - ); - count++; - break; - case "_className": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.functions[count].client.toLowerCase()) - ); - break; - case "_client": - if ( - (data.functions[count].classConstructorData.parameters[0].type = - "TypeReference" && - !data.functions[count].classConstructorData.parameters[0] - .optional) - ) { - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - data.functions[count].classConstructorData.parameters[0].name - ) - ); - } else { - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("_" + data.mainClass.toLowerCase()) - ); - } - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("_" + data.mainClass.toLowerCase()) - ); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(data.mainClass) - ); - break; - } - return updatedIdentifier; - } - - if (ts.isCallExpression(node)) { - node.expression.forEachChild(childNode => { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - const args = data.functions[count].params.map(param => - ts.createIdentifier(param.name) - ); - node.arguments = args; - } - }); - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const addComments = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - const comment = `* + const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); + + if (!data.functions || !data.classData) { + throw new Error('Input is invalid'); + } + + if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { + throw new Error('Code is invalid'); + } + + code = cloneDeep(code); + + const addFunctions = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + const functions: any = []; + data.functions.map(method => { + let clonedNode; + if (method.returnTypeName === 'Promise') { + if ( + (method.classConstructorData.parameters[0].type = + 'TypeReference' && + !method.classConstructorData.parameters[0] + .optional) + ) { + clonedNode = Object.assign({}, node.members[3]); + } else { + clonedNode = Object.assign({}, node.members[1]); + } + } else { + clonedNode = Object.assign({}, node.members[2]); + } + clonedNode.name = ts.createIdentifier(method.functionName); + functions.push(clonedNode); + }); + + const updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray([node.members[0]].concat(functions)) + ); + + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const addIdentifiers = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + function visit(node: ts.Node): ts.Node { + if (ts.isMethodDeclaration(node)) { + data.functions[count].allParams = []; + + let params = []; + if ( + (data.functions[ + count + ].classConstructorData.parameters[0].type = + 'TypeReference' && + !data.functions[count].classConstructorData + .parameters[0].optional) + ) { + params.push( + data.functions[count].classConstructorData.parameters[0] + ); + + data.functions[count].allParams.push({ + name: 'identifier', + optional: true, + type: 'string', + }); + } + + params = params.concat(data.functions[count].params); + data.functions[count].allParams = data.functions[ + count + ].allParams.concat(params); + + const parameters: any = params.map(param => { + const paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + + return paramNode; + }); + + node.parameters = parameters.concat(node.parameters); + } + + if (ts.isStringLiteral(node) && node.text === 'pkgName') { + return ts.createStringLiteral( + '@google-cloud/' + data.functions[0].pkgName + ); + } + + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + let updatedIdentifier; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'GCP_' + data.functions[0].pkgName + ) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier(data.mainClass) + ); + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[count].SDKFunctionName + ) + ); + count++; + break; + case '_className': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[count].client.toLowerCase() + ) + ); + break; + case '_client': + if ( + (data.functions[ + count + ].classConstructorData.parameters[0].type = + 'TypeReference' && + !data.functions[count].classConstructorData + .parameters[0].optional) + ) { + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + data.functions[count].classConstructorData + .parameters[0].name + ) + ); + } else { + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + data.mainClass.toLowerCase() + ) + ); + } + break; + case '_clientObj': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + data.mainClass.toLowerCase() + ) + ); + break; + case 'Client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier(data.mainClass) + ); + break; + } + return updatedIdentifier; + } + + if (ts.isCallExpression(node)) { + node.expression.forEachChild(childNode => { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + const args = data.functions[count].params.map(param => + ts.createIdentifier(param.name) + ); + node.arguments = args; + } + }); + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const addComments = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + const comment = `* * Class to create a ${data.functions[0].pkgName} object * @category Google Cloud `; - addMultiLineComment(node, comment); - } - - if (ts.isMethodDeclaration(node)) { - let parameters = data.functions[count].allParams.map(param => { - let statment; - - if (param.optional) { - statment = `* @param {${ - param.typeRefName ? param.typeRefName : param.type - }} [${param.name}] - Optional parameter`; - } else { - statment = `* @param {${ - param.typeRefName ? param.typeRefName : param.type - }} ${param.name} - Mandatory parameter`; - } - return statment; - }); - - let comment; - if (parameters.length > 0) { - let paramStatments: string = ""; - parameters.map(param => { - paramStatments = paramStatments.concat( - paramStatments === "" ? `${param}` : `\n ${param}` - ); - }); - - comment = `* + addMultiLineComment(node, comment); + } + + if (ts.isMethodDeclaration(node)) { + const parameters = data.functions[count].allParams.map( + param => { + let statment; + + if (param.optional) { + statment = `* @param {${ + param.typeRefName + ? param.typeRefName + : param.type + }} [${param.name}] - Optional parameter`; + } else { + statment = `* @param {${ + param.typeRefName + ? param.typeRefName + : param.type + }} ${param.name} - Mandatory parameter`; + } + return statment; + } + ); + + let comment; + if (parameters.length > 0) { + let paramStatments: string = ''; + parameters.map(param => { + paramStatments = paramStatments.concat( + paramStatments === '' ? `${param}` : `\n ${param}` + ); + }); + + comment = `* * Trigers the ${data.functions[count].SDKFunctionName} function of ${data.functions[0].pkgName} ${paramStatments} * @returns {Promise<${data.functions[count].SDKFunctionName}Response>} `; - } else { - comment = `* + } else { + comment = `* * Trigers the ${data.functions[count].SDKFunctionName} function of ${data.functions[0].pkgName} * @returns {Promise<${data.functions[count].SDKFunctionName}Response>} `; - } - - addMultiLineComment(node, comment); - count++; - } - - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; - - const result_1 = await runTransformation(code, addFunctions); - const result_2 = await runTransformation( - toSourceFile(result_1), - addIdentifiers - ); - const result_3 = await runTransformation(toSourceFile(result_2), addComments); - return result_3; + } + + addMultiLineComment(node, comment); + count++; + } + + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + + const result_1 = await runTransformation(code, addFunctions); + const result_2 = await runTransformation( + toSourceFile(result_1), + addIdentifiers + ); + const result_3 = await runTransformation( + toSourceFile(result_2), + addComments + ); + return result_3; } diff --git a/generator/transformers/googleCloud/clientBasedTransformer.js b/generator/transformers/googleCloud/clientBasedTransformer.js index 81956231..715482e2 100644 --- a/generator/transformers/googleCloud/clientBasedTransformer.js +++ b/generator/transformers/googleCloud/clientBasedTransformer.js @@ -1,236 +1,536 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; +'use strict'; +var __awaiter = + (this && this.__awaiter) || + function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator['throw'](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected); + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ); + }); + }; +var __generator = + (this && this.__generator) || + function(thisArg, body) { + var _ = { + label: 0, + sent: function() { + if (t[0] & 1) throw t[1]; + return t[1]; + }, + trys: [], + ops: [], + }, + f, + y, + t, + g; + return ( + (g = { next: verb(0), throw: verb(1), return: verb(2) }), + typeof Symbol === 'function' && + (g[Symbol.iterator] = function() { + return this; + }), + g + ); + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) throw new TypeError('Generator is already executing.'); + while (_) + try { + if ( + ((f = 1), + y && + (t = + op[0] & 2 + ? y['return'] + : op[0] + ? y['throw'] || + ((t = y['return']) && t.call(y), 0) + : y.next) && + !(t = t.call(y, op[1])).done) + ) + return t; + if (((y = 0), t)) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if ( + !((t = _.trys), + (t = t.length > 0 && t[t.length - 1])) && + (op[0] === 6 || op[0] === 2) + ) { + _ = 0; + continue; + } + if ( + op[0] === 3 && + (!t || (op[1] > t[0] && op[1] < t[3])) + ) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; exports.__esModule = true; exports.clientBasedTransform = void 0; -var lodash_1 = require("lodash"); -var ts = require("typescript"); +var lodash_1 = require('lodash'); +var ts = require('typescript'); var dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client" + 'ClassName', + 'SDKFunctionName', + 'ClientName', + '_client', + '_clientObj', + 'Client', ]; var printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment) { - ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment, true); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod) { - return new Promise(function (resolve, reject) { - try { - var result = ts.transform(sourceCode, [transformMethod]); - var transformedNodes = result.transformed[0]; - var output = printer.printNode(ts.EmitHint.SourceFile, transformedNodes, sourceCode); - resolve(output); - } - catch (error) { - reject(error); - } - }); + return new Promise(function(resolve, reject) { + try { + var result = ts.transform(sourceCode, [transformMethod]); + var transformedNodes = result.transformed[0]; + var output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode) { - return ts.createSourceFile("dummyClass.js", sourceCode, ts.ScriptTarget.Latest, true); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } function clientBasedTransform(code, classData) { - return __awaiter(this, void 0, void 0, function () { - var node, importStatments, classDeclarationNode, constructorNode, clientObjects, addFunctions, addIdentifiers, addComments, result_1, result_2, result_3; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - node = code.statements.find(function (stm) { return ts.isClassDeclaration(stm); }); - if (!classData.functions) { - throw new Error("Input is invalid"); - } - if (!node || !node.members.some(function (member) { return ts.isMethodDeclaration(member); })) { - throw new Error("Code is invalid"); - } - code = lodash_1.cloneDeep(code); - // import related - classData.clients = Array.from(new Set(classData.functions.map(function (method) { return method.client; }))); - importStatments = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); - classDeclarationNode = code.statements.find(function (node) { - return ts.isClassDeclaration(node); - }); - constructorNode = classDeclarationNode.members.find(function (node) { return ts.SyntaxKind[node.kind] === "Constructor"; }); - clientObjects = new Array(classData.clients.length); - clientObjects.fill(Object.assign({}, constructorNode.body.statements[0])); - constructorNode.body.statements = clientObjects; - addFunctions = function (context) { return function (rootNode) { - function visit(node) { - if (ts.isClassDeclaration(node)) { - var functions_1 = []; - classData.functions.map(function (method) { - var clonedNode; - if (method.returnTypeName === "Promise") { - clonedNode = Object.assign({}, node.members[1]); - } - else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions_1.push(clonedNode); - }); - var updatedClass = ts.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, ts.createNodeArray([node.members[0]].concat(functions_1))); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addIdentifiers = function (context) { return function (rootNode) { - var count = 0; - var clientCount = 0; - var clientObjCount = 0; - function visit(node) { - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var paramNode = ts.createParameter(undefined, undefined, undefined, param.name); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } - return paramNode; - }); - node.parameters = parameters; - } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral("@google-cloud/" + classData.functions[0].pkgName); - } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - var updatedIdentifier = void 0; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("GCP_" + classData.serviceName)); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientCount])); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.functions[count].SDKFunctionName)); - count++; - break; - case "_client": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + - classData.functions[count].client.toLowerCase().charAt(0) + - classData.functions[count].client.substr(1))); - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier("_" + - classData.clients[clientObjCount].toLowerCase().charAt(0) + - classData.clients[clientObjCount].substr(1))); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier(ts.createIdentifier(classData.clients[clientObjCount])); - clientObjCount++; - break; - } - return updatedIdentifier; - } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(function (childNode) { - if (ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName") { - var args = classData.functions[count].params.map(function (param) { - return ts.createIdentifier(param.name); - }); - node.arguments = args; - } - }); - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - addComments = function (context) { return function (rootNode) { - var count = 0; - function visit(node) { - if (ts.isClassDeclaration(node)) { - addMultiLineComment(node, "This is an auto generated class, please do not change."); - var comment = "*\n * Class to create a " + classData.serviceName + " object\n * @category Google Cloud\n "; - addMultiLineComment(node, comment); - } - if (ts.isMethodDeclaration(node)) { - var parameters = classData.functions[count].params.map(function (param) { - var statment; - if (param.optional) { - statment = "* @param {" + param.type + "} [" + param.name + "] - Data required for " + classData.functions[count].SDKFunctionName; - } - else { - statment = "* @param {" + param.type + "} " + param.name + " - Data required for " + classData.functions[count].SDKFunctionName; - } - return statment; - }); - var comment = void 0; - if (parameters.length > 0) { - var paramStatments_1 = ""; - parameters.map(function (param) { - paramStatments_1 = paramStatments_1.concat(paramStatments_1 === "" ? "" + param : "\n " + param); - }); - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n " + paramStatments_1 + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - else { - comment = "*\n * Trigers the " + classData.functions[count].SDKFunctionName + " function of " + classData.functions[0].pkgName.split("-")[1] + "\n * @returns {Promise<" + classData.functions[count].SDKFunctionName + "Response>}\n "; - } - addMultiLineComment(node, comment); - count++; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; }; - return [4 /*yield*/, runTransformation(code, addFunctions)]; - case 1: - result_1 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_1), addIdentifiers)]; - case 2: - result_2 = _a.sent(); - return [4 /*yield*/, runTransformation(toSourceFile(result_2), addComments)]; - case 3: - result_3 = _a.sent(); - return [2 /*return*/, result_3]; - } - }); - }); + return __awaiter(this, void 0, void 0, function() { + var node, + importStatments, + classDeclarationNode, + constructorNode, + clientObjects, + addFunctions, + addIdentifiers, + addComments, + result_1, + result_2, + result_3; + return __generator(this, function(_a) { + switch (_a.label) { + case 0: + node = code.statements.find(function(stm) { + return ts.isClassDeclaration(stm); + }); + if (!classData.functions) { + throw new Error('Input is invalid'); + } + if ( + !node || + !node.members.some(function(member) { + return ts.isMethodDeclaration(member); + }) + ) { + throw new Error('Code is invalid'); + } + code = lodash_1.cloneDeep(code); + // import related + classData.clients = Array.from( + new Set( + classData.functions.map(function(method) { + return method.client; + }) + ) + ); + importStatments = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat( + code.statements.slice(1) + ); + classDeclarationNode = code.statements.find(function(node) { + return ts.isClassDeclaration(node); + }); + constructorNode = classDeclarationNode.members.find( + function(node) { + return ts.SyntaxKind[node.kind] === 'Constructor'; + } + ); + clientObjects = new Array(classData.clients.length); + clientObjects.fill( + Object.assign({}, constructorNode.body.statements[0]) + ); + constructorNode.body.statements = clientObjects; + addFunctions = function(context) { + return function(rootNode) { + function visit(node) { + if (ts.isClassDeclaration(node)) { + var functions_1 = []; + classData.functions.map(function(method) { + var clonedNode; + if ( + method.returnTypeName === 'Promise' + ) { + clonedNode = Object.assign( + {}, + node.members[1] + ); + } else { + clonedNode = Object.assign( + {}, + node.members[2] + ); + } + clonedNode.name = ts.createIdentifier( + method.functionName + ); + functions_1.push(clonedNode); + }); + var updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray( + [node.members[0]].concat( + functions_1 + ) + ) + ); + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addIdentifiers = function(context) { + return function(rootNode) { + var count = 0; + var clientCount = 0; + var clientObjCount = 0; + function visit(node) { + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } + return paramNode; + }); + node.parameters = parameters; + } + if ( + ts.isStringLiteral(node) && + node.text === 'pkgName' + ) { + return ts.createStringLiteral( + '@google-cloud/' + + classData.functions[0].pkgName + ); + } + if ( + ts.isIdentifier(node) && + dummyIdentifiers.includes(node.text) + ) { + var updatedIdentifier = void 0; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + 'GCP_' + + classData.serviceName + ) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.clients[ + clientCount + ] + ) + ); + clientCount++; + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count] + .SDKFunctionName + ) + ); + count++; + break; + case '_client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.functions[ + count + ].client + .toLowerCase() + .charAt(0) + + classData.functions[ + count + ].client.substr(1) + ) + ); + break; + case '_clientObj': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.clients[ + clientObjCount + ] + .toLowerCase() + .charAt(0) + + classData.clients[ + clientObjCount + ].substr(1) + ) + ); + break; + case 'Client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.clients[ + clientObjCount + ] + ) + ); + clientObjCount++; + break; + } + return updatedIdentifier; + } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(function( + childNode + ) { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + var args = classData.functions[ + count + ].params.map(function(param) { + return ts.createIdentifier( + param.name + ); + }); + node.arguments = args; + } + }); + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + addComments = function(context) { + return function(rootNode) { + var count = 0; + function visit(node) { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + var comment = + '*\n * Class to create a ' + + classData.serviceName + + ' object\n * @category Google Cloud\n '; + addMultiLineComment(node, comment); + } + if (ts.isMethodDeclaration(node)) { + var parameters = classData.functions[ + count + ].params.map(function(param) { + var statment; + if (param.optional) { + statment = + '* @param {' + + param.type + + '} [' + + param.name + + '] - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } else { + statment = + '* @param {' + + param.type + + '} ' + + param.name + + ' - Data required for ' + + classData.functions[count] + .SDKFunctionName; + } + return statment; + }); + var comment = void 0; + if (parameters.length > 0) { + var paramStatments_1 = ''; + parameters.map(function(param) { + paramStatments_1 = paramStatments_1.concat( + paramStatments_1 === '' + ? '' + param + : '\n ' + param + ); + }); + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.functions[0].pkgName.split( + '-' + )[1] + + '\n ' + + paramStatments_1 + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } else { + comment = + '*\n * Trigers the ' + + classData.functions[count] + .SDKFunctionName + + ' function of ' + + classData.functions[0].pkgName.split( + '-' + )[1] + + '\n * @returns {Promise<' + + classData.functions[count] + .SDKFunctionName + + 'Response>}\n '; + } + addMultiLineComment(node, comment); + count++; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; + }; + return [4 /*yield*/, runTransformation(code, addFunctions)]; + case 1: + result_1 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation( + toSourceFile(result_1), + addIdentifiers + ), + ]; + case 2: + result_2 = _a.sent(); + return [ + 4 /*yield*/, + runTransformation(toSourceFile(result_2), addComments), + ]; + case 3: + result_3 = _a.sent(); + return [2 /*return*/, result_3]; + } + }); + }); } exports.clientBasedTransform = clientBasedTransform; diff --git a/generator/transformers/googleCloud/clientBasedTransformer.ts b/generator/transformers/googleCloud/clientBasedTransformer.ts index 525086dd..b2819e53 100644 --- a/generator/transformers/googleCloud/clientBasedTransformer.ts +++ b/generator/transformers/googleCloud/clientBasedTransformer.ts @@ -1,292 +1,309 @@ -import { cloneDeep } from "lodash"; -import * as ts from "typescript"; +import { cloneDeep } from 'lodash'; +import * as ts from 'typescript'; const dummyIdentifiers = [ - "ClassName", - "SDKFunctionName", - "ClientName", - "_client", - "_clientObj", - "Client" + 'ClassName', + 'SDKFunctionName', + 'ClientName', + '_client', + '_clientObj', + 'Client', ]; const printer: ts.Printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - removeComments: false + newLine: ts.NewLineKind.LineFeed, + removeComments: false, }); function addMultiLineComment(node, comment: string) { - ts.addSyntheticLeadingComment( - node, - ts.SyntaxKind.MultiLineCommentTrivia, - comment, - true - ); + ts.addSyntheticLeadingComment( + node, + ts.SyntaxKind.MultiLineCommentTrivia, + comment, + true + ); } function runTransformation(sourceCode, transformMethod): Promise { - return new Promise((resolve, reject) => { - try { - const result = ts.transform(sourceCode, [transformMethod]); - const transformedNodes = result.transformed[0]; - const output = printer.printNode( - ts.EmitHint.SourceFile, - transformedNodes, - sourceCode - ); - resolve(output); - } catch (error) { - reject(error); - } - }); + return new Promise((resolve, reject) => { + try { + const result = ts.transform(sourceCode, [transformMethod]); + const transformedNodes = result.transformed[0]; + const output = printer.printNode( + ts.EmitHint.SourceFile, + transformedNodes, + sourceCode + ); + resolve(output); + } catch (error) { + reject(error); + } + }); } function toSourceFile(sourceCode: string): ts.SourceFile { - return ts.createSourceFile( - "dummyClass.js", - sourceCode, - ts.ScriptTarget.Latest, - true - ); + return ts.createSourceFile( + 'dummyClass.js', + sourceCode, + ts.ScriptTarget.Latest, + true + ); } export async function clientBasedTransform( - code: ts.SourceFile, - classData: any + code: ts.SourceFile, + classData: any ): Promise { - const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); + const node: any = code.statements.find(stm => ts.isClassDeclaration(stm)); - if (!classData.functions) { - throw new Error("Input is invalid"); - } + if (!classData.functions) { + throw new Error('Input is invalid'); + } - if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { - throw new Error("Code is invalid"); - } + if (!node || !node.members.some(member => ts.isMethodDeclaration(member))) { + throw new Error('Code is invalid'); + } - code = cloneDeep(code); + code = cloneDeep(code); - // import related - classData.clients = Array.from( - new Set(classData.functions.map(method => method.client)) - ); - const importStatments: any = new Array(classData.clients.length); - importStatments.fill(Object.assign({}, code.statements[0])); - code.statements = importStatments.concat(code.statements.slice(1)); + // import related + classData.clients = Array.from( + new Set(classData.functions.map(method => method.client)) + ); + const importStatments: any = new Array(classData.clients.length); + importStatments.fill(Object.assign({}, code.statements[0])); + code.statements = importStatments.concat(code.statements.slice(1)); - let classDeclarationNode: any = code.statements.find(node => - ts.isClassDeclaration(node) - ); - let constructorNode: any = classDeclarationNode.members.find( - node => ts.SyntaxKind[node.kind] === "Constructor" - ); - const clientObjects: any = new Array(classData.clients.length); - clientObjects.fill(Object.assign({}, constructorNode.body.statements[0])); - constructorNode.body.statements = clientObjects; - // import related + const classDeclarationNode: any = code.statements.find(node => + ts.isClassDeclaration(node) + ); + const constructorNode: any = classDeclarationNode.members.find( + node => ts.SyntaxKind[node.kind] === 'Constructor' + ); + const clientObjects: any = new Array(classData.clients.length); + clientObjects.fill(Object.assign({}, constructorNode.body.statements[0])); + constructorNode.body.statements = clientObjects; + // import related - const addFunctions = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - let functions: any = []; - classData.functions.map(method => { - let clonedNode; - if (method.returnTypeName === "Promise") { - clonedNode = Object.assign({}, node.members[1]); - } else { - clonedNode = Object.assign({}, node.members[2]); - } - clonedNode.name = ts.createIdentifier(method.functionName); - functions.push(clonedNode); - }); + const addFunctions = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + const functions: any = []; + classData.functions.map(method => { + let clonedNode; + if (method.returnTypeName === 'Promise') { + clonedNode = Object.assign({}, node.members[1]); + } else { + clonedNode = Object.assign({}, node.members[2]); + } + clonedNode.name = ts.createIdentifier(method.functionName); + functions.push(clonedNode); + }); - const updatedClass = ts.updateClassDeclaration( - node, - node.decorators, - node.modifiers, - node.name, - node.typeParameters, - node.heritageClauses, - ts.createNodeArray([node.members[0]].concat(functions)) - ); + const updatedClass = ts.updateClassDeclaration( + node, + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + ts.createNodeArray([node.members[0]].concat(functions)) + ); - return updatedClass; - } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return updatedClass; + } + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const addIdentifiers = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; - let clientCount = 0; - let clientObjCount = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isMethodDeclaration(node)) { - const parameters = classData.functions[count].params.map(param => { - const paramNode = ts.createParameter( - undefined, - undefined, - undefined, - param.name - ); + const addIdentifiers = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; + let clientCount = 0; + let clientObjCount = 0; + function visit(node: ts.Node): ts.Node { + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + const paramNode = ts.createParameter( + undefined, + undefined, + undefined, + param.name + ); - if (param.optional) { - paramNode.initializer = ts.createIdentifier("undefined"); - } + if (param.optional) { + paramNode.initializer = ts.createIdentifier( + 'undefined' + ); + } - return paramNode; - }); + return paramNode; + } + ); - node.parameters = parameters; - } + node.parameters = parameters; + } - if (ts.isStringLiteral(node) && node.text === "pkgName") { - return ts.createStringLiteral( - "@google-cloud/" + classData.functions[0].pkgName - ); - } + if (ts.isStringLiteral(node) && node.text === 'pkgName') { + return ts.createStringLiteral( + '@google-cloud/' + classData.functions[0].pkgName + ); + } - if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { - let updatedIdentifier; - switch (node.text) { - case "ClassName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier("GCP_" + classData.serviceName) - ); - break; - case "ClientName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientCount]) - ); - clientCount++; - break; - case "SDKFunctionName": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.functions[count].SDKFunctionName) - ); - count++; - break; - case "_client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.functions[count].client.toLowerCase().charAt(0) + - classData.functions[count].client.substr(1) - ) - ); - break; - case "_clientObj": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier( - "_" + - classData.clients[clientObjCount].toLowerCase().charAt(0) + - classData.clients[clientObjCount].substr(1) - ) - ); - break; - case "Client": - updatedIdentifier = ts.updateIdentifier( - ts.createIdentifier(classData.clients[clientObjCount]) - ); - clientObjCount++; - break; - } - return updatedIdentifier; - } + if (ts.isIdentifier(node) && dummyIdentifiers.includes(node.text)) { + let updatedIdentifier; + switch (node.text) { + case 'ClassName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier('GCP_' + classData.serviceName) + ); + break; + case 'ClientName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier(classData.clients[clientCount]) + ); + clientCount++; + break; + case 'SDKFunctionName': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.functions[count].SDKFunctionName + ) + ); + count++; + break; + case '_client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.functions[count].client + .toLowerCase() + .charAt(0) + + classData.functions[count].client.substr(1) + ) + ); + break; + case '_clientObj': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + '_' + + classData.clients[clientObjCount] + .toLowerCase() + .charAt(0) + + classData.clients[clientObjCount].substr(1) + ) + ); + break; + case 'Client': + updatedIdentifier = ts.updateIdentifier( + ts.createIdentifier( + classData.clients[clientObjCount] + ) + ); + clientObjCount++; + break; + } + return updatedIdentifier; + } - if (ts.isCallExpression(node)) { - node.expression.forEachChild(childNode => { - if ( - ts.isIdentifier(childNode) && - childNode.text === "SDKFunctionName" - ) { - const args = classData.functions[count].params.map(param => - ts.createIdentifier(param.name) - ); - node.arguments = args; - } - }); - } + if (ts.isCallExpression(node)) { + node.expression.forEachChild(childNode => { + if ( + ts.isIdentifier(childNode) && + childNode.text === 'SDKFunctionName' + ) { + const args = classData.functions[count].params.map( + param => ts.createIdentifier(param.name) + ); + node.arguments = args; + } + }); + } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const addComments = ( - context: ts.TransformationContext - ) => (rootNode: T) => { - let count = 0; + const addComments = ( + context: ts.TransformationContext + ) => (rootNode: T) => { + let count = 0; - function visit(node: ts.Node): ts.Node { - if (ts.isClassDeclaration(node)) { - addMultiLineComment( - node, - "This is an auto generated class, please do not change." - ); - const comment = `* + function visit(node: ts.Node): ts.Node { + if (ts.isClassDeclaration(node)) { + addMultiLineComment( + node, + 'This is an auto generated class, please do not change.' + ); + const comment = `* * Class to create a ${classData.serviceName} object * @category Google Cloud `; - addMultiLineComment(node, comment); - } + addMultiLineComment(node, comment); + } - if (ts.isMethodDeclaration(node)) { - let parameters = classData.functions[count].params.map(param => { - let statment; + if (ts.isMethodDeclaration(node)) { + const parameters = classData.functions[count].params.map( + param => { + let statment; - if (param.optional) { - statment = `* @param {${param.type}} [${param.name}] - Data required for ${classData.functions[count].SDKFunctionName}`; - } else { - statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; - } - return statment; - }); + if (param.optional) { + statment = `* @param {${param.type}} [${param.name}] - Data required for ${classData.functions[count].SDKFunctionName}`; + } else { + statment = `* @param {${param.type}} ${param.name} - Data required for ${classData.functions[count].SDKFunctionName}`; + } + return statment; + } + ); - let comment; - if (parameters.length > 0) { - let paramStatments: string = ""; - parameters.map(param => { - paramStatments = paramStatments.concat( - paramStatments === "" ? `${param}` : `\n ${param}` - ); - }); + let comment; + if (parameters.length > 0) { + let paramStatments: string = ''; + parameters.map(param => { + paramStatments = paramStatments.concat( + paramStatments === '' ? `${param}` : `\n ${param}` + ); + }); - comment = `* + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${ - classData.functions[0].pkgName.split("-")[1] - } + classData.functions[0].pkgName.split('-')[1] + } ${paramStatments} * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } else { - comment = `* + } else { + comment = `* * Trigers the ${classData.functions[count].SDKFunctionName} function of ${ - classData.functions[0].pkgName.split("-")[1] - } + classData.functions[0].pkgName.split('-')[1] + } * @returns {Promise<${classData.functions[count].SDKFunctionName}Response>} `; - } + } - addMultiLineComment(node, comment); - count++; - } + addMultiLineComment(node, comment); + count++; + } - return ts.visitEachChild(node, visit, context); - } - return ts.visitNode(rootNode, visit); - }; + return ts.visitEachChild(node, visit, context); + } + return ts.visitNode(rootNode, visit); + }; - const result_1 = await runTransformation(code, addFunctions); - const result_2 = await runTransformation( - toSourceFile(result_1), - addIdentifiers - ); - const result_3 = await runTransformation(toSourceFile(result_2), addComments); - return result_3; + const result_1 = await runTransformation(code, addFunctions); + const result_2 = await runTransformation( + toSourceFile(result_1), + addIdentifiers + ); + const result_3 = await runTransformation( + toSourceFile(result_2), + addComments + ); + return result_3; } From 3f70a91db09b9424ef59d35157e92a89c7b4e7f6 Mon Sep 17 00:00:00 2001 From: Partik SIngh Date: Fri, 7 Jul 2023 17:00:01 +0530 Subject: [PATCH 4/4] Changed Generator function Signed-off-by: Partik SIngh --- generator/generators/linode/generator.ts | 112 ++++++++++++++--------- generator/parsers/linode/parser.ts | 13 --- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/generator/generators/linode/generator.ts b/generator/generators/linode/generator.ts index 2c71772c..5a50e74c 100644 --- a/generator/generators/linode/generator.ts +++ b/generator/generators/linode/generator.ts @@ -1,6 +1,8 @@ -import { SyntaxKind } from 'typescript'; +import * as fs from 'fs'; +import { createSourceFile, ScriptTarget,SyntaxKind } from 'typescript'; import { getAST } from '../../parsers/linode/parser'; +import { getDir, printFile } from '../lib/helper'; interface SDKClassData { pkgName: string; @@ -31,6 +33,15 @@ interface param { optional: boolean; } +const dummyFile = process.cwd() + '/dummyClasses/linode.js'; + +const dummyAst = createSourceFile( + dummyFile, + fs.readFileSync(dummyFile).toString(), + ScriptTarget.Latest, + true +); + export function extractSDKData(sdkAst, serviceClass) { const methods: FunctionData[] = []; const functions = []; @@ -48,7 +59,6 @@ export function extractSDKData(sdkAst, serviceClass) { name = key; } }); - const parameters = []; const methodParameters = method.type.parameters; @@ -63,12 +73,11 @@ export function extractSDKData(sdkAst, serviceClass) { }; // common type if (param.type.typeName) { - parameter.typeName = param.type.typeName.excapedText; + parameter.typeName = param.type.typeName.text; } parameters.push(parameter); } }); - methods.push({ functionName: name.toString(), SDKFunctionName: methodName, @@ -76,55 +85,74 @@ export function extractSDKData(sdkAst, serviceClass) { }); } }); - const classData: ClassData = { - className: '', - functions: methods, - serviceName: null, - }; - return classData; -} -export async function generateLinodeClass(serviceClass, serviceName) { - const methods: SDKClassData[] = []; - if (serviceClass == null) return; - Object.keys(serviceClass).map((key, index) => { - methods.push({ - pkgName: serviceClass[key].split(' ')[0], - fileName: serviceClass[key].split(' ')[1], - functionName: key, - SDKFunctionName: serviceClass[key].split(' ')[2], - params: [], - returnType: null, - client: null, - }); - }); - - const files = Array.from(new Set(methods.map(method => method.fileName))); - - const sdkFiles = files.map(file => { - return { - fileName: file, - pkgName: methods[0].pkgName, - ast: null, - client: null, - sdkFunctionNames: methods - .filter(method => method.fileName === file) - .map(method => method.SDKFunctionName), - }; - }); + return methods; +} - sdkFiles.map(async file => { +export async function getFunctions(sdkFiles, serviceClass) { + const functionsArray: FunctionData[] = []; + await sdkFiles.map(async file => { getAST(file).then(async result => { const sdkAst = result; try { - const classData: ClassData = extractSDKData( + const functions: FunctionData[] = extractSDKData( sdkAst, serviceClass ); - classData.serviceName = serviceName; + + functions.map((method, index) => { + functionsArray.push(method); + }); } catch (e) { console.error(e); } }); }); + return functionsArray; } + +export async function generateLinodeClass(serviceClass, serviceName) { + try { + const methods: SDKClassData[] = []; + if (serviceClass == null) return; + Object.keys(serviceClass).map((key, index) => { + methods.push({ + pkgName: serviceClass[key].split(' ')[0], + fileName: serviceClass[key].split(' ')[1], + functionName: key, + SDKFunctionName: serviceClass[key].split(' ')[2], + params: [], + returnType: null, + client: null, + }); + }); + + const files = Array.from( + new Set(methods.map(method => method.fileName)) + ); + + const sdkFiles = files.map(file => { + return { + fileName: file, + pkgName: methods[0].pkgName, + ast: null, + client: null, + sdkFunctionNames: methods + .filter(method => method.fileName === file) + .map(method => method.SDKFunctionName), + }; + }); + const functionsArray: FunctionData[] = await getFunctions( + sdkFiles, + serviceClass + ); + + const classData: ClassData = { + className: serviceName + 'LinodeClass', + functions: functionsArray, + serviceName: serviceName, + }; + } catch (e) { + console.error(e); + } +} \ No newline at end of file diff --git a/generator/parsers/linode/parser.ts b/generator/parsers/linode/parser.ts index 7308ea0f..e29eee56 100644 --- a/generator/parsers/linode/parser.ts +++ b/generator/parsers/linode/parser.ts @@ -23,26 +23,13 @@ export function getAST(sdkFileInfo) { const cloned = []; let tmp = null; await ast.forEachChild(child => { - // fs.writeFile('test.txt', SyntaxKind[child.kind], null); - // console.log(SyntaxKind[child.kind]); - - // console.log('Linode', SyntaxKind[child.kind]); - // console.log("child",child); - if (SyntaxKind[child.kind] === 'FirstStatement') { // console.log("child",child); // resolve(false) tmp = Object.assign({}, child); cloned.push(tmp.declarationList.declarations[0]); - - // console.log( - // 'name', - // tmp.declarationList.declarations[0].type.parameters[0] - // ); } }); - // console.log('cloned', cloned); - if (!cloned) { reject(new Error('Function not found!')); } else {