Skip to content

Commit 6f295e6

Browse files
authored
Merge pull request #5 from SoftwareAG/10.12_additional_apis
10.12 additional apis
2 parents c22bfc0 + 718a1a4 commit 6f295e6

File tree

8 files changed

+536
-39
lines changed

8 files changed

+536
-39
lines changed

flowservice.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,39 @@ const rest = require('./rest.js');
88
const dbg = require('./debug.js');
99

1010

11-
var domainName, username,password,timeout;
11+
var domainName, username,password,timeout,prettyprint;
1212
var url;
1313

1414
function debug(message){
1515
dbg.message("<FLOWSERVICE> " + message);
1616
}
1717

18-
function init(inDomainName, inUsername, inPassword,inTimeout,projectId){
18+
function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyPrint,projectId){
1919
domainName = inDomainName;
2020
username = inUsername;
2121
password = inPassword;
2222
timeout = inTimeout;
23+
prettyprint = inPrettyPrint;
24+
2325
url = "https://" + domainName + "/enterprise/v1/rest/projects/" + projectId ;
2426
debug("Username [" + username + "]");
2527
debug("URL [" + url + "]");
2628
debug("Timeout [" + timeout + "]");
2729
}
2830

29-
function processResponse(data,status,filename){
30-
debug("Processing response message");
31-
console.log(JSON.stringify(data));
31+
/**
32+
* Call back function to process REST response
33+
* @param {return data from REST request} data
34+
* @param {status} status
35+
*/
36+
function processResponse(data,status){
37+
if(prettyprint==true){
38+
console.log(JSON.stringify(data,null,4));
39+
}
40+
else{
41+
console.log(JSON.stringify(data));
42+
}
43+
3244
if(status!=0){
3345
process.exit(status);
3446
}

projects.js

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
*/
66

77
const request = require('./rest.js');
8+
const dbg = require('./debug.js');
89

910
var domainName, username,password,timeout;
1011
var prettyprint = false;
1112
var url;
1213

13-
function checkForErrors(inBody)
14-
{
15-
//Error Codes
16-
//Any error response
17-
14+
function debug(message){
15+
dbg.message("<PROJECTS> " + message);
1816
}
1917

18+
2019
function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
2120
domainName = inDomainName;
2221
username = inUsername;
@@ -25,6 +24,9 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
2524
prettyprint = inPrettyprint;
2625

2726
url = "https://" + domainName + "/apis/v1/rest/projects";
27+
debug("Username [" + username + "]");
28+
debug("URL [" + url + "]");
29+
debug("Timeout [" + timeout + "]");
2830
}
2931

3032
/**
@@ -45,37 +47,97 @@ function processResponse(data,status){
4547
}
4648
}
4749

50+
/* Projects */
4851
function list(projectId){
4952

53+
debug("List Projects ID[" + projectId + "]");
5054
if(projectId)url+="/" + projectId;
5155
request.get(url,username,password,timeout,processResponse);
5256
}
5357

54-
function listAssets(projectId){
55-
if(projectId)url+="/" + projectId + "/assets";
56-
request.get(url,username,password,timeout,processResponse);
57-
}
58-
5958
function create(projectName){
59+
debug("Create Project ID[" + projectName + "]");
6060
var data={"name":projectName};
6161
request.post(url,username,password,timeout,data,processResponse);
6262
}
6363

6464
function update(projectId, projectName){
65-
65+
debug("Update Project ID[" + projectId + "] Name[" + projectName + "]");
6666
url += "/" + projectId;
6767
var data={"name":projectName};
6868
request.put(url,username,password,timeout,data,processResponse);
6969
}
7070

7171
function del(projectId){
72-
72+
debug("Create Project ID[" + projectId + "]");
7373
url += "/" + projectId;
7474
var data={};
7575
request.httpDelete(url,username,password,timeout,data,processResponse);
7676
}
7777

78+
/* Project Assets */
79+
function listAssets(projectId){
80+
debug("List Assets [" + projectId + "]");
81+
if(projectId)url+="/" + projectId + "/assets";
82+
request.get(url,username,password,timeout,processResponse);
83+
}
84+
85+
/* Project Params */
86+
function listParam(projectId,paramId){
87+
debug("List Params [" + projectId + "] Param ID [" + paramId + "]");
88+
if(projectId)url+="/" + projectId + "/params";
89+
if(paramId)url +="/" + paramId;
90+
request.get(url,username,password,timeout,processResponse);
91+
}
92+
93+
function createParam(projectId,paramName,paramValue,required,isPassword){
94+
debug("Create Param Project ID[" + projectId + "] Name [" + paramName + "] value ["+paramValue + "] required [" + required + "] isPassword [" + isPassword + "]" );
95+
if(projectId)url+="/" + projectId + "/params";
96+
var data={"key":paramName,"value":paramValue,"required":required,"isPassword":isPassword};
97+
request.post(url,username,password,timeout,data,processResponse);
98+
}
99+
100+
function updateParam(projectId,paramId,paramName,paramValue,required,isPassword){
101+
debug("Update Param ProjectId [" + projectId + "] Param ID[" + paramId + "] Name [" + paramName + "] value ["+paramValue + "] required [" + required + "] isPassword [" + isPassword + "]" );
102+
if(projectId)url+="/" + projectId + "/params";
103+
if(paramId)url +="/" + paramId;
104+
var data={"key":paramName,"value":paramValue,"required":required,"isPassword":isPassword};
105+
request.put(url,username,password,timeout,data,processResponse);
106+
}
107+
108+
function deleteParam(projectId,paramId){
109+
debug("Delete Param ProjectId [" + projectId + "] Param ID[" + paramId + "]");
110+
if(projectId)url+="/" + projectId + "/params";
111+
if(paramId)url +="/" + paramId;
112+
var data={};
113+
request.httpDelete(url,username,password,timeout,data,processResponse);
114+
}
115+
116+
117+
/* Webhook APIs */
118+
function listWebhooks(projectId){
119+
debug("List webhooks ProjectId [" + projectId + "]");
120+
if(projectId)url+="/" + projectId + "/webhook-flows";
121+
request.get(url,username,password,timeout,processResponse);
122+
}
123+
124+
function regenWebhook(projectId,workflowUid){
125+
debug("List webhooks ProjectId [" + projectId + "] workflowUid [" + workflowUid + "]");
126+
if(projectId)url+="/" + projectId + "/webhook-flows";
127+
if(workflowUid)url +="/" + workflowUid + "/reset";
128+
request.put(url,username,password,timeout,{},processResponse);
129+
}
130+
131+
function setWebhookAuth(projectId,workflowUid,authType){
132+
debug("List webhooks ProjectId [" + projectId + "] workflowUid [" + workflowUid + "] auth type [" + authType + "]");
133+
if(projectId)url+="/" + projectId + "/webhook-flows";
134+
if(workflowUid)url +="/" + workflowUid + "/auth";
135+
var data={"auth": authType};
136+
request.post(url,username,password,timeout,data,processResponse);
137+
}
78138

139+
140+
/* Deployment */
79141

80142
/**
81143
* Pushes a deployment to a destination tenant
@@ -86,6 +148,7 @@ function del(projectId){
86148
* @param {assets to publish} assets
87149
*/
88150
function pub(projectId,publishName,targetTenantDomainName,targetUserId,targetUserPassword,assetsJson){
151+
debug("Project Pub ProjectId [" + projectId + "] publishName [" + publishName + "] target Tenant [" + targetTenantDomainName + "]");
89152
//{"output":{"workflows":["fla73a20e13dd6736cf9c355","fl3cfd145262bbc5d44acff3"],"flows":["mapLeads"],"rest_api":[],"soap_api":[],"listener":[],"messaging":[]}}
90153
url += "/" + projectId + "/push";
91154

@@ -111,9 +174,14 @@ function pub(projectId,publishName,targetTenantDomainName,targetUserId,targetUse
111174
*/
112175
function deploy(projectName, version)
113176
{
177+
debug("Project Deploy ProjectName [" + projectName + "] Version [" + version + "]");
114178
url += "/" + projectName + "/deploy";
115179
data={"version":parseInt(version)};
116180
request.post(url,username,password,timeout,data,processResponse);
117181
}
118182

119-
module.exports = { init, list, listAssets, create, update, del, pub, deploy};
183+
module.exports = { init, list, create, update, del,
184+
listAssets, pub, deploy,
185+
createParam,updateParam,listParam,deleteParam,
186+
listWebhooks, regenWebhook, setWebhookAuth
187+
};

recipe.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* webMethods.io CLI
3+
* Copyright 2022 Software AG
4+
* Apache-2.0
5+
*/
6+
7+
const rest = require('./rest.js');
8+
const dbg = require('./debug.js');
9+
10+
11+
var domainName, username,password,timeout,prettyprint;
12+
var url;
13+
14+
function debug(message){
15+
dbg.message("<RECIPE> " + message);
16+
}
17+
18+
function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyPrint){
19+
domainName = inDomainName;
20+
username = inUsername;
21+
password = inPassword;
22+
timeout = inTimeout;
23+
prettyprint = inPrettyPrint;
24+
url = "https://" + domainName + "/apis/v1/rest/recipes" ;
25+
debug("Username [" + username + "]");
26+
debug("URL [" + url + "]");
27+
debug("Timeout [" + timeout + "]");
28+
}
29+
30+
/**
31+
* Call back function to process REST response
32+
* @param {return data from REST request} data
33+
* @param {status} status
34+
*/
35+
function processResponse(data,status){
36+
if(prettyprint==true){
37+
console.log(JSON.stringify(data,null,4));
38+
}
39+
else{
40+
console.log(JSON.stringify(data));
41+
}
42+
43+
if(status!=0){
44+
process.exit(status);
45+
}
46+
}
47+
48+
function create(filename){
49+
debug("Creating Recipe from file [" + filename + "]");
50+
rest.postUploadFile(url,username,password,timeout,undefined,filename,processResponse);
51+
}
52+
53+
function list(recipeUid){
54+
if(recipeUid)url+="/" + recipeUid;
55+
debug("List Recipes [" + recipeUid + "]");
56+
rest.get(url,username,password,timeout,processResponse);
57+
}
58+
59+
60+
function del(recipeUid){
61+
debug("Deleting Recipe with ID [" + recipeUid + "]");
62+
url += "/" + recipeUid;
63+
rest.del(url,username,password,timeout,{},processResponse);
64+
}
65+
66+
module.exports = { init, list, del, create };

0 commit comments

Comments
 (0)