From 879894da9761e7cc5814a0d2fa0fa91a164b26cc Mon Sep 17 00:00:00 2001 From: sagpembo Date: Tue, 7 Mar 2023 08:03:40 +0000 Subject: [PATCH] 2023.3.0 --- accounts.js | 104 ++++++ experimental.js | 41 ++- monitor.js | 145 ++++++++ wmiocli.js | 871 ++++++++++++++++++++++++++---------------------- 4 files changed, 751 insertions(+), 410 deletions(-) create mode 100644 accounts.js create mode 100644 monitor.js diff --git a/accounts.js b/accounts.js new file mode 100644 index 0000000..e236d92 --- /dev/null +++ b/accounts.js @@ -0,0 +1,104 @@ +/* + * webMethods.io CLI + * Copyright 2022 Software AG + * Apache-2.0 + */ + +const request = require('./rest.js'); + + +var domainName, username, password, timeout; +var prettyprint = false; +var url; + +function debug(message) { + dbg.message(" " + message,4); +} + +function help() { + return ` +\x1b[4mAccounts\x1b[0m + +\x1b[32mGet Accounts:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + account + + +\x1b[32mDelete an Account:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + account-delete accountUid + +\x1b[32mDelete an Account:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + account-update accountUid +`; +} +function init(inDomainName, inUsername, inPassword, inTimeout, inPrettyprint) { + domainName = inDomainName; + username = inUsername; + password = inPassword; + timeout = inTimeout; + prettyprint = inPrettyprint; + + url = "https://" + domainName + "/apis/v1/rest/projects"; + debug("Username [" + username + "]"); + debug("URL [" + url + "]"); + debug("Timeout [" + timeout + "]"); +} + +/** + * Call back function to process REST response + * @param {return data from REST request} data + * @param {status} status + */ +function processResponse(data, status) { + if (prettyprint == true) { + console.log(JSON.stringify(data, null, 4)); + } + else { + console.log(JSON.stringify(data)); + } + + if (status != 0) { + process.exit(status); + } +} + +/* Accounts */ +function getAccount(projectId) { + + url +="/" + projectId + "/accounts"; + request.get(url, username, password, timeout, processResponse); +} + +function deleteAccount(projectId,accountUid) { + + url +="/" + projectId + "/accounts/" + accountUid; + request.del(url, username, password, timeout,null, processResponse); +} + +/** + * To be completed + * @param {} projectId + * @param {*} accountUid + */ +function updateConfiguration(projectId,accountUid) { + + //url +="/" + projectId + "/accounts/" + accountUid; + //request.del(url, username, password, timeout,null, processResponse); +} + + + +module.exports = { + help, init, getAccount, deleteAccount +}; diff --git a/experimental.js b/experimental.js index 98fee16..a5b0d6e 100644 --- a/experimental.js +++ b/experimental.js @@ -39,6 +39,8 @@ var payloaduid; var projectuid; var data; var type; +var flowServiceId; +var scheduleStatus; const maxRunningWorkflows = 20; @@ -69,6 +71,28 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){ dbg.message("Timeout [" + timeout + "]",4); } + +function flowserviceScheduler(inFlowServiceId, inScheduleStatus, inProjectId) +{ + flowServiceId = inFlowServiceId; + scheduleStatus = inScheduleStatus; + projectId = inProjectId; + finalCall = processScheduleStatus; + debug("******************Starting FlowService Scheduler"); + loginPhase1(); +} + +function processScheduleStatus() +{ + debug("Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]"); + + var endPoint = "https://" +domainName + "/integration/rest/scheduler/"+ scheduleStatus +"/" + flowServiceId +"?projectName="+ projectId ; + debug("Next URL [" + endPoint + "]"); + var headers = setHeaders(); + var body; + rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,undefined,headers,true,false); +} + function user() { finalCall = execUserInfo; @@ -236,6 +260,9 @@ function setHeaders() {name:"X-Requested-With",value:"XMLHttpRequest"}, {name:"X-Request-ID",value:generateUUID()}, {name:"project_uid",value:projectId}, + {name:"x-csrf-token",value:csrf}, + + ]; return headers; } @@ -664,7 +691,7 @@ function getLogs() function searchProjectsByName() { dbg.message(""+"Search Projects By Name [" + projectName + "]",4); - var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=1000&skip=0&q=" + projectName; + var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=" + returnCount+ "&skip=" + returnStart + "&q=" + projectName; dbg.message(""+"Next URL [" + endPoint + "]",4); var headers = setHeaders(); rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false); @@ -711,7 +738,10 @@ function projectWorkflowsInfo() { debug("Project Workflows Info"); - var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=1000&skip=0&filter=recent&tags=&query="; + var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=" + returnCount+ "&skip=" + returnStart + "&filter=recent&tags=&query="; + + + debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processProjectsResponse,undefined,headers,true,false); @@ -721,7 +751,7 @@ function projectFlowServicesInfo() { debug("Project FlowServices Info"); - var endPoint = "https://" + domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?skip=0&limit=1000"; + var endPoint = "https://" + domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?limit=" + returnCount+ "&skip=" + returnStart; debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false); @@ -996,6 +1026,9 @@ function loginResponse(url,err,body,res){ } + + + module.exports = {init, user,stages, searchProject, @@ -1004,4 +1037,4 @@ module.exports = {init, connectorAccounts,getProjectAccountConfig, getMonitorInfo,workflowResubmit, messagingCreate,messagingStats,messagingDelete, - vbidAnalysis}; \ No newline at end of file + vbidAnalysis, flowserviceScheduler}; \ No newline at end of file diff --git a/monitor.js b/monitor.js new file mode 100644 index 0000000..4ca0885 --- /dev/null +++ b/monitor.js @@ -0,0 +1,145 @@ +/* + * webMethods.io CLI + * Copyright 2022 Software AG + * Apache-2.0 + */ + +const request = require('./rest.js'); + + +var domainName, username, password, timeout; +var prettyprint = false; +var url; + +function debug(message) { + dbg.message(" " + message,4); +} + +function help() { + return ` +\x1b[4mMonitor\x1b[0m + +\x1b[32mRetrieve Monitor Summary:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + monitor from count startDate endDate projectsList workflowsList executionStatus + e.g. + monitor 1 10 2023-01-01 2023-01-10 myProject workflow1,workflow2 failed,timeout,stopped + monitor 11 10 2023-01-01 2023-01-10 myProject workflow1,workflow2 failed,timeout,stopped + monitor + + +\x1b[32mView an Execution Log:\x1b[0m +$ node wmiocli.js + -d tenant.int-aws-us.webmethods.io + -u user + -p password + monitor-workflow-log billUid + +`; +} +function init(inDomainName, inUsername, inPassword, inTimeout, inPrettyprint) { + domainName = inDomainName; + username = inUsername; + password = inPassword; + timeout = inTimeout; + prettyprint = inPrettyprint; + + url = "https://" + domainName + "/apis/v1/rest/monitor"; + debug("Username [" + username + "]"); + debug("URL [" + url + "]"); + debug("Timeout [" + timeout + "]"); +} + +/** + * Call back function to process REST response + * @param {return data from REST request} data + * @param {status} status + */ +function processResponse(data, status) { + if (prettyprint == true) { + console.log(JSON.stringify(data, null, 4)); + } + else { + console.log(JSON.stringify(data)); + } + + if (status != 0) { + process.exit(status); + } +} + +/* Monitor */ +function list(startDate,endDate,projectsList,workflowsList,executionStatusList) { + + url +="/summary"; + + //debug("################### Get Monitor Summary " + "[" + startDate + "," + endDate + "," + projectsList +"," + workflowsList +"," + executionStatusList +"]"); + + var start_date = startDate; + var end_date = endDate; + var projects = []; + var workflows = []; + var execution_status=[]; + + + + if(end_date===undefined) + { + var now = new Date(); + var month = now.getMonth()+1; + + + if(month.toString().length==1)month = "0" + month.toString(); + + + end_date=now.getFullYear() + "-" + month + "-" + now.getDate(); + + now.setDate(now.getDate()-30); + month = now.getMonth()+1; + if(month.toString().length==1)month = "0" + '' + month; + start_date=now.getFullYear() + "-" + month + "-" + now.getDate(); + + } + + debug("***** START POSITION: " + returnStart); + debug("***** COUNT : " + returnCount); + + debug("***** START_DATE: " + start_date); + debug("***** END_DATE: " + end_date); + + if(projectsList!== undefined && projectsList!==null)projects = projectsList.split(","); + if(workflowsList!== undefined && workflowsList!==null)workflows = workflowsList.split(","); + if(executionStatusList!== undefined && executionStatusList!==null)execution_status = executionStatusList.split(","); + + var data={}; + data.start_date=start_date; + data.end_date=end_date; + + if(projects.length>0)data.projects=projects; + if(workflows.length>0)data.workflows=workflows; + if(execution_status.length>0)data.execution_status=execution_status; + + //var data = { "start_date": start_date, "end_date": end_date, "projects": projects, "workflows": workflows, "execution_status":execution_status }; + + if(returnStart!==undefined && returnCount !==undefined) + { + url+="?skip="+returnStart + "&limit=" + returnCount; + } + request.post(url, username, password, timeout,data, processResponse); +} + +function logDetail(billUid) { + + url +="/workflow-execution/logs/" + billUid; + debug("############################ getLog Detail"); + request.get(url, username, password, timeout, processResponse); +} + + + +module.exports = { + help, init, list, logDetail +}; diff --git a/wmiocli.js b/wmiocli.js index 0c43223..4a6d001 100644 --- a/wmiocli.js +++ b/wmiocli.js @@ -4,7 +4,7 @@ * Apache-2.0 */ -const versionNo = "2022.11.3" +const versionNo = "2023.3.0" const { Command, Option } = require('commander'); const { exit } = require('process'); const readline = require('readline-sync'); @@ -15,8 +15,11 @@ var wf = require('./workflow.js'); var theme = require('./themes.js'); var recipe = require('./recipe.js'); var flowservice = require('./flowservice.js'); +var monitor = require('./monitor.js'); var experimental = require('./experimental.js'); var hideExperimental = true; +returnStart = 0; +returnCount = 1000; const { setLogLevel } = require('./debug.js'); @@ -33,54 +36,66 @@ var tenantUser; var tenantPw; -function readFromConsole(question,isPassword) -{ +function readFromConsole(question, isPassword) { var answer; - if(isPassword !== undefined && isPassword!==null && isPassword==true) - { - answer = readline.question("\x1b[32m" + question + "\x1b[0m",{hideEchoBack: true}); + if (isPassword !== undefined && isPassword !== null && isPassword == true) { + answer = readline.question("\x1b[32m" + question + "\x1b[0m", { hideEchoBack: true }); } - else - { + else { answer = readline.question("\x1b[32m" + question + "\x1b[0m"); } return answer; } -function checkOptions(){ +function checkOptions() { - if(program.opts().proxy !== undefined) - { + if (program.opts().proxy !== undefined) { proxy = program.opts().proxy; debug("Using Proxy: " + proxy); } - if(program.opts().caCert !== undefined) - { + if (program.opts().caCert !== undefined) { caCertFile = program.opts().caCert; debug("Using CA Cert File: " + caCertFile); } + if(program.opts().start !== undefined) { + if(isNaN(program.opts().start)) + { + console.log("--start must be a numeric value"); + process.exit(1); + } + returnStart = program.opts().start; + } + + if(program.opts().count !== undefined) { + if(isNaN(program.opts().count)) + { + console.log("--count must be a numeric value"); + process.exit(1); + } + returnCount = program.opts().count; + } + + ignoreTLS = program.opts().ignoreTLSErrors; - - if(program.opts().prettyprint == true) - { + + if (program.opts().prettyprint == true) { prettyprint = true; } + + var levelInput = program.opts().loglevel - if(program.opts().verbose == true) - { + if (program.opts().verbose == true) { levelInput = "DEBUG"; } - if(levelInput == undefined && !program.opts().verbose){ + if (levelInput == undefined && !program.opts().verbose) { levelInput = "OFF"; } - else - { - switch (levelInput) - { + else { + switch (levelInput) { case "OFF": dbg.setLogLevel(0); break; @@ -95,69 +110,73 @@ function checkOptions(){ break; case "DEBUG": dbg.setLogLevel(4); - break; + break; default: console.log("-level incorrectly set, should be one of: OFF, ERROR, WARN, INFO, DEBUG"); process.exit(1); } - } + } - if(program.opts().domain == undefined){ + if (program.opts().domain == undefined) { tenantDomain = readFromConsole('Please type your tenant domain name: '); } - else{ + else { tenantDomain = program.opts().domain - if(tenantDomain.indexOf("http")==0){ + if (tenantDomain.indexOf("http") == 0) { console.log("Please provide the tenant domain name only (without https:// prefix and any URL suffix\ne.g. 'tenant.int-aws-us.webmethods.io'"); process.exit(1); } } - if(program.opts().user == undefined){ + if (program.opts().user == undefined) { tenantUser = readFromConsole('Please type your tenant User ID: '); } - else{ + else { tenantUser = program.opts().user } - if(program.opts().password == undefined){ - tenantPw = readFromConsole('Please type your tenant User Password: ',true); + if (program.opts().password == undefined) { + tenantPw = readFromConsole('Please type your tenant User Password: ', true); } - else{ + else { tenantPw = program.opts().password } } -function debug(message){ - dbg.message("
" + message,4); +function debug(message) { + dbg.message("
" + message, 4); } const program = new Command(); program -//Program Info + //Program Info .version(versionNo) -//required options + //required options .option('-d, --domain ', 'Tenant Doamin Name, e.g. "tenant.int-aws-us.webmethods.io"') .option('-u, --user ', 'Tenant User ID') .option('-p, --password ', 'Tenant User Password') //.requiredOption('-p, --password ', 'Tenant User Password') - -//options + + //Positional optoins + .option('-s, --start ', 'Index of where to start the return of data (default 0)') + .option('-l, --count ', 'Count of items to return (default 1000)') + + //options .addOption(new Option('-t, --timeout ', 'timeout in seconds').default(60, 'one minute')) - .option('--prettyprint','Pretty Print JSON output') - .option('--verbose','Enables full debug mode (replaced by --loglevel DEBUG)') - .option('--loglevel ','Change the logging level of DEBUG, INFO,WARN,ERROR,OFF (default being off)') + .option('--prettyprint', 'Pretty Print JSON output') + .option('--verbose', 'Enables full debug mode (replaced by --loglevel DEBUG)') + .option('--loglevel ', 'Change the logging level of DEBUG, INFO,WARN,ERROR,OFF (default being off)') - .option('--proxy ','URL for proxy server if required') - .option('--caCert ','Path to a CACert PEM file if required') - .option('--ignoreTLSErrors','Ignore TLS errors') - .option('--experimental','Provide help information on experimental commands') + .option('--proxy ', 'URL for proxy server if required') + .option('--caCert ', 'Path to a CACert PEM file if required') + .option('--ignoreTLSErrors', 'Ignore TLS errors') + .option('--experimental', 'Provide help information on experimental commands') - -//Additional help + + //Additional help .addHelpText('before', ` \x1b[34m┌──────────────────────────────────────────────────────────────────────────────┐ │\x1b[36m webMethods.io Integration API CLI tool\x1b[0m\x1b[34m │ @@ -182,12 +201,14 @@ $ node wmiocli.js --help + wf.help() + flowservice.help() + role.help() - + recipe.help() + + recipe.help() + theme.help() -) + + monitor.help() + ) + .showSuggestionAfterError() -; + ; /** * ------------------------------------------------------------------------------------------------------------------------------------ @@ -195,157 +216,157 @@ $ node wmiocli.js --help * ------------------------------------------------------------------------------------------------------------------------------------ */ program.command('project [project-name]') -.description('Lists all projects or view an individual project, specified via project name or uid') -.action((projectName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = project.list(projectName); - if(resp)console.log(resp); -}); + .description('Lists all projects or view an individual project, specified via project name or uid') + .action((projectName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = project.list(projectName); + if (resp) console.log(resp); + }); program.command('project-assets ') -.description('Lists project assets from given project name or uid') -.action((projectName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = project.listAssets(projectName); - if(resp)console.log(resp); -}); + .description('Lists project assets from given project name or uid') + .action((projectName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = project.listAssets(projectName); + if (resp) console.log(resp); + }); program.command('project-assets-detailed ') -.description('Lists project assets (All Details) from given project name or uid') -.action((projectName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = project.listAssetsDetailed(projectName); - if(resp)console.log(resp); -}); + .description('Lists project assets (All Details) from given project name or uid') + .action((projectName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = project.listAssetsDetailed(projectName); + if (resp) console.log(resp); + }); program.command('project-create ') -.description('Create project with given name') -.action((projectName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.create(projectName); -}); + .description('Create project with given name') + .action((projectName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.create(projectName); + }); program.command('project-update ') -.description('Update project with new name') -.action((projectId, projectName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.update(projectId, projectName); -}); + .description('Update project with new name') + .action((projectId, projectName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.update(projectId, projectName); + }); program.command('project-delete ') -.description('Delete project with given id') -.action((projectId) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.del(projectId); -}); + .description('Delete project with given id') + .action((projectId) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.del(projectId); + }); program.command('project-publish ') -.description('Pubilsh project to another tenant with given id') -.action((projectId,publishName,targetTenantDomainName,targetUserId,targetUserPassword,assetsJson) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.pub(projectId,publishName,targetTenantDomainName,targetUserId,targetUserPassword,assetsJson); - -}); + .description('Pubilsh project to another tenant with given id') + .action((projectId, publishName, targetTenantDomainName, targetUserId, targetUserPassword, assetsJson) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.pub(projectId, publishName, targetTenantDomainName, targetUserId, targetUserPassword, assetsJson); + + }); program.command('project-deploy ') -.description('deploy published project with given version into tenant') -.action((projectName, version) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.deploy(projectName,version); -}); + .description('deploy published project with given version into tenant') + .action((projectName, version) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.deploy(projectName, version); + }); program.command('project-param [param-uid]') -.description('Lists all project parameters from given project name, or specific parameter with given parameter uid') -.action((projectName,paramName) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = project.listParam(projectName,paramName); - if(resp)console.log(resp); -}); + .description('Lists all project parameters from given project name, or specific parameter with given parameter uid') + .action((projectName, paramName) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = project.listParam(projectName, paramName); + if (resp) console.log(resp); + }); program.command('project-param-create ') -.description('Creates a project parameter with given values') -.action((projectName,paramName,paramValue,required,isPassword) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - boolReq = false; - boolIsPass = false; - if(required.toUpperCase()=="TRUE")boolReq = true; - if(isPassword.toUpperCase()=="TRUE")boolIsPass = true; - var resp = project.createParam(projectName,paramName,paramValue,boolReq,boolIsPass); - if(resp)console.log(resp); -}); + .description('Creates a project parameter with given values') + .action((projectName, paramName, paramValue, required, isPassword) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + boolReq = false; + boolIsPass = false; + if (required.toUpperCase() == "TRUE") boolReq = true; + if (isPassword.toUpperCase() == "TRUE") boolIsPass = true; + var resp = project.createParam(projectName, paramName, paramValue, boolReq, boolIsPass); + if (resp) console.log(resp); + }); program.command('project-param-update ') -.description('Updates a project parameter matching the provided UID with given values') -.action((projectName,paramUid,paramName,paramValue,required,isPassword) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - boolReq = false; - boolIsPass = false; - if(required.toUpperCase()=="TRUE")boolReq = true; - if(isPassword.toUpperCase()=="TRUE")boolIsPass = true; - var resp = project.updateParam(projectName,paramUid,paramName,paramValue,boolReq,boolIsPass); - if(resp)console.log(resp); -}); + .description('Updates a project parameter matching the provided UID with given values') + .action((projectName, paramUid, paramName, paramValue, required, isPassword) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + boolReq = false; + boolIsPass = false; + if (required.toUpperCase() == "TRUE") boolReq = true; + if (isPassword.toUpperCase() == "TRUE") boolIsPass = true; + var resp = project.updateParam(projectName, paramUid, paramName, paramValue, boolReq, boolIsPass); + if (resp) console.log(resp); + }); program.command('project-param-delete ') -.description('Deletes a project parameter mathcing the given paramater uid') -.action((projectName,paramUid) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = project.deleteParam(projectName,paramUid); - if(resp)console.log(resp); -}); + .description('Deletes a project parameter mathcing the given paramater uid') + .action((projectName, paramUid) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = project.deleteParam(projectName, paramUid); + if (resp) console.log(resp); + }); program.command('project-webhooks-list ') -.description('List webhooks in a project') -.action((projectId) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.listWebhooks(projectId); -}); + .description('List webhooks in a project') + .action((projectId) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.listWebhooks(projectId); + }); program.command('project-webhooks-regenerate ') -.description('Regenerate a webhook in a project for a given workflow UID') -.action((projectId,workflowUid) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.regenWebhook(projectId,workflowUid); -}); + .description('Regenerate a webhook in a project for a given workflow UID') + .action((projectId, workflowUid) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.regenWebhook(projectId, workflowUid); + }); program.command('project-webhooks-auth ') -.description('Set authenatication type (none,login,token) for a webhook in a project for a given workflow UID') -.action((projectId,workflowUid,authType) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.setWebhookAuth(projectId,workflowUid,authType); -}); + .description('Set authenatication type (none,login,token) for a webhook in a project for a given workflow UID') + .action((projectId, workflowUid, authType) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.setWebhookAuth(projectId, workflowUid, authType); + }); program.command('project-triggers-list ') -.description('Provide a list of triggers within a project') -.action((projectId) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.listTriggers(projectId); -}); + .description('Provide a list of triggers within a project') + .action((projectId) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.listTriggers(projectId); + }); program.command('project-triggers-delete ') -.description('Delete a trigger within a project with the given IDs') -.action((projectId,triggerId) => { - checkOptions(); - project.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - project.deleteTrigger(projectId,triggerId); -}); + .description('Delete a trigger within a project with the given IDs') + .action((projectId, triggerId) => { + checkOptions(); + project.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + project.deleteTrigger(projectId, triggerId); + }); /** @@ -354,37 +375,37 @@ program.command('project-triggers-delete ') * ------------------------------------------------------------------------------------------------------------------------------------ */ program.command('role [role-id]') -.description('Lists all roles or views an individual role') -.action((roleId) => { - checkOptions(); - role.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - var resp = role.list(roleId); - if(resp)console.log(resp); -}); + .description('Lists all roles or views an individual role') + .action((roleId) => { + checkOptions(); + role.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + var resp = role.list(roleId); + if (resp) console.log(resp); + }); program.command('role-create ') -.description('Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;') -.action((roleName,roleDescription,rolesList) => { - checkOptions(); - role.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint); - role.insert(roleName,roleDescription, rolesList); -}); + .description('Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;') + .action((roleName, roleDescription, rolesList) => { + checkOptions(); + role.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint); + role.insert(roleName, roleDescription, rolesList); + }); program.command('role-update ') -.description('Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;') -.action((roleId, roleName,roleDescription,rolesList) => { - checkOptions(); - role.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint); - role.update(roleId, roleName,roleDescription, rolesList); -}); + .description('Create roles and specify the permissions for that role. Roles-list should be provided as follows projectName,r,w,e;project name 2,r;') + .action((roleId, roleName, roleDescription, rolesList) => { + checkOptions(); + role.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint); + role.update(roleId, roleName, roleDescription, rolesList); + }); program.command('role-delete ') -.description('Delete a roles with the given role id') -.action((roleId) => { - checkOptions(); - role.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint); - role.del(roleId); -}); + .description('Delete a roles with the given role id') + .action((roleId) => { + checkOptions(); + role.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint); + role.del(roleId); + }); /** * ------------------------------------------------------------------------------------------------------------------------------------ @@ -396,22 +417,22 @@ program.command('role-delete ') * Needs user-id adding. */ program.command('user') -.description('Lists all users') -.action(() => { - checkOptions(); - user.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint); - user.list(undefined); -}); + .description('Lists all users') + .action(() => { + checkOptions(); + user.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint); + user.list(undefined); + }); program.command('user-role-assignment ') -.description('Assigns a user to roles') -.action((userId,roleNames) => { - checkOptions(); - debug("userId: " + userId); - debug("Roles: " + roleNames); - user.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint); - user.assignRoles(userId,roleNames); -}); + .description('Assigns a user to roles') + .action((userId, roleNames) => { + checkOptions(); + debug("userId: " + userId); + debug("Roles: " + roleNames); + user.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint); + user.assignRoles(userId, roleNames); + }); /** * ------------------------------------------------------------------------------------------------------------------------------------ @@ -419,54 +440,54 @@ program.command('user-role-assignment ') * ------------------------------------------------------------------------------------------------------------------------------------ */ program.command('workflow-export ') -.description('Export workflow with id from project ') -.action((projectId, workflowId, filename) => { - checkOptions(); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - wf.exportwf(workflowId,filename); -}); + .description('Export workflow with id from project ') + .action((projectId, workflowId, filename) => { + checkOptions(); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + wf.exportwf(workflowId, filename); + }); program.command('workflow-import ') -.description('Import workflow into project from file ') -.action((projectId, filename) => { - checkOptions(); - debug("Importing Workflow"); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - wf.importwf(filename); -}); + .description('Import workflow into project from file ') + .action((projectId, filename) => { + checkOptions(); + debug("Importing Workflow"); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + wf.importwf(filename); + }); program.command('workflow-delete ') -.description('Delete workflow from project ') -.action((projectId, workflowId) => { - checkOptions(); - debug("Deleting Workflow [" + workflowId + "]"); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - wf.deletewf(workflowId); -}); + .description('Delete workflow from project ') + .action((projectId, workflowId) => { + checkOptions(); + debug("Deleting Workflow [" + workflowId + "]"); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + wf.deletewf(workflowId); + }); program.command('workflow-execute ') - .description('Execute workflow from project ') -.action((projectId, workflowId) => { - checkOptions(); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - wf.runwf(workflowId) -}); + .description('Execute workflow from project ') + .action((projectId, workflowId) => { + checkOptions(); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + wf.runwf(workflowId) + }); program.command('workflow-status ') -.description('Gets Execution status for workflow execution ') -.action((projectId, runId) => { - checkOptions(); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,projectId); - wf.statuswf(runId); -}); + .description('Gets Execution status for workflow execution ') + .action((projectId, runId) => { + checkOptions(); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, projectId); + wf.statuswf(runId); + }); program.command('workflow-create ') -.description('Creates a blank workflow with the given name/description') -.action((projectId, workflowName,workflowDescription) => { - checkOptions(); - wf.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,projectId); - wf.createwf(workflowName,workflowDescription); -}); + .description('Creates a blank workflow with the given name/description') + .action((projectId, workflowName, workflowDescription) => { + checkOptions(); + wf.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, projectId); + wf.createwf(workflowName, workflowDescription); + }); /** * ------------------------------------------------------------------------------------------------------------------------------------ @@ -474,240 +495,278 @@ program.command('workflow-create ') -.description('Export FlowService with name from project ') -.action((projectId, flowName,filename) => { - checkOptions(); - flowservice.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - flowservice.exportFlowService(flowName,filename); -}); + .description('Export FlowService with name from project ') + .action((projectId, flowName, filename) => { + checkOptions(); + flowservice.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + flowservice.exportFlowService(flowName, filename); + }); program.command('flowservice-import ') -.description('Import FlowService from into project ') -.action((projectId, filename) => { - checkOptions(); - flowservice.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - flowservice.importFlowService(filename); -}); + .description('Import FlowService from into project ') + .action((projectId, filename) => { + checkOptions(); + flowservice.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + flowservice.importFlowService(filename); + }); program.command('flowservice-delete ') -.description('Delete FlowService from project ') -.action((projectId, flowName) => { - checkOptions(); - flowservice.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - flowservice.deleteFlowService(flowName); -}); + .description('Delete FlowService from project ') + .action((projectId, flowName) => { + checkOptions(); + flowservice.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + flowservice.deleteFlowService(flowName); + }); program.command('flowservice-execute [input-json]') - .description('Execute FlowService from project with data ') -.action((projectId, flowName,inputJson) => { - checkOptions(); - flowservice.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint,projectId); - flowservice.runFlowService(flowName,inputJson); -}); + .description('Execute FlowService from project with data ') + .action((projectId, flowName, inputJson) => { + checkOptions(); + flowservice.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint, projectId); + flowservice.runFlowService(flowName, inputJson); + }); /** * ------------------------------------------------------------------------------------------------------------------------------------ * THEMES * ------------------------------------------------------------------------------------------------------------------------------------ */ - program.command('theme [theme-uid]') - .description('Lists themes or views an individual theme, specified via uid') - .action((themeUid) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.list(themeUid); - }); - - - program.command('theme-create [footer-text] [about-page]') - .description('Create theme with given data') - .action((themeName,themeDescription,themeObject,footerText,aboutPage) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.create(themeName,themeDescription,themeObject,footerText,aboutPage); - }); - - program.command('theme-update [footer-text] [about-page]') - .description('Update theme with the given UID with given data') - .action((themeUid, themeName,themeDescription,themeObject,footerText,aboutPage) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.update(themeUid, themeName,themeDescription,themeObject,footerText,aboutPage); - }); - - program.command('theme-delete ') - .description('Delete theme with the given UID') - .action((themeUid) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.del(themeUid); - }); - - program.command('theme-activate ') - .description('Activate theme with the given UID') - .action((themeUid) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.activate(themeUid); - }); - - program.command('theme-deactivate ') - .description('Deactivate theme with the given UID') - .action((themeUid) => { - checkOptions(); - theme.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - theme.deactivate(themeUid); - }); - - /** - * ------------------------------------------------------------------------------------------------------------------------------------ - * Recipes - * ------------------------------------------------------------------------------------------------------------------------------------ - */ - - program.command('recipe [recipe-uid]') - .description('List all Workflow recipes, or get a single recipe with a given recipe UID') - .action((recipeUid) => { - checkOptions(); - recipe.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - recipe.list(recipeUid); - }); - - program.command('recipe-delete ') - .description('Delete Workflow recipe with a given recipe UID') - .action((recipeUid) => { - checkOptions(); - recipe.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - recipe.del(recipeUid); - }); - - program.command('recipe-create ') -.description('Create Workfllow Receipt from file ') -.action((filename) => { - checkOptions(); - debug("Importing Workflow"); - recipe.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - recipe.create(filename); -}); - - /** - * ------------------------------------------------------------------------------------------------------------------------------------ - * experimental non-public APIs - * ------------------------------------------------------------------------------------------------------------------------------------ +program.command('theme [theme-uid]') + .description('Lists themes or views an individual theme, specified via uid') + .action((themeUid) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.list(themeUid); + }); + + +program.command('theme-create [footer-text] [about-page]') + .description('Create theme with given data') + .action((themeName, themeDescription, themeObject, footerText, aboutPage) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.create(themeName, themeDescription, themeObject, footerText, aboutPage); + }); + +program.command('theme-update [footer-text] [about-page]') + .description('Update theme with the given UID with given data') + .action((themeUid, themeName, themeDescription, themeObject, footerText, aboutPage) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.update(themeUid, themeName, themeDescription, themeObject, footerText, aboutPage); + }); + +program.command('theme-delete ') + .description('Delete theme with the given UID') + .action((themeUid) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.del(themeUid); + }); + +program.command('theme-activate ') + .description('Activate theme with the given UID') + .action((themeUid) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.activate(themeUid); + }); + +program.command('theme-deactivate ') + .description('Deactivate theme with the given UID') + .action((themeUid) => { + checkOptions(); + theme.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + theme.deactivate(themeUid); + }); + +/** +* ------------------------------------------------------------------------------------------------------------------------------------ +* Recipes +* ------------------------------------------------------------------------------------------------------------------------------------ +*/ + +program.command('recipe [recipe-uid]') + .description('List all Workflow recipes, or get a single recipe with a given recipe UID') + .action((recipeUid) => { + checkOptions(); + recipe.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + recipe.list(recipeUid); + }); + +program.command('recipe-delete ') + .description('Delete Workflow recipe with a given recipe UID') + .action((recipeUid) => { + checkOptions(); + recipe.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + recipe.del(recipeUid); + }); + +program.command('recipe-create ') + .description('Create Workflow Recipe from file ') + .action((filename) => { + checkOptions(); + debug("Importing Workflow"); + recipe.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + recipe.create(filename); + }); + +/** Monitor + * */ - program.command('experimental-user',{hidden: hideExperimental}) - .addHelpCommand("HELP") - .description('Get User information') - .action(() => { - checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.user(); + + program.command('monitor [start-date] [end-date] [projects-list] [workflows-list] [execution-status]') + .description('Get Monitor summary') + .action((from,count,startDate,endDate,projectsList,workflowsList,executionStatus) => { + checkOptions(); + debug("Monitor Summary"); + debug("***************** startdate:" + startDate); + monitor.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + monitor.list(startDate,endDate,projectsList,workflowsList,executionStatus,from,count) + }); + + program.command('monitor-workflow-log ') + .description('Get Monitor summary') + .action((billUid) => { + checkOptions(); + debug("Monitor Log"); + monitor.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + monitor.logDetail(billUid); }); - program.command('experimental-stages',{hidden: hideExperimental}) +/** +* ------------------------------------------------------------------------------------------------------------------------------------ +* experimental non-public APIs +* ------------------------------------------------------------------------------------------------------------------------------------ +*/ +program.command('experimental-user', { hidden: hideExperimental }) + .addHelpCommand("HELP") + .description('Get User information') + .action(() => { + checkOptions(); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.user(); + }); + +program.command('experimental-stages', { hidden: hideExperimental }) .description('Get Stage information') .action(() => { - checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.stages(); + checkOptions(); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.stages(); }); - program.command('experimental-project-workflows ',{hidden: hideExperimental}) +program.command('experimental-project-workflows ', { hidden: hideExperimental }) .description('Get information about project workflows') .action((projectId) => { - checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.projectWorkflows(projectId); + checkOptions(); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.projectWorkflows(projectId); }); - program.command('experimental-project-flowservices ',{hidden: hideExperimental}) +program.command('experimental-project-flowservices ', { hidden: hideExperimental }) .description('Get information about project FlowServices') .action((projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) experimental.projectFlowservices(projectId); }); - program.command('experimental-project-connector-accounts ',{hidden: hideExperimental}) +program.command('experimental-project-connector-accounts ', { hidden: hideExperimental }) .description('Get Information about project connector accounts') .action((projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) experimental.connectorAccounts(projectId); }); - program.command('experimental-project-connector-account-wf-config ',{hidden: hideExperimental}) +program.command('experimental-project-connector-account-wf-config ', { hidden: hideExperimental }) .description('Get configuration information about project connector accounts') .action((projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) experimental.getProjectAccountConfig(projectId); }); - program.command('experimental-project-search ',{hidden: hideExperimental}) +program.command('experimental-project-search ', { hidden: hideExperimental }) .description('Search project info by name') .action((projectName) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) experimental.searchProject(projectName); }); - program.command('experimental-project-deployments ',{hidden: hideExperimental}) +program.command('experimental-project-deployments ', { hidden: hideExperimental }) .description('List all project deployments') .action((projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) experimental.projectDeployments(projectId); }); - program.command('experimental-workflow-monitor [execution-status] [start-date] [end-date] [project-id] [workflow-id]',{hidden: hideExperimental}) +program.command('experimental-workflow-monitor [execution-status] [start-date] [end-date] [project-id] [workflow-id]', { hidden: hideExperimental }) .description('List Workflow Monitor') - .action((executionStatus,startDate,endDate,projectId,workflowId) => { + .action((executionStatus, startDate, endDate, projectId, workflowId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.getMonitorInfo(executionStatus,startDate,endDate,projectId,workflowId); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.getMonitorInfo(executionStatus, startDate, endDate, projectId, workflowId); }); - program.command('experimental-workflow-resubmit [restart-or-resume] [start-date] [end-date] [project-id] [workflow-id]',{hidden: hideExperimental}) +program.command('experimental-workflow-resubmit [restart-or-resume] [start-date] [end-date] [project-id] [workflow-id]', { hidden: hideExperimental }) .description('Resubmit workflows from monitor') - .action((restartOrResume,startDate,endDate,projectId,workflowId) => { + .action((restartOrResume, startDate, endDate, projectId, workflowId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.workflowResubmit(restartOrResume, startDate, endDate, projectId,workflowId); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.workflowResubmit(restartOrResume, startDate, endDate, projectId, workflowId); }); - - program.command('experimental-messaging-create ',{hidden: hideExperimental}) + +program.command('experimental-messaging-create ', { hidden: hideExperimental }) .description('Create a messaging queue or topic') - .action((queueOrTopc,name,projectId) => { + .action((queueOrTopc, name, projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.messagingCreate(queueOrTopc,projectId,name); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.messagingCreate(queueOrTopc, projectId, name); }); - program.command('experimental-messaging-delete ',{hidden: hideExperimental}) +program.command('experimental-messaging-delete ', { hidden: hideExperimental }) .description('Delete a messaging queue or topic') - .action((queueOrTopc,name,projectId) => { + .action((queueOrTopc, name, projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.messagingDelete(queueOrTopc,projectId,name); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.messagingDelete(queueOrTopc, projectId, name); }); - program.command('experimental-messaging-stats ',{hidden: hideExperimental}) +program.command('experimental-messaging-stats ', { hidden: hideExperimental }) .description('Get Messaging Stats') - .action((name,projectId) => { + .action((name, projectId) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.messagingStats(projectId,name); - }); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.messagingStats(projectId, name); + }); - program.command('experimental-workflow-execution-analysis [format]',{hidden: hideExperimental}) +program.command('experimental-workflow-execution-analysis [format]', { hidden: hideExperimental }) .description('Provide workflow exedcution analysis') - .action((vbid,format) => { + .action((vbid, format) => { checkOptions(); - experimental.init(tenantDomain,tenantUser,tenantPw,program.opts().timeout,program.opts().prettyprint) - experimental.vbidAnalysis(vbid,format); + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.vbidAnalysis(vbid, format); + }) + + +program.command('experimental-flowservice-scheduler ', { hidden: hideExperimental }) + .description('Provide workflow exedcution analysis') + .action((projectId, flowServiceId,scheduleStatus) => { + checkOptions(); + //Valid status = pause or resume. + scheduleStatus = scheduleStatus.toLowerCase(); + if(scheduleStatus != "pause" && scheduleStatus !="resume") + { + console.log("Schedule status should be one of pause or resume. You provided: " + scheduleStatus); + process.exit(1); + } + experimental.init(tenantDomain, tenantUser, tenantPw, program.opts().timeout, program.opts().prettyprint) + experimental.flowserviceScheduler(flowServiceId,scheduleStatus,projectId); }) - program.parse();