Skip to content

Commit

Permalink
2023.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sagpembo committed Mar 7, 2023
1 parent 285ab31 commit 879894d
Show file tree
Hide file tree
Showing 4 changed files with 751 additions and 410 deletions.
104 changes: 104 additions & 0 deletions accounts.js
Original file line number Diff line number Diff line change
@@ -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("<ACCOUNTS> " + 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
};
41 changes: 37 additions & 4 deletions experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var payloaduid;
var projectuid;
var data;
var type;
var flowServiceId;
var scheduleStatus;


const maxRunningWorkflows = 20;
Expand Down Expand Up @@ -69,6 +71,28 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
dbg.message("<EXPERIMENTAL>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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -664,7 +691,7 @@ function getLogs()
function searchProjectsByName()
{
dbg.message("<EXPERIMENTAL>"+"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("<EXPERIMENTAL>"+"Next URL [" + endPoint + "]",4);
var headers = setHeaders();
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -996,6 +1026,9 @@ function loginResponse(url,err,body,res){

}




module.exports = {init,
user,stages,
searchProject,
Expand All @@ -1004,4 +1037,4 @@ module.exports = {init,
connectorAccounts,getProjectAccountConfig,
getMonitorInfo,workflowResubmit,
messagingCreate,messagingStats,messagingDelete,
vbidAnalysis};
vbidAnalysis, flowserviceScheduler};
145 changes: 145 additions & 0 deletions monitor.js
Original file line number Diff line number Diff line change
@@ -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("<MONITOR> " + 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
};
Loading

0 comments on commit 879894d

Please sign in to comment.