Skip to content

Commit 879894d

Browse files
committed
2023.3.0
1 parent 285ab31 commit 879894d

File tree

4 files changed

+751
-410
lines changed

4 files changed

+751
-410
lines changed

accounts.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* webMethods.io CLI
3+
* Copyright 2022 Software AG
4+
* Apache-2.0
5+
*/
6+
7+
const request = require('./rest.js');
8+
9+
10+
var domainName, username, password, timeout;
11+
var prettyprint = false;
12+
var url;
13+
14+
function debug(message) {
15+
dbg.message("<ACCOUNTS> " + message,4);
16+
}
17+
18+
function help() {
19+
return `
20+
\x1b[4mAccounts\x1b[0m
21+
22+
\x1b[32mGet Accounts:\x1b[0m
23+
$ node wmiocli.js
24+
-d tenant.int-aws-us.webmethods.io
25+
-u user
26+
-p password
27+
account
28+
29+
30+
\x1b[32mDelete an Account:\x1b[0m
31+
$ node wmiocli.js
32+
-d tenant.int-aws-us.webmethods.io
33+
-u user
34+
-p password
35+
account-delete accountUid
36+
37+
\x1b[32mDelete an Account:\x1b[0m
38+
$ node wmiocli.js
39+
-d tenant.int-aws-us.webmethods.io
40+
-u user
41+
-p password
42+
account-update accountUid
43+
`;
44+
}
45+
function init(inDomainName, inUsername, inPassword, inTimeout, inPrettyprint) {
46+
domainName = inDomainName;
47+
username = inUsername;
48+
password = inPassword;
49+
timeout = inTimeout;
50+
prettyprint = inPrettyprint;
51+
52+
url = "https://" + domainName + "/apis/v1/rest/projects";
53+
debug("Username [" + username + "]");
54+
debug("URL [" + url + "]");
55+
debug("Timeout [" + timeout + "]");
56+
}
57+
58+
/**
59+
* Call back function to process REST response
60+
* @param {return data from REST request} data
61+
* @param {status} status
62+
*/
63+
function processResponse(data, status) {
64+
if (prettyprint == true) {
65+
console.log(JSON.stringify(data, null, 4));
66+
}
67+
else {
68+
console.log(JSON.stringify(data));
69+
}
70+
71+
if (status != 0) {
72+
process.exit(status);
73+
}
74+
}
75+
76+
/* Accounts */
77+
function getAccount(projectId) {
78+
79+
url +="/" + projectId + "/accounts";
80+
request.get(url, username, password, timeout, processResponse);
81+
}
82+
83+
function deleteAccount(projectId,accountUid) {
84+
85+
url +="/" + projectId + "/accounts/" + accountUid;
86+
request.del(url, username, password, timeout,null, processResponse);
87+
}
88+
89+
/**
90+
* To be completed
91+
* @param {} projectId
92+
* @param {*} accountUid
93+
*/
94+
function updateConfiguration(projectId,accountUid) {
95+
96+
//url +="/" + projectId + "/accounts/" + accountUid;
97+
//request.del(url, username, password, timeout,null, processResponse);
98+
}
99+
100+
101+
102+
module.exports = {
103+
help, init, getAccount, deleteAccount
104+
};

experimental.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var payloaduid;
3939
var projectuid;
4040
var data;
4141
var type;
42+
var flowServiceId;
43+
var scheduleStatus;
4244

4345

4446
const maxRunningWorkflows = 20;
@@ -69,6 +71,28 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
6971
dbg.message("<EXPERIMENTAL>Timeout [" + timeout + "]",4);
7072
}
7173

