Skip to content

Commit 4db745c

Browse files
authored
Merge pull request #16 from SoftwareAG/development
Development
2 parents cce263c + 973e17e commit 4db745c

File tree

4 files changed

+851
-410
lines changed

4 files changed

+851
-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: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ var payloaduid;
3939
var projectuid;
4040
var data;
4141
var type;
42+
var flowServiceId;
43+
var scheduleStatus;
44+
var optionEnable;
45+
var flowOptionType;
46+
var incEdgeFlows;
4247

4348

4449
const maxRunningWorkflows = 20;
@@ -69,6 +74,86 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
6974
dbg.message("<EXPERIMENTAL>Timeout [" + timeout + "]",4);
7075
}
7176

77+
78+
function flowserviceDetails(inProjectId,includeEdgeFlows)
79+
{
80+
projectId = inProjectId;
81+
incEdgeFlows = includeEdgeFlows
82+
finalCall = processflowDetails;
83+
loginPhase1();
84+
}
85+
86+
function processflowDetails()
87+
{
88+
debug("Process FlowService Details - Project [" + projectId + "] Include Edge flows [" + incEdgeFlows + "]");
89+
var endPoint = "https://" +domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?limit=" + returnCount+ "&skip=" + returnStart;
90+
var body;
91+
debug("Next URL [" + endPoint + "]");
92+
var headers = setHeaders();
93+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"GET",processResponse,undefined,headers,true,false);
94+
}
95+
96+
function flowserviceOption(inFlowServiceId, inEnable, inProjectId,inOptionType)
97+
{
98+
flowServiceId = inFlowServiceId;
99+
optionEnable = inEnable;
100+
projectId = inProjectId;
101+
flowOptionType = inOptionType;
102+
finalCall = processflowOption;
103+
loginPhase1();
104+
}
105+
106+
function processflowOption()
107+
{
108+
debug("Process FlowService Option [" + flowOptionType + "] - Project [" + projectId + "] FlowService [" + flowServiceId + "] Enable [" + optionEnable + "]");
109+
if(optionEnable!==undefined&&optionEnable!==null&optionEnable.length>1){
110+
optionEnable = (optionEnable.toLowerCase()=="true");
111+
}
112+
113+
var endPoint = "https://" +domainName + "/integration/rest/ut-flow/flow/";
114+
var body={};
115+
if(flowOptionType=="http")
116+
{
117+
endPoint+= "export/" + flowServiceId +"?projectName="+ projectId ;
118+
body = {"integration":{"serviceData":{"stages":[{"stageName":"stage00","markExportable":optionEnable}]}}};
119+
}
120+
else if(flowOptionType=="resubmit")
121+
{
122+
endPoint+= "resubmit/" + flowServiceId +"?projectName="+ projectId ;
123+
body = {"integration":{"serviceData":{"stages":[{"stageName":"stage00","markResubmittable":optionEnable}]}}};
124+
}
125+
else
126+
{
127+
console.log("Unable to determine flow option type: " + flowOptionType);
128+
process.exit(1);
129+
}
130+
131+
debug("Next URL [" + endPoint + "]");
132+
var headers = setHeaders();
133+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"PUT",processResponse,undefined,headers,true,false);
134+
}
135+
136+
137+
function flowserviceScheduler(inFlowServiceId, inScheduleStatus, inProjectId)
138+
{
139+
flowServiceId = inFlowServiceId;
140+
scheduleStatus = inScheduleStatus;
141+
projectId = inProjectId;
142+
finalCall = processScheduleStatus;
143+
loginPhase1();
144+
}
145+
146+
function processScheduleStatus()
147+
{
148+
debug("Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]");
149+
150+
var endPoint = "https://" +domainName + "/integration/rest/scheduler/"+ scheduleStatus +"/" + flowServiceId +"?projectName="+ projectId ;
151+
debug("Next URL [" + endPoint + "]");
152+
var headers = setHeaders();
153+
var body;
154+
rest.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,undefined,headers,true,false);
155+
}
156+
72157
function user()
73158
{
74159
finalCall = execUserInfo;
@@ -236,6 +321,9 @@ function setHeaders()
236321
{name:"X-Requested-With",value:"XMLHttpRequest"},
237322
{name:"X-Request-ID",value:generateUUID()},
238323
{name:"project_uid",value:projectId},
324+
{name:"x-csrf-token",value:csrf},
325+
326+
239327
];
240328
return headers;
241329
}
@@ -664,7 +752,7 @@ function getLogs()
664752
function searchProjectsByName()
665753
{
666754
dbg.message("<EXPERIMENTAL>"+"Search Projects By Name [" + projectName + "]",4);
667-
var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=1000&skip=0&q=" + projectName;
755+
var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=" + returnCount+ "&skip=" + returnStart + "&q=" + projectName;
668756
dbg.message("<EXPERIMENTAL>"+"Next URL [" + endPoint + "]",4);
669757
var headers = setHeaders();
670758
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,undefined,headers,true,false);
@@ -711,7 +799,10 @@ function projectWorkflowsInfo()
711799
{
712800

713801
debug("Project Workflows Info");
714-
var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=1000&skip=0&filter=recent&tags=&query=";
802+
var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=" + returnCount+ "&skip=" + returnStart + "&filter=recent&tags=&query=";
803+
804+
805+
715806
debug("Next URL [" + endPoint + "]");
716807
var headers = setHeaders();
717808
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processProjectsResponse,undefined,headers,true,false);
@@ -721,7 +812,7 @@ function projectFlowServicesInfo()
721812
{
722813

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

9971088
}
9981089

1090+
1091+
1092+
9991093
module.exports = {init,
10001094
user,stages,
10011095
searchProject,
@@ -1004,4 +1098,4 @@ module.exports = {init,
10041098
connectorAccounts,getProjectAccountConfig,
10051099
getMonitorInfo,workflowResubmit,
10061100
messagingCreate,messagingStats,messagingDelete,
1007-
vbidAnalysis};
1101+
vbidAnalysis, flowserviceScheduler,flowserviceOption,flowserviceDetails};

0 commit comments

Comments
 (0)