@@ -19,7 +19,9 @@ var url;
1919
2020var authtoken = "" ;
2121var uid = "" ;
22+ var userUid = "" ;
2223var csrf = "" ;
24+ var filterUsername = "" ;
2325var projectId ;
2426var workflowId ;
2527var projectName ;
@@ -71,10 +73,6 @@ function generateUUID(){
7173 return guidstring ;
7274}
7375
74- function debug ( message ) {
75- logger . debug ( "<EXPERIMENTAL> " + message ) ;
76- }
77-
7876function init ( inDomainName , inUsername , inPassword , inTimeout , inPrettyprint ) {
7977
8078 logger . warn ( "EXPERIMENTAL/UNSUPPORTED APIs - USE THESE AT YOUR OWN RISK" ) ;
@@ -90,6 +88,20 @@ function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){
9088}
9189
9290
91+ function getUserList ( inUsername )
92+ {
93+ filterUsername = inUsername ;
94+ finalCall = getUsers ;
95+ loginPhase1 ( ) ;
96+ }
97+
98+ function deleteUser ( inUid )
99+ {
100+ userUid = inUid
101+ finalCall = deleteIntegrationUser ;
102+ loginPhase1 ( ) ;
103+ }
104+
93105function flowserviceDetails ( inProjectId , includeEdgeFlows )
94106{
95107 projectId = inProjectId ;
@@ -98,6 +110,24 @@ function flowserviceDetails(inProjectId,includeEdgeFlows)
98110 loginPhase1 ( ) ;
99111}
100112
113+ function deleteIntegrationUser ( )
114+ {
115+ logger . debug ( "Deleting Integration User [" + userUid + "]" ) ;
116+ var endPoint = "https://" + domainName + "/enterprise/v1/users/" + userUid ;
117+ var body ;
118+ logger . debug ( "Next URL [" + endPoint + "]" ) ;
119+ var headers = setHeaders ( true ) ;
120+ headers . push ( { name :"Accept" , value :"application/json, text/plain, */*" } ) ;
121+ headers . push ( { name :"accept-encoding" , value :"gzip, deflate, br" } ) ;
122+ headers . push ( { name :"content-type" , value :"application/json" } ) ;
123+ headers . push ( { name :"Connection" , value :"keep-alive" } ) ;
124+ headers . push ( { name :"DNT" , value :"1" } ) ;
125+ headers . push ( { name :"Cache-Control" , value :"no-cache" } ) ;
126+ headers . push ( { name :"Origin" , value :"https://" + domainName } ) ;
127+ headers . push ( { name :"Referer" , value :"https://" + domainName + "/" } ) ;
128+ rest_fetch . custom ( endPoint , undefined , undefined , timeout , body , undefined , "DELETE" , processResponse , headers , true , false ) ;
129+ }
130+
101131function processflowDetails ( )
102132{
103133 logger . debug ( "Process FlowService Details - Project [" + projectId + "] Include Edge flows [" + incEdgeFlows + "]" ) ;
@@ -168,6 +198,16 @@ function flowserviceScheduler(inFlowServiceId, inScheduleStatus, inProjectId)
168198 loginPhase1 ( ) ;
169199}
170200
201+ function getUsers ( )
202+ {
203+ logger . debug ( "Getting Integration User [" + username + "]" ) ;
204+ var endPoint = "https://" + domainName + "/enterprise/v1/tenant/users" ;
205+ logger . debug ( "Next URL [" + endPoint + "]" ) ;
206+ var headers = setHeaders ( ) ;
207+ var body ;
208+ rest_fetch . custom ( endPoint , undefined , undefined , timeout , body , undefined , "GET" , processUserListResponse , headers , true , false ) ;
209+ }
210+
171211function processScheduleStatus ( )
172212{
173213 logger . debug ( "Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]" ) ;
@@ -355,15 +395,19 @@ function processMonitorBody()
355395 return body ;
356396}
357397
358- function setHeaders ( )
398+ function setHeaders ( omitAccept )
359399{
360400 var headers = [
361401 { name :"authtoken" , value :authtoken } ,
362- { name :"accept" , value :"application/json" } ,
363402 { name :"X-Requested-With" , value :"XMLHttpRequest" } ,
364403 { name :"X-Request-ID" , value :generateUUID ( ) } ,
365404 { name :"x-csrf-token" , value :csrf } ,
366405 ] ;
406+
407+ if ( omitAccept === undefined || omitAccept === null || omitAccept == false ) {
408+ headers . push ( { name :"accept" , value :"application/json" } ) ;
409+ }
410+
367411 if ( projectId !== undefined && projectId !== null && projectId . length > 0 )
368412 {
369413 headers . push ( { name :"Project_uid" , value :projectId } ) ;
@@ -1046,6 +1090,9 @@ function processProjectsResponse(url,err,body,res){
10461090}
10471091
10481092function processResponse ( url , err , body , res ) {
1093+ if ( err !== undefined && err !== null ) logger . error ( err ) ;
1094+ logger . debug ( "HTTP Response Status [" + res . status + "]" ) ;
1095+ logger . debug ( "HTTP Resposne Status Text [" + res . statusText + "]" ) ;
10491096 if ( res . status == 200 )
10501097 {
10511098 if ( prettyprint == true ) {
@@ -1063,6 +1110,45 @@ function processResponse(url,err,body,res){
10631110 }
10641111}
10651112
1113+
1114+ function processUserListResponse ( url , err , body , res ) {
1115+
1116+ if ( res . status == 200 )
1117+ {
1118+ var jsonObj = { } ;
1119+ jsonObj . output = { } ;
1120+ if ( filterUsername !== undefined && filterUsername !== null && filterUsername . length > 0 ) {
1121+ //Filter down to the right user
1122+ //console.log("**********" + body.output.objects[0].wmic_username);
1123+ for ( var j = 0 ; j < body . output . objects . length ; j ++ ) {
1124+ if ( body . output . objects [ j ] . wmic_username == filterUsername ) {
1125+ var objects = [ ] ;
1126+ objects . push ( body . output . objects [ j ] ) ;
1127+ jsonObj . output . objects = objects ;
1128+ break ;
1129+ }
1130+ }
1131+ }
1132+ else {
1133+ jsonObj = body ;
1134+ }
1135+
1136+ if ( prettyprint == true ) {
1137+ console . log ( JSON . stringify ( jsonObj , null , 4 ) ) ;
1138+ }
1139+ else {
1140+ console . log ( ( JSON . stringify ( jsonObj ) ) ) ;
1141+ }
1142+ }
1143+ else
1144+ {
1145+ if ( jsonObj !== null ) console . log ( ( JSON . stringify ( jsonObj ) ) ) ;
1146+ else logger . warn ( "Failed to login via Software AG Cloud - exiting" ) ;
1147+ process . exit ( 99 ) ;
1148+ }
1149+ }
1150+
1151+
10661152function processUserResponse ( url , err , body , res ) {
10671153 if ( res . status == 200 )
10681154 {
@@ -1163,7 +1249,8 @@ function loginResponse(url,err,body,res){
11631249
11641250
11651251module . exports = { init, help,
1166- user, stages,
1252+ user, getUserList, deleteUser,
1253+ stages,
11671254 searchProject,
11681255 projectDeployments,
11691256 projectWorkflows, projectFlowservices,
0 commit comments