74+
75+
function flowserviceScheduler(inFlowServiceId, inScheduleStatus, inProjectId)
76+
{
77+
flowServiceId = inFlowServiceId;
78+
scheduleStatus = inScheduleStatus;
79+
projectId = inProjectId;
80+
finalCall = processScheduleStatus;
81+
debug("******************Starting FlowService Scheduler");
82+
loginPhase1();
83+
}
84+
85+
function processScheduleStatus()
86+
{
87+
debug("Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]");
88+
89+
var endPoint = "https://" +domainName + "/integration/rest/scheduler/"+ scheduleStatus +"/" + flowServiceId +"?projectName="+ projectId ;
90+
debug("Next URL [" + endPoint + "]");
91+
var headers = setHeaders();
92+
var body;
93+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,undefined,headers,true,false);
94+
}
95+
7296
function user()
7397
{
7498
finalCall = execUserInfo;
@@ -236,6 +260,9 @@ function setHeaders()
236260
{name:"X-Requested-With",value:"XMLHttpRequest"},
237261
{name:"X-Request-ID",value:generateUUID()},
238262
{name:"project_uid",value:projectId},
263+
{name:"x-csrf-token",value:csrf},
264+
265+
239266
];
240267
return headers;
241268
}
@@ -664,7 +691,7 @@ function getLogs()
664691
function searchProjectsByName()
665692
{
666693
dbg.message("<EXPERIMENTAL>"+"Search Projects By Name [" + projectName + "]",4);
667-
var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=1000&skip=0&q=" + projectName;
694+
var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=" + returnCount+ "&skip=" + returnStart + "&q=" + projectName;
668695
dbg.message("<EXPERIMENTAL>"+"Next URL [" + endPoint + "]",4);
669696
var headers = setHeaders();
670697
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
@@ -711,7 +738,10 @@ function projectWorkflowsInfo()
711738
{
712739

713740
debug("Project Workflows Info");
714-
var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=1000&skip=0&filter=recent&tags=&query=";
741+
var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=" + returnCount+ "&skip=" + returnStart + "&filter=recent&tags=&query=";
742+
743+
744+
715745
debug("Next URL [" + endPoint + "]");
716746
var headers = setHeaders();
717747
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processProjectsResponse,undefined,headers,true,false);
@@ -721,7 +751,7 @@ function projectFlowServicesInfo()
721751
{
722752

723753
debug("Project FlowServices Info");
724-
var endPoint = "https://" + domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?skip=0&limit=1000";
754+
var endPoint = "https://" + domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?limit=" + returnCount+ "&skip=" + returnStart;
725755
debug("Next URL [" + endPoint + "]");
726756
var headers = setHeaders();
727757
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
@@ -996,6 +1026,9 @@ function loginResponse(url,err,body,res){
9961026

9971027
}
9981028

1029+
1030+
1031+
9991032
module.exports = {init,
10001033
user,stages,
10011034
searchProject,
@@ -1004,4 +1037,4 @@ module.exports = {init,
10041037
connectorAccounts,getProjectAccountConfig,
10051038
getMonitorInfo,workflowResubmit,
10061039
messagingCreate,messagingStats,messagingDelete,
1007-
vbidAnalysis};
1040+
vbidAnalysis, flowserviceScheduler};

monitor.js

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*
2+
* webMethods.io CLI
3+
* Copyright 2022 Software AG
4+
* Apache-2.0
5+
*/
6+
7+
const request = require('./rest.js');
8+
9+
10+
var domainName, username, password, timeout;
11+
var prettyprint = false;
12+
var url;
13+
14+
function debug(message) {
15+
dbg.message("<MONITOR> " + message,4);
16+
}
17+
18+
function help() {
19+
return `
20+
\x1b[4mMonitor\x1b[0m
21+
22+
\x1b[32mRetrieve Monitor Summary:\x1b[0m
23+
$ node wmiocli.js
24+
-d tenant.int-aws-us.webmethods.io
25+
-u user
26+
-p password
27+
monitor from count startDate endDate projectsList workflowsList executionStatus
28+
e.g.
29+
monitor 1 10 2023-01-01 2023-01-10 myProject workflow1,workflow2 failed,timeout,stopped
30+
monitor 11 10 2023-01-01 2023-01-10 myProject workflow1,workflow2 failed,timeout,stopped
31+
monitor
32+
33+
34+
\x1b[32mView an Execution Log:\x1b[0m
35+
$ node wmiocli.js
36+
-d tenant.int-aws-us.webmethods.io
37+
-u user
38+
-p password
39+
monitor-workflow-log billUid
40+
41+
`;
42+
}
43+
function init(inDomainName, inUsername, inPassword, inTimeout, inPrettyprint) {
44+
domainName = inDomainName;
45+
username = inUsername;
46+
password = inPassword;
47+
timeout = inTimeout;
48+
prettyprint = inPrettyprint;
49+
50+
url = "https://" + domainName + "/apis/v1/rest/monitor";
51+
debug("Username [" + username + "]");
52+
debug("URL [" + url + "]");
53+
debug("Timeout [" + timeout + "]");
54+
}
55+
56+
/**
57+
* Call back function to process REST response
58+
* @param {return data from REST request} data
59+
* @param {status} status
60+
*/
61+
function processResponse(data, status) {
62+
if (prettyprint == true) {
63+
console.log(JSON.stringify(data, null, 4));
64+
}
65+
else {
66+
console.log(JSON.stringify(data));
67+
}
68+
69+
if (status != 0) {
70+
process.exit(status);
71+
}
72+
}
73+
74+
/* Monitor */
75+
function list(startDate,endDate,projectsList,workflowsList,executionStatusList) {
76+
77+
url +="/summary";
78+
79+
//debug("################### Get Monitor Summary " + "[" + startDate + "," + endDate + "," + projectsList +"," + workflowsList +"," + executionStatusList +"]");
80+
81+
var start_date = startDate;
82+
var end_date = endDate;
83+
var projects = [];
84+
var workflows = [];
85+
var execution_status=[];
86+
87+
88+
89+
if(end_date===undefined)
90+
{
91+
var now = new Date();
92+
var month = now.getMonth()+1;
93+
94+
95+
if(month.toString().length==1)month = "0" + month.toString();
96+
97+
98+
end_date=now.getFullYear() + "-" + month + "-" + now.getDate();
99+
100+
now.setDate(now.getDate()-30);
101+
month = now.getMonth()+1;
102+
if(month.toString().length==1)month = "0" + '' + month;
103+
start_date=now.getFullYear() + "-" + month + "-" + now.getDate();
104+
105+
}
106+
107+
debug("***** START POSITION: " + returnStart);
108+
debug("***** COUNT : " + returnCount);
109+
110+
debug("***** START_DATE: " + start_date);
111+
debug("***** END_DATE: " + end_date);
112+
113+
if(projectsList!== undefined && projectsList!==null)projects = projectsList.split(",");
114+
if(workflowsList!== undefined && workflowsList!==null)workflows = workflowsList.split(",");
115+
if(executionStatusList!== undefined && executionStatusList!==null)execution_status = executionStatusList.split(",");
116+
117+
var data={};
118+
data.start_date=start_date;
119+
data.end_date=end_date;
120+
121+
if(projects.length>0)data.projects=projects;
122+
if(workflows.length>0)data.workflows=workflows;
123+
if(execution_status.length>0)data.execution_status=execution_status;
124+
125+
//var data = { "start_date": start_date, "end_date": end_date, "projects": projects, "workflows": workflows, "execution_status":execution_status };
126+
127+
if(returnStart!==undefined && returnCount !==undefined)
128+
{
129+
url+="?skip="+returnStart + "&limit=" + returnCount;
130+
}
131+
request.post(url, username, password, timeout,data, processResponse);
132+
}
133+
134+
function logDetail(billUid) {
135+
136+
url +="/workflow-execution/logs/" + billUid;
137+
debug("############################ getLog Detail");
138+
request.get(url, username, password, timeout, processResponse);
139+
}
140+
141+
142+
143+
module.exports = {
144+
help, init, list, logDetail
145+
};

0 commit comments

Comments
 (0